diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-10-02 04:25:21 +0100 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-10-03 00:14:06 +0100 |
commit | bf09121354b4d1bc3c34a86eac9e42d54d06724e (patch) | |
tree | fee8f7ba09a520cc7e40fa48af6c54ccd02d9022 /src | |
parent | 39674b6fb02fc3b771701fca52110623ad1d1967 (diff) | |
download | craftbukkit-bf09121354b4d1bc3c34a86eac9e42d54d06724e.tar craftbukkit-bf09121354b4d1bc3c34a86eac9e42d54d06724e.tar.gz craftbukkit-bf09121354b4d1bc3c34a86eac9e42d54d06724e.tar.lz craftbukkit-bf09121354b4d1bc3c34a86eac9e42d54d06724e.tar.xz craftbukkit-bf09121354b4d1bc3c34a86eac9e42d54d06724e.zip |
Attempt to fix any damage caused by misplaced tile entities
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/net/minecraft/server/Chunk.java | 5 | ||||
-rw-r--r-- | src/main/java/net/minecraft/server/WorldServer.java | 56 |
2 files changed, 60 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java index 4982e6d6..939fa69f 100644 --- a/src/main/java/net/minecraft/server/Chunk.java +++ b/src/main/java/net/minecraft/server/Chunk.java @@ -605,7 +605,10 @@ public class Chunk { tileentity.n(); this.tileEntities.put(chunkposition, tileentity); } else { - System.out.println("Attempted to place a tile entity where there was no entity tile!"); + // CraftBukkit start + System.out.println("Attempted to place a tile entity (" + tileentity + ") at " + tileentity.x + "," + tileentity.y + "," + tileentity.z + + " (" + org.bukkit.Material.getMaterial(getTypeId(i, j, k)) + ") where there was no entity tile!"); + // CraftBukkit end } } diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index fcc3fd82..569190c8 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -36,6 +36,62 @@ public class WorldServer extends World implements BlockChangeDelegate { return height; } + @Override + public TileEntity getTileEntity(int i, int j, int k) { + TileEntity result = super.getTileEntity(i, j, k); + int type = getTypeId(i, j, k); + + if (type == Block.CHEST.id) { + if (!(result instanceof TileEntityChest)) { + result = fixTileEntity(i, j, k, type, result); + } + } else if (type == Block.FURNACE.id) { + if (!(result instanceof TileEntityFurnace)) { + result = fixTileEntity(i, j, k, type, result); + } + } else if (type == Block.PISTON_MOVING.id) { + if (!(result instanceof TileEntityPiston)) { + result = fixTileEntity(i, j, k, type, result); + } + } else if (type == Block.DISPENSER.id) { + if (!(result instanceof TileEntityDispenser)) { + result = fixTileEntity(i, j, k, type, result); + } + } else if (type == Block.JUKEBOX.id) { + if (!(result instanceof TileEntityRecordPlayer)) { + result = fixTileEntity(i, j, k, type, result); + } + } else if (type == Block.NOTE_BLOCK.id) { + if (!(result instanceof TileEntityNote)) { + result = fixTileEntity(i, j, k, type, result); + } + } else if (type == Block.MOB_SPAWNER.id) { + if (!(result instanceof TileEntityMobSpawner)) { + result = fixTileEntity(i, j, k, type, result); + } + } else if ((type == Block.SIGN_POST.id) || (type == Block.WALL_SIGN.id)) { + if (!(result instanceof TileEntitySign)) { + result = fixTileEntity(i, j, k, type, result); + } + } + + return result; + } + + private TileEntity fixTileEntity(int x, int y, int z, int type, TileEntity found) { + getServer().getLogger().severe("Block at " + x + "," + y + "," + z + " is " + org.bukkit.Material.getMaterial(type).toString() + " but has " + found + ". " + + "Bukkit will attempt to fix this, but there may be additional damage that we cannot recover."); + + if (Block.byId[type] instanceof BlockContainer) { + TileEntity replacement = ((BlockContainer)Block.byId[type]).a_(); + setTileEntity(x, y, z, replacement); + return replacement; + } else { + getServer().getLogger().severe("Don't know how to fix for this type... Can't do anything! :("); + return found; + } + } + public final int dimension; public EntityTracker tracker; public PlayerManager manager; |