Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creative inventory has no nbt items #863

Closed
Flonja opened this issue Apr 21, 2024 · 1 comment
Closed

Creative inventory has no nbt items #863

Flonja opened this issue Apr 21, 2024 · 1 comment

Comments

@Flonja
Copy link
Contributor

Flonja commented Apr 21, 2024

Research

What the user sees

image
image

What debugging will do

In server/item/creative.go:

func init() {
	var m []creativeItemEntry
	if err := nbt.Unmarshal(creativeItemData, &m); err != nil {
		panic(err)
	}
+	var genericSliceThatShouldntGetMoreAttentionThanItNeeds []any
+	if err := nbt.Unmarshal(creativeItemData, &genericSliceThatShouldntGetMoreAttentionThanItNeeds); err != nil {
+		panic(err)
+	}
+	for i, data := range m {
-	for _, data := range m {
		if n, ok := it.(world.NBTer); ok {
			if len(data.NBT) > 0 {
				it = n.DecodeNBT(data.NBT).(world.Item)
			}
		}

		st := item.NewStack(it, 1)
+		if _, ok := it.(item.EnchantedBook); ok {
+			fmt.Printf("%v: %#v\n", i, genericSliceThatShouldntGetMoreAttentionThanItNeeds[i])
+		}
		if len(data.NBT) > 0 {
			var invalid bool

Will result in:

1452: map[string]interface {}{"meta":0, "name":"minecraft:enchanted_book", "nbt":map[string]interface {}{}}

...
(For the sake of simplicity, I cut all the in between since its all the same anyway...)
...

1561: map[string]interface {}{"meta":0, "name":"minecraft:enchanted_book", "nbt":map[string]interface {}{}}

Clearly there was intended to be nbt there, but it never got assigned(?)

@TwistedAsylumMC
Copy link
Member

Fixed in 223f136

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

No branches or pull requests

2 participants