aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/gui
diff options
context:
space:
mode:
authorrepo-alt <wvk17@yandex.ru>2022-08-23 19:44:25 +0300
committerGitHub <noreply@github.com>2022-08-23 18:44:25 +0200
commit6bef2556c78cbbd6bde0f73a9849ab709590c8bd (patch)
tree40146cf238d68c281278e7bd0dd5929656479435 /src/main/java/gregtech/common/gui
parent43e283f28747967af991a7dfc36d70124c5be765 (diff)
downloadGT5-Unofficial-6bef2556c78cbbd6bde0f73a9849ab709590c8bd.tar.gz
GT5-Unofficial-6bef2556c78cbbd6bde0f73a9849ab709590c8bd.tar.bz2
GT5-Unofficial-6bef2556c78cbbd6bde0f73a9849ab709590c8bd.zip
Refactored built-in integrated circuit support (#1284)
* Refactored built-in integrated circuit support Added built-in integrated circuit to input buses * fix spacing
Diffstat (limited to 'src/main/java/gregtech/common/gui')
-rw-r--r--src/main/java/gregtech/common/gui/GT_Container_InputBus_ME.java47
-rw-r--r--src/main/java/gregtech/common/gui/GT_GUIContainer_InputBus_ME.java64
2 files changed, 13 insertions, 98 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 c164d06695..b815856fe4 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
@@ -1,13 +1,10 @@
package gregtech.common.gui;
-import java.util.List;
-
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
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;
@@ -16,13 +13,11 @@ 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 {
+public class GT_Container_InputBus_ME extends GT_ContainerMetaTile_Machine {
private static final int LEFT_OFFSET = 8;
private static final int TOP_OFFSET = 10;
private static final int SLOT_SIZE = 18;
public static final int CIRCUIT_SLOT = 32;
- private Runnable circuitSlotClickCallback;
- GT_Slot_Render slotCircuit;
public GT_Container_InputBus_ME(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity) {
super(aInventoryPlayer, aTileEntity);
}
@@ -38,7 +33,7 @@ public class GT_Container_InputBus_ME extends GT_ContainerMetaTile_Machine {
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));
+ super.addSlots(aInventoryPlayer);
}
private boolean containsSuchStack(ItemStack tStack) {
@@ -64,7 +59,7 @@ public class GT_Container_InputBus_ME extends GT_ContainerMetaTile_Machine {
else {
if (containsSuchStack(tStack))
return null;
- tSlot.putStack(GT_Utility.copyAmount(1L, new Object[] {tStack}));
+ tSlot.putStack(GT_Utility.copyAmount(1L, tStack));
}
if (mTileEntity.isServerSide()) {
ItemStack newInfo = ((GT_MetaTileEntity_Hatch_InputBus_ME) mTileEntity.getMetaTileEntity()).updateInformationSlot(aSlotIndex, tStack);
@@ -74,42 +69,6 @@ public class GT_Container_InputBus_ME extends GT_ContainerMetaTile_Machine {
return null;
}
}
-
- else if (aSlotIndex == CIRCUIT_SLOT && 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<ItemStack> tCircuits = GregTech_API.getConfigurationCircuitList(1);
- int index = GT_Utility.findMatchingStackInList(tCircuits, cursorStack);
- if (index < 0) {
- int curIndex = GT_Utility.findMatchingStackInList(tCircuits, mTileEntity.getStackInSlot(CIRCUIT_SLOT)) + 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(CIRCUIT_SLOT, newCircuit);
- return newCircuit;
- }
return super.slotClick(aSlotIndex, aMouseclick, aShifthold, aPlayer);
}
- public void setCircuitSlotClickCallback(Runnable circuitSlotClickCallback) {
- this.circuitSlotClickCallback = circuitSlotClickCallback;
- }
}
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 08801d1473..51e6289d3d 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
@@ -1,13 +1,9 @@
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;
@@ -16,15 +12,9 @@ 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 {
@@ -32,11 +22,6 @@ public class GT_GUIContainer_InputBus_ME extends GT_GUIContainerMetaTile_Machin
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);
- }
-
- private GT_Container_InputBus_ME getContainer() {
- return (GT_Container_InputBus_ME) mContainer;
}
@Override
@@ -47,40 +32,18 @@ public class GT_GUIContainer_InputBus_ME extends GT_GUIContainerMetaTile_Machin
drawTexturedModalRect(x, y, 0, 0, this.xSize, this.ySize);
}
- private void onCircuitSelected(ItemStack selected) {
- GT_Values.NW.sendToServer(new GT_Packet_SetConfigurationCircuit_Bus(mContainer.mTileEntity, selected));
- // we will not do any validation on client side
- // it doesn't get to actually decide what inventory contains anyway
- mContainer.mTileEntity.setInventorySlotContents(GT_Container_InputBus_ME.CIRCUIT_SLOT, selected);
- }
- private void openSelectCircuitDialog() {
- List<ItemStack> circuits = GregTech_API.getConfigurationCircuitList(1);
- mc.displayGuiScreen(new GT_GUIDialogSelectItem(
- StatCollector.translateToLocal("GT5U.machines.select_circuit"),
- mContainer.mTileEntity.getMetaTileEntity().getStackForm(0),
- this,
- this::onCircuitSelected,
- circuits,
- 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 );
+ private RenderItem setItemRender(final RenderItem item) {
+ if (IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI)) {
+ return ((INEI)IntegrationRegistry.INSTANCE.getInstance(IntegrationType.NEI)).setItemRender(item);
}
- else
- {
+ else {
final RenderItem ri = itemRender;
itemRender = item;
return ri;
@@ -88,22 +51,17 @@ public class GT_GUIContainer_InputBus_ME extends GT_GUIContainerMetaTile_Machin
}
@Optional.Method(modid = "appliedenergistics2")
- private void drawSlot( final Slot s )
- {
+ private void drawSlot( final Slot s ) {
if (s instanceof GT_Slot_Holo_ME) {
final RenderItem pIR = this.setItemRender( this.aeRenderItem );
- try
- {
+ 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() );
+ catch (final Exception err) {
+ AELog.warn( "[AppEng] AE prevented crash while drawing slot: " + err.toString());
}
this.setItemRender( pIR );
return;
@@ -114,12 +72,10 @@ public class GT_GUIContainer_InputBus_ME extends GT_GUIContainerMetaTile_Machin
@Optional.Method(modid = "appliedenergistics2")
private void safeDrawSlot( final Slot s )
{
- try
- {
+ try {
GuiContainer.class.getDeclaredMethod( "func_146977_a_original", Slot.class ).invoke( this, s );
}
- catch( final Exception err )
- {
+ catch (final Exception ignored) {
}
}
}