13
0
geforkt von Mirrors/Paper

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

Dieser Commit ist enthalten in:
Fabian Faßbender 2014-12-01 03:19:24 +01:00 committet von Thinkofdeath
Ursprung 8110f51b50
Commit 497a7b4cfb

Datei anzeigen

@ -219,6 +219,20 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
openCustomInventory(inventory, player, "minecraft:hopper"); openCustomInventory(inventory, player, "minecraft:hopper");
} }
break; 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 CREATIVE:
case CRAFTING: case CRAFTING:
throw new IllegalArgumentException("Can't open a " + type + " inventory!"); 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(); String title = container.getBukkitView().getTitle();
int size = container.getBukkitView().getTopInventory().getSize(); 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)); player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, new ChatComponentText(title), size));
getHandle().activeContainer = container; getHandle().activeContainer = container;
getHandle().activeContainer.addSlotListener(player); getHandle().activeContainer.addSlotListener(player);