Check XP level, and add Item

Started by Kent15 on Mon, 04/02/2018 - 14:00

Topic category: Help with MCreator software

Last seen on 16:14, 8. Sep 2018
Joined Jan 2016
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Check XP level, and add Item
Mon, 04/02/2018 - 14:00

Hey! 

So in a mod I need an action that when you right click an item in the air, it will check if you have 40 XP levels.

If you do, it will take 40 away and give an item.

I have tried the command "/xp -40L @p" but it will happen even if you have less than 40.

Even then, I can't see how to make an if/then action with this.

On this forum: https://www.minecraftforum.net/forums/minecraft-java-edition/redstone-discussion-and/commands-command-blocks-and/2816165-anyway-to-use-the-if-then-command-all-in-one

I found this piece of code from "nigathan":

if (player.level >= 5) {

player.addLevel(-5)

player.giveItem(...)

}

So in MCreator, I set it to where if you right click the item in the air it will run that code.

But when exporting the mod, I get 2 errors:

error: ';' expected player.addLevel(-40)

error: ';' expected player.giveItem(mcreator_testLightsaberXP.block)

 

I just need a way for this to work, whether the code gets fixed or a work-around.

Sorry for such a long post :D

Any help would be appreciated.

Last seen on 15:27, 21. Aug 2020
Joined Dec 2014
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
have you tried global events
Mon, 04/16/2018 - 07:48

have you tried global events

Last seen on 16:14, 8. Sep 2018
Joined Jan 2016
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I looked at that, but these…
Thu, 05/03/2018 - 13:59

I looked at that, but these trigger an event. But I need an event, not a trigger.