13
0
geforkt von Mirrors/Paper

Implement Dropper interface. Adds BUKKIT-3750

Dieser Commit ist enthalten in:
Xephi 2013-03-21 13:43:10 +01:00 committet von Nate Mortensen
Ursprung 978de7e9da
Commit ae19f2c46f
4 geänderte Dateien mit 57 neuen und 1 gelöschten Zeilen

Datei anzeigen

@ -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();

Datei anzeigen

@ -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:

Datei anzeigen

@ -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;
}
}

Datei anzeigen

@ -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) {