Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tutorial.generic;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.player.EntityPlayerMP;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.util.IChatComponent;
- import net.minecraft.world.World;
- import net.minecraftforge.common.IExtendedEntityProperties;
- public final class PlayerInformation implements IExtendedEntityProperties {
- private int currentXP;
- public final static String EXT_PROP_NAME = "PlayerInformation";
- private final EntityPlayer player;
- public static final PlayerInformation get(EntityPlayer player) {
- return (PlayerInformation) player.getExtendedProperties(EXT_PROP_NAME);
- }
- public PlayerInformation(EntityPlayer player) {
- this.player = player;
- }
- public static final void register(EntityPlayer player) {
- player.registerExtendedProperties(PlayerInformation.EXT_PROP_NAME, new PlayerInformation(player));
- }
- @Override //Updates anything that needs to be updated each tick
- public void init(Entity entity, World world) {
- }
- @Override
- public void saveNBTData(NBTTagCompound compound) {
- NBTTagCompound properties = new NBTTagCompound();
- properties.setInteger("currentXP", currentXP);
- //System.out.println("NBT Saved");
- //System.out.println(compound);
- }
- @Override
- public final void loadNBTData(NBTTagCompound compound) {
- System.out.println("NBT LOADED");
- NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);
- System.out.println(this.currentXP);
- if (this.currentXP != 0)
- {
- this.currentXP = properties.getInteger("currentXP");
- }
- else
- {
- System.out.println("From loadNBTData:"+currentXP);
- }
- }
- public void addXP(int ammount){
- this.currentXP += ammount;
- }
- public int getXP(){
- return this.currentXP;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement