How To Take Away Xp In Minecraft
This thread was marked as Locked by Badprenup.
- Search
- Tools
Command for taking xp points from a histrion
How To Take Away Xp In Minecraft,
Source: https://www.minecraftforum.net/forums/minecraft-java-edition/suggestions/89502-command-for-taking-xp-points-from-a-player
Posted by: campbelltrailtoo.blogspot.com
#1 February 12, 2014
I was working on edifice a shop on my server that used xp points every bit currency. I know everybody uses xp levels as the currency, but i don't think that's off-white, considering if you are at a loftier level, items will price way more xp than at a lower level. for example: if an item costs 1 level and you only have 1 level, you are spending 17xp. Just if you are at level 40 you have to spend 125xp to become that same item. That is why i thought it would exist useful to be able to apply individual xp points equally currency, that fashion it wouldn't affair if y'all are level 2 or level 100, if something price 50xp you lot would spend 50 xp regardless of your xp level. All that would have to be done is change the xp command to let negative values. Equally information technology stands right at present, you can give a player xp, but yous can't have information technology away.
This is valid:
/xp 5L @p
This is valid:
/xp -5L @p
And this is valid:
/xp 85 @p
but this is not valid:
/xp -85 @p
i don't sympathise why.
Does anyone else think this that assuasive /xp -85 @p expert thought? If so, how do i propose it to Mojang?
-also on i side note, while it wouldn't be required it would be handy to also have an statement for minimum xp (xm or something like that) instead of just minimum level (lm)
Rollback Post to Revision RollBack
Tomorrow will never come up
#2 Feb 12, 2014
If im not mistaken thats possible already...
From the wiki:
/xp <amount>L [playername]
Gives playername the amount number of experience levels. Maximum is 2,147,483,647 — if a actor is given levels pushing them past this limit, they get reset to 0. Negative amounts may be used to remove experience levels.
In fact im sure some people use this for stores.
Im not sure what your request for =/
Terminal edited past Ttzara: Feb 12, 2014
Rollback Postal service to Revision RollBack
#3 Feb 12, 2014
Yes, i know, that's what i said in the description. I know you tin remove xp levels, but you can not remove individual xp points. removing levels is non fair, because college levels are worth much more xp than lower levels.
Rollback Post to Revision RollBack
Tomorrow will never come
#four February 12, 2014
Im sure its non coded for a reason, it might a problem to keep track on the xp that might be taken and how it reflects on the xp bar, im not sure if its possible, it might exist but kinda complicated.
Rollback Post to Revision RollBack
#5 Feb 12, 2014
The reason that doesn't piece of work is considering that sets the XP of the role player, where as L makes it relative to the player'south electric current feel. Doing that sets negative experience, which shouldn't be in the game.
Rollback Mail to Revision RollBack
#vi Feb 12, 2014
You hateful that players would exist able to get on - xp and all the same enchant or something similar that ? And then they should add some kind of condition or check that says that xp>0, and if the player tryies to enchant and the xp would be less than 0 so he deceit do it.
BTW, equally you can see im non coder and then im just wondering...
Rollback Post to Revision RollBack
#vii February 12, 2014
I thought that made sense at first, so i went to exam it and information technology doesn't exactly work that way. If you enter /xp 17 @p it does non gear up your total xp to 17, information technology adds 17xp to your total, same thing if you added Fifty subsequently the number, it would add 17 levels. And so i really come across no reason why you lot can't enter /xp -17 @p to subtract 17 points from your total the same style you tin subtract 17 levels from your total, unless as Ttzara said there is a good reason Mojang left it out.
Rollback Post to Revision RollBack
Tomorrow volition never come up
#8 Feb 12, 2014
Oh, hang on... I got confused there for a second. Isn't in that location already a way to negate feel? If non, then I back up for sure!
Rollback Post to Revision RollBack
#nine Feb 13, 2014
According to the wiki: http://minecraft.gamepedia.com/Commands there is no way. Do you know how to bring this to Mojang'due south attention?
Rollback Postal service to Revision RollBack
Tomorrow will never come
#x Feb thirteen, 2014
Not exactly familiar with that, but y'all could endeavour Reddit or Twitter.
Rollback Post to Revision RollBack
#11 February 13, 2014
Reddit or Twitter are your best bets, but information technology typically isn't a practiced idea to contact them until your idea has received a fair bit of feedback and accept made changes accordingly. That being said, this seems adequately straightforward. If I had to add i matter to this I would say that the only thing Minecraft needs to make sure this works is prevention from going into negatives, equally that tin break everything. So basically, when this control is used, the game will bank check the player'south electric current XP, and if information technology is less than the corporeality y'all want to remove it will merely remove the corporeality the player has or give an fault message like "Cannot remove <number> experience from <thespian>. This player does not take enough experience."
Likewise on that note, I'1000 not certain if it exists already but you would too demand a way to bank check how much experience a player has commencement to ensure they have enough.
Rollback Mail service to Revision RollBack
#12 February 13, 2014
Equally far equally going into negatives, it shouldn't be a problem, remember that you lot can still subtract xp levels. If you are at level 1 and you lot subtract ii levels your xp will go to zippo, not -one. And if you add 1xp later that it goes to 1, rather than staying at nil which disproves the possibility of it even so counting it at -ane fifty-fifty if it shows it at 0. It doesn't give you whatsoever error message, it just says "took 2 levels from [playername]" but it only takes one because you only have one.
There is indeed a way to prevent subtracting the xp if they don't have it which is what i did for my shop. Hither'southward how it works:
The first block has a button which the player presses to buy the detail. On the back of the block is a repeater that goes out to a command block. That command block has the lawmaking: "/requite @p[lm=n] <item id> <quantity> <datavalue> <tags>" where lm is an statement that means the player must accept a minimum level of due north and n would exist the price of the particular.
Then in that location is a repeater coming out of that command cake to some other command block with this code: "/xp -nL @p" This will subtract n levels from the nearest player unless the previous command cake output is false, in which case it wouldn't light upward the repeater between the 2 blocks and the 2nd control block will never actuate. If you wanted you could run a redstone signal off the first repeater with a repeater in it (for delay) that would go to another command cake which would test for the 2nd repeater beingness off. If it came back true it could output a signal to another control block which could exist set to say to the player "you do not have enough xp" or "insufficient funds" or something like that.
Rollback Postal service to Revision RollBack
Tomorrow will never come
#14 Apr 29, 2018
Unfortunately, Mojang volition probable never add together this, at least not someday soon; apparently, they can't figure out how to subtract XP points:
This seems to be related to the fact that the game does not really shop experience straight, but only your electric current level and "progress" to the adjacent level - but it does store the total amount of XP that you've accumulated since your last death:
Using the XP values for 1.half-dozen.iv the "XpP" value means that I've accumulated 94 out of 104 XP required to reach level 37 (I really get 94.0346992 due to floating signal precision error, which becomes 94 when cast to an integer. This also means that collecting XP likely does not work properly when you need a very large amount of XP to attain the next level since the precision of a float is too low).
I'm not sure why the game has "Score" and "XpTotal" tags when they are always (every bit far as I can tell) the same; one could be used to track XP since your final decease while the other would store the XP you have based on your current level and "progress" (which could be removed; the game can easily calculate the progress when displaying the XP bar). In fact, I separated these in my modernistic so one tracks the total XP you've accumulated in the world (displayed in your inventory) while the other is since your last death (all I did was have the game e'er save "XpTotal" regardless of keepInventory, with "Score" being the value displayed in the death screen and reset on decease, otherwise, it seems like they e'er rails each other in vanilla, except perhaps if you employ commands to change them). Also, if XP were always stored as an integer (or long to avoid overflow long before you lot reached the level cap) the same floating point bug would exist eliminated.
Rollback Post to Revision RollBack
#xv Apr 29, 2018
This control would exist a practiced thought for making exact experience levels if you already accept points, only what y'all could do is plow on keep inventory and kill yourself. Then give yourself xp according to the exact number of levels you want.
Rollback Post to Revision RollBack
#17 Jul 30, 2018
I have just confirmed what Beer678 has said works in 1.xiii. Closing thread as this has been implemented.
Rollback Post to Revision RollBack