diff options
author | Martin Robertz <dream-master@gmx.net> | 2021-08-01 10:22:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-01 10:22:35 +0200 |
commit | b44029d318a2450b51e23cceb20949ae89c1cd5d (patch) | |
tree | e5951870823f276651cc0a7d7c8b5b97e1da5ae2 | |
parent | 550343a732972184bc488451ae639c620988c972 (diff) | |
parent | 290e3d4ddf85fa6f912f5c81028a3032fb6ca1c7 (diff) | |
download | GT5-Unofficial-b44029d318a2450b51e23cceb20949ae89c1cd5d.tar.gz GT5-Unofficial-b44029d318a2450b51e23cceb20949ae89c1cd5d.tar.bz2 GT5-Unofficial-b44029d318a2450b51e23cceb20949ae89c1cd5d.zip |
Merge pull request #615 from GTNewHorizons/structurelib-integration
Fix off by one in cubic multi base and tooltip builder
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. * <p> * 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. * <p> * Implementation tips: - * <ul> - * <li>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: - * <pre> - * {@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; - * } - * }</pre> - * Example 2: Allow dynamo, muffler and prevent energy hatch - * <pre> - * {@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); - * } - * }</pre></li> - * <li>To limit rotation, override {@link #getInitialAlignmentLimits()}</li> - *</ul> - * @param <T> this + * 2. To limit rotation, override {@link #getInitialAlignmentLimits()} + * + * @param <T> */ public abstract class GT_MetaTileEntity_CubicMultiBlockBase<T extends GT_MetaTileEntity_CubicMultiBlockBase<T>> extends GT_MetaTileEntity_EnhancedMultiBlockBase<T> { protected static final String STRUCTURE_PIECE_MAIN = "main"; @@ -95,14 +58,6 @@ public abstract class GT_MetaTileEntity_CubicMultiBlockBase<T extends GT_MetaTil super(aName); } - @Override - public boolean addToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) { - return addInputToMachineList(aTileEntity, aBaseCasingIndex) || - addOutputToMachineList(aTileEntity, aBaseCasingIndex) || - addEnergyInputToMachineList(aTileEntity, aBaseCasingIndex) || - addMaintenanceToMachineList(aTileEntity, aBaseCasingIndex); - } - /** * Create a simple 3x3x3 hollow cubic structure made of a single type of machine casing and accepts hatches everywhere. * <p> @@ -123,7 +78,7 @@ public abstract class GT_MetaTileEntity_CubicMultiBlockBase<T extends GT_MetaTil public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { mCasingAmount = 0; return checkPiece(STRUCTURE_PIECE_MAIN, 1, 1, 0) && - mCasingAmount > 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 <amount>\" - adds the <amount> 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) { |