mojira.dev
MC-99075

Cancelled block place (spawn protection) causes inventory desync

The bug

Enable spawn protection. Attempt to place a block. The block will not place, however it will be removed from your inventory. Relog, or click the empty slot and it will reappear.

With recent (1.15 snapshots) changes moving item usage to the client-side as well to get correct arm movement, this affects even more items, e.g. fire charges used to ignite camp fires.

Code analysis

Code analysis by @unknown can be found in this comment.

Related issues

Comments

marcono1234

The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.

The method net.minecraft.network.NetHandlerPlayServer.func_184337_a(CPacketPlayerTryUseItem) should probably synchronize the player inventory based on the returned EnumActionResult by the call to the method net.minecraft.server.management.PlayerInteractionManager.func_187251_a(EntityPlayer, World, ItemStack, EnumHand, BlockPos, EnumFacing, float, float, float), or if it fails because for example the spawn protection prevents placing blocks.

This desync is normally only visible if the spawn protection prevents placing a block because this is only tested server-side. Placing a block behind the worldborder or above the build limit is tested client-side as well. The latter situations can create desync if the client receives changes to the worldborder too late or if the built height is lower than the default one (this creates block desync for breaking blocks as well).

But I guess @unknown knows more about this

migrated

How do you enable spawn protection? Also, is this in survival mode?

migrated

it's only in a server's propperties, and effects non-ops, no matter what gamemode

marcono1234

And there has to be at least one op, see @unknown's tweet

wobst.michael

Is this still an issue in the most recent versions (currently that is 1.12.2, or the latest 1.13 pre-release) of Minecraft?

Uriel Salischiker

Is this still a issue in the latest version of the game(currently 1.13.1)?

If so, please add it to the affected versions, thanks!

migrated

Affects 20w51a
Placing a candle on a cake in spawn protection will also desync (separate from MC-205212).

migrated

Confirmed for 1.17.1.

Avoma

Can confirm in 1.18.1.

Avoma

Can confirm in 1.18.2 and 22w15a.

Avoma

Can confirm in 1.19.

Avoma

Can confirm in 1.19.2.

Machine Maker

Still happens in 1.21.1

md_5

(Unassigned)

Confirmed

Platform

Important

Networking

desync, spawn-protection

Minecraft 1.9, Minecraft 1.10.2, Minecraft 1.13.1, Minecraft 1.13.2, Minecraft 18w48a, ..., 1.19.3, 1.19.4, 1.20.1, 1.21, 1.21.4

Retrieved