Procedure to add xp orbs

Published by smmmadden on
Issue description

Hi - I've tried multiple variations of having a procedure on a block that when destroyed by the player or explosion, the block is dropped.  The player is able to pickup the block and everything works.  What I'm now trying to add to this is the option to also drop an XP Orb so that the player can also earn experience points with these ores I'm working on.

I've tried just calling a command of: xp 8 @p in its simplest form and also added a do while and checked for the block being broken followed by the command to create the orb and play the sound (playsound minecraft:entity.experience_orb.pickup ambient @p).  Neither of the commands appear to be executing as I don't see the orbs and I don't hear the sound playing.

Issue comments

Thank you for opening a ticket.

This is not possible yet. I have changed the type of this ticket to a feature request. We will add new procedure block to add XP to the player or to spawn XP orbs in the future updates, but as the 1.8.0 feature queue is full, I am postponing this to a later version for now.

Great!  Thanks for the update and confirming I'm not doing something wrong. Drove me crazy for a few hours. I was also thinking of trying to add the code manually using a code snippet or in the code section that would handle both events when I found the code that it should call.  Is this possible until the UI supports it?

I usually spawn XP by using this procedure block

"Spawn entity (xp orb) at x, y, z "

I don't remember very well its name

 

I changed the codes in the procedure and it worked. I only added coordinate to EntityOrb and number of XP. 

In this line --> Entity entityToSpawn = new EntityXPOrb(world); 

I add this --> Entity entityToSpawn = new EntityXPOrb(world, x, y, z, 2); 

2 means it will give you 2 XP Orb. I think if you put 2L means it will give you 2 levels.

I leave xyz without value because I want the EntityXPOrb to be spawned at the block coordinate that is spawning the XP Orb.