summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/net/minecraft/server/ChunkProviderGenerate.java567
-rw-r--r--src/main/java/net/minecraft/server/ChunkProviderServer.java2
-rw-r--r--src/main/java/net/minecraft/server/EntityCreature.java4
-rw-r--r--src/main/java/net/minecraft/server/ItemBlock.java4
-rw-r--r--src/main/java/net/minecraft/server/LongHashtable.java2
-rw-r--r--src/main/java/net/minecraft/server/MinecraftServer.java12
-rw-r--r--src/main/java/net/minecraft/server/NetServerHandler.java12
-rw-r--r--src/main/java/net/minecraft/server/World.java15
-rw-r--r--src/main/java/net/minecraft/server/WorldServer.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftServer.java4
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftWorld.java6
-rw-r--r--src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java28
12 files changed, 634 insertions, 26 deletions
diff --git a/src/main/java/net/minecraft/server/ChunkProviderGenerate.java b/src/main/java/net/minecraft/server/ChunkProviderGenerate.java
new file mode 100644
index 00000000..a1987ce3
--- /dev/null
+++ b/src/main/java/net/minecraft/server/ChunkProviderGenerate.java
@@ -0,0 +1,567 @@
+package net.minecraft.server;
+
+import java.util.Random;
+
+public class ChunkProviderGenerate implements IChunkProvider {
+
+ private Random j;
+ private NoiseGeneratorOctaves k;
+ private NoiseGeneratorOctaves l;
+ private NoiseGeneratorOctaves m;
+ private NoiseGeneratorOctaves n;
+ private NoiseGeneratorOctaves o;
+ public NoiseGeneratorOctaves a;
+ public NoiseGeneratorOctaves b;
+ public NoiseGeneratorOctaves c;
+ private World p;
+ private double[] q;
+ private double[] r = new double[256];
+ private double[] s = new double[256];
+ private double[] t = new double[256];
+ private MapGenBase u = new MapGenCaves();
+ private BiomeBase[] v;
+ double[] d;
+ double[] e;
+ double[] f;
+ double[] g;
+ double[] h;
+ int[][] i = new int[32][32];
+ private double[] w;
+
+ public ChunkProviderGenerate(World world, long i) {
+ this.p = world;
+ this.j = new Random(i);
+ this.k = new NoiseGeneratorOctaves(this.j, 16);
+ this.l = new NoiseGeneratorOctaves(this.j, 16);
+ this.m = new NoiseGeneratorOctaves(this.j, 8);
+ this.n = new NoiseGeneratorOctaves(this.j, 4);
+ this.o = new NoiseGeneratorOctaves(this.j, 4);
+ this.a = new NoiseGeneratorOctaves(this.j, 10);
+ this.b = new NoiseGeneratorOctaves(this.j, 16);
+ this.c = new NoiseGeneratorOctaves(this.j, 8);
+ }
+
+ public void a(int i, int j, byte[] abyte, BiomeBase[] abiomebase, double[] adouble) {
+ byte b0 = 4;
+ byte b1 = 64;
+ int k = b0 + 1;
+ byte b2 = 17;
+ int l = b0 + 1;
+
+ this.q = this.a(this.q, i * b0, 0, j * b0, k, b2, l);
+
+ for (int i1 = 0; i1 < b0; ++i1) {
+ for (int j1 = 0; j1 < b0; ++j1) {
+ for (int k1 = 0; k1 < 16; ++k1) {
+ double d0 = 0.125D;
+ double d1 = this.q[((i1 + 0) * l + j1 + 0) * b2 + k1 + 0];
+ double d2 = this.q[((i1 + 0) * l + j1 + 1) * b2 + k1 + 0];
+ double d3 = this.q[((i1 + 1) * l + j1 + 0) * b2 + k1 + 0];
+ double d4 = this.q[((i1 + 1) * l + j1 + 1) * b2 + k1 + 0];
+ double d5 = (this.q[((i1 + 0) * l + j1 + 0) * b2 + k1 + 1] - d1) * d0;
+ double d6 = (this.q[((i1 + 0) * l + j1 + 1) * b2 + k1 + 1] - d2) * d0;
+ double d7 = (this.q[((i1 + 1) * l + j1 + 0) * b2 + k1 + 1] - d3) * d0;
+ double d8 = (this.q[((i1 + 1) * l + j1 + 1) * b2 + k1 + 1] - d4) * d0;
+
+ for (int l1 = 0; l1 < 8; ++l1) {
+ double d9 = 0.25D;
+ double d10 = d1;
+ double d11 = d2;
+ double d12 = (d3 - d1) * d9;
+ double d13 = (d4 - d2) * d9;
+
+ for (int i2 = 0; i2 < 4; ++i2) {
+ int j2 = i2 + i1 * 4 << 11 | 0 + j1 * 4 << 7 | k1 * 8 + l1;
+ short short1 = 128;
+ double d14 = 0.25D;
+ double d15 = d10;
+ double d16 = (d11 - d10) * d14;
+
+ for (int k2 = 0; k2 < 4; ++k2) {
+ double d17 = adouble[(i1 * 4 + i2) * 16 + j1 * 4 + k2];
+ int l2 = 0;
+
+ if (k1 * 8 + l1 < b1) {
+ if (d17 < 0.5D && k1 * 8 + l1 >= b1 - 1) {
+ l2 = Block.ICE.id;
+ } else {
+ l2 = Block.STATIONARY_WATER.id;
+ }
+ }
+
+ if (d15 > 0.0D) {
+ l2 = Block.STONE.id;
+ }
+
+ abyte[j2] = (byte) l2;
+ j2 += short1;
+ d15 += d16;
+ }
+
+ d10 += d12;
+ d11 += d13;
+ }
+
+ d1 += d5;
+ d2 += d6;
+ d3 += d7;
+ d4 += d8;
+ }
+ }
+ }
+ }
+ }
+
+ public void a(int i, int j, byte[] abyte, BiomeBase[] abiomebase) {
+ byte b0 = 64;
+ double d0 = 0.03125D;
+
+ this.r = this.n.a(this.r, (double) (i * 16), (double) (j * 16), 0.0D, 16, 16, 1, d0, d0, 1.0D);
+ this.s = this.n.a(this.s, (double) (i * 16), 109.0134D, (double) (j * 16), 16, 1, 16, d0, 1.0D, d0); // CraftBukkit -- i & j swapped.
+ this.t = this.o.a(this.t, (double) (i * 16), (double) (j * 16), 0.0D, 16, 16, 1, d0 * 2.0D, d0 * 2.0D, d0 * 2.0D);
+
+ for (int k = 0; k < 16; ++k) {
+ for (int l = 0; l < 16; ++l) {
+ BiomeBase biomebase = abiomebase[k + l * 16];
+ boolean flag = this.r[k + l * 16] + this.j.nextDouble() * 0.2D > 0.0D;
+ boolean flag1 = this.s[k + l * 16] + this.j.nextDouble() * 0.2D > 3.0D;
+ int i1 = (int) (this.t[k + l * 16] / 3.0D + 3.0D + this.j.nextDouble() * 0.25D);
+ int j1 = -1;
+ byte b1 = biomebase.o;
+ byte b2 = biomebase.p;
+
+ for (int k1 = 127; k1 >= 0; --k1) {
+ int l1 = (k + l * 16) * 128 + k1; // CraftBukkit (k*16+l) -> (k+l*16)
+
+ if (k1 <= 0 + this.j.nextInt(5)) {
+ abyte[l1] = (byte) Block.BEDROCK.id;
+ } else {
+ byte b3 = abyte[l1];
+
+ if (b3 == 0) {
+ j1 = -1;
+ } else if (b3 == Block.STONE.id) {
+ if (j1 == -1) {
+ if (i1 <= 0) {
+ b1 = 0;
+ b2 = (byte) Block.STONE.id;
+ } else if (k1 >= b0 - 4 && k1 <= b0 + 1) {
+ b1 = biomebase.o;
+ b2 = biomebase.p;
+ if (flag1) {
+ b1 = 0;
+ }
+
+ if (flag1) {
+ b2 = (byte) Block.GRAVEL.id;
+ }
+
+ if (flag) {
+ b1 = (byte) Block.SAND.id;
+ }
+
+ if (flag) {
+ b2 = (byte) Block.SAND.id;
+ }
+ }
+
+ if (k1 < b0 && b1 == 0) {
+ b1 = (byte) Block.STATIONARY_WATER.id;
+ }
+
+ j1 = i1;
+ if (k1 >= b0 - 1) {
+ abyte[l1] = b1;
+ } else {
+ abyte[l1] = b2;
+ }
+ } else if (j1 > 0) {
+ --j1;
+ abyte[l1] = b2;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public Chunk b(int i, int j) {
+ this.j.setSeed((long) i * 341873128712L + (long) j * 132897987541L);
+ byte[] abyte = new byte['\u8000'];
+ Chunk chunk = new Chunk(this.p, abyte, i, j);
+
+ this.v = this.p.a().a(this.v, i * 16, j * 16, 16, 16);
+ double[] adouble = this.p.a().a;
+
+ this.a(i, j, abyte, this.v, adouble);
+ this.a(i, j, abyte, this.v);
+ this.u.a(this, this.p, i, j, abyte);
+ chunk.b();
+ return chunk;
+ }
+
+ private double[] a(double[] adouble, int i, int j, int k, int l, int i1, int j1) {
+ if (adouble == null) {
+ adouble = new double[l * i1 * j1];
+ }
+
+ double d0 = 684.412D;
+ double d1 = 684.412D;
+ double[] adouble1 = this.p.a().a;
+ double[] adouble2 = this.p.a().b;
+
+ this.g = this.a.a(this.g, i, k, l, j1, 1.121D, 1.121D, 0.5D);
+ this.h = this.b.a(this.h, i, k, l, j1, 200.0D, 200.0D, 0.5D);
+ this.d = this.m.a(this.d, (double) i, (double) j, (double) k, l, i1, j1, d0 / 80.0D, d1 / 160.0D, d0 / 80.0D);
+ this.e = this.k.a(this.e, (double) i, (double) j, (double) k, l, i1, j1, d0, d1, d0);
+ this.f = this.l.a(this.f, (double) i, (double) j, (double) k, l, i1, j1, d0, d1, d0);
+ int k1 = 0;
+ int l1 = 0;
+ int i2 = 16 / l;
+
+ for (int j2 = 0; j2 < l; ++j2) {
+ int k2 = j2 * i2 + i2 / 2;
+
+ for (int l2 = 0; l2 < j1; ++l2) {
+ int i3 = l2 * i2 + i2 / 2;
+ double d2 = adouble1[k2 * 16 + i3];
+ double d3 = adouble2[k2 * 16 + i3] * d2;
+ double d4 = 1.0D - d3;
+
+ d4 *= d4;
+ d4 *= d4;
+ d4 = 1.0D - d4;
+ double d5 = (this.g[l1] + 256.0D) / 512.0D;
+
+ d5 *= d4;
+ if (d5 > 1.0D) {
+ d5 = 1.0D;
+ }
+
+ double d6 = this.h[l1] / 8000.0D;
+
+ if (d6 < 0.0D) {
+ d6 = -d6 * 0.3D;
+ }
+
+ d6 = d6 * 3.0D - 2.0D;
+ if (d6 < 0.0D) {
+ d6 /= 2.0D;
+ if (d6 < -1.0D) {
+ d6 = -1.0D;
+ }
+
+ d6 /= 1.4D;
+ d6 /= 2.0D;
+ d5 = 0.0D;
+ } else {
+ if (d6 > 1.0D) {
+ d6 = 1.0D;
+ }
+
+ d6 /= 8.0D;
+ }
+
+ if (d5 < 0.0D) {
+ d5 = 0.0D;
+ }
+
+ d5 += 0.5D;
+ d6 = d6 * (double) i1 / 16.0D;
+ double d7 = (double) i1 / 2.0D + d6 * 4.0D;
+
+ ++l1;
+
+ for (int j3 = 0; j3 < i1; ++j3) {
+ double d8 = 0.0D;
+ double d9 = ((double) j3 - d7) * 12.0D / d5;
+
+ if (d9 < 0.0D) {
+ d9 *= 4.0D;
+ }
+
+ double d10 = this.e[k1] / 512.0D;
+ double d11 = this.f[k1] / 512.0D;
+ double d12 = (this.d[k1] / 10.0D + 1.0D) / 2.0D;
+
+ if (d12 < 0.0D) {
+ d8 = d10;
+ } else if (d12 > 1.0D) {
+ d8 = d11;
+ } else {
+ d8 = d10 + (d11 - d10) * d12;
+ }
+
+ d8 -= d9;
+ if (j3 > i1 - 4) {
+ double d13 = (double) ((float) (j3 - (i1 - 4)) / 3.0F);
+
+ d8 = d8 * (1.0D - d13) + -10.0D * d13;
+ }
+
+ adouble[k1] = d8;
+ ++k1;
+ }
+ }
+ }
+
+ return adouble;
+ }
+
+ public boolean a(int i, int j) {
+ return true;
+ }
+
+ public void a(IChunkProvider ichunkprovider, int i, int j) {
+ BlockSand.a = true;
+ int k = i * 16;
+ int l = j * 16;
+ BiomeBase biomebase = this.p.a().a(k + 16, l + 16);
+
+ this.j.setSeed(this.p.u);
+ long i1 = this.j.nextLong() / 2L * 2L + 1L;
+ long j1 = this.j.nextLong() / 2L * 2L + 1L;
+
+ this.j.setSeed((long) i * i1 + (long) j * j1 ^ this.p.u);
+ double d0 = 0.25D;
+ int k1;
+ int l1;
+ int i2;
+
+ if (this.j.nextInt(4) == 0) {
+ k1 = k + this.j.nextInt(16) + 8;
+ l1 = this.j.nextInt(128);
+ i2 = l + this.j.nextInt(16) + 8;
+ (new WorldGenLakes(Block.STATIONARY_WATER.id)).a(this.p, this.j, k1, l1, i2);
+ }
+
+ if (this.j.nextInt(8) == 0) {
+ k1 = k + this.j.nextInt(16) + 8;
+ l1 = this.j.nextInt(this.j.nextInt(120) + 8);
+ i2 = l + this.j.nextInt(16) + 8;
+ if (l1 < 64 || this.j.nextInt(10) == 0) {
+ (new WorldGenLakes(Block.STATIONARY_LAVA.id)).a(this.p, this.j, k1, l1, i2);
+ }
+ }
+
+ int j2;
+
+ for (k1 = 0; k1 < 8; ++k1) {
+ l1 = k + this.j.nextInt(16) + 8;
+ i2 = this.j.nextInt(128);
+ j2 = l + this.j.nextInt(16) + 8;
+ (new WorldGenDungeons()).a(this.p, this.j, l1, i2, j2);
+ }
+
+ for (k1 = 0; k1 < 10; ++k1) {
+ l1 = k + this.j.nextInt(16);
+ i2 = this.j.nextInt(128);
+ j2 = l + this.j.nextInt(16);
+ (new WorldGenClay(32)).a(this.p, this.j, l1, i2, j2);
+ }
+
+ for (k1 = 0; k1 < 20; ++k1) {
+ l1 = k + this.j.nextInt(16);
+ i2 = this.j.nextInt(128);
+ j2 = l + this.j.nextInt(16);
+ (new WorldGenMinable(Block.DIRT.id, 32)).a(this.p, this.j, l1, i2, j2);
+ }
+
+ for (k1 = 0; k1 < 10; ++k1) {
+ l1 = k + this.j.nextInt(16);
+ i2 = this.j.nextInt(128);
+ j2 = l + this.j.nextInt(16);
+ (new WorldGenMinable(Block.GRAVEL.id, 32)).a(this.p, this.j, l1, i2, j2);
+ }
+
+ for (k1 = 0; k1 < 20; ++k1) {
+ l1 = k + this.j.nextInt(16);
+ i2 = this.j.nextInt(128);
+ j2 = l + this.j.nextInt(16);
+ (new WorldGenMinable(Block.COAL_ORE.id, 16)).a(this.p, this.j, l1, i2, j2);
+ }
+
+ for (k1 = 0; k1 < 20; ++k1) {
+ l1 = k + this.j.nextInt(16);
+ i2 = this.j.nextInt(64);
+ j2 = l + this.j.nextInt(16);
+ (new WorldGenMinable(Block.IRON_ORE.id, 8)).a(this.p, this.j, l1, i2, j2);
+ }
+
+ for (k1 = 0; k1 < 2; ++k1) {
+ l1 = k + this.j.nextInt(16);
+ i2 = this.j.nextInt(32);
+ j2 = l + this.j.nextInt(16);
+ (new WorldGenMinable(Block.GOLD_ORE.id, 8)).a(this.p, this.j, l1, i2, j2);
+ }
+
+ for (k1 = 0; k1 < 8; ++k1) {
+ l1 = k + this.j.nextInt(16);
+ i2 = this.j.nextInt(16);
+ j2 = l + this.j.nextInt(16);
+ (new WorldGenMinable(Block.REDSTONE_ORE.id, 7)).a(this.p, this.j, l1, i2, j2);
+ }
+
+ for (k1 = 0; k1 < 1; ++k1) {
+ l1 = k + this.j.nextInt(16);
+ i2 = this.j.nextInt(16);
+ j2 = l + this.j.nextInt(16);
+ (new WorldGenMinable(Block.DIAMOND_ORE.id, 7)).a(this.p, this.j, l1, i2, j2);
+ }
+
+ for (k1 = 0; k1 < 1; ++k1) {
+ l1 = k + this.j.nextInt(16);
+ i2 = this.j.nextInt(16) + this.j.nextInt(16);
+ j2 = l + this.j.nextInt(16);
+ (new WorldGenMinable(Block.LAPIS_ORE.id, 6)).a(this.p, this.j, l1, i2, j2);
+ }
+
+ d0 = 0.5D;
+ k1 = (int) ((this.c.a((double) k * d0, (double) l * d0) / 8.0D + this.j.nextDouble() * 4.0D + 4.0D) / 3.0D);
+ l1 = 0;
+ if (this.j.nextInt(10) == 0) {
+ ++l1;
+ }
+
+ if (biomebase == BiomeBase.FOREST) {
+ l1 += k1 + 5;
+ }
+
+ if (biomebase == BiomeBase.RAINFOREST) {
+ l1 += k1 + 5;
+ }
+
+ if (biomebase == BiomeBase.SEASONAL_FOREST) {
+ l1 += k1 + 2;
+ }
+
+ if (biomebase == BiomeBase.TAIGA) {
+ l1 += k1 + 5;
+ }
+
+ if (biomebase == BiomeBase.DESERT) {
+ l1 -= 20;
+ }
+
+ if (biomebase == BiomeBase.TUNDRA) {
+ l1 -= 20;
+ }
+
+ if (biomebase == BiomeBase.PLAINS) {
+ l1 -= 20;
+ }
+
+ int k2;
+
+ for (i2 = 0; i2 < l1; ++i2) {
+ j2 = k + this.j.nextInt(16) + 8;
+ k2 = l + this.j.nextInt(16) + 8;
+ WorldGenerator worldgenerator = biomebase.a(this.j);
+
+ worldgenerator.a(1.0D, 1.0D, 1.0D);
+ worldgenerator.a(this.p, this.j, j2, this.p.d(j2, k2), k2);
+ }
+
+ int l2;
+
+ for (i2 = 0; i2 < 2; ++i2) {
+ j2 = k + this.j.nextInt(16) + 8;
+ k2 = this.j.nextInt(128);
+ l2 = l + this.j.nextInt(16) + 8;
+ (new WorldGenFlowers(Block.YELLOW_FLOWER.id)).a(this.p, this.j, j2, k2, l2);
+ }
+
+ if (this.j.nextInt(2) == 0) {
+ i2 = k + this.j.nextInt(16) + 8;
+ j2 = this.j.nextInt(128);
+ k2 = l + this.j.nextInt(16) + 8;
+ (new WorldGenFlowers(Block.RED_ROSE.id)).a(this.p, this.j, i2, j2, k2);
+ }
+
+ if (this.j.nextInt(4) == 0) {
+ i2 = k + this.j.nextInt(16) + 8;
+ j2 = this.j.nextInt(128);
+ k2 = l + this.j.nextInt(16) + 8;
+ (new WorldGenFlowers(Block.BROWN_MUSHROOM.id)).a(this.p, this.j, i2, j2, k2);
+ }
+
+ if (this.j.nextInt(8) == 0) {
+ i2 = k + this.j.nextInt(16) + 8;
+ j2 = this.j.nextInt(128);
+ k2 = l + this.j.nextInt(16) + 8;
+ (new WorldGenFlowers(Block.RED_MUSHROOM.id)).a(this.p, this.j, i2, j2, k2);
+ }
+
+ for (i2 = 0; i2 < 10; ++i2) {
+ j2 = k + this.j.nextInt(16) + 8;
+ k2 = this.j.nextInt(128);
+ l2 = l + this.j.nextInt(16) + 8;
+ (new WorldGenReed()).a(this.p, this.j, j2, k2, l2);
+ }
+
+ if (this.j.nextInt(32) == 0) {
+ i2 = k + this.j.nextInt(16) + 8;
+ j2 = this.j.nextInt(128);
+ k2 = l + this.j.nextInt(16) + 8;
+ (new WorldGenPumpkin()).a(this.p, this.j, i2, j2, k2);
+ }
+
+ i2 = 0;
+ if (biomebase == BiomeBase.DESERT) {
+ i2 += 10;
+ }
+
+ int i3;
+
+ for (j2 = 0; j2 < i2; ++j2) {
+ k2 = k + this.j.nextInt(16) + 8;
+ l2 = this.j.nextInt(128);
+ i3 = l + this.j.nextInt(16) + 8;
+ (new WorldGenCactus()).a(this.p, this.j, k2, l2, i3);
+ }
+
+ for (j2 = 0; j2 < 50; ++j2) {
+ k2 = k + this.j.nextInt(16) + 8;
+ l2 = this.j.nextInt(this.j.nextInt(120) + 8);
+ i3 = l + this.j.nextInt(16) + 8;
+ (new WorldGenLiquids(Block.WATER.id)).a(this.p, this.j, k2, l2, i3);
+ }
+
+ for (j2 = 0; j2 < 20; ++j2) {
+ k2 = k + this.j.nextInt(16) + 8;
+ l2 = this.j.nextInt(this.j.nextInt(this.j.nextInt(112) + 8) + 8);
+ i3 = l + this.j.nextInt(16) + 8;
+ (new WorldGenLiquids(Block.LAVA.id)).a(this.p, this.j, k2, l2, i3);
+ }
+
+ this.w = this.p.a().a(this.w, k + 8, l + 8, 16, 16);
+
+ for (j2 = k + 8; j2 < k + 8 + 16; ++j2) {
+ for (k2 = l + 8; k2 < l + 8 + 16; ++k2) {
+ l2 = j2 - (k + 8);
+ i3 = k2 - (l + 8);
+ int j3 = this.p.e(j2, k2);
+ double d1 = this.w[l2 * 16 + i3] - (double) (j3 - 64) / 64.0D * 0.3D;
+
+ if (d1 < 0.5D && j3 > 0 && j3 < 128 && this.p.isEmpty(j2, j3, k2) && this.p.getMaterial(j2, j3 - 1, k2).isSolid() && this.p.getMaterial(j2, j3 - 1, k2) != Material.ICE) {
+ this.p.e(j2, j3, k2, Block.SNOW.id);
+ }
+ }
+ }
+
+ BlockSand.a = false;
+ }
+
+ public boolean a(boolean flag, IProgressUpdate iprogressupdate) {
+ return true;
+ }
+
+ public boolean a() {
+ return false;
+ }
+
+ public boolean b() {
+ return true;
+ }
+}
diff --git a/src/main/java/net/minecraft/server/ChunkProviderServer.java b/src/main/java/net/minecraft/server/ChunkProviderServer.java
index e3c9dee6..376ff355 100644
--- a/src/main/java/net/minecraft/server/ChunkProviderServer.java
+++ b/src/main/java/net/minecraft/server/ChunkProviderServer.java
@@ -206,7 +206,7 @@ public class ChunkProviderServer implements IChunkProvider {
chunk.e();
this.b(chunk);
this.a(chunk);
- // this.a.remove(chunkcoordinates); // CraftBukkit
+ this.a.remove(chunkcoordinates);
this.e.remove(chunkcoordinates);
this.f.remove(chunk);
}
diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java
index 26c8c7e9..c867b32c 100644
--- a/src/main/java/net/minecraft/server/EntityCreature.java
+++ b/src/main/java/net/minecraft/server/EntityCreature.java
@@ -13,8 +13,8 @@ import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
public class EntityCreature extends EntityLiving {
- private PathEntity a;
- protected Entity d;
+ public PathEntity a; // Craftbukkit - public
+ public Entity d; // Craftbukkit - public
protected boolean e = false;
public EntityCreature(World world) {
diff --git a/src/main/java/net/minecraft/server/ItemBlock.java b/src/main/java/net/minecraft/server/ItemBlock.java
index 7819be2e..d3a886e3 100644
--- a/src/main/java/net/minecraft/server/ItemBlock.java
+++ b/src/main/java/net/minecraft/server/ItemBlock.java
@@ -98,9 +98,7 @@ public class ItemBlock extends Item {
int distanceFromSpawn = (int) Math.max(Math.abs(i - world.spawnX), Math.abs(k - world.spawnZ));
- // CraftBukkit hardcoded Spawn distance for now
- // TODO make spawn size configurable
- boolean canBuild = distanceFromSpawn > 16 || thePlayer.isOp();
+ boolean canBuild = distanceFromSpawn > ((WorldServer) world).D.spawnProtection || thePlayer.isOp(); // CraftBukkit Configurable spawn protection start
BlockPlaceEvent event = new BlockPlaceEvent(eventType, placedBlock, replacedBlockState, blockClicked, itemInHand, thePlayer, canBuild);
server.getPluginManager().callEvent(event);
diff --git a/src/main/java/net/minecraft/server/LongHashtable.java b/src/main/java/net/minecraft/server/LongHashtable.java
index e057a653..e71e0a30 100644
--- a/src/main/java/net/minecraft/server/LongHashtable.java
+++ b/src/main/java/net/minecraft/server/LongHashtable.java
@@ -82,7 +82,7 @@ public class LongHashtable<V> extends LongHash {
if(inner == null) continue;
for(Object entry : inner) {
if(entry == null) break;
- ret.add((V)entry);
+ ret.add((V)((Entry)entry).value);
}
}
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 23ef042b..6d800657 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -18,7 +18,9 @@ import joptsimple.OptionSet;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
-// CraftBukkit end
+import org.bukkit.event.Event;
+import org.bukkit.event.world.WorldEvent;
+//CraftBukkit end
public class MinecraftServer implements ICommandListener, Runnable {
@@ -39,6 +41,7 @@ public class MinecraftServer implements ICommandListener, Runnable {
public boolean l;
public boolean m;
public boolean n;
+ public int spawnProtection; // CraftBukkit Configurable spawn protection start
public List<WorldServer> worlds = new ArrayList<WorldServer>();
// Craftbukkit start - adds argument OptionSet
@@ -71,6 +74,7 @@ public class MinecraftServer implements ICommandListener, Runnable {
this.l = this.d.a("online-mode", true);
this.m = this.d.a("spawn-animals", true);
this.n = this.d.a("pvp", true);
+ this.spawnProtection = this.d.a("spawn-protection", 16); // CraftBukkit Configurable spawn protection start
InetAddress inetaddress = null;
if (s.length() > 0) {
@@ -173,6 +177,9 @@ public class MinecraftServer implements ICommandListener, Runnable {
// Craftbukkit start
for (WorldServer world : worlds) {
world.a(true, (IProgressUpdate) null);
+
+ Event worldSaved = new WorldEvent( Event.Type.WORLD_SAVED, world.getWorld() );
+ server.getPluginManager().callEvent( worldSaved );
}
// Craftbukkit end
}
@@ -351,6 +358,9 @@ public class MinecraftServer implements ICommandListener, Runnable {
// Craftbukkit start
for (WorldServer world : worlds) {
world.a(true, (IProgressUpdate) null);
+
+ Event worldSaved = new WorldEvent( Event.Type.WORLD_SAVED, world.getWorld() );
+ server.getPluginManager().callEvent( worldSaved );
}
this.f.d();
diff --git a/src/main/java/net/minecraft/server/NetServerHandler.java b/src/main/java/net/minecraft/server/NetServerHandler.java
index 3d54810f..b5acdc86 100644
--- a/src/main/java/net/minecraft/server/NetServerHandler.java
+++ b/src/main/java/net/minecraft/server/NetServerHandler.java
@@ -325,8 +325,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
// CraftBukkit end
if (packet14blockdig.e == 0) {
- if (j1 > 16 || flag) {
- // CraftBukkit start
+ // CraftBukkit start
+ if (j1 > this.d.spawnProtection || flag) {
if(blockId > 0) {
BlockDamageEvent event;
// If the amount of damage that the player is going to do to the block
@@ -341,8 +341,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
this.e.c.a(i, j, k);
}
}
- // CraftBukkit end
}
+ // CraftBukkit end
} else if (packet14blockdig.e == 2) {
// CraftBukkit start - Get last block that the player hit
// Otherwise the block is a Bedrock @(0,0,0)
@@ -354,8 +354,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
}
// CraftBukkit end
} else if (packet14blockdig.e == 1) {
- if (j1 > 16 || flag) {
- // CraftBukkit start
+ // CraftBukkit start
+ if (j1 > this.d.spawnProtection || flag) {
BlockDamageEvent event;
// If the amount of damage going to the block plus the current amount
// of damage is greater than 1, the block is going to break.
@@ -370,8 +370,8 @@ public class NetServerHandler extends NetHandler implements ICommandListener {
} else {
e.c.d = 0; // Reset the amount of damage if stopping break.
}
- // CraftBukkit end
}
+ // CraftBukkit end
} else if (packet14blockdig.e == 3) {
double d5 = this.e.locX - ((double) i + 0.5D);
double d6 = this.e.locY - ((double) j + 0.5D);
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index be0b8e22..9a1c5a28 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -286,13 +286,18 @@ public class World implements IBlockAccess {
Chunk lastChunkAccessed;
int lastXAccessed = Integer.MIN_VALUE;
int lastZAccessed = Integer.MIN_VALUE;
+ final Object chunkLock = new Object();
public Chunk c(int i, int j) {
- if(lastChunkAccessed == null || lastXAccessed != i || lastZAccessed != j) {
- lastXAccessed = i;
- lastZAccessed = j;
- lastChunkAccessed = this.G.b(i, j);
+ Chunk result = null;
+ synchronized (chunkLock) {
+ if (lastChunkAccessed == null || lastXAccessed != i || lastZAccessed != j) {
+ lastXAccessed = i;
+ lastZAccessed = j;
+ lastChunkAccessed = this.G.b(i, j);
+ }
+ result = lastChunkAccessed;
}
- return lastChunkAccessed;
+ return result;
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
index 91914ab8..f20b51f1 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -16,7 +16,7 @@ public class WorldServer extends World implements BlockChangeDelegate {
public ChunkProviderServer A;
public boolean B = false;
public boolean C;
- private MinecraftServer D;
+ public final MinecraftServer D;
private EntityList E = new EntityList();
public PlayerManager manager; // Craftbukkit
@@ -87,7 +87,7 @@ public class WorldServer extends World implements BlockChangeDelegate {
i1 = l;
}
- return i1 > 16 || this.D.f.g(entityhuman.name);
+ return i1 > this.D.spawnProtection || this.D.f.g(entityhuman.name); // CraftBukkit Configurable spawn protection start
}
protected void b(Entity entity) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index a034bae1..623fc3f9 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -4,7 +4,7 @@ import org.bukkit.command.*;
import org.bukkit.entity.Player;
import java.io.File;
import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
@@ -34,7 +34,7 @@ public final class CraftServer implements Server {
private final CommandMap commandMap = new SimpleCommandMap(this);
protected final MinecraftServer console;
protected final ServerConfigurationManager server;
- private final Map<String, World> worlds = new HashMap<String, World>();
+ private final Map<String, World> worlds = new LinkedHashMap<String, World>();
public CraftServer(MinecraftServer console, ServerConfigurationManager server) {
this.console = console;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index 0abcc941..168d85e5 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -73,11 +73,12 @@ public class CraftWorld implements World {
}
public Chunk[] getLoadedChunks() {
- net.minecraft.server.Chunk[] chunks = (net.minecraft.server.Chunk[])provider.e.values().toArray();
+ Object[] chunks = provider.e.values().toArray();
org.bukkit.Chunk[] craftChunks = new CraftChunk[chunks.length];
for (int i = 0; i < chunks.length; i++) {
- craftChunks[i] = chunks[i].bukkitChunk;
+ net.minecraft.server.Chunk chunk = (net.minecraft.server.Chunk)chunks[i];
+ craftChunks[i] = chunk.bukkitChunk;
}
return craftChunks;
@@ -123,6 +124,7 @@ public class CraftWorld implements World {
}
provider.a.remove(x, z);
+ provider.a.remove(x, z);
provider.e.remove(x, z);
provider.f.remove(chunk);
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java
index 24b8b227..d881c0e8 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftCreature.java
@@ -1,18 +1,44 @@
package org.bukkit.craftbukkit.entity;
import net.minecraft.server.EntityCreature;
+import net.minecraft.server.EntityLiving;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.Creature;
+import org.bukkit.entity.LivingEntity;
public class CraftCreature extends CraftLivingEntity implements Creature{
+ private EntityCreature entity;
public CraftCreature(CraftServer server, EntityCreature entity) {
super(server, entity);
+ this.entity = entity;
+ }
+
+ public void setTarget(LivingEntity target) {
+ if (target == null) {
+ entity.d = null;
+ } else if (target instanceof CraftLivingEntity) {
+ EntityLiving victim = ((CraftLivingEntity)target).getHandle();
+ entity.d = victim;
+ entity.a = entity.world.a(entity, entity.d, 16.0F);
+ }
+ }
+
+ public CraftLivingEntity getTarget() {
+ if (entity.d == null) {
+ return null;
+ } else {
+ return (CraftLivingEntity)entity.d.getBukkitEntity();
+ }
+ }
+
+ @Override
+ public EntityCreature getHandle() {
+ return entity;
}
@Override
public String toString() {
return "CraftCreature";
}
-
}