Skip to content

Commit

Permalink
fix: hulls are no longer counted as energy inputs in cleanrooms (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikerooni authored Nov 12, 2023
1 parent 2262f8f commit 11cc8f9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ Version: 1.0.15
* fix item pipes stopping transfer after their transfer rate per second has been reached once
* fix capability IO directions
* fix laser pipes not connecting to hatches
* fix diodes being counted as energy input in cleanrooms
* fix diodes and hulls being counted as energy input in cleanrooms
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import com.gregtechceu.gtceu.api.capability.GTCapabilityHelper;
import com.gregtechceu.gtceu.api.capability.ICleanroomReceiver;
import com.gregtechceu.gtceu.api.capability.IEnergyContainer;
import com.gregtechceu.gtceu.common.machine.multiblock.part.DiodePartMachine;
import com.gregtechceu.gtceu.common.machine.trait.CleanroomLogic;
import com.gregtechceu.gtceu.api.capability.recipe.EURecipeCapability;
import com.gregtechceu.gtceu.api.capability.recipe.IO;
import com.gregtechceu.gtceu.api.machine.IMachineBlockEntity;
Expand All @@ -19,14 +17,23 @@
import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMaintenanceMachine;
import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMufflerMachine;
import com.gregtechceu.gtceu.api.machine.feature.multiblock.IMultiPart;
import com.gregtechceu.gtceu.api.machine.multiblock.*;
import com.gregtechceu.gtceu.api.machine.multiblock.CleanroomType;
import com.gregtechceu.gtceu.api.machine.multiblock.PartAbility;
import com.gregtechceu.gtceu.api.machine.multiblock.WorkableElectricMultiblockMachine;
import com.gregtechceu.gtceu.api.machine.multiblock.WorkableMultiblockMachine;
import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic;
import com.gregtechceu.gtceu.api.misc.EnergyContainerList;
import com.gregtechceu.gtceu.api.pattern.*;
import com.gregtechceu.gtceu.api.pattern.BlockPattern;
import com.gregtechceu.gtceu.api.pattern.FactoryBlockPattern;
import com.gregtechceu.gtceu.api.pattern.Predicates;
import com.gregtechceu.gtceu.api.pattern.TraceabilityPredicate;
import com.gregtechceu.gtceu.common.data.GTBlocks;
import com.gregtechceu.gtceu.common.machine.electric.HullMachine;
import com.gregtechceu.gtceu.common.machine.multiblock.part.DiodePartMachine;
import com.gregtechceu.gtceu.common.machine.multiblock.primitive.CokeOvenMachine;
import com.gregtechceu.gtceu.common.machine.multiblock.primitive.PrimitiveBlastFurnaceMachine;
import com.gregtechceu.gtceu.common.machine.multiblock.primitive.PrimitivePumpMachine;
import com.gregtechceu.gtceu.common.machine.trait.CleanroomLogic;
import com.gregtechceu.gtceu.utils.GTUtil;
import com.lowdragmc.lowdraglib.syncdata.annotation.Persisted;
import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder;
Expand All @@ -53,7 +60,8 @@
import javax.annotation.ParametersAreNonnullByDefault;
import java.util.*;

import static com.gregtechceu.gtceu.api.pattern.Predicates.*;
import static com.gregtechceu.gtceu.api.pattern.Predicates.abilities;
import static com.gregtechceu.gtceu.api.pattern.Predicates.states;

@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
Expand Down Expand Up @@ -158,9 +166,9 @@ protected void initializeAbilities() {
List<IEnergyContainer> energyContainers = new ArrayList<>();
Map<Long, IO> ioMap = getMultiblockState().getMatchContext().getOrCreate("ioMap", Long2ObjectMaps::emptyMap);
for (IMultiPart part : getParts()) {
if (part instanceof DiodePartMachine) continue;
if (isPartIgnored(part)) continue;
IO io = ioMap.getOrDefault(part.self().getPos().asLong(), IO.BOTH);
if(io == IO.NONE || io == IO.OUT) continue;
if (io == IO.NONE || io == IO.OUT) continue;
for (var handler : part.getRecipeHandlers()) {
// If IO not compatible
if (io != IO.BOTH && handler.getHandlerIO() != IO.BOTH && io != handler.getHandlerIO()) continue;
Expand All @@ -176,6 +184,14 @@ protected void initializeAbilities() {
getRecipeLogic().setEnergyContainer(this.inputEnergyContainers);
}

@SuppressWarnings("RedundantIfStatement") // `return false` being a separate statement is better for readability
private static boolean isPartIgnored(IMultiPart part) {
if (part instanceof DiodePartMachine) return true;
if (part instanceof HullMachine) return true;

return false;
}

/**
* Scans for blocks around the controller to update the dimensions
*/
Expand Down Expand Up @@ -376,7 +392,7 @@ protected BlockState getGlassState() {
@Nonnull
protected static TraceabilityPredicate doorPredicate() {
return Predicates.custom(blockWorldState -> blockWorldState.getBlockState().getBlock() instanceof DoorBlock,
() -> new BlockInfo[] {new BlockInfo(Blocks.IRON_DOOR.defaultBlockState()), new BlockInfo(Blocks.IRON_DOOR.defaultBlockState().setValue(DoorBlock.HALF, DoubleBlockHalf.UPPER))});
() -> new BlockInfo[]{new BlockInfo(Blocks.IRON_DOOR.defaultBlockState()), new BlockInfo(Blocks.IRON_DOOR.defaultBlockState().setValue(DoorBlock.HALF, DoubleBlockHalf.UPPER))});
}

@Nonnull
Expand Down

0 comments on commit 11cc8f9

Please sign in to comment.