Skip to content

Commit 28a0b08

Browse files
authored
implement reading of unbreakable value (#1)
1 parent 550cb1b commit 28a0b08

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

server/internal/nbtconv/read.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ func MapItem(x map[string]any, k string) item.Stack {
152152
readEnchantments(tag, &s)
153153
readDisplay(tag, &s)
154154
readDragonflyData(tag, &s)
155+
readUnbreakable(tag, &s)
155156
return s
156157
}
157158
return item.Stack{}
@@ -176,6 +177,7 @@ func Item(data map[string]any, s *item.Stack) item.Stack {
176177
readDisplay(tag, s)
177178
readDragonflyData(tag, s)
178179
readEnchantments(tag, s)
180+
readUnbreakable(tag, s)
179181
return *s
180182
}
181183

@@ -281,3 +283,9 @@ func readDragonflyData(m map[string]any, s *item.Stack) {
281283
}
282284
}
283285
}
286+
287+
// readDamage reads the unbreakable value stored in the NBT with the Unbreakable tag and saves it to the item.Stack
288+
// passed.
289+
func readUnbreakable(m map[string]any, s *item.Stack) {
290+
*s = s.WithUnbreakable(Bool(m, "Unbreakable"))
291+
}

0 commit comments

Comments
 (0)