diff --git a/src/main/java/com/minelittlepony/unicopia/CustomDrops.java b/src/main/java/com/minelittlepony/unicopia/CustomDrops.java deleted file mode 100644 index 2ff7bcc1..00000000 --- a/src/main/java/com/minelittlepony/unicopia/CustomDrops.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.minelittlepony.unicopia; - -import java.util.List; - -import com.minelittlepony.unicopia.block.UBlocks; -import com.minelittlepony.unicopia.item.UItems; -import com.minelittlepony.unicopia.magic.spell.SpellRegistry; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockState; -import net.minecraft.block.Blocks; -import net.minecraft.block.GrassBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; - -@Deprecated -public class CustomDrops { - // XXX: loot table - public void addAuxiliaryDrops(World world, BlockState state, BlockPos pos, List drops, int fortune) { - Block block = state.getBlock(); - - int fortuneFactor = 1 + fortune * 15; - - if (block == Blocks.STONE) { - if (world.random.nextInt(500 / fortuneFactor) == 0) { - for (int i = 0; i < 1 + fortune; i++) { - if (world.random.nextInt(10) > 3) { - drops.add(new ItemStack(UItems.CORRUPTED_GEM)); - } else { - drops.add(new ItemStack(UItems.GEM)); - } - } - } - - if (world.random.nextInt(5000) == 0) { - drops.add(SpellRegistry.instance().enchantStack(new ItemStack(UItems.GEM), "awkward")); - } - } else if (block == Blocks.DIRT || block == Blocks.CLAY || block == Blocks.GRASS_PATH || block == Blocks.GRASS || block == UBlocks.HIVE_WALL_BLOCK) { - if (world.random.nextInt(25 / fortuneFactor) == 0) { - drops.add(new ItemStack(UItems.WHEAT_WORMS, 1 + fortune)); - } - } else if (block instanceof GrassBlock) { - if (world.random.nextInt(25 / fortuneFactor) == 0) { - for (int i = 0; i < 1 + fortune; i++) { - int chance = world.random.nextInt(3); - - if (chance == 0) { - drops.add(new ItemStack(UItems.ALFALFA_SEEDS)); - } else if (chance == 1) { - drops.add(new ItemStack(UItems.APPLE_SEEDS)); - } else { - drops.add(new ItemStack(UItems.TOMATO_SEEDS)); - } - } - } - } - } -} diff --git a/src/main/java/com/minelittlepony/unicopia/Unicopia.java b/src/main/java/com/minelittlepony/unicopia/Unicopia.java index 3d52e7be..33143a0d 100644 --- a/src/main/java/com/minelittlepony/unicopia/Unicopia.java +++ b/src/main/java/com/minelittlepony/unicopia/Unicopia.java @@ -1,8 +1,12 @@ package com.minelittlepony.unicopia; import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.loot.v1.FabricLootSupplier; +import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; +import net.minecraft.loot.LootTable; import net.minecraft.resource.ResourceType; +import net.minecraft.util.Identifier; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -48,5 +52,17 @@ public class Unicopia implements ModInitializer { CriterionsRegistry.register(BOHDeathCriterion.INSTANCE); ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(Pages.instance()); + + LootTableLoadingCallback.EVENT.register((res, manager, id, supplier, setter) -> { + if (!"minecraft".contentEquals(id.getNamespace())) { + return; + } + + Identifier modId = new Identifier("unicopiamc", id.getPath()); + LootTable table = manager.getSupplier(modId); + if (table != LootTable.EMPTY) { + supplier.withPools(((FabricLootSupplier)table).getPools()); + } + }); } } diff --git a/src/main/resources/data/unicopia/loot_tables/blocks/hive_wall_block.json b/src/main/resources/data/unicopia/loot_tables/blocks/hive_wall_block.json index 3b26731a..58f52c09 100644 --- a/src/main/resources/data/unicopia/loot_tables/blocks/hive_wall_block.json +++ b/src/main/resources/data/unicopia/loot_tables/blocks/hive_wall_block.json @@ -6,6 +6,37 @@ "entries": [ { "type": "minecraft:item", "name": "unicopia:hive_wall_block" } ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.06, 0.072222223, 0.075, 0.096666665, 1 + ] + } + ], + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "min": 1.0, + "max": 2.0, + "type": "minecraft:uniform" + } + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:wheat_worms" + } + ] } ] } diff --git a/src/main/resources/data/unicopiamc/loot_tables/blocks/clay.json b/src/main/resources/data/unicopiamc/loot_tables/blocks/clay.json new file mode 100644 index 00000000..dc5427fc --- /dev/null +++ b/src/main/resources/data/unicopiamc/loot_tables/blocks/clay.json @@ -0,0 +1,36 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.07, 0.072222223, 0.075, 0.086666665, 0.2 + ] + } + ], + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "min": 1.0, + "max": 3.0, + "type": "minecraft:uniform" + } + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:wheat_worms" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/unicopiamc/loot_tables/blocks/dirt.json b/src/main/resources/data/unicopiamc/loot_tables/blocks/dirt.json new file mode 100644 index 00000000..5132660e --- /dev/null +++ b/src/main/resources/data/unicopiamc/loot_tables/blocks/dirt.json @@ -0,0 +1,36 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.05, 0.052222223, 0.055, 0.066666665, 0.1 + ] + } + ], + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "min": 1.0, + "max": 2.0, + "type": "minecraft:uniform" + } + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:wheat_worms" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/unicopiamc/loot_tables/blocks/grass.json b/src/main/resources/data/unicopiamc/loot_tables/blocks/grass.json new file mode 100644 index 00000000..c7432965 --- /dev/null +++ b/src/main/resources/data/unicopiamc/loot_tables/blocks/grass.json @@ -0,0 +1,74 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.05, 0.052222223, 0.055, 0.066666665, 0.1 + ] + } + ], + "functions": [ + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:alfalfa_seeds" + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.05, 0.052222223, 0.055, 0.066666665, 0.1 + ] + } + ], + "functions": [ + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:apple_seeds" + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.05, 0.052222223, 0.055, 0.066666665, 0.1 + ] + } + ], + "functions": [ + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:tomato_seeds" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/unicopiamc/loot_tables/blocks/grass_block.json b/src/main/resources/data/unicopiamc/loot_tables/blocks/grass_block.json new file mode 100644 index 00000000..5132660e --- /dev/null +++ b/src/main/resources/data/unicopiamc/loot_tables/blocks/grass_block.json @@ -0,0 +1,36 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.05, 0.052222223, 0.055, 0.066666665, 0.1 + ] + } + ], + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "min": 1.0, + "max": 2.0, + "type": "minecraft:uniform" + } + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:wheat_worms" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/unicopiamc/loot_tables/blocks/grass_path.json b/src/main/resources/data/unicopiamc/loot_tables/blocks/grass_path.json new file mode 100644 index 00000000..5132660e --- /dev/null +++ b/src/main/resources/data/unicopiamc/loot_tables/blocks/grass_path.json @@ -0,0 +1,36 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.05, 0.052222223, 0.055, 0.066666665, 0.1 + ] + } + ], + "functions": [ + { + "function": "minecraft:set_count", + "count": { + "min": 1.0, + "max": 2.0, + "type": "minecraft:uniform" + } + }, + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:wheat_worms" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/unicopiamc/loot_tables/blocks/large_fern.json b/src/main/resources/data/unicopiamc/loot_tables/blocks/large_fern.json new file mode 100644 index 00000000..1cbd9d9e --- /dev/null +++ b/src/main/resources/data/unicopiamc/loot_tables/blocks/large_fern.json @@ -0,0 +1,74 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.15, 0.152222223, 0.155, 0.166666665, 0.4 + ] + } + ], + "functions": [ + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:alfalfa_seeds" + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.15, 0.152222223, 0.155, 0.166666665, 0.4 + ] + } + ], + "functions": [ + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:apple_seeds" + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.15, 0.152222223, 0.155, 0.166666665, 0.4 + ] + } + ], + "functions": [ + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:tomato_seeds" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/unicopiamc/loot_tables/blocks/stone.json b/src/main/resources/data/unicopiamc/loot_tables/blocks/stone.json new file mode 100644 index 00000000..da58c98c --- /dev/null +++ b/src/main/resources/data/unicopiamc/loot_tables/blocks/stone.json @@ -0,0 +1,51 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.15, 0.152222223, 0.155, 0.166666665, 0.4 + ] + } + ], + "functions": [ + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:gem" + } + ] + }, + { + "rolls": 2, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.15, 0.152222223, 0.155, 0.166666665, 0.4 + ] + } + ], + "functions": [ + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:corrupted_gem" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/unicopiamc/loot_tables/blocks/tall_grass.json b/src/main/resources/data/unicopiamc/loot_tables/blocks/tall_grass.json new file mode 100644 index 00000000..1cbd9d9e --- /dev/null +++ b/src/main/resources/data/unicopiamc/loot_tables/blocks/tall_grass.json @@ -0,0 +1,74 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.15, 0.152222223, 0.155, 0.166666665, 0.4 + ] + } + ], + "functions": [ + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:alfalfa_seeds" + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.15, 0.152222223, 0.155, 0.166666665, 0.4 + ] + } + ], + "functions": [ + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:apple_seeds" + } + ] + }, + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "conditions": [ + { + "condition": "minecraft:table_bonus", + "enchantment": "minecraft:fortune", + "chances": [ + 0.15, 0.152222223, 0.155, 0.166666665, 0.4 + ] + } + ], + "functions": [ + { + "function": "minecraft:explosion_decay" + } + ], + "name": "unicopia:tomato_seeds" + } + ] + } + ] +} \ No newline at end of file