Update CraftBukkit to Minecraft 1.3.1
This commit is contained in:
committed by
Travis Watkins
parent
08e2923bd4
commit
a43d621c01
@@ -36,18 +36,16 @@ public final class SpawnerCreature {
|
||||
|
||||
protected static final Class[] a = new Class[] { EntitySpider.class, EntityZombie.class, EntitySkeleton.class};
|
||||
|
||||
public SpawnerCreature() {}
|
||||
|
||||
protected static ChunkPosition getRandomPosition(World world, int i, int j) {
|
||||
Chunk chunk = world.getChunkAt(i, j);
|
||||
int k = i * 16 + world.random.nextInt(16);
|
||||
int l = world.random.nextInt(chunk == null ? 128 : Math.max(128, chunk.g()));
|
||||
int i1 = j * 16 + world.random.nextInt(16);
|
||||
int l = j * 16 + world.random.nextInt(16);
|
||||
int i1 = world.random.nextInt(chunk == null ? world.L() : chunk.h() + 16 - 1);
|
||||
|
||||
return new ChunkPosition(k, l, i1);
|
||||
return new ChunkPosition(k, i1, l);
|
||||
}
|
||||
|
||||
public static final int spawnEntities(World world, boolean flag, boolean flag1) {
|
||||
public static final int spawnEntities(WorldServer worldserver, boolean flag, boolean flag1) {
|
||||
if (!flag && !flag1) {
|
||||
return 0;
|
||||
} else {
|
||||
@@ -59,8 +57,8 @@ public final class SpawnerCreature {
|
||||
int i;
|
||||
int j;
|
||||
|
||||
for (i = 0; i < world.players.size(); ++i) {
|
||||
EntityHuman entityhuman = (EntityHuman) world.players.get(i);
|
||||
for (i = 0; i < worldserver.players.size(); ++i) {
|
||||
EntityHuman entityhuman = (EntityHuman) worldserver.players.get(i);
|
||||
int k = MathHelper.floor(entityhuman.locX / 16.0D);
|
||||
|
||||
j = MathHelper.floor(entityhuman.locZ / 16.0D);
|
||||
@@ -83,7 +81,7 @@ public final class SpawnerCreature {
|
||||
}
|
||||
|
||||
i = 0;
|
||||
ChunkCoordinates chunkcoordinates = world.getSpawn();
|
||||
ChunkCoordinates chunkcoordinates = worldserver.getSpawn();
|
||||
java.util.ArrayList<EntryBase> b = chunkCoords.entries(); // CraftBukkit
|
||||
EnumCreatureType[] aenumcreaturetype = EnumCreatureType.values();
|
||||
|
||||
@@ -96,13 +94,13 @@ public final class SpawnerCreature {
|
||||
int limit = 0;
|
||||
switch (enumcreaturetype) {
|
||||
case MONSTER:
|
||||
limit = world.getWorld().getMonsterSpawnLimit();
|
||||
limit = worldserver.getWorld().getMonsterSpawnLimit();
|
||||
break;
|
||||
case CREATURE:
|
||||
limit = world.getWorld().getAnimalSpawnLimit();
|
||||
limit = worldserver.getWorld().getAnimalSpawnLimit();
|
||||
break;
|
||||
case WATER_CREATURE:
|
||||
limit = world.getWorld().getWaterAnimalSpawnLimit();
|
||||
limit = worldserver.getWorld().getWaterAnimalSpawnLimit();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -111,20 +109,20 @@ public final class SpawnerCreature {
|
||||
}
|
||||
// CraftBukkit end
|
||||
|
||||
if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && world.a(enumcreaturetype.a()) <= limit * b.size() / 256) { // CraftBukkit - use per-world limits
|
||||
if ((!enumcreaturetype.d() || flag1) && (enumcreaturetype.d() || flag) && worldserver.a(enumcreaturetype.a()) <= limit * b.size() / 256) { // CraftBukkit - use per-world limits
|
||||
|
||||
// CraftBukkit start
|
||||
label108:
|
||||
for (EntryBase base : b) {
|
||||
ChunkEntry entry = (SpawnerCreature.ChunkEntry) base;
|
||||
if (!entry.spawn) {
|
||||
ChunkPosition chunkposition = getRandomPosition(world, entry.getX(), entry.getZ());
|
||||
ChunkPosition chunkposition = getRandomPosition(worldserver, entry.getX(), entry.getZ());
|
||||
// CraftBukkit end
|
||||
int k1 = chunkposition.x;
|
||||
int l1 = chunkposition.y;
|
||||
int i2 = chunkposition.z;
|
||||
|
||||
if (!world.e(k1, l1, i2) && world.getMaterial(k1, l1, i2) == enumcreaturetype.c()) {
|
||||
if (!worldserver.s(k1, l1, i2) && worldserver.getMaterial(k1, l1, i2) == enumcreaturetype.c()) {
|
||||
int j2 = 0;
|
||||
int k2 = 0;
|
||||
|
||||
@@ -139,15 +137,15 @@ public final class SpawnerCreature {
|
||||
while (true) {
|
||||
if (k3 < 4) {
|
||||
label101: {
|
||||
l2 += world.random.nextInt(b1) - world.random.nextInt(b1);
|
||||
i3 += world.random.nextInt(1) - world.random.nextInt(1);
|
||||
j3 += world.random.nextInt(b1) - world.random.nextInt(b1);
|
||||
if (a(enumcreaturetype, world, l2, i3, j3)) {
|
||||
l2 += worldserver.random.nextInt(b1) - worldserver.random.nextInt(b1);
|
||||
i3 += worldserver.random.nextInt(1) - worldserver.random.nextInt(1);
|
||||
j3 += worldserver.random.nextInt(b1) - worldserver.random.nextInt(b1);
|
||||
if (a(enumcreaturetype, worldserver, l2, i3, j3)) {
|
||||
float f = (float) l2 + 0.5F;
|
||||
float f1 = (float) i3;
|
||||
float f2 = (float) j3 + 0.5F;
|
||||
|
||||
if (world.findNearbyPlayer((double) f, (double) f1, (double) f2, 24.0D) == null) {
|
||||
if (worldserver.findNearbyPlayer((double) f, (double) f1, (double) f2, 24.0D) == null) {
|
||||
float f3 = f - (float) chunkcoordinates.x;
|
||||
float f4 = f1 - (float) chunkcoordinates.y;
|
||||
float f5 = f2 - (float) chunkcoordinates.z;
|
||||
@@ -155,7 +153,7 @@ public final class SpawnerCreature {
|
||||
|
||||
if (f6 >= 576.0F) {
|
||||
if (biomemeta == null) {
|
||||
biomemeta = world.a(enumcreaturetype, l2, i3, j3);
|
||||
biomemeta = worldserver.a(enumcreaturetype, l2, i3, j3);
|
||||
if (biomemeta == null) {
|
||||
break label101;
|
||||
}
|
||||
@@ -164,22 +162,19 @@ public final class SpawnerCreature {
|
||||
EntityLiving entityliving;
|
||||
|
||||
try {
|
||||
entityliving = (EntityLiving) biomemeta.a.getConstructor(new Class[] { World.class}).newInstance(new Object[] { world});
|
||||
entityliving = (EntityLiving) biomemeta.b.getConstructor(new Class[] { World.class}).newInstance(new Object[] { worldserver});
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
return i;
|
||||
}
|
||||
|
||||
// CraftBukkit - made slimes spawn less often in FLAT worlds.
|
||||
if (entityliving instanceof EntitySlime && world.worldData.getType() == WorldType.FLAT && world.random.nextInt(200) == 0) return 0;
|
||||
|
||||
entityliving.setPositionRotation((double) f, (double) f1, (double) f2, world.random.nextFloat() * 360.0F, 0.0F);
|
||||
entityliving.setPositionRotation((double) f, (double) f1, (double) f2, worldserver.random.nextFloat() * 360.0F, 0.0F);
|
||||
if (entityliving.canSpawn()) {
|
||||
++j2;
|
||||
// CraftBukkit - added a reason for spawning this creature
|
||||
world.addEntity(entityliving, SpawnReason.NATURAL);
|
||||
a(entityliving, world, f, f1, f2);
|
||||
if (j2 >= entityliving.q()) {
|
||||
worldserver.addEntity(entityliving, SpawnReason.NATURAL);
|
||||
a(entityliving, worldserver, f, f1, f2);
|
||||
if (j2 >= entityliving.bl()) {
|
||||
continue label108;
|
||||
}
|
||||
}
|
||||
@@ -210,11 +205,13 @@ public final class SpawnerCreature {
|
||||
|
||||
public static boolean a(EnumCreatureType enumcreaturetype, World world, int i, int j, int k) {
|
||||
if (enumcreaturetype.c() == Material.WATER) {
|
||||
return world.getMaterial(i, j, k).isLiquid() && !world.e(i, j + 1, k);
|
||||
return world.getMaterial(i, j, k).isLiquid() && !world.s(i, j + 1, k);
|
||||
} else if (!world.t(i, j - 1, k)) {
|
||||
return false;
|
||||
} else {
|
||||
int l = world.getTypeId(i, j - 1, k);
|
||||
|
||||
return Block.g(l) && l != Block.BEDROCK.id && !world.e(i, j, k) && !world.getMaterial(i, j, k).isLiquid() && !world.e(i, j + 1, k);
|
||||
return l != Block.BEDROCK.id && !world.s(i, j, k) && !world.getMaterial(i, j, k).isLiquid() && !world.s(i, j + 1, k);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +232,7 @@ public final class SpawnerCreature {
|
||||
|
||||
entityocelot.setPositionRotation((double) f, (double) f1, (double) f2, entityliving.yaw, 0.0F);
|
||||
entityocelot.setAge(-24000);
|
||||
world.addEntity(entityocelot, SpawnReason.NATURAL); // CraftBukkit - SpawnReason
|
||||
world.addEntity(entityocelot, SpawnReason.NATURAL); // CraftBukkit - added SpawnReason
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -246,7 +243,7 @@ public final class SpawnerCreature {
|
||||
if (!list.isEmpty()) {
|
||||
while (random.nextFloat() < biomebase.f()) {
|
||||
BiomeMeta biomemeta = (BiomeMeta) WeightedRandom.a(world.random, (Collection) list);
|
||||
int i1 = biomemeta.b + random.nextInt(1 + biomemeta.c - biomemeta.b);
|
||||
int i1 = biomemeta.c + random.nextInt(1 + biomemeta.d - biomemeta.c);
|
||||
int j1 = i + random.nextInt(k);
|
||||
int k1 = j + random.nextInt(l);
|
||||
int l1 = j1;
|
||||
@@ -256,7 +253,7 @@ public final class SpawnerCreature {
|
||||
boolean flag = false;
|
||||
|
||||
for (int k2 = 0; !flag && k2 < 4; ++k2) {
|
||||
int l2 = world.g(j1, k1);
|
||||
int l2 = world.h(j1, k1);
|
||||
|
||||
if (a(EnumCreatureType.CREATURE, world, j1, l2, k1)) {
|
||||
float f = (float) j1 + 0.5F;
|
||||
@@ -266,7 +263,7 @@ public final class SpawnerCreature {
|
||||
EntityLiving entityliving;
|
||||
|
||||
try {
|
||||
entityliving = (EntityLiving) biomemeta.a.getConstructor(new Class[] { World.class}).newInstance(new Object[] { world});
|
||||
entityliving = (EntityLiving) biomemeta.b.getConstructor(new Class[] { World.class}).newInstance(new Object[] { world});
|
||||
} catch (Exception exception) {
|
||||
exception.printStackTrace();
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user