--- a/net/minecraft/world/level/block/BlockBed.java +++ b/net/minecraft/world/level/block/BlockBed.java @@ -94,7 +94,8 @@ } } - if (!canSetSpawn(world)) { + // CraftBukkit - moved world and biome check into EntityHuman + if (false && !canSetSpawn(world)) { world.removeBlock(blockposition, false); BlockPosition blockposition1 = blockposition.relative(((EnumDirection) iblockdata.getValue(BlockBed.FACING)).getOpposite()); @@ -113,7 +114,16 @@ return EnumInteractionResult.SUCCESS; } else { + // CraftBukkit start + IBlockData finaliblockdata = iblockdata; + BlockPosition finalblockposition = blockposition; + // CraftBukkit end entityhuman.startSleepInBed(blockposition).ifLeft((entityhuman_enumbedresult) -> { + // CraftBukkit start - handling bed explosion from below here + if (!world.dimensionType().bedWorks()) { + this.explodeBed(finaliblockdata, world, finalblockposition); + } else + // CraftBukkit end if (entityhuman_enumbedresult.getMessage() != null) { entityhuman.displayClientMessage(entityhuman_enumbedresult.getMessage(), true); } @@ -124,8 +134,29 @@ } } + // CraftBukkit start + private EnumInteractionResult explodeBed(IBlockData iblockdata, World world, BlockPosition blockposition) { + { + { + world.removeBlock(blockposition, false); + BlockPosition blockposition1 = blockposition.relative(((EnumDirection) iblockdata.getValue(BlockBed.FACING)).getOpposite()); + + if (world.getBlockState(blockposition1).getBlock() == this) { + world.removeBlock(blockposition1, false); + } + + Vec3D vec3d = blockposition.getCenter(); + + world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, World.a.BLOCK); + return EnumInteractionResult.SUCCESS; + } + } + } + // CraftBukkit end + public static boolean canSetSpawn(World world) { - return world.dimensionType().bedWorks(); + // CraftBukkit - moved world and biome check into EntityHuman + return true || world.dimensionType().bedWorks(); } private boolean kickVillagerOutOfBed(World world, BlockPosition blockposition) { @@ -324,6 +355,11 @@ BlockPosition blockposition1 = blockposition.relative((EnumDirection) iblockdata.getValue(BlockBed.FACING)); world.setBlock(blockposition1, (IBlockData) iblockdata.setValue(BlockBed.PART, BlockPropertyBedPart.HEAD), 3); + // CraftBukkit start - SPIGOT-7315: Don't updated if we capture block states + if (world.captureBlockStates) { + return; + } + // CraftBukkit end world.blockUpdated(blockposition, Blocks.AIR); iblockdata.updateNeighbourShapes(world, blockposition, 3); }