Implement Hopper block state and inventory methods. Adds BUKKIT-3749
By: Michael Limiero <mike5713@gmail.com>
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user