Merge branch 'development' of https://github.com/aidancbrady/Mekanism into development
This commit is contained in:
commit
7c5fe23833
8 changed files with 66 additions and 22 deletions
|
@ -10,6 +10,7 @@ import mekanism.common.tile.TileEntityAdvancedElectricMachine;
|
||||||
import mekanism.common.util.MekanismUtils;
|
import mekanism.common.util.MekanismUtils;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal interface for managing various Factory types.
|
* Internal interface for managing various Factory types.
|
||||||
|
@ -102,6 +103,36 @@ public interface IFactory
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canReceiveGas(ForgeDirection side, Gas type)
|
||||||
|
{
|
||||||
|
if(usesFuel)
|
||||||
|
{
|
||||||
|
return getTile().canReceiveGas(side, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canTubeConnect(ForgeDirection side)
|
||||||
|
{
|
||||||
|
if(usesFuel)
|
||||||
|
{
|
||||||
|
return getTile().canTubeConnect(side);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isValidGas(Gas gas)
|
||||||
|
{
|
||||||
|
if(usesFuel)
|
||||||
|
{
|
||||||
|
return getTile().isValidGas(gas);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public TileEntityAdvancedElectricMachine getTile()
|
public TileEntityAdvancedElectricMachine getTile()
|
||||||
{
|
{
|
||||||
if(cacheTile == null)
|
if(cacheTile == null)
|
||||||
|
|
|
@ -79,6 +79,8 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
||||||
* @return fuel ticks
|
* @return fuel ticks
|
||||||
*/
|
*/
|
||||||
public abstract GasStack getItemGas(ItemStack itemstack);
|
public abstract GasStack getItemGas(ItemStack itemstack);
|
||||||
|
|
||||||
|
public abstract boolean isValidGas(Gas gas);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate()
|
public void onUpdate()
|
||||||
|
|
|
@ -66,7 +66,7 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr
|
||||||
|
|
||||||
if(isValidGas(gas))
|
if(isValidGas(gas))
|
||||||
{
|
{
|
||||||
GasStack removed = GasTransmission.removeGas(inventory[1], gas, gasTank.getNeeded());
|
GasStack removed = GasTransmission.removeGas(inventory[1], gasTank.getGas() != null ? gasTank.getGas().getGas() : null, gasTank.getNeeded());
|
||||||
gasTank.receive(removed, true);
|
gasTank.receive(removed, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +82,7 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean isValidGas(Gas gas)
|
public boolean isValidGas(Gas gas)
|
||||||
{
|
{
|
||||||
return gas == GasRegistry.getGas("sulfuricAcid") || gas == GasRegistry.getGas("water") || gas == GasRegistry.getGas("hydrogenChloride");
|
return gas == GasRegistry.getGas("sulfuricAcid") || gas == GasRegistry.getGas("water") || gas == GasRegistry.getGas("hydrogenChloride");
|
||||||
|
|
|
@ -2,6 +2,7 @@ package mekanism.common.tile;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import mekanism.api.gas.Gas;
|
||||||
import mekanism.api.gas.GasRegistry;
|
import mekanism.api.gas.GasRegistry;
|
||||||
import mekanism.api.gas.GasStack;
|
import mekanism.api.gas.GasStack;
|
||||||
import mekanism.common.Mekanism;
|
import mekanism.common.Mekanism;
|
||||||
|
@ -35,4 +36,10 @@ public class TileEntityCombiner extends TileEntityAdvancedElectricMachine
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValidGas(Gas gas)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,25 +343,17 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
||||||
{
|
{
|
||||||
if(inventory[4] != null && RecipeType.values()[recipeType].usesFuel() && gasTank.getNeeded() > 0)
|
if(inventory[4] != null && RecipeType.values()[recipeType].usesFuel() && gasTank.getNeeded() > 0)
|
||||||
{
|
{
|
||||||
if(recipeType == RecipeType.PURIFYING.ordinal())
|
if(inventory[4].getItem() instanceof IGasItem)
|
||||||
{
|
{
|
||||||
if(inventory[4].getItem() instanceof IGasItem)
|
Gas gas = ((IGasItem)inventory[4].getItem()).getGas(inventory[4]).getGas();
|
||||||
|
|
||||||
|
if(RecipeType.values()[recipeType].isValidGas(gas))
|
||||||
{
|
{
|
||||||
GasStack removed = GasTransmission.removeGas(inventory[4], GasRegistry.getGas("oxygen"), gasTank.getNeeded());
|
GasStack removed = GasTransmission.removeGas(inventory[4], gasTank.getGas() != null ? gasTank.getGas().getGas() : null, gasTank.getNeeded());
|
||||||
gasTank.receive(removed, true);
|
gasTank.receive(removed, true);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(recipeType == RecipeType.INJECTING.ordinal())
|
|
||||||
{
|
|
||||||
if(inventory[4].getItem() instanceof IGasItem)
|
|
||||||
{
|
|
||||||
GasStack removed = GasTransmission.removeGas(inventory[4], GasRegistry.getGas("sulfuricAcid"), gasTank.getNeeded());
|
|
||||||
gasTank.receive(removed, true);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GasStack stack = RecipeType.values()[recipeType].getItemGas(inventory[4]);
|
GasStack stack = RecipeType.values()[recipeType].getItemGas(inventory[4]);
|
||||||
|
@ -897,8 +889,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
||||||
@Override
|
@Override
|
||||||
public int receiveGas(ForgeDirection side, GasStack stack)
|
public int receiveGas(ForgeDirection side, GasStack stack)
|
||||||
{
|
{
|
||||||
if(recipeType == RecipeType.PURIFYING.ordinal() && stack.getGas() == GasRegistry.getGas("oxygen") ||
|
if(canReceiveGas(side, stack.getGas()))
|
||||||
recipeType == RecipeType.INJECTING.ordinal() && stack.getGas() == GasRegistry.getGas("sulfuricAcid"))
|
|
||||||
{
|
{
|
||||||
return gasTank.receive(stack, true);
|
return gasTank.receive(stack, true);
|
||||||
}
|
}
|
||||||
|
@ -909,14 +900,13 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
||||||
@Override
|
@Override
|
||||||
public boolean canReceiveGas(ForgeDirection side, Gas type)
|
public boolean canReceiveGas(ForgeDirection side, Gas type)
|
||||||
{
|
{
|
||||||
return recipeType == RecipeType.PURIFYING.ordinal() && type == GasRegistry.getGas("oxygen") ||
|
return RecipeType.values()[recipeType].canReceiveGas(side, type);
|
||||||
recipeType == RecipeType.INJECTING.ordinal() && type == GasRegistry.getGas("sulfuricAcid");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTubeConnect(ForgeDirection side)
|
public boolean canTubeConnect(ForgeDirection side)
|
||||||
{
|
{
|
||||||
return recipeType == RecipeType.PURIFYING.ordinal() || recipeType == RecipeType.INJECTING.ordinal();
|
return RecipeType.values()[recipeType].canTubeConnect(side);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
||||||
|
|
||||||
if(inventory[1] != null && (gasTank.getGas() == null || gasTank.getGas().amount < gasTank.getMaxGas()))
|
if(inventory[1] != null && (gasTank.getGas() == null || gasTank.getGas().amount < gasTank.getMaxGas()))
|
||||||
{
|
{
|
||||||
gasTank.receive(GasTransmission.removeGas(inventory[1], null, gasTank.getNeeded()), true);
|
gasTank.receive(GasTransmission.removeGas(inventory[1], gasTank.getGas() != null ? gasTank.getGas().getGas() : null, gasTank.getNeeded()), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!worldObj.isRemote && gasTank.getGas() != null && MekanismUtils.canFunction(this))
|
if(!worldObj.isRemote && gasTank.getGas() != null && MekanismUtils.canFunction(this))
|
||||||
|
|
|
@ -2,6 +2,7 @@ package mekanism.common.tile;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import mekanism.api.gas.Gas;
|
||||||
import mekanism.api.gas.GasRegistry;
|
import mekanism.api.gas.GasRegistry;
|
||||||
import mekanism.api.gas.GasStack;
|
import mekanism.api.gas.GasStack;
|
||||||
import mekanism.common.Mekanism;
|
import mekanism.common.Mekanism;
|
||||||
|
@ -47,4 +48,10 @@ public class TileEntityOsmiumCompressor extends TileEntityAdvancedElectricMachin
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValidGas(Gas gas)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,4 +75,10 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValidGas(Gas gas)
|
||||||
|
{
|
||||||
|
return gas == GasRegistry.getGas("oxygen");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue