Advertisement
Guest User

Untitled

a guest
Apr 14th, 2014
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.41 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.         NBTTagCompound nbt = new NBTTagCompound();
  30.         nbt.setInteger("currentXP", currentXP);
  31.         System.out.println("NBT Saved");
  32.     }
  33.  
  34.     @Override
  35.     public void loadNBTData(NBTTagCompound playerNbt) {
  36.         NBTTagCompound nbt = playerNbt.getCompoundTag(IDENTIFIER);
  37.         this.currentXP = nbt.getInteger("currentXP");
  38.         System.out.println("NBT Loaded");
  39.  
  40.         }
  41.  
  42.     public void addXP(int ammount){
  43.         this.currentXP += ammount;
  44.  
  45.     }
  46.    
  47.     public int getXP(){
  48.         return this.currentXP;
  49.     }
  50.  
  51.     @Override
  52.     public void init(Entity entity, World world) {     
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement