Skip to content

Add NBT (de)serialize for 1.13+ protocols#5567

Open
mjagdis wants to merge 1 commit intocuberite:masterfrom
mjagdis:nbthandling
Open

Add NBT (de)serialize for 1.13+ protocols#5567
mjagdis wants to merge 1 commit intocuberite:masterfrom
mjagdis:nbthandling

Conversation

@mjagdis
Copy link
Contributor

@mjagdis mjagdis commented Jun 23, 2024

Fixes #5566

Protocols for 1.13 and later clients need to send/receive metadata as blocks of NBT.

Map creation when an empty map is used needs to refresh potentially affected inventory slots because the client makes some bad predictions about how they might change.

@Janmm14
Copy link
Contributor

Janmm14 commented Jun 23, 2024

Are you positive its a specific issue just with map # 0 ?

@mjagdis
Copy link
Contributor Author

mjagdis commented Jun 23, 2024

It's not specific to map 0 as such. What happens is that when you right click an empty map the client goes, "ah, a map is being added, empty maps - 1, add a new map, uh, oh, maybe... 0?" and adds a "Map #0" to the inventory. That happens (visibly) before HandlePacketUseItem even gets called on the server. The server then does the right thing, allocates a new map number, creates the item, adds it to the inventory and sends the client a SetSlot to tell it what happened. But the client's predicted map 0 went "somewhere" - maybe stacked with another "Map #0", maybe into an empty slot. So we need to tell the client what SHOULD be in any slot we know is either empty or has one or more "Map #0"s. One of them is wrong on the client but we don't know which one :-(

The 1.13 problem, ah, "enhances" that because if the client doesn't get the map number in item NBT data it thinks every map is #0 - even the ones correctly added by the server. Even more entertaining is that if you don't parse NBT on item data received by HandlePacketCreativeAction then the as soon as you open the inventory in creative mode the server becomes persuaded that all your maps are #0 too! Passing NBT backwards and forwards probably also fixes, or at least heps with, other issues with damage, repair costs, custom name and other stuff.

Interesting times, huh?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Creating a map dups map #0

2 participants