Search in sources :

Example 1 with Chicken

use of org.spongepowered.api.entity.living.animal.Chicken in project Skree by Skelril.

the class SkyWarsInstance method spawnChickens.

private void spawnChickens() {
    Vector3i bvMax = getRegion().getMaximumPoint();
    Vector3i bvMin = getRegion().getMinimumPoint();
    for (int i = 0; i < getPlayers(PARTICIPANT).size(); ++i) {
        Location<World> testLoc = new Location<>(getRegion().getExtent(), Probability.getRangedRandom(bvMin.getX(), bvMax.getX()), bvMax.getY() - 10, Probability.getRangedRandom(bvMin.getZ(), bvMax.getZ()));
        Vector2d testPos = new Vector2d(testLoc.getX(), testLoc.getZ());
        Vector2d originPos = new Vector2d(startingLocation.getX(), startingLocation.getZ());
        if (testPos.distanceSquared(originPos) >= 70 * 70) {
            --i;
            continue;
        }
        Chicken chicken = (Chicken) testLoc.getExtent().createEntity(EntityTypes.CHICKEN, testLoc.getPosition());
        chicken.offer(Keys.PERSISTS, false);
        testLoc.getExtent().spawnEntity(chicken, Cause.source(SpawnCause.builder().type(SpawnTypes.PLUGIN).build()).build());
    }
}
Also used : Vector2d(com.flowpowered.math.vector.Vector2d) Vector3i(com.flowpowered.math.vector.Vector3i) Chicken(org.spongepowered.api.entity.living.animal.Chicken) World(org.spongepowered.api.world.World) Location(org.spongepowered.api.world.Location)

Aggregations

Vector2d (com.flowpowered.math.vector.Vector2d)1 Vector3i (com.flowpowered.math.vector.Vector3i)1 Chicken (org.spongepowered.api.entity.living.animal.Chicken)1 Location (org.spongepowered.api.world.Location)1 World (org.spongepowered.api.world.World)1