mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-22 13:09:53 +00:00
56 lines
1.5 KiB
Java
56 lines
1.5 KiB
Java
package tconstruct.util.network;
|
|
|
|
import mantle.common.network.AbstractPacket;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.nbt.NBTTagCompound;
|
|
|
|
import tconstruct.armor.TinkerArmor;
|
|
import tconstruct.armor.player.TPlayerStats;
|
|
import cpw.mods.fml.common.network.ByteBufUtils;
|
|
import io.netty.buffer.ByteBuf;
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
|
|
/**
|
|
* This Packet is for sending the players TPlayerStats from the server to the client.
|
|
*
|
|
* @author covers1624
|
|
*/
|
|
public class ArmourGuiSyncPacket extends AbstractPacket {
|
|
|
|
NBTTagCompound playerStats = new NBTTagCompound();
|
|
|
|
public ArmourGuiSyncPacket() {}
|
|
|
|
/**
|
|
* For sending the players TPlayerStats to the client.
|
|
*
|
|
* @param tag, The players TPlayerStats written to NBT.
|
|
*/
|
|
public ArmourGuiSyncPacket(NBTTagCompound tag) {
|
|
playerStats = tag;
|
|
}
|
|
|
|
@Override
|
|
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
|
|
ByteBufUtils.writeTag(buffer, playerStats);
|
|
}
|
|
|
|
@Override
|
|
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
|
|
playerStats = ByteBufUtils.readTag(buffer);
|
|
}
|
|
|
|
@Override
|
|
public void handleClientSide(EntityPlayer player) {
|
|
TPlayerStats stats = new TPlayerStats(player);
|
|
stats.loadNBTData(playerStats);
|
|
TinkerArmor.proxy.updatePlayerStats(stats);
|
|
}
|
|
|
|
@Override
|
|
public void handleServerSide(EntityPlayer player) {
|
|
// NO-OP. this is a Server -> client packet.
|
|
}
|
|
}
|