-
Bug
-
Resolution: Unresolved
-
None
-
1.16.5, 21w15a, 21w16a, 21w18a, 21w19a, 21w20a, 1.17.1, 1.18.1, 1.18.2, 1.19, 1.19.2, 1.19.3, 1.19.4, 1.20.1, 1.21
-
Confirmed
-
Block states
The Bug:
You can place the upper halves of beds into spawn protection.
Steps to Reproduce:
- Start a server, join it, give operator permissions to yourself, and switch into creative mode.
- Set the world spawn to your current location by using the command provided below.
/setworldspawn ~ ~ ~
- Locate the edge of spawn protection and obtain a bed.
- Switch into survival mode, remove your operator permissions, and grant anyone else with them in order to activate spawn protection.
- Place the bed adjacent to, but not inside of spawn protection.
- Take note as to whether or not you can place the upper halves of beds into spawn protection.
Observed Behavior:
You can place the upper halves of beds into spawn protection.
Expected Behavior:
You would not be able to place the upper halves of beds into spawn protection.
Code Analysis:
Code analysis by Avoma can be found below.
The following is based on a decompiled version of Minecraft 1.18.1 using MCP-Reborn.
net.minecraft.world.level.block.BedBlock.java
public class BedBlock extends HorizontalDirectionalBlock implements EntityBlock { ... public BlockState getStateForPlacement(BlockPlaceContext $bpc) { Direction direction = $bpc.getHorizontalDirection(); BlockPos blockpos = $bpc.getClickedPos(); BlockPos blockpos1 = blockpos.relative(direction); Level level = $bpc.getLevel(); return level.getBlockState(blockpos1).canBeReplaced($bpc) && level.getWorldBorder().isWithinBounds(blockpos1) ? this.defaultBlockState().setValue(FACING, direction) : null; } ...
If we look at the above class, we can see that before a bed is placed, two checks are carried out. These two checks are as follows:
- Is the block that the upper half of the bed will occupy a replaceable block?
- Is the block that the upper half of the bed will occupy within the world border?
Currently, no checks are carried out to see whether or not the block that the upper half of the bed will occupy is inside of spawn protection, and because of this, you can place the upper halves of beds into spawn protection.