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

Posted

Hi, I need some help. I am creating a basic warp mod. However I want to add a little something extra. Warping will cost experience. I will work out all the details later, but right now I need to know how to add/detract XP levels from the player. I want to focus on detracting right now, because I want to set up my /warp command with something like this:

 

If(player.xplevel > warp_cost)

{

    player.xplevel -= warp_cost;

}

else

{

    println("Not enough XP);

}

 

Could somebody please direct me to the correct class, or more helpfully the actual line of code that will add XP? Using that I can refine my google searches and learn more about it. Thanks.

 

~SirLich

 

 

My name is SirLich and I am really, really trying to learn Modding. I am not some dumb middle schooler. I am not some no-coding-loser who wants to mod. I know a number of computer programming languages and right now I am learning Java. Please help me -.-

EntityPlayer#addExperience

,

EntityPlayer#removeExperienceLevel

and

EntityPlayer#addExperienceLevel

allow you to add and remove XP from the player.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

hi,

 

you could even drop exp with

 

public void dropXpOnBlockBreak(World worldIn, BlockPos pos, int amount)
    {
        if (!worldIn.isRemote)
        {
            while (amount > 0)
            {
                int j = EntityXPOrb.getXPSplit(amount);
                amount -= j;
                worldIn.spawnEntityInWorld(new EntityXPOrb(worldIn, (double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, j));
            }
        }
    }

(Taken from the Block.class)

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.