Search in sources :

Example 6 with Village

use of net.minecraft.village.Village in project DynamicSurroundings by OreCruncher.

the class EnvironmentService method tickEvent.

@SubscribeEvent
public void tickEvent(@Nonnull final TickEvent.PlayerTickEvent event) {
    if (event.phase == Phase.END && event.side == Side.SERVER) {
        final EntityPlayer player = event.player;
        final VillageCollection villageCollection = player.getEntityWorld().getVillageCollection();
        boolean inVillage = false;
        final List<Village> villages = villageCollection.getVillageList();
        if (villages.size() > 0) {
            final BlockPos pos = player.getPosition();
            for (final Village v : villages) if (v.isBlockPosWithinSqVillageRadius(pos)) {
                inVillage = true;
                break;
            }
        }
        final PacketEnvironment packet = new PacketEnvironment(inVillage);
        Network.sendToPlayer((EntityPlayerMP) player, packet);
    }
}
Also used : Village(net.minecraft.village.Village) PacketEnvironment(org.orecruncher.dsurround.network.PacketEnvironment) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) VillageCollection(net.minecraft.village.VillageCollection) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 7 with Village

use of net.minecraft.village.Village in project kull by Sxmurai.

the class EntityAIMoveThroughVillage method shouldExecute.

/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute() {
    this.resizeDoorList();
    if (this.isNocturnal && this.theEntity.worldObj.isDaytime()) {
        return false;
    } else {
        Village village = this.theEntity.worldObj.getVillageCollection().getNearestVillage(new BlockPos(this.theEntity), 0);
        if (village == null) {
            return false;
        } else {
            this.doorInfo = this.findNearestDoor(village);
            if (this.doorInfo == null) {
                return false;
            } else {
                PathNavigateGround pathnavigateground = (PathNavigateGround) this.theEntity.getNavigator();
                boolean flag = pathnavigateground.getEnterDoors();
                pathnavigateground.setBreakDoors(false);
                this.entityPathNavigate = pathnavigateground.getPathToPos(this.doorInfo.getDoorBlockPos());
                pathnavigateground.setBreakDoors(flag);
                if (this.entityPathNavigate != null) {
                    return true;
                } else {
                    Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockTowards(this.theEntity, 10, 7, new Vec3((double) this.doorInfo.getDoorBlockPos().getX(), (double) this.doorInfo.getDoorBlockPos().getY(), (double) this.doorInfo.getDoorBlockPos().getZ()));
                    if (vec3 == null) {
                        return false;
                    } else {
                        pathnavigateground.setBreakDoors(false);
                        this.entityPathNavigate = this.theEntity.getNavigator().getPathToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord);
                        pathnavigateground.setBreakDoors(flag);
                        return this.entityPathNavigate != null;
                    }
                }
            }
        }
    }
}
Also used : Village(net.minecraft.village.Village) Vec3(net.minecraft.util.Vec3) BlockPos(net.minecraft.util.BlockPos) PathNavigateGround(net.minecraft.pathfinding.PathNavigateGround)

Example 8 with Village

use of net.minecraft.village.Village in project kull by Sxmurai.

the class EntityAIRestrictOpenDoor method shouldExecute.

/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute() {
    if (this.entityObj.worldObj.isDaytime()) {
        return false;
    } else {
        BlockPos blockpos = new BlockPos(this.entityObj);
        Village village = this.entityObj.worldObj.getVillageCollection().getNearestVillage(blockpos, 16);
        if (village == null) {
            return false;
        } else {
            this.frontDoor = village.getNearestDoor(blockpos);
            return this.frontDoor == null ? false : (double) this.frontDoor.getDistanceToInsideBlockSq(blockpos) < 2.25D;
        }
    }
}
Also used : Village(net.minecraft.village.Village) BlockPos(net.minecraft.util.BlockPos)

Example 9 with Village

use of net.minecraft.village.Village in project UtilityClient2 by Utility-Client.

the class EntityAIRestrictOpenDoor method shouldExecute.

/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute() {
    if (this.entityObj.worldObj.isDaytime()) {
        return false;
    } else {
        BlockPos blockpos = new BlockPos(this.entityObj);
        Village village = this.entityObj.worldObj.getVillageCollection().getNearestVillage(blockpos, 16);
        if (village == null) {
            return false;
        } else {
            this.frontDoor = village.getNearestDoor(blockpos);
            return this.frontDoor == null ? false : (double) this.frontDoor.getDistanceToInsideBlockSq(blockpos) < 2.25D;
        }
    }
}
Also used : Village(net.minecraft.village.Village) BlockPos(net.minecraft.util.BlockPos)

Example 10 with Village

use of net.minecraft.village.Village in project UtilityClient2 by Utility-Client.

the class EntityAIMoveThroughVillage method shouldExecute.

/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute() {
    this.resizeDoorList();
    if (this.isNocturnal && this.theEntity.worldObj.isDaytime()) {
        return false;
    } else {
        Village village = this.theEntity.worldObj.getVillageCollection().getNearestVillage(new BlockPos(this.theEntity), 0);
        if (village == null) {
            return false;
        } else {
            this.doorInfo = this.findNearestDoor(village);
            if (this.doorInfo == null) {
                return false;
            } else {
                PathNavigateGround pathnavigateground = (PathNavigateGround) this.theEntity.getNavigator();
                boolean flag = pathnavigateground.getEnterDoors();
                pathnavigateground.setBreakDoors(false);
                this.entityPathNavigate = pathnavigateground.getPathToPos(this.doorInfo.getDoorBlockPos());
                pathnavigateground.setBreakDoors(flag);
                if (this.entityPathNavigate != null) {
                    return true;
                } else {
                    Vec3 vec3 = RandomPositionGenerator.findRandomTargetBlockTowards(this.theEntity, 10, 7, new Vec3((double) this.doorInfo.getDoorBlockPos().getX(), (double) this.doorInfo.getDoorBlockPos().getY(), (double) this.doorInfo.getDoorBlockPos().getZ()));
                    if (vec3 == null) {
                        return false;
                    } else {
                        pathnavigateground.setBreakDoors(false);
                        this.entityPathNavigate = this.theEntity.getNavigator().getPathToXYZ(vec3.xCoord, vec3.yCoord, vec3.zCoord);
                        pathnavigateground.setBreakDoors(flag);
                        return this.entityPathNavigate != null;
                    }
                }
            }
        }
    }
}
Also used : Village(net.minecraft.village.Village) Vec3(net.minecraft.util.Vec3) BlockPos(net.minecraft.util.BlockPos) PathNavigateGround(net.minecraft.pathfinding.PathNavigateGround)

Aggregations

Village (net.minecraft.village.Village)14 BlockPos (net.minecraft.util.math.BlockPos)7 BlockPos (net.minecraft.util.BlockPos)6 PathNavigateGround (net.minecraft.pathfinding.PathNavigateGround)5 Vec3 (net.minecraft.util.Vec3)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 Vec3d (net.minecraft.util.math.Vec3d)2 VillageCollection (net.minecraft.village.VillageCollection)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 ChunkCoordinates (net.minecraft.util.ChunkCoordinates)1 VillageDoorInfo (net.minecraft.village.VillageDoorInfo)1 PacketEnvironment (org.blockartistry.DynSurround.network.PacketEnvironment)1 PacketEnvironment (org.orecruncher.dsurround.network.PacketEnvironment)1 Overwrite (org.spongepowered.asm.mixin.Overwrite)1