Here is the code I'm working on currently:
@Override
public void onArmorTick(ItemStack stack, Level level, Player player) {
super.onArmorTick(stack, level, player);
if(player.isOnGround() && !onGround) {
onGround = true;
if(Minecraft.getInstance().level != null) {
List<Entity> entities = Utils.getEntities(Minecraft.getInstance().level, player.getBlockX(), player.getBlockZ(), 6);
for(Entity e : entities) {
if(!e.equals(player)) {
e.hurtMarked = true;
e.hurt(DamageSource.OUT_OF_WORLD, 5f);
}
}
}
} else {
if(!player.isOnGround())
onGround = false;
}
}
My problem is that I can't get e.hurt() to work properly. It doesn't seem to do anything in game.
EDIT:
It's working now, I mistakenly used the Minecraft class to get the client level instead of the level provided in the function parameters. oops.