Making a start on Gas Centrifuge.
This commit is contained in:
parent
5dc0e5dca1
commit
b5f3d77b83
9 changed files with 307 additions and 2 deletions
|
@ -80,6 +80,7 @@ public class MekanismConfig
|
||||||
public static double fluidicPlenisherUsage;
|
public static double fluidicPlenisherUsage;
|
||||||
public static double laserUsage;
|
public static double laserUsage;
|
||||||
public static double salinationPlantWaterUsage;
|
public static double salinationPlantWaterUsage;
|
||||||
|
public static double gasCentrifugeUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class generators
|
public static class generators
|
||||||
|
|
|
@ -137,6 +137,7 @@ import mekanism.common.tile.TileEntityEnrichmentChamber;
|
||||||
import mekanism.common.tile.TileEntityEntangledBlock;
|
import mekanism.common.tile.TileEntityEntangledBlock;
|
||||||
import mekanism.common.tile.TileEntityFactory;
|
import mekanism.common.tile.TileEntityFactory;
|
||||||
import mekanism.common.tile.TileEntityFluidicPlenisher;
|
import mekanism.common.tile.TileEntityFluidicPlenisher;
|
||||||
|
import mekanism.common.tile.TileEntityGasCentrifuge;
|
||||||
import mekanism.common.tile.TileEntityGasTank;
|
import mekanism.common.tile.TileEntityGasTank;
|
||||||
import mekanism.common.tile.TileEntityLaser;
|
import mekanism.common.tile.TileEntityLaser;
|
||||||
import mekanism.common.tile.TileEntityLaserAmplifier;
|
import mekanism.common.tile.TileEntityLaserAmplifier;
|
||||||
|
@ -311,6 +312,7 @@ public class ClientProxy extends CommonProxy
|
||||||
ClientRegistry.registerTileEntity(TileEntityLaserAmplifier.class, "LaserAmplifier", new RenderLaserAmplifier());
|
ClientRegistry.registerTileEntity(TileEntityLaserAmplifier.class, "LaserAmplifier", new RenderLaserAmplifier());
|
||||||
ClientRegistry.registerTileEntity(TileEntityLaserTractorBeam.class, "LaserTractorBeam", new RenderLaserTractorBeam());
|
ClientRegistry.registerTileEntity(TileEntityLaserTractorBeam.class, "LaserTractorBeam", new RenderLaserTractorBeam());
|
||||||
GameRegistry.registerTileEntity(TileEntityAmbientAccumulator.class, "AmbientAccumulator");
|
GameRegistry.registerTileEntity(TileEntityAmbientAccumulator.class, "AmbientAccumulator");
|
||||||
|
GameRegistry.registerTileEntity(TileEntityGasCentrifuge.class, "GasCentrifuge");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -72,6 +72,7 @@ import mekanism.common.tile.TileEntityEnergyCube;
|
||||||
import mekanism.common.tile.TileEntityEnrichmentChamber;
|
import mekanism.common.tile.TileEntityEnrichmentChamber;
|
||||||
import mekanism.common.tile.TileEntityFactory;
|
import mekanism.common.tile.TileEntityFactory;
|
||||||
import mekanism.common.tile.TileEntityFluidicPlenisher;
|
import mekanism.common.tile.TileEntityFluidicPlenisher;
|
||||||
|
import mekanism.common.tile.TileEntityGasCentrifuge;
|
||||||
import mekanism.common.tile.TileEntityGasTank;
|
import mekanism.common.tile.TileEntityGasTank;
|
||||||
import mekanism.common.tile.TileEntityLaser;
|
import mekanism.common.tile.TileEntityLaser;
|
||||||
import mekanism.common.tile.TileEntityLaserAmplifier;
|
import mekanism.common.tile.TileEntityLaserAmplifier;
|
||||||
|
@ -155,6 +156,7 @@ public class CommonProxy
|
||||||
GameRegistry.registerTileEntity(TileEntityLaserAmplifier.class, "LaserAmplifier");
|
GameRegistry.registerTileEntity(TileEntityLaserAmplifier.class, "LaserAmplifier");
|
||||||
GameRegistry.registerTileEntity(TileEntityLaserTractorBeam.class, "LaserTractorBeam");
|
GameRegistry.registerTileEntity(TileEntityLaserTractorBeam.class, "LaserTractorBeam");
|
||||||
GameRegistry.registerTileEntity(TileEntityAmbientAccumulator.class, "AmbientAccumulator");
|
GameRegistry.registerTileEntity(TileEntityAmbientAccumulator.class, "AmbientAccumulator");
|
||||||
|
GameRegistry.registerTileEntity(TileEntityGasCentrifuge.class, "GasCentrifuge");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -268,6 +270,7 @@ public class CommonProxy
|
||||||
usage.fluidicPlenisherUsage = Mekanism.configuration.get("usage", "FluidicPlenisherUsage", 100D).getDouble(100D);
|
usage.fluidicPlenisherUsage = Mekanism.configuration.get("usage", "FluidicPlenisherUsage", 100D).getDouble(100D);
|
||||||
usage.laserUsage = Mekanism.configuration.get("usage", "LaserUsage", 5000D).getDouble(5000D);
|
usage.laserUsage = Mekanism.configuration.get("usage", "LaserUsage", 5000D).getDouble(5000D);
|
||||||
usage.salinationPlantWaterUsage = Mekanism.configuration.get("usage", "SalinationPlantSpeed", 40.0, "Millibuckets of water turned into brine by the plant per tick", 1.0, 9000.0).getDouble();
|
usage.salinationPlantWaterUsage = Mekanism.configuration.get("usage", "SalinationPlantSpeed", 40.0, "Millibuckets of water turned into brine by the plant per tick", 1.0, 9000.0).getDouble();
|
||||||
|
usage.gasCentrifugeUsage = Mekanism.configuration.get("usage", "GasCentrifugeUsage", 100D).getDouble(100D);
|
||||||
|
|
||||||
if(Mekanism.configuration.hasChanged())
|
if(Mekanism.configuration.hasChanged())
|
||||||
{
|
{
|
||||||
|
|
|
@ -744,6 +744,9 @@ public class Mekanism
|
||||||
60
|
60
|
||||||
);
|
);
|
||||||
|
|
||||||
|
RecipeHandler.addCentrifugeRecipe(new GasStack(GasRegistry.getGas("hydrogen"), 10), new GasStack(GasRegistry.getGas("deuterium"), 1));
|
||||||
|
RecipeHandler.addCentrifugeRecipe(new GasStack(GasRegistry.getGas("deuterium"), 10), new GasStack(GasRegistry.getGas("tritium"), 1));
|
||||||
|
|
||||||
//Infuse objects
|
//Infuse objects
|
||||||
InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.BioFuel), new InfuseObject(InfuseRegistry.get("BIO"), 5));
|
InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.BioFuel), new InfuseObject(InfuseRegistry.get("BIO"), 5));
|
||||||
InfuseRegistry.registerInfuseObject(new ItemStack(Items.coal, 1, 0), new InfuseObject(InfuseRegistry.get("CARBON"), 10));
|
InfuseRegistry.registerInfuseObject(new ItemStack(Items.coal, 1, 0), new InfuseObject(InfuseRegistry.get("CARBON"), 10));
|
||||||
|
|
|
@ -53,6 +53,7 @@ import mekanism.common.tile.TileEntityEnrichmentChamber;
|
||||||
import mekanism.common.tile.TileEntityEntangledBlock;
|
import mekanism.common.tile.TileEntityEntangledBlock;
|
||||||
import mekanism.common.tile.TileEntityFactory;
|
import mekanism.common.tile.TileEntityFactory;
|
||||||
import mekanism.common.tile.TileEntityFluidicPlenisher;
|
import mekanism.common.tile.TileEntityFluidicPlenisher;
|
||||||
|
import mekanism.common.tile.TileEntityGasCentrifuge;
|
||||||
import mekanism.common.tile.TileEntityLaser;
|
import mekanism.common.tile.TileEntityLaser;
|
||||||
import mekanism.common.tile.TileEntityLaserAmplifier;
|
import mekanism.common.tile.TileEntityLaserAmplifier;
|
||||||
import mekanism.common.tile.TileEntityLaserTractorBeam;
|
import mekanism.common.tile.TileEntityLaserTractorBeam;
|
||||||
|
@ -205,6 +206,7 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
||||||
case MACHINE_BLOCK_3:
|
case MACHINE_BLOCK_3:
|
||||||
icons[0][0] = register.registerIcon("mekanism:AmbientAccumulator");
|
icons[0][0] = register.registerIcon("mekanism:AmbientAccumulator");
|
||||||
icons[1][0] = register.registerIcon("mekanism:SteelCasing");
|
icons[1][0] = register.registerIcon("mekanism:SteelCasing");
|
||||||
|
icons[2][0] = register.registerIcon("mekanism:GasCentrifuge");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1055,7 +1057,8 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
||||||
LASER_AMPLIFIER(MachineBlock.MACHINE_BLOCK_2, 14, "LaserAmplifier", 44, TileEntityLaserAmplifier.class, false, true, false),
|
LASER_AMPLIFIER(MachineBlock.MACHINE_BLOCK_2, 14, "LaserAmplifier", 44, TileEntityLaserAmplifier.class, false, true, false),
|
||||||
LASER_TRACTOR_BEAM(MachineBlock.MACHINE_BLOCK_2, 15, "LaserTractorBeam", 45, TileEntityLaserTractorBeam.class, false, true, false),
|
LASER_TRACTOR_BEAM(MachineBlock.MACHINE_BLOCK_2, 15, "LaserTractorBeam", 45, TileEntityLaserTractorBeam.class, false, true, false),
|
||||||
AMBIENT_ACCUMULATOR(MachineBlock.MACHINE_BLOCK_3, 0, "AmbientAccumulator", 46, TileEntityAmbientAccumulator.class, true, false, false),
|
AMBIENT_ACCUMULATOR(MachineBlock.MACHINE_BLOCK_3, 0, "AmbientAccumulator", 46, TileEntityAmbientAccumulator.class, true, false, false),
|
||||||
ENTANGLED_BLOCK(MachineBlock.MACHINE_BLOCK_3, 1, "EntangledBlock", 47, TileEntityEntangledBlock.class, true, false, false);
|
ENTANGLED_BLOCK(MachineBlock.MACHINE_BLOCK_3, 1, "EntangledBlock", 47, TileEntityEntangledBlock.class, true, false, false),
|
||||||
|
GAS_CENTRIFUGE(MachineBlock.MACHINE_BLOCK_3, 2, "GasCentrifuge", 48, TileEntityGasCentrifuge.class, true, false, false);
|
||||||
|
|
||||||
public MachineBlock typeBlock;
|
public MachineBlock typeBlock;
|
||||||
public int meta;
|
public int meta;
|
||||||
|
@ -1186,6 +1189,8 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
||||||
return 0;
|
return 0;
|
||||||
case ENTANGLED_BLOCK:
|
case ENTANGLED_BLOCK:
|
||||||
return 0;
|
return 0;
|
||||||
|
case GAS_CENTRIFUGE:
|
||||||
|
return 100;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
|
||||||
dataStream.writeDouble(usage.seismicVibratorUsage);
|
dataStream.writeDouble(usage.seismicVibratorUsage);
|
||||||
dataStream.writeDouble(usage.fluidicPlenisherUsage);
|
dataStream.writeDouble(usage.fluidicPlenisherUsage);
|
||||||
dataStream.writeDouble(usage.salinationPlantWaterUsage);
|
dataStream.writeDouble(usage.salinationPlantWaterUsage);
|
||||||
|
dataStream.writeDouble(usage.gasCentrifugeUsage);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for(IModule module : Mekanism.modulesLoaded)
|
for(IModule module : Mekanism.modulesLoaded)
|
||||||
|
@ -132,6 +133,7 @@ public class PacketConfigSync implements IMessageHandler<ConfigSyncMessage, IMes
|
||||||
usage.seismicVibratorUsage = dataStream.readDouble();
|
usage.seismicVibratorUsage = dataStream.readDouble();
|
||||||
usage.fluidicPlenisherUsage = dataStream.readDouble();
|
usage.fluidicPlenisherUsage = dataStream.readDouble();
|
||||||
usage.salinationPlantWaterUsage = dataStream.readDouble();
|
usage.salinationPlantWaterUsage = dataStream.readDouble();
|
||||||
|
usage.gasCentrifugeUsage = dataStream.readDouble();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for(IModule module : Mekanism.modulesLoaded)
|
for(IModule module : Mekanism.modulesLoaded)
|
||||||
|
|
|
@ -26,6 +26,7 @@ import mekanism.common.recipe.machines.CrusherRecipe;
|
||||||
import mekanism.common.recipe.machines.CrystallizerRecipe;
|
import mekanism.common.recipe.machines.CrystallizerRecipe;
|
||||||
import mekanism.common.recipe.machines.DissolutionRecipe;
|
import mekanism.common.recipe.machines.DissolutionRecipe;
|
||||||
import mekanism.common.recipe.machines.EnrichmentRecipe;
|
import mekanism.common.recipe.machines.EnrichmentRecipe;
|
||||||
|
import mekanism.common.recipe.machines.GasCentrifugeRecipe;
|
||||||
import mekanism.common.recipe.machines.InjectionRecipe;
|
import mekanism.common.recipe.machines.InjectionRecipe;
|
||||||
import mekanism.common.recipe.machines.MachineRecipe;
|
import mekanism.common.recipe.machines.MachineRecipe;
|
||||||
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
|
import mekanism.common.recipe.machines.MetallurgicInfuserRecipe;
|
||||||
|
@ -230,6 +231,11 @@ public final class RecipeHandler
|
||||||
addRecipe(Recipe.AMBIENT_ACCUMULATOR, new AmbientGasRecipe(dimensionID, ambientGasName));
|
addRecipe(Recipe.AMBIENT_ACCUMULATOR, new AmbientGasRecipe(dimensionID, ambientGasName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void addCentrifugeRecipe(GasStack inputGas, GasStack outputGas)
|
||||||
|
{
|
||||||
|
addRecipe(Recipe.GAS_CENTRIFUGE, new GasCentrifugeRecipe(inputGas, outputGas));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the Metallurgic Infuser Recipe for the InfusionInput in the parameters.
|
* Gets the Metallurgic Infuser Recipe for the InfusionInput in the parameters.
|
||||||
* @param input - input Infusion
|
* @param input - input Infusion
|
||||||
|
@ -338,6 +344,19 @@ public final class RecipeHandler
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static GasCentrifugeRecipe getCentrifugeRecipe(GasInput input)
|
||||||
|
{
|
||||||
|
if(input.isValid())
|
||||||
|
{
|
||||||
|
HashMap<GasInput, GasCentrifugeRecipe> recipes = Recipe.GAS_CENTRIFUGE.get();
|
||||||
|
|
||||||
|
GasCentrifugeRecipe recipe = recipes.get(input);
|
||||||
|
return recipe == null ? null : recipe.copy();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ChanceMachineRecipe of the ItemStackInput in the parameters, using the map in the parameters.
|
* Gets the ChanceMachineRecipe of the ItemStackInput in the parameters, using the map in the parameters.
|
||||||
* @param input - ItemStackInput
|
* @param input - ItemStackInput
|
||||||
|
@ -499,7 +518,8 @@ public final class RecipeHandler
|
||||||
CHEMICAL_WASHER(new HashMap<GasInput, WasherRecipe>()),
|
CHEMICAL_WASHER(new HashMap<GasInput, WasherRecipe>()),
|
||||||
CHEMICAL_CRYSTALLIZER(new HashMap<GasInput, CrystallizerRecipe>()),
|
CHEMICAL_CRYSTALLIZER(new HashMap<GasInput, CrystallizerRecipe>()),
|
||||||
PRESSURIZED_REACTION_CHAMBER(new HashMap<PressurizedInput, PressurizedRecipe>()),
|
PRESSURIZED_REACTION_CHAMBER(new HashMap<PressurizedInput, PressurizedRecipe>()),
|
||||||
AMBIENT_ACCUMULATOR(new HashMap<IntegerInput, AmbientGasRecipe>());
|
AMBIENT_ACCUMULATOR(new HashMap<IntegerInput, AmbientGasRecipe>()),
|
||||||
|
GAS_CENTRIFUGE(new HashMap<GasInput, GasCentrifugeRecipe>());
|
||||||
|
|
||||||
private HashMap recipes;
|
private HashMap recipes;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package mekanism.common.recipe.machines;
|
||||||
|
|
||||||
|
import mekanism.api.gas.GasStack;
|
||||||
|
import mekanism.api.gas.GasTank;
|
||||||
|
import mekanism.common.recipe.inputs.GasInput;
|
||||||
|
import mekanism.common.recipe.outputs.GasOutput;
|
||||||
|
|
||||||
|
public class GasCentrifugeRecipe extends MachineRecipe<GasInput, GasOutput, GasCentrifugeRecipe>
|
||||||
|
{
|
||||||
|
public GasCentrifugeRecipe(GasStack input, GasStack output)
|
||||||
|
{
|
||||||
|
super(new GasInput(input), new GasOutput(output));
|
||||||
|
}
|
||||||
|
|
||||||
|
public GasCentrifugeRecipe(GasInput input, GasOutput output)
|
||||||
|
{
|
||||||
|
super(input, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GasCentrifugeRecipe copy()
|
||||||
|
{
|
||||||
|
return new GasCentrifugeRecipe(getInput(), getOutput());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canOperate(GasTank inputTank, GasTank outputTank)
|
||||||
|
{
|
||||||
|
return getInput().useGas(inputTank, false) && getOutput().applyOutputs(outputTank, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void operate(GasTank inputTank, GasTank outputTank)
|
||||||
|
{
|
||||||
|
if(getInput().useGas(inputTank, true))
|
||||||
|
{
|
||||||
|
getOutput().applyOutputs(outputTank, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
230
src/main/java/mekanism/common/tile/TileEntityGasCentrifuge.java
Normal file
230
src/main/java/mekanism/common/tile/TileEntityGasCentrifuge.java
Normal file
|
@ -0,0 +1,230 @@
|
||||||
|
package mekanism.common.tile;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import mekanism.api.Coord4D;
|
||||||
|
import mekanism.api.MekanismConfig.usage;
|
||||||
|
import mekanism.api.Range4D;
|
||||||
|
import mekanism.api.gas.Gas;
|
||||||
|
import mekanism.api.gas.GasStack;
|
||||||
|
import mekanism.api.gas.GasTank;
|
||||||
|
import mekanism.api.gas.GasTransmission;
|
||||||
|
import mekanism.api.gas.IGasHandler;
|
||||||
|
import mekanism.api.gas.ITubeConnection;
|
||||||
|
import mekanism.common.Mekanism;
|
||||||
|
import mekanism.common.base.IRedstoneControl.RedstoneControl;
|
||||||
|
import mekanism.common.block.BlockMachine.MachineType;
|
||||||
|
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||||
|
import mekanism.common.recipe.RecipeHandler;
|
||||||
|
import mekanism.common.recipe.inputs.GasInput;
|
||||||
|
import mekanism.common.recipe.machines.GasCentrifugeRecipe;
|
||||||
|
import mekanism.common.util.ChargeUtils;
|
||||||
|
import mekanism.common.util.MekanismUtils;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
public class TileEntityGasCentrifuge extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection
|
||||||
|
{
|
||||||
|
public GasTank inputTank = new GasTank(MAX_GAS);
|
||||||
|
public GasTank outputTank = new GasTank(MAX_GAS);
|
||||||
|
|
||||||
|
public static final int MAX_GAS = 10000;
|
||||||
|
|
||||||
|
public int updateDelay;
|
||||||
|
|
||||||
|
public int gasOutput = 16;
|
||||||
|
|
||||||
|
public boolean isActive;
|
||||||
|
|
||||||
|
public boolean clientActive;
|
||||||
|
|
||||||
|
public double prevEnergy;
|
||||||
|
|
||||||
|
public double energyUsage = usage.gasCentrifugeUsage;
|
||||||
|
|
||||||
|
public GasCentrifugeRecipe cachedRecipe;
|
||||||
|
|
||||||
|
public RedstoneControl controlType = RedstoneControl.DISABLED;
|
||||||
|
|
||||||
|
public TileEntityGasCentrifuge()
|
||||||
|
{
|
||||||
|
super("machine.centrifuge", "GasCentrifuge", MachineType.GAS_CENTRIFUGE.baseEnergy);
|
||||||
|
inventory = new ItemStack[3];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onUpdate()
|
||||||
|
{
|
||||||
|
if(worldObj.isRemote && updateDelay > 0)
|
||||||
|
{
|
||||||
|
updateDelay--;
|
||||||
|
|
||||||
|
if(updateDelay == 0 && clientActive != isActive)
|
||||||
|
{
|
||||||
|
isActive = clientActive;
|
||||||
|
MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!worldObj.isRemote)
|
||||||
|
{
|
||||||
|
GasCentrifugeRecipe recipe = getRecipe();
|
||||||
|
if(updateDelay > 0)
|
||||||
|
{
|
||||||
|
updateDelay--;
|
||||||
|
|
||||||
|
if(updateDelay == 0 && clientActive != isActive)
|
||||||
|
{
|
||||||
|
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ChargeUtils.discharge(1, this);
|
||||||
|
|
||||||
|
if(inventory[2] != null && inputTank.getGas() != null)
|
||||||
|
{
|
||||||
|
inputTank.draw(GasTransmission.addGas(inventory[2], inputTank.getGas()), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(canOperate(recipe) && getEnergy() >= energyUsage && MekanismUtils.canFunction(this))
|
||||||
|
{
|
||||||
|
setActive(true);
|
||||||
|
setEnergy(getEnergy() - energyUsage);
|
||||||
|
|
||||||
|
operate(recipe);
|
||||||
|
markDirty();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(prevEnergy >= getEnergy())
|
||||||
|
{
|
||||||
|
setActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
prevEnergy = getEnergy();
|
||||||
|
|
||||||
|
if(outputTank.getGas() != null)
|
||||||
|
{
|
||||||
|
GasStack toSend = new GasStack(outputTank.getGas().getGas(), Math.min(outputTank.getStored(), gasOutput));
|
||||||
|
|
||||||
|
for(ForgeDirection side : new ForgeDirection[]{ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.WEST, ForgeDirection.EAST})
|
||||||
|
{
|
||||||
|
TileEntity tileEntity = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj);
|
||||||
|
|
||||||
|
if(tileEntity instanceof IGasHandler)
|
||||||
|
{
|
||||||
|
if(((IGasHandler)tileEntity).canReceiveGas(side.getOpposite(), outputTank.getGas().getGas()))
|
||||||
|
{
|
||||||
|
outputTank.draw(((IGasHandler)tileEntity).receiveGas(side.getOpposite(), toSend, true), true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public GasCentrifugeRecipe getRecipe()
|
||||||
|
{
|
||||||
|
GasInput input = getInput();
|
||||||
|
if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput()))
|
||||||
|
{
|
||||||
|
cachedRecipe = RecipeHandler.getCentrifugeRecipe(getInput());
|
||||||
|
}
|
||||||
|
return cachedRecipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GasInput getInput()
|
||||||
|
{
|
||||||
|
return new GasInput(inputTank.getGas());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canOperate(GasCentrifugeRecipe recipe)
|
||||||
|
{
|
||||||
|
return recipe != null && recipe.canOperate(inputTank, outputTank);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void operate(GasCentrifugeRecipe recipe)
|
||||||
|
{
|
||||||
|
recipe.operate(inputTank, outputTank);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setActive(boolean active)
|
||||||
|
{
|
||||||
|
isActive = active;
|
||||||
|
|
||||||
|
if(clientActive != active && updateDelay == 0)
|
||||||
|
{
|
||||||
|
Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this)));
|
||||||
|
|
||||||
|
updateDelay = 10;
|
||||||
|
clientActive = active;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getActive()
|
||||||
|
{
|
||||||
|
return isActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean renderUpdate()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean lightUpdate()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GasTank getTank(ForgeDirection side)
|
||||||
|
{
|
||||||
|
return side == ForgeDirection.UP ? inputTank : outputTank;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer)
|
||||||
|
{
|
||||||
|
if(canReceiveGas(side, stack != null ? stack.getGas() : null))
|
||||||
|
{
|
||||||
|
return getTank(side).receive(stack, doTransfer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer)
|
||||||
|
{
|
||||||
|
if(canDrawGas(side, null))
|
||||||
|
{
|
||||||
|
return getTank(side).draw(amount, doTransfer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canDrawGas(ForgeDirection side, Gas type)
|
||||||
|
{
|
||||||
|
return getTank(side) == outputTank ? getTank(side).canDraw(type) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canReceiveGas(ForgeDirection side, Gas type)
|
||||||
|
{
|
||||||
|
return getTank(side) != null && getTank(side) != outputTank ? getTank(side).canReceive(type) : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canTubeConnect(ForgeDirection side)
|
||||||
|
{
|
||||||
|
return side != ForgeDirection.DOWN;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue