Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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.

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.

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?

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.