Advertisement
Guest User

Untitled

a guest
Apr 14th, 2014
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 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.nbt.NBTTagCompound;
  6. import net.minecraft.nbt.NBTTagList;
  7. import net.minecraft.world.World;
  8. import net.minecraftforge.common.IExtendedEntityProperties;
  9.  
  10.  
  11. public final class PlayerInformation implements IExtendedEntityProperties {
  12.    
  13.     public int currentXP;
  14.  
  15.    
  16.     private final EntityPlayer player;
  17.     public PlayerInformation(EntityPlayer player) {
  18.         this.player = player;
  19.     }
  20.    
  21.     public static final String IDENTIFIER = "minepg_playerinfo";
  22.    
  23.     public static PlayerInformation forPlayer(Entity player) {
  24.         return (PlayerInformation) player.getExtendedProperties(IDENTIFIER);
  25.     }
  26.  
  27.     @Override
  28.     public void saveNBTData(NBTTagCompound compound) {
  29.         compound.setInteger("currentXP", currentXP);
  30.         System.out.println("NBT Saved");
  31.     }
  32.  
  33.     @Override
  34.     public void loadNBTData(NBTTagCompound compound) {
  35.         this.currentXP = compound.getInteger("currentXP");
  36.         System.out.println("NBT Loaded");
  37.  
  38.         }
  39.  
  40.     public void addXP(int ammount){
  41.         this.currentXP += ammount;
  42.  
  43.     }
  44.    
  45.     public int getXP(){
  46.         return this.currentXP;
  47.     }
  48.  
  49.     @Override
  50.     public void init(Entity entity, World world) {     
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement