From 83ebeadd3b867f45914972f4573211b3324ca433 Mon Sep 17 00:00:00 2001 From: miozune Date: Fri, 16 Aug 2024 22:26:16 +0900 Subject: Cleanup (#2904) * Remove redundant inputSeparation=true call * Remove deprecated MetaTileEntity#isDisplaySecondaryDescription * Always use ModularUI * Remove useModularUI * Remove unused GUI features * Remove IGlobalWirelessEnergy * Remove CommonValues.V & CommonValues.VN * More deprecation cleanup --------- Co-authored-by: boubou19 --- src/main/java/gregtech/api/gui/GT_Container.java | 740 --------------------- .../api/gui/GT_ContainerMetaTile_Machine.java | 244 ------- .../java/gregtech/api/gui/GT_Container_1by1.java | 30 - .../java/gregtech/api/gui/GT_Container_2by2.java | 33 - .../java/gregtech/api/gui/GT_Container_3by3.java | 38 -- .../java/gregtech/api/gui/GT_Container_4by4.java | 45 -- .../gregtech/api/gui/GT_Container_BasicTank.java | 138 ---- .../api/gui/GT_Container_MultiMachine.java | 39 -- .../java/gregtech/api/gui/GT_GUIColorOverride.java | 1 + .../java/gregtech/api/gui/GT_GUIContainer.java | 99 --- .../api/gui/GT_GUIContainerMetaTile_Machine.java | 271 -------- .../gregtech/api/gui/GT_GUIContainer_1by1.java | 42 -- .../gregtech/api/gui/GT_GUIContainer_2by2.java | 42 -- .../gregtech/api/gui/GT_GUIContainer_3by3.java | 42 -- .../gregtech/api/gui/GT_GUIContainer_4by4.java | 42 -- .../api/gui/GT_GUIContainer_BasicTank.java | 47 -- .../api/gui/GT_GUIContainer_MultiMachine.java | 173 ----- src/main/java/gregtech/api/gui/GT_GUICover.java | 55 -- .../gregtech/api/gui/GT_GUIDialogSelectItem.java | 229 ------- src/main/java/gregtech/api/gui/GT_GUIScreen.java | 327 --------- src/main/java/gregtech/api/gui/GT_Slot_Armor.java | 30 - .../java/gregtech/api/gui/GT_Slot_DataOrb.java | 19 - src/main/java/gregtech/api/gui/GT_Slot_Holo.java | 77 --- src/main/java/gregtech/api/gui/GT_Slot_Output.java | 17 - src/main/java/gregtech/api/gui/GT_Slot_Render.java | 24 - .../api/gui/widgets/GT_GuiCoverTabLine.java | 179 ----- .../api/gui/widgets/GT_GuiFakeItemButton.java | 162 ----- .../java/gregtech/api/gui/widgets/GT_GuiIcon.java | 157 ----- .../gregtech/api/gui/widgets/GT_GuiIconButton.java | 114 ---- .../api/gui/widgets/GT_GuiIconCheckButton.java | 43 -- .../api/gui/widgets/GT_GuiIntegerTextBox.java | 73 -- .../api/gui/widgets/GT_GuiSlotTooltip.java | 24 - .../api/gui/widgets/GT_GuiSmartTooltip.java | 27 - .../java/gregtech/api/gui/widgets/GT_GuiTab.java | 174 ----- .../gregtech/api/gui/widgets/GT_GuiTabLine.java | 274 -------- .../gregtech/api/gui/widgets/GT_GuiTooltip.java | 121 ---- .../api/gui/widgets/GT_GuiTooltipManager.java | 80 --- 37 files changed, 1 insertion(+), 4271 deletions(-) delete mode 100644 src/main/java/gregtech/api/gui/GT_Container.java delete mode 100644 src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java delete mode 100644 src/main/java/gregtech/api/gui/GT_Container_1by1.java delete mode 100644 src/main/java/gregtech/api/gui/GT_Container_2by2.java delete mode 100644 src/main/java/gregtech/api/gui/GT_Container_3by3.java delete mode 100644 src/main/java/gregtech/api/gui/GT_Container_4by4.java delete mode 100644 src/main/java/gregtech/api/gui/GT_Container_BasicTank.java delete mode 100644 src/main/java/gregtech/api/gui/GT_Container_MultiMachine.java delete mode 100644 src/main/java/gregtech/api/gui/GT_GUIContainer.java delete mode 100644 src/main/java/gregtech/api/gui/GT_GUIContainerMetaTile_Machine.java delete mode 100644 src/main/java/gregtech/api/gui/GT_GUIContainer_1by1.java delete mode 100644 src/main/java/gregtech/api/gui/GT_GUIContainer_2by2.java delete mode 100644 src/main/java/gregtech/api/gui/GT_GUIContainer_3by3.java delete mode 100644 src/main/java/gregtech/api/gui/GT_GUIContainer_4by4.java delete mode 100644 src/main/java/gregtech/api/gui/GT_GUIContainer_BasicTank.java delete mode 100644 src/main/java/gregtech/api/gui/GT_GUIContainer_MultiMachine.java delete mode 100644 src/main/java/gregtech/api/gui/GT_GUICover.java delete mode 100644 src/main/java/gregtech/api/gui/GT_GUIDialogSelectItem.java delete mode 100644 src/main/java/gregtech/api/gui/GT_GUIScreen.java delete mode 100644 src/main/java/gregtech/api/gui/GT_Slot_Armor.java delete mode 100644 src/main/java/gregtech/api/gui/GT_Slot_DataOrb.java delete mode 100644 src/main/java/gregtech/api/gui/GT_Slot_Holo.java delete mode 100644 src/main/java/gregtech/api/gui/GT_Slot_Output.java delete mode 100644 src/main/java/gregtech/api/gui/GT_Slot_Render.java delete mode 100644 src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java delete mode 100644 src/main/java/gregtech/api/gui/widgets/GT_GuiFakeItemButton.java delete mode 100644 src/main/java/gregtech/api/gui/widgets/GT_GuiIcon.java delete mode 100644 src/main/java/gregtech/api/gui/widgets/GT_GuiIconButton.java delete mode 100644 src/main/java/gregtech/api/gui/widgets/GT_GuiIconCheckButton.java delete mode 100644 src/main/java/gregtech/api/gui/widgets/GT_GuiIntegerTextBox.java delete mode 100644 src/main/java/gregtech/api/gui/widgets/GT_GuiSlotTooltip.java delete mode 100644 src/main/java/gregtech/api/gui/widgets/GT_GuiSmartTooltip.java delete mode 100644 src/main/java/gregtech/api/gui/widgets/GT_GuiTab.java delete mode 100644 src/main/java/gregtech/api/gui/widgets/GT_GuiTabLine.java delete mode 100644 src/main/java/gregtech/api/gui/widgets/GT_GuiTooltip.java delete mode 100644 src/main/java/gregtech/api/gui/widgets/GT_GuiTooltipManager.java (limited to 'src/main/java/gregtech/api/gui') diff --git a/src/main/java/gregtech/api/gui/GT_Container.java b/src/main/java/gregtech/api/gui/GT_Container.java deleted file mode 100644 index 851e1f6461..0000000000 --- a/src/main/java/gregtech/api/gui/GT_Container.java +++ /dev/null @@ -1,740 +0,0 @@ -package gregtech.api.gui; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.IFluidContainerItem; - -import gregtech.api.interfaces.IFluidAccess; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Log; -import gregtech.api.util.GT_Utility; - -/** - * The main Container class. It is used for all GregTech GUIs. - *

- * Never include this file in your mod - it will break your modpack. - */ -public class GT_Container extends Container { - - public IGregTechTileEntity mTileEntity; - public InventoryPlayer mPlayerInventory; - - public GT_Container(InventoryPlayer aPlayerInventory, IGregTechTileEntity aTileEntityInventory) { - - mTileEntity = aTileEntityInventory; - mPlayerInventory = aPlayerInventory; - mTileEntity.openInventory(); - } - - /** - * To add the Slots to your GUI - */ - public void addSlots(InventoryPlayer aPlayerInventory) { - // - } - - /** - * Amount of regular Slots in the GUI (so, non-HoloSlots) - */ - public int getSlotCount() { - return 0; - } - - /** - * Amount of ALL Slots in the GUI including HoloSlots and ArmorSlots, but excluding regular Player Slots - */ - protected final int getAllSlotCount() { - if (inventorySlots != null) { - if (doesBindPlayerInventory()) return inventorySlots.size() - 36; - return inventorySlots.size(); - } - return getSlotCount(); - } - - /** - * Start-Index of the usable Slots (the first non-HoloSlot) - */ - public int getSlotStartIndex() { - return 0; - } - - public int getShiftClickStartIndex() { - return getSlotStartIndex(); - } - - /** - * Amount of Slots in the GUI the player can Shift-Click into. Uses also getSlotStartIndex - */ - public int getShiftClickSlotCount() { - return 0; - } - - /** - * Is Player-Inventory visible? - */ - public boolean doesBindPlayerInventory() { - return true; - } - - /** - * Override this Function with something like "return mTileEntity.isUseableByPlayer(aPlayer);" - */ - @Override - public boolean canInteractWith(EntityPlayer aPlayer) { - return false; - } - - protected void bindPlayerInventory(InventoryPlayer aInventoryPlayer) { - for (int i = 0; i < 3; i++) { - for (int j = 0; j < 9; j++) { - addSlotToContainer(new Slot(aInventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - - for (int i = 0; i < 9; i++) { - addSlotToContainer(new Slot(aInventoryPlayer, i, 8 + i * 18, 142)); - } - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - mTileEntity.markDirty(); - - if (aSlotIndex >= 0) { - if (inventorySlots.get(aSlotIndex) == null || inventorySlots.get(aSlotIndex) instanceof GT_Slot_Holo) - return null; - if (!(inventorySlots.get(aSlotIndex) instanceof GT_Slot_Armor)) if (aSlotIndex < getAllSlotCount()) - if (aSlotIndex < getSlotStartIndex() || aSlotIndex >= getSlotStartIndex() + getSlotCount()) return null; - } - - try { - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - - // It looks like the rest of this code should ideally never be - // called, and might in fact never be called. - - ItemStack rStack = null; - InventoryPlayer aPlayerInventory = aPlayer.inventory; - Slot aSlot; - ItemStack tTempStack; - int tTempStackSize; - ItemStack aHoldStack; - - if ((aShifthold == 0 || aShifthold == 1) && (aMouseclick == 0 || aMouseclick == 1)) { - if (aSlotIndex == -999) { - if (aPlayerInventory.getItemStack() != null) { - if (aMouseclick == 0) { - aPlayer.dropPlayerItemWithRandomChoice(aPlayerInventory.getItemStack(), true); - aPlayerInventory.setItemStack(null); - } - if (aMouseclick == 1) { - aPlayer.dropPlayerItemWithRandomChoice( - aPlayerInventory.getItemStack() - .splitStack(1), - true); - if (aPlayerInventory.getItemStack().stackSize == 0) { - aPlayerInventory.setItemStack(null); - } - } - } - } else if (aShifthold == 1) { - aSlot = this.inventorySlots.get(aSlotIndex); - if (aSlot != null && aSlot.canTakeStack(aPlayer)) { - tTempStack = this.transferStackInSlot(aPlayer, aSlotIndex); - if (tTempStack != null) { - rStack = GT_Utility.copyOrNull(tTempStack); - if (aSlot.getStack() != null && aSlot.getStack() - .getItem() == tTempStack.getItem()) { - slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - } - } - } else { - if (aSlotIndex < 0) { - return null; - } - aSlot = this.inventorySlots.get(aSlotIndex); - if (aSlot != null) { - tTempStack = aSlot.getStack(); - ItemStack mouseStack = aPlayerInventory.getItemStack(); - if (tTempStack != null) { - rStack = GT_Utility.copyOrNull(tTempStack); - } - if (tTempStack == null) { - if (mouseStack != null && aSlot.isItemValid(mouseStack)) { - tTempStackSize = aMouseclick == 0 ? mouseStack.stackSize : 1; - if (tTempStackSize > aSlot.getSlotStackLimit()) { - tTempStackSize = aSlot.getSlotStackLimit(); - } - aSlot.putStack(mouseStack.splitStack(tTempStackSize)); - - if (mouseStack.stackSize == 0) { - aPlayerInventory.setItemStack(null); - } - } - } else if (aSlot.canTakeStack(aPlayer)) { - if (mouseStack == null) { - tTempStackSize = aMouseclick == 0 ? tTempStack.stackSize : (tTempStack.stackSize + 1) / 2; - aHoldStack = aSlot.decrStackSize(tTempStackSize); - aPlayerInventory.setItemStack(aHoldStack); - if (tTempStack.stackSize == 0) { - aSlot.putStack(null); - } - aSlot.onPickupFromSlot(aPlayer, aPlayerInventory.getItemStack()); - } else if (aSlot.isItemValid(mouseStack)) { - if (tTempStack.getItem() == mouseStack.getItem() - && tTempStack.getItemDamage() == mouseStack.getItemDamage() - && ItemStack.areItemStackTagsEqual(tTempStack, mouseStack)) { - tTempStackSize = aMouseclick == 0 ? mouseStack.stackSize : 1; - if (tTempStackSize > aSlot.getSlotStackLimit() - tTempStack.stackSize) { - tTempStackSize = aSlot.getSlotStackLimit() - tTempStack.stackSize; - } - if (tTempStackSize > mouseStack.getMaxStackSize() - tTempStack.stackSize) { - tTempStackSize = mouseStack.getMaxStackSize() - tTempStack.stackSize; - } - mouseStack.splitStack(tTempStackSize); - if (mouseStack.stackSize == 0) { - aPlayerInventory.setItemStack(null); - } - tTempStack.stackSize += tTempStackSize; - } else if (mouseStack.stackSize <= aSlot.getSlotStackLimit()) { - aSlot.putStack(mouseStack); - aPlayerInventory.setItemStack(tTempStack); - } - } else if (tTempStack.getItem() == mouseStack.getItem() && mouseStack.getMaxStackSize() > 1 - && (!tTempStack.getHasSubtypes() - || tTempStack.getItemDamage() == mouseStack.getItemDamage()) - && ItemStack.areItemStackTagsEqual(tTempStack, mouseStack)) { - tTempStackSize = tTempStack.stackSize; - - if (tTempStackSize > 0 - && tTempStackSize + mouseStack.stackSize <= mouseStack.getMaxStackSize()) { - mouseStack.stackSize += tTempStackSize; - tTempStack = aSlot.decrStackSize(tTempStackSize); - - if (tTempStack.stackSize == 0) { - aSlot.putStack(null); - } - - aSlot.onPickupFromSlot(aPlayer, aPlayerInventory.getItemStack()); - } - } - } - aSlot.onSlotChanged(); - } - } - // Did the player try to swap a slot with his hotbar using a - // number key from 1 to 9 - // aMouseclick == 0 means number 1, aMouseclick == 8 means number 9 - } else if (aShifthold == 2 && aMouseclick >= 0 && aMouseclick < 9) { - aSlot = this.inventorySlots.get(aSlotIndex); - - if (aSlot.canTakeStack(aPlayer)) { - // get the stack at the specified hotbar slot. - tTempStack = aPlayerInventory.getStackInSlot(aMouseclick); - boolean canSwap = tTempStack == null - || aSlot.inventory == aPlayerInventory && aSlot.isItemValid(tTempStack); - tTempStackSize = -1; - - if (!canSwap) { - tTempStackSize = aPlayerInventory.getFirstEmptyStack(); - canSwap = tTempStackSize > -1; - } - - if (canSwap && aSlot.getHasStack()) { - aHoldStack = aSlot.getStack(); - aPlayerInventory.setInventorySlotContents(aMouseclick, aHoldStack); - - if (tTempStack != null && (aSlot.inventory != aPlayerInventory || !aSlot.isItemValid(tTempStack))) { - if (tTempStackSize > -1) { - aPlayerInventory.addItemStackToInventory(tTempStack); - aSlot.decrStackSize(aHoldStack.stackSize); - aSlot.putStack(null); - aSlot.onPickupFromSlot(aPlayer, aHoldStack); - } - } else { - aSlot.decrStackSize(aHoldStack.stackSize); - aSlot.putStack(tTempStack); - aSlot.onPickupFromSlot(aPlayer, aHoldStack); - } - } else if (tTempStack != null && !aSlot.getHasStack() && aSlot.isItemValid(tTempStack)) { - aPlayerInventory.setInventorySlotContents(aMouseclick, null); - aSlot.putStack(tTempStack); - } - } - } else if (aShifthold == 3 && aPlayer.capabilities.isCreativeMode - && aPlayerInventory.getItemStack() == null - && aSlotIndex >= 0) { - aSlot = this.inventorySlots.get(aSlotIndex); - if (aSlot != null && aSlot.getHasStack()) { - tTempStack = GT_Utility.copyOrNull(aSlot.getStack()); - tTempStack.stackSize = tTempStack.getMaxStackSize(); - aPlayerInventory.setItemStack(tTempStack); - } - } - return rStack; - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer aPlayer, int aSlotIndex) { - ItemStack stack = null; - Slot slotObject = inventorySlots.get(aSlotIndex); - - mTileEntity.markDirty(); - - // null checks and checks if the item can be stacked (maxStackSize > 1) - if (getSlotCount() > 0 && slotObject != null - && slotObject.getHasStack() - && !(slotObject instanceof GT_Slot_Holo)) { - ItemStack stackInSlot = slotObject.getStack(); - stack = GT_Utility.copyOrNull(stackInSlot); - - // TileEntity -> Player - if (aSlotIndex < getAllSlotCount()) { - if (doesBindPlayerInventory()) - if (!mergeItemStack(stackInSlot, getAllSlotCount(), getAllSlotCount() + 36, true)) { - return null; - } - // Player -> TileEntity - } else if (!mergeItemStack( - stackInSlot, - getShiftClickStartIndex(), - getShiftClickStartIndex() + getShiftClickSlotCount(), - false)) { - return null; - } - - if (stackInSlot.stackSize == 0) { - slotObject.putStack(null); - } else { - slotObject.onSlotChanged(); - } - } - return stack; - } - - /** - * merges provided ItemStack with the first avaliable one in the container/player inventory - */ - @Override - protected boolean mergeItemStack(ItemStack aStack, int aStartIndex, int aSlotCount, boolean reverseOrder) { - boolean transferredStack = false; - int slotIndex = aStartIndex; - - mTileEntity.markDirty(); - - if (reverseOrder) { - slotIndex = aSlotCount - 1; - } - - Slot slot; - ItemStack itemStack; - - if (aStack.isStackable()) { - while (aStack.stackSize > 0 - && (!reverseOrder && slotIndex < aSlotCount || reverseOrder && slotIndex >= aStartIndex)) { - slot = this.inventorySlots.get(slotIndex); - itemStack = slot.getStack(); - if (!(slot instanceof GT_Slot_Holo) && !(slot instanceof GT_Slot_Output) - && slot.isItemValid(aStack) - && itemStack != null - && itemStack.getItem() == aStack.getItem() - && (!aStack.getHasSubtypes() || aStack.getItemDamage() == itemStack.getItemDamage()) - && ItemStack.areItemStackTagsEqual(aStack, itemStack)) { - int combinedStackSize = itemStack.stackSize + aStack.stackSize; - if (itemStack.stackSize < mTileEntity.getInventoryStackLimit()) { - if (combinedStackSize <= aStack.getMaxStackSize()) { - aStack.stackSize = 0; - itemStack.stackSize = combinedStackSize; - slot.onSlotChanged(); - transferredStack = true; - } else if (itemStack.stackSize < aStack.getMaxStackSize()) { - aStack.stackSize -= aStack.getMaxStackSize() - itemStack.stackSize; - itemStack.stackSize = aStack.getMaxStackSize(); - slot.onSlotChanged(); - transferredStack = true; - } - } - } - - if (reverseOrder) { - --slotIndex; - } else { - ++slotIndex; - } - } - } - if (aStack.stackSize > 0) { - if (reverseOrder) { - slotIndex = aSlotCount - 1; - } else { - slotIndex = aStartIndex; - } - - while (!reverseOrder && slotIndex < aSlotCount || reverseOrder && slotIndex >= aStartIndex) { - slot = this.inventorySlots.get(slotIndex); - itemStack = slot.getStack(); - - if (slot.isItemValid(aStack) && itemStack == null) { - int quantityToTransfer = Math.min(aStack.stackSize, mTileEntity.getInventoryStackLimit()); - slot.putStack(GT_Utility.copyAmount(quantityToTransfer, aStack)); - slot.onSlotChanged(); - aStack.stackSize -= quantityToTransfer; - transferredStack = true; - break; - } - - if (reverseOrder) { - --slotIndex; - } else { - ++slotIndex; - } - } - } - - return transferredStack; - } - - @Override - protected Slot addSlotToContainer(Slot slot) { - try { - return super.addSlotToContainer(slot); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - return slot; - } - - @Override - public void addCraftingToCrafters(ICrafting player) { - try { - super.addCraftingToCrafters(player); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - - @Override - public List getInventory() { - try { - return super.getInventory(); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - return null; - } - - @Override - public void removeCraftingFromCrafters(ICrafting player) { - try { - super.removeCraftingFromCrafters(player); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - - @Override - public void detectAndSendChanges() { - try { - super.detectAndSendChanges(); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - - @Override - public boolean enchantItem(EntityPlayer player, int slotIndex) { - try { - return super.enchantItem(player, slotIndex); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - return false; - } - - @Override - public Slot getSlotFromInventory(IInventory inventory, int slotIndex) { - try { - return super.getSlotFromInventory(inventory, slotIndex); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - return null; - } - - @Override - public Slot getSlot(int slotIndex) { - try { - if (this.inventorySlots.size() > slotIndex) return super.getSlot(slotIndex); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - return null; - } - - @Override - public boolean func_94530_a(ItemStack itemStack, Slot slot) { - try { - return super.func_94530_a(itemStack, slot); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - return true; - } - - @Override - protected void retrySlotClick(int slotIndex, int mouseButton, boolean aShifthold, EntityPlayer player) { - try { - super.retrySlotClick(slotIndex, mouseButton, aShifthold, player); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - - @Override - public void onContainerClosed(EntityPlayer player) { - try { - super.onContainerClosed(player); - mTileEntity.closeInventory(); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - - @Override - public void onCraftMatrixChanged(IInventory inventory) { - try { - super.onCraftMatrixChanged(inventory); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - - @Override - public void putStackInSlot(int slotIndex, ItemStack itemStack) { - try { - super.putStackInSlot(slotIndex, itemStack); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - - @Override - public void putStacksInSlots(ItemStack[] itemStacks) { - try { - super.putStacksInSlots(itemStacks); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - - @Override - public void updateProgressBar(int id, int value) { - try { - super.updateProgressBar(id, value); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - - @Override - public short getNextTransactionID(InventoryPlayer inventoryPlayer) { - try { - return super.getNextTransactionID(inventoryPlayer); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - return 0; - } - - @Override - public boolean isPlayerNotUsingContainer(EntityPlayer player) { - try { - return super.isPlayerNotUsingContainer(player); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - return true; - } - - @Override - public void setPlayerIsPresent(EntityPlayer player, boolean value) { - try { - super.setPlayerIsPresent(player, value); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - - @Override - protected void func_94533_d() { - try { - super.func_94533_d(); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - } - - @Override - public boolean canDragIntoSlot(Slot slot) { - try { - return super.canDragIntoSlot(slot); - } catch (Throwable e) { - e.printStackTrace(GT_Log.err); - } - return true; - } - - protected static ItemStack handleFluidSlotClick(IFluidAccess aFluidAccess, EntityPlayer aPlayer, - boolean aProcessFullStack, boolean aCanDrain, boolean aCanFill) { - ItemStack tStackHeld = aPlayer.inventory.getItemStack(); - ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); - if (tStackSizedOne == null || tStackHeld.stackSize == 0) return null; - FluidStack tInputFluid = aFluidAccess.get(); - FluidStack tFluidHeld = GT_Utility.getFluidForFilledItem(tStackSizedOne, true); - if (tFluidHeld != null && tFluidHeld.amount <= 0) tFluidHeld = null; - if (tInputFluid == null) { - // tank empty, consider fill only from now on - if (!aCanFill) - // cannot fill and nothing to take, bail out - return null; - if (tFluidHeld == null) - // no fluid to fill - return null; - return fillFluid(aFluidAccess, aPlayer, tFluidHeld, aProcessFullStack); - } - // tank not empty, both action possible - if (tFluidHeld != null && tInputFluid.amount < aFluidAccess.getCapacity()) { - // both nonnull and have space left for filling. - if (aCanFill) - // actually both pickup and fill is reasonable, but I'll go with fill here - return fillFluid(aFluidAccess, aPlayer, tFluidHeld, aProcessFullStack); - if (!aCanDrain) - // cannot take AND cannot fill, why make this call then? - return null; - // the slot does not allow filling, so try take some - return drainFluid(aFluidAccess, aPlayer, aProcessFullStack); - } else { - // cannot fill and there is something to take - if (!aCanDrain) - // but the slot does not allow taking, so bail out - return null; - return drainFluid(aFluidAccess, aPlayer, aProcessFullStack); - } - } - - protected static ItemStack drainFluid(IFluidAccess aFluidAccess, EntityPlayer aPlayer, boolean aProcessFullStack) { - FluidStack tTankStack = aFluidAccess.get(); - if (tTankStack == null) return null; - ItemStack tStackHeld = aPlayer.inventory.getItemStack(); - ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); - if (tStackSizedOne == null || tStackHeld.stackSize == 0) return null; - int tOriginalFluidAmount = tTankStack.amount; - ItemStack tFilledContainer = GT_Utility.fillFluidContainer(tTankStack, tStackSizedOne, true, false); - if (tFilledContainer == null && tStackSizedOne.getItem() instanceof IFluidContainerItem tContainerItem) { - int tFilledAmount = tContainerItem.fill(tStackSizedOne, tTankStack, true); - if (tFilledAmount > 0) { - tFilledContainer = tStackSizedOne; - tTankStack.amount -= tFilledAmount; - } - } - if (tFilledContainer != null) { - if (aProcessFullStack) { - int tFilledAmount = tOriginalFluidAmount - tTankStack.amount; - /* - * work out how many more items we can fill one cell is already used, so account for that the round down - * behavior will left over a fraction of a cell worth of fluid the user then get to decide what to do - * with it it will not be too fancy if it spills out partially filled cells - */ - int tAdditionalParallel = Math.min(tStackHeld.stackSize - 1, tTankStack.amount / tFilledAmount); - tTankStack.amount -= tFilledAmount * tAdditionalParallel; - tFilledContainer.stackSize += tAdditionalParallel; - } - replaceCursorItemStack(aPlayer, tFilledContainer); - } - aFluidAccess.verifyFluidStack(); - return tFilledContainer; - } - - protected static ItemStack fillFluid(IFluidAccess aFluidAccess, EntityPlayer aPlayer, FluidStack aFluidHeld, - boolean aProcessFullStack) { - // we are not using aMachine.fill() here any more, so we need to check for fluid type here ourselves - if (aFluidAccess.get() != null && !aFluidAccess.get() - .isFluidEqual(aFluidHeld)) return null; - ItemStack tStackHeld = aPlayer.inventory.getItemStack(); - ItemStack tStackSizedOne = GT_Utility.copyAmount(1, tStackHeld); - if (tStackSizedOne == null) return null; - - int tFreeSpace = aFluidAccess.getCapacity() - (aFluidAccess.get() != null ? aFluidAccess.get().amount : 0); - if (tFreeSpace <= 0) - // no space left - return null; - - // find out how much fluid can be taken - // some cells cannot be partially filled - ItemStack tStackEmptied = null; - int tAmountTaken = 0; - if (tFreeSpace >= aFluidHeld.amount) { - // fully accepted - try take it from item now - // IFluidContainerItem is intentionally not checked here. it will be checked later - tStackEmptied = GT_Utility.getContainerForFilledItem(tStackSizedOne, false); - tAmountTaken = aFluidHeld.amount; - } - if (tStackEmptied == null && tStackSizedOne.getItem() instanceof IFluidContainerItem container) { - // either partially accepted, or is IFluidContainerItem - FluidStack tDrained = container.drain(tStackSizedOne, tFreeSpace, true); - if (tDrained != null && tDrained.amount > 0) { - // something is actually drained - change the cell and drop it to player - tStackEmptied = tStackSizedOne; - tAmountTaken = tDrained.amount; - } - } - if (tStackEmptied == null) - // somehow the cell refuse to give out that amount of fluid, no op then - return null; - - // find out how many fill can we do - // same round down behavior as above - // however here the fluid stack is not changed at all, so the exact code will slightly differ - int tParallel = aProcessFullStack ? Math.min(tFreeSpace / tAmountTaken, tStackHeld.stackSize) : 1; - if (aFluidAccess.get() == null) { - FluidStack tNewFillableStack = aFluidHeld.copy(); - tNewFillableStack.amount = tAmountTaken * tParallel; - aFluidAccess.set(tNewFillableStack); - } else { - aFluidAccess.addAmount(tAmountTaken * tParallel); - } - tStackEmptied.stackSize = tParallel; - replaceCursorItemStack(aPlayer, tStackEmptied); - return tStackEmptied; - } - - private static void replaceCursorItemStack(EntityPlayer aPlayer, ItemStack tStackResult) { - int tStackResultMaxStackSize = tStackResult.getMaxStackSize(); - while (tStackResult.stackSize > tStackResultMaxStackSize) { - aPlayer.inventory.getItemStack().stackSize -= tStackResultMaxStackSize; - GT_Utility.addItemToPlayerInventory(aPlayer, tStackResult.splitStack(tStackResultMaxStackSize)); - } - if (aPlayer.inventory.getItemStack().stackSize == tStackResult.stackSize) { - // every cell is mutated. it could just stay on the cursor. - aPlayer.inventory.setItemStack(tStackResult); - } else { - // some cells not mutated. The mutated cells must go into the inventory - // or drop into the world if there isn't enough space. - ItemStack tStackHeld = aPlayer.inventory.getItemStack(); - tStackHeld.stackSize -= tStackResult.stackSize; - GT_Utility.addItemToPlayerInventory(aPlayer, tStackResult); - } - } -} diff --git a/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java b/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java deleted file mode 100644 index a77f376e00..0000000000 --- a/src/main/java/gregtech/api/gui/GT_ContainerMetaTile_Machine.java +++ /dev/null @@ -1,244 +0,0 @@ -package gregtech.api.gui; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.item.ItemStack; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.interfaces.IConfigurationCircuitSupport; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.util.GT_Utility; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - *

- * The Container I use for all my MetaTileEntities - */ -public class GT_ContainerMetaTile_Machine extends GT_Container { - - public int mActive = 0, mMaxProgressTime = 0, mProgressTime = 0, mEnergy = 0, mSteam = 0, mSteamStorage = 0, - mStorage = 0, mOutput = 0, mInput = 0, mID = 0, mDisplayErrorCode = 0; - public long mEnergyLong = 0, mStorageLong = 0; - private int oActive = 0, oMaxProgressTime = 0, oProgressTime = 0, oEnergy = 0, oSteam = 0, oSteamStorage = 0, - oStorage = 0, oOutput = 0, oInput = 0, oID = 0, oDisplayErrorCode = 0; - private long oEnergyLong = 0, oStorageLong = 0; - protected int mTimer = 0; - protected Runnable circuitSlotClickCallback; - - public GT_ContainerMetaTile_Machine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - - mTileEntity = aTileEntity; - - if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { - addSlots(aInventoryPlayer); - if (doesBindPlayerInventory()) bindPlayerInventory(aInventoryPlayer); - detectAndSendChanges(); - } else { - aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer; - } - } - - public GT_ContainerMetaTile_Machine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, - boolean doesBindInventory) { - super(aInventoryPlayer, aTileEntity); - mTileEntity = aTileEntity; - - if (mTileEntity != null && mTileEntity.getMetaTileEntity() != null) { - addSlots(aInventoryPlayer); - if (doesBindPlayerInventory() && doesBindInventory) bindPlayerInventory(aInventoryPlayer); - detectAndSendChanges(); - } else { - aInventoryPlayer.player.openContainer = aInventoryPlayer.player.inventoryContainer; - } - } - - protected void addCircuitSlot() { - if (mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport ccs) { - GT_Slot_Render slotCircuit = new GT_Slot_Render( - mTileEntity, - ccs.getCircuitSlot(), - ccs.getCircuitSlotX(), - ccs.getCircuitSlotY()); - addSlotToContainer(slotCircuit); - slotCircuit.setEnabled(ccs.allowSelectCircuit()); - } - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addCircuitSlot(); - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; - mStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getEUCapacity()); - mStorageLong = mTileEntity.getEUCapacity(); - mEnergy = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getStoredEU()); - mEnergyLong = mTileEntity.getStoredEU(); - mSteamStorage = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getSteamCapacity()); - mSteam = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getStoredSteam()); - mOutput = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getOutputVoltage()); - mInput = (int) Math.min(Integer.MAX_VALUE, mTileEntity.getInputVoltage()); - mDisplayErrorCode = mTileEntity.getErrorDisplayID(); - mProgressTime = mTileEntity.getProgress(); - mMaxProgressTime = mTileEntity.getMaxProgress(); - mActive = mTileEntity.isActive() ? 1 : 0; - mTimer++; - - for (ICrafting player : this.crafters) { - if (mTimer % 500 == 10 || oEnergy != mEnergy) { - player.sendProgressBarUpdate(this, 0, mEnergy & 65535); - player.sendProgressBarUpdate(this, 1, mEnergy >>> 16); - } - if (mTimer % 500 == 10 || oStorage != mStorage) { - player.sendProgressBarUpdate(this, 2, mStorage & 65535); - player.sendProgressBarUpdate(this, 3, mStorage >>> 16); - } - if (mTimer % 500 == 10 || oOutput != mOutput) { - player.sendProgressBarUpdate(this, 4, mOutput); - } - if (mTimer % 500 == 10 || oInput != mInput) { - player.sendProgressBarUpdate(this, 5, mInput); - } - if (mTimer % 500 == 10 || oDisplayErrorCode != mDisplayErrorCode) { - player.sendProgressBarUpdate(this, 6, mDisplayErrorCode); - } - if (mTimer % 500 == 10 || oProgressTime != mProgressTime) { - player.sendProgressBarUpdate(this, 11, mProgressTime & 65535); - player.sendProgressBarUpdate(this, 12, mProgressTime >>> 16); - } - if (mTimer % 500 == 10 || oMaxProgressTime != mMaxProgressTime) { - player.sendProgressBarUpdate(this, 13, mMaxProgressTime & 65535); - player.sendProgressBarUpdate(this, 14, mMaxProgressTime >>> 16); - } - if (mTimer % 500 == 10 || oID != mID) { - player.sendProgressBarUpdate(this, 15, mID); - } - if (mTimer % 500 == 10 || oActive != mActive) { - player.sendProgressBarUpdate(this, 16, mActive); - } - if (mTimer % 500 == 10 || oSteam != mSteam) { - player.sendProgressBarUpdate(this, 17, mSteam & 65535); - player.sendProgressBarUpdate(this, 18, mSteam >>> 16); - } - if (mTimer % 500 == 10 || oSteamStorage != mSteamStorage) { - player.sendProgressBarUpdate(this, 19, mSteamStorage & 65535); - player.sendProgressBarUpdate(this, 20, mSteamStorage >>> 16); - } - if (mTimer % 500 == 10 || oEnergyLong != mEnergyLong) { - player.sendProgressBarUpdate(this, 21, (int) mEnergyLong); - player.sendProgressBarUpdate(this, 22, (int) (mEnergyLong >>> 32)); - } - if (mTimer % 500 == 10 || oStorageLong != mStorageLong) { - player.sendProgressBarUpdate(this, 23, (int) mStorageLong); - player.sendProgressBarUpdate(this, 24, (int) (mStorageLong >>> 32)); - } - } - - oID = mID; - oSteam = mSteam; - oInput = mInput; - oActive = mActive; - oOutput = mOutput; - oEnergy = mEnergy; - oEnergyLong = mEnergyLong; - oStorage = mStorage; - oStorageLong = mStorageLong; - oSteamStorage = mSteamStorage; - oProgressTime = mProgressTime; - oMaxProgressTime = mMaxProgressTime; - oDisplayErrorCode = mDisplayErrorCode; - } - - @SideOnly(Side.CLIENT) - @Override - public void updateProgressBar(int id, int value) { - super.updateProgressBar(id, value); - switch (id) { - case 0 -> mEnergy = mEnergy & 0xffff0000 | value & 0x0000ffff; - case 1 -> mEnergy = mEnergy & 0x0000ffff | value << 16; - case 2 -> mStorage = mStorage & 0xffff0000 | value & 0x0000ffff; - case 3 -> mStorage = mStorage & 0x0000ffff | value << 16; - case 4 -> mOutput = value; - case 5 -> mInput = value; - case 6 -> mDisplayErrorCode = value; - case 11 -> mProgressTime = mProgressTime & 0xffff0000 | value; - case 12 -> mProgressTime = mProgressTime & 0x0000ffff | value << 16; - case 13 -> mMaxProgressTime = mMaxProgressTime & 0xffff0000 | value & 0x0000ffff; - case 14 -> mMaxProgressTime = mMaxProgressTime & 0x0000ffff | value << 16; - case 15 -> mID = value; - case 16 -> mActive = value; - case 17 -> mSteam = mSteam & 0xffff0000 | value & 0x0000ffff; - case 18 -> mSteam = mSteam & 0x0000ffff | value << 16; - case 19 -> mSteamStorage = mSteamStorage & 0xffff0000 | value & 0x0000ffff; - case 20 -> mSteamStorage = mSteamStorage & 0x0000ffff | value << 16; - case 21 -> mEnergyLong = mEnergyLong & 0xffffffff00000000L | value & 0x00000000ffffffffL; - case 22 -> mEnergyLong = mEnergyLong & 0x00000000ffffffffL | (long) value << 32; - case 23 -> mStorageLong = mStorageLong & 0xffffffff00000000L | value & 0x00000000ffffffffL; - case 24 -> mStorageLong = mStorageLong & 0x00000000ffffffffL | (long) value << 32; - } - } - - @Override - public boolean canInteractWith(EntityPlayer player) { - return mTileEntity.isUseableByPlayer(player); - } - - @Deprecated - public String trans(String aKey, String aEnglish) { - return GT_Utility.trans(aKey, aEnglish); - } - - public void setCircuitSlotClickCallback(Runnable circuitSlotClickCallback) { - this.circuitSlotClickCallback = circuitSlotClickCallback; - } - - @Override - public ItemStack slotClick(int aSlotNumber, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (mTileEntity.getMetaTileEntity() instanceof IConfigurationCircuitSupport) { - IMetaTileEntity machine = mTileEntity.getMetaTileEntity(); - IConfigurationCircuitSupport ccs = (IConfigurationCircuitSupport) machine; - if (ccs.allowSelectCircuit() && aSlotNumber == ccs.getCircuitGUISlot() && aMouseclick < 2) { - ItemStack newCircuit; - if (aShifthold == 1) { - if (aMouseclick == 0) { - if (circuitSlotClickCallback != null) circuitSlotClickCallback.run(); - return null; - } else { - // clear - newCircuit = null; - } - } else { - ItemStack cursorStack = aPlayer.inventory.getItemStack(); - List tCircuits = ccs.getConfigurationCircuits(); - int index = GT_Utility.findMatchingStackInList(tCircuits, cursorStack); - if (index < 0) { - int curIndex = GT_Utility - .findMatchingStackInList(tCircuits, machine.getStackInSlot(ccs.getCircuitSlot())) + 1; - if (aMouseclick == 0) { - curIndex += 1; - } else { - curIndex -= 1; - } - curIndex = Math.floorMod(curIndex, tCircuits.size() + 1) - 1; - newCircuit = curIndex < 0 ? null : tCircuits.get(curIndex); - } else { - // set to whatever it is - newCircuit = tCircuits.get(index); - } - } - mTileEntity.setInventorySlotContents(ccs.getCircuitSlot(), newCircuit); - return newCircuit; - } - } - return super.slotClick(aSlotNumber, aMouseclick, aShifthold, aPlayer); - } -} diff --git a/src/main/java/gregtech/api/gui/GT_Container_1by1.java b/src/main/java/gregtech/api/gui/GT_Container_1by1.java deleted file mode 100644 index 06efaee5ef..0000000000 --- a/src/main/java/gregtech/api/gui/GT_Container_1by1.java +++ /dev/null @@ -1,30 +0,0 @@ -package gregtech.api.gui; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - -@Deprecated -public class GT_Container_1by1 extends GT_ContainerMetaTile_Machine { - - public GT_Container_1by1(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(mTileEntity, 0, 80, 35)); - super.addSlots(aInventoryPlayer); - } - - @Override - public int getSlotCount() { - return 1; - } - - @Override - public int getShiftClickSlotCount() { - return 1; - } -} diff --git a/src/main/java/gregtech/api/gui/GT_Container_2by2.java b/src/main/java/gregtech/api/gui/GT_Container_2by2.java deleted file mode 100644 index 4e3584a0a6..0000000000 --- a/src/main/java/gregtech/api/gui/GT_Container_2by2.java +++ /dev/null @@ -1,33 +0,0 @@ -package gregtech.api.gui; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - -@Deprecated -public class GT_Container_2by2 extends GT_ContainerMetaTile_Machine { - - public GT_Container_2by2(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(mTileEntity, 0, 71, 26)); - addSlotToContainer(new Slot(mTileEntity, 1, 89, 26)); - addSlotToContainer(new Slot(mTileEntity, 2, 71, 44)); - addSlotToContainer(new Slot(mTileEntity, 3, 89, 44)); - super.addSlots(aInventoryPlayer); - } - - @Override - public int getSlotCount() { - return 4; - } - - @Override - public int getShiftClickSlotCount() { - return 4; - } -} diff --git a/src/main/java/gregtech/api/gui/GT_Container_3by3.java b/src/main/java/gregtech/api/gui/GT_Container_3by3.java deleted file mode 100644 index 4c0f7f946b..0000000000 --- a/src/main/java/gregtech/api/gui/GT_Container_3by3.java +++ /dev/null @@ -1,38 +0,0 @@ -package gregtech.api.gui; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - -@Deprecated -public class GT_Container_3by3 extends GT_ContainerMetaTile_Machine { - - public GT_Container_3by3(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(mTileEntity, 0, 62, 17)); - addSlotToContainer(new Slot(mTileEntity, 1, 80, 17)); - addSlotToContainer(new Slot(mTileEntity, 2, 98, 17)); - addSlotToContainer(new Slot(mTileEntity, 3, 62, 35)); - addSlotToContainer(new Slot(mTileEntity, 4, 80, 35)); - addSlotToContainer(new Slot(mTileEntity, 5, 98, 35)); - addSlotToContainer(new Slot(mTileEntity, 6, 62, 53)); - addSlotToContainer(new Slot(mTileEntity, 7, 80, 53)); - addSlotToContainer(new Slot(mTileEntity, 8, 98, 53)); - super.addSlots(aInventoryPlayer); - } - - @Override - public int getSlotCount() { - return 9; - } - - @Override - public int getShiftClickSlotCount() { - return 9; - } -} diff --git a/src/main/java/gregtech/api/gui/GT_Container_4by4.java b/src/main/java/gregtech/api/gui/GT_Container_4by4.java deleted file mode 100644 index db5cde4cfe..0000000000 --- a/src/main/java/gregtech/api/gui/GT_Container_4by4.java +++ /dev/null @@ -1,45 +0,0 @@ -package gregtech.api.gui; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - -@Deprecated -public class GT_Container_4by4 extends GT_ContainerMetaTile_Machine { - - public GT_Container_4by4(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(mTileEntity, 0, 53, 8)); - addSlotToContainer(new Slot(mTileEntity, 1, 71, 8)); - addSlotToContainer(new Slot(mTileEntity, 2, 89, 8)); - addSlotToContainer(new Slot(mTileEntity, 3, 107, 8)); - addSlotToContainer(new Slot(mTileEntity, 4, 53, 26)); - addSlotToContainer(new Slot(mTileEntity, 5, 71, 26)); - addSlotToContainer(new Slot(mTileEntity, 6, 89, 26)); - addSlotToContainer(new Slot(mTileEntity, 7, 107, 26)); - addSlotToContainer(new Slot(mTileEntity, 8, 53, 44)); - addSlotToContainer(new Slot(mTileEntity, 9, 71, 44)); - addSlotToContainer(new Slot(mTileEntity, 10, 89, 44)); - addSlotToContainer(new Slot(mTileEntity, 11, 107, 44)); - addSlotToContainer(new Slot(mTileEntity, 12, 53, 62)); - addSlotToContainer(new Slot(mTileEntity, 13, 71, 62)); - addSlotToContainer(new Slot(mTileEntity, 14, 89, 62)); - addSlotToContainer(new Slot(mTileEntity, 15, 107, 62)); - super.addSlots(aInventoryPlayer); - } - - @Override - public int getSlotCount() { - return 16; - } - - @Override - public int getShiftClickSlotCount() { - return 16; - } -} diff --git a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java b/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java deleted file mode 100644 index 403de4bab5..0000000000 --- a/src/main/java/gregtech/api/gui/GT_Container_BasicTank.java +++ /dev/null @@ -1,138 +0,0 @@ -package gregtech.api.gui; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.ICrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.interfaces.IFluidAccess; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicTank; -import gregtech.api.util.GT_Utility; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - *

- * The Container I use for all my Basic Tanks - */ -public class GT_Container_BasicTank extends GT_ContainerMetaTile_Machine { - - public int mContent = 0; - protected int oContent = 0; - - public GT_Container_BasicTank(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - /** - * Subclasses must ensure third slot (aSlotIndex==2) is drainable fluid display item slot. Otherwise, subclasses - * must intercept the appropriate the slotClick event and call super.slotClick(2, xxx) if necessary - */ - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(mTileEntity, 0, 80, 17)); - addSlotToContainer(new GT_Slot_Output(mTileEntity, 1, 80, 53)); - addSlotToContainer(new GT_Slot_Render(mTileEntity, 2, 59, 42)); - } - - @Override - public ItemStack slotClick(int aSlotIndex, int aMouseclick, int aShifthold, EntityPlayer aPlayer) { - if (aSlotIndex == 2 && aMouseclick < 2) { - GT_MetaTileEntity_BasicTank tTank = (GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity(); - if (mTileEntity.isClientSide()) { - /* - * While a logical client don't really need to process fluid cells upon click (it could have just wait - * for server side to send the result), doing so would result in every fluid interaction having a - * noticeable delay between clicking and changes happening even on single player. I'd imagine this lag - * to become only more severe when playing MP over ethernet, which would have much more latency than a - * memory connection - */ - Slot slot = inventorySlots.get(aSlotIndex); - tTank.setDrainableStack(GT_Utility.getFluidFromDisplayStack(slot.getStack())); - } - IFluidAccess tDrainableAccess = constructFluidAccess(tTank, false); - return handleFluidSlotClick( - tDrainableAccess, - aPlayer, - aMouseclick == 0, - true, - !tTank.isDrainableStackSeparate()); - } - return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer); - } - - @Override - public void detectAndSendChanges() { - super.detectAndSendChanges(); - if (mTileEntity.isClientSide() || mTileEntity.getMetaTileEntity() == null) return; - if (((GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity()).mFluid != null) - mContent = ((GT_MetaTileEntity_BasicTank) mTileEntity.getMetaTileEntity()).mFluid.amount; - else mContent = 0; - sendProgressBar(); - oContent = mContent; - } - - public void sendProgressBar() { - for (ICrafting player : this.crafters) { - if (mTimer % 500 == 0 || oContent != mContent) { - player.sendProgressBarUpdate(this, 100, mContent & 65535); - player.sendProgressBarUpdate(this, 101, mContent >>> 16); - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public void updateProgressBar(int id, int value) { - super.updateProgressBar(id, value); - switch (id) { - case 100 -> mContent = mContent & 0xffff0000 | value & 0x0000ffff; - case 101 -> mContent = mContent & 0xffff | value << 16; - } - } - - @Override - public int getSlotCount() { - return 2; - } - - @Override - public int getShiftClickSlotCount() { - return 1; - } - - protected IFluidAccess constructFluidAccess(GT_MetaTileEntity_BasicTank aTank, boolean aIsFillableStack) { - return new BasicTankFluidAccess(aTank, aIsFillableStack); - } - - static class BasicTankFluidAccess implements IFluidAccess { - - protected final GT_MetaTileEntity_BasicTank mTank; - protected final boolean mIsFillableStack; - - public BasicTankFluidAccess(GT_MetaTileEntity_BasicTank aTank, boolean aIsFillableStack) { - this.mTank = aTank; - this.mIsFillableStack = aIsFillableStack; - } - - @Override - public void set(FluidStack stack) { - if (mIsFillableStack) mTank.setFillableStack(stack); - else mTank.setDrainableStack(stack); - } - - @Override - public FluidStack get() { - return mIsFillableStack ? mTank.getFillableStack() : mTank.getDrainableStack(); - } - - @Override - public int getCapacity() { - return mTank.getCapacity(); - } - } -} diff --git a/src/main/java/gregtech/api/gui/GT_Container_MultiMachine.java b/src/main/java/gregtech/api/gui/GT_Container_MultiMachine.java deleted file mode 100644 index 142b84e008..0000000000 --- a/src/main/java/gregtech/api/gui/GT_Container_MultiMachine.java +++ /dev/null @@ -1,39 +0,0 @@ -package gregtech.api.gui; - -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Slot; - -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - *

- * The Container I use for all my Basic Machines - */ -@Deprecated -public class GT_Container_MultiMachine extends GT_ContainerMetaTile_Machine { - - public GT_Container_MultiMachine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) { - super(aInventoryPlayer, aTileEntity); - } - - public GT_Container_MultiMachine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, - boolean bindInventory) { - super(aInventoryPlayer, aTileEntity, bindInventory); - } - - @Override - public void addSlots(InventoryPlayer aInventoryPlayer) { - addSlotToContainer(new Slot(mTileEntity, 1, 152, 5)); - } - - @Override - public int getSlotCount() { - return 1; - } - - @Override - public int getShiftClickSlotCount() { - return 1; - } -} diff --git a/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java b/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java index 304e792a2a..6ade7b030d 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java +++ b/src/main/java/gregtech/api/gui/GT_GUIColorOverride.java @@ -18,6 +18,7 @@ import cpw.mods.fml.relauncher.Side; import gregtech.api.GregTech_API; import gregtech.api.util.ColorsMetadataSection; +@SuppressWarnings("UnstableApiUsage") public class GT_GUIColorOverride { private static final Object NOT_FOUND = new Object(); diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer.java b/src/main/java/gregtech/api/gui/GT_GUIContainer.java deleted file mode 100644 index 639bd56162..0000000000 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer.java +++ /dev/null @@ -1,99 +0,0 @@ -package gregtech.api.gui; - -import static gregtech.GT_Mod.GT_FML_LOGGER; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.input.Mouse; - -/** - * NEVER INCLUDE THIS FILE IN YOUR MOD!!! - *

- * Main GUI-Container-Class which basically contains the Code needed to prevent crashes from improperly Coded Items. - */ -public class GT_GUIContainer extends GuiContainer { - - public boolean mCrashed = false; - - public ResourceLocation mGUIbackground; - - public GT_GUIColorOverride colorOverride; - - public String mGUIbackgroundPath; - - public GT_GUIContainer(Container aContainer, String aGUIbackground) { - super(aContainer); - mGUIbackground = new ResourceLocation(mGUIbackgroundPath = aGUIbackground); - colorOverride = GT_GUIColorOverride.get(aGUIbackground); - } - - protected int getTextColorOrDefault(String textType, int defaultColor) { - return colorOverride.getTextColorOrDefault(textType, defaultColor); - } - - public int getLeft() { - return guiLeft; - } - - public int getTop() { - return guiTop; - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - // - } - - @Override - protected void drawGuiContainerBackgroundLayer(float parTicks, int mouseX, int mouseY) { - mc.renderEngine.bindTexture(mGUIbackground); - } - - @Override - public void drawScreen(int mouseX, int mouseY, float parTicks) { - try { - super.drawScreen(mouseX, mouseY, parTicks); - } catch (Throwable e) { - try { - Tessellator.instance.draw(); - } catch (Throwable f) { - // - } - } - } - - @Override - public void handleMouseInput() { - int delta = Mouse.getEventDWheel(); - if (delta != 0) { - int i = Mouse.getEventX() * this.width / this.mc.displayWidth; - int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1; - onMouseWheel(i, j, delta); - } - super.handleMouseInput(); - } - - protected void onMouseWheel(int mx, int my, int delta) {} - - public boolean isMouseOverSlot(int slotIndex, int mx, int my) { - int size = inventorySlots.inventorySlots.size(); - if (slotIndex < 0 || slotIndex >= size) { - // slot does not exist somehow. log and carry on - GT_FML_LOGGER.error("Slot {} required where only {} is present", slotIndex, size); - return false; - } - Slot slot = inventorySlots.getSlot(slotIndex); - return this.func_146978_c(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mx, my); - } - - /* - * @Override protected void drawSlotInve