From 0ef6a00aa79f022e5bd56b3f77e6861bbecf6d94 Mon Sep 17 00:00:00 2001 From: OnyxDarkKnight Date: Thu, 13 Aug 2015 21:12:11 +0100 Subject: Added a new structure, a new curse, achievements, challenges, curses entry in the guide; reworked liquids to be tile entities, cleaned the structures code, potion code and... you know what? I improved and changed so much stuff that I literally forgot what I did... --- .../network/PacketSendServerPlayerInfo.java | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 src/main/java/darkknight/jewelrycraft/network/PacketSendServerPlayerInfo.java (limited to 'src/main/java/darkknight/jewelrycraft/network/PacketSendServerPlayerInfo.java') diff --git a/src/main/java/darkknight/jewelrycraft/network/PacketSendServerPlayerInfo.java b/src/main/java/darkknight/jewelrycraft/network/PacketSendServerPlayerInfo.java new file mode 100644 index 0000000..afefb65 --- /dev/null +++ b/src/main/java/darkknight/jewelrycraft/network/PacketSendServerPlayerInfo.java @@ -0,0 +1,71 @@ +package darkknight.jewelrycraft.network; + +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 darkknight.jewelrycraft.util.PlayerUtils; +import darkknight.jewelrycraft.util.Variables; +import io.netty.buffer.ByteBuf; +import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.nbt.NBTTagCompound; + +public class PacketSendServerPlayerInfo implements IMessage, IMessageHandler +{ + public NBTTagCompound tagCompound; + public String curse, action; + + /** + * @param tagCompound + */ + public PacketSendServerPlayerInfo(String action, String curse, NBTTagCompound tagCompound) + { + this.tagCompound = tagCompound; + this.curse = curse; + this.action = action; + } + + /** + * + */ + public PacketSendServerPlayerInfo() + {} + + /** + * @param message + * @param ctx + * @return + */ + @Override + public IMessage onMessage(PacketSendServerPlayerInfo message, MessageContext ctx) + { + EntityPlayerMP serverPlayer = ctx.getServerHandler().playerEntity; + NBTTagCompound playerInfo = PlayerUtils.getModPlayerPersistTag(serverPlayer, Variables.MODID); + playerInfo.setInteger(message.curse, message.action.equals("remove") ? 0 : 1); + playerInfo.setInteger("activeCurses", message.tagCompound.getInteger("activeCurses")); + System.out.println(message.action + " " + message.curse + " " + message.tagCompound.getInteger(curse) + " " + message.tagCompound.getInteger("activeCurses")); + return null; + } + + /** + * @param buf + */ + @Override + public void fromBytes(ByteBuf buf) + { + tagCompound = ByteBufUtils.readTag(buf); + curse = ByteBufUtils.readUTF8String(buf); + action = ByteBufUtils.readUTF8String(buf); + } + + /** + * @param buf + */ + @Override + public void toBytes(ByteBuf buf) + { + ByteBufUtils.writeTag(buf, tagCompound); + ByteBufUtils.writeUTF8String(buf, curse); + ByteBufUtils.writeUTF8String(buf, action); + } +} -- cgit v1.2.3