Add ANVIL and BEACON custom inventories. Also handle a few special cases for inventory sizes

By: Fabian Faßbender <fabian.fassbender42@googlemail.com>
This commit is contained in:
CraftBukkit/Spigot 2014-12-01 03:19:24 +01:00
parent 7e5da5bf6f
commit 975c29d381

View file

@ -219,6 +219,20 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
openCustomInventory(inventory, player, "minecraft:hopper");
}
break;
case BEACON:
if (craftinv.getInventory() instanceof TileEntityBeacon) {
getHandle().openTileEntity((TileEntityBeacon) craftinv.getInventory());
} else {
openCustomInventory(inventory, player, "minecraft:beacon");
}
break;
case ANVIL:
if (craftinv.getInventory() instanceof TileEntityContainerAnvil) {
getHandle().openTileEntity((TileEntityContainerAnvil) craftinv.getInventory());
} else {
openCustomInventory(inventory, player, "minecraft:anvil");
}
break;
case CREATIVE:
case CRAFTING:
throw new IllegalArgumentException("Can't open a " + type + " inventory!");
@ -240,6 +254,14 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
String title = container.getBukkitView().getTitle();
int size = container.getBukkitView().getTopInventory().getSize();
// Special cases
if (windowType.equals("minecraft:crafting_table")
|| windowType.equals("minecraft:anvil")
|| windowType.equals("minecraft:enchanting_table")
) {
size = 0;
}
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title), size));
getHandle().activeContainer = container;
getHandle().activeContainer.addSlotListener(player);