mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-27 15:23:16 +00:00
Don't hard code some machines to specific gas types
This commit is contained in:
1 parent
f8b162bc31
commit
d8b6dfbb78
21 files changed
+181
-282
No files matched your search
@@ -4,8 +4,6 @@ import java.util.Map;
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.MekanismBlocks;
|
||||
import mekanism.common.MekanismFluids;
|
||||
import mekanism.common.block.states.BlockStateMachine;
|
||||
import mekanism.common.config.MekanismConfig.usage;
|
||||
import mekanism.common.recipe.RecipeHandler.Recipe;
|
||||
@@ -13,8 +11,6 @@ import mekanism.common.recipe.inputs.AdvancedMachineInput;
|
||||
import mekanism.common.recipe.machines.PurificationRecipe;
|
||||
import mekanism.common.tile.prefab.TileEntityAdvancedElectricMachine;
|
||||
import mekanism.common.util.GasUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
@@ -30,40 +26,29 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac
|
||||
return Recipe.PURIFICATION_CHAMBER.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GasStack getItemGas(ItemStack itemstack) {
|
||||
if (itemstack.isItemEqual(new ItemStack(Items.FLINT))) {
|
||||
return new GasStack(MekanismFluids.Oxygen, 10);
|
||||
}
|
||||
if (Block.getBlockFromItem(itemstack.getItem()) == MekanismBlocks.GasTank
|
||||
&& ((IGasItem) itemstack.getItem()).getGas(itemstack) != null &&
|
||||
((IGasItem) itemstack.getItem()).getGas(itemstack).getGas() == MekanismFluids.Oxygen) {
|
||||
return new GasStack(MekanismFluids.Oxygen, 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveGas(EnumFacing side, GasStack stack, boolean doTransfer) {
|
||||
if (stack.getGas() == MekanismFluids.Oxygen) {
|
||||
if (canReceiveGas(side, stack.getGas())) {
|
||||
return gasTank.receive(stack, doTransfer);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceiveGas(EnumFacing side, Gas type) {
|
||||
return type == MekanismFluids.Oxygen;
|
||||
return gasTank.canReceive(type) && isValidGas(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSecondaryFuel() {
|
||||
if (!inventory.get(1).isEmpty() && gasTank.getNeeded() > 0 && inventory.get(1).getItem() instanceof IGasItem) {
|
||||
GasStack removed = GasUtils.removeGas(inventory.get(1), MekanismFluids.Oxygen, gasTank.getNeeded());
|
||||
gasTank.receive(removed, true);
|
||||
return;
|
||||
ItemStack itemStack = inventory.get(1);
|
||||
if (!itemStack.isEmpty() && gasTank.getNeeded() > 0 && itemStack.getItem() instanceof IGasItem) {
|
||||
GasStack gas = ((IGasItem) itemStack.getItem()).getGas(itemStack);
|
||||
if (gas != null) {
|
||||
GasStack removed = GasUtils.removeGas(itemStack, gas.getGas(), gasTank.getNeeded());
|
||||
gasTank.receive(removed, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
super.handleSecondaryFuel();
|
||||
@@ -76,7 +61,7 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac
|
||||
|
||||
@Override
|
||||
public boolean isValidGas(Gas gas) {
|
||||
return gas == MekanismFluids.Oxygen;
|
||||
return Recipe.PURIFICATION_CHAMBER.containsRecipe(gas);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user