本文整理汇总了Java中net.minecraft.village.Village.isInRange方法的典型用法代码示例。如果您正苦于以下问题:Java Village.isInRange方法的具体用法?Java Village.isInRange怎么用?Java Village.isInRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.village.Village
的用法示例。
在下文中一共展示了Village.isInRange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: okToSpawnNearVillage
import net.minecraft.village.Village; //导入方法依赖的package包/类
public boolean okToSpawnNearVillage(int distanceToLook) {
World world = this.worldObj;
int x = (int) this.posX;
int z = (int) this.posZ;
int surfaceY = world.getHeightValue(x, z);
Village v = world.villageCollectionObj.findNearestVillage(x, surfaceY, z, distanceToLook);
if (v == null) {
return false;
}
int r = v.getVillageRadius();
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(v.getCenter().posX - r, surfaceY - 20, v.getCenter().posZ - r,
v.getCenter().posX + r, surfaceY + 35, v.getCenter().posZ + r);
int spawnedGuards = world.getEntitiesWithinAABB(EntityGuard.class, box).size();
// LogHelper.info("GuardSpawn: Found village at: " + v.getCenter().posX + " " + v.getCenter().posY
// + " " + v.getCenter().posZ + " with " + spawnedGuards + " Guards");
if (v.isInRange(x, surfaceY, z) && spawnedGuards < BALANCE.MOBPROP.GUARD_MAX_PER_VILLAGE) {
setHomeArea(v.getCenter().posX, v.getCenter().posY, v.getCenter().posZ, r);
setFoundHome();
return true;
}
else
return false;
}
示例2: okToSpawnNearVillage
import net.minecraft.village.Village; //导入方法依赖的package包/类
public boolean okToSpawnNearVillage(EntityJoinWorldEvent event, int distanceToLook) {
World world = event.world;
int x = (int) event.entity.posX;
int z = (int) event.entity.posZ;
int surfaceY = world.getHeightValue(x, z);
Village v = world.villageCollectionObj.findNearestVillage(x, surfaceY, z, distanceToLook);
if (v == null) {
return false;
}
int r = v.getVillageRadius();
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(v.getCenter().posX - r, surfaceY - 20, v.getCenter().posZ - r,
v.getCenter().posX + r, surfaceY + 35, v.getCenter().posZ + r);
int spawnedGuards = world.getEntitiesWithinAABB(EntityGuard.class, box).size();
// LogHelper.info("GuardSpawn: Found village at: " + v.getCenter().posX + " " + v.getCenter().posY
// + " " + v.getCenter().posZ + " with " + spawnedGuards + " Guards");
if (v.isInRange(x, surfaceY, z) && spawnedGuards < BALANCE.MOBPROP.GUARD_MAX_PER_VILLAGE) {
EntityGuard guard = (EntityGuard) event.entity;
if (guard instanceof EntityGuard) {
guard.setHomeArea(v.getCenter().posX, v.getCenter().posY, v.getCenter().posZ, r);
guard.setFoundHome();
return true;
}
}
return false;
}
示例3: addSurfaceEntities
import net.minecraft.village.Village; //导入方法依赖的package包/类
/**
* Generates entities
*
* @param world World
* @param random Random
* @param x xCoord
* @param z ZCoord
*/
private void addSurfaceEntities(World world, Random random, int x, int z) {
int surfaceY = world.getHeightValue(x, z);
if (world.villageCollectionObj == null)
return;
Village v = world.villageCollectionObj.findNearestVillage(x, surfaceY, z, 16);
if (v == null) {
return;
}
int r = v.getVillageRadius();
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(v.getCenter().posX - r, surfaceY - 20, v.getCenter().posZ - r,
v.getCenter().posX + r, surfaceY + 35, v.getCenter().posZ + r);
int spawnedGuards = world.getEntitiesWithinAABB(EntityGuard.class, box).size();
// if (spawnedGuards < BALANCE.MOBPROP.GUARD_MAX_PER_VILLAGE){
// LogHelper.info("WorldGen: Found village at: " + v.getCenter().posX + " " + v.getCenter().posY
// + " " + v.getCenter().posZ + " with " + spawnedGuards + " Guards");
// }
// All guards are currently spawning at the center of the village
for (int i = 1; i < (BALANCE.MOBPROP.GUARD_MAX_PER_VILLAGE * 2) && spawnedGuards < BALANCE.MOBPROP.GUARD_MAX_PER_VILLAGE; i++) {
int x1 = v.getCenter().posX + world.rand.nextInt((int) (1.2 * r)) - (int) (0.6 * r);
int z1 = v.getCenter().posZ + world.rand.nextInt((int) (1.2 * r)) - (int) (0.6 * r);
// Don't spawn in well
int xFromCenter = MathHelper.abs_int(v.getCenter().posX - x1);
int zFromCenter = MathHelper.abs_int(v.getCenter().posZ - z1);
if (xFromCenter < 3 && zFromCenter < 3)
continue;
int y1 = world.getHeightValue(x1, z1);
if (v.isInRange(x1, y1, z1)) {
// LogHelper.info("WorldGen: going to spawn Guard!");
EntityGuard guard = EntityGuard.createGuardTypePerBiome(world, x, z);
// Entity e = EntityList.createEntityByName(EntityGuard.getFullName(), world);
if (guard == null){
LogHelper.error("WorldGen: createGuardTypePerBiome returned null!");
return;
}
guard.setLocationAndAngles(x1, y1, z1, 0.0F, 0.0F);
guard.setFoundHome();
if (guard.getCanSpawnHere()) {
guard.setHomeArea(v.getCenter().posX, v.getCenter().posY, v.getCenter().posZ, r);
// guard.setGuardTypePerBiome(world);
world.spawnEntityInWorld(guard);
// LogHelper.info("WorldGen: Spawned guard at: " + x1 + " " + y1 + " " + z1);
spawnedGuards++;
} else {
guard.setDead();
}
}
}
}