Where did the equation E = 3.5 * n * (n + 1)
come from? I see that you say it came from the wiki, but I am unable to find it on there. I do see:
For any given level, the experience, E, required to achieve the next level n+1 from the current level, n is: E = 7 + roundDown(n * 3.5)
Thus, if you were level 0 you would require 7 experience to achieve level 1, which is not the case with E = 3.5 * n * (n + 1)
. To advance to level 2, you would need 10 more experience, a total of 17, not 14 more experience, with a total of 21. I hope that equation is not correct (because I just spent an hour on what I think is the correct one), and that would explain why you don't have to kill 1785 hostile mobs before level 50.
I've come up with E = 7n + round(3.5(.5(n^2)-.5n)) - n/4)
E is the total experience needed to reach level n.
"7n" accounts for the constant 7 experience required to reach every next level. This is the only experience you must collect to reach level 1. E = 7 + roundDown(n * 3.5)
The ".5(n^2)-.5n" provides the number of 3.5 increments between level 0 and level n, but ignores the rounding down. Because the rounding down is not yet accounted for, I have "-n/4" (without this, the equation says you require one more experience than reality every 4 levels). E = 7 + roundDown(n * 3.5) Ex. Between levels 0 and 1 the number of required 3.5 experience increments is 0. Between 1 and 2 the number of 3.5 increments is 1. Between levels 2 and 3 the number of increments is 2. Between levels 0 and 3 the number of increments is 3. 0 + 1 + 2 = 3 3*3.5 is 10.5, and then 7*3 is 21. 10.5 + 21 is 31.5
The "round()" rounds up some E values ending in .75 that result from the "-n/4".
31.5 - 3/4 = 30.75 round(30.75)= 31 And so you need 31 experience to reach level 3 from level 0.
With this equation, you require 4625 experience to reach level 50, which /5 is 925.
The error you are getting simply means that no entity can be found that matches your target selector. Basically, the target selector then returns NULL, which is not a valid UUID, hence the message.
As to why your command fails, you have confused target selector arguments with data tags, which represent NBT data. While some target selector arguments duplicate checking for NBT data, for example [name=Bob] <-> {CustomName:Bob}
, these are different things. In particular, some commands are unable to check NBT data altogether, such as execute
(scoreboard
does, and is therefore a common very workaround to turn NBT into a target selector).
Luckily, testfor
is able to check matching NBT data as an optional argument:
testfor <player> [dataTag]
There is another issue with your command, which is that the Inventory
data tag is only valid for players. Mobs have an Equipment
tag instead, which is a list of 5 Item tags (Hand, Feet, Legs, Chest, Head). Due to Minecraft's partial tag matching, you can leave the other 4 tags empty:
In order to make your command work, you should use
/testfor @e[name=Skeletor] {Equipment:[{},{},{},{},{id:minecraft:golden_helmet}]}
For reasons unknown to me, you need to use the full item id, including the minecraft:
prefix. Using only id:golden_helmet
does not work.
Best Answer
HurtTime increases once the mob is hit. So detecting a hit is as simple as running a command when its the value is greater than 0.
Place down a repeating command block and attach 2 chain command blocks it to. Set them all to always active and paste these in (in the exact same order):
Also, in case you are wondering what the 2 other commands are, it takes a few seconds for the HurtTime value to go back to 0 so those commands make sure that you only get 1 XP orb during that time.
Command block layout: