mirror of
https://github.com/Thorfusion/Mekanism-Community-Edition.git
synced 2026-11-28 07:36:01 +00:00
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:
1 parent
16c5f7cdb3
commit
12f3ef8665
16 files changed
+337
-40
No files matched your search
@@ -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()];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user