Implement Hopper block state and inventory methods. Adds BUKKIT-3749

By: Michael Limiero <mike5713@gmail.com>
This commit is contained in:
CraftBukkit/Spigot
2013-03-16 00:46:35 -04:00
parent f48f89f433
commit 002dd2b7cd
4 changed files with 47 additions and 1 deletions

View File

@@ -249,6 +249,8 @@ public class CraftBlock implements Block {
return new CraftFurnace(this);
case DISPENSER:
return new CraftDispenser(this);
case HOPPER:
return new CraftHopper(this);
case MOB_SPAWNER:
return new CraftCreatureSpawner(this);
case NOTE_BLOCK:

View File

@@ -0,0 +1,35 @@
package org.bukkit.craftbukkit.block;
import net.minecraft.server.TileEntityHopper;
import org.bukkit.block.Block;
import org.bukkit.block.Hopper;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.inventory.CraftInventory;
import org.bukkit.inventory.Inventory;
public class CraftHopper extends CraftBlockState implements Hopper {
private final CraftWorld world;
private final TileEntityHopper hopper;
public CraftHopper(final Block block) {
super(block);
world = (CraftWorld) block.getWorld();
hopper = (TileEntityHopper) world.getTileEntityAt(getX(), getY(), getZ());
}
public Inventory getInventory() {
return new CraftInventory(hopper);
}
@Override
public boolean update(boolean force) {
boolean result = super.update(force);
if (result) {
hopper.update();
}
return result;
}
}