Skip to content

fix colour of placed banners in 1.13+#5569

Open
mjagdis wants to merge 2 commits intocuberite:masterfrom
mjagdis:placedbanners
Open

fix colour of placed banners in 1.13+#5569
mjagdis wants to merge 2 commits intocuberite:masterfrom
mjagdis:placedbanners

Conversation

@mjagdis
Copy link
Contributor

@mjagdis mjagdis commented Jun 30, 2024

1.13 and later protocols need the banner colour as part of the mapped block id. Currently we don't do that and all placed banners turn white.

I split this into two commits for clarity. The first does the heavy lifting of getting the colour to the right place. The second just renames the type used for block metas from NIBBLETYPE (which it isn't and really never was except that previously only 4 bits got used) to BLOCKMETATYPE. That's currently a Byte (which actually NIBBLETYPE is as well even if it isn't) and we could arguably use Byte instead of BLOCKMETATYPE but it's kinda widespread already and we might need to increase it again one day.

mjagdis added 2 commits June 30, 2024 22:05
It isn't restricted to being a nibble. That's just because it was used
in 1.12 and earlier protocols for rotation/facing data (a 16 bit value).
In 1.13+ protocols meta is, for instance, used to pass the colour of
banners as well as their rotation through the mapping code.

Signed-off-by: Mike Jagdis <[email protected]>
Copy link
Member

@bearbin bearbin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Big changes here, I think this will cause problems for 1.12- as the ChunkDataSerializer has not been modified to take into account 8 bit meta values so banners will be sent with corrupted block type.

Will need to come back and give this a more in-depth review later.

/** The datatype used by block metadata */
typedef unsigned char BLOCKMETATYPE;

/** The datatype used by nibbledata (meta, light, skylight) */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment will need updating.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To what?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChunkDataSerializer sends blocks. They've always had 8 bit metadata of which only 4 bits are used. Nothing has changed there. (Although there may be a case to be argued that it should mask the meta to avoid possible future surprises.)

Banners aren't blocks though. They're block entities. Block entities are responsible for their own updates via SendUpdateBlockEntity and SendBlockChange.

SendUpdateBlockEntity isn't affected. There are no material changes and banner colour is always sent as an int value in the NBT blob.

SendBlockChange is the one that uses meta. >= 1.13 uses the given meta as-is (colour and rotation where the colour part gets promoted into the mapped block id), < 1.13 masks to get only the lowest 4 bits (rotation).

So all is fine. (Or at least: it works for me :-) )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or, to put it another way, block meta and block entity meta aren't quite the same. The chunk holds the block type (standing banner or wall banner) and a meta that represents the rotation. Block entities take a copy of that and pass their version through the update entity protocol path. In the case of banners the meta is modified to include colour so that the block id mapping can do the right thing. The meta in the chunk is fixed when the block is placed and entities never write their copy back to the chunk.

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.

2 participants