diff --git a/gradle.properties b/gradle.properties index 31d2bca..4ab1fb2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,11 +7,11 @@ minecraft_version=1.18.2 yarn_mappings=1.18.2+build.1 loader_version=0.13.3 # Mod Properties -mod_version=1.0.22 +mod_version=1.0.23 maven_group=com.glisco archives_base_name=conjuring # Dependencies -fabric_version=0.47.8+1.18.2 +fabric_version=0.55.1+1.18.2 # https://maven.blamejared.com/vazkii/patchouli/Patchouli/ patchouli_version=1.18.2-66-FABRIC @@ -23,4 +23,4 @@ rei_version=8.0.438 modmenu_version=3.0.1 # https://maven.wispforest.io/io/wispforest/owo-lib/ -owo_version=0.5.4+1.18 \ No newline at end of file +owo_version=0.5.4+1.18 diff --git a/src/main/java/com/glisco/conjuring/Conjuring.java b/src/main/java/com/glisco/conjuring/Conjuring.java index bc80776..2faec9c 100644 --- a/src/main/java/com/glisco/conjuring/Conjuring.java +++ b/src/main/java/com/glisco/conjuring/Conjuring.java @@ -23,7 +23,7 @@ import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents; -import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback; +import net.fabricmc.fabric.api.loot.v2.LootTableEvents; import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; import net.fabricmc.fabric.api.object.builder.v1.advancement.CriterionRegistry; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricEntityTypeBuilder; @@ -35,8 +35,13 @@ import net.minecraft.item.ItemStack; import net.minecraft.loot.LootPool; import net.minecraft.loot.LootTables; +import net.minecraft.loot.condition.InvertedLootCondition; +import net.minecraft.loot.condition.MatchToolLootCondition; import net.minecraft.loot.entry.ItemEntry; import net.minecraft.loot.function.ApplyBonusLootFunction; +import net.minecraft.predicate.NumberRange; +import net.minecraft.predicate.item.EnchantmentPredicate; +import net.minecraft.predicate.item.ItemPredicate; import net.minecraft.screen.ScreenHandlerType; import net.minecraft.sound.SoundEvent; import net.minecraft.util.Identifier; @@ -128,16 +133,26 @@ public void onInitialize() { Registry.register(Registry.SOUND_EVENT, Conjuring.id("block.soul_weaver.weee"), WEEE); - if (CONFIG.conjurer_config.fortuneEnabled) { - LootTableLoadingCallback.EVENT.register((resourceManager, manager, id, supplier, setter) -> { - if (!new Identifier("blocks/spawner").equals(id)) return; - supplier.withPool(LootPool.builder().with( - ItemEntry.builder(ConjuringItems.CONJURATION_ESSENCE).apply(ApplyBonusLootFunction.oreDrops(Enchantments.FORTUNE))) - .build()); - }); - } else { - LootOps.injectItem(ConjuringItems.CONJURATION_ESSENCE, 1, new Identifier("blocks/spawner")); - } + final var spawnerLootTableId = new Identifier("blocks/spawner"); + LootTableEvents.MODIFY.register((resourceManager, lootManager, id, tableBuilder, source) -> { + if (!spawnerLootTableId.equals(id)) return; + + var itemEntry = ItemEntry.builder(ConjuringItems.CONJURATION_ESSENCE); + if (CONFIG.conjurer_config.fortuneEnabled) { + itemEntry.apply(ApplyBonusLootFunction.oreDrops(Enchantments.FORTUNE)); + } + + if (CONFIG.conjurer_config.respectSilkTouch) { + itemEntry.conditionally(InvertedLootCondition.builder( + MatchToolLootCondition.builder(ItemPredicate.Builder.create().enchantment( + new EnchantmentPredicate(Enchantments.SILK_TOUCH, NumberRange.IntRange.atLeast(1)) + ))) + ); + } + + tableBuilder.pool(LootPool.builder().with(itemEntry).build()); + }); + LootOps.injectItem(ConjuringItems.CONJURATION_ESSENCE, .35f, LootTables.SIMPLE_DUNGEON_CHEST); LootOps.injectItem(ConjuringItems.CONJURATION_ESSENCE, .175f, LootTables.BASTION_TREASURE_CHEST); diff --git a/src/main/java/com/glisco/conjuring/compat/config/ConjuringConfig.java b/src/main/java/com/glisco/conjuring/compat/config/ConjuringConfig.java index 42c09e9..0c56258 100644 --- a/src/main/java/com/glisco/conjuring/compat/config/ConjuringConfig.java +++ b/src/main/java/com/glisco/conjuring/compat/config/ConjuringConfig.java @@ -23,10 +23,12 @@ public ConjuringConfig() { public ToolsConfig tools_config = new ToolsConfig(); public static class ConjurerConfig { - @ConfigEntry.Gui.RequiresRestart @Comment("Whether Fortune should affect the amount of Conjuration Essence you can get when breaking a spawner") public boolean fortuneEnabled = false; + @Comment("Whether Conjuration Essence should only drop from spawners that were mined without Silk Touch") + public boolean respectSilkTouch = false; + @Comment("How many extra mobs to spawn per abundance charm") public int abundance_multiplier = 2; diff --git a/src/main/resources/assets/conjuring/lang/en_us.json b/src/main/resources/assets/conjuring/lang/en_us.json index 09a8703..3dc8206 100644 --- a/src/main/resources/assets/conjuring/lang/en_us.json +++ b/src/main/resources/assets/conjuring/lang/en_us.json @@ -91,6 +91,7 @@ "text.autoconfig.conjuring.option.conjurer_config": "Conjurer", "text.autoconfig.conjuring.option.conjurer_config.fortuneEnabled": "Fortune Enabled", + "text.autoconfig.conjuring.option.conjurer_config.respectSilkTouch": "Respect Silk Touch", "text.autoconfig.conjuring.option.conjurer_config.abundance_multiplier": "Abundance Multiplier", "text.autoconfig.conjuring.option.conjurer_config.haste_multiplier": "Haste Multiplier", "text.autoconfig.conjuring.option.conjurer_config.scope_multiplier": "Scope Multiplier",