Fix a couple of upstream bed issues

Upstream incorrectly skipped explosion logic if
the bed was occupied and added a "feature" where
if you set your spawn in a respawn anchor world
but then replaced it with a bed, you could respawn
at the bed in that world.
This commit is contained in:
Jake Potrebic 2023-04-09 21:11:58 -07:00
parent 8e6779e8e9
commit 988f9ed56f

View File

@ -10,7 +10,14 @@
world.removeBlock(pos, false);
BlockPos blockposition1 = pos.relative(((Direction) state.getValue(BedBlock.FACING)).getOpposite());
@@ -114,19 +115,59 @@
@@ -108,25 +109,65 @@
world.explode((Entity) null, world.damageSources().badRespawnPointExplosion(vec3d), (ExplosionDamageCalculator) null, vec3d, 5.0F, true, Level.ExplosionInteraction.BLOCK);
return InteractionResult.SUCCESS_SERVER;
} else if ((Boolean) state.getValue(BedBlock.OCCUPIED)) {
+ if (!BedBlock.canSetSpawn(world)) return this.explodeBed(state, world, pos); // Paper - check explode first
if (!this.kickVillagerOutOfBed(world, pos)) {
player.displayClientMessage(Component.translatable("block.minecraft.bed.occupied"), true);
}
return InteractionResult.SUCCESS_SERVER;
} else {
@ -67,8 +74,7 @@
public static boolean canSetSpawn(Level world) {
- return world.dimensionType().bedWorks();
+ // CraftBukkit - moved world and biome check into EntityHuman
+ return true || world.dimensionType().bedWorks();
+ return world.dimensionType().bedWorks(); // Paper - actually check if the bed works
}
private boolean kickVillagerOutOfBed(Level world, BlockPos pos) {