Skip to content

Commit

Permalink
chores: minor optimization on Explosion
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd committed Jan 23, 2025
1 parent 294f5fb commit 1cd6c4d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/src/main/java/org/allaymc/api/world/Explosion.java
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ public void explode(Dimension dimension, float x, float y, float z) {
if (affectedEntity instanceof EntityAttributeComponent attributeComponent && attributeComponent.supportAttribute(AttributeType.KNOCKBACK_RESISTANCE)) {
kbResistance = attributeComponent.getAttributeValue(AttributeType.KNOCKBACK_RESISTANCE);
}
affectedEntity.addMotion(MathUtils.normalizeIfNotZero(affectedEntity.getLocation().sub(explosionPos, new Vector3f())).mul(impact * (1.0f - kbResistance)));
var direction = affectedEntity.getLocation().sub(explosionPos, new Vector3f());
if (direction.lengthSquared() > 0) {
affectedEntity.addMotion(direction.normalize().mul(impact * (1.0f - kbResistance)));
}
if (affectedEntity instanceof EntityDamageComponent damageComponent) {
var m = switch (dimension.getWorld().getWorldData().getDifficulty()) {
case PEACEFUL -> 0.0f;
Expand Down

0 comments on commit 1cd6c4d

Please sign in to comment.