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);
}
}
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;
}
}
}
}
}
}
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;
}
}
}
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;
}
}
}
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;
}
}
}
}
}
}
Aggregations