aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java309
-rw-r--r--src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java40
2 files changed, 335 insertions, 14 deletions
diff --git a/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java
new file mode 100644
index 0000000000..c8914c0b7d
--- /dev/null
+++ b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java
@@ -0,0 +1,309 @@
+package gregtech.api.util;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraft.util.StatCollector;
+
+/**
+ * This makes it easier to build multi tooltips, with a standardized format. <br>
+ * Info section order should be:<br>
+ * addMachineType<br>
+ * addInfo, for what it does, special notes, etc.<br>
+ * addSeparator, if you need it<br>
+ * addPollutionAmount<br>
+ * <br>
+ * Structure order should be:<br>
+ * beginStructureBlock<br>
+ * addController<br>
+ * addCasingInfo<br>
+ * addOtherStructurePart, for secondary structure block info (pipes, coils, etc)<br>
+ * addEnergyHatch/addDynamoHatch<br>
+ * addMaintenanceHatch<br>
+ * addMufflerHatch<br>
+ * addInputBus/addInputHatch/addOutputBus/addOutputHatch, in that order<br>
+ * Use addStructureInfo for any comments on nonstandard structure info wherever needed
+ * <br>
+ * toolTipFinisher<br>
+ * <br>
+ * Originally created by kekzdealer
+ */
+public class GT_Multiblock_Tooltip_Builder {
+ private static final String TAB = " ";
+ private static final String COLON = ": ";
+
+ private final List<String> iLines;
+ private final List<String> sLines;
+
+ private String[] iArray;
+ private String[] sArray;
+
+ //Localized tooltips
+ private static final String TT_machineType = StatCollector.translateToLocal("GT5U.MBTT.MachineType");
+ private static final String TT_dimensions = StatCollector.translateToLocal("GT5U.MBTT.Dimensions");
+ private static final String TT_structure = StatCollector.translateToLocal("GT5U.MBTT.Structure");
+ private static final String TT_controller = StatCollector.translateToLocal("GT5U.MBTT.Controller");
+ private static final String TT_minimum = StatCollector.translateToLocal("GT5U.MBTT.Minimum");
+ private static final String TT_maintenancehatch = StatCollector.translateToLocal("GT5U.MBTT.MaintenanceHatch");
+ private static final String TT_energyhatch = StatCollector.translateToLocal("GT5U.MBTT.EnergyHatch");
+ private static final String TT_dynamohatch = StatCollector.translateToLocal("GT5U.MBTT.DynamoHatch");
+ private static final String TT_mufflerhatch = StatCollector.translateToLocal("GT5U.MBTT.MufflerHatch");
+ private static final String TT_inputbus = StatCollector.translateToLocal("GT5U.MBTT.InputBus");
+ private static final String TT_inputhatch = StatCollector.translateToLocal("GT5U.MBTT.InputHatch");
+ private static final String TT_outputbus = StatCollector.translateToLocal("GT5U.MBTT.OutputBus");
+ private static final String TT_outputhatch = StatCollector.translateToLocal("GT5U.MBTT.OutputHatch");
+ private static final String TT_causes = StatCollector.translateToLocal("GT5U.MBTT.Causes");
+ private static final String TT_pps = StatCollector.translateToLocal("GT5U.MBTT.PPS");
+ private static final String TT_hold = StatCollector.translateToLocal("GT5U.MBTT.Hold");
+ private static final String TT_todisplay = StatCollector.translateToLocal("GT5U.MBTT.Display");
+ private static final String TT_mod = StatCollector.translateToLocal("GT5U.MBTT.Mod");
+
+ public GT_Multiblock_Tooltip_Builder() {
+ iLines = new LinkedList<>();
+ sLines = new LinkedList<>();
+ }
+
+ /**
+ * Add a line telling you what the machine type is. Usually, this will be the name of a SB version.<br>
+ * Machine Type: machine
+ *
+ * @param machine
+ * Name of the machine type
+ *
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addMachineType(String machine) {
+ iLines.add(TT_machineType + EnumChatFormatting.YELLOW + machine + EnumChatFormatting.RESET);
+ return this;
+ }
+
+ /**
+ * Add a basic line of information about this structure
+ *
+ * @param info
+ * The line to be added.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addInfo(String info) {
+ iLines.add(info);
+ return this;
+ }
+
+ /**
+ * Add a separator line like this:<br>
+ * -----------------------------------------
+ *
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addSeparator() {
+ iLines.add("-----------------------------------------");
+ return this;
+ }
+
+ /**
+ * Add a line telling you what the machine type is. Usually, this will be the name of a SB version.<br>
+ * Machine Type: machine
+ *
+ * @param machine
+ * Name of the machine type
+ *
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addPollutionAmount(int pollution) {
+ iLines.add(TT_causes + " " + EnumChatFormatting.DARK_PURPLE + pollution + " " + TT_pps + EnumChatFormatting.RESET);
+ return this;
+ }
+
+ /**
+ * Begin adding structural information by adding a line about the structure's dimensions
+ * and then inserting a "Structure:" line.
+ *
+ * @param w
+ * Structure width.
+ * @param h
+ * Structure height.
+ * @param l
+ * Structure depth/length.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder beginStructureBlock(int w, int h, int l) {
+ sLines.add(TT_dimensions + w + "x" + h + "x" + l + " (WxHxL)");
+ sLines.add(TT_structure);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Controller: info
+ * @param info
+ * Positional information.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addController(String info) {
+ sLines.add(TAB + TT_controller + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)minCountx casingName (minimum)
+ * @param casingName
+ * Name of the Casing.
+ * @param minCount
+ * Minimum needed for valid structure check.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addCasingInfo(String casingName, int minCount) {
+ sLines.add(TAB + minCount +"x " + casingName + " " + TT_minimum);
+ return this;
+ }
+
+ /**
+ * Use this method to add a structural part that isn't covered by the other methods.<br>
+ * (indent)name: info
+ * @param name
+ * Name of the hatch or other component.
+ * @param info
+ * Positional information.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addOtherStructurePart(String name, String info) {
+ sLines.add(TAB + name + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Maintenance Hatch: info
+ * @param info
+ * Positional information.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addMaintenanceHatch(String info) {
+ sLines.add(TAB + TT_maintenancehatch + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Muffler Hatch: info
+ * @param info
+ * Location where the hatch goes
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addMufflerHatch(String info) {
+ sLines.add(TAB + TT_mufflerhatch + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Energy Hatch: info
+ * @param info
+ * Positional information.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addEnergyHatch(String info) {
+ sLines.add(TAB + TT_energyhatch + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Dynamo Hatch: info
+ * @param info
+ * Positional information.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addDynamoHatch(String info) {
+ sLines.add(TAB + TT_dynamohatch + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Input Bus: info
+ * @param info
+ * Location where the bus goes
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addInputBus(String info) {
+ sLines.add(TAB + TT_inputbus + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Input Hatch: info
+ * @param info
+ * Location where the hatch goes
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addInputHatch(String info) {
+ sLines.add(TAB + TT_inputhatch + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Output Bus: info
+ * @param info
+ * Location where the bus goes
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addOutputBus(String info) {
+ sLines.add(TAB + TT_outputbus + info);
+ return this;
+ }
+
+ /**
+ * Add a line of information about the structure:<br>
+ * (indent)Output Hatch: info
+ * @param info
+ * Location where the bus goes
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addOutputHatch(String info) {
+ sLines.add(TAB + TT_outputhatch + info);
+ return this;
+ }
+
+ /**
+ * Use this method to add non-standard structural info.<br>
+ * (indent)info
+ * @param info
+ * The line to be added.
+ * @return Instance this method was called on.
+ */
+ public GT_Multiblock_Tooltip_Builder addStructureInfo(String info) {
+ sLines.add(TAB + info);
+ return this;
+ }
+
+ /**
+ * Call at the very end.<br>
+ * Adds a final line with the mod name and information on how to display the structure guidelines.<br>
+ * Ends the building process.
+ *
+ * @param mod
+ * Name of the mod that adds this multiblock machine
+ */
+ public void toolTipFinisher(String mod) {
+ iLines.add(TT_hold + " " + EnumChatFormatting.BOLD + "[LSHIFT]" + EnumChatFormatting.RESET + EnumChatFormatting.GRAY + " " + TT_todisplay);
+ iLines.add(TT_mod + " " + EnumChatFormatting.GREEN + mod + EnumChatFormatting.RESET);
+ iArray = new String[iLines.size()];
+ sArray = new String[sLines.size()];
+ iLines.toArray(iArray);
+ sLines.toArray(sArray);
+ }
+
+ public String[] getInformation() {
+ return iArray;
+ }
+
+ public String[] getStructureInformation() {
+ return sArray;
+ }
+
+}
diff --git a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java
index fad880e5e4..c5f1852629 100644
--- a/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java
+++ b/src/main/java/gregtech/common/tileentities/machines/multi/GT_MetaTileEntity_LargeChemicalReactor.java
@@ -8,6 +8,7 @@ import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_MultiBlockBase;
import gregtech.api.objects.GT_RenderedTexture;
+import gregtech.api.util.GT_Multiblock_Tooltip_Builder;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import net.minecraft.block.Block;
@@ -18,6 +19,8 @@ import net.minecraftforge.fluids.FluidStack;
import java.util.ArrayList;
+import org.lwjgl.input.Keyboard;
+
public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_MultiBlockBase {
private final int CASING_INDEX = 176;
@@ -37,20 +40,29 @@ public class GT_MetaTileEntity_LargeChemicalReactor extends GT_MetaTileEntity_Mu
@Override
public String[] getDescription() {
- return new String[] {
- "Controller block for the Large Chemical Reactor",
- "Has the same recipes as the Chemical Reactor",
- "Does not lose efficiency when overclocked",
- "Accepts fluids instead of fluid cells",
- "Size(WxHxD): 3x3x3",
- "3x3x3 of Chemically Inert Machine Casings (hollow, min 8!)",
- "Controller (Front centered)",
- "1x PTFE Pipe Machine Casing (inside the hollow casings)",
- "1x Cupronickel Coil Block (next to PTFE Pipe Machine Casing)",
- "1x Input Bus/Hatch (Any inert casing)",
- "1x Output Bus/Hatch (Any inert casing)",
- "1x Maintenance Hatch (Any inert casing)",
- "1x Energy Hatch (Any inert casing)"};
+ final GT_Multiblock_Tooltip_Builder tt = new GT_Multiblock_Tooltip_Builder();
+ tt.addMachineType("Chemical Reactor")
+ .addInfo("Controller block for the Large Chemical Reactor")
+ .addInfo("Does not lose efficiency when overclocked")
+ .addInfo("Accepts fluids instead of fluid cells")
+ .beginStructureBlock(3, 3, 3)
+ .addController("Front centered")
+ .addCasingInfo("Chemically Inert Machine Casings", 8)
+ .addOtherStructurePart("PTFE Pipe Machine Casing", "Center")
+ .addOtherStructurePart("Cupronickel Coil Block", "Adjacent to the PTFE Pipe Machine Casing")
+ .addEnergyHatch("Any Casing")
+ .addMaintenanceHatch("Any Casing")
+ .addInputBus("Any Casing")
+ .addInputHatch("Any Casing")
+ .addOutputBus("Any Casing")
+ .addOutputHatch("Any Casing")
+ .addStructureInfo("You can have multiple I/O hatches/busses")
+ .toolTipFinisher("Gregtech");
+ if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
+ return tt.getInformation();
+ } else {
+ return tt.getStructureInformation();
+ }
}
@Override