Skip to content

Commit 7776a2f

Browse files
committed
fix item_tags component
1 parent b92621a commit 7776a2f

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

utils/behaviourpack/item.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (bp *Pack) AddItem(item protocol.ItemEntry) {
4141
}
4242
}
4343

44-
func processItemComponent(name string, component map[string]any, componentsOut map[string]any) (string, any) {
44+
func processItemComponent(name string, component map[string]any, componentsOut map[string]any, minVersion *string) (string, any) {
4545
switch name {
4646
case "item_properties":
4747
if icon, ok := component["minecraft:icon"].(map[string]any); ok {
@@ -65,11 +65,17 @@ func processItemComponent(name string, component map[string]any, componentsOut m
6565
return name, component["interact_text"]
6666

6767
case "item_tags":
68-
return "", nil
68+
return name, component
6969

7070
case "minecraft:durability":
7171
return name, component
7272

73+
case "minecraft:dyeable":
74+
if *minVersion < "1.21.30" {
75+
*minVersion = "1.21.30"
76+
}
77+
return name, component
78+
7379
default:
7480
if utils.IsDebug() {
7581
fmt.Printf("unhandled component %s\n%v\n\n", name, component)
@@ -87,12 +93,20 @@ func (bp *Pack) ApplyComponentEntries(entries []protocol.ItemEntry) {
8793
if components, ok := ice.Data["components"].(map[string]any); ok {
8894
var componentsOut = make(map[string]any)
8995
for name, component := range components {
96+
if name == "item_tags" {
97+
if componentSlice, ok := component.([]any); ok {
98+
component = map[string]any{
99+
"tags": componentSlice,
100+
}
101+
}
102+
}
103+
90104
componentMap, ok := component.(map[string]any)
91105
if !ok {
92106
fmt.Printf("skipped component %s %v\n", name, component)
93107
continue
94108
}
95-
nameOut, value := processItemComponent(name, componentMap, componentsOut)
109+
nameOut, value := processItemComponent(name, componentMap, componentsOut, &item.FormatVersion)
96110
if name == "" {
97111
continue
98112
}

0 commit comments

Comments
 (0)