I want to reset fall damage distance (not to cancel a event)
With Bukkit I was using : player.setFallDistance(0);
Is something equivalent to this method ?
When would you know to reset the fall distance without listening to a damage event?
It’s a bit complex, i’m writing a custom gravity engine like I did in Bukkit.
It’s a task which is scheduled every tick.
Every tick if the player is in a region with a gravity factor less than 0.5, his fall distance is reset.
I’m not cancelling an event because if the player pass through a region (with < 0.5 g) when he will hit on the ground he will take all damage (even if the region slowed his fall).
I hope I was clear ^^’ I’m not English
It’s a bit of a work around but would something like this help?
Set<Player> disabledFallDamage
onPlayerMove {
if ( player inside 0.5g region ) {
disableFallDamage.add(player)
}
if ( player is on ground ) {
disabledFallDamage.remove(player)
}
}
onPlayerDamage {
if ( disableFallDamage.contains(player) && damageType == fallDamage) event.cancel()
}
With your method the player will take the same amount of damage if he was slowed or not by a region during his fall.
I want to reset this field every tick while the player is in a region :
net/minecraft/entity/Entity.java : line 111 : public float fallDistance;
I can use reflection or mixin but something like entity.offer(Keys.FALL_DISTANCE, 0);
would be nice.
There is a NBT Tag: http://minecraft-de.gamepedia.com/Player_Format#Objektbasisdaten (unfortunatly the “FallDistance” is only shown in the German version of gamepedia).
Should be implemented into Sponge.
Working on a PR for this currently, to be added to SpongeAPI
Here we are: Add FallDistanceData to API by ZephireNZ · Pull Request #891 · SpongePowered/SpongeAPI · GitHub
Yeah I wasn’t arguing that it shouldn’t be exposed. Just that a work around was available. I don’t see the difference, but maybe I misunderstand what you wanted.