aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/gui
diff options
context:
space:
mode:
authorrepo-alt <wvk17@yandex.ru>2022-08-20 18:41:11 +0300
committerGitHub <noreply@github.com>2022-08-20 18:41:11 +0300
commitcd0868afdd05fd5c3de04a3814e013f008d8c01a (patch)
tree83a98b6acdf12344f18b42a820e8a00d2bcd965c /src/main/java/gregtech/common/gui
parent34641b3e24916e663b8dee0d69cf3f456a28350c (diff)
downloadGT5-Unofficial-cd0868afdd05fd5c3de04a3814e013f008d8c01a.tar.gz
GT5-Unofficial-cd0868afdd05fd5c3de04a3814e013f008d8c01a.tar.bz2
GT5-Unofficial-cd0868afdd05fd5c3de04a3814e013f008d8c01a.zip
Some fixes for the new input bus (#1278)
* Fix a circuit slot position "Borrow" item size rendering from AE2 * Add existing type check
Diffstat (limited to 'src/main/java/gregtech/common/gui')
-rw-r--r--src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java35
-rw-r--r--src/main/java/gregtech/common/gui/GT_GUIContainer_InputBus_ME.java72
2 files changed, 101 insertions, 6 deletions
diff --git a/src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java b/src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java
index ae018657c4..c164d06695 100644
--- a/src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java
+++ b/src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java
@@ -10,9 +10,11 @@ import net.minecraft.item.ItemStack;
import gregtech.api.GregTech_API;
import gregtech.api.gui.GT_ContainerMetaTile_Machine;
import gregtech.api.gui.GT_Slot_Holo;
+import gregtech.api.gui.GT_Slot_Holo_ME;
import gregtech.api.gui.GT_Slot_Render;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.util.GT_Utility;
+import gregtech.common.tileentities.machines.GT_MetaTileEntity_Hatch_InputBus_ME;
public class GT_Container_InputBus_ME extends GT_ContainerMetaTile_Machine {
private static final int LEFT_OFFSET = 8;
@@ -26,12 +28,26 @@ public class GT_Container_InputBus_ME extends GT_ContainerMetaTile_Machine {
}
@Override
public void addSlots(InventoryPlayer aInventoryPlayer) {
- for (int z = 0; z < 2; ++z)
- for (int y = 0; y < 4; ++y)
- for (int x = 0; x < 4; ++x)
- addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, x + y * 4 + z * 16,
- LEFT_OFFSET + x * SLOT_SIZE + z * 90, TOP_OFFSET + y * SLOT_SIZE, false, true, 1));
- addSlotToContainer(slotCircuit = new GT_Slot_Render(mTileEntity, CIRCUIT_SLOT, 153, 63));
+ for (int y = 0; y < 4; ++y)
+ for (int x = 0; x < 4; ++x)
+ addSlotToContainer(new GT_Slot_Holo(this.mTileEntity, x + y * 4,
+ LEFT_OFFSET + x * SLOT_SIZE, TOP_OFFSET + y * SLOT_SIZE, false, true, 1));
+ for (int y = 0; y < 4; ++y)
+ for (int x = 0; x < 4; ++x) {
+ GT_Slot_Holo_ME slot = new GT_Slot_Holo_ME(this.mTileEntity, x + y * 4 + 16,
+ LEFT_OFFSET + x * SLOT_SIZE + 90, TOP_OFFSET + y * SLOT_SIZE, false, true);
+ addSlotToContainer(slot);
+ }
+ addSlotToContainer(slotCircuit = new GT_Slot_Render(mTileEntity, CIRCUIT_SLOT, 80, 63));
+ }
+
+ private boolean containsSuchStack(ItemStack tStack) {
+ for (int i = 0; i < 16; ++i) {
+ Slot tSlot = (Slot) this.inventorySlots.get(i);
+ if (tSlot != null && GT_Utility.areStacksEqual(tSlot.getStack(), tStack, false))
+ return true;
+ }
+ return false;
}
@Override
@@ -46,8 +62,15 @@ public class GT_Container_InputBus_ME extends GT_ContainerMetaTile_Machine {
tSlot.putStack(null);
}
else {
+ if (containsSuchStack(tStack))
+ return null;
tSlot.putStack(GT_Utility.copyAmount(1L, new Object[] {tStack}));
}
+ if (mTileEntity.isServerSide()) {
+ ItemStack newInfo = ((GT_MetaTileEntity_Hatch_InputBus_ME) mTileEntity.getMetaTileEntity()).updateInformationSlot(aSlotIndex, tStack);
+ ((Slot) this.inventorySlots.get(aSlotIndex + 16)).putStack(newInfo);
+ detectAndSendChanges();
+ }
return null;
}
}
diff --git a/src/main/java/gregtech/common/gui/GT_GUIContainer_InputBus_ME.java b/src/main/java/gregtech/common/gui/GT_GUIContainer_InputBus_ME.java
index 5aefb98e55..08801d1473 100644
--- a/src/main/java/gregtech/common/gui/GT_GUIContainer_InputBus_ME.java
+++ b/src/main/java/gregtech/common/gui/GT_GUIContainer_InputBus_ME.java
@@ -2,20 +2,34 @@ package gregtech.common.gui;
import java.util.List;
+import net.minecraft.client.gui.inventory.GuiContainer;
+import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.player.InventoryPlayer;
+import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.StatCollector;
+import appeng.client.render.AppEngRenderItem;
+import appeng.core.AELog;
+import appeng.integration.IntegrationRegistry;
+import appeng.integration.IntegrationType;
+import appeng.integration.abstraction.INEI;
+import appeng.util.Platform;
+import cpw.mods.fml.common.Optional;
import gregtech.api.GregTech_API;
import gregtech.api.enums.GT_Values;
import gregtech.api.gui.GT_GUIContainerMetaTile_Machine;
import gregtech.api.gui.GT_GUIDialogSelectItem;
+import gregtech.api.gui.GT_Slot_Holo;
+import gregtech.api.gui.GT_Slot_Holo_ME;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.net.GT_Packet_SetConfigurationCircuit_Bus;
import gregtech.api.util.GT_Utility;
public class GT_GUIContainer_InputBus_ME extends GT_GUIContainerMetaTile_Machine {
+ private final AppEngRenderItem aeRenderItem = new AppEngRenderItem();
+
public GT_GUIContainer_InputBus_ME(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) {
super(new GT_Container_InputBus_ME(aInventoryPlayer, aTileEntity), "gregtech:textures/gui/InputBusME.png");
getContainer().setCircuitSlotClickCallback(this::openSelectCircuitDialog);
@@ -50,4 +64,62 @@ public class GT_GUIContainer_InputBus_ME extends GT_GUIContainerMetaTile_Machin
GT_Utility.findMatchingStackInList(circuits,
mContainer.mTileEntity.getStackInSlot(GT_Container_InputBus_ME.CIRCUIT_SLOT))));
}
+
+ // base method is made public by AE2 ASM
+ public void func_146977_a( final Slot s )
+ {
+ this.drawSlot( s );
+ }
+
+
+ @Optional.Method(modid = "appliedenergistics2")
+ private RenderItem setItemRender( final RenderItem item )
+ {
+ if( IntegrationRegistry.INSTANCE.isEnabled( IntegrationType.NEI ) )
+ {
+ return ( (INEI) IntegrationRegistry.INSTANCE.getInstance( IntegrationType.NEI ) ).setItemRender( item );
+ }
+ else
+ {
+ final RenderItem ri = itemRender;
+ itemRender = item;
+ return ri;
+ }
+ }
+
+ @Optional.Method(modid = "appliedenergistics2")
+ private void drawSlot( final Slot s )
+ {
+ if (s instanceof GT_Slot_Holo_ME) {
+ final RenderItem pIR = this.setItemRender( this.aeRenderItem );
+ try
+ {
+ this.zLevel = 0.0F;
+ itemRender.zLevel = 0.0F;
+
+ this.aeRenderItem.setAeStack( Platform.getAEStackInSlot( s ) );
+
+ this.safeDrawSlot( s );
+ }
+ catch( final Exception err )
+ {
+ AELog.warn( "[AppEng] AE prevented crash while drawing slot: " + err.toString() );
+ }
+ this.setItemRender( pIR );
+ return;
+ }
+ safeDrawSlot(s);
+ }
+
+ @Optional.Method(modid = "appliedenergistics2")
+ private void safeDrawSlot( final Slot s )
+ {
+ try
+ {
+ GuiContainer.class.getDeclaredMethod( "func_146977_a_original", Slot.class ).invoke( this, s );
+ }
+ catch( final Exception err )
+ {
+ }
+ }
}