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 net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
* Internal interface for managing various Factory types.
|
||||
|
@ -102,6 +103,36 @@ public interface IFactory
|
|||
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()
|
||||
{
|
||||
if(cacheTile == null)
|
||||
|
|
|
@ -80,6 +80,8 @@ public abstract class TileEntityAdvancedElectricMachine extends TileEntityBasicM
|
|||
*/
|
||||
public abstract GasStack getItemGas(ItemStack itemstack);
|
||||
|
||||
public abstract boolean isValidGas(Gas gas);
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
|
|
|
@ -66,7 +66,7 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -82,6 +82,7 @@ public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectr
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGas(Gas gas)
|
||||
{
|
||||
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 mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.common.Mekanism;
|
||||
|
@ -35,4 +36,10 @@ public class TileEntityCombiner extends TileEntityAdvancedElectricMachine
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGas(Gas gas)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -342,27 +342,19 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
public void handleSecondaryFuel()
|
||||
{
|
||||
if(inventory[4] != null && RecipeType.values()[recipeType].usesFuel() && gasTank.getNeeded() > 0)
|
||||
{
|
||||
if(recipeType == RecipeType.PURIFYING.ordinal())
|
||||
{
|
||||
if(inventory[4].getItem() instanceof IGasItem)
|
||||
{
|
||||
GasStack removed = GasTransmission.removeGas(inventory[4], GasRegistry.getGas("oxygen"), gasTank.getNeeded());
|
||||
Gas gas = ((IGasItem)inventory[4].getItem()).getGas(inventory[4]).getGas();
|
||||
|
||||
if(RecipeType.values()[recipeType].isValidGas(gas))
|
||||
{
|
||||
GasStack removed = GasTransmission.removeGas(inventory[4], gasTank.getGas() != null ? gasTank.getGas().getGas() : null, gasTank.getNeeded());
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
GasStack stack = RecipeType.values()[recipeType].getItemGas(inventory[4]);
|
||||
int gasNeeded = gasTank.getNeeded();
|
||||
|
@ -897,8 +889,7 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
@Override
|
||||
public int receiveGas(ForgeDirection side, GasStack stack)
|
||||
{
|
||||
if(recipeType == RecipeType.PURIFYING.ordinal() && stack.getGas() == GasRegistry.getGas("oxygen") ||
|
||||
recipeType == RecipeType.INJECTING.ordinal() && stack.getGas() == GasRegistry.getGas("sulfuricAcid"))
|
||||
if(canReceiveGas(side, stack.getGas()))
|
||||
{
|
||||
return gasTank.receive(stack, true);
|
||||
}
|
||||
|
@ -909,14 +900,13 @@ public class TileEntityFactory extends TileEntityElectricBlock implements IPerip
|
|||
@Override
|
||||
public boolean canReceiveGas(ForgeDirection side, Gas type)
|
||||
{
|
||||
return recipeType == RecipeType.PURIFYING.ordinal() && type == GasRegistry.getGas("oxygen") ||
|
||||
recipeType == RecipeType.INJECTING.ordinal() && type == GasRegistry.getGas("sulfuricAcid");
|
||||
return RecipeType.values()[recipeType].canReceiveGas(side, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTubeConnect(ForgeDirection side)
|
||||
{
|
||||
return recipeType == RecipeType.PURIFYING.ordinal() || recipeType == RecipeType.INJECTING.ordinal();
|
||||
return RecipeType.values()[recipeType].canTubeConnect(side);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -50,7 +50,7 @@ public class TileEntityGasTank extends TileEntityContainerBlock implements IGasH
|
|||
|
||||
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))
|
||||
|
|
|
@ -2,6 +2,7 @@ package mekanism.common.tile;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import mekanism.api.gas.Gas;
|
||||
import mekanism.api.gas.GasRegistry;
|
||||
import mekanism.api.gas.GasStack;
|
||||
import mekanism.common.Mekanism;
|
||||
|
@ -47,4 +48,10 @@ public class TileEntityOsmiumCompressor extends TileEntityAdvancedElectricMachin
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGas(Gas gas)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,4 +75,10 @@ public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMac
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidGas(Gas gas)
|
||||
{
|
||||
return gas == GasRegistry.getGas("oxygen");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue