3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 12:30:06 +01:00

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");
}
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);