Skip to content
This repository was archived by the owner on May 26, 2024. It is now read-only.

Commit c472513

Browse files
authored
Fix Industral Arc Furnace structure check (#850)
* fix structure check * typo
1 parent 639706e commit c472513

File tree

1 file changed

+64
-34
lines changed

1 file changed

+64
-34
lines changed

src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialArcFurnace.java

+64-34
Original file line numberDiff line numberDiff line change
@@ -89,58 +89,93 @@ protected GT_Multiblock_Tooltip_Builder createTooltip() {
8989
return tt;
9090
}
9191

92+
/**
93+
* The front part of multi. Used to determine the tier, or in other words, determine the size of multi.
94+
*/
95+
private static final String STRUCTURE_PIECE_FRONT = "front";
96+
/**
97+
* The rest part of multi.
98+
*/
99+
private static final String STRUCTURE_PIECE_REST = "rest";
100+
private static final int MAX_TIER = 3;
101+
92102
@Override
93103
public IStructureDefinition<GregtechMetaTileEntity_IndustrialArcFurnace> getStructureDefinition() {
94104
if (STRUCTURE_DEFINITION == null) {
95-
STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialArcFurnace>builder().addShape(
96-
mName + "3",
97-
new String[][] { { "CCC", "C~C", "CCC" }, { "CCC", "C-C", "CCC" }, { "CCC", "CCC", "CCC" }, })
105+
STRUCTURE_DEFINITION = StructureDefinition.<GregtechMetaTileEntity_IndustrialArcFurnace>builder()
106+
.addShape(STRUCTURE_PIECE_FRONT + 1, new String[][] { { "CCC", "C~C", "CCC" } })
98107
.addShape(
99-
mName + "5",
100-
new String[][] { { "CCCCC", "CCCCC", "CC~CC", "CCCCC", "CCCCC" },
101-
{ "CCCCC", "C---C", "C---C", "C---C", "CCCCC" },
102-
{ "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC" }, })
108+
STRUCTURE_PIECE_FRONT + 2,
109+
new String[][] { { "CCCCC", "C C", "C C", "C C", "CCCCC" } })
103110
.addShape(
104-
mName + "7",
111+
STRUCTURE_PIECE_FRONT + 3,
112+
new String[][] {
113+
{ "CCCCCCC", "C C", "C C", "C C", "C C", "C C", "CCCCCCC" }, })
114+
.addShape(
115+
STRUCTURE_PIECE_REST + 1,
116+
new String[][] { { "CCC", "C-C", "CCC" }, { "CCC", "CCC", "CCC" } })
117+
.addShape(
118+
STRUCTURE_PIECE_REST + 2,
119+
new String[][] { { "CCCCC", "C---C", "C---C", "C---C", "CCCCC" },
120+
{ "CCCCC", "CCCCC", "CCCCC", "CCCCC", "CCCCC" } })
121+
.addShape(
122+
STRUCTURE_PIECE_REST + 3,
105123
new String[][] {
106-
{ "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCC~CCC", "CCCCCCC", "CCCCCCC", "CCCCCCC" },
107124
{ "CCCCCCC", "C-----C", "C-----C", "C-----C", "C-----C", "C-----C", "CCCCCCC" },
108125
{ "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC", "CCCCCCC" }, })
109126
.addElement(
110127
'C',
111128
buildHatchAdder(GregtechMetaTileEntity_IndustrialArcFurnace.class)
112129
.atLeast(InputBus, InputHatch, OutputBus, OutputHatch, Maintenance, Energy, Muffler)
113-
.casingIndex(getCasingTextureIndex()).dot(1).buildAndChain(
130+
.casingIndex(getCasingTextureIndex()).dot(1).allowOnly(ForgeDirection.NORTH)
131+
.buildAndChain(
114132
onElementPass(x -> ++x.mCasing, ofBlock(ModBlocks.blockCasings4Misc, 3))))
115133
.build();
116134
}
117135
return STRUCTURE_DEFINITION;
118136
}
119137

120-
private int getSizeFromHint(ItemStack stackSize) {
121-
return switch (stackSize.stackSize) {
122-
case 1 -> 3;
123-
case 2 -> 5;
124-
default -> 7;
125-
};
138+
private int getTierFromHint(ItemStack stackSize) {
139+
if (stackSize.stackSize <= 0 || stackSize.stackSize >= MAX_TIER) {
140+
return MAX_TIER;
141+
}
142+
return stackSize.stackSize;
126143
}
127144

128145
@Override
129146
public void construct(ItemStack stackSize, boolean hintsOnly) {
130-
int size = getSizeFromHint(stackSize);
131-
buildPiece(mName + size, stackSize, hintsOnly, (size - 1) / 2, (size - 1) / 2, 0);
147+
int maxTier = getTierFromHint(stackSize);
148+
for (int tier = 1; tier <= maxTier; tier++) {
149+
buildPiece(STRUCTURE_PIECE_FRONT + tier, stackSize, hintsOnly, tier, tier, 0);
150+
}
151+
buildPiece(STRUCTURE_PIECE_REST + maxTier, stackSize, hintsOnly, maxTier, maxTier, -1);
132152
}
133153

134154
@Override
135155
public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) {
136156
if (mMachine) return -1;
137-
int size = getSizeFromHint(stackSize);
157+
int maxTier = getTierFromHint(stackSize);
158+
int built;
159+
for (int tier = 1; tier <= maxTier; tier++) {
160+
built = survivialBuildPiece(
161+
STRUCTURE_PIECE_FRONT + tier,
162+
stackSize,
163+
tier,
164+
tier,
165+
0,
166+
elementBudget,
167+
env,
168+
false,
169+
true);
170+
if (built >= 0) return built;
171+
}
172+
138173
return survivialBuildPiece(
139-
mName + size,
174+
STRUCTURE_PIECE_REST + maxTier,
140175
stackSize,
141-
(size - 1) / 2,
142-
(size - 1) / 2,
143-
0,
176+
maxTier,
177+
maxTier,
178+
-1,
144179
elementBudget,
145180
env,
146181
false,
@@ -151,18 +186,13 @@ public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBu
151186
public boolean checkMachine(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) {
152187
mCasing = 0;
153188
mSize = 0;
154-
if (checkPiece(mName + "3", 1, 1, 0)) {
155-
mSize = 3;
156-
return mCasing >= 10 && checkHatch();
189+
int tier = 0;
190+
while (tier < MAX_TIER && checkPiece(STRUCTURE_PIECE_FRONT + (tier + 1), (tier + 1), (tier + 1), 0)) {
191+
tier++;
157192
}
158-
mCasing = 0;
159-
if (checkPiece(mName + "5", 2, 2, 0)) {
160-
mSize = 5;
161-
return mCasing >= 10 && checkHatch();
162-
}
163-
mCasing = 0;
164-
if (checkPiece(mName + "7", 3, 3, 0)) {
165-
mSize = 7;
193+
if (tier <= 0) return false;
194+
if (checkPiece(STRUCTURE_PIECE_REST + tier, tier, tier, -1)) {
195+
mSize = 2 * tier + 1;
166196
return mCasing >= 10 && checkHatch();
167197
}
168198
return false;

0 commit comments

Comments
 (0)