Advertisement
Guest User

Untitled

a guest
Apr 14th, 2014
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.NBTTagCompound;
  7. import net.minecraft.util.IChatComponent;
  8. import net.minecraft.world.World;
  9. import net.minecraftforge.common.IExtendedEntityProperties;
  10.  
  11.  
  12.  
  13.  
  14. public final class PlayerInformation implements IExtendedEntityProperties {
  15.     private int currentXP;
  16.     public final static String EXT_PROP_NAME = "PlayerInformation";
  17.     private final EntityPlayer player;
  18.    
  19.     public static final PlayerInformation get(EntityPlayer player) {
  20.         return (PlayerInformation) player.getExtendedProperties(EXT_PROP_NAME);
  21.     }
  22.    
  23.    
  24.     public PlayerInformation(EntityPlayer player) {
  25.         this.player = player;
  26.     }
  27.    
  28.     public static final void register(EntityPlayer player) {
  29.         player.registerExtendedProperties(PlayerInformation.EXT_PROP_NAME, new PlayerInformation(player));
  30.     }
  31.  
  32.     @Override //Updates anything that needs to be updated each tick
  33.     public void init(Entity entity, World world) {     
  34.     }
  35.  
  36.     @Override
  37.     public void saveNBTData(NBTTagCompound compound) {
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement