private boolean doesDoorListContain(@Nonnull VillageDoorInfo doorInfoIn) { for (VillageDoorInfo villagedoorinfo : this.doorList) { if (doorInfoIn.getDoorBlockPos().equals(villagedoorinfo.getDoorBlockPos())) { return true; } } return false; }
/** * Resets the task */ public void resetTask() { this.insidePosX = this.doorInfo.getInsideBlockPos().getX(); this.insidePosZ = this.doorInfo.getInsideBlockPos().getZ(); this.doorInfo = null; }
for (VillageDoorInfo villagedoorinfo : this.villageDoorInfoList) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setInteger("X", villagedoorinfo.getDoorBlockPos().getX()); nbttagcompound.setInteger("Y", villagedoorinfo.getDoorBlockPos().getY()); nbttagcompound.setInteger("Z", villagedoorinfo.getDoorBlockPos().getZ()); nbttagcompound.setInteger("IDX", villagedoorinfo.getInsideOffsetX()); nbttagcompound.setInteger("IDZ", villagedoorinfo.getInsideOffsetZ()); nbttagcompound.setInteger("TS", villagedoorinfo.getLastActivityTimestamp()); nbttaglist.appendTag(nbttagcompound);
private VillageDoorInfo findNearestDoor(Village villageIn) { VillageDoorInfo villagedoorinfo = null; int i = Integer.MAX_VALUE; for (VillageDoorInfo villagedoorinfo1 : villageIn.getVillageDoorInfoList()) { int j = villagedoorinfo1.getDistanceSquared(MathHelper.floor(this.theEntity.posX), MathHelper.floor(this.theEntity.posY), MathHelper.floor(this.theEntity.posZ)); if (j < i && !this.doesDoorListContain(villagedoorinfo1)) { villagedoorinfo = villagedoorinfo1; i = j; } } return villagedoorinfo; }
for (int i = 0; i < nbttaglist.tagCount(); ++i) { NBTTagCompound nbttagcompound = nbttaglist.getCompoundTagAt(i); VillageDoorInfo villagedoorinfo = new VillageDoorInfo(new BlockPos(nbttagcompound.getInteger("X"), nbttagcompound.getInteger("Y"), nbttagcompound.getInteger("Z")), nbttagcompound.getInteger("IDX"), nbttagcompound.getInteger("IDZ"), nbttagcompound.getInteger("TS")); this.villageDoorInfoList.add(villagedoorinfo);
/** * Resets the task */ @Override public void resetTask() { if (doorInfo != null && (this.theEntity.getNavigator().noPath() || this.theEntity.getDistanceSq(this.doorInfo.getDoorBlockPos()) < 16.0D)) { this.doorList.add(this.doorInfo); } }
/** * Execute a one shot task or start executing a continuous task */ public void startExecuting() { this.insidePosX = -1; BlockPos blockpos = this.doorInfo.getInsideBlockPos(); int i = blockpos.getX(); int j = blockpos.getY(); int k = blockpos.getZ(); if (this.entityObj.getDistanceSq(blockpos) > 256.0D) { Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockTowards(this.entityObj, 14, 3, new Vec3d((double) i + 0.5D, (double) j, (double) k + 0.5D)); if (vec3d != null) { this.entityObj.getNavigator().tryMoveToXYZ(vec3d.x, vec3d.y, vec3d.z, 1.0D); } } else { this.entityObj.getNavigator().tryMoveToXYZ((double) i + 0.5D, (double) j, (double) k + 0.5D, 1.0D); } } }
/** * Returns whether an in-progress EntityAIBase should continue executing */ @Override public boolean shouldContinueExecuting() { if (this.theEntity.getNavigator().noPath() || this.doorInfo == null) { return false; } else { float f = this.theEntity.width + 4.0F; return this.theEntity.getDistanceSq(this.doorInfo.getDoorBlockPos()) > (double) (f * f); } }
/** * Returns true if the village has a door in the specified chunk. */ public static boolean isVillageDoorInChunk(Village village, Chunk chunk) { int centerX = (chunk.x << 4) + 8; int centerZ = (chunk.z << 4) + 8; if (village.isAnnihilated()) { return true; } for (Object doorInfo : village.getVillageDoorInfoList()) { BlockPos door = ((VillageDoorInfo) doorInfo).getDoorBlockPos(); if ((centerX - door.getX())*(centerX - door.getX()) + (centerZ - door.getZ())*(centerZ - door.getZ()) <= 10*10) { return true; } } return false; } }
boolean flag = pathnavigateground.getEnterDoors(); pathnavigateground.setBreakDoors(false); this.entityPathNavigate = pathnavigateground.getPathToPos(this.doorInfo.getDoorBlockPos()); pathnavigateground.setBreakDoors(flag); Vec3d vec3d = RandomPositionGenerator.findRandomTargetBlockTowards(this.theEntity, 10, 7, new Vec3d((double) this.doorInfo.getDoorBlockPos().getX(), (double) this.doorInfo.getDoorBlockPos().getY(), (double) this.doorInfo.getDoorBlockPos().getZ()));