The Server was not syncing the players TPlayerStats to the client until
the Armor tab was opened.
Added Packet.
Send Packet on EntityJoinEvent.

Format Derp.

Changed to Debug and added Knapsack slot output.
This commit is contained in:
covers1624 committed 2015-05-01 23:33:08 +09:30
1 parent dfed1dd9f4
commit b38cfee5ff
5 files changed
+143 -3

No files matched your search

@@ -0,0 +1,62 @@
package tconstruct.util.network;
import tconstruct.TConstruct;
import tconstruct.armor.TinkerArmor;
import tconstruct.armor.player.TPlayerStats;
import cpw.mods.fml.common.network.ByteBufUtils;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import mantle.common.network.AbstractPacket;
/**
* 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)
{
TConstruct.logger.info("Packet Arrived!");
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.
}
}
@@ -135,6 +135,8 @@ public class PacketPipeline extends MessageToMessageCodec<FMLProxyPacket, Abstra
registerPacket(GogglePacket.class);
registerPacket(MovementUpdatePacket.class);
registerPacket(ArmourGuiSyncPacket.class);
}
// Method to call from FMLPostInitializationEvent