mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-26 14:52:58 +00:00
This commit is contained in:
1 parent
d10a623e51
commit
b49e45a03d
6 files changed
+25
-1
No files matched your search
@@ -191,6 +191,13 @@ public interface IFactory {
|
||||
return fuelType == MachineFuelType.ADVANCED;
|
||||
}
|
||||
|
||||
public boolean isValidGas(Gas gas) {
|
||||
if (fuelType == MachineFuelType.ADVANCED) {
|
||||
return getTile().isValidGas(gas);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasRecipe(ItemStack itemStack) {
|
||||
if (itemStack.isEmpty()) {
|
||||
return false;
|
||||
|
||||
@@ -217,6 +217,9 @@ public class GeneralConfig extends BaseConfig {
|
||||
public final BooleanOption destroyDisabledBlocks = new BooleanOption(this, "general", "DestroyDisabledBlocks", true,
|
||||
"If machine is disabled in config, do we set its block to air if it is found in world?");
|
||||
|
||||
public final BooleanOption voidInvalidGases = new BooleanOption(this, "general", "VoidInvalidGases", true,
|
||||
"Should machines void the gas inside of them on load if there is no recipe using that gas.");
|
||||
|
||||
public final IntOption digitalMinerMaxRadius = new IntOption(this, "general", "digitalMinerMaxRadius", 32,
|
||||
"Maximum radius in blocks that the Digital Miner can reach. (Increasing this may have negative effects on stability and/or performance. "
|
||||
+ "We strongly recommend you leave it at the default value.)", 1, Integer.MAX_VALUE);
|
||||
|
||||
@@ -186,6 +186,7 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityMachine impl
|
||||
operatingTicks = nbtTags.getInteger("operatingTicks");
|
||||
injectTank.read(nbtTags.getCompoundTag("injectTank"));
|
||||
outputTank.read(nbtTags.getCompoundTag("gasTank"));
|
||||
GasUtils.clearIfInvalid(injectTank, this::isValidGas);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -474,7 +474,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
@Nullable
|
||||
public GasStack getItemGas(ItemStack itemStack) {
|
||||
if (recipeType.getFuelType() == MachineFuelType.ADVANCED) {
|
||||
return GasConversionHandler.getItemGas(itemStack, gasTank, recipeType.getTile()::isValidGas);
|
||||
return GasConversionHandler.getItemGas(itemStack, gasTank, recipeType::isValidGas);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -749,6 +749,7 @@ public class TileEntityFactory extends TileEntityMachine implements IComputerInt
|
||||
progress[i] = nbtTags.getInteger("progress" + i);
|
||||
}
|
||||
gasTank.read(nbtTags.getCompoundTag("gasTank"));
|
||||
GasUtils.clearIfInvalid(gasTank, recipeType::isValidGas);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -249,6 +249,7 @@ public abstract class TileEntityAdvancedElectricMachine<RECIPE extends AdvancedM
|
||||
super.readFromNBT(nbtTags);
|
||||
gasTank.read(nbtTags.getCompoundTag("gasTank"));
|
||||
gasTank.setMaxGas(MAX_GAS);
|
||||
GasUtils.clearIfInvalid(gasTank, this::isValidGas);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -3,6 +3,7 @@ package mekanism.common.util;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.GasTank;
|
||||
@@ -10,6 +11,7 @@ import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.base.target.GasHandlerTarget;
|
||||
import mekanism.common.capabilities.Capabilities;
|
||||
import mekanism.common.config.MekanismConfig;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -51,6 +53,15 @@ public final class GasUtils {
|
||||
return CapabilityUtils.hasCapability(tile, Capabilities.GAS_HANDLER_CAPABILITY, side.getOpposite());
|
||||
}
|
||||
|
||||
public static void clearIfInvalid(GasTank tank, Predicate<Gas> isValid) {
|
||||
if (MekanismConfig.current().general.voidInvalidGases.val()) {
|
||||
Gas gas = tank.getGasType();
|
||||
if (gas != null && !isValid.test(gas)) {
|
||||
tank.setGas(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a specified amount of gas from an IGasItem.
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user