View difference between Paste ID: rDAGKv0f and 8b7pk36Y
SHOW: | | - or go back to the newest paste.
1
package tutorial.generic;
2
3
import net.minecraft.entity.Entity;
4
import net.minecraft.entity.player.EntityPlayer;
5
import net.minecraft.entity.player.EntityPlayerMP;
6-
import net.minecraft.nbt.NBTTagList;
6+
7
import net.minecraft.util.IChatComponent;
8
import net.minecraft.world.World;
9
import net.minecraftforge.common.IExtendedEntityProperties;
10
11
12
13-
	public int currentXP;
13+
14
public final class PlayerInformation implements IExtendedEntityProperties {
15
	private int currentXP;
16
	public final static String EXT_PROP_NAME = "PlayerInformation";	
17-
    public PlayerInformation(EntityPlayer player) {
17+
18-
        this.player = player;
18+
19
	public static final PlayerInformation get(EntityPlayer player) {
20
		return (PlayerInformation) player.getExtendedProperties(EXT_PROP_NAME);
21-
	public static final String IDENTIFIER = "minepg_playerinfo";
21+
22
	
23-
	public static PlayerInformation forPlayer(Entity player) {
23+
24-
        return (PlayerInformation) player.getExtendedProperties(IDENTIFIER);
24+
	public PlayerInformation(EntityPlayer player) {
25
		this.player = player;
26
	}
27
	
28
	public static final void register(EntityPlayer player) {
29-
    	compound.setInteger("currentXP", currentXP);
29+
		player.registerExtendedProperties(PlayerInformation.EXT_PROP_NAME, new PlayerInformation(player));
30-
        System.out.println("NBT Saved");
30+
31
32
	@Override //Updates anything that needs to be updated each tick
33
	public void init(Entity entity, World world) {		
34-
    public void loadNBTData(NBTTagCompound compound) {
34+
35-
        this.currentXP = compound.getInteger("currentXP");
35+
36-
        System.out.println("NBT Loaded");
36+
37
    public void saveNBTData(NBTTagCompound compound) {
38-
        }
38+
    	NBTTagCompound properties = new NBTTagCompound();
39
    	properties.setInteger("currentXP", currentXP);
40
        //System.out.println("NBT Saved");
41
        //System.out.println(compound);
42
        
43
    }
44
45
	@Override
46
	public final void loadNBTData(NBTTagCompound compound) {
47
		NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);
48
		System.out.println(this.currentXP);
49
		this.currentXP = properties.getInteger("currentXP");
50
51
}
52
53
54
  
55
    public void addXP(int ammount){
56
    	this.currentXP += ammount;
57
    }
58
    
59
    public int getXP(){
60
    	return this.currentXP;
61
    }
62
63
}