Skip to content

Commit

Permalink
fix: explosion damage now scales with game difficulty, and a bug was …
Browse files Browse the repository at this point in the history
…fixed that cause the damage two times bigger than the correct damage.
  • Loading branch information
smartcmd committed Jan 23, 2025
1 parent c3568c8 commit 294f5fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Unless otherwise specified, any version comparison below is the comparison of se
- Plugins are able to create their own world generator implementation now. In previous versions a ClassCastException would be thrown when
initializing the dimension.
- Explosion now calculates entity exposure correctly. In previous version any non-air block will block the explosion ray.
- Explosion damage now scales with game difficulty, and a bug was fixed that cause the damage two times bigger than the correct damage.

### Removed

Expand Down
9 changes: 8 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 @@ -213,7 +213,14 @@ public void explode(Dimension dimension, float x, float y, float z) {
}
affectedEntity.addMotion(MathUtils.normalizeIfNotZero(affectedEntity.getLocation().sub(explosionPos, new Vector3f())).mul(impact * (1.0f - kbResistance)));
if (affectedEntity instanceof EntityDamageComponent damageComponent) {
var damage = (float) Math.floor((impact * impact + impact) * 3.5 * size * 2 + 1);
var m = switch (dimension.getWorld().getWorldData().getDifficulty()) {
case PEACEFUL -> 0.0f;
case EASY -> 3.5f;
case NORMAL -> 7.0f;
case HARD -> 10.5f;
};
var power = size / 2.0f;
var damage = (float) Math.floor((impact * impact + impact) * m * power + 1.0f);
if (entity == null) {
damageComponent.attack(DamageContainer.blockExplosion(damage));
} else {
Expand Down

0 comments on commit 294f5fb

Please sign in to comment.