Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

tweak cal structure code #376

Merged
merged 2 commits into from
Dec 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

import static com.github.bartimaeusnek.bartworks.util.BW_Tooltip_Reference.ADDED_BY_BARTIMAEUSNEK_VIA_BARTWORKS;
import static com.github.bartimaeusnek.bartworks.util.BW_Util.ofGlassTieredMixed;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.*;
import static gregtech.api.enums.GT_HatchElement.Energy;
import static gregtech.api.enums.GT_HatchElement.InputBus;
import static gregtech.api.enums.GT_HatchElement.InputHatch;
Expand Down Expand Up @@ -90,6 +89,8 @@ public class GT_TileEntity_CircuitAssemblyLine extends

private static final String STRUCTURE_PIECE_FIRST = "first";
private static final String STRUCTURE_PIECE_NEXT = "next";
private static final String STRUCTURE_PIECE_NEXT_HINT = "next_hint";
private static final String STRUCTURE_PIECE_LAST = "last";

private static final int MINIMUM_CIRCUIT_ASSEMBLER_LENGTH = 5;
protected static final String IMPRINT_KEY = "Type";
Expand All @@ -109,6 +110,12 @@ public class GT_TileEntity_CircuitAssemblyLine extends
.addShape(
STRUCTURE_PIECE_NEXT,
transpose(new String[][] { { "G", "G", "G" }, { "g", "l", "g" }, { "b", "I", "b" }, }))
.addShape(
STRUCTURE_PIECE_NEXT_HINT,
transpose(new String[][] { { "G", "G", "G" }, { "g", "l", "g" }, { "b", "i", "b" }, }))
.addShape(
STRUCTURE_PIECE_LAST,
transpose(new String[][] { { "G", "G", "G" }, { "g", "l", "g" }, { "b", "o", "b" }, }))
.addElement(
'G',
buildHatchAdder(GT_TileEntity_CircuitAssemblyLine.class).atLeast(Energy).casingIndex(CASING_INDEX)
Expand All @@ -118,13 +125,15 @@ public class GT_TileEntity_CircuitAssemblyLine extends
.addElement(
'b',
buildHatchAdder(GT_TileEntity_CircuitAssemblyLine.class).atLeast(InputHatch, Maintenance)
.casingIndex(CASING_INDEX).dot(2).buildAndChain(GregTech_API.sBlockCasings2, 0))
.addElement('i', InputBus.newAny(CASING_INDEX, 3))
.casingIndex(CASING_INDEX).dot(2).disallowOnly(ForgeDirection.EAST, ForgeDirection.WEST)
.buildAndChain(GregTech_API.sBlockCasings2, 0))
.addElement('i', InputBus.newAny(CASING_INDEX, 3, ForgeDirection.DOWN))
.addElement(
'I',
buildHatchAdder(GT_TileEntity_CircuitAssemblyLine.class).atLeast(InputHatch, InputBus, OutputBus)
.casingIndex(CASING_INDEX).dot(2).buildAndChain(GregTech_API.sBlockCasings2, 0))
.build();
.casingIndex(CASING_INDEX).dot(2).disallowOnly(ForgeDirection.EAST, ForgeDirection.WEST)
.buildAndChain(GregTech_API.sBlockCasings2, 0))
.addElement('o', OutputBus.newAny(CASING_INDEX, 2, ForgeDirection.DOWN)).build();

@Override
public IStructureDefinition<GT_TileEntity_CircuitAssemblyLine> getStructureDefinition() {
Expand Down Expand Up @@ -440,16 +449,33 @@ public void construct(ItemStack stackSize, boolean hintsOnly) {
public int survivalConstruct(ItemStack stackSize, int elementBudget, ISurvivalBuildEnvironment env) {
if (this.mMachine) return -1;
int built;
built = this.survivialBuildPiece(STRUCTURE_PIECE_FIRST, stackSize, 0, 0, 0, elementBudget, env, false, true);
built = survivialBuildPiece(STRUCTURE_PIECE_FIRST, stackSize, 0, 0, 0, elementBudget, env, false, true);
if (built >= 0) return built;
int tLength = Math.min(stackSize.stackSize + 1, 7);

for (int i = 1; i < tLength; ++i) {
built = this
.survivialBuildPiece(STRUCTURE_PIECE_NEXT, stackSize, -i, 0, 0, elementBudget, env, false, true);
for (int i = 1; i < tLength - 1; ++i) {
built = survivialBuildPiece(
STRUCTURE_PIECE_NEXT_HINT,
stackSize,
-i,
0,
0,
elementBudget,
env,
false,
true);
if (built >= 0) return built;
}
return -1;
return survivialBuildPiece(
STRUCTURE_PIECE_LAST,
stackSize,
-(tLength - 1),
0,
0,
elementBudget,
env,
false,
true);
}

@Override
Expand Down