Finished off new system of sustained data

This commit is contained in:
Aidan C. Brady 2014-07-26 18:44:24 -04:00
parent 94c3a6aa60
commit ab34edc46a
9 changed files with 165 additions and 198 deletions

View file

@ -1072,121 +1072,6 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
factoryItem.setRecipeType(((TileEntityFactory)tileEntity).recipeType, itemStack);
}
if(tileEntity instanceof TileEntityChemicalOxidizer)
{
TileEntityChemicalOxidizer oxidizer = (TileEntityChemicalOxidizer)tileEntity;
if(oxidizer.gasTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("gasTank", oxidizer.gasTank.getGas().write(new NBTTagCompound()));
}
}
if(tileEntity instanceof TileEntityChemicalInfuser)
{
TileEntityChemicalInfuser infuser = (TileEntityChemicalInfuser)tileEntity;
if(infuser.leftTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("leftTank", infuser.leftTank.getGas().write(new NBTTagCompound()));
}
if(infuser.rightTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("rightTank", infuser.rightTank.getGas().write(new NBTTagCompound()));
}
if(infuser.centerTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("centerTank", infuser.centerTank.getGas().write(new NBTTagCompound()));
}
}
if(tileEntity instanceof TileEntityChemicalDissolutionChamber)
{
TileEntityChemicalDissolutionChamber chamber = (TileEntityChemicalDissolutionChamber)tileEntity;
if(chamber.injectTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("injectTank", chamber.injectTank.getGas().write(new NBTTagCompound()));
}
if(chamber.outputTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("outputTank", chamber.outputTank.getGas().write(new NBTTagCompound()));
}
}
if(tileEntity instanceof TileEntityChemicalWasher)
{
TileEntityChemicalWasher washer = (TileEntityChemicalWasher)tileEntity;
if(washer.fluidTank.getFluid() != null)
{
itemStack.stackTagCompound.setTag("fluidTank", washer.fluidTank.getFluid().writeToNBT(new NBTTagCompound()));
}
if(washer.inputTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("inputTank", washer.inputTank.getGas().write(new NBTTagCompound()));
}
if(washer.outputTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("outputTank", washer.outputTank.getGas().write(new NBTTagCompound()));
}
}
if(tileEntity instanceof TileEntityChemicalCrystallizer)
{
TileEntityChemicalCrystallizer crystallizer = (TileEntityChemicalCrystallizer)tileEntity;
if(crystallizer.inputTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("inputTank", crystallizer.inputTank.getGas().write(new NBTTagCompound()));
}
}
if(tileEntity instanceof TileEntityElectrolyticSeparator)
{
TileEntityElectrolyticSeparator separator = (TileEntityElectrolyticSeparator)tileEntity;
if(separator.fluidTank.getFluid() != null)
{
itemStack.stackTagCompound.setTag("fluidTank", separator.fluidTank.getFluid().writeToNBT(new NBTTagCompound()));
}
if(separator.leftTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("leftTank", separator.leftTank.getGas().write(new NBTTagCompound()));
}
if(separator.rightTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("rightTank", separator.rightTank.getGas().write(new NBTTagCompound()));
}
}
if(tileEntity instanceof TileEntityPRC)
{
TileEntityPRC prc = (TileEntityPRC)tileEntity;
if(prc.inputFluidTank.getFluid() != null)
{
itemStack.stackTagCompound.setTag("inputFluidTank", prc.inputFluidTank.getFluid().writeToNBT(new NBTTagCompound()));
}
if(prc.inputGasTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("inputGasTank", prc.inputGasTank.getGas().write(new NBTTagCompound()));
}
if(prc.outputGasTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("outputGasTank", prc.outputGasTank.getGas().write(new NBTTagCompound()));
}
}
return itemStack;
}

View file

