Advertisement
Guest User

Untitled

a guest
Apr 14th, 2014
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.88 KB | None | 0 0
  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. public final class PlayerInformation implements IExtendedEntityProperties {
  12.     private int currentXP;
  13.     public final static String EXT_PROP_NAME = "PlayerInformation";
  14.     private final EntityPlayer player;
  15.    
  16.     public static final PlayerInformation get(EntityPlayer player) {
  17.         return (PlayerInformation) player.getExtendedProperties(EXT_PROP_NAME);
  18.     }
  19.    
  20.    
  21.     public PlayerInformation(EntityPlayer player) {
  22.         this.player = player;
  23.     }
  24.    
  25.     public static final void register(EntityPlayer player) {
  26.         player.registerExtendedProperties(PlayerInformation.EXT_PROP_NAME, new PlayerInformation(player));
  27.     }
  28.  
  29.     @Override //Updates anything that needs to be updated each tick
  30.     public void init(Entity entity, World world) {     
  31.     }
  32.  
  33.     @Override
  34.     public void saveNBTData(NBTTagCompound compound) {
  35.         NBTTagCompound properties = new NBTTagCompound();
  36.         properties.setInteger("currentXP", currentXP);
  37.         //System.out.println("NBT Saved");
  38.         //System.out.println(compound);
  39.        
  40.     }
  41.  
  42.     @Override
  43.     public final void loadNBTData(NBTTagCompound compound) {
  44.         System.out.println("NBT LOADED");
  45.         NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);
  46.         System.out.println(this.currentXP);
  47.         if (this.currentXP != 0)
  48.         {
  49.         this.currentXP = properties.getInteger("currentXP");
  50.         }
  51.         else
  52.         {
  53.             System.out.println("From loadNBTData:"+currentXP);
  54.         }
  55.  
  56.     }
  57.  
  58.     public void addXP(int ammount){
  59.         this.currentXP += ammount;
  60.     }
  61.    
  62.     public int getXP(){
  63.         return this.currentXP;
  64.     }
  65.  
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement