Lay out the foundation for container edit modes. Also changed the way Dynamic Tank caches work - they are now much more modular and will remember their multiblock inventories on world reload.
This commit is contained in:
parent
16c5f7cdb3
commit
12f3ef8665
16 changed files with 337 additions and 40 deletions
88
src/main/java/mekanism/client/gui/GuiContainerEditMode.java
Normal file
88
src/main/java/mekanism/client/gui/GuiContainerEditMode.java
Normal file
|
@ -0,0 +1,88 @@
|
|||
package mekanism.client.gui;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.client.sound.SoundHandler;
|
||||
import mekanism.common.IFluidContainerManager;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.network.PacketContainerEditMode.ContainerEditModeMessage;
|
||||
import mekanism.common.util.FluidContainerUtils.ContainerEditMode;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
|
||||
public class GuiContainerEditMode extends GuiElement
|
||||
{
|
||||
TileEntity tileEntity;
|
||||
|
||||
public GuiContainerEditMode(IGuiWrapper gui, TileEntity tile, ResourceLocation def)
|
||||
{
|
||||
super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiContainerEditMode.png"), gui, def);
|
||||
|
||||
tileEntity = tile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle4i getBounds(int guiWidth, int guiHeight)
|
||||
{
|
||||
return new Rectangle4i(guiWidth + 176, guiHeight + 138, 26, 26);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)
|
||||
{
|
||||
mc.renderEngine.bindTexture(RESOURCE);
|
||||
|
||||
guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 138, 0, 0, 26, 26);
|
||||
|
||||
IFluidContainerManager control = (IFluidContainerManager)tileEntity;
|
||||
int renderX = 26 + (18*control.getContainerEditMode().ordinal());
|
||||
|
||||
if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160)
|
||||
{
|
||||
guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 142, renderX, 0, 18, 18);
|
||||
}
|
||||
else {
|
||||
guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 142, renderX, 18, 18, 18);
|
||||
}
|
||||
|
||||
mc.renderEngine.bindTexture(defaultLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderForeground(int xAxis, int yAxis)
|
||||
{
|
||||
mc.renderEngine.bindTexture(RESOURCE);
|
||||
|
||||
IFluidContainerManager manager = (IFluidContainerManager)tileEntity;
|
||||
|
||||
if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160)
|
||||
{
|
||||
displayTooltip(manager.getContainerEditMode().getDisplay(), xAxis, yAxis);
|
||||
}
|
||||
|
||||
mc.renderEngine.bindTexture(defaultLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preMouseClicked(int xAxis, int yAxis, int button) {}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int xAxis, int yAxis, int button)
|
||||
{
|
||||
IFluidContainerManager manager = (IFluidContainerManager)tileEntity;
|
||||
|
||||
if(button == 0)
|
||||
{
|
||||
if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160)
|
||||
{
|
||||
ContainerEditMode current = manager.getContainerEditMode();
|
||||
int ordinalToSet = current.ordinal() < (ContainerEditMode.values().length-1) ? current.ordinal()+1 : 0;
|
||||
|
||||
SoundHandler.playSound("gui.button.press");
|
||||
Mekanism.packetHandler.sendToServer(new ContainerEditModeMessage(Coord4D.get(tileEntity), ContainerEditMode.values()[ordinalToSet]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ public class GuiDynamicTank extends GuiMekanism
|
|||
{
|
||||
super(new ContainerDynamicTank(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
guiElements.add(new GuiContainerEditMode(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,6 +24,7 @@ public class GuiPortableTank extends GuiMekanism
|
|||
{
|
||||
super(new ContainerPortableTank(inventory, tentity));
|
||||
tileEntity = tentity;
|
||||
guiElements.add(new GuiContainerEditMode(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")));
|
||||
guiElements.add(new GuiFluidGauge(new IFluidInfoHandler()
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -115,7 +115,7 @@ public class CommonWorldTickHandler
|
|||
|
||||
if(dynamicTank != null)
|
||||
{
|
||||
dynamicTank.cachedFluid = null;
|
||||
dynamicTank.cachedData = new DynamicTankCache();
|
||||
dynamicTank.inventory = new ItemStack[2];
|
||||
dynamicTank.inventoryID = -1;
|
||||
}
|
||||
|
|
10
src/main/java/mekanism/common/IFluidContainerManager.java
Normal file
10
src/main/java/mekanism/common/IFluidContainerManager.java
Normal file
|
@ -0,0 +1,10 @@
|
|||
package mekanism.common;
|
||||
|
||||
import mekanism.common.util.FluidContainerUtils.ContainerEditMode;
|
||||
|
||||
public interface IFluidContainerManager
|
||||
{
|
||||
public ContainerEditMode getContainerEditMode();
|
||||
|
||||
public void setContainerEditMode(ContainerEditMode mode);
|
||||
}
|
|
@ -13,6 +13,8 @@ import mekanism.common.network.PacketConfigurationUpdate;
|
|||
import mekanism.common.network.PacketConfigurationUpdate.ConfigurationUpdateMessage;
|
||||
import mekanism.common.network.PacketConfiguratorState;
|
||||
import mekanism.common.network.PacketConfiguratorState.ConfiguratorStateMessage;
|
||||
import mekanism.common.network.PacketContainerEditMode;
|
||||
import mekanism.common.network.PacketContainerEditMode.ContainerEditModeMessage;
|
||||
import mekanism.common.network.PacketDataRequest;
|
||||
import mekanism.common.network.PacketDataRequest.DataRequestMessage;
|
||||
import mekanism.common.network.PacketDigitUpdate;
|
||||
|
@ -57,7 +59,6 @@ import mekanism.common.network.PacketTransmitterUpdate;
|
|||
import mekanism.common.network.PacketTransmitterUpdate.TransmitterUpdateMessage;
|
||||
import mekanism.common.network.PacketWalkieTalkieState;
|
||||
import mekanism.common.network.PacketWalkieTalkieState.WalkieTalkieStateMessage;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
@ -113,6 +114,7 @@ public class PacketHandler
|
|||
netHandler.registerMessage(PacketConfigSync.class, ConfigSyncMessage.class, 23, Side.CLIENT);
|
||||
netHandler.registerMessage(PacketBoxBlacklist.class, BoxBlacklistMessage.class, 24, Side.CLIENT);
|
||||
netHandler.registerMessage(PacketPortableTankState.class, PortableTankStateMessage.class, 25, Side.SERVER);
|
||||
netHandler.registerMessage(PacketContainerEditMode.class, ContainerEditModeMessage.class, 26, Side.SERVER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
package mekanism.common.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.IFluidContainerManager;
|
||||
import mekanism.common.PacketHandler;
|
||||
import mekanism.common.network.PacketContainerEditMode.ContainerEditModeMessage;
|
||||
import mekanism.common.util.FluidContainerUtils.ContainerEditMode;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class PacketContainerEditMode implements IMessageHandler<ContainerEditModeMessage, IMessage>
|
||||
{
|
||||
@Override
|
||||
public IMessage onMessage(ContainerEditModeMessage message, MessageContext context)
|
||||
{
|
||||
EntityPlayer player = PacketHandler.getPlayer(context);
|
||||
TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj);
|
||||
|
||||
if(tileEntity instanceof IFluidContainerManager)
|
||||
{
|
||||
((IFluidContainerManager)tileEntity).setContainerEditMode(message.value);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class ContainerEditModeMessage implements IMessage
|
||||
{
|
||||
public Coord4D coord4D;
|
||||
public ContainerEditMode value;
|
||||
|
||||
public ContainerEditModeMessage() {}
|
||||
|
||||
public ContainerEditModeMessage(Coord4D coord, ContainerEditMode mode)
|
||||
{
|
||||
coord4D = coord;
|
||||
value = mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf dataStream)
|
||||
{
|
||||
dataStream.writeInt(coord4D.xCoord);
|
||||
dataStream.writeInt(coord4D.yCoord);
|
||||
dataStream.writeInt(coord4D.zCoord);
|
||||
dataStream.writeInt(coord4D.dimensionId);
|
||||
|
||||
dataStream.writeInt(value.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf dataStream)
|
||||
{
|
||||
coord4D = Coord4D.read(dataStream);
|
||||
value = ContainerEditMode.values()[dataStream.readInt()];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,13 +3,81 @@ package mekanism.common.tank;
|
|||
import java.util.HashSet;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.util.FluidContainerUtils.ContainerEditMode;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.util.Constants.NBT;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
public class DynamicTankCache
|
||||
{
|
||||
public ItemStack[] inventory = new ItemStack[2];
|
||||
public FluidStack fluid;
|
||||
public ContainerEditMode editMode = ContainerEditMode.BOTH;
|
||||
|
||||
public void apply(SynchronizedTankData data)
|
||||
{
|
||||
data.inventory = inventory;
|
||||
data.fluidStored = fluid;
|
||||
data.editMode = editMode;
|
||||
}
|
||||
|
||||
public void sync(SynchronizedTankData data)
|
||||
{
|
||||
inventory = data.inventory;
|
||||
fluid = data.fluidStored;
|
||||
editMode = data.editMode;
|
||||
}
|
||||
|
||||
public void load(NBTTagCompound nbtTags)
|
||||
{
|
||||
editMode = ContainerEditMode.values()[nbtTags.getInteger("editMode")];
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if(nbtTags.hasKey("cachedFluid"))
|
||||
{
|
||||
fluid = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedFluid"));
|
||||
}
|
||||
}
|
||||
|
||||
public void save(NBTTagCompound nbtTags)
|
||||
{
|
||||
nbtTags.setInteger("editMode", editMode.ordinal());
|
||||
|
||||
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);
|
||||
|
||||
if(fluid != null)
|
||||
{
|
||||
nbtTags.setTag("cachedFluid", fluid.writeToNBT(new NBTTagCompound()));
|
||||
}
|
||||
}
|
||||
|
||||
public HashSet<Coord4D> locations = new HashSet<Coord4D>();
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import java.util.HashSet;
|
|||
import java.util.Set;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.tile.TileEntityDynamicTank;
|
||||
import mekanism.common.util.FluidContainerUtils.ContainerEditMode;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
@ -21,6 +23,8 @@ public class SynchronizedTankData
|
|||
public int volume;
|
||||
|
||||
public FluidStack fluidStored;
|
||||
|
||||
public ContainerEditMode editMode = ContainerEditMode.BOTH;
|
||||
|
||||
public ItemStack[] inventory = new ItemStack[2];
|
||||
|
||||
|
|
|
@ -404,8 +404,7 @@ public class TankUpdateProtocol
|
|||
idFound = MekanismUtils.getUniqueInventoryID();
|
||||
}
|
||||
|
||||
structureFound.fluidStored = cache.fluid;
|
||||
structureFound.inventory = cache.inventory;
|
||||
cache.apply(structureFound);
|
||||
|
||||
if(structureFound.fluidStored != null)
|
||||
{
|
||||
|
@ -418,8 +417,8 @@ public class TankUpdateProtocol
|
|||
|
||||
tileEntity.inventoryID = idFound;
|
||||
tileEntity.structure = structureFound;
|
||||
tileEntity.cachedFluid = structureFound.fluidStored;
|
||||
tileEntity.inventory = structureFound.inventory;
|
||||
|
||||
tileEntity.cachedData.sync(structureFound);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -7,11 +7,14 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.IFluidContainerManager;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.tank.DynamicTankCache;
|
||||
import mekanism.common.tank.SynchronizedTankData;
|
||||
import mekanism.common.tank.SynchronizedTankData.ValveData;
|
||||
import mekanism.common.tank.TankUpdateProtocol;
|
||||
import mekanism.common.util.FluidContainerUtils.ContainerEditMode;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -23,13 +26,16 @@ import net.minecraftforge.fluids.FluidStack;
|
|||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TileEntityDynamicTank extends TileEntityContainerBlock
|
||||
public class TileEntityDynamicTank extends TileEntityContainerBlock implements IFluidContainerManager
|
||||
{
|
||||
/** Unique inventory ID for the dynamic tank, serves as a way to retrieve cached inventories. */
|
||||
public int inventoryID = -1;
|
||||
|
||||
/** The tank data for this structure. */
|
||||
public SynchronizedTankData structure;
|
||||
|
||||
/** The cache used by this specific tank segment */
|
||||
public DynamicTankCache cachedData = new DynamicTankCache();
|
||||
|
||||
/** Whether or not to send this tank's structure in the next update packet. */
|
||||
public boolean sendStructure;
|
||||
|
@ -40,9 +46,6 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock
|
|||
/** Whether or not this tank has it's structure, for the client side mechanics. */
|
||||
public boolean clientHasStructure;
|
||||
|
||||
/** The cached fluid this tank segment contains. */
|
||||
public FluidStack cachedFluid;
|
||||
|
||||
/** A client-sided and server-sided map of valves on this tank's structure, used on the client for rendering fluids. */
|
||||
public Map<ValveData, Integer> valveViewing = new HashMap<ValveData, Integer>();
|
||||
|
||||
|
@ -146,7 +149,7 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock
|
|||
|
||||
if(inventoryID != -1 && structure == null)
|
||||
{
|
||||
MekanismUtils.updateCache(inventoryID, cachedFluid, inventory, this);
|
||||
MekanismUtils.updateCache(inventoryID, cachedData, this);
|
||||
}
|
||||
|
||||
if(structure == null && ticker == 5)
|
||||
|
@ -184,10 +187,8 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock
|
|||
|
||||
if(inventoryID != -1)
|
||||
{
|
||||
MekanismUtils.updateCache(inventoryID, structure.fluidStored, structure.inventory, this);
|
||||
|
||||
cachedFluid = structure.fluidStored;
|
||||
inventory = structure.inventory;
|
||||
cachedData.sync(structure);
|
||||
MekanismUtils.updateCache(inventoryID, cachedData, this);
|
||||
}
|
||||
|
||||
manageInventory();
|
||||
|
@ -308,7 +309,12 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock
|
|||
|
||||
data.add(isRendering);
|
||||
data.add(structure != null);
|
||||
data.add(structure != null ? structure.volume*TankUpdateProtocol.FLUID_PER_TANK : 0);
|
||||
|
||||
if(structure != null)
|
||||
{
|
||||
data.add(structure.volume*TankUpdateProtocol.FLUID_PER_TANK);
|
||||
data.add(structure.editMode.ordinal());
|
||||
}
|
||||
|
||||
if(structure != null && structure.fluidStored != null)
|
||||
{
|
||||
|
@ -364,8 +370,12 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock
|
|||
|
||||
isRendering = dataStream.readBoolean();
|
||||
clientHasStructure = dataStream.readBoolean();
|
||||
|
||||
clientCapacity = dataStream.readInt();
|
||||
|
||||
if(clientHasStructure)
|
||||
{
|
||||
clientCapacity = dataStream.readInt();
|
||||
structure.editMode = ContainerEditMode.values()[dataStream.readInt()];
|
||||
}
|
||||
|
||||
if(dataStream.readInt() == 1)
|
||||
{
|
||||
|
@ -477,10 +487,7 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock
|
|||
|
||||
if(inventoryID != -1)
|
||||
{
|
||||
if(nbtTags.hasKey("cachedFluid"))
|
||||
{
|
||||
cachedFluid = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedFluid"));
|
||||
}
|
||||
cachedData.load(nbtTags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -492,9 +499,9 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock
|
|||
|
||||
nbtTags.setInteger("inventoryID", inventoryID);
|
||||
|
||||
if(cachedFluid != null)
|
||||
if(inventoryID != -1)
|
||||
{
|
||||
nbtTags.setTag("cachedFluid", cachedFluid.writeToNBT(new NBTTagCompound()));
|
||||
cachedData.save(nbtTags);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -504,4 +511,26 @@ public class TileEntityDynamicTank extends TileEntityContainerBlock
|
|||
{
|
||||
return INFINITE_EXTENT_AABB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContainerEditMode getContainerEditMode()
|
||||
{
|
||||
if(structure != null)
|
||||
{
|
||||
return structure.editMode;
|
||||
}
|
||||
|
||||
return ContainerEditMode.BOTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContainerEditMode(ContainerEditMode mode)
|
||||
{
|
||||
if(structure == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
structure.editMode = mode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,12 +8,13 @@ import mekanism.api.Coord4D;
|
|||
import mekanism.api.IConfigurable;
|
||||
import mekanism.api.gas.IGasItem;
|
||||
import mekanism.common.IActiveState;
|
||||
import mekanism.common.IFluidContainerManager;
|
||||
import mekanism.common.ISustainedTank;
|
||||
import mekanism.common.Mekanism;
|
||||
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
|
||||
import mekanism.common.util.FluidContainerUtils.ContainerEditMode;
|
||||
import mekanism.common.util.InventoryUtils;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.PipeUtils;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -27,7 +28,7 @@ import net.minecraftforge.fluids.FluidTank;
|
|||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class TileEntityPortableTank extends TileEntityContainerBlock implements IActiveState, IConfigurable, IFluidHandler, ISustainedTank
|
||||
public class TileEntityPortableTank extends TileEntityContainerBlock implements IActiveState, IConfigurable, IFluidHandler, ISustainedTank, IFluidContainerManager
|
||||
{
|
||||
public boolean isActive;
|
||||
|
||||
|
@ -37,6 +38,8 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
|
|||
|
||||
public FluidTank fluidTank = new FluidTank(MAX_FLUID);
|
||||
|
||||
public ContainerEditMode editMode = ContainerEditMode.BOTH;
|
||||
|
||||
public int updateDelay;
|
||||
|
||||
public int prevAmount;
|
||||
|
@ -303,6 +306,7 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
|
|||
super.writeToNBT(nbtTags);
|
||||
|
||||
nbtTags.setBoolean("isActive", isActive);
|
||||
nbtTags.setInteger("editMode", editMode.ordinal());
|
||||
|
||||
if(fluidTank.getFluid() != null)
|
||||
{
|
||||
|
@ -316,6 +320,7 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
|
|||
super.readFromNBT(nbtTags);
|
||||
|
||||
clientActive = isActive = nbtTags.getBoolean("isActive");
|
||||
editMode = ContainerEditMode.values()[nbtTags.getInteger("editMode")];
|
||||
|
||||
if(nbtTags.hasKey("fluidTank"))
|
||||
{
|
||||
|
@ -330,6 +335,7 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
|
|||
|
||||
clientActive = dataStream.readBoolean();
|
||||
valve = dataStream.readInt();
|
||||
editMode = ContainerEditMode.values()[dataStream.readInt()];
|
||||
|
||||
if(valve > 0)
|
||||
{
|
||||
|
@ -376,6 +382,7 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
|
|||
|
||||
data.add(isActive);
|
||||
data.add(valve);
|
||||
data.add(editMode.ordinal());
|
||||
|
||||
if(valve > 0)
|
||||
{
|
||||
|
@ -512,12 +519,7 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
|
|||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
if(from == ForgeDirection.UP || from == ForgeDirection.DOWN)
|
||||
{
|
||||
return new FluidTankInfo[] {fluidTank.getInfo()};
|
||||
}
|
||||
|
||||
return PipeUtils.EMPTY;
|
||||
return new FluidTankInfo[] {fluidTank.getInfo()};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -537,4 +539,16 @@ public class TileEntityPortableTank extends TileEntityContainerBlock implements
|
|||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContainerEditMode getContainerEditMode()
|
||||
{
|
||||
return editMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContainerEditMode(ContainerEditMode mode)
|
||||
{
|
||||
editMode = mode;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,4 +36,23 @@ public final class FluidContainerUtils
|
|||
|
||||
return item.fill(container, tileTank.getFluid(), true);
|
||||
}
|
||||
|
||||
public static enum ContainerEditMode
|
||||
{
|
||||
BOTH("fluidedit.both"),
|
||||
FILL("fluidedit.fill"),
|
||||
EMPTY("fluidedit.empty");
|
||||
|
||||
private String display;
|
||||
|
||||
public String getDisplay()
|
||||
{
|
||||
return MekanismUtils.localize(display);
|
||||
}
|
||||
|
||||
private ContainerEditMode(String s)
|
||||
{
|
||||
display = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -886,7 +886,7 @@ public final class MekanismUtils
|
|||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
tileEntity.cachedFluid = null;
|
||||
tileEntity.cachedData = new DynamicTankCache();
|
||||
tileEntity.inventory = new ItemStack[2];
|
||||
tileEntity.inventoryID = -1;
|
||||
}
|
||||
|
@ -904,13 +904,10 @@ public final class MekanismUtils
|
|||
* @param inventory - inventory of the dynamic tank
|
||||
* @param tileEntity - dynamic tank TileEntity
|
||||
*/
|
||||
public static void updateCache(int inventoryID, FluidStack fluid, ItemStack[] inventory, TileEntityDynamicTank tileEntity)
|
||||
public static void updateCache(int inventoryID, DynamicTankCache cache, TileEntityDynamicTank tileEntity)
|
||||
{
|
||||
if(!Mekanism.dynamicInventories.containsKey(inventoryID))
|
||||
{
|
||||
DynamicTankCache cache = new DynamicTankCache();
|
||||
cache.inventory = inventory;
|
||||
cache.fluid = fluid;
|
||||
cache.locations.add(Coord4D.get(tileEntity));
|
||||
|
||||
Mekanism.dynamicInventories.put(inventoryID, cache);
|
||||
|
@ -918,9 +915,7 @@ public final class MekanismUtils
|
|||
return;
|
||||
}
|
||||
|
||||
Mekanism.dynamicInventories.get(inventoryID).inventory = inventory;
|
||||
Mekanism.dynamicInventories.get(inventoryID).fluid = fluid;
|
||||
|
||||
Mekanism.dynamicInventories.put(inventoryID, cache);
|
||||
Mekanism.dynamicInventories.get(inventoryID).locations.add(Coord4D.get(tileEntity));
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.4 KiB |
|
@ -564,6 +564,11 @@ control.disabled.desc=Always active
|
|||
control.high.desc=Active with signal
|
||||
control.low.desc=Active without signal
|
||||
|
||||
//Container edit modes
|
||||
fluidedit.both=Both
|
||||
fluidedit.fill=Fill
|
||||
fluidedit.empty=Empty
|
||||
|
||||
//Colors
|
||||
color.black=Black
|
||||
color.darkBlue=Dark Blue
|
||||
|
|
Loading…
Reference in a new issue