mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-03 06:01:39 +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);
|
delegate = new ContainerHopper(windowId, bottom, top);
|
||||||
break;
|
break;
|
||||||
case ANVIL:
|
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;
|
break;
|
||||||
case SMITHING:
|
case SMITHING:
|
||||||
delegate = new ContainerSmithing(windowId, bottom);
|
delegate = new ContainerSmithing(windowId, bottom);
|
||||||
@ -227,8 +227,13 @@ public class CraftContainer extends Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SPIGOT-4598 - we should still delegate the shift click handler
|
// SPIGOT-4598 - we should still delegate the shift click handler
|
||||||
if (cachedType == InventoryType.WORKBENCH) {
|
switch (cachedType) {
|
||||||
|
case WORKBENCH:
|
||||||
delegate = new ContainerWorkbench(windowId, bottom);
|
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
|
// 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
|
@Override
|
||||||
public ItemStack shiftClick(EntityHuman entityhuman, int i) {
|
public ItemStack shiftClick(EntityHuman entityhuman, int i) {
|
||||||
return (delegate != null) ? delegate.shiftClick(entityhuman, i) : super.shiftClick(entityhuman, i);
|
return (delegate != null) ? delegate.shiftClick(entityhuman, i) : super.shiftClick(entityhuman, i);
|
||||||
|
Loading…
Reference in New Issue
Block a user