@ -307,71 +307,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
((TileEntityElectricChest)tileEntity).password = getPassword(stack);
}
if(tileEntity instanceof TileEntityChemicalOxidizer)
{
if(stack.stackTagCompound != null)
{
((TileEntityChemicalOxidizer)tileEntity).gasTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("gasTank")));
}
}
if(tileEntity instanceof TileEntityChemicalInfuser)
{
if(stack.stackTagCompound != null)
{
((TileEntityChemicalInfuser)tileEntity).leftTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("leftTank")));
((TileEntityChemicalInfuser)tileEntity).rightTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("rightTank")));
((TileEntityChemicalInfuser)tileEntity).centerTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("centerTank")));
}
}
if(tileEntity instanceof TileEntityChemicalDissolutionChamber)
{
if(stack.stackTagCompound != null)
{
((TileEntityChemicalDissolutionChamber)tileEntity).injectTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("injectTank")));
((TileEntityChemicalDissolutionChamber)tileEntity).outputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("outputTank")));
}
}
if(tileEntity instanceof TileEntityChemicalWasher)
{
if(stack.stackTagCompound != null)
{
((TileEntityChemicalWasher)tileEntity).fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(stack.stackTagCompound.getCompoundTag("fluidTank")));
((TileEntityChemicalWasher)tileEntity).inputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("inputTank")));
((TileEntityChemicalWasher)tileEntity).outputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("outputTank")));
}
}
if(tileEntity instanceof TileEntityChemicalCrystallizer)
{
if(stack.stackTagCompound != null)
{
((TileEntityChemicalCrystallizer)tileEntity).inputTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("inputTank")));
}
}
if(tileEntity instanceof TileEntityElectrolyticSeparator)
{
if(stack.stackTagCompound != null)
{
((TileEntityElectrolyticSeparator)tileEntity).fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(stack.stackTagCompound.getCompoundTag("fluidTank")));
((TileEntityElectrolyticSeparator)tileEntity).leftTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("leftTank")));
((TileEntityElectrolyticSeparator)tileEntity).rightTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("rightTank")));
}
}
if(tileEntity instanceof TileEntityPRC)
{
if(stack.stackTagCompound != null)
{
((TileEntityPRC)tileEntity).inputFluidTank.setFluid(FluidStack.loadFluidStackFromNBT(stack.stackTagCompound.getCompoundTag("inputFluidTank")));
((TileEntityPRC)tileEntity).inputGasTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("inputGasTank")));
((TileEntityPRC)tileEntity).outputGasTank.setGas(GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("outputGasTank")));
}
}
((ISustainedInventory)tileEntity).setInventory(getInventory(stack));
if(tileEntity instanceof TileEntityElectricBlock)

View file

@ -19,6 +19,7 @@ import mekanism.common.IActiveState;
import mekanism.common.IEjector;
import mekanism.common.IInvConfiguration;
import mekanism.common.IRedstoneControl;
import mekanism.common.ISustainedData;
import mekanism.common.IUpgradeTile;
import mekanism.common.Mekanism;
import mekanism.common.SideData;
@ -38,7 +39,7 @@ import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
public class TileEntityChemicalCrystallizer extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound, IInvConfiguration, IUpgradeTile
public class TileEntityChemicalCrystallizer extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound, IInvConfiguration, IUpgradeTile, ISustainedData
{
public static final int MAX_GAS = 10000;
public static final int MAX_FLUID = 10000;
@ -539,4 +540,19 @@ public class TileEntityChemicalCrystallizer extends TileEntityElectricBlock impl
{
return upgradeComponent;
}
@Override
public void writeSustainedData(ItemStack itemStack)
{
if(inputTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("inputTank", inputTank.getGas().write(new NBTTagCompound()));
}
}
@Override
public void readSustainedData(ItemStack itemStack)
{
inputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("inputTank")));
}
}

View file

