From 0eae915d704538c8466a9c27626919e8db632f98 Mon Sep 17 00:00:00 2001 From: Kli Kli Date: Mon, 15 Jul 2024 13:46:46 +0200 Subject: [PATCH] fix: miners are not enchantable Closes #1152 --- .../data/minecraft/tags/item/enchantable/durability.json | 5 +++++ .../resources/data/occultism/tags/item/miners.json | 8 ++++++++ .../occultism/common/item/spirit/MinerSpiritItem.java | 4 +++- .../occultism/datagen/tags/OccultismItemTagProvider.java | 9 +++++++++ .../klikli_dev/occultism/registry/OccultismItems.java | 1 + .../com/klikli_dev/occultism/registry/OccultismTags.java | 2 ++ 6 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/generated/resources/data/minecraft/tags/item/enchantable/durability.json create mode 100644 src/generated/resources/data/occultism/tags/item/miners.json diff --git a/src/generated/resources/data/minecraft/tags/item/enchantable/durability.json b/src/generated/resources/data/minecraft/tags/item/enchantable/durability.json new file mode 100644 index 000000000..cf5e040c5 --- /dev/null +++ b/src/generated/resources/data/minecraft/tags/item/enchantable/durability.json @@ -0,0 +1,5 @@ +{ + "values": [ + "#occultism:miners" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/occultism/tags/item/miners.json b/src/generated/resources/data/occultism/tags/item/miners.json new file mode 100644 index 000000000..75d1e19aa --- /dev/null +++ b/src/generated/resources/data/occultism/tags/item/miners.json @@ -0,0 +1,8 @@ +{ + "values": [ + "#occultism:miners/basic_resources", + "#occultism:miners/deeps", + "#occultism:miners/master", + "#occultism:miners/ores" + ] +} \ No newline at end of file diff --git a/src/main/java/com/klikli_dev/occultism/common/item/spirit/MinerSpiritItem.java b/src/main/java/com/klikli_dev/occultism/common/item/spirit/MinerSpiritItem.java index 7e938355d..1b5deb30c 100644 --- a/src/main/java/com/klikli_dev/occultism/common/item/spirit/MinerSpiritItem.java +++ b/src/main/java/com/klikli_dev/occultism/common/item/spirit/MinerSpiritItem.java @@ -26,12 +26,14 @@ import com.klikli_dev.occultism.registry.OccultismDataComponents; import com.klikli_dev.occultism.util.ItemNBTUtil; import com.klikli_dev.occultism.util.TextUtil; +import net.minecraft.core.component.DataComponents; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; +import net.minecraft.world.item.enchantment.ItemEnchantments; import net.minecraft.world.level.Level; import net.neoforged.neoforge.capabilities.ICapabilityProvider; import org.jetbrains.annotations.Nullable; @@ -46,7 +48,7 @@ public class MinerSpiritItem extends Item { private final Supplier maxDamage; public MinerSpiritItem(Properties properties, Supplier maxMiningTime, Supplier rollsPerOperation, Supplier maxDamage) { - super(properties); + super(properties.component(DataComponents.ENCHANTMENTS, ItemEnchantments.EMPTY)); this.maxMiningTime = maxMiningTime; this.rollsPerOperation = rollsPerOperation; this.maxDamage = maxDamage; diff --git a/src/main/java/com/klikli_dev/occultism/datagen/tags/OccultismItemTagProvider.java b/src/main/java/com/klikli_dev/occultism/datagen/tags/OccultismItemTagProvider.java index d579894bf..320d1c0b3 100644 --- a/src/main/java/com/klikli_dev/occultism/datagen/tags/OccultismItemTagProvider.java +++ b/src/main/java/com/klikli_dev/occultism/datagen/tags/OccultismItemTagProvider.java @@ -56,6 +56,13 @@ private void addOccultismTags(HolderLookup.Provider provider) { this.tag(OccultismTags.Items.Miners.MASTER).add(OccultismItems.MINER_MARID_MASTER.get()).replace(false); this.tag(OccultismTags.Items.Miners.ORES).add(OccultismItems.MINER_FOLIOT_UNSPECIALIZED.get(), OccultismItems.MINER_DEBUG_UNSPECIALIZED.get(), OccultismItems.MINER_AFRIT_DEEPS.get(), OccultismItems.MINER_MARID_MASTER.get(), OccultismItems.MINER_DJINNI_ORES.get()).replace(false); + + this.tag(OccultismTags.Items.Miners.MINERS) + .addTag(OccultismTags.Items.Miners.BASIC_RESOURCES) + .addTag(OccultismTags.Items.Miners.DEEPS) + .addTag(OccultismTags.Items.Miners.MASTER) + .addTag(OccultismTags.Items.Miners.ORES).replace(false); + this.copy(OccultismTags.Blocks.OTHERWORLD_SAPLINGS, OccultismTags.Items.OTHERWORLD_SAPLINGS); this.tag(OccultismTags.Items.TOOL_KNIVES).add(OccultismItems.BUTCHER_KNIFE.get()).replace(false); this.tag(OccultismTags.Items.ELYTRA).add(Items.ELYTRA).addOptional(ResourceLocation.fromNamespaceAndPath("mana-and-artifice", "spectral_elytra")).replace(false); @@ -78,6 +85,8 @@ private void addMinecraftTags(HolderLookup.Provider provider) { this.tag(ItemTags.BOOKSHELF_BOOKS).add(OccultismItems.BOOK_OF_CALLING_FOLIOT_TRANSPORT_ITEMS.get()); this.tag(ItemTags.BOOKSHELF_BOOKS).add(OccultismItems.BOOK_OF_BINDING_EMPTY.get()); + this.tag(ItemTags.DURABILITY_ENCHANTABLE).addTag(OccultismTags.Items.Miners.MINERS); + this.tag(ItemTags.CLUSTER_MAX_HARVESTABLES).add(OccultismItems.INFUSED_PICKAXE.get(),OccultismItems.IESNIUM_PICKAXE.get()).replace(false); this.copy(BlockTags.LEAVES,ItemTags.LEAVES); this.copy(BlockTags.LOGS,ItemTags.LOGS); diff --git a/src/main/java/com/klikli_dev/occultism/registry/OccultismItems.java b/src/main/java/com/klikli_dev/occultism/registry/OccultismItems.java index 33692a61c..cf7b11681 100644 --- a/src/main/java/com/klikli_dev/occultism/registry/OccultismItems.java +++ b/src/main/java/com/klikli_dev/occultism/registry/OccultismItems.java @@ -37,6 +37,7 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.item.*; import net.minecraft.world.item.component.ItemContainerContents; +import net.minecraft.world.item.enchantment.ItemEnchantments; import net.neoforged.neoforge.common.DeferredSpawnEggItem; import net.neoforged.neoforge.registries.DeferredItem; import net.neoforged.neoforge.registries.DeferredRegister; diff --git a/src/main/java/com/klikli_dev/occultism/registry/OccultismTags.java b/src/main/java/com/klikli_dev/occultism/registry/OccultismTags.java index 16d5a3fa5..ca145b55a 100644 --- a/src/main/java/com/klikli_dev/occultism/registry/OccultismTags.java +++ b/src/main/java/com/klikli_dev/occultism/registry/OccultismTags.java @@ -111,6 +111,8 @@ public static class Items { public static final TagKey OTHERWORLD_SAPLINGS = makeItemTag(ResourceLocation.fromNamespaceAndPath(Occultism.MODID, "saplings/otherworld")); public static class Miners { + public static final TagKey MINERS = makeItemTag(ResourceLocation.fromNamespaceAndPath(Occultism.MODID, "miners")); + public static final TagKey BASIC_RESOURCES = makeItemTag(ResourceLocation.fromNamespaceAndPath(Occultism.MODID, "miners/basic_resources")); public static final TagKey DEEPS = makeItemTag(ResourceLocation.fromNamespaceAndPath(Occultism.MODID, "miners/deeps")); public static final TagKey MASTER = makeItemTag(ResourceLocation.fromNamespaceAndPath(Occultism.MODID, "miners/master"));