Revert "Always pass event block to damage source (#12158)"

This reverts commit ab984a0711e55ac600dfa12a77430799eadd8ac3.

The block damage is null *and has been* null in cases where the block
has already been cleared. Consumers are supposed to use the
getDamagerBlockState instead.
This commit is contained in:
Bjarne Koll 2025-02-21 11:52:04 +01:00
parent ab984a0711
commit 7b4d44f573
No known key found for this signature in database
GPG Key ID: 9576DAF3FDDB088F
3 changed files with 4 additions and 9 deletions

View File

@ -1,6 +1,6 @@
--- a/net/minecraft/world/damagesource/DamageSource.java --- a/net/minecraft/world/damagesource/DamageSource.java
+++ b/net/minecraft/world/damagesource/DamageSource.java +++ b/net/minecraft/world/damagesource/DamageSource.java
@@ -20,6 +_,97 @@ @@ -20,6 +_,92 @@
private final Entity directEntity; private final Entity directEntity;
@Nullable @Nullable
private final Vec3 damageSourcePosition; private final Vec3 damageSourcePosition;
@ -60,16 +60,11 @@
+ return this.fromBlockSnapshot; + return this.fromBlockSnapshot;
+ } + }
+ +
+ public DamageSource causingBlockSnapshot( + public DamageSource causingBlockSnapshot(final @Nullable org.bukkit.block.BlockState blockState) {
+ final net.minecraft.world.level.LevelAccessor level,
+ final net.minecraft.core.BlockPos pos,
+ final @Nullable org.bukkit.block.BlockState blockState
+ ) {
+ if (this.eventBlockDamager != null) { + if (this.eventBlockDamager != null) {
+ throw new IllegalStateException("Cannot set a block snapshot when an event block damager is already set (report a bug to Paper)"); + throw new IllegalStateException("Cannot set a block snapshot when an event block damager is already set (report a bug to Paper)");
+ } + }
+ final DamageSource damageSource = this.copy(); + final DamageSource damageSource = this.copy();
+ damageSource.eventBlockDamager = org.bukkit.craftbukkit.block.CraftBlock.at(level, pos);
+ damageSource.fromBlockSnapshot = blockState; + damageSource.fromBlockSnapshot = blockState;
+ return damageSource; + return damageSource;
+ } + }

View File

@ -59,7 +59,7 @@
+ } + }
+ +
+ Vec3 center = pos.getCenter(); + Vec3 center = pos.getCenter();
+ level.explode(null, level.damageSources().badRespawnPointExplosion(center).causingBlockSnapshot(level, pos, blockState), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state + level.explode(null, level.damageSources().badRespawnPointExplosion(center).causingBlockSnapshot(blockState), null, center, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state
+ return InteractionResult.SUCCESS_SERVER; + return InteractionResult.SUCCESS_SERVER;
+ } + }
+ // CraftBukkit end + // CraftBukkit end

View File

@ -31,7 +31,7 @@
Vec3 center = pos2.getCenter(); Vec3 center = pos2.getCenter();
level.explode( level.explode(
- null, level.damageSources().badRespawnPointExplosion(center), explosionDamageCalculator, center, 5.0F, true, Level.ExplosionInteraction.BLOCK - null, level.damageSources().badRespawnPointExplosion(center), explosionDamageCalculator, center, 5.0F, true, Level.ExplosionInteraction.BLOCK
+ null, level.damageSources().badRespawnPointExplosion(center).causingBlockSnapshot(level, pos2, blockState), explosionDamageCalculator, center, 5.0F, true, Level.ExplosionInteraction.BLOCK // CraftBukkit - add state + null, level.damageSources().badRespawnPointExplosion(center).causingBlockSnapshot(blockState), explosionDamageCalculator, center, 5.0F, true, Level.ExplosionInteraction.BLOCK // CraftBukkit - add state
); );
} }