So basically I'm making a weapon, which when right click is held is supposed damage every entities (except the player) in a specified radius every ~1sec.
I found a way to detect every entities in this radius :
public void radius(PlayerEntity player){ int maxDistanceFromPlayer = 5; Box entityBox = new Box(player.getBlockPos()).expand(maxDistanceFromPlayer); List entityList = player.getWorld().getEntitiesByClass(MobEntity.class, entityBox, e -> e.isAlive()); player.sendMessage(Text.literal(entityList.toString())); }
But I cannot find a way to damage them ??
If you could also tell me how to change the damage amount and rate of damage accordingly to damage amount and attack speed specified in in the item attributeModifier
here is the github repo : https://github.com/FROSTYTRIX/frostytrixs-random-items-mod-1.21.1
Contribute to FROSTYTRIX/frostytrixs-random-items-mod-1.21.1 development by creating an account on GitHub.