The Bug:
Blocks can be placed outside of the world border by placing them against other blocks within the world border.
Steps to Reproduce:
Set the world border's center to your current position and to seven blocks wide by using the commands provided below
/worldborder center ~ ~
/worldborder set 7
Place a fence directly adjacent to the edge of the world border.
While looking at the side face of the fence that's facing the world border, attempt to place another fence.
Take note as to whether or not blocks can be placed outside of the world border by placing them against other blocks within the world border.
Observed Behavior:
The fence is placed outside of the world border.
Expected Behavior:
Blocks would not be able to be placed outside of the world border at all, regardless of the block they are placed against.
Code Analysis:
Code analysis by @unknown can be found below.
The following is based on a decompiled version of Minecraft 1.16.5 using MCP.
The problem is that the only check for not placing a block outside the border makes sure the position being targeted when the block is placed/an item is used is not outside the border, which doesn't prevent blocks from being placed when used on the side of other blocks that have hitboxes that don't extend to the border's side. At net.minecraft.item.BlockItem
in the placeBlock
method a check can be added to prevent the block being set if it is outside the world border. The check should be placed there in order to maintain other functionalities such as /setblock
outside the border.
Linked issues
is duplicated by 2
Attachments
Comments 7
Can confirm in 21w11a.
Can confirm in 21w17a.
Can confirm in 1.17.1.
Can confirm in 1.18.1.

Can confirm in 23w03a

Can confirm in 1.20.3 rc-1
I can confirm in 21w08b and 1.16.5. I have attached a video.
How to reproduce
Teleport to the world border (
/tp @s 29999980 ~ ~
)Stand facing away from the world border, then place a trapdoor at your feet
Open the trapdoor
Shift-click a block onto the side of the trapdoor facing toward the world border
❌ The block is successfully placed outside of the world border