SHARE
TWEET

Extended_Jamiga

a guest Apr 12th, 2014 22 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package aJamigaPack1;
  2.  
  3. import net.minecraft.entity.player.EntityPlayer;
  4. import net.minecraftforge.event.ForgeSubscribe;
  5. import net.minecraftforge.event.entity.EntityEvent.EntityConstructing;
  6.  
  7. public class TutEventHandler
  8. {
  9. @ForgeSubscribe
  10. public void onEntityConstructing(EntityConstructing event)
  11. {
  12. /*
  13. Be sure to check if the entity being constructed is the correct type for the extended properties you're about to add! The null check may not be necessary - I only use it to make sure properties are only registered once per entity
  14. */
  15. if (event.entity instanceof EntityPlayer && ExtendedPlayer.get((EntityPlayer) event.entity) == null)
  16. // This is how extended properties are registered using our convenient method from earlier
  17. ExtendedPlayer.register((EntityPlayer) event.entity);
  18. // That will call the constructor as well as cause the init() method
  19. // to be called automatically
  20.  
  21. // If you didn't make the two convenient methods from earlier, your code would be
  22. // much uglier:
  23. if (event.entity instanceof EntityPlayer && event.entity.getExtendedProperties(ExtendedPlayer.EXT_PROP_NAME) == null)
  24. event.entity.registerExtendedProperties(ExtendedPlayer.EXT_PROP_NAME, new ExtendedPlayer((EntityPlayer) event.entity));
  25. }
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top