feat: update Minestom version and replace deprecated ItemComponent API

Updated the Minestom library to version 1_21_5-69b9a5d844 and migrated from the deprecated `ItemComponent` API to `DataComponents`. This ensures compatibility with the latest changes and improves maintainability.
This commit is contained in:
Christian Bergschneider 2025-05-27 23:25:34 +02:00
parent 1dd59c378e
commit 089b25dea4
No known key found for this signature in database
GPG Key ID: 3991F97F5FA28D3E
2 changed files with 4 additions and 4 deletions

View File

@ -84,6 +84,6 @@ object Versions {
}
object Minestom {
const val minestom = "fb895cb899"
const val minestom = "1_21_5-69b9a5d844"
}
}

View File

@ -6,7 +6,7 @@ import com.dfsek.terra.api.inventory.item.Enchantment;
import com.dfsek.terra.api.inventory.item.ItemMeta;
import net.minestom.server.MinecraftServer;
import net.minestom.server.item.ItemComponent;
import net.minestom.server.component.DataComponents;
import net.minestom.server.item.ItemStack;
import net.minestom.server.item.component.EnchantmentList;
import net.minestom.server.registry.DynamicRegistry;
@ -47,7 +47,7 @@ public class MinestomItemStack implements com.dfsek.terra.api.inventory.ItemStac
@Override
public ItemMeta getItemMeta() {
HashMap<Enchantment, Integer> enchantments = new HashMap<>();
EnchantmentList enchantmentList = base.get(ItemComponent.ENCHANTMENTS);
EnchantmentList enchantmentList = base.get(DataComponents.ENCHANTMENTS);
if(enchantmentList != null) {
enchantmentList.enchantments().forEach((enchantmentKey, integer) -> {
enchantments.put(
@ -67,6 +67,6 @@ public class MinestomItemStack implements com.dfsek.terra.api.inventory.ItemStac
});
EnchantmentList list = new EnchantmentList(enchantments);
base = base.with(ItemComponent.ENCHANTMENTS, list);
base = base.with(DataComponents.ENCHANTMENTS, list);
}
}