January 19, 201510 yr You may try to give player XP indirectly by spawning XP orbs at their position and setting their (orb) values to your desired value. Extends EntityXPOrb And you may find out usage / constructor of it.
January 19, 201510 yr Now here is a step by step tutorial of making such custom entity. First, think of what your entity should be called in the code. It can be like EntityCustomXPOrb or something you wish. Second, when making (public class "Name"), be sure it extends (extends EntityXPOrb) so that you can have everything in (EntityXPOrb) ready for your usage. And because you inherit from a pre-defined class (or you can say it is vanilla) you can skip the annoying stuff about update movements, renders, textures, and eventually what the xp orb should do with the player. Third, make constructor "Name"(World world, double x, double y, double z, int xp), then add super(world, x, y, z, xp) to tell Forge / Minecraft you now have a new entity which is similar to those in vanilla Minecraft, and tell Minecraft to make a new EntityXPOrb based on your values. Finally, call world.spawnEntityInWorld(new "Name"(this.worldObj, x, y, z, xp)); when you want to spawn your entity. I hope this helps.
January 19, 201510 yr Minecraft has in the EntityPlayer class methods for adding experience to player so all you would need to do is add player.addExperience where player is an instance of EntityPlayer. Or for levels it's player.addExperienceLevel A lot less complicated than spawning in entities Did you really need to know?
January 19, 201510 yr yeah, use the latter one instead. We are learning modding together so let's compare methods to see of which one is better.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.