Skip to content

Commit

Permalink
Fix (another) Computation Bug (#3432)
Browse files Browse the repository at this point in the history
Co-authored-by: Martin Robertz <dream-master@gmx.net>
  • Loading branch information
DylanTaylor1 and Dream-Master authored Nov 17, 2024
1 parent bb74217 commit 71ab970
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import static com.gtnewhorizon.structurelib.structure.StructureUtility.ofBlock;
import static com.gtnewhorizon.structurelib.structure.StructureUtility.transpose;
import static gregtech.api.enums.GTValues.V;
import static gregtech.api.util.GTStructureUtility.ofHatchAdderOptional;
import static gregtech.api.enums.HatchElement.Energy;
import static gregtech.api.enums.HatchElement.Maintenance;
import static gregtech.api.util.GTStructureUtility.buildHatchAdder;
import static net.minecraft.util.StatCollector.translateToLocal;

import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -44,23 +46,35 @@ public class MTENetworkSwitch extends TTMultiblockBase implements IConstructable
// region structure
private static final String[] description = new String[] {
EnumChatFormatting.AQUA + translateToLocal("tt.keyphrase.Hint_Details") + ":",
"1 - Classic/Data Hatches or Computer casing", // 1 - Classic/Data Hatches or Computer casing
translateToLocal("gt.blockmachines.multimachine.em.switch.hint.0"), // 1 - Data Input/Output Hatches or Advanced
// computer casing
translateToLocal("gt.blockmachines.multimachine.em.switch.hint.1"), // 2 - Data Output Hatches or Computer
// casing
};

private static final IStructureDefinition<MTENetworkSwitch> STRUCTURE_DEFINITION = IStructureDefinition
.<MTENetworkSwitch>builder()
.addShape(
"main",
transpose(new String[][] { { "BBB", "BBB", "BBB" }, { "B~B", "BAB", "BBB" }, { "BBB", "BBB", "BBB" } }))
.addElement('A', ofBlock(TTCasingsContainer.sBlockCasingsTT, 3))
transpose(new String[][] { { "BBB", "BAB", "BBB" }, { "B~B", "AAA", "BAB" }, { "BBB", "BAB", "BBB" } }))
.addElement(
'A',
buildHatchAdder(MTENetworkSwitch.class)
.atLeast(
Energy.or(HatchElement.EnergyMulti),
Maintenance,
HatchElement.InputData,
HatchElement.OutputData)
.casingIndex(BlockGTCasingsTT.textureOffset + 3)
.dot(1)
.buildAndChain(ofBlock(TTCasingsContainer.sBlockCasingsTT, 3)))
.addElement(
'B',
ofHatchAdderOptional(
MTENetworkSwitch::addClassicToMachineList,
BlockGTCasingsTT.textureOffset + 1,
1,
TTCasingsContainer.sBlockCasingsTT,
1))
buildHatchAdder(MTENetworkSwitch.class)
.atLeast(Energy.or(HatchElement.EnergyMulti), Maintenance, HatchElement.OutputData) // No Input Data
.casingIndex(BlockGTCasingsTT.textureOffset + 1)
.dot(2)
.buildAndChain(ofBlock(TTCasingsContainer.sBlockCasingsTT, 1)))
.build();
// endregion

Expand Down Expand Up @@ -209,24 +223,20 @@ public MultiblockTooltipBuilder createTooltip() {
.addInfo(translateToLocal("gt.blockmachines.multimachine.em.switch.desc.2")) // Needs a Parametrizer to
// be configured
.addTecTechHatchInfo()

.beginStructureBlock(3, 3, 3, false)
.addController(translateToLocal("tt.keyword.Structure.FrontCenter")) // Controller: Front center
.addCasingInfoMin(translateToLocal("gt.blockcasingsTT.1.name"), 0, false) // 0x Computer Casing
// (minimum)
.addOtherStructurePart(
translateToLocal("gt.blockcasingsTT.3.name"),
translateToLocal("tt.keyword.Structure.Center")) // Advanced Computer Casing: Center
.addOtherStructurePart(
translateToLocal("tt.keyword.Structure.DataConnector"),
translateToLocal("tt.keyword.Structure.AnyComputerCasing"),
2) // Data Connector: Any Computer Casing
translateToLocal("tt.keyword.Structure.DataInput"), // Data Input Hatch: Any Advanced Computer Casing
translateToLocal("tt.keyword.Structure.AnyAdvComputerCasing"),
1)
.addOtherStructurePart(
translateToLocal("gt.blockmachines.hatch.param.tier.05.name"),
translateToLocal("tt.keyword.Structure.DataOutput"), // Data Output Hatch: Any Computer Casing
translateToLocal("tt.keyword.Structure.AnyComputerCasing"),
2) // Parametrizer: Any Computer Casing
.addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasing"), 1) // Energy Hatch: Any
2)
.addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasing"), 2) // Energy Hatch: Any
// Computer Casing
.addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasing"), 1) // Maintenance
.addMaintenanceHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasing"), 2) // Maintenance
// Hatch: Any
// Computer Casing
.toolTipFinisher();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public class MTEQuantumComputer extends TTMultiblockBase implements ISurvivalCon
Energy.or(HatchElement.EnergyMulti),
Maintenance,
HatchElement.Uncertainty,
HatchElement.InputData,
HatchElement.OutputData,
WirelessComputationHatchElement.INSTANCE)
.casingIndex(BlockGTCasingsTT.textureOffset + 1)
Expand Down Expand Up @@ -368,11 +369,6 @@ public MultiblockTooltipBuilder createTooltip() {
translateToLocal("gt.blockmachines.hatch.rack.tier.08.name"),
translateToLocal("tt.keyword.Structure.AnyAdvComputerCasingExceptOuter"),
2) // Computer Rack: Any Advanced Computer Casing, except the outer ones
.addOtherStructurePart(
translateToLocal("gt.blockmachines.hatch.param.tier.05.name"),
translateToLocal("tt.keyword.Structure.Optional") + " "
+ translateToLocal("tt.keyword.Structure.AnyComputerCasingFirstOrLastSlice"),
2) // Parametrizer: (optional) Any Computer Casing on first or last slice
.addEnergyHatch(translateToLocal("tt.keyword.Structure.AnyComputerCasingFirstOrLastSlice"), 1) // Energy
// Hatch:
// Any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2085,7 +2085,7 @@ public final boolean addClassicMaintenanceToMachineList(IGregTechTileEntity aTil
}

