diff options
author | Glease <4586901+Glease@users.noreply.github.com> | 2021-12-18 23:59:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-18 16:59:01 +0100 |
commit | edaa52a7c611de1d2cbada493a7458ce893f5c42 (patch) | |
tree | 482640f10f3621086e1a00cdd3ce62146ea8bb30 /src | |
parent | 70d22c3444c3d65e662a03ecfb141cb4c3ae3fa1 (diff) | |
download | GT5-Unofficial-edaa52a7c611de1d2cbada493a7458ce893f5c42.tar.gz GT5-Unofficial-edaa52a7c611de1d2cbada493a7458ce893f5c42.tar.bz2 GT5-Unofficial-edaa52a7c611de1d2cbada493a7458ce893f5c42.zip |
Add tooltip to ghost circuit slot (#821)
Also tweaked allowPutStack to consider configured circuits as well.
Diffstat (limited to 'src')
4 files changed, 38 insertions, 13 deletions
diff --git a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java index f9580aa5fd..dc61578362 100644 --- a/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java +++ b/src/main/java/gregtech/api/gui/GT_GUIContainer_BasicMachine.java @@ -8,10 +8,13 @@ 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.EnumChatFormatting; import net.minecraft.util.StatCollector; -import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; import static gregtech.api.enums.GT_Values.RES_PATH_GUI; @@ -24,6 +27,12 @@ import static gregtech.api.enums.GT_Values.RES_PATH_GUI; */ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machine { + private static final List<String> GHOST_CIRCUIT_TOOLTIP = Arrays.asList( + "GT5U.machines.select_circuit.tooltip", + "GT5U.machines.select_circuit.tooltip.1", + "GT5U.machines.select_circuit.tooltip.2", + "GT5U.machines.select_circuit.tooltip.3" + ); public final String mName, mNEI; @@ -86,17 +95,17 @@ public class GT_GUIContainer_BasicMachine extends GT_GUIContainerMetaTile_Machin int yStart = (height - ySize) / 2; int x = x2 - xStart; int y = y2 - yStart + 5; - List<String> list = new ArrayList<>(); if (y >= 67 && y <= 84) { - if (x >= 7 && x <= 24) { - list.add("Fluid Auto-Output"); + if (mRenderAutoOutputSlots && x >= 7 && x <= 24) { + drawHoveringText(Collections.singletonList("Fluid Auto-Output"), x2, y2, fontRendererObj); } - if (x >= 25 && x <= 42) { - list.add("Item Auto-Output"); + if (mRenderAutoOutputSlots && x >= 25 && x <= 42) { + drawHoveringText(Collections.singletonList("Item Auto-Output"), x2, y2, fontRendererObj); + } + if (getMachine().allowSelectCircuit() && getMachine().getStackInSlot(getMachine().getCircuitSlot()) == null && x >= 153 && x <= 180) { + drawHoveringText(GHOST_CIRCUIT_TOOLTIP.stream().map(StatCollector::translateToLocal).collect(Collectors.toList()), x2, y2, fontRendererObj); } } - if (!list.isEmpty()) - drawHoveringText(list, x2, y2, fontRendererObj); } @Override diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java index d4f19c5fbe..08fbd4c1dc 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine.java @@ -893,6 +893,18 @@ public abstract class GT_MetaTileEntity_BasicMachine extends GT_MetaTileEntity_B return false; } + protected final ItemStack[] appendSelectedCircuit(ItemStack... inputs) { + if (allowSelectCircuit()) { + ItemStack circuit = getStackInSlot(getCircuitSlot()); + if (circuit != null) { + ItemStack[] result = Arrays.copyOf(inputs, inputs.length + 1); + result[inputs.length] = circuit; + return result; + } + } + return inputs; + } + /** * This might be non-final in the future, but for now, no, don't change this. */ diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java index f87f4532e3..feeebf0cf4 100644 --- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java +++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GT_Recipe.java @@ -773,7 +773,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ else return this.getRecipeList().findRecipe( this.getBaseMetaTileEntity(), this.mLastRecipe, true, true, V[this.mTier], new FluidStack[]{this.getFillableStack()}, - this.getSpecialSlot(), new ItemStack[]{aStack} + this.getSpecialSlot(), appendSelectedCircuit(aStack) ) != null; case 2: @@ -790,9 +790,9 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ this.getRecipeList().findRecipe( this.getBaseMetaTileEntity(), this.mLastRecipe, true, true, V[this.mTier], new FluidStack[]{this.getFillableStack()}, - this.getSpecialSlot(), aIndex == this.getInputSlot() ? - new ItemStack[]{aStack, this.getInputAt(1)} : - new ItemStack[]{this.getInputAt(0), aStack} + this.getSpecialSlot(), aIndex == this.getInputSlot() ? + appendSelectedCircuit(aStack, this.getInputAt(1)) : + appendSelectedCircuit(this.getInputAt(0), aStack) ) != null ) ) @@ -803,7 +803,7 @@ public class GT_MetaTileEntity_BasicMachine_GT_Recipe extends GT_MetaTileEntity_ if (tID >= 211 && tID <= 218 || tID >= 1180 && tID <= 1187 || tID >= 10780 && tID <= 10786) { //assembler lv-iv; circuit asseblers lv - uv; assemblers luv-uev if (GT_Utility.isStackValid(aStack)) for (int oreID : OreDictionary.getOreIDs(aStack)) { - if (OreDictionary.getOreName(oreID).contains("circuit")) + if (OreDictionary.getOreName(oreID).startsWith("circuit")) return true; } } diff --git a/src/main/resources/assets/gregtech/lang/en_US.lang b/src/main/resources/assets/gregtech/lang/en_US.lang index 3680bfa9c8..8a75355f64 100644 --- a/src/main/resources/assets/gregtech/lang/en_US.lang +++ b/src/main/resources/assets/gregtech/lang/en_US.lang @@ -81,6 +81,10 @@ GT5U.machines.minermulti=Multiblock Miner GT5U.machines.voidoveflow.enabled=Overflow voiding enabled GT5U.machines.voidoveflow.disabled=Overflow voiding disabled GT5U.machines.select_circuit=Select Machine Mode +GT5U.machines.select_circuit.tooltip=Ghost Circuit Slot +GT5U.machines.select_circuit.tooltip.1=§7LMB/RMB/scroll to cycle through the list +GT5U.machines.select_circuit.tooltip.2=§7Shift left click to open GUI +GT5U.machines.select_circuit.tooltip.3=§7Shift right click to clear GT5U.gui.select.current=Current: |