Fix items being lost when trying to stack items in the player inventory.
This commit is contained in:
@@ -95,8 +95,6 @@ public abstract class AEBaseContainer extends ScreenHandler {
|
|||||||
private boolean sentCustomName;
|
private boolean sentCustomName;
|
||||||
private int ticksSinceCheck = 900;
|
private int ticksSinceCheck = 900;
|
||||||
private IAEItemStack clientRequestedTargetItem = null;
|
private IAEItemStack clientRequestedTargetItem = null;
|
||||||
// Slots that were created to represent the player inventory
|
|
||||||
private List<Slot> playerInventorySlots = null;
|
|
||||||
|
|
||||||
public AEBaseContainer(ScreenHandlerType<?> containerType, int id, final PlayerInventory ip,
|
public AEBaseContainer(ScreenHandlerType<?> containerType, int id, final PlayerInventory ip,
|
||||||
final BlockEntity myTile, final IPart myPart) {
|
final BlockEntity myTile, final IPart myPart) {
|
||||||
@@ -264,25 +262,39 @@ public abstract class AEBaseContainer extends ScreenHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void bindPlayerInventory(final PlayerInventory playerInventory, final int offsetX, final int offsetY) {
|
protected void bindPlayerInventory(final PlayerInventory playerInventory, final int offsetX, final int offsetY) {
|
||||||
FixedItemInv ih = new FixedInventoryVanillaWrapper(playerInventory);
|
FixedItemInv ih = new FixedInventoryVanillaWrapper(playerInventory) {
|
||||||
|
// Vanilla needs this to be modifiable otherwise stacking will eat items.
|
||||||
|
// FIXME FABRIC: Remove when LBA makes these mutable as per
|
||||||
|
// ModifiableFixedItemInv
|
||||||
|
@Override
|
||||||
|
public ItemStack getInvStack(int slot) {
|
||||||
|
return playerInventory.getStack(slot);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// bind player inventory
|
// bind player inventory
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
for (int j = 0; j < 9; j++) {
|
for (int j = 0; j < 9; j++) {
|
||||||
if (this.locked.contains(j + i * 9 + 9)) {
|
int invSlot = j + i * 9 + 9;
|
||||||
this.addSlot(new DisabledSlot(ih, j + i * 9 + 9, 8 + j * 18 + offsetX, offsetY + i * 18));
|
int x = 8 + j * 18 + offsetX;
|
||||||
|
int y = offsetY + i * 18;
|
||||||
|
|
||||||
|
if (this.locked.contains(invSlot)) {
|
||||||
|
this.addSlot(new DisabledSlot(ih, invSlot, x, y));
|
||||||
} else {
|
} else {
|
||||||
this.addSlot(new PlayerInvSlot(ih, j + i * 9 + 9, 8 + j * 18 + offsetX, offsetY + i * 18));
|
this.addSlot(new PlayerInvSlot(ih, invSlot, x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// bind player hotbar
|
// bind player hotbar
|
||||||
for (int i = 0; i < 9; i++) {
|
for (int i = 0; i < 9; i++) {
|
||||||
|
int x = 8 + i * 18 + offsetX;
|
||||||
|
int y = 58 + offsetY;
|
||||||
if (this.locked.contains(i)) {
|
if (this.locked.contains(i)) {
|
||||||
this.addSlot(new DisabledSlot(ih, i, 8 + i * 18 + offsetX, 58 + offsetY));
|
this.addSlot(new DisabledSlot(ih, i, x, y));
|
||||||
} else {
|
} else {
|
||||||
this.addSlot(new PlayerHotBarSlot(ih, i, 8 + i * 18 + offsetX, 58 + offsetY));
|
this.addSlot(new PlayerHotBarSlot(ih, i, x, y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,11 +21,10 @@ package appeng.container.slot;
|
|||||||
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
import alexiil.mc.lib.attributes.item.FixedItemInv;
|
||||||
|
|
||||||
// there is nothing special about this slot, its simply used to represent the players inventory, vs a container slot.
|
// there is nothing special about this slot, its simply used to represent the players inventory, vs a container slot.
|
||||||
|
|
||||||
public class PlayerInvSlot extends AppEngSlot {
|
public class PlayerInvSlot extends AppEngSlot {
|
||||||
|
|
||||||
public PlayerInvSlot(final FixedItemInv par1iInventory, final int invSlot, final int x, final int y) {
|
public PlayerInvSlot(final FixedItemInv inv, final int invSlot, final int x, final int y) {
|
||||||
super(par1iInventory, invSlot, x, y);
|
super(inv, invSlot, x, y);
|
||||||
|
|
||||||
this.setPlayerSide(true);
|
this.setPlayerSide(true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user