From 5eb7eee7756dfced2881821416f009668ee21116 Mon Sep 17 00:00:00 2001 From: jimchen5209 Date: Thu, 25 Apr 2024 23:27:06 +0800 Subject: [PATCH] fix: common itemStack nbts --- .../galaxy/block/entity/HarvestBlockEntity.kt | 4 ++-- src/main/kotlin/one/oktw/galaxy/gui/GUI.kt | 2 +- .../kotlin/one/oktw/galaxy/item/CustomItem.kt | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/kotlin/one/oktw/galaxy/block/entity/HarvestBlockEntity.kt b/src/main/kotlin/one/oktw/galaxy/block/entity/HarvestBlockEntity.kt index f5a36cd3b..9998f3e9f 100644 --- a/src/main/kotlin/one/oktw/galaxy/block/entity/HarvestBlockEntity.kt +++ b/src/main/kotlin/one/oktw/galaxy/block/entity/HarvestBlockEntity.kt @@ -104,7 +104,7 @@ class HarvestBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: Ite if (originItem.isEmpty) { setStack(slot, item) break - } else if (originItem.count < originItem.maxCount && ItemStack.canCombine(originItem, item)) { + } else if (originItem.count < originItem.maxCount && ItemStack.areItemsAndComponentsEqual(originItem, item)) { val count = item.count.coerceAtMost(originItem.maxCount - originItem.count) item.decrement(count) originItem.increment(count) @@ -112,7 +112,7 @@ class HarvestBlockEntity(type: BlockEntityType<*>, pos: BlockPos, modelItem: Ite } } } - if (tool.damage(1, world.random, null)) { + tool.damage(1, world.random, null) { tool.decrement(1) tool.damage = 0 } diff --git a/src/main/kotlin/one/oktw/galaxy/gui/GUI.kt b/src/main/kotlin/one/oktw/galaxy/gui/GUI.kt index c7b6ba0b5..0fb4dccbf 100644 --- a/src/main/kotlin/one/oktw/galaxy/gui/GUI.kt +++ b/src/main/kotlin/one/oktw/galaxy/gui/GUI.kt @@ -265,7 +265,7 @@ class GUI private constructor(private val type: ScreenHandlerType acc or i }) // ALL - putInt("CustomModelData", modelData) - putBoolean("Unbreakable", true) - put("AttributeModifiers", NbtList()) - } - setCustomName(this@CustomItem.getName()) + set(DataComponentTypes.CUSTOM_MODEL_DATA, CustomModelDataComponent(modelData)) + set(DataComponentTypes.UNBREAKABLE, UnbreakableComponent(false)) + set(DataComponentTypes.ATTRIBUTE_MODIFIERS, AttributeModifiersComponent(listOf(), false)) + set(DataComponentTypes.CUSTOM_NAME, this@CustomItem.getName()) writeCustomNbt(getOrCreateSubNbt("GalaxyData")) }.also { if (cacheable) cacheItemStack = it.copy() } }