Skip to content

Commit

Permalink
session/player.go: Strip NBT from blocks in the creative inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
DaPigGuy committed Dec 19, 2024
1 parent 9def5fd commit c98e0e5
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion server/session/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,9 +827,27 @@ func stacksToIngredientItems(inputs []recipe.Item) []protocol.ItemDescriptorCoun
func creativeItems() []protocol.CreativeItem {
it := make([]protocol.CreativeItem, 0, len(creative.Items()))
for index, i := range creative.Items() {
st := deleteDamage(stackFromItem(i))
// Strip block entity NBT from creative item entries. NBT causes issues
// with the creative inventory item groups for blocks such as signs and
// skulls.
if b, ok := i.Item().(world.Block); ok {
if nbt, ok := b.(world.NBTer); ok {
for k := range nbt.EncodeNBT() {
delete(st.NBTData, k)
}

// Banner items are still expected to have the Type NBT tag, while
// the other tags are discarded.
if banner, ok := b.(block.Banner); ok {
st.NBTData["Type"] = int32(boolByte(banner.Illager))
}
}
}

it = append(it, protocol.CreativeItem{
CreativeItemNetworkID: uint32(index) + 1,
Item: deleteDamage(stackFromItem(i)),
Item: st,
})
}
return it
Expand Down

0 comments on commit c98e0e5

Please sign in to comment.