@ -16,6 +16,7 @@ import mekanism.api.gas.ITubeConnection;
import mekanism.client.sound.IHasSound;
import mekanism.common.IActiveState;
import mekanism.common.IRedstoneControl;
import mekanism.common.ISustainedData;
import mekanism.common.IUpgradeTile;
import mekanism.common.Mekanism;
import mekanism.common.block.BlockMachine.MachineType;
@ -31,7 +32,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBlock implements IActiveState, ITubeConnection, IRedstoneControl, IHasSound, IGasHandler, IUpgradeTile
public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBlock implements IActiveState, ITubeConnection, IRedstoneControl, IHasSound, IGasHandler, IUpgradeTile, ISustainedData
{
public GasTank injectTank = new GasTank(MAX_GAS);
public GasTank outputTank = new GasTank(MAX_GAS);
@ -471,4 +472,25 @@ public class TileEntityChemicalDissolutionChamber extends TileEntityElectricBloc
{
return upgradeComponent;
}
@Override
public void writeSustainedData(ItemStack itemStack)
{
if(injectTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("injectTank", injectTank.getGas().write(new NBTTagCompound()));
}
if(outputTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("outputTank", outputTank.getGas().write(new NBTTagCompound()));
}
}
@Override
public void readSustainedData(ItemStack itemStack)
{
injectTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("injectTank")));
outputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("outputTank")));
}
}

View file

@ -16,6 +16,7 @@ import mekanism.api.gas.ITubeConnection;
import mekanism.client.sound.IHasSound;
import mekanism.common.IActiveState;
import mekanism.common.IRedstoneControl;
import mekanism.common.ISustainedData;
import mekanism.common.Mekanism;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
@ -30,7 +31,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityChemicalInfuser extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound
public class TileEntityChemicalInfuser extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound, ISustainedData
{
public GasTank leftTank = new GasTank(MAX_GAS);
public GasTank rightTank = new GasTank(MAX_GAS);
@ -476,4 +477,31 @@ public class TileEntityChemicalInfuser extends TileEntityElectricBlock implement
{
return 1;
}
@Override
public void writeSustainedData(ItemStack itemStack)
{
if(leftTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("leftTank", leftTank.getGas().write(new NBTTagCompound()));
}
if(rightTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("rightTank", rightTank.getGas().write(new NBTTagCompound()));
}
if(centerTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("centerTank", centerTank.getGas().write(new NBTTagCompound()));
}
}
@Override
public void readSustainedData(ItemStack itemStack)
{
leftTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("leftTank")));
rightTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("rightTank")));
centerTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("centerTank")));
}
}

View file

@ -15,6 +15,7 @@ import mekanism.api.gas.ITubeConnection;
import mekanism.client.sound.IHasSound;
import mekanism.common.IActiveState;
import mekanism.common.IRedstoneControl;
import mekanism.common.ISustainedData;
import mekanism.common.IUpgradeTile;
import mekanism.common.Mekanism;
import mekanism.common.block.BlockMachine.MachineType;
@ -30,7 +31,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implements IActiveState, ITubeConnection, IRedstoneControl, IHasSound, IUpgradeTile
public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implements IActiveState, ITubeConnection, IRedstoneControl, IHasSound, IUpgradeTile, ISustainedData
{
public GasTank gasTank = new GasTank(MAX_GAS);
@ -397,4 +398,19 @@ public class TileEntityChemicalOxidizer extends TileEntityElectricBlock implemen
{
return upgradeComponent;
}
@Override
public void writeSustainedData(ItemStack itemStack)
{
if(gasTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("gasTank", gasTank.getGas().write(new NBTTagCompound()));
}
}
@Override
public void readSustainedData(ItemStack itemStack)
{
gasTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("gasTank")));
}
}

View file

