Skip to content

Commit

Permalink
Fix Air Scrubber issues (GregTechCEu#2613)
Browse files Browse the repository at this point in the history
  • Loading branch information
krossgg authored and omergunr100 committed Dec 25, 2024
1 parent 9637fbe commit 557c518
Showing 1 changed file with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity;
import com.gregtechceu.gtceu.api.machine.SimpleTieredMachine;
import com.gregtechceu.gtceu.api.machine.feature.IEnvironmentalHazardCleaner;
import com.gregtechceu.gtceu.api.recipe.GTRecipe;
import com.gregtechceu.gtceu.common.blockentity.DuctPipeBlockEntity;
import com.gregtechceu.gtceu.common.capability.EnvironmentalHazardSavedData;
import com.gregtechceu.gtceu.common.data.GTRecipeTypes;
Expand All @@ -25,6 +26,7 @@
import it.unimi.dsi.fastutil.objects.Object2FloatMap;
import it.unimi.dsi.fastutil.objects.Object2FloatOpenHashMap;
import lombok.Getter;
import org.jetbrains.annotations.Nullable;

import static com.gregtechceu.gtceu.api.GTValues.LV;
import static com.gregtechceu.gtceu.api.GTValues.VHA;
Expand All @@ -33,14 +35,14 @@ public class AirScrubberMachine extends SimpleTieredMachine implements IEnvironm

public static final float MIN_CLEANING_PER_OPERATION = 10;

private final float cleaningPerOperation;
private float cleaningPerOperation;

@Getter
private float removedLastSecond;

public AirScrubberMachine(IMachineBlockEntity holder, int tier, Object... args) {
super(holder, tier, GTMachineUtils.largeTankSizeFunction, args);
this.cleaningPerOperation = MIN_CLEANING_PER_OPERATION * tier;
this.cleaningPerOperation = MIN_CLEANING_PER_OPERATION;
}

@Override
Expand All @@ -60,14 +62,27 @@ public void cleanHazard(MedicalCondition condition, float amount) {
this.recipeLogic.checkMatchedRecipeAvailable(builder.buildRawRecipe());
}

@Override
public boolean isRecipeLogicAvailable() {
// Don't run recipes if hazards are off
return ConfigHolder.INSTANCE.gameplay.environmentalHazards;
}

@Override
public boolean beforeWorking(@Nullable GTRecipe recipe) {
if (super.beforeWorking(recipe) && recipe != null) {
// Sets the amount of hazard to clean based on the recipe tier, not the machine tier
this.cleaningPerOperation = MIN_CLEANING_PER_OPERATION * (recipe.ocLevel + 1);
return true;
}
return false;
}

@Override
public boolean onWorking() {
if (!super.onWorking()) {
if (!super.onWorking() || !ConfigHolder.INSTANCE.gameplay.environmentalHazards) {
return false;
}
if (!ConfigHolder.INSTANCE.gameplay.environmentalHazards) {
return true;
}

if (getOffsetTimer() % 20 == 0) {
removedLastSecond = 0;
Expand Down

0 comments on commit 557c518

Please sign in to comment.