// NEW METHOD
public final boolean addDataConnectorToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
public final boolean addDataInputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
if (aTileEntity == null) {
return false;
}
Expand All @@ -2097,6 +2097,18 @@ public final boolean addDataConnectorToMachineList(IGregTechTileEntity aTileEnti
((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
return eInputData.add((MTEHatchDataInput) aMetaTileEntity);
}
return false;
}

// NEW METHOD
public final boolean addDataOutputToMachineList(IGregTechTileEntity aTileEntity, int aBaseCasingIndex) {
if (aTileEntity == null) {
return false;
}
IMetaTileEntity aMetaTileEntity = aTileEntity.getMetaTileEntity();
if (aMetaTileEntity == null) {
return false;
}
if (aMetaTileEntity instanceof MTEHatchDataOutput) {
((MTEHatch) aMetaTileEntity).updateTexture(aBaseCasingIndex);
return eOutputData.add((MTEHatchDataOutput) aMetaTileEntity);
Expand Down Expand Up @@ -2175,14 +2187,14 @@ public long count(TTMultiblockBase t) {
return t.eDynamoMulti.size();
}
},
InputData(TTMultiblockBase::addDataConnectorToMachineList, MTEHatchDataInput.class) {
InputData(TTMultiblockBase::addDataInputToMachineList, MTEHatchDataInput.class) {

@Override
public long count(TTMultiblockBase t) {
return t.eInputData.size();
}
},
OutputData(TTMultiblockBase::addDataConnectorToMachineList, MTEHatchDataOutput.class) {
OutputData(TTMultiblockBase::addDataOutputToMachineList, MTEHatchDataOutput.class) {

@Override
public long count(TTMultiblockBase t) {
Expand Down
10 changes: 6 additions & 4 deletions src/main/resources/assets/tectech/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -693,11 +693,10 @@ gt.blockmachines.multimachine.tm.teslaCoil.cfgo.8=Scan time display
gt.blockmachines.multimachine.tm.teslaCoil.cfgo.9=Output max display

gt.blockmachines.multimachine.em.switch.name=Network Switch With QoS
gt.blockmachines.multimachine.em.switch.hint=1 - Classic/Data Hatches or Computer casing
gt.blockmachines.multimachine.em.switch.hint.0=1 - Data Input/Output Hatches or Advanced computer casing
gt.blockmachines.multimachine.em.switch.hint.1=2 - Data Output Hatches or Computer casing
gt.blockmachines.multimachine.em.switch.desc.0=Controller block of the Network Switch With QoS
gt.blockmachines.multimachine.em.switch.desc.1=Used to route and distribute computation
gt.blockmachines.multimachine.em.switch.desc.2=Needs a Parametrizer to be configured

gt.blockmachines.multimachine.em.switch.desc.1=Routes and distributes computation

gt.blockmachines.multimachine.em.computer.name=Quantum Computer
gt.blockmachines.multimachine.em.computer.hint.0=1 - Classic/Data Hatches or Computer casing
Expand Down Expand Up @@ -1342,6 +1341,7 @@ tt.keyword.Structure.AnyHighPowerCasingFront=Any High Power Casing on the front
tt.keyword.Structure.AnyTeslaBaseCasingOuter=Any outer Tesla Base Casing
tt.keyword.Structure.AnyComputerCasingFirstOrLastSlice=Any Computer Casing on the first or last slice
tt.keyword.Structure.AnyComputerCasingBackMain=Any Computer Casing on the backside of the main body
tt.keyword.Structure.AnyAdvComputerCasing=Any Advanced Computer Casing
tt.keyword.Structure.AnyAdvComputerCasingExceptOuter=Any Advanced Computer Casing, except the outer ones
tt.keyword.Structure.AnyMolecularCasing=Any Molecular Casing
tt.keyword.Structure.AnyMolecularCasing2D=Any Molecular Casing with 2 dots
Expand All @@ -1368,6 +1368,8 @@ tt.keyword.Structure.ElementalOverflow=Elemental Overflow Hatch
tt.keyword.Structure.ElementalInput=Elemental Input Hatch
tt.keyword.Structure.EssentiaStorage=Essentia Storage
tt.keyword.Structure.DataConnector=Data Connector
tt.keyword.Structure.DataInput=Data Input Hatch
tt.keyword.Structure.DataOutput=Data Output Hatch
tt.keyword.Structure.SuperconductingCoilBlock=Superconducting Coil Block
tt.keyword.Structure.StainlessSteelCasing=Stainless Steel Casing
tt.wirelessInputData.config.text=Configure how much computation to pull from wireless network
Expand Down

0 comments on commit 71ab970

Please sign in to comment.