@ -16,6 +16,7 @@ import mekanism.api.gas.ITubeConnection;
import mekanism.client.sound.IHasSound;
import mekanism.common.IActiveState;
import mekanism.common.IRedstoneControl;
import mekanism.common.ISustainedData;
import mekanism.common.Mekanism;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
@ -40,7 +41,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidContainerItem;
import net.minecraftforge.fluids.IFluidHandler;
public class TileEntityChemicalWasher extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound, IFluidHandler
public class TileEntityChemicalWasher extends TileEntityElectricBlock implements IActiveState, IGasHandler, ITubeConnection, IRedstoneControl, IHasSound, IFluidHandler, ISustainedData
{
public FluidTank fluidTank = new FluidTank(MAX_FLUID);
public GasTank inputTank = new GasTank(MAX_GAS);
@ -587,4 +588,31 @@ public class TileEntityChemicalWasher extends TileEntityElectricBlock implements
return PipeUtils.EMPTY;
}
@Override
public void writeSustainedData(ItemStack itemStack)
{
if(fluidTank.getFluid() != null)
{
itemStack.stackTagCompound.setTag("fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound()));
}
if(inputTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("inputTank", inputTank.getGas().write(new NBTTagCompound()));
}
if(outputTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("outputTank", outputTank.getGas().write(new NBTTagCompound()));
}
}
@Override
public void readSustainedData(ItemStack itemStack)
{
fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("fluidTank")));
inputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("inputTank")));
outputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("outputTank")));
}
}

View file

@ -14,7 +14,7 @@ import mekanism.api.gas.GasTransmission;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.IGasItem;
import mekanism.api.gas.ITubeConnection;
import mekanism.common.ISustainedTank;
import mekanism.common.ISustainedData;
import mekanism.common.Mekanism;
import mekanism.common.block.BlockMachine.MachineType;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
@ -43,7 +43,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IFluidHandler, IPeripheral, ITubeConnection, ISustainedTank, IGasHandler
public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IFluidHandler, IPeripheral, ITubeConnection, ISustainedData, IGasHandler
{
/** This separator's water slot. */
public FluidTank fluidTank = new FluidTank(24000);
@ -575,21 +575,30 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp
}
@Override
public void setFluidStack(FluidStack fluidStack, Object... data)
public void writeSustainedData(ItemStack itemStack)
{
fluidTank.setFluid(fluidStack);
if(fluidTank.getFluid() != null)
{
itemStack.stackTagCompound.setTag("fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound()));
}
if(leftTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("leftTank", leftTank.getGas().write(new NBTTagCompound()));
}
if(rightTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("rightTank", rightTank.getGas().write(new NBTTagCompound()));
}
}
@Override
public FluidStack getFluidStack(Object... data)
public void readSustainedData(ItemStack itemStack)
{
return fluidTank.getFluid();
}
@Override
public boolean hasTank(Object... data)
{
return true;
fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("fluidTank")));
leftTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("leftTank")));
rightTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("rightTank")));
}
@Override

View file

@ -15,6 +15,7 @@ import mekanism.api.gas.GasStack;
import mekanism.api.gas.GasTank;
import mekanism.api.gas.IGasHandler;
import mekanism.api.gas.ITubeConnection;
import mekanism.common.ISustainedData;
import mekanism.common.Mekanism;
import mekanism.common.SideData;
import mekanism.common.block.BlockMachine.MachineType;
@ -41,7 +42,7 @@ import cpw.mods.fml.common.Optional.Method;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandler, IGasHandler, ITubeConnection
public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandler, IGasHandler, ITubeConnection, ISustainedData
{
public FluidTank inputFluidTank = new FluidTank(10000);
public GasTank inputGasTank = new GasTank(10000);
@ -438,4 +439,31 @@ public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandl
{
return side == MekanismUtils.getLeft(facing) || side == MekanismUtils.getRight(facing);
}
@Override
public void writeSustainedData(ItemStack itemStack)
{
if(inputFluidTank.getFluid() != null)
{
itemStack.stackTagCompound.setTag("inputFluidTank", inputFluidTank.getFluid().writeToNBT(new NBTTagCompound()));
}
if(inputGasTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("inputGasTank", inputGasTank.getGas().write(new NBTTagCompound()));
}
if(outputGasTank.getGas() != null)
{
itemStack.stackTagCompound.setTag("outputGasTank", outputGasTank.getGas().write(new NBTTagCompound()));
}
}
@Override
public void readSustainedData(ItemStack itemStack)
{
inputFluidTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("inputFluidTank")));
inputGasTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("inputGasTank")));
outputGasTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("outputGasTank")));
}
}