Guest User

Untitled

a guest
Jan 20th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.23 KB | None | 0 0
  1. import com.github.QVBA.Reference;
  2.  
  3. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  4. import net.minecraft.entity.Entity;
  5. import net.minecraft.entity.player.EntityPlayer;
  6. import net.minecraft.nbt.NBTTagCompound;
  7. import net.minecraft.world.World;
  8. import net.minecraftforge.common.IExtendedEntityProperties;
  9. import net.minecraftforge.common.MinecraftForge;
  10. import net.minecraftforge.event.entity.EntityEvent;
  11.  
  12. /**
  13.  * Only for use on players.
  14.  * @author QVBA/Roxox1
  15.  */
  16. public class PlayerEntityProperties implements IExtendedEntityProperties
  17. {
  18.  
  19.     public static final String EXT_PROP_NAME = Reference.MOD_ID + "_skull";
  20.     private final EntityPlayer player;
  21.  
  22.     //Keys
  23.     private final String KEY_IS_SKULLED = "isSkulled";
  24.     private final String KEY_IS_OWED = "isOwed";
  25.    
  26.     //Values
  27.     private boolean isSkulled;
  28.     private boolean isOwed;
  29.    
  30.     public PlayerEntityProperties(EntityPlayer player) {
  31.         this.player = player;
  32.         this.isSkulled = false;
  33.         this.isOwed = false;
  34.     }
  35.    
  36.     public static final void register(EntityPlayer player) {
  37.         player.registerExtendedProperties(EXT_PROP_NAME, new PlayerEntityProperties(player));
  38.     }
  39.    
  40.     public static final PlayerEntityProperties get(EntityPlayer player) {
  41.         return (PlayerEntityProperties) player.getExtendedProperties(EXT_PROP_NAME);
  42.     }
  43.    
  44.     //Save custom data.
  45.     @Override
  46.     public void saveNBTData(NBTTagCompound compound) {
  47.         NBTTagCompound properties = new NBTTagCompound();
  48.         properties.setBoolean(KEY_IS_SKULLED, this.isSkulled);
  49.         properties.setBoolean(KEY_IS_OWED, this.isOwed);
  50.         compound.setTag(EXT_PROP_NAME, properties);
  51.     }
  52.  
  53.     //Load the data we saved.
  54.     @Override
  55.     public void loadNBTData(NBTTagCompound compound) {
  56.         NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXT_PROP_NAME);
  57.         this.isSkulled = properties.getBoolean(KEY_IS_SKULLED);
  58.         this.isOwed = properties.getBoolean(KEY_IS_OWED);
  59.     }
  60.  
  61.     @Override
  62.     public void init(Entity entity, World world) {
  63.         // TODO Auto-generated method stub
  64.        
  65.     }
  66.    
  67.     public void setSkulled(boolean skulled) {
  68.         this.isSkulled = skulled;
  69.     }
  70.    
  71.     public boolean isSkulled() {
  72.         return this.isSkulled;
  73.     }
  74.    
  75.     public boolean isOwed() {
  76.         return this.isOwed;
  77.     }
  78.    
  79.     public void setOwed(boolean owed) {
  80.         this.isOwed = owed;
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment