summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/net/minecraft/server/BlockDropper.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java2
-rw-r--r--src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java50
-rw-r--r--src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java4
4 files changed, 57 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/BlockDropper.java b/src/main/java/net/minecraft/server/BlockDropper.java
index afcc8a84..856aadab 100644
--- a/src/main/java/net/minecraft/server/BlockDropper.java
+++ b/src/main/java/net/minecraft/server/BlockDropper.java
@@ -16,7 +16,7 @@ public class BlockDropper extends BlockDispenser {
return new TileEntityDropper();
}
- protected void dispense(World world, int i, int j, int k) {
+ public void dispense(World world, int i, int j, int k) { // CraftBukkit - protected -> public
SourceBlock sourceblock = new SourceBlock(world, i, j, k);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser) sourceblock.getTileEntity();
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
index ecd08eb6..f1c0e419 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java
@@ -249,6 +249,8 @@ public class CraftBlock implements Block {
return new CraftFurnace(this);
case DISPENSER:
return new CraftDispenser(this);
+ case DROPPER:
+ return new CraftDropper(this);
case HOPPER:
return new CraftHopper(this);
case MOB_SPAWNER:
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java b/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java
new file mode 100644
index 00000000..ace93e08
--- /dev/null
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftDropper.java
@@ -0,0 +1,50 @@
+package org.bukkit.craftbukkit.block;
+
+import net.minecraft.server.BlockDropper;
+import net.minecraft.server.TileEntityDropper;
+
+import org.bukkit.Material;
+import org.bukkit.block.Block;
+import org.bukkit.block.Dropper;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.inventory.CraftInventory;
+import org.bukkit.inventory.Inventory;
+
+public class CraftDropper extends CraftBlockState implements Dropper {
+ private final CraftWorld world;
+ private final TileEntityDropper dropper;
+
+ public CraftDropper(final Block block) {
+ super(block);
+
+ world = (CraftWorld) block.getWorld();
+ dropper = (TileEntityDropper) world.getTileEntityAt(getX(), getY(), getZ());
+ }
+
+ public Inventory getInventory() {
+ return new CraftInventory(dropper);
+ }
+
+ public void drop() {
+ Block block = getBlock();
+
+ synchronized (block) {
+ if (block.getType() == Material.DROPPER) {
+ BlockDropper drop = (BlockDropper) net.minecraft.server.Block.DROPPER;
+
+ drop.dispense(world.getHandle(), getX(), getY(), getZ());
+ }
+ }
+ }
+
+ @Override
+ public boolean update(boolean force) {
+ boolean result = super.update(force);
+
+ if (result) {
+ dropper.update();
+ }
+
+ return result;
+ }
+}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
index ed2e9dc1..9231bf70 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java
@@ -15,6 +15,7 @@ import net.minecraft.server.PlayerInventory;
import net.minecraft.server.TileEntityBeacon;
import net.minecraft.server.TileEntityBrewingStand;
import net.minecraft.server.TileEntityDispenser;
+import net.minecraft.server.TileEntityDropper;
import net.minecraft.server.TileEntityFurnace;
import org.apache.commons.lang.Validate;
@@ -423,10 +424,13 @@ public class CraftInventory implements Inventory {
}
public InventoryType getType() {
+ // Thanks to Droppers extending Dispensers, order is important.
if (inventory instanceof InventoryCrafting) {
return inventory.getSize() >= 9 ? InventoryType.WORKBENCH : InventoryType.CRAFTING;
} else if (inventory instanceof PlayerInventory) {
return InventoryType.PLAYER;
+ } else if (inventory instanceof TileEntityDropper) {
+ return InventoryType.DROPPER;
} else if (inventory instanceof TileEntityDispenser) {
return InventoryType.DISPENSER;
} else if (inventory instanceof TileEntityFurnace) {