diff options
author | Erik Broes <erikbroes@grum.nl> | 2011-01-29 22:50:29 +0100 |
---|---|---|
committer | Erik Broes <erikbroes@grum.nl> | 2011-01-30 13:24:39 +0100 |
commit | df69047324abc54f5d5b8d069bb69b1061b20cce (patch) | |
tree | 76f8d13addf80730deea9285f4bd9a1ffbe45f80 /src/main/java/net/minecraft/server/WorldServer.java | |
parent | d0cd8c6cc7d1aaf38934996e7e5d3e03272e4ff1 (diff) | |
download | craftbukkit-df69047324abc54f5d5b8d069bb69b1061b20cce.tar craftbukkit-df69047324abc54f5d5b8d069bb69b1061b20cce.tar.gz craftbukkit-df69047324abc54f5d5b8d069bb69b1061b20cce.tar.lz craftbukkit-df69047324abc54f5d5b8d069bb69b1061b20cce.tar.xz craftbukkit-df69047324abc54f5d5b8d069bb69b1061b20cce.zip |
Port to new mc-dev format.
Diffstat (limited to 'src/main/java/net/minecraft/server/WorldServer.java')
-rw-r--r-- | src/main/java/net/minecraft/server/WorldServer.java | 227 |
1 files changed, 110 insertions, 117 deletions
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index 06ceb23a..97316346 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -1,7 +1,9 @@ package net.minecraft.server; import java.io.File; -import java.util.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; // CraftBukkit start import org.bukkit.craftbukkit.CraftServer; @@ -15,29 +17,69 @@ import org.bukkit.event.block.BlockPhysicsEvent; public class WorldServer extends World { public ChunkProviderServer A; - public boolean B; + public boolean B = false; public boolean C; private MinecraftServer D; - private MCHashTable E; + private EntityList E = new EntityList(); - public WorldServer(MinecraftServer minecraftserver, File file, String s, int i) { - super(file, s, (new Random()).nextLong(), WorldProvider.a(i)); - B = false; - E = new MCHashTable(); - D = minecraftserver; - world = new CraftWorld(this); // CraftBukkit - server = minecraftserver.server; // CraftBukkit + public WorldServer(MinecraftServer minecraftserver, File file1, String s, int i) { + super(file1, s, (new Random()).nextLong(), WorldProvider.a(i)); + this.D = minecraftserver; + + // CraftBukkit start + world = new CraftWorld(this); + server = minecraftserver.server; + } + + private final CraftWorld world; + private final CraftServer server; + + @Override + public boolean d(int i1, int j1, int k1, int l1) { + boolean result = super.d(i1, j1, k1, l1); + if ((result) && (world != null)) world.updateBlock(i1, j1, k1); + return result; + } + + @Override + public boolean setTypeId(int i, int j, int k, int l) { + boolean result = super.setTypeId(i, j, k, l); + if ((result) && (world != null)) world.updateBlock(i, j, k); + return result; + } + + @Override + public boolean setTypeIdAndData(int i, int j, int k, int l, int i1) { + boolean result = super.setTypeIdAndData(i, j, k, l, i1); + if ((result) && (world != null)) world.updateBlock(i, j, k); + return result; } + @Override + public void setTileEntity(int i, int j, int k, TileEntity tileentity) { + super.setTileEntity(i, j, k, tileentity); + if (world != null) world.updateBlock(i, j, k); + } + + public CraftWorld getWorld() { + return world; + } + + public CraftServer getServer() { + return server; + } + // CraftBukkit end + public void f() { super.f(); } public void a(Entity entity, boolean flag) { - if (!D.m && ((entity instanceof EntityAnimals) || (entity instanceof EntityWaterMob))) { + if (!this.D.m && (entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal)) { entity.q(); } - if (entity.j == null || !(entity.j instanceof EntityPlayer)) { + + if (entity.passenger == null || !(entity.passenger instanceof EntityHuman)) { super.a(entity, flag); } } @@ -46,173 +88,124 @@ public class WorldServer extends World { super.a(entity, flag); } - protected IChunkProvider a(File file) { - A = new ChunkProviderServer(this, q.a(file), q.c()); - return ((IChunkProvider) (A)); + protected IChunkProvider a(File file1) { + this.A = new ChunkProviderServer(this, this.q.a(file1), this.q.c()); + return this.A; } public List d(int i, int j, int k, int l, int i1, int j1) { ArrayList arraylist = new ArrayList(); - for (int k1 = 0; k1 < c.size(); k1++) { - TileEntity tileentity = (TileEntity) c.get(k1); + for (int k1 = 0; k1 < this.c.size(); ++k1) { + TileEntity tileentity = (TileEntity) this.c.get(k1); if (tileentity.b >= i && tileentity.c >= j && tileentity.d >= k && tileentity.b < l && tileentity.c < i1 && tileentity.d < j1) { - ((List) (arraylist)).add(((tileentity))); + arraylist.add(tileentity); } } - return ((List) (arraylist)); + return arraylist; } - public boolean a(EntityPlayer entityplayer, int i, int j, int k) { - int l = (int) MathHelper.e(i - m); - int i1 = (int) MathHelper.e(k - o); + public boolean a(EntityHuman entityhuman, int i, int j, int k) { + int l = (int) MathHelper.e((float) (i - this.spawnX)); + int i1 = (int) MathHelper.e((float) (k - this.spawnZ)); if (l > i1) { i1 = l; } - return i1 > 16 || D.f.g(entityplayer.aw); + + return i1 > 16 || this.D.f.g(entityhuman.name); } protected void b(Entity entity) { super.b(entity); - E.a(entity.g, ((entity))); + this.E.a(entity.id, entity); } protected void c(Entity entity) { super.c(entity); - E.d(entity.g); + this.E.d(entity.id); } public Entity a(int i) { - return (Entity) E.a(i); + return (Entity) this.E.a(i); } - public void a(Entity entity, byte byte0) { - Packet38 packet38 = new Packet38(entity.g, byte0); + public void a(Entity entity, byte b0) { + Packet38EntityStatus packet38entitystatus = new Packet38EntityStatus(entity.id, b0); - D.k.b(entity, ((Packet) (packet38))); + this.D.k.b(entity, packet38entitystatus); } - public Explosion a(Entity entity, double d1, double d2, double d3, float f1, boolean flag) { - Explosion explosion = super.a(entity, d1, d2, d3, f1, flag); + public Explosion a(Entity entity, double d0, double d1, double d2, float f, boolean flag) { + Explosion explosion = super.a(entity, d0, d1, d2, f, flag); - D.f.a(d1, d2, d3, 64D, ((Packet) (new Packet60(d1, d2, d3, f1, explosion.g)))); + this.D.f.a(d0, d1, d2, 64.0D, new Packet60Explosion(d0, d1, d2, f, explosion.g)); return explosion; } public void c(int i, int j, int k, int l, int i1) { super.c(i, j, k, l, i1); - D.f.a(i, j, k, 64D, ((Packet) (new Packet54(i, j, k, l, i1)))); + this.D.f.a((double) i, (double) j, (double) k, 64.0D, new Packet54PlayNoteBlock(i, j, k, l, i1)); } - // CraftBukkit start - private final CraftWorld world; - private final CraftServer server; - - @Override - public boolean d(int i1, int j1, int k1, int l1) { - boolean result = super.d(i1, j1, k1, l1); - if ((result) && (world != null)) world.updateBlock(i1, j1, k1); - return result; - } - - @Override - public boolean b(int i1, int j1, int k1, int l1) { - boolean result = super.b(i1, j1, k1, l1); - if ((result) && (world != null)) world.updateBlock(i1, j1, k1); - return result; - } - - @Override - public boolean a(int i1, int j1, int k1, int l1, int i2) { - boolean result = super.a(i1, j1, k1, l1, i2); - if ((result) && (world != null)) world.updateBlock(i1, j1, k1); - return result; - } - - @Override - public void a(int i1, int j1, int k1, TileEntity tileentity) { - super.a(i1, j1, k1, tileentity); - if (world != null) world.updateBlock(i1, j1, k1); - } - - public CraftWorld getWorld() { - return world; - } - - public CraftServer getServer() { - return server; - } - // CraftBukkit end - // XXX: the following method is straight from the World.java with tweaks as noted. KEEP THEM UPDATED! // XXX: done because it calls private k() @Override - public void h(int i1, int j1, int k1, int l1) { - l(i1 - 1, j1, k1, l1); - l(i1 + 1, j1, k1, l1); - l(i1, j1 - 1, k1, l1); - l(i1, j1 + 1, k1, l1); - l(i1, j1, k1 - 1, l1); - l(i1, j1, k1 + 1, l1); + public void h(int i, int j, int k, int l) { + this.l(i - 1, j, k, l); + this.l(i + 1, j, k, l); + this.l(i, j - 1, k, l); + this.l(i, j + 1, k, l); + this.l(i, j, k - 1, l); + this.l(i, j, k + 1, l); } // XXX: the following method is straight from the World.java with tweaks as noted. KEEP THEM UPDATED! - private void l(int i1, int j1, int k1, int l1) { - if (i || z) { - return; - } - Block block = Block.m[a(i1, j1, k1)]; - - if (block != null) { - // CraftBukkit start - if (world != null) { - BlockPhysicsEvent event = new BlockPhysicsEvent(Event.Type.BLOCK_PHYSICS, world.getBlockAt(i1, j1, k1), l1); - server.getPluginManager().callEvent(event); - if (event.isCancelled()) { - return; + private void l(int i, int j, int k, int l) { + if (!this.i && !this.isStatic) { + Block block = Block.byId[this.getTypeId(i, j, k)]; + + if (block != null) { + // CraftBukkit start + if (world != null) { + BlockPhysicsEvent event = new BlockPhysicsEvent(Event.Type.BLOCK_PHYSICS, world.getBlockAt(i, j, k), l); + server.getPluginManager().callEvent(event); + if (event.isCancelled()) { + return; + } } - } - // CraftBukkit stop + // CraftBukkit stop - block.b(this, i1, j1, k1, l1); + block.b(this, i, j, k, l); + } } } // XXX: the following method is straight from the World.java with tweaks as noted. KEEP THEM UPDATED! @Override - public boolean a(int i1, int j1, int k1, int l1, boolean flag) { - int i2 = a(j1, k1, l1); - Block block = Block.m[i2]; - Block block1 = Block.m[i1]; - AxisAlignedBB axisalignedbb = block1.d(this, j1, k1, l1); + public boolean a(int i, int j, int k, int l, boolean flag) { + int i1 = this.getTypeId(j, k, l); + Block block = Block.byId[i1]; + Block block1 = Block.byId[i]; + AxisAlignedBB axisalignedbb = block1.d(this, j, k, l); if (flag) { axisalignedbb = null; } - if (axisalignedbb != null && !a(axisalignedbb)) { - return false; - } + // Craftbukkit start - We dont want to allow the user to override the bounding box check - boolean defaultReturn; + boolean defaultReturn = axisalignedbb != null && !this.a(axisalignedbb) ? false : (block != Block.WATER && block != Block.STATIONARY_WATER && block != Block.LAVA && block != Block.STATIONARY_LAVA && block != Block.FIRE && block != Block.SNOW ? i > 0 && block == null && block1.a(this, j, k, l) : true); - if (block == Block.A || block == Block.B || block == Block.C || block == Block.D || block == Block.ar || block == Block.aS) { - defaultReturn = true; - } else { - defaultReturn = (i1 > 0) && (block == null) && (block1.a(this, j1, k1, l1)); + if (!defaultReturn) { + return false; } - // Craftbukkit - If flag is true, it's natural, not user placement. Don't hook. - if (!flag) { - BlockCanBuildEvent event = new BlockCanBuildEvent(Type.BLOCK_CANBUILD, getWorld().getBlockAt(j1, k1, l1), i1, defaultReturn); - server.getPluginManager().callEvent(event); + BlockCanBuildEvent event = new BlockCanBuildEvent(Type.BLOCK_CANBUILD, getWorld().getBlockAt(j, k, l), i1, defaultReturn); + server.getPluginManager().callEvent(event); - return event.isBuildable(); - } else { - return defaultReturn; - } + return event.isBuildable(); // CraftBukkit end } } |