Skip to content

Commit

Permalink
Merge branch '1.19.x' of https://github.com/mekanism/Mekanism into 1.…
Browse files Browse the repository at this point in the history
…20.x
  • Loading branch information
pupnewfster committed Jul 14, 2023
2 parents b759b44 + cefeaae commit 19dcdc3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import mekanism.common.capabilities.holder.chemical.ConfigChemicalTankHolder.ConfigSlurryTankHolder;
import mekanism.common.tile.component.TileComponentConfig;
import net.minecraft.core.Direction;
import net.minecraftforge.common.util.NonNullSupplier;
import org.jetbrains.annotations.NotNull;

public class ChemicalTankHelper<CHEMICAL extends Chemical<CHEMICAL>, STACK extends ChemicalStack<CHEMICAL>, TANK extends IChemicalTank<CHEMICAL, STACK>> {
Expand All @@ -38,10 +39,10 @@ private ChemicalTankHelper(IChemicalTankHolder<CHEMICAL, STACK, TANK> slotHolder
this.slotHolder = slotHolder;
}

public static BiPredicate<@NotNull Gas, @NotNull AutomationType> radioactiveInputTankPredicate(IGasTank outputTank) {
public static BiPredicate<@NotNull Gas, @NotNull AutomationType> radioactiveInputTankPredicate(NonNullSupplier<IGasTank> outputTank) {
//Allow extracting out of the input gas tank if it isn't external OR the output tank is empty AND the input is radioactive
//Note: This only is the case if radiation is enabled as otherwise things like gauge droppers can work as the way to remove radioactive contents
return (type, automationType) -> automationType != AutomationType.EXTERNAL || (outputTank.isEmpty() && type.has(GasAttributes.Radiation.class) &&
return (type, automationType) -> automationType != AutomationType.EXTERNAL || (outputTank.get().isEmpty() && type.has(GasAttributes.Radiation.class) &&
MekanismAPI.getRadiationManager().isRadiationEnabled());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public TileEntityIsotopicCentrifuge(BlockPos pos, BlockState state) {
public IChemicalTankHolder<Gas, GasStack, IGasTank> getInitialGasTanks(IContentsListener listener, IContentsListener recipeCacheListener) {
ChemicalTankHelper<Gas, GasStack, IGasTank> builder = ChemicalTankHelper.forSideGasWithConfig(this::getDirection, this::getConfig);
//Allow extracting out of the input gas tank if it isn't external OR the output tank is empty AND the input is radioactive
builder.addTank(inputTank = ChemicalTankBuilder.GAS.create(MAX_GAS, ChemicalTankHelper.radioactiveInputTankPredicate(outputTank),
builder.addTank(inputTank = ChemicalTankBuilder.GAS.create(MAX_GAS, ChemicalTankHelper.radioactiveInputTankPredicate(() -> outputTank),
ChemicalTankBuilder.GAS.alwaysTrueBi, this::containsRecipe, ChemicalAttributeValidator.ALWAYS_ALLOW, recipeCacheListener));
builder.addTank(outputTank = ChemicalTankBuilder.GAS.output(MAX_GAS, listener));
return builder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public TileEntityPressurizedReactionChamber(BlockPos pos, BlockState state) {
public IChemicalTankHolder<Gas, GasStack, IGasTank> getInitialGasTanks(IContentsListener listener, IContentsListener recipeCacheListener) {
ChemicalTankHelper<Gas, GasStack, IGasTank> builder = ChemicalTankHelper.forSideGasWithConfig(this::getDirection, this::getConfig);
//Allow extracting out of the input gas tank if it isn't external OR the output tank is empty AND the input is radioactive
builder.addTank(inputGasTank = ChemicalTankBuilder.GAS.create(MAX_GAS, ChemicalTankHelper.radioactiveInputTankPredicate(outputGasTank),
builder.addTank(inputGasTank = ChemicalTankBuilder.GAS.create(MAX_GAS, ChemicalTankHelper.radioactiveInputTankPredicate(() -> outputGasTank),
(gas, automationType) -> containsRecipeCAB(inputSlot.getStack(), inputFluidTank.getFluid(), gas), this::containsRecipeC,
ChemicalAttributeValidator.ALWAYS_ALLOW, recipeCacheListener));
builder.addTank(outputGasTank = ChemicalTankBuilder.GAS.output(MAX_GAS, listener));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public TileEntitySolarNeutronActivator(BlockPos pos, BlockState state) {
public IChemicalTankHolder<Gas, GasStack, IGasTank> getInitialGasTanks(IContentsListener listener, IContentsListener recipeCacheListener) {
ChemicalTankHelper<Gas, GasStack, IGasTank> builder = ChemicalTankHelper.forSideGasWithConfig(this::getDirection, this::getConfig);
//Allow extracting out of the input gas tank if it isn't external OR the output tank is empty AND the input is radioactive
builder.addTank(inputTank = ChemicalTankBuilder.GAS.create(MAX_GAS, ChemicalTankHelper.radioactiveInputTankPredicate(outputTank),
builder.addTank(inputTank = ChemicalTankBuilder.GAS.create(MAX_GAS, ChemicalTankHelper.radioactiveInputTankPredicate(() -> outputTank),
ChemicalTankBuilder.GAS.alwaysTrueBi, this::containsRecipe, ChemicalAttributeValidator.ALWAYS_ALLOW, recipeCacheListener));
builder.addTank(outputTank = ChemicalTankBuilder.GAS.output(MAX_GAS, listener));
return builder.build();
Expand Down

0 comments on commit 19dcdc3

Please sign in to comment.