Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mightydanp.eot.core.entities.player;
- import java.lang.ref.WeakReference;
- import com.mightydanp.eot.core.gui.inventory.EotInventory;
- import com.mightydanp.eot.lib.References;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.nbt.NBTTagCompound;
- import net.minecraft.world.World;
- import net.minecraftforge.common.IExtendedEntityProperties;
- public class EotPlayerStats implements IExtendedEntityProperties
- {
- public final static String EXT_PROP_NAME = "ExtendedPlayer";
- public final EotInventory inventory = new EotInventory();
- private final EntityPlayer player;
- public EotPlayerStats(EntityPlayer player) {
- this.player = player;
- }
- /**
- * Used to register these extended properties for the player during EntityConstructing event
- */
- public static final void register(EntityPlayer player) {
- player.registerExtendedProperties(EotPlayerStats.EXT_PROP_NAME, new EotPlayerStats(player));
- }
- /**
- * Returns ExtendedPlayer properties for player
- */
- public static final EotPlayerStats get(EntityPlayer player) {
- return (EotPlayerStats) player.getExtendedProperties(EXT_PROP_NAME);
- }
- /**
- * Copies additional player data from the given ExtendedPlayer instance
- * Avoids NBT disk I/O overhead when cloning a player after respawn
- */
- public void copy(EotPlayerStats props) {}
- @Override
- public final void saveNBTData(NBTTagCompound compound) {
- NBTTagCompound properties = new NBTTagCompound();
- compound.setTag(EXT_PROP_NAME, properties);
- this.inventory.writeToNBT(properties);
- }
- @Override
- public final void loadNBTData(NBTTagCompound compound) {
- NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);
- this.inventory.readFromNBT(properties);
- }
- @Override
- public void init(Entity entity, World world) {}
- }
Advertisement
Add Comment
Please, Sign In to add comment