package gregtech.api.gui; import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine; import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine_Bronze; import gregtech.api.net.GT_Packet_SetConfigurationCircuit; import gregtech.api.util.GT_Utility; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import java.util.ArrayList; import java.util.List; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; /** * NEVER INCLUDE THIS FILE IN YOUR MOD!!! *
* The GUI-Container I use for all my Basic Machines * * As the NEI-RecipeTransferRect Handler can't handle one GUI-Class for all GUIs I needed to produce some dummy-classes which extend this class */ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machine { public final String mName, mNEI; public final byte mProgressBarDirection, mProgressBarAmount; public final boolean mRenderAutoOutputSlots; public GT_GUIContainer_BasicMachine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile, String aNEI) { this(aInventoryPlayer, aTileEntity, aName, aTextureFile, aNEI, (byte) 0, (byte) 1); } public GT_GUIContainer_BasicMachine(InventoryPlayer aInventoryPlayer, IGregTechTileEntity aTileEntity, String aName, String aTextureFile, String aNEI, byte aProgressBarDirection, byte aProgressBarAmount) { super(new GT_Container_BasicMachine(aInventoryPlayer, aTileEntity), RES_PATH_GUI + "basicmachines/" + aTextureFile); getContainer().setCircuitSlotClickCallback(this::openSelectCircuitDialog); mProgressBarDirection = aProgressBarDirection; mProgressBarAmount = (byte) Math.max(1, aProgressBarAmount); mName = aName; mNEI = aNEI; mRenderAutoOutputSlots = !(aTileEntity.getMetaTileEntity() instanceof GT_MetaTileEntity_BasicMachine_Bronze); } private void openSelectCircuitDialog() { mc.displayGuiScreen(new GT_GUIDialogSelectItem( StatCollector.translateToLocal("GT5U.machines.select_circuit"), mContainer.mTileEntity.getMetaTileEntity().getStackForm(0), this, this::onCircuitSelected, getMachine().getConfigurationCircuits(), GT_Utility.findMatchingStackInList(getMachine().getConfigurationCircuits(), getMachine().getStackInSlot(getMachine().getCircuitSlot())))); } private void onCircuitSelected(ItemStack selected) { GT_Values.NW.sendToServer(new GT_Packet_SetConfigurationCircuit(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(getMachine().getCircuitSlot(), selected); } private GT_MetaTileEntity_BasicMachine getMachine() { return (GT_MetaTileEntity_BasicMachine) mContainer.mTileEntity.getMetaTileEntity(); } @Override public void drawScreen(int par1, int par2, float par3) { super.drawScreen(par1, par2, par3); if (mRenderAutoOutputSlots){ drawTooltip(par1, par2); } } @Override protected void drawGuiContainerForegroundLayer(int par1, int par2) { fontRendererObj.drawString(mName, 8, 4, 4210752); } private void drawTooltip(int x2, int y2) { int xStart = (width - xSize) / 2; int yStart = (height - ySize) / 2; int x = x2 - xStart; int y = y2 - yStart + 5; List