mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-20 12:09:45 +00:00
Started work on a new system of managing sustained data
This commit is contained in:
1 parent
7ac7fbc5cc
commit
94c3a6aa60
6 files changed
+155
-153
No files matched your search
@@ -0,0 +1,10 @@
|
||||
package mekanism.common;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public interface ISustainedData
|
||||
{
|
||||
public void writeSustainedData(ItemStack itemStack);
|
||||
|
||||
public void readSustainedData(ItemStack itemStack);
|
||||
}
|
||||
@@ -14,12 +14,12 @@ import mekanism.common.IFactory.RecipeType;
|
||||
import mekanism.common.IInvConfiguration;
|
||||
import mekanism.common.IRedstoneControl;
|
||||
import mekanism.common.ISpecialBounds;
|
||||
import mekanism.common.ISustainedData;
|
||||
import mekanism.common.ISustainedInventory;
|
||||
import mekanism.common.ISustainedTank;
|
||||
import mekanism.common.IUpgradeManagement;
|
||||
import mekanism.common.ItemAttacher;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.miner.MinerFilter;
|
||||
import mekanism.common.network.PacketElectricChest.ElectricChestMessage;
|
||||
import mekanism.common.network.PacketElectricChest.ElectricChestPacketType;
|
||||
import mekanism.common.network.PacketLogisticalSorterGui.LogisticalSorterGuiMessage;
|
||||
@@ -1023,66 +1023,10 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
||||
itemStack.stackTagCompound.setByte("config"+i, config.getConfiguration()[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if(tileEntity instanceof TileEntityDigitalMiner)
|
||||
|
||||
if(tileEntity instanceof ISustainedData)
|
||||
{
|
||||
TileEntityDigitalMiner miner = (TileEntityDigitalMiner)tileEntity;
|
||||
|
||||
itemStack.stackTagCompound.setBoolean("hasMinerConfig", true);
|
||||
|
||||
itemStack.stackTagCompound.setInteger("radius", miner.radius);
|
||||
itemStack.stackTagCompound.setInteger("minY", miner.minY);
|
||||
itemStack.stackTagCompound.setInteger("maxY", miner.maxY);
|
||||
itemStack.stackTagCompound.setBoolean("doEject", miner.doEject);
|
||||
itemStack.stackTagCompound.setBoolean("doPull", miner.doPull);
|
||||
itemStack.stackTagCompound.setBoolean("silkTouch", miner.silkTouch);
|
||||
itemStack.stackTagCompound.setBoolean("inverse", miner.inverse);
|
||||
|
||||
if(miner.replaceStack != null)
|
||||
{
|
||||
itemStack.stackTagCompound.setTag("replaceStack", miner.replaceStack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
NBTTagList filterTags = new NBTTagList();
|
||||
|
||||
for(MinerFilter filter : miner.filters)
|
||||
{
|
||||
filterTags.appendTag(filter.write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(filterTags.tagCount() != 0)
|
||||
{
|
||||
itemStack.stackTagCompound.setTag("filters", filterTags);
|
||||
}
|
||||
}
|
||||
|
||||
if(tileEntity instanceof TileEntityLogisticalSorter)
|
||||
{
|
||||
TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)tileEntity;
|
||||
|
||||
itemStack.stackTagCompound.setBoolean("hasSorterConfig", true);
|
||||
|
||||
if(sorter.color != null)
|
||||
{
|
||||
itemStack.stackTagCompound.setInteger("color", TransporterUtils.colors.indexOf(sorter.color));
|
||||
}
|
||||
|
||||
itemStack.stackTagCompound.setBoolean("autoEject", sorter.autoEject);
|
||||
itemStack.stackTagCompound.setBoolean("roundRobin", sorter.roundRobin);
|
||||
|
||||
NBTTagList filterTags = new NBTTagList();
|
||||
|
||||
for(TransporterFilter filter : sorter.filters)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
filter.write(tagCompound);
|
||||
filterTags.appendTag(tagCompound);
|
||||
}
|
||||
|
||||
if(filterTags.tagCount() != 0)
|
||||
{
|
||||
itemStack.stackTagCompound.setTag("filters", filterTags);
|
||||
}
|
||||
((ISustainedData)tileEntity).writeSustainedData(itemStack);
|
||||
}
|
||||
|
||||
if(tileEntity instanceof IRedstoneControl)
|
||||
@@ -1128,16 +1072,6 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
|
||||
factoryItem.setRecipeType(((TileEntityFactory)tileEntity).recipeType, itemStack);
|
||||
}
|
||||
|
||||
if(tileEntity instanceof TileEntityRotaryCondensentrator)
|
||||
{
|
||||
TileEntityRotaryCondensentrator condensentrator = (TileEntityRotaryCondensentrator)tileEntity;
|
||||
|
||||
if(condensentrator.gasTank.getGas() != null)
|
||||
{
|
||||
itemStack.stackTagCompound.setTag("gasStack", condensentrator.gasTank.getGas().write(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
if(tileEntity instanceof TileEntityChemicalOxidizer)
|
||||
{
|
||||
TileEntityChemicalOxidizer oxidizer = (TileEntityChemicalOxidizer)tileEntity;
|
||||
|
||||
@@ -18,6 +18,7 @@ import mekanism.common.IFactory;
|
||||
import mekanism.common.IInvConfiguration;
|
||||
import mekanism.common.IRedstoneControl;
|
||||
import mekanism.common.IRedstoneControl.RedstoneControl;
|
||||
import mekanism.common.ISustainedData;
|
||||
import mekanism.common.ISustainedInventory;
|
||||
import mekanism.common.ISustainedTank;
|
||||
import mekanism.common.IUpgradeManagement;
|
||||
@@ -25,7 +26,6 @@ import mekanism.common.Mekanism;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.integration.IC2ItemManager;
|
||||
import mekanism.common.inventory.InventoryElectricChest;
|
||||
import mekanism.common.miner.MinerFilter;
|
||||
import mekanism.common.network.PacketElectricChest.ElectricChestMessage;
|
||||
import mekanism.common.network.PacketElectricChest.ElectricChestPacketType;
|
||||
import mekanism.common.tile.TileEntityBasicBlock;
|
||||
@@ -34,7 +34,6 @@ import mekanism.common.tile.TileEntityChemicalDissolutionChamber;
|
||||
import mekanism.common.tile.TileEntityChemicalInfuser;
|
||||
import mekanism.common.tile.TileEntityChemicalOxidizer;
|
||||
import mekanism.common.tile.TileEntityChemicalWasher;
|
||||
import mekanism.common.tile.TileEntityDigitalMiner;
|
||||
import mekanism.common.tile.TileEntityElectricBlock;
|
||||
import mekanism.common.tile.TileEntityElectricChest;
|
||||
import mekanism.common.tile.TileEntityElectrolyticSeparator;
|
||||
@@ -270,61 +269,12 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(tileEntity instanceof TileEntityDigitalMiner)
|
||||
|
||||
if(tileEntity instanceof ISustainedData)
|
||||
{
|
||||
TileEntityDigitalMiner miner = (TileEntityDigitalMiner)tileEntity;
|
||||
|
||||
if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasMinerConfig"))
|
||||
if(stack.stackTagCompound != null)
|
||||
{
|
||||
miner.radius = stack.stackTagCompound.getInteger("radius");
|
||||
miner.minY = stack.stackTagCompound.getInteger("minY");
|
||||
miner.maxY = stack.stackTagCompound.getInteger("maxY");
|
||||
miner.doEject = stack.stackTagCompound.getBoolean("doEject");
|
||||
miner.doPull = stack.stackTagCompound.getBoolean("doPull");
|
||||
miner.silkTouch = stack.stackTagCompound.getBoolean("silkTouch");
|
||||
miner.inverse = stack.stackTagCompound.getBoolean("inverse");
|
||||
|
||||
if(stack.stackTagCompound.hasKey("replaceStack"))
|
||||
{
|
||||
miner.replaceStack = ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("replaceStack"));
|
||||
}
|
||||
|
||||
if(stack.stackTagCompound.hasKey("filters"))
|
||||
{
|
||||
NBTTagList tagList = stack.stackTagCompound.getTagList("filters", NBT.TAG_COMPOUND);
|
||||
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
miner.filters.add(MinerFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(tileEntity instanceof TileEntityLogisticalSorter)
|
||||
{
|
||||
TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)tileEntity;
|
||||
|
||||
if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("hasSorterConfig"))
|
||||
{
|
||||
if(stack.stackTagCompound.hasKey("color"))
|
||||
{
|
||||
sorter.color = TransporterUtils.colors.get(stack.stackTagCompound.getInteger("color"));
|
||||
}
|
||||
|
||||
sorter.autoEject = stack.stackTagCompound.getBoolean("autoEject");
|
||||
sorter.roundRobin = stack.stackTagCompound.getBoolean("roundRobin");
|
||||
|
||||
if(stack.stackTagCompound.hasKey("filters"))
|
||||
{
|
||||
NBTTagList tagList = stack.stackTagCompound.getTagList("filters", NBT.TAG_COMPOUND);
|
||||
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
sorter.filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i)));
|
||||
}
|
||||
}
|
||||
((ISustainedData)tileEntity).readSustainedData(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,15 +307,6 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
((TileEntityElectricChest)tileEntity).password = getPassword(stack);
|
||||
}
|
||||
|
||||
if(tileEntity instanceof TileEntityRotaryCondensentrator)
|
||||
{
|
||||
if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("gasStack"))
|
||||
{
|
||||
GasStack gasStack = GasStack.readFromNBT(stack.stackTagCompound.getCompoundTag("gasStack"));
|
||||
((TileEntityRotaryCondensentrator)tileEntity).gasTank.setGas(gasStack);
|
||||
}
|
||||
}
|
||||
|
||||
if(tileEntity instanceof TileEntityChemicalOxidizer)
|
||||
{
|
||||
if(stack.stackTagCompound != null)
|
||||
@@ -878,8 +819,7 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec
|
||||
|
||||
MachineType type = MachineType.get((ItemStack)data[0]);
|
||||
|
||||
return type == MachineType.ELECTRIC_PUMP || type == MachineType.ROTARY_CONDENSENTRATOR
|
||||
|| type == MachineType.PORTABLE_TANK || type == MachineType.FLUIDIC_PLENISHER;
|
||||
return type == MachineType.ELECTRIC_PUMP || type == MachineType.PORTABLE_TANK || type == MachineType.FLUIDIC_PLENISHER;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import mekanism.common.IActiveState;
|
||||
import mekanism.common.IAdvancedBoundingBlock;
|
||||
import mekanism.common.ILogisticalTransporter;
|
||||
import mekanism.common.IRedstoneControl;
|
||||
import mekanism.common.ISustainedData;
|
||||
import mekanism.common.IUpgradeTile;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
@@ -37,7 +38,6 @@ import mekanism.common.util.TransporterUtils;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -56,7 +56,7 @@ import dan200.computercraft.api.peripheral.IComputerAccess;
|
||||
import dan200.computercraft.api.peripheral.IPeripheral;
|
||||
|
||||
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
|
||||
public class TileEntityDigitalMiner extends TileEntityElectricBlock implements IPeripheral, IUpgradeTile, IRedstoneControl, IActiveState, IAdvancedBoundingBlock
|
||||
public class TileEntityDigitalMiner extends TileEntityElectricBlock implements IPeripheral, IUpgradeTile, IRedstoneControl, IActiveState, ISustainedData, IAdvancedBoundingBlock
|
||||
{
|
||||
public static int[] EJECT_INV;
|
||||
|
||||
@@ -1369,4 +1369,65 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
|
||||
{
|
||||
return "tooltip.filterCard.digitalMiner";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSustainedData(ItemStack itemStack)
|
||||
{
|
||||
itemStack.stackTagCompound.setBoolean("hasMinerConfig", true);
|
||||
|
||||
itemStack.stackTagCompound.setInteger("radius", radius);
|
||||
itemStack.stackTagCompound.setInteger("minY", minY);
|
||||
itemStack.stackTagCompound.setInteger("maxY", maxY);
|
||||
itemStack.stackTagCompound.setBoolean("doEject", doEject);
|
||||
itemStack.stackTagCompound.setBoolean("doPull", doPull);
|
||||
itemStack.stackTagCompound.setBoolean("silkTouch", silkTouch);
|
||||
itemStack.stackTagCompound.setBoolean("inverse", inverse);
|
||||
|
||||
if(replaceStack != null)
|
||||
{
|
||||
itemStack.stackTagCompound.setTag("replaceStack", replaceStack.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
NBTTagList filterTags = new NBTTagList();
|
||||
|
||||
for(MinerFilter filter : filters)
|
||||
{
|
||||
filterTags.appendTag(filter.write(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
if(filterTags.tagCount() != 0)
|
||||
{
|
||||
itemStack.stackTagCompound.setTag("filters", filterTags);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.stackTagCompound.hasKey("hasMinerConfig"))
|
||||
{
|
||||
radius = itemStack.stackTagCompound.getInteger("radius");
|
||||
minY = itemStack.stackTagCompound.getInteger("minY");
|
||||
maxY = itemStack.stackTagCompound.getInteger("maxY");
|
||||
doEject = itemStack.stackTagCompound.getBoolean("doEject");
|
||||
doPull = itemStack.stackTagCompound.getBoolean("doPull");
|
||||
silkTouch = itemStack.stackTagCompound.getBoolean("silkTouch");
|
||||
inverse = itemStack.stackTagCompound.getBoolean("inverse");
|
||||
|
||||
if(itemStack.stackTagCompound.hasKey("replaceStack"))
|
||||
{
|
||||
replaceStack = ItemStack.loadItemStackFromNBT(itemStack.stackTagCompound.getCompoundTag("replaceStack"));
|
||||
}
|
||||
|
||||
if(itemStack.stackTagCompound.hasKey("filters"))
|
||||
{
|
||||
NBTTagList tagList = itemStack.stackTagCompound.getTagList("filters", NBT.TAG_COMPOUND);
|
||||
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
filters.add(MinerFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ import mekanism.common.HashList;
|
||||
import mekanism.common.IActiveState;
|
||||
import mekanism.common.ILogisticalTransporter;
|
||||
import mekanism.common.IRedstoneControl;
|
||||
import mekanism.common.ISustainedData;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
@@ -33,7 +34,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntityLogisticalSorter extends TileEntityElectricBlock implements IRedstoneControl, IActiveState, IFilterAccess
|
||||
public class TileEntityLogisticalSorter extends TileEntityElectricBlock implements IRedstoneControl, IActiveState, IFilterAccess, ISustainedData
|
||||
{
|
||||
public HashList<TransporterFilter> filters = new HashList<TransporterFilter>();
|
||||
|
||||
@@ -620,4 +621,57 @@ public class TileEntityLogisticalSorter extends TileEntityElectricBlock implemen
|
||||
{
|
||||
return "tooltip.filterCard.logisticalSorter";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSustainedData(ItemStack itemStack)
|
||||
{
|
||||
itemStack.stackTagCompound.setBoolean("hasSorterConfig", true);
|
||||
|
||||
if(color != null)
|
||||
{
|
||||
itemStack.stackTagCompound.setInteger("color", TransporterUtils.colors.indexOf(color));
|
||||
}
|
||||
|
||||
itemStack.stackTagCompound.setBoolean("autoEject", autoEject);
|
||||
itemStack.stackTagCompound.setBoolean("roundRobin", roundRobin);
|
||||
|
||||
NBTTagList filterTags = new NBTTagList();
|
||||
|
||||
for(TransporterFilter filter : filters)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
filter.write(tagCompound);
|
||||
filterTags.appendTag(tagCompound);
|
||||
}
|
||||
|
||||
if(filterTags.tagCount() != 0)
|
||||
{
|
||||
itemStack.stackTagCompound.setTag("filters", filterTags);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSustainedData(ItemStack itemStack)
|
||||
{
|
||||
if(itemStack.stackTagCompound.hasKey("hasSorterConfig"))
|
||||
{
|
||||
if(itemStack.stackTagCompound.hasKey("color"))
|
||||
{
|
||||
color = TransporterUtils.colors.get(itemStack.stackTagCompound.getInteger("color"));
|
||||
}
|
||||
|
||||
autoEject = itemStack.stackTagCompound.getBoolean("autoEject");
|
||||
roundRobin = itemStack.stackTagCompound.getBoolean("roundRobin");
|
||||
|
||||
if(itemStack.stackTagCompound.hasKey("filters"))
|
||||
{
|
||||
NBTTagList tagList = itemStack.stackTagCompound.getTagList("filters", NBT.TAG_COMPOUND);
|
||||
|
||||
for(int i = 0; i < tagList.tagCount(); i++)
|
||||
{
|
||||
filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import mekanism.api.gas.IGasHandler;
|
||||
import mekanism.api.gas.ITubeConnection;
|
||||
import mekanism.common.IActiveState;
|
||||
import mekanism.common.IRedstoneControl;
|
||||
import mekanism.common.ISustainedTank;
|
||||
import mekanism.common.ISustainedData;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.block.BlockMachine.MachineType;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
@@ -36,7 +36,7 @@ import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock implements IActiveState, ISustainedTank, IFluidHandler, IGasHandler, ITubeConnection, IRedstoneControl
|
||||
public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock implements IActiveState, ISustainedData, IFluidHandler, IGasHandler, ITubeConnection, IRedstoneControl
|
||||
{
|
||||
public GasTank gasTank = new GasTank(MAX_FLUID);
|
||||
|
||||
@@ -501,23 +501,26 @@ public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock imp
|
||||
{
|
||||
return mode == 0 && side == MekanismUtils.getLeft(facing) ? gasTank.canReceive(type) : false;
|
||||
}
|
||||
|
||||
|
||||
@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(gasTank.getGas() != null)
|
||||
{
|
||||
itemStack.stackTagCompound.setTag("gasTank", gasTank.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")));
|
||||
gasTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("gasTank")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user