aboutsummaryrefslogtreecommitdiff
path: root/src/Java/miscutil/enderio/conduit/gas/PacketGasLevel.java
blob: 0e1b96313cc7a6429f317d8c21b7c916804645eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package crazypants.enderio.conduit.gas;

import com.enderio.core.common.network.MessageTileEntity;
import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
import crazypants.enderio.conduit.IConduitBundle;
import crazypants.util.ClientUtil;
import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;

public class PacketGasLevel
  extends MessageTileEntity<TileEntity>
  implements IMessageHandler<PacketGasLevel, IMessage>
{
  public NBTTagCompound tc;
  
  public PacketGasLevel() {}
  
  public PacketGasLevel(IGasConduit conduit)
  {
    super(conduit.getBundle().getEntity());
    this.tc = new NBTTagCompound();
    conduit.writeToNBT(this.tc);
  }
  
  public void toBytes(ByteBuf buf)
  {
    super.toBytes(buf);
    ByteBufUtils.writeTag(buf, this.tc);
  }
  
  public void fromBytes(ByteBuf buf)
  {
    super.fromBytes(buf);
    this.tc = ByteBufUtils.readTag(buf);
  }
  
  public IMessage onMessage(PacketGasLevel message, MessageContext ctx)
  {
    ClientUtil.doGasLevelUpdate(message.x, message.y, message.z, message);
    return null;
  }
}