From 61a36373c0c634033feaaad21780239bc5ead118 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Tue, 30 Apr 2024 16:42:43 -0700 Subject: [PATCH] Fixes beds not exploding in the nether Also correctly marks the captured BlockState as "unplaced" Fixes #10629 --- ...ck-state-to-EntityDamageByBlockEvent.patch | 45 +++++++++++++++++-- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/patches/server/Add-exploded-block-state-to-EntityDamageByBlockEvent.patch b/patches/server/Add-exploded-block-state-to-EntityDamageByBlockEvent.patch index b3fde36100..d0e1c929d7 100644 --- a/patches/server/Add-exploded-block-state-to-EntityDamageByBlockEvent.patch +++ b/patches/server/Add-exploded-block-state-to-EntityDamageByBlockEvent.patch @@ -17,16 +17,53 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @Deprecated @io.papermc.paper.annotation.DoNotUse // Paper - add exploded state public DamageSource badRespawnPointExplosion(Vec3 position) { // CraftBukkit start - return this.badRespawnPointExplosion(position, null, null, null); -@@ -0,0 +0,0 @@ public class DamageSources { - public DamageSource badRespawnPointExplosion(Vec3 vec3d, net.minecraft.world.level.Level world, net.minecraft.world.level.block.state.BlockState blockData, net.minecraft.core.BlockPos position) { +- return this.badRespawnPointExplosion(position, null, null, null); ++ return this.badRespawnPointExplosion(position, null, null, null, null); // Paper - pass possible BlockEntity + } + +- public DamageSource badRespawnPointExplosion(Vec3 vec3d, net.minecraft.world.level.Level world, net.minecraft.world.level.block.state.BlockState blockData, net.minecraft.core.BlockPos position) { ++ public DamageSource badRespawnPointExplosion(Vec3 vec3d, net.minecraft.world.level.Level world, net.minecraft.world.level.block.state.BlockState blockData, net.minecraft.core.BlockPos position, @Nullable net.minecraft.world.level.block.entity.BlockEntity blockEntity) { // Paper - pass possible BlockEntity DamageSource damageSource = new DamageSource(this.damageTypes.getHolderOrThrow(DamageTypes.BAD_RESPAWN_POINT), vec3d); if (world != null && blockData != null && position != null) { - damageSource.blockState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(world, position, blockData, null); -+ damageSource.blockState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(world.getWorld(), position, blockData, world.getBlockEntity(position)); // Paper ++ damageSource.blockState = org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(null, position, blockData, blockEntity); // Paper - pass possible BlockEntity (null world for unplaced) } return damageSource; // CraftBukkit end +diff --git a/src/main/java/net/minecraft/world/level/block/BedBlock.java b/src/main/java/net/minecraft/world/level/block/BedBlock.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/block/BedBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/BedBlock.java +@@ -0,0 +0,0 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock + private InteractionResult explodeBed(BlockState iblockdata, Level world, BlockPos blockposition) { + { + { ++ final BlockEntity blockEntity = world.getBlockEntity(blockposition); // Paper - capture BlockEntity + world.removeBlock(blockposition, false); + BlockPos blockposition1 = blockposition.relative(((Direction) iblockdata.getValue(BedBlock.FACING)).getOpposite()); + +@@ -0,0 +0,0 @@ public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock + + Vec3 vec3d = blockposition.getCenter(); + +- world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, world, iblockdata, blockposition), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state ++ world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, world, iblockdata, blockposition, blockEntity), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state // Paper - add BlockEntity + return InteractionResult.SUCCESS; + } + } +diff --git a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/RespawnAnchorBlock.java +@@ -0,0 +0,0 @@ public class RespawnAnchorBlock extends Block { + }; + Vec3 vec3d = explodedPos.getCenter(); + +- world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, world, state, explodedPos), explosiondamagecalculator, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state ++ world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d, world, state, explodedPos, null), explosiondamagecalculator, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK); // CraftBukkit - add state // Paper + } + + public static boolean canSetSpawn(Level world) { diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java