Jump to content

Awarding experience on breaking blocks.


SirLich

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.