Skip to content

Commit 9554638

Browse files
author
Apop T. Osis
committed
Removed redundant coolant calculations since the unnamed receiver won't use coolant.
1 parent 8d43695 commit 9554638

5 files changed

Lines changed: 12 additions & 104 deletions

File tree

src/main/java/net/neganote/gtutilities/common/machine/UtilMachines.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public static MachineDefinition[] registerTieredMachines(String name,
226226
.translatable("tooltip.pterb_machine.uses_coolant",
227227
UtilMaterials.QuantumCoolant !=
228228
null ? UtilMaterials.QuantumCoolant.getLocalizedName()
229-
.withStyle(ChatFormatting.AQUA) : "")
229+
.withStyle(ChatFormatting.AQUA) : "")
230230
.withStyle(ChatFormatting.DARK_RED),
231231
UtilConfig.coolantEnabled())
232232
.conditionalTooltip(Component.translatable("tooltip.pterb_machine.input_coolant_before_use")
@@ -238,7 +238,9 @@ public static MachineDefinition[] registerTieredMachines(String name,
238238
.aisle("bbbbb", "abdba", "aacaa", "aaaaa", "aaaaa", "aacaa", "aaaaa", "aaaaa")
239239
.aisle("abeba", "aabaa", "aaaaa", "aaaaa", "aaaaa", "aacaa", "aacaa", "aadaa")
240240
.where("e", controller(blocks(multiblockMachineDefinition.getBlock())))
241-
.where('b', blocks(HIGH_POWER_CASING.get()).setMinGlobalLimited(12).or(WEBMachine.getHatchPredicates()))
241+
.where('b',
242+
blocks(HIGH_POWER_CASING.get()).setMinGlobalLimited(12)
243+
.or(WEBMachine.getHatchPredicates()))
242244
.where("d", blocks(SUPERCONDUCTING_COIL.get()))
243245
.where("c", frames(GTMaterials.NaquadahAlloy))
244246
.where("a", air())
@@ -252,6 +254,5 @@ public static MachineDefinition[] registerTieredMachines(String name,
252254

253255
}
254256

255-
256257
public static void init() {}
257258
}

src/main/java/net/neganote/gtutilities/common/machine/multiblock/PTERBMachine.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import net.minecraft.server.level.ServerLevel;
4343
import net.minecraft.world.entity.player.Player;
4444
import net.minecraft.world.level.block.Block;
45-
import net.minecraft.world.level.dimension.DimensionType;
4645
import net.neganote.gtutilities.common.materials.UtilMaterials;
4746
import net.neganote.gtutilities.config.UtilConfig;
4847
import net.neganote.gtutilities.saveddata.PTERBSavedData;
@@ -171,7 +170,6 @@ private int calculateCoolantDrain() {
171170
inputVoltage = localInputs.getInputVoltage();
172171
}
173172

174-
175173
long scalingFactor = inputAmperage * inputVoltage;
176174

177175
int coolantDrain = UtilConfig.INSTANCE.features.pterbCoolantBaseDrain +

src/main/java/net/neganote/gtutilities/common/machine/multiblock/WEBMachine.java

Lines changed: 8 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,33 @@
1717
import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMultiPart;
1818
import com.gregtechceu.gtceu.api.machine.multiblock.PartAbility;
1919
import com.gregtechceu.gtceu.api.machine.multiblock.WorkableElectricMultiblockMachine;
20-
import com.gregtechceu.gtceu.api.machine.trait.NotifiableFluidTank;
2120
import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic;
2221
import com.gregtechceu.gtceu.api.misc.EnergyContainerList;
2322
import com.gregtechceu.gtceu.api.pattern.TraceabilityPredicate;
2423
import com.gregtechceu.gtceu.api.pattern.error.PatternError;
25-
import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient;
2624
import com.gregtechceu.gtceu.common.data.GTItems;
27-
import com.gregtechceu.gtceu.common.data.GTRecipeCapabilities;
2825
import com.gregtechceu.gtceu.config.ConfigHolder;
2926
import com.gregtechceu.gtceu.utils.FormattingUtil;
3027
import com.gregtechceu.gtceu.utils.GTUtil;
28+
3129
import com.lowdragmc.lowdraglib.gui.modular.ModularUI;
3230
import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture;
3331
import com.lowdragmc.lowdraglib.gui.texture.ItemStackTexture;
3432
import com.lowdragmc.lowdraglib.gui.widget.*;
3533
import com.lowdragmc.lowdraglib.syncdata.annotation.DescSynced;
3634
import com.lowdragmc.lowdraglib.syncdata.annotation.Persisted;
3735
import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder;
38-
import it.unimi.dsi.fastutil.longs.Long2ObjectMaps;
39-
import lombok.Getter;
36+
4037
import net.minecraft.ChatFormatting;
4138
import net.minecraft.network.chat.Component;
4239
import net.minecraft.server.level.ServerLevel;
4340
import net.minecraft.world.entity.player.Player;
4441
import net.minecraft.world.level.block.Block;
45-
import net.neganote.gtutilities.GregTechModernUtilities;
46-
import net.neganote.gtutilities.common.materials.UtilMaterials;
47-
import net.neganote.gtutilities.config.UtilConfig;
4842
import net.neganote.gtutilities.saveddata.PTERBSavedData;
4943
import net.neganote.gtutilities.utils.EnergyUtils;
50-
import org.apache.logging.log4j.Level;
44+
45+
import it.unimi.dsi.fastutil.longs.Long2ObjectMaps;
46+
import lombok.Getter;
5147
import org.jetbrains.annotations.NotNull;
5248

5349
import java.util.*;
@@ -56,8 +52,8 @@
5652

5753
// A lot of this is copied from the Active Transformer
5854
public class WEBMachine extends WorkableElectricMultiblockMachine
59-
implements IControllable, IExplosionMachine, IFancyUIMachine,
60-
IDisplayUIMachine {
55+
implements IControllable, IExplosionMachine, IFancyUIMachine,
56+
IDisplayUIMachine {
6157

6258
protected static final ManagedFieldHolder MANAGED_FIELD_HOLDER = new ManagedFieldHolder(
6359
WEBMachine.class, WorkableElectricMultiblockMachine.MANAGED_FIELD_HOLDER);
@@ -68,9 +64,6 @@ public class WEBMachine extends WorkableElectricMultiblockMachine
6864

6965
protected ConditionalSubscriptionHandler converterSubscription;
7066

71-
@Getter
72-
private int coolantDrain;
73-
7467
@Persisted
7568
@DescSynced
7669
@Getter
@@ -115,33 +108,7 @@ public void convertEnergyTick() {
115108
getRecipeLogic()
116109
.setStatus(isSubscriptionActive() ? RecipeLogic.Status.WORKING : RecipeLogic.Status.SUSPEND);
117110
}
118-
if (isWorkingEnabled() && getRecipeLogic().getStatus() == RecipeLogic.Status.WORKING &&
119-
UtilConfig.coolantEnabled() && coolantTimer == 0 && frequency != 0) {
120-
121-
var coolantTanks = getCapabilitiesFlat(IO.IN, GTRecipeCapabilities.FLUID).stream()
122-
.map(NotifiableFluidTank.class::cast).toList();
123111

124-
List<FluidIngredient> left = List
125-
.of(FluidIngredient.of(UtilMaterials.QuantumCoolant.getFluid(), coolantDrain));
126-
127-
for (var tank : coolantTanks) {
128-
left = tank.handleRecipe(IO.IN, null, left, false);
129-
if (left == null) {
130-
break;
131-
}
132-
}
133-
134-
if (left != null && !left.isEmpty()) {
135-
if (!ConfigHolder.INSTANCE.machines.harmlessActiveTransformers) {
136-
explode();
137-
} else {
138-
coolantTimer = 0;
139-
getRecipeLogic().setStatus(RecipeLogic.Status.SUSPEND);
140-
converterSubscription.updateSubscription();
141-
return;
142-
}
143-
}
144-
}
145112
if (isWorkingEnabled() && getRecipeLogic().getStatus() == RecipeLogic.Status.WORKING) {
146113
coolantTimer = (coolantTimer + 1) % 20;
147114
}
@@ -159,34 +126,6 @@ public void convertEnergyTick() {
159126
converterSubscription.updateSubscription();
160127
}
161128

162-
private int calculateCoolantDrain() {
163-
long inputAmperage = 0;
164-
long inputVoltage = 0;
165-
long outputAmperage = 0;
166-
long outputVoltage = 0;
167-
168-
if (!localPowerInput.isEmpty()) {
169-
EnergyContainerList localInputs = EnergyUtils.getEnergyListFromMultiParts(localPowerInput);
170-
inputAmperage = localInputs.getInputAmperage();
171-
inputVoltage = localInputs.getInputVoltage();
172-
}
173-
174-
if (!localPowerOutput.isEmpty()) {
175-
EnergyContainerList localOutputs = EnergyUtils.getEnergyListFromMultiParts(localPowerOutput);
176-
outputAmperage = localOutputs.getOutputAmperage();
177-
outputVoltage = localOutputs.getOutputVoltage();
178-
}
179-
180-
long scalingFactor = Math.max(inputAmperage * inputVoltage, outputAmperage * outputVoltage);
181-
182-
int coolantDrain = UtilConfig.INSTANCE.features.pterbCoolantBaseDrain +
183-
(int) (scalingFactor * UtilConfig.INSTANCE.features.pterbCoolantIOMultiplier);
184-
if (coolantDrain <= 0) {
185-
coolantDrain = 1;
186-
}
187-
return coolantDrain / 4;
188-
}
189-
190129
@SuppressWarnings("RedundantIfStatement") // It is cleaner to have the final return true separate.
191130
protected boolean isSubscriptionActive() {
192131
if (!isFormed()) return false;
@@ -243,11 +182,8 @@ public void onStructureFormed() {
243182
return;
244183
}
245184

246-
this.localPowerInput = localPowerInput;
247185
this.localPowerOutput = localPowerOutput;
248186

249-
this.coolantDrain = calculateCoolantDrain();
250-
251187
if (frequency != 0 && isActive()) {
252188
addWirelessEnergy();
253189
}
@@ -312,13 +248,9 @@ private void addWirelessEnergy() {
312248
}
313249

314250
public static TraceabilityPredicate getHatchPredicates() {
315-
var predicate = abilities(PartAbility.OUTPUT_ENERGY).setPreviewCount(2)
251+
return abilities(PartAbility.OUTPUT_ENERGY).setPreviewCount(2)
316252
.or(abilities(PartAbility.SUBSTATION_OUTPUT_ENERGY).setPreviewCount(1))
317253
.or(abilities(PartAbility.OUTPUT_LASER).setPreviewCount(1));
318-
if (UtilConfig.coolantEnabled()) {
319-
predicate = predicate.or(abilities(PartAbility.IMPORT_FLUIDS).setExactLimit(1));
320-
}
321-
return predicate;
322254
}
323255

324256
@Override
@@ -331,45 +263,24 @@ public void addDisplayText(@NotNull List<Component> textList) {
331263
if (!isWorkingEnabled()) {
332264
textList.add(Component.translatable("gtceu.multiblock.work_paused"));
333265
} else if (isActive()) {
334-
long inputAmperage = 0;
335-
long inputVoltage = 0;
336266
long outputAmperage = 0;
337267
long outputVoltage = 0;
338268

339-
if (!localPowerInput.isEmpty()) {
340-
EnergyContainerList localInputs = EnergyUtils.getEnergyListFromMultiParts(localPowerInput);
341-
inputAmperage = localInputs.getInputAmperage();
342-
inputVoltage = localInputs.getInputVoltage();
343-
}
344-
345269
if (!localPowerOutput.isEmpty()) {
346270
EnergyContainerList localOutputs = EnergyUtils.getEnergyListFromMultiParts(localPowerOutput);
347271
outputAmperage = localOutputs.getOutputAmperage();
348272
outputVoltage = localOutputs.getOutputVoltage();
349273
}
350274

351-
long inputTotal = inputVoltage * inputAmperage;
352275
long outputTotal = outputVoltage * outputAmperage;
353276

354277
textList.add(Component.translatable("gtceu.multiblock.running"));
355-
if (inputTotal > 0) {
356-
textList.add(Component
357-
.translatable("gtceu.multiblock.active_transformer.max_input",
358-
FormattingUtil.formatNumbers(
359-
Math.abs(inputTotal))));
360-
}
361278
if (outputTotal > 0) {
362279
textList.add(Component
363280
.translatable("gtceu.multiblock.active_transformer.max_output",
364281
FormattingUtil.formatNumbers(
365282
Math.abs(outputTotal))));
366283
}
367-
if (UtilConfig.coolantEnabled()) {
368-
textList.add(Component
369-
.translatable("gtmutils.multiblock.pterb_machine.coolant_usage",
370-
FormattingUtil.formatNumbers(coolantDrain),
371-
UtilMaterials.QuantumCoolant.getLocalizedName()));
372-
}
373284
if (!ConfigHolder.INSTANCE.machines.harmlessActiveTransformers) {
374285
textList.add(Component
375286
.translatable("gtceu.multiblock.active_transformer.danger_enabled"));

src/main/java/net/neganote/gtutilities/datagen/lang/UtilLangHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public static void init(RegistrateLangProvider provider) {
7777
"The {name tbd} is the energy output of a wireless energy network, it shares a frequency with a {name tbd} and outputs energy from it");
7878
provider.add("tooltip.web_machine.only_output", "Receives energy from a {name tbd}");
7979

80-
8180
provider.add("config.jade.plugin_gtmutils.pterb_info", "WAT Info");
8281

8382
multiLang(provider, "gtceu.placeholder_info.watfrequency",

src/main/java/net/neganote/gtutilities/saveddata/PTERBSavedData.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public class PTERBSavedData extends SavedData {
3737

3838
private final ServerLevel serverLevel;
3939

40-
4140
private PTERBSavedData(ServerLevel serverLevel) {
4241
energyInputs = new HashMap<>();
4342
energyOutputs = new HashMap<>();

0 commit comments

Comments
 (0)