From c86267599940b95f652a88b64e4af589c10afd5b Mon Sep 17 00:00:00 2001
From: sylvessa <225480449+sylvessa@users.noreply.github.com>
Date: Sat, 18 Apr 2026 14:31:19 -0500
Subject: [PATCH] fix disenchant bugs from setdurability etc
---
Minecraft.Server.FourKit/Inventory/Meta/ItemMeta.cs | 2 +-
Minecraft.Server/FourKitNatives.cpp | 12 +++++-------
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/Minecraft.Server.FourKit/Inventory/Meta/ItemMeta.cs b/Minecraft.Server.FourKit/Inventory/Meta/ItemMeta.cs
index 60ba224cf..d9913a428 100644
--- a/Minecraft.Server.FourKit/Inventory/Meta/ItemMeta.cs
+++ b/Minecraft.Server.FourKit/Inventory/Meta/ItemMeta.cs
@@ -154,7 +154,7 @@ public class ItemMeta
/// The enchantments to set.
public void setEnchants(Dictionary? enchants)
{
- enchants = enchants != null ? new Dictionary(enchants) : null;
+ _enchants = enchants != null ? new Dictionary(enchants) : null;
}
diff --git a/Minecraft.Server/FourKitNatives.cpp b/Minecraft.Server/FourKitNatives.cpp
index 1c522f40b..a79d53f36 100644
--- a/Minecraft.Server/FourKitNatives.cpp
+++ b/Minecraft.Server/FourKitNatives.cpp
@@ -828,16 +828,14 @@ int __cdecl NativeGetItemMeta(int entityId, int slot, char *outBuf, int bufSize)
return 0;
CompoundTag *tag = item->getTag();
- if (!tag || !tag->contains(L"display"))
- return 0;
-
- CompoundTag *display = tag->getCompound(L"display");
- bool hasName = display->contains(L"Name");
- bool hasLore = display->contains(L"Lore");
bool hasEnchantments = item->isEnchanted();
- if (!hasName && !hasLore)
+ CompoundTag *display = (tag && tag->contains(L"display")) ? tag->getCompound(L"display") : nullptr;
+ bool hasName = display && display->contains(L"Name");
+ bool hasLore = display && display->contains(L"Lore");
+
+ if (!hasName && !hasLore && !hasEnchantments)
return 0;
int offset = 0;