Fix WCT invisible stacksizes, OOB when opening pattern terminal

FIx security station card slot being reaaally off
This commit is contained in:
PrototypeTrousers
2022-10-18 23:56:40 -03:00
parent 15a1e8f150
commit 0e0729166f
6 changed files with 30 additions and 28 deletions
@@ -899,7 +899,10 @@ public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContain
if (s instanceof SlotPlayerInv || s instanceof SlotPlayerHotBar) { if (s instanceof SlotPlayerInv || s instanceof SlotPlayerHotBar) {
super.drawSlot(s); super.drawSlot(s);
} else if (s instanceof AppEngSlot) { } else if (s instanceof AppEngSlot) {
((AppEngSlot) s).setDisplay(true); AppEngSlot appEngSlot = ((AppEngSlot) s);
appEngSlot.setDisplay(true);
appEngSlot.setReturnAsSingleStack(true);
this.zLevel = 100.0F; this.zLevel = 100.0F;
this.itemRender.zLevel = 100.0F; this.itemRender.zLevel = 100.0F;
@@ -913,7 +916,7 @@ public abstract class AEBaseGui extends GuiContainer implements IMTModGuiContain
// Annoying but easier than trying to splice into render item // Annoying but easier than trying to splice into render item
super.drawSlot(s); super.drawSlot(s);
this.stackSizeRenderer.renderStackSize(this.fontRenderer, AEItemStack.fromItemStack(((AppEngSlot) s).getDisplayStack()), s.xPos, s.yPos); this.stackSizeRenderer.renderStackSize(this.fontRenderer, AEItemStack.fromItemStack(appEngSlot.getDisplayStack()), s.xPos, s.yPos);
return; return;
} else { } else {
super.drawSlot(s); super.drawSlot(s);
@@ -425,7 +425,7 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
return new ItemStack[]{out}; return new ItemStack[]{out};
} }
} else { } else {
final List<ItemStack> list = new ArrayList<>(); final List<ItemStack> list = new ArrayList<>(outputSlots.length);
boolean hasValue = false; boolean hasValue = false;
for (final OptionalSlotFake outputSlot : this.outputSlots) { for (final OptionalSlotFake outputSlot : this.outputSlots) {
@@ -438,7 +438,7 @@ public abstract class ContainerPatternEncoder extends ContainerMEMonitorable imp
} }
if (hasValue) { if (hasValue) {
return list.toArray(new ItemStack[0]); return list.toArray(new ItemStack[outputSlots.length]);
} }
} }
@@ -21,50 +21,35 @@ package appeng.container.implementations;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.Actionable; import appeng.api.config.Actionable;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.IMEMonitor; import appeng.api.storage.IMEMonitor;
import appeng.api.storage.ITerminalHost; import appeng.api.storage.ITerminalHost;
import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList; import appeng.api.storage.data.IItemList;
import appeng.container.ContainerNull; import appeng.container.ContainerNull;
import appeng.container.guisync.GuiSync;
import appeng.container.slot.AppEngSlot;
import appeng.container.slot.OptionalSlotFake; import appeng.container.slot.OptionalSlotFake;
import appeng.container.slot.SlotFakeCraftingMatrix; import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternOutputs; import appeng.container.slot.SlotPatternOutputs;
import appeng.container.slot.SlotPatternTerm; import appeng.container.slot.SlotPatternTerm;
import appeng.container.slot.SlotPlayerHotBar;
import appeng.container.slot.SlotPlayerInv;
import appeng.container.slot.SlotRestrictedInput; import appeng.container.slot.SlotRestrictedInput;
import appeng.core.sync.packets.PacketPatternSlot; import appeng.core.sync.packets.PacketPatternSlot;
import appeng.items.storage.ItemViewCell; import appeng.items.storage.ItemViewCell;
import appeng.me.helpers.MachineSource; import appeng.me.helpers.MachineSource;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.InventoryAdaptor; import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.AdaptorItemHandler; import appeng.util.inv.AdaptorItemHandler;
import appeng.util.inv.InvOperation;
import appeng.util.inv.WrapperCursorItemHandler; import appeng.util.inv.WrapperCursorItemHandler;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.*; import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.SlotCrafting;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class ContainerPatternTerm extends ContainerPatternEncoder { public class ContainerPatternTerm extends ContainerPatternEncoder {
@@ -91,7 +76,7 @@ public class ContainerPatternTerm extends ContainerPatternEncoder {
.getPowerSource(), monitorable, this.crafting, patternInv, this.cOut, 110, -76 + 18, this, 2, this)); .getPowerSource(), monitorable, this.crafting, patternInv, this.cOut, 110, -76 + 18, this, 2, this));
this.craftSlot.setIIcon(-1); this.craftSlot.setIIcon(-1);
for (int y = 0; y < 3; y++) { for (int y = 0; y < this.outputSlots.length; y++) {
this.addSlotToContainer(this.outputSlots[y] = new SlotPatternOutputs(output, this, y, 110, -76 + y * 18, 0, 0, 1)); this.addSlotToContainer(this.outputSlots[y] = new SlotPatternOutputs(output, this, y, 110, -76 + y * 18, 0, 0, 1));
this.outputSlots[y].setRenderDisabled(false); this.outputSlots[y].setRenderDisabled(false);
this.outputSlots[y].setIIcon(-1); this.outputSlots[y].setIIcon(-1);
@@ -61,7 +61,7 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
this.securityBox = (TileSecurityStation) monitorable; this.securityBox = (TileSecurityStation) monitorable;
this.addSlotToContainer(this.configSlot = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.BIOMETRIC_CARD, this.securityBox this.addSlotToContainer(this.configSlot = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.BIOMETRIC_CARD, this.securityBox
.getConfigSlot(), 0, 37, -33 + jeiOffset, ip)); .getConfigSlot(), 0, 37, -33, ip));
this.addSlotToContainer( this.addSlotToContainer(
this.wirelessIn = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ENCODABLE_ITEM, this.wirelessEncoder, 0, 212, 10 + jeiOffset, ip)); this.wirelessIn = new SlotRestrictedInput(SlotRestrictedInput.PlacableItemType.ENCODABLE_ITEM, this.wirelessEncoder, 0, 212, 10 + jeiOffset, ip));
@@ -46,6 +46,7 @@ public class AppEngSlot extends Slot {
private int IIcon = -1; private int IIcon = -1;
private hasCalculatedValidness isValid; private hasCalculatedValidness isValid;
private boolean isDisplay = false; private boolean isDisplay = false;
private boolean returnAsSingleStack;
public AppEngSlot(final IItemHandler inv, final int idx, final int x, final int y) { public AppEngSlot(final IItemHandler inv, final int idx, final int x, final int y) {
super(emptyInventory, idx, x, y); super(emptyInventory, idx, x, y);
@@ -94,16 +95,29 @@ public class AppEngSlot extends Slot {
return ItemStack.EMPTY; return ItemStack.EMPTY;
} }
if (this.isDisplay()) { if (this.isDisplay()) {
this.setDisplay(false); this.setDisplay(false);
ItemStack retStack = this.getDisplayStack().copy(); if (this.returnAsSingleStack()) {
retStack.setCount(1); setReturnAsSingleStack(false);
return retStack; ItemStack ret = this.getDisplayStack().copy();
ret.setCount(1);
return ret;
}
return this.getDisplayStack();
} }
return this.itemHandler.getStackInSlot(this.index); return this.itemHandler.getStackInSlot(this.index);
} }
private boolean returnAsSingleStack() {
return this.returnAsSingleStack;
}
public void setReturnAsSingleStack(boolean returnAsSingleStack) {
this.returnAsSingleStack = returnAsSingleStack;
}
@Override @Override
public void putStack(final ItemStack stack) { public void putStack(final ItemStack stack) {
if (this.isSlotEnabled()) { if (this.isSlotEnabled()) {
@@ -51,7 +51,7 @@ public class PartPatternTerminal extends AbstractPartEncoder {
public PartPatternTerminal(final ItemStack is) { public PartPatternTerminal(final ItemStack is) {
super(is); super(is);
this.crafting = new AppEngInternalInventory(this, CRAFTING_GRID_DIMENSION * CRAFTING_GRID_DIMENSION); this.crafting = new AppEngInternalInventory(this, CRAFTING_GRID_DIMENSION * CRAFTING_GRID_DIMENSION);
this.output = new AppEngInternalInventory(this, CRAFTING_OUTPUT_LIMIT); this.output = new AppEngInternalInventory(this, 3);
this.pattern = new AppEngInternalInventory(this, 2); this.pattern = new AppEngInternalInventory(this, 2);
} }