isolate the oversized slots and itemhandlers

This commit is contained in:
PrototypeTrousers
2022-10-27 20:13:44 -03:00
parent 833f8aca2a
commit 53ed861e23
6 changed files with 162 additions and 105 deletions
@@ -404,7 +404,7 @@ public abstract class AEBaseContainer extends Container {
if (tis.getCount() <= 0) {
clickSlot.putStack(ItemStack.EMPTY);
d.onSlotChanged();
this.updateSlot(clickSlot);
this.updateSlot(d);
return ItemStack.EMPTY;
@@ -423,42 +423,7 @@ public abstract class AEBaseContainer extends Container {
}
if (d.isItemValid(tis)) {
if (d.getHasStack()) {
final ItemStack t = d.getStack().copy();
if (Platform.itemComparisons().isSameItem(t, tis)) {
int maxSize = t.getMaxStackSize();
if (d.getSlotStackLimit() < maxSize) {
maxSize = d.getSlotStackLimit();
}
int placeAble = maxSize - t.getCount();
if (tis.getCount() < placeAble) {
placeAble = tis.getCount();
}
t.setCount(t.getCount() + placeAble);
tis.setCount(tis.getCount() - placeAble);
d.putStack(t);
if (tis.getCount() <= 0) {
clickSlot.putStack(ItemStack.EMPTY);
d.onSlotChanged();
// if ( worldEntity != null )
// worldEntity.markDirty();
// if ( hasMETiles ) updateClient();
this.updateSlot(clickSlot);
this.updateSlot(d);
return ItemStack.EMPTY;
} else {
this.updateSlot(d);
}
}
} else {
if (!d.getHasStack()) {
int maxSize = tis.getMaxStackSize();
if (maxSize > d.getSlotStackLimit()) {
maxSize = d.getSlotStackLimit();
@@ -476,10 +441,6 @@ public abstract class AEBaseContainer extends Container {
clickSlot.putStack(ItemStack.EMPTY);
d.onSlotChanged();
// if ( worldEntity != null )
// worldEntity.markDirty();
// if ( hasMETiles ) updateClient();
this.updateSlot(clickSlot);
this.updateSlot(d);
return ItemStack.EMPTY;
@@ -28,8 +28,13 @@ import appeng.container.guisync.GuiSync;
import appeng.container.slot.*;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.AppEngInternalOversizedInventory;
import appeng.util.Platform;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.ClickType;
import net.minecraft.item.ItemStack;
public class ContainerInterface extends ContainerUpgradeable implements IOptionalSlotHost {
@@ -62,10 +67,23 @@ public class ContainerInterface extends ContainerUpgradeable implements IOptiona
}
for (int x = 0; x < DualityInterface.NUMBER_OF_STORAGE_SLOTS; x++) {
this.addSlotToContainer(new SlotNormal(this.myDuality.getStorage(), x, 8 + 18 * x, 35 + 18));
this.addSlotToContainer(new SlotOversized(this.myDuality.getStorage(), x, 8 + 18 * x, 35 + 18));
}
}
@Override
public ItemStack slotClick(int slotId, int dragType, ClickType clickTypeIn, EntityPlayer player) {
if (slotId >= 0 && slotId < this.inventorySlots.size()) {
if (this.inventorySlots.get(slotId) instanceof SlotOversized) {
((AppEngInternalOversizedInventory) ((SlotOversized) this.inventorySlots.get(slotId)).getItemHandler()).limitExtraction(true);
ItemStack ret = super.slotClick(slotId, dragType, clickTypeIn, player);
((AppEngInternalOversizedInventory) ((SlotOversized) this.inventorySlots.get(slotId)).getItemHandler()).limitExtraction(false);
return ret;
}
}
return super.slotClick(slotId, dragType, clickTypeIn, player);
}
@Override
protected int getHeight() {
return 256;
@@ -0,0 +1,9 @@
package appeng.container.slot;
import net.minecraftforge.items.IItemHandler;
public class SlotOversized extends SlotNormal {
public SlotOversized(IItemHandler inv, int slot, int xPos, int yPos) {
super(inv, slot, xPos, yPos);
}
}