From 290e3d4ddf85fa6f912f5c81028a3032fb6ca1c7 Mon Sep 17 00:00:00 2001
From: Glease <4586901+Glease@users.noreply.github.com>
Date: Sun, 1 Aug 2021 02:59:57 +0800
Subject: Fix off by one in cubic multi base and tooltip builder
Also added a command to toggle structure lib debug print.
Signed-off-by: Glease <4586901+Glease@users.noreply.github.com>
---
.../GT_MetaTileEntity_CubicMultiBlockBase.java | 57 +++-------------------
.../api/util/GT_Multiblock_Tooltip_Builder.java | 3 +-
src/main/java/gregtech/common/misc/GT_Command.java | 9 +++-
3 files changed, 16 insertions(+), 53 deletions(-)
diff --git a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java
index de36b845b2..3854a96cda 100644
--- a/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java
+++ b/src/main/java/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_CubicMultiBlockBase.java
@@ -13,56 +13,19 @@ import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose
import static gregtech.api.util.GT_StructureUtility.ofHatchAdder;
/**
- * A simple 3x3x3 hollow cubic multiblock, that can be arbitrarily rotated, made of a single type of machine casing, accepts hatches everywhere.
- *
+ * A simple 3x3x3 hollow cubic multiblock, that can be arbitrarily rotated, made of a single type of machine casing and accepts hatches everywhere.
* Controller will be placed in front center of the structure.
*
* Note: You cannot use different casing for the same Class. Make a new subclass for it. You also should not change the casing
* dynamically, i.e. it should be a dumb method returning some sort of constant.
*
* Implementation tips:
- *
- * - To restrict hatches, override {@link #addDynamoToMachineList(IGregTechTileEntity, int)} and its cousins instead of overriding the whole
+ * 1. To restrict hatches, override {@link #addDynamoToMachineList(IGregTechTileEntity, int)} and its cousins instead of overriding the whole
* {@link #getStructureDefinition()} or change {@link #checkHatches(IGregTechTileEntity, ItemStack)}. The former is a total overkill, while the later cannot
* stop the structure check early.
- * Example 1: Require ULV input only:
- *
- * {@code
- * @Override
- * public boolean addInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
- * if (aTileEntity == null) return false;
- * IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
- * if (aMetaTileEntity == null) return false;
- * if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_Input) {
- * if (((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier != 0) return false; // addition
- * ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
- * ((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity).mRecipeMap = getRecipeMap();
- * return mInputHatches.add((GT_MetaTileEntity_Hatch_Input) aMetaTileEntity);
- * }
- * if (aMetaTileEntity instanceof GT_MetaTileEntity_Hatch_InputBus) {
- * if (((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mTier != 0) return false; // addition
- * ((GT_MetaTileEntity_Hatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
- * ((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity).mRecipeMap = getRecipeMap();
- * return mInputBusses.add((GT_MetaTileEntity_Hatch_InputBus) aMetaTileEntity);
- * }
- * return false;
- * }
- * }
- * Example 2: Allow dynamo, muffler and prevent energy hatch
- *
- * {@code
- * @Override
- * public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
- * return addInputToMachineList(aTileEntity, aBaseCasingIndex) ||
- * addOutputToMachineList(aTileEntity, aBaseCasingIndex) ||
- * addDynamoToMachineList(aTileEntity, aBaseCasingIndex) ||
- * addMufflerToMachineList(aTileEntity, aBaseCasingIndex) ||
- * addMaintenanceToMachineList(aTileEntity, aBaseCasingIndex);
- * }
- * }
- * - To limit rotation, override {@link #getInitialAlignmentLimits()}
- *
- * @param this
+ * 2. To limit rotation, override {@link #getInitialAlignmentLimits()}
+ *
+ * @param
*/
public abstract class GT_MetaTileEntity_CubicMultiBlockBase> extends GT_MetaTileEntity_EnhancedMultiBlockBase {
protected static final String STRUCTURE_PIECE_MAIN = "main";
@@ -95,14 +58,6 @@ public abstract class GT_MetaTileEntity_CubicMultiBlockBase
@@ -123,7 +78,7 @@ public abstract class GT_MetaTileEntity_CubicMultiBlockBase getRequiredCasingCount() &&
+ mCasingAmount >= getRequiredCasingCount() &&
checkHatches(aBaseMetaTileEntity, aStack);
}
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
index 9afb9e58c1..3071cb95a3 100644
--- a/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java
+++ b/src/main/java/gregtech/api/util/GT_Multiblock_Tooltip_Builder.java
@@ -504,7 +504,8 @@ public class GT_Multiblock_Tooltip_Builder {
hLines.add(TT_structurehint);
iArray = iLines.toArray(new String[0]);
sArray = sLines.toArray(new String[0]);
- hArray = Stream.concat(hLines.stream(), hBlocks.asMap().entrySet().stream().map(e -> TT_dots[e.getKey()] + COLON + String.join(SEPARATOR, e.getValue()))).toArray(String[]::new);
+ // e.getKey() - 1 because 1 dot is meta 0.
+ hArray = Stream.concat(hLines.stream(), hBlocks.asMap().entrySet().stream().map(e -> TT_dots[e.getKey() - 1] + COLON + String.join(SEPARATOR, e.getValue()))).toArray(String[]::new);
}
public String[] getInformation() {
diff --git a/src/main/java/gregtech/common/misc/GT_Command.java b/src/main/java/gregtech/common/misc/GT_Command.java
index a4b46b8cee..13e26353d8 100644
--- a/src/main/java/gregtech/common/misc/GT_Command.java
+++ b/src/main/java/gregtech/common/misc/GT_Command.java
@@ -1,5 +1,6 @@
package gregtech.common.misc;
+import com.gtnewhorizon.structurelib.StructureLib;
import gregtech.GT_Mod;
import gregtech.api.enums.GT_Values;
import gregtech.api.objects.GT_ChunkManager;
@@ -40,6 +41,7 @@ public final class GT_Command extends CommandBase {
sender.addChatMessage(new ChatComponentText("\"toggle debugSmallOres\" - toggles worldgen small vein debug"));
sender.addChatMessage(new ChatComponentText("\"toggle debugStones\" - toggles worldgen stones debug"));
sender.addChatMessage(new ChatComponentText("\"toggle debugChunkloaders\" - toggles chunkloaders debug"));
+ sender.addChatMessage(new ChatComponentText("\"toggle debugMulti\" - toggles structurelib debug"));
sender.addChatMessage(new ChatComponentText("\"chunks\" - print a list of the force loaded chunks"));
sender.addChatMessage(new ChatComponentText(
"\"pollution \" - adds the of the pollution to the current chunk, " +
@@ -59,7 +61,7 @@ public final class GT_Command extends CommandBase {
} else if (test.equals("toggle")) {
String test1 = ss[1].trim();
Stream.of("D1", "D2", "debugCleanroom", "debugDriller", "debugBlockPump", "debugBlockMiner", "debugWorldGen", "debugEntityCramming",
- "debugOrevein", "debugSmallOres", "debugStones", "debugChunkloaders")
+ "debugOrevein", "debugSmallOres", "debugStones", "debugChunkloaders", "debugMulti")
.filter(s -> test1.isEmpty() || s.startsWith(test1))
.forEach(l::add);
@@ -79,6 +81,11 @@ public final class GT_Command extends CommandBase {
printHelp(sender);
return;
}
+ if ("debugMulti".equals(strings[1])) {
+ StructureLib.DEBUG_MODE = !StructureLib.DEBUG_MODE;
+ sender.addChatMessage(new ChatComponentText(strings[1] + " = " + (StructureLib.DEBUG_MODE ? "true" : "false")));
+ return;
+ }
try {
Field field = GT_Values.class.getDeclaredField(strings[1]);
if (field.getType() != boolean.class) {
--
cgit