Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Air Scrubber issues #2613

Merged
merged 1 commit into from
Dec 21, 2024
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 @@ -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
Loading