Skip to content

Commit 055dd85

Browse files
committed
Fix wrong visual explosion size due to missing deduplication
Relates to #696
1 parent 2a7dfb6 commit 055dd85

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

common/src/main/java/net/caffeinemc/mods/lithium/mixin/world/explosions/block_raycast/ServerExplosionMixin.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public abstract class ServerExplosionMixin {
8787
@Unique
8888
private boolean explodeAirBlocks;
8989
@Unique
90-
private int explodedPositions; //Vanilla uses the number of exploded blocks, which is reduced by the air block optimization
90+
private LongOpenHashSet explodedPositions; //Vanilla uses the number of exploded blocks, which is reduced by the air block optimization. Deduplication using a hashset is necessary as different explosion rays traverse the same blocks.
9191

9292
@Unique
9393
private int bottomY, topY;
@@ -111,6 +111,8 @@ private void init(ServerLevel serverLevel, Entity entity, DamageSource damageSou
111111
}
112112
}
113113
this.explodeAirBlocks = explodeAir;
114+
115+
this.explodedPositions = new LongOpenHashSet();
114116
}
115117

116118
@SuppressWarnings("unchecked")
@@ -134,7 +136,7 @@ public int skipLoop(int prevValue) {
134136
method = "explode", at = @At(value = "INVOKE", target = "Ljava/util/List;size()I")
135137
)
136138
private int getExplodedPositionCount(List<?> instance) {
137-
return this.explodedPositions;
139+
return this.explodedPositions.size();
138140
}
139141

140142
/**
@@ -310,10 +312,11 @@ private float traverseBlock(float strength, int blockX, int blockY, int blockZ,
310312
// of positions to destroy
311313
float reducedStrength = strength - totalResistance;
312314
if (reducedStrength > 0.0F) {
313-
this.explodedPositions++;
315+
long posLong = pos.asLong();
316+
this.explodedPositions.add(posLong);
314317
if (this.explodeAirBlocks || !blockState.isAir()) {
315318
if (this.damageCalculator.shouldBlockExplode((Explosion) (Object) this, this.level, pos, blockState, reducedStrength)) {
316-
touched.add(pos.asLong());
319+
touched.add(posLong);
317320
}
318321
}
319322
}

0 commit comments

Comments
 (0)