Guest User

Untitled

a guest
Sep 6th, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.47 KB | None | 0 0
  1. package com.halestormxv.Main.handler;
  2.  
  3. import com.halestormxv.entity.goldspirits.EntityAries;
  4.  
  5. import net.minecraft.entity.Entity;
  6. import net.minecraft.entity.player.EntityPlayer;
  7. import net.minecraft.nbt.NBTTagCompound;
  8. import net.minecraft.world.World;
  9. import net.minecraftforge.common.IExtendedEntityProperties;
  10.  
  11. public class ExtendedPlayer implements IExtendedEntityProperties {
  12.     public final static String PLAYER_HAS_CONTRACT = "Has Contract With Spirit";
  13.     public static boolean aquariusActive, taurusActive, cancerActive, virgoActive, sagittariusActive, leoActive,
  14.     ariesActive, scorpioActive, geminiActive, capricornActive, piscesActive, libraActive;
  15.     private final EntityPlayer player;
  16.     //public static boolean[] summonedState = new boolean[]{aquariusActive, taurusActive, cancerActive, virgoActive, sagittariusActive, leoActive, ariesActive, scorpioActive, geminiActive, capricornActive, piscesActive, libraActive};
  17.    
  18.     public ExtendedPlayer(EntityPlayer player)
  19.     {
  20.         this.player = player;
  21.         //All players default to no contract
  22.         this.aquariusActive = false;
  23.         this.taurusActive = false;
  24.         this.cancerActive = false;
  25.         this.virgoActive = false;
  26.         this.sagittariusActive = false;
  27.         this.leoActive = false;
  28.         this.ariesActive = false;
  29.         this.scorpioActive = false;
  30.         this.geminiActive = false;
  31.         this.capricornActive = false;
  32.         this.piscesActive = false;
  33.         this.libraActive = false;
  34.     }
  35.  
  36.     public static final void register(EntityPlayer player)
  37.     {
  38.         player.registerExtendedProperties(ExtendedPlayer.PLAYER_HAS_CONTRACT, new ExtendedPlayer(player));
  39.     }
  40.  
  41.     public static final ExtendedPlayer get(EntityPlayer player)
  42.     {
  43.         return (ExtendedPlayer) player.getExtendedProperties(PLAYER_HAS_CONTRACT);
  44.     }
  45.  
  46.     // Save any custom data that needs saving here
  47.     @Override
  48.     public void saveNBTData(NBTTagCompound compound)
  49.     {
  50.         // We need to create a new tag compound that will save everything for our Extended Properties
  51.         NBTTagCompound properties = new NBTTagCompound();
  52.         // We only have 2 variables currently; save them both to the new tag
  53.         properties.setBoolean("aquariusActive", false);
  54.         properties.setBoolean("taurusActive", false);
  55.         properties.setBoolean("cancerActive", false);
  56.         properties.setBoolean("virgoActive", false);
  57.         properties.setBoolean("sagittariusActive", false);
  58.         properties.setBoolean("leoActive", false);
  59.         properties.setBoolean("ariesActive", false);
  60.         properties.setBoolean("scorpioActive", false);
  61.         properties.setBoolean("geminiActive", false);
  62.         properties.setBoolean("capricornActive", false);
  63.         properties.setBoolean("piscesActive", false);
  64.         properties.setBoolean("libraActive", false);
  65.  
  66.         // Now add our custom tag to the player's tag with a unique name (our property's name)
  67.         // This will allow you to save multiple types of properties and distinguish between them
  68.         // If you only have one type, it isn't as important, but it will still avoid conflicts between
  69.         // your tag names and vanilla tag names. For instance, if you add some "Items" tag,
  70.         // that will conflict with vanilla. Not good. So just use a unique tag name.
  71.         for(int i = 0; i < 12; i++)
  72.         {
  73.         compound.setTag(PLAYER_HAS_CONTRACT, properties);
  74.         }
  75.     }
  76.  
  77.     // Load whatever data you saved
  78.     @Override
  79.     public void loadNBTData(NBTTagCompound compound)
  80.     {
  81.         // Here we fetch the unique tag compound we set for this class of Extended Properties
  82.         NBTTagCompound properties = (NBTTagCompound) compound.getTag(PLAYER_HAS_CONTRACT);
  83.         // Get our data from the custom tag compound
  84.         this.aquariusActive = properties.getBoolean(PLAYER_HAS_CONTRACT);
  85.         this.taurusActive = properties.getBoolean(PLAYER_HAS_CONTRACT);
  86.         this.cancerActive = properties.getBoolean(PLAYER_HAS_CONTRACT);
  87.         this.virgoActive = properties.getBoolean(PLAYER_HAS_CONTRACT);
  88.         this.sagittariusActive = properties.getBoolean(PLAYER_HAS_CONTRACT);
  89.         this.leoActive = properties.getBoolean(PLAYER_HAS_CONTRACT);
  90.         this.ariesActive = properties.getBoolean(PLAYER_HAS_CONTRACT);
  91.         this.scorpioActive = properties.getBoolean(PLAYER_HAS_CONTRACT);
  92.         this.geminiActive = properties.getBoolean(PLAYER_HAS_CONTRACT);
  93.         this.capricornActive = properties.getBoolean(PLAYER_HAS_CONTRACT);
  94.         this.piscesActive = properties.getBoolean(PLAYER_HAS_CONTRACT);
  95.         this.libraActive = properties.getBoolean(PLAYER_HAS_CONTRACT);
  96.     }
  97.  
  98.     /*
  99.     I personally have yet to find a use for this method. If you know of any,
  100.     please let me know and I'll add it in!
  101.      */
  102.     @Override
  103.     public void init(Entity entity, World world)
  104.     {
  105.     }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment