blob: bf3ce1acc08589f81ea948cc7d8886548af00254 (
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
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<PacketSendServerPlayerInfo, IMessage> {
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);
}
}
|