/** * Finds the nearest village, but only the given coordinates are withing it's bounding box plus the given the distance. */ public static @Nullable VampirismVillage getNearestVillage(World w, BlockPos pos, int r) { Village v = w.villageCollection.getNearestVillage(pos, r); if (v != null) { return VampirismVillage.get(v); } return null; }
@Override public boolean getCanSpawnHere() { if (isGettingSundamage(true) || (world.isDaytime() && rand.nextInt(5) != 0)) return false; if (isGettingGarlicDamage(true) != EnumStrength.NONE) return false; if (world.getVillageCollection().getNearestVillage(getPosition(), 1) != null) { if (getRNG().nextInt(60) != 0) { return false; } } return super.getCanSpawnHere() && (!restrictedSpawn || getCanSpawnHereRestricted()); }
return world.getVillageCollection().getNearestVillage(world.getHeight(new BlockPos(i << 4, 0, j << 4)), 20) == null;
@Override public boolean shouldExecute() { BlockPos blockpos = new BlockPos(this.entityObj); if (this.entityObj.getEntityWorld().isDaytime() && this.entityObj.getEntityWorld().provider.hasSkyLight()) { if (this.entityObj.getRNG().nextInt(50) != 0) { return false; } else if (this.insidePosX != -1 && this.entityObj.getDistanceSq((double) this.insidePosX, this.entityObj.posY, (double) this.insidePosZ) < 4.0D) { return false; } else { Village village = this.entityObj.getEntityWorld().getVillageCollection().getNearestVillage(blockpos, 14); if (village == null) { return false; } else { this.doorInfo = village.getDoorInfo(blockpos); return this.doorInfo != null; } } } else { return false; } }
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { BlockPos pos = sender.getPosition(); World world = sender.getEntityWorld(); int dX, dZ; int range = 64; Village closest = world.villageCollection.getNearestVillage(pos, range); if (closest == null) { UtilChat.addChatMessage(sender, "command.villageinfo.none"); } else { int doors = closest.getNumVillageDoors(); int villagers = closest.getNumVillagers(); UtilChat.addChatMessage(sender, UtilChat.lang("command.villageinfo.popul") + String.format("%d", villagers)); UtilChat.addChatMessage(sender, UtilChat.lang("command.villageinfo.doors") + String.format("%d", doors)); if (sender instanceof EntityPlayer) { // command blocks/server controllers do not have reputation EntityPlayer player = (EntityPlayer) sender; int rep = closest.getPlayerReputation(player.getUniqueID()); UtilChat.addChatMessage(sender, player.getName() + " " + UtilChat.lang("command.villageinfo.reputation") + String.format("%d", rep)); } dX = pos.getX() - closest.getCenter().getX(); dZ = pos.getZ() - closest.getCenter().getZ(); int dist = MathHelper.floor(Math.sqrt(dX * dX + dZ * dZ)); UtilChat.addChatMessage(sender, UtilChat.lang("command.villageinfo.center") + String.format("%d", dist)); } } }
&& world.getVillageCollection().getNearestVillage(pos, Configurations.gameplay.workingRangeTownHallChunks * BLOCKS_PER_CHUNK) != null)
} else { @Nullable Village village = this.theEntity.getEntityWorld().getVillageCollection().getNearestVillage(new BlockPos(this.theEntity), 0);