1717import com .gregtechceu .gtceu .api .machine .feature .multiblock .IMultiPart ;
1818import com .gregtechceu .gtceu .api .machine .multiblock .PartAbility ;
1919import com .gregtechceu .gtceu .api .machine .multiblock .WorkableElectricMultiblockMachine ;
20- import com .gregtechceu .gtceu .api .machine .trait .NotifiableFluidTank ;
2120import com .gregtechceu .gtceu .api .machine .trait .RecipeLogic ;
2221import com .gregtechceu .gtceu .api .misc .EnergyContainerList ;
2322import com .gregtechceu .gtceu .api .pattern .TraceabilityPredicate ;
2423import com .gregtechceu .gtceu .api .pattern .error .PatternError ;
25- import com .gregtechceu .gtceu .api .recipe .ingredient .FluidIngredient ;
2624import com .gregtechceu .gtceu .common .data .GTItems ;
27- import com .gregtechceu .gtceu .common .data .GTRecipeCapabilities ;
2825import com .gregtechceu .gtceu .config .ConfigHolder ;
2926import com .gregtechceu .gtceu .utils .FormattingUtil ;
3027import com .gregtechceu .gtceu .utils .GTUtil ;
28+
3129import com .lowdragmc .lowdraglib .gui .modular .ModularUI ;
3230import com .lowdragmc .lowdraglib .gui .texture .IGuiTexture ;
3331import com .lowdragmc .lowdraglib .gui .texture .ItemStackTexture ;
3432import com .lowdragmc .lowdraglib .gui .widget .*;
3533import com .lowdragmc .lowdraglib .syncdata .annotation .DescSynced ;
3634import com .lowdragmc .lowdraglib .syncdata .annotation .Persisted ;
3735import com .lowdragmc .lowdraglib .syncdata .field .ManagedFieldHolder ;
38- import it .unimi .dsi .fastutil .longs .Long2ObjectMaps ;
39- import lombok .Getter ;
36+
4037import net .minecraft .ChatFormatting ;
4138import net .minecraft .network .chat .Component ;
4239import net .minecraft .server .level .ServerLevel ;
4340import net .minecraft .world .entity .player .Player ;
4441import 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 ;
4842import net .neganote .gtutilities .saveddata .PTERBSavedData ;
4943import 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 ;
5147import org .jetbrains .annotations .NotNull ;
5248
5349import java .util .*;
5652
5753// A lot of this is copied from the Active Transformer
5854public 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" ));
0 commit comments