Added full tile entity data support for all block types that use it, including chests, dispensers, furnaces, mob spawners, and note blocks.

This commit is contained in:
sk89q
2011-01-23 00:37:10 -08:00
parent e0b04001aa
commit 9cd81ddd6d
7 changed files with 335 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntityChest;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.inventory.Inventory;
/**
* Represents a chest.
*
* @author sk89q
*/
public class CraftChest extends CraftBlockState implements Chest {
private final CraftWorld world;
private final TileEntityChest chest;
public CraftChest(final Block block) {
super(block);
world = (CraftWorld)block.getWorld();
chest = (TileEntityChest)world.getTileEntityAt(getX(), getY(), getZ());
}
public Inventory getInventory() {
return new CraftInventory(chest);
}
@Override
public boolean update(boolean force) {
boolean result = super.update(force);
if (result) {
chest.d();
}
return result;
}
}