Carpet

Carpet

2M Downloads

`/script run modify(p, 'add_exhaustion', value)` casts `value` to an integer before applying the exhaustion

James103 opened this issue ยท 0 comments

commented

put("add_exhaustion", (e, v)-> {
if(e instanceof PlayerEntity) ((PlayerEntity) e).getHungerManager().addExhaustion((int) NumericValue.asNumber(v).getLong());
});

The above code means that /script run modify(p, 'add_exhaustion', 1.5) will actually add 1 exhaustion instead of 1.5, and modify(p, 'add_exhaustion', value where value < 1 will do nothing as

(int) NumericValue.asNumber(v).getLong()

rounds the given value to the nearest integer towards zero, truncating any decimals, then

((PlayerEntity) e).getHungerManager().addExhaustion(0); // see above

does nothing to change the player's exhaustion level.