From 21539d859d3ec74a35e176dcd95256367e6543ea Mon Sep 17 00:00:00 2001 From: jimchen5209 Date: Sun, 16 Jun 2024 13:25:41 +0800 Subject: [PATCH] Revert "refactor: change nbt naming style to snake" This reverts commit c3fc180e68b20dfeb24cb7adfcc7b3ff794ae71e. --- src/main/kotlin/one/oktw/galaxy/item/CustomItem.kt | 6 +++--- src/main/kotlin/one/oktw/galaxy/item/CustomItemHelper.kt | 4 ++-- src/main/kotlin/one/oktw/galaxy/item/Tool.kt | 4 ++-- src/main/kotlin/one/oktw/galaxy/item/Weapon.kt | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/kotlin/one/oktw/galaxy/item/CustomItem.kt b/src/main/kotlin/one/oktw/galaxy/item/CustomItem.kt index a3e9e7d4c..bcc6c7cf8 100644 --- a/src/main/kotlin/one/oktw/galaxy/item/CustomItem.kt +++ b/src/main/kotlin/one/oktw/galaxy/item/CustomItem.kt @@ -52,11 +52,11 @@ abstract class CustomItem(override val identifier: Identifier, private val baseI abstract fun getName(): Text? open fun writeCustomNbt(nbt: NbtCompound) { - nbt.putString("custom_item_identifier", identifier.toString()) + nbt.putString("CustomItemIdentifier", identifier.toString()) } open fun readCustomNbt(nbt: NbtCompound): CustomItem { - require(nbt.getString("custom_item_identifier") == identifier.toString()) + require(nbt.getString("CustomItemIdentifier") == identifier.toString()) return this } @@ -75,7 +75,7 @@ abstract class CustomItem(override val identifier: Identifier, private val baseI writeCustomNbt(galaxyNbt) apply(DataComponentTypes.CUSTOM_DATA, NbtComponent.DEFAULT) { component -> component.apply { nbt -> - nbt.put("galaxy_data", galaxyNbt) + nbt.put("GalaxyData", galaxyNbt) } } }.also { if (cacheable) cacheItemStack = it.copy() } diff --git a/src/main/kotlin/one/oktw/galaxy/item/CustomItemHelper.kt b/src/main/kotlin/one/oktw/galaxy/item/CustomItemHelper.kt index dea27c17e..0dad44e18 100644 --- a/src/main/kotlin/one/oktw/galaxy/item/CustomItemHelper.kt +++ b/src/main/kotlin/one/oktw/galaxy/item/CustomItemHelper.kt @@ -27,13 +27,13 @@ import net.minecraft.util.Identifier object CustomItemHelper { fun getNbt(itemStack: ItemStack): NbtCompound { val galaxyData = (itemStack.get(DataComponentTypes.CUSTOM_DATA) ?: NbtComponent.DEFAULT).copyNbt() - return galaxyData.getCompound("galaxy_data") + return galaxyData.getCompound("GalaxyData") } fun getItem(itemStack: ItemStack): CustomItem? { val customNbt = getNbt(itemStack) - return customNbt.getString("custom_item_identifier")?.let(Identifier::tryParse) + return customNbt.getString("CustomItemIdentifier")?.let(Identifier::tryParse) ?.let(CustomItem.registry::get) ?.run { readCustomNbt(customNbt) } } diff --git a/src/main/kotlin/one/oktw/galaxy/item/Tool.kt b/src/main/kotlin/one/oktw/galaxy/item/Tool.kt index b21c1627b..6dba40fe0 100644 --- a/src/main/kotlin/one/oktw/galaxy/item/Tool.kt +++ b/src/main/kotlin/one/oktw/galaxy/item/Tool.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2024 + * Copyright (C) 2018-2023 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -39,6 +39,6 @@ class Tool private constructor(id: String, modelData: Int, private val name: Str override fun writeCustomNbt(nbt: NbtCompound) { super.writeCustomNbt(nbt) - nbt.put("tool_data", NbtCompound().apply { putUuid("id", MathHelper.randomUuid()) }) + nbt.put("ToolData", NbtCompound().apply { putUuid("id", MathHelper.randomUuid()) }) } } diff --git a/src/main/kotlin/one/oktw/galaxy/item/Weapon.kt b/src/main/kotlin/one/oktw/galaxy/item/Weapon.kt index 580aa78bd..7351ec435 100644 --- a/src/main/kotlin/one/oktw/galaxy/item/Weapon.kt +++ b/src/main/kotlin/one/oktw/galaxy/item/Weapon.kt @@ -1,6 +1,6 @@ /* * OKTW Galaxy Project - * Copyright (C) 2018-2024 + * Copyright (C) 2018-2022 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published @@ -61,6 +61,6 @@ class Weapon private constructor(id: String, modelData: Int, private val name: S override fun writeCustomNbt(nbt: NbtCompound) { super.writeCustomNbt(nbt) - nbt.put("weapon_data", NbtCompound().apply { putUuid("id", MathHelper.randomUuid()) }) + nbt.put("WeaponData", NbtCompound().apply { putUuid("id", MathHelper.randomUuid()) }) } }