mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-23 21:39:40 +00:00
Added cache implementation of EIM
This commit is contained in:
1 parent
c24c11cb33
commit
540eed908e
3 files changed
+46
-6
No files matched your search
@@ -1,31 +1,69 @@
|
||||
package mekanism.common.matrix;
|
||||
|
||||
import mekanism.common.multiblock.MultiblockCache;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
|
||||
public class MatrixCache extends MultiblockCache<SynchronizedMatrixData>
|
||||
{
|
||||
public ItemStack[] inventory = new ItemStack[2];
|
||||
|
||||
public double electricityStored;
|
||||
|
||||
@Override
|
||||
public void apply(SynchronizedMatrixData data)
|
||||
{
|
||||
|
||||
data.inventory = inventory;
|
||||
data.electricityStored = electricityStored;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync(SynchronizedMatrixData data)
|
||||
{
|
||||
|
||||
inventory = data.inventory;
|
||||
electricityStored = data.electricityStored;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(NBTTagCompound nbtTags)
|
||||
{
|
||||
NBTTagList tagList = nbtTags.getTagList("Items", NBT.TAG_COMPOUND);
|
||||
inventory = new ItemStack[2];
|
||||
|
||||
for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++)
|
||||
{
|
||||
NBTTagCompound tagCompound = (NBTTagCompound)tagList.getCompoundTagAt(tagCount);
|
||||
byte slotID = tagCompound.getByte("Slot");
|
||||
|
||||
if(slotID >= 0 && slotID < 2)
|
||||
{
|
||||
inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
electricityStored = nbtTags.getDouble("electricityStored");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(NBTTagCompound nbtTags)
|
||||
{
|
||||
NBTTagList tagList = new NBTTagList();
|
||||
|
||||
for(int slotCount = 0; slotCount < 2; slotCount++)
|
||||
{
|
||||
if(inventory[slotCount] != null)
|
||||
{
|
||||
NBTTagCompound tagCompound = new NBTTagCompound();
|
||||
tagCompound.setByte("Slot", (byte)slotCount);
|
||||
inventory[slotCount].writeToNBT(tagCompound);
|
||||
tagList.appendTag(tagCompound);
|
||||
}
|
||||
}
|
||||
|
||||
nbtTags.setTag("Items", tagList);
|
||||
|
||||
nbtTags.setDouble("electricityStored", electricityStored);
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,11 @@ package mekanism.common.matrix;
|
||||
|
||||
import mekanism.common.multiblock.SynchronizedData;
|
||||
import mekanism.common.tank.SynchronizedTankData;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class SynchronizedMatrixData extends SynchronizedData<SynchronizedTankData>
|
||||
{
|
||||
|
||||
public ItemStack[] inventory = new ItemStack[2];
|
||||
|
||||
public double electricityStored;
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
package mekanism.common.tank;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.multiblock.MultiblockCache;
|
||||
import mekanism.common.util.FluidContainerUtils.ContainerEditMode;
|
||||
import net.minecraft.item.ItemStack;
|
||||
@@ -14,7 +11,9 @@ import net.minecraftforge.fluids.FluidStack;
|
||||
public class DynamicTankCache extends MultiblockCache<SynchronizedTankData>
|
||||
{
|
||||
public ItemStack[] inventory = new ItemStack[2];
|
||||
|
||||
public FluidStack fluid;
|
||||
|
||||
public ContainerEditMode editMode = ContainerEditMode.BOTH;
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user