From 8e92e70b8edbc3728ef79e474bf373ac8d4519e2 Mon Sep 17 00:00:00 2001 From: thedarkcolour <30441001+thedarkcolour@users.noreply.github.com> Date: Tue, 9 Jul 2024 12:10:33 -0700 Subject: [PATCH] Fix logs dropping sawdust + generate GLMs --- .../221483d9edeccdc82e726e39216c875f3fc356d3 | 4 +- .../f1f3e3a91f3dfa1ddb5216abfcdcc42a5cffc23b | 5 +++ .../loot_modifiers/compressed_hammer.json | 2 +- .../data/exdeorum/loot_modifiers/crook.json | 2 +- .../data/exdeorum/loot_modifiers/hammer.json | 2 +- .../tags/item/enchantable/durability.json | 3 +- .../loot_modifiers/global_loot_modifiers.json | 8 ++++ .../thedarkcolour/exdeorum/data/Data.java | 7 ++-- .../exdeorum/data/LootModifiers.java | 38 +++++++++++++++++++ .../exdeorum/loot/CrookLootModifier.java | 4 +- .../exdeorum/loot/HammerLootModifier.java | 2 +- .../loot_modifiers/global_loot_modifiers.json | 8 ---- 12 files changed, 64 insertions(+), 21 deletions(-) create mode 100644 src/generated/resources/.cache/f1f3e3a91f3dfa1ddb5216abfcdcc42a5cffc23b rename src/{main => generated}/resources/data/exdeorum/loot_modifiers/compressed_hammer.json (75%) rename src/{main => generated}/resources/data/exdeorum/loot_modifiers/crook.json (78%) rename src/{main => generated}/resources/data/exdeorum/loot_modifiers/hammer.json (78%) create mode 100644 src/generated/resources/data/neoforge/loot_modifiers/global_loot_modifiers.json create mode 100644 src/main/java/thedarkcolour/exdeorum/data/LootModifiers.java delete mode 100644 src/main/resources/data/neoforge/loot_modifiers/global_loot_modifiers.json diff --git a/src/generated/resources/.cache/221483d9edeccdc82e726e39216c875f3fc356d3 b/src/generated/resources/.cache/221483d9edeccdc82e726e39216c875f3fc356d3 index 67cbbb5c..8697335c 100644 --- a/src/generated/resources/.cache/221483d9edeccdc82e726e39216c875f3fc356d3 +++ b/src/generated/resources/.cache/221483d9edeccdc82e726e39216c875f3fc356d3 @@ -1,4 +1,4 @@ -// 1.21 2024-07-07T19:20:32.6499748 Tags for minecraft:item mod id exdeorum +// 1.21 2024-07-09T11:58:49.7850138 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 @@ -30,6 +30,6 @@ b90bd3c642e69b9e800c58a9f8f53e369652e6ba data/exdeorum/tags/item/pebbles.json 8e1b5ab26037123d3948e9ac9f50da1b7cd0a129 data/exdeorum/tags/item/sieve_meshes.json 0152da758e7665bf282f17f466599c7a009d9a15 data/exdeorum/tags/item/stone_barrels.json 8bde4a30abefaa373fa41813da07b6f79f32b874 data/exdeorum/tags/item/wooden_barrels.json -564bef8c17ecd8c359840d05c11c4af926e2a795 data/minecraft/tags/item/enchantable/durability.json +28fd077df8796b5061613218d902549c88f3e2fb data/minecraft/tags/item/enchantable/durability.json 564bef8c17ecd8c359840d05c11c4af926e2a795 data/minecraft/tags/item/enchantable/mining.json 564bef8c17ecd8c359840d05c11c4af926e2a795 data/minecraft/tags/item/enchantable/mining_loot.json diff --git a/src/generated/resources/.cache/f1f3e3a91f3dfa1ddb5216abfcdcc42a5cffc23b b/src/generated/resources/.cache/f1f3e3a91f3dfa1ddb5216abfcdcc42a5cffc23b new file mode 100644 index 00000000..cd14a260 --- /dev/null +++ b/src/generated/resources/.cache/f1f3e3a91f3dfa1ddb5216abfcdcc42a5cffc23b @@ -0,0 +1,5 @@ +// 1.21 2024-07-09T12:06:52.712022 Global Loot Modifiers : exdeorum +539ba0e881830430ae2c03f7ac8dec6f2de478a0 data/exdeorum/loot_modifiers/compressed_hammer.json +dd0417e36e03e0f51e1f1bbcff295b54128fdf8f data/exdeorum/loot_modifiers/crook.json +57991d8346a472f12c1a4b6cb94151d2c1bfa371 data/exdeorum/loot_modifiers/hammer.json +ec4635d28242c1e6ec5858fb58e43c004a34dbc1 data/neoforge/loot_modifiers/global_loot_modifiers.json diff --git a/src/main/resources/data/exdeorum/loot_modifiers/compressed_hammer.json b/src/generated/resources/data/exdeorum/loot_modifiers/compressed_hammer.json similarity index 75% rename from src/main/resources/data/exdeorum/loot_modifiers/compressed_hammer.json rename to src/generated/resources/data/exdeorum/loot_modifiers/compressed_hammer.json index 7e85eefe..357ac142 100644 --- a/src/main/resources/data/exdeorum/loot_modifiers/compressed_hammer.json +++ b/src/generated/resources/data/exdeorum/loot_modifiers/compressed_hammer.json @@ -4,7 +4,7 @@ { "condition": "minecraft:match_tool", "predicate": { - "tag": "exdeorum:compressed_hammers" + "items": "#exdeorum:compressed_hammers" } } ] diff --git a/src/main/resources/data/exdeorum/loot_modifiers/crook.json b/src/generated/resources/data/exdeorum/loot_modifiers/crook.json similarity index 78% rename from src/main/resources/data/exdeorum/loot_modifiers/crook.json rename to src/generated/resources/data/exdeorum/loot_modifiers/crook.json index dcb81357..65bfa325 100644 --- a/src/main/resources/data/exdeorum/loot_modifiers/crook.json +++ b/src/generated/resources/data/exdeorum/loot_modifiers/crook.json @@ -4,7 +4,7 @@ { "condition": "minecraft:match_tool", "predicate": { - "tag": "exdeorum:crooks" + "items": "#exdeorum:crooks" } } ] diff --git a/src/main/resources/data/exdeorum/loot_modifiers/hammer.json b/src/generated/resources/data/exdeorum/loot_modifiers/hammer.json similarity index 78% rename from src/main/resources/data/exdeorum/loot_modifiers/hammer.json rename to src/generated/resources/data/exdeorum/loot_modifiers/hammer.json index 6a13dc29..3378ec09 100644 --- a/src/main/resources/data/exdeorum/loot_modifiers/hammer.json +++ b/src/generated/resources/data/exdeorum/loot_modifiers/hammer.json @@ -4,7 +4,7 @@ { "condition": "minecraft:match_tool", "predicate": { - "tag": "exdeorum:hammers" + "items": "#exdeorum:hammers" } } ] diff --git a/src/generated/resources/data/minecraft/tags/item/enchantable/durability.json b/src/generated/resources/data/minecraft/tags/item/enchantable/durability.json index 61c97d6d..03e0d9a6 100644 --- a/src/generated/resources/data/minecraft/tags/item/enchantable/durability.json +++ b/src/generated/resources/data/minecraft/tags/item/enchantable/durability.json @@ -2,7 +2,6 @@ "values": [ "#exdeorum:hammers", "#exdeorum:compressed_hammers", - "#exdeorum:crooks", - "#exdeorum:sieve_meshes" + "#exdeorum:crooks" ] } \ No newline at end of file diff --git a/src/generated/resources/data/neoforge/loot_modifiers/global_loot_modifiers.json b/src/generated/resources/data/neoforge/loot_modifiers/global_loot_modifiers.json new file mode 100644 index 00000000..40022b62 --- /dev/null +++ b/src/generated/resources/data/neoforge/loot_modifiers/global_loot_modifiers.json @@ -0,0 +1,8 @@ +{ + "entries": [ + "exdeorum:compressed_hammer", + "exdeorum:hammer", + "exdeorum:crook" + ], + "replace": false +} \ No newline at end of file diff --git a/src/main/java/thedarkcolour/exdeorum/data/Data.java b/src/main/java/thedarkcolour/exdeorum/data/Data.java index fc6b6b0d..a0f720fd 100644 --- a/src/main/java/thedarkcolour/exdeorum/data/Data.java +++ b/src/main/java/thedarkcolour/exdeorum/data/Data.java @@ -29,7 +29,7 @@ public class Data { // Two things used by data generators var gen = event.getGenerator(); // writes to json var output = gen.getPackOutput(); - var lookup = event.getLookupProvider(); + var registries = event.getLookupProvider(); // reads existing files like pngs and parent models var helper = event.getExistingFileHelper(); @@ -45,8 +45,9 @@ public class Data { dataHelper.createTags(Registries.STRUCTURE_SET, ModTags::createStructureSetTags); dataHelper.createTags(Registries.WORLD_PRESET, ModTags::createWorldPresetTags); - gen.addProvider(true, new LootTables(output, lookup)); - gen.addProvider(true, new Advancements(output, lookup, helper)); + gen.addProvider(true, new LootTables(output, registries)); + gen.addProvider(true, new Advancements(output, registries, helper)); gen.addProvider(true, new Sounds(output, helper)); + gen.addProvider(true, new LootModifiers(output, registries)); } } diff --git a/src/main/java/thedarkcolour/exdeorum/data/LootModifiers.java b/src/main/java/thedarkcolour/exdeorum/data/LootModifiers.java new file mode 100644 index 00000000..9a81877f --- /dev/null +++ b/src/main/java/thedarkcolour/exdeorum/data/LootModifiers.java @@ -0,0 +1,38 @@ +package thedarkcolour.exdeorum.data; + +import net.minecraft.advancements.critereon.ItemPredicate; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.PackOutput; +import net.minecraft.tags.TagKey; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.storage.loot.predicates.LootItemCondition; +import net.minecraft.world.level.storage.loot.predicates.MatchTool; +import net.neoforged.neoforge.common.data.GlobalLootModifierProvider; +import net.neoforged.neoforge.common.loot.IGlobalLootModifier; +import thedarkcolour.exdeorum.ExDeorum; +import thedarkcolour.exdeorum.loot.CompressedHammerLootModifier; +import thedarkcolour.exdeorum.loot.CrookLootModifier; +import thedarkcolour.exdeorum.loot.HammerLootModifier; +import thedarkcolour.exdeorum.tag.EItemTags; + +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; + +class LootModifiers extends GlobalLootModifierProvider { + LootModifiers(PackOutput output, CompletableFuture registries) { + super(output, registries, ExDeorum.ID); + } + + @Override + protected void start() { + add("hammer", HammerLootModifier::new, EItemTags.HAMMERS); + add("compressed_hammer", CompressedHammerLootModifier::new, EItemTags.COMPRESSED_HAMMERS); + add("crook", CrookLootModifier::new, EItemTags.CROOKS); + } + + private void add(String name, Function constructor, TagKey requiredTag) { + add(name, constructor.apply(new LootItemCondition[]{new MatchTool(Optional.of(ItemPredicate.Builder.item().of(requiredTag).build()))}), List.of()); + } +} diff --git a/src/main/java/thedarkcolour/exdeorum/loot/CrookLootModifier.java b/src/main/java/thedarkcolour/exdeorum/loot/CrookLootModifier.java index ebcb5e63..92596a8f 100644 --- a/src/main/java/thedarkcolour/exdeorum/loot/CrookLootModifier.java +++ b/src/main/java/thedarkcolour/exdeorum/loot/CrookLootModifier.java @@ -43,7 +43,7 @@ import java.util.List; public class CrookLootModifier extends LootModifier { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(inst -> LootModifier.codecStart(inst).apply(inst, CrookLootModifier::new)); - protected CrookLootModifier(LootItemCondition[] conditions) { + public CrookLootModifier(LootItemCondition[] conditions) { super(conditions); } @@ -52,7 +52,7 @@ public class CrookLootModifier extends LootModifier { var state = context.getParamOrNull(LootContextParams.BLOCK_STATE); var stack = context.getParamOrNull(LootContextParams.TOOL); - if (state != null && stack != null && stack.getItem() != Items.BARRIER) { + if (state != null && stack != null) { var rand = context.getRandom(); if (stack.getEnchantmentLevel(context.getLevel().holderLookup(Registries.ENCHANTMENT).getOrThrow(Enchantments.SILK_TOUCH)) == 0) { diff --git a/src/main/java/thedarkcolour/exdeorum/loot/HammerLootModifier.java b/src/main/java/thedarkcolour/exdeorum/loot/HammerLootModifier.java index fd016049..0e802075 100644 --- a/src/main/java/thedarkcolour/exdeorum/loot/HammerLootModifier.java +++ b/src/main/java/thedarkcolour/exdeorum/loot/HammerLootModifier.java @@ -40,7 +40,7 @@ import thedarkcolour.exdeorum.recipe.hammer.HammerRecipe; public class HammerLootModifier extends LootModifier { public static final MapCodec CODEC = RecordCodecBuilder.mapCodec(inst -> LootModifier.codecStart(inst).apply(inst, HammerLootModifier::new)); - protected HammerLootModifier(LootItemCondition[] conditionsIn) { + public HammerLootModifier(LootItemCondition[] conditionsIn) { super(conditionsIn); } diff --git a/src/main/resources/data/neoforge/loot_modifiers/global_loot_modifiers.json b/src/main/resources/data/neoforge/loot_modifiers/global_loot_modifiers.json deleted file mode 100644 index ae40e0f9..00000000 --- a/src/main/resources/data/neoforge/loot_modifiers/global_loot_modifiers.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "replace": false, - "entries":[ - "exdeorum:crook", - "exdeorum:hammer", - "exdeorum:compressed_hammer" - ] -} \ No newline at end of file