Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.railsofwar.row.stock.packets;
- import io.netty.buffer.ByteBuf;
- import net.minecraft.client.Minecraft;
- import net.minecraft.entity.Entity;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraftforge.fml.common.network.ByteBufUtils;
- import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
- import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
- import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
- public class PacketSendClientNBTData implements IMessage{
- private int id;
- private NBTTagCompound tagCompound;
- public PacketSendClientNBTData(){
- }
- public PacketSendClientNBTData(int id, NBTTagCompound tagCompound){
- this.id = id;
- this.tagCompound = tagCompound;
- }
- @Override
- public void toBytes(ByteBuf buf){
- buf.writeInt(id);
- ByteBufUtils.writeTag(buf, tagCompound);
- }
- @Override
- public void fromBytes(ByteBuf buf){
- this.id = buf.readInt();
- this.tagCompound = ByteBufUtils.readTag(buf);
- }
- public static class Handler implements IMessageHandler<PacketSendClientNBTData, IMessage>{
- @Override
- public IMessage onMessage(PacketSendClientNBTData message, MessageContext ctx){
- Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(message.id);
- if(entity != null)
- entity.readFromNBT(message.tagCompound);
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement