aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r--src/main/java/gregtech/common/GT_Network.java3
-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
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java21
4 files changed, 29 insertions, 106 deletions
diff --git a/src/main/java/gregtech/common/GT_Network.java b/src/main/java/gregtech/common/GT_Network.java
index 3dfc7b8f84..8db38d86f7 100644
--- a/src/main/java/gregtech/common/GT_Network.java
+++ b/src/main/java/gregtech/common/GT_Network.java
@@ -53,8 +53,7 @@ public class GT_Network extends MessageToMessageCodec<FMLProxyPacket, GT_Packet>
new GT_Packet_SetLockedFluid(),
new GT_Packet_GtTileEntityGuiRequest(),
new GT_Packet_SendCoverData(),
- new GT_Packet_RequestCoverData(),
- new GT_Packet_SetConfigurationCircuit_Bus()
+ new GT_Packet_RequestCoverData()
);
}
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) {
}
}
}
diff --git a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java
index 613e97e911..ec747a79f3 100644
--- a/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java
+++ b/src/main/java/gregtech/common/tileentities/machines/GT_MetaTileEntity_Hatch_InputBus_ME.java
@@ -24,6 +24,7 @@ import cpw.mods.fml.common.Optional;
import gregtech.api.GregTech_API;
import gregtech.api.enums.ItemList;
import gregtech.api.interfaces.ITexture;
+import gregtech.api.interfaces.metatileentity.IConfigurationCircuitSupport;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.MetaTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus;
@@ -34,12 +35,12 @@ import gregtech.common.gui.GT_GUIContainer_InputBus_ME;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_HATCH;
import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_ME_INPUT_HATCH_ACTIVE;
-public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch_InputBus {
+public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch_InputBus implements IConfigurationCircuitSupport {
private static final int SLOT_COUNT = 16;
private BaseActionSource requestSource = null;
private AENetworkProxy gridProxy = null;
- private ItemStack[] shadowInventory = new ItemStack[SLOT_COUNT];
- private int[] savedStackSizes = new int[SLOT_COUNT];
+ private final ItemStack[] shadowInventory = new ItemStack[SLOT_COUNT];
+ private final int[] savedStackSizes = new int[SLOT_COUNT];
private boolean processingRecipe = false;
public GT_MetaTileEntity_Hatch_InputBus_ME(int aID, String aName, String aNameRegional) {
super(aID, aName, aNameRegional, 1, SLOT_COUNT * 2 + 1, new String[] {
@@ -184,10 +185,20 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
public int getCircuitSlot() { return SLOT_COUNT * 2; }
@Override
+ public int getCircuitSlotX() {
+ return 80;
+ }
+
+ @Override
+ public int getCircuitSlotY() {
+ return 63;
+ }
+
+ @Override
public ItemStack getStackInSlot(int aIndex) {
if (!processingRecipe)
return super.getStackInSlot(aIndex);
- if (aIndex < 0 && aIndex > mInventory.length)
+ if (aIndex < 0 || aIndex > mInventory.length)
return null;
if (aIndex >= SLOT_COUNT && aIndex < SLOT_COUNT * 2)
//Display slots
@@ -274,7 +285,6 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
if (GregTech_API.mAE2 && aIndex >= 0 && aIndex < SLOT_COUNT) {
if (aStack == null) {
super.setInventorySlotContents(aIndex + SLOT_COUNT, null);
- return null;
}
else {
AENetworkProxy proxy = getProxy();
@@ -293,7 +303,6 @@ public class GT_MetaTileEntity_Hatch_InputBus_ME extends GT_MetaTileEntity_Hatch
}
catch (final GridAccessException ignored) {
}
- return null;
}
}
return null;