Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.github.QVBA.Reference;
- import cpw.mods.fml.common.eventhandler.SubscribeEvent;
- 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;
- import net.minecraftforge.common.MinecraftForge;
- import net.minecraftforge.event.entity.EntityEvent;
- /**
- * Only for use on players.
- * @author QVBA/Roxox1
- */
- public class PlayerEntityProperties implements IExtendedEntityProperties
- {
- public static final String EXT_PROP_NAME = Reference.MOD_ID + "_skull";
- private final EntityPlayer player;
- //Keys
- private final String KEY_IS_SKULLED = "isSkulled";
- private final String KEY_IS_OWED = "isOwed";
- //Values
- private boolean isSkulled;
- private boolean isOwed;
- public PlayerEntityProperties(EntityPlayer player) {
- this.player = player;
- this.isSkulled = false;
- this.isOwed = false;
- }
- public static final void register(EntityPlayer player) {
- player.registerExtendedProperties(EXT_PROP_NAME, new PlayerEntityProperties(player));
- }
- public static final PlayerEntityProperties get(EntityPlayer player) {
- return (PlayerEntityProperties) player.getExtendedProperties(EXT_PROP_NAME);
- }
- //Save custom data.
- @Override
- public void saveNBTData(NBTTagCompound compound) {
- NBTTagCompound properties = new NBTTagCompound();
- properties.setBoolean(KEY_IS_SKULLED, this.isSkulled);
- properties.setBoolean(KEY_IS_OWED, this.isOwed);
- compound.setTag(EXT_PROP_NAME, properties);
- }
- //Load the data we saved.
- @Override
- public void loadNBTData(NBTTagCompound compound) {
- NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);
- this.isSkulled = properties.getBoolean(KEY_IS_SKULLED);
- this.isOwed = properties.getBoolean(KEY_IS_OWED);
- }
- @Override
- public void init(Entity entity, World world) {
- // TODO Auto-generated method stub
- }
- public void setSkulled(boolean skulled) {
- this.isSkulled = skulled;
- }
- public boolean isSkulled() {
- return this.isSkulled;
- }
- public boolean isOwed() {
- return this.isOwed;
- }
- public void setOwed(boolean owed) {
- this.isOwed = owed;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment