mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-24 01:01:58 +01:00
SPIGOT-6783: Items do not appear in custom anvil inventories
By: md_5 <git@md-5.net>
This commit is contained in:
parent
fda316b6eb
commit
148964d14e
@ -183,7 +183,7 @@ public class CraftContainer extends Container {
|
||||
delegate = new ContainerHopper(windowId, bottom, top);
|
||||
break;
|
||||
case ANVIL:
|
||||
delegate = new ContainerAnvil(windowId, bottom);
|
||||
setupAnvil(top, bottom); // SPIGOT-6783 - manually set up slots so we can use the delegated inventory and not the automatically created one
|
||||
break;
|
||||
case SMITHING:
|
||||
delegate = new ContainerSmithing(windowId, bottom);
|
||||
@ -227,8 +227,13 @@ public class CraftContainer extends Container {
|
||||
}
|
||||
|
||||
// SPIGOT-4598 - we should still delegate the shift click handler
|
||||
if (cachedType == InventoryType.WORKBENCH) {
|
||||
delegate = new ContainerWorkbench(windowId, bottom);
|
||||
switch (cachedType) {
|
||||
case WORKBENCH:
|
||||
delegate = new ContainerWorkbench(windowId, bottom);
|
||||
break;
|
||||
case ANVIL:
|
||||
delegate = new ContainerAnvil(windowId, bottom);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,6 +262,27 @@ public class CraftContainer extends Container {
|
||||
// End copy from ContainerWorkbench
|
||||
}
|
||||
|
||||
private void setupAnvil(IInventory top, IInventory bottom) {
|
||||
// This code copied from ContainerAnvilAbstract
|
||||
this.a(new Slot(top, 0, 27, 47));
|
||||
this.a(new Slot(top, 1, 76, 47));
|
||||
this.a(new Slot(top, 2, 134, 47));
|
||||
|
||||
int row;
|
||||
int col;
|
||||
|
||||
for (row = 0; row < 3; ++row) {
|
||||
for (col = 0; col < 9; ++col) {
|
||||
this.a(new Slot(bottom, col + row * 9 + 9, 8 + col * 18, 84 + row * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (row = 0; row < 9; ++row) {
|
||||
this.a(new Slot(bottom, row, 8 + row * 18, 142));
|
||||
}
|
||||
// End copy from ContainerAnvilAbstract
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack shiftClick(EntityHuman entityhuman, int i) {
|
||||
return (delegate != null) ? delegate.shiftClick(entityhuman, i) : super.shiftClick(entityhuman, i);
|
||||
|
Loading…
Reference in New Issue
Block a user