diff --git a/build.gradle b/build.gradle index 08be872a..63958332 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ plugins { id 'java-library' id 'idea' - id 'net.neoforged.moddev' version '2.0.71' + id 'net.neoforged.moddev' version '2.0.107' id("com.modrinth.minotaur") version '2.+' id("com.matthewprenger.cursegradle") version '1.4.0' } diff --git a/changelog.md b/changelog.md index fe0ab70f..4f3d626d 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,6 @@ +## Ex Deorum 3.9 +- Add `#exdeorum:hammer_fortune_blacklist` and `#exdeorum:compressed_hammer_fortune_blacklist` item tags, allowing pack makers to prevent Fortune from affecting a block's hammer or compressed hammer drops + ## Ex Deorum 3.8 - Fix memory leak in VisualUpdateTracker (#153) - Added Hungarian translation (#147) diff --git a/src/generated/resources/.cache/221483d9edeccdc82e726e39216c875f3fc356d3 b/src/generated/resources/.cache/221483d9edeccdc82e726e39216c875f3fc356d3 index 74037cb5..98c49979 100644 --- a/src/generated/resources/.cache/221483d9edeccdc82e726e39216c875f3fc356d3 +++ b/src/generated/resources/.cache/221483d9edeccdc82e726e39216c875f3fc356d3 @@ -1,4 +1,4 @@ -// 1.21.1 2025-06-03T14:16:11.5378401 Tags for minecraft:item mod id exdeorum +// 1.21.1 2025-09-01T13:22:27.1441593 Tags for minecraft:item mod id exdeorum 6c72957356b1d59a27be736fa1da54a5a9795ef7 data/exdeorum/tags/item/barrels.json 6afa16b45f76c0defa1675d07586e2c6e6b0be69 data/exdeorum/tags/item/compressed/andesite.json 31b46613766e4cdc53196850495ab1019f61cb48 data/exdeorum/tags/item/compressed/blackstone.json @@ -22,9 +22,11 @@ fc279d9fa656ad00c5504b3f313586ca34fc4477 data/exdeorum/tags/item/compressed/red_ 2de46f3e2e91a340f1b71ea5b600f8383a7ce875 data/exdeorum/tags/item/compressed/sands.json 874b33131f557d077ab366fc6506c41369151a40 data/exdeorum/tags/item/compressed/soul_sand.json dad00c75d1a0b74a2f843bead336ee278e9cecba data/exdeorum/tags/item/compressed_hammers.json +35133e95f1c8fdd7a1c21afcc231fc0bffefb9a8 data/exdeorum/tags/item/compressed_hammer_fortune_blacklist.json 5feb54ce68fa657af5ce696f75b8c7a6d04cc7a7 data/exdeorum/tags/item/crooks.json 74eefeb986d633d26ad42202c4a6b5e71463c425 data/exdeorum/tags/item/end_cake_materials.json be46bf2abe731d5ee5bd15ce72f222b2b9a49385 data/exdeorum/tags/item/hammers.json +35133e95f1c8fdd7a1c21afcc231fc0bffefb9a8 data/exdeorum/tags/item/hammer_fortune_blacklist.json 008b4a382f07b9c0f9a07c78bedb949b4400e011 data/exdeorum/tags/item/ore_chunks.json b90bd3c642e69b9e800c58a9f8f53e369652e6ba data/exdeorum/tags/item/pebbles.json 10f2167f7a9472e5df6870bad71b95869fc64b9a data/exdeorum/tags/item/random_shard_drops.json diff --git a/src/generated/resources/data/exdeorum/tags/item/compressed_hammer_fortune_blacklist.json b/src/generated/resources/data/exdeorum/tags/item/compressed_hammer_fortune_blacklist.json new file mode 100644 index 00000000..f72d209d --- /dev/null +++ b/src/generated/resources/data/exdeorum/tags/item/compressed_hammer_fortune_blacklist.json @@ -0,0 +1,3 @@ +{ + "values": [] +} \ No newline at end of file diff --git a/src/generated/resources/data/exdeorum/tags/item/hammer_fortune_blacklist.json b/src/generated/resources/data/exdeorum/tags/item/hammer_fortune_blacklist.json new file mode 100644 index 00000000..f72d209d --- /dev/null +++ b/src/generated/resources/data/exdeorum/tags/item/hammer_fortune_blacklist.json @@ -0,0 +1,3 @@ +{ + "values": [] +} \ No newline at end of file diff --git a/src/main/java/thedarkcolour/exdeorum/blockentity/MechanicalHammerBlockEntity.java b/src/main/java/thedarkcolour/exdeorum/blockentity/MechanicalHammerBlockEntity.java index c18e2b80..400175ec 100644 --- a/src/main/java/thedarkcolour/exdeorum/blockentity/MechanicalHammerBlockEntity.java +++ b/src/main/java/thedarkcolour/exdeorum/blockentity/MechanicalHammerBlockEntity.java @@ -152,7 +152,9 @@ public class MechanicalHammerBlockEntity extends AbstractMachineBlockEntity CODEC = RecordCodecBuilder.mapCodec(inst -> LootModifier.codecStart(inst).apply(inst, CompressedHammerLootModifier::new)); public CompressedHammerLootModifier(LootItemCondition[] conditionsIn) { - super(conditionsIn); + super(conditionsIn, EItemTags.COMPRESSED_HAMMER_FORTUNE_BLACKLIST); } @Override diff --git a/src/main/java/thedarkcolour/exdeorum/loot/HammerLootModifier.java b/src/main/java/thedarkcolour/exdeorum/loot/HammerLootModifier.java index 0e802075..bd002e23 100644 --- a/src/main/java/thedarkcolour/exdeorum/loot/HammerLootModifier.java +++ b/src/main/java/thedarkcolour/exdeorum/loot/HammerLootModifier.java @@ -23,6 +23,7 @@ import com.mojang.serialization.codecs.RecordCodecBuilder; import it.unimi.dsi.fastutil.objects.ObjectArrayList; import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.Registries; +import net.minecraft.tags.TagKey; import net.minecraft.util.RandomSource; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -36,42 +37,57 @@ import net.neoforged.neoforge.common.loot.LootModifier; import org.jetbrains.annotations.Nullable; import thedarkcolour.exdeorum.recipe.RecipeUtil; import thedarkcolour.exdeorum.recipe.hammer.HammerRecipe; +import thedarkcolour.exdeorum.tag.EItemTags; public class HammerLootModifier extends LootModifier { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(inst -> LootModifier.codecStart(inst).apply(inst, HammerLootModifier::new)); + private final TagKey fortuneBlacklistTag; + public HammerLootModifier(LootItemCondition[] conditionsIn) { super(conditionsIn); + + this.fortuneBlacklistTag = EItemTags.HAMMER_FORTUNE_BLACKLIST; + } + + protected HammerLootModifier(LootItemCondition[] conditionsIn, TagKey fortuneBlacklistTag) { + super(conditionsIn); + + this.fortuneBlacklistTag = fortuneBlacklistTag; } @Override protected ObjectArrayList doApply(ObjectArrayList generatedLoot, LootContext context) { var state = context.getParamOrNull(LootContextParams.BLOCK_STATE); - if (state != null) { - var itemForm = state.getBlock().asItem(); - if (itemForm != Items.AIR) { - var recipe = getRecipe(itemForm); - - if (recipe != null) { - ObjectArrayList newLoot = new ObjectArrayList<>(); - var resultAmount = recipe.resultAmount.getInt(context); - - // fortune handling; more likely to boost drops if there are none to begin with - if (context.hasParam(LootContextParams.TOOL)) { - var hammer = context.getParam(LootContextParams.TOOL); - resultAmount += calculateFortuneBonus(context.getLevel().registryAccess(), hammer, context.getRandom(), resultAmount == 0); - } - - if (resultAmount > 0) { - newLoot.add(recipe.result.copyWithCount(resultAmount)); - } - return newLoot; - } - } + if (state == null) { + return generatedLoot; } - return generatedLoot; + var itemForm = state.getBlock().asItem(); + if (itemForm == Items.AIR) { + return generatedLoot; + } + + var recipe = getRecipe(itemForm); + if (recipe == null) { + return generatedLoot; + } + + ObjectArrayList newLoot = new ObjectArrayList<>(); + var resultAmount = recipe.resultAmount.getInt(context); + + if (!itemForm.builtInRegistryHolder().is(this.fortuneBlacklistTag) && context.hasParam(LootContextParams.TOOL)) { + var hammer = context.getParam(LootContextParams.TOOL); + // fortune handling; more likely to boost drops if there are none to begin with + resultAmount += calculateFortuneBonus(context.getLevel().registryAccess(), hammer, context.getRandom(), resultAmount == 0); + } + + if (resultAmount > 0) { + newLoot.add(recipe.result.copyWithCount(resultAmount)); + } + + return newLoot; } @Nullable diff --git a/src/main/java/thedarkcolour/exdeorum/tag/EItemTags.java b/src/main/java/thedarkcolour/exdeorum/tag/EItemTags.java index 4981c7db..408f4309 100644 --- a/src/main/java/thedarkcolour/exdeorum/tag/EItemTags.java +++ b/src/main/java/thedarkcolour/exdeorum/tag/EItemTags.java @@ -33,6 +33,9 @@ public class EItemTags { public static final TagKey ORE_CHUNKS = tag("ore_chunks"); public static final TagKey END_CAKE_MATERIAL = tag("end_cake_materials"); + public static final TagKey HAMMER_FORTUNE_BLACKLIST = tag("hammer_fortune_blacklist"); + public static final TagKey COMPRESSED_HAMMER_FORTUNE_BLACKLIST = tag("compressed_hammer_fortune_blacklist"); + public static final TagKey RANDOM_SHERD_DROPS = tag("random_shard_drops"); public static final TagKey RANDOM_TRIM_DROPS = tag("random_trim_drops");