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) {
- NBTTagCompound entityTempTag = player.getEntityData();
- NBTTagCompound persistTag = entityTempTag.getCompoundTag(player.PERSISTED_NBT_TAG);
- 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) {
- compound.setInteger("currentXP", currentXP);
- //System.out.println("NBT Saved");
- //System.out.println(compound);
- }
- @Override
- public final void loadNBTData(NBTTagCompound compound) {
- System.out.println("NBT LOADED");
- this.currentXP = compound.getInteger("currentXP");
- }
- public void addXP(int ammount){
- this.currentXP += ammount;
- }
- public void setXP(int ammount){
- this.currentXP = ammount;
- }
- public int getXP(){
- return this.currentXP;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement