From 58b6986f1648be0105355a420a33fa99a9da22d6 Mon Sep 17 00:00:00 2001 From: btwonion Date: Thu, 1 Aug 2024 16:31:28 +0200 Subject: [PATCH] fix enchantment not tradeable in >=1.20.6 --- changelog.md | 2 +- .../telekinesis/TelekinesisEnchantmentGenerator.kt | 11 ++++++++++- .../tags/enchantment/in_enchanting_table.json | 8 ++++++++ .../data/minecraft/tags/enchantment/tradeable.json | 8 ++++++++ .../data/minecraft/tags/enchantment/treasure.json | 8 ++++++++ 5 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 versions/1.21/src/main/generated/data/minecraft/tags/enchantment/in_enchanting_table.json create mode 100644 versions/1.21/src/main/generated/data/minecraft/tags/enchantment/tradeable.json create mode 100644 versions/1.21/src/main/generated/data/minecraft/tags/enchantment/treasure.json diff --git a/changelog.md b/changelog.md index 9b7c41d..ae03e90 100644 --- a/changelog.md +++ b/changelog.md @@ -1 +1 @@ -- fix translations \ No newline at end of file +- fix enchantment not tradeable in >=1.20.6 \ No newline at end of file diff --git a/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantmentGenerator.kt b/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantmentGenerator.kt index ad1e007..33b1225 100644 --- a/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantmentGenerator.kt +++ b/src/main/kotlin/dev/nyon/telekinesis/TelekinesisEnchantmentGenerator.kt @@ -11,6 +11,7 @@ import net.minecraft.core.HolderLookup import net.minecraft.core.registries.Registries import net.minecraft.resources.ResourceKey import net.minecraft.resources.ResourceLocation +import net.minecraft.tags.TagKey import net.minecraft.world.entity.EquipmentSlotGroup import net.minecraft.world.item.enchantment.Enchantment import net.minecraft.world.item.enchantment.Enchantment.EnchantmentDefinition @@ -34,7 +35,15 @@ private class TelekinesisEnchantmentTagProvider( output: FabricDataOutput, completableFuture: CompletableFuture ) : EnchantmentTagProvider(output, completableFuture) { override fun addTags(registries: HolderLookup.Provider) { - getOrCreateTagBuilder(telekinesisEffectId).addOptional(telekinesisEnchantmentId) + fun minecraftTagKey(value: String): TagKey = TagKey.create(Registries.ENCHANTMENT, ResourceLocation.fromNamespaceAndPath("minecraft", value)) + listOf( + getOrCreateTagBuilder(telekinesisEffectId), + getOrCreateTagBuilder(minecraftTagKey("tradeable")), + getOrCreateTagBuilder(minecraftTagKey("treasure")), + getOrCreateTagBuilder(minecraftTagKey("in_enchanting_table")) + ).forEach { + it.add(telekinesisEnchantmentId) + } } } diff --git a/versions/1.21/src/main/generated/data/minecraft/tags/enchantment/in_enchanting_table.json b/versions/1.21/src/main/generated/data/minecraft/tags/enchantment/in_enchanting_table.json new file mode 100644 index 0000000..0d9aebf --- /dev/null +++ b/versions/1.21/src/main/generated/data/minecraft/tags/enchantment/in_enchanting_table.json @@ -0,0 +1,8 @@ +{ + "values": [ + { + "id": "telekinesis:telekinesis", + "required": false + } + ] +} \ No newline at end of file diff --git a/versions/1.21/src/main/generated/data/minecraft/tags/enchantment/tradeable.json b/versions/1.21/src/main/generated/data/minecraft/tags/enchantment/tradeable.json new file mode 100644 index 0000000..0d9aebf --- /dev/null +++ b/versions/1.21/src/main/generated/data/minecraft/tags/enchantment/tradeable.json @@ -0,0 +1,8 @@ +{ + "values": [ + { + "id": "telekinesis:telekinesis", + "required": false + } + ] +} \ No newline at end of file diff --git a/versions/1.21/src/main/generated/data/minecraft/tags/enchantment/treasure.json b/versions/1.21/src/main/generated/data/minecraft/tags/enchantment/treasure.json new file mode 100644 index 0000000..0d9aebf --- /dev/null +++ b/versions/1.21/src/main/generated/data/minecraft/tags/enchantment/treasure.json @@ -0,0 +1,8 @@ +{ + "values": [ + { + "id": "telekinesis:telekinesis", + "required": false + } + ] +} \ No newline at end of file