Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted

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?

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.