tutorial:adding_to_loot_tables
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
tutorial:adding_to_loot_tables [2019/08/12 23:06] – fixed parenthesis yanis48 | tutorial:adding_to_loot_tables [2022/03/27 07:20] – stormyfabric | ||
---|---|---|---|
Line 9: | Line 9: | ||
===== Listening to loot table loading ===== | ===== Listening to loot table loading ===== | ||
- | Fabric API has an event that’s fired when loot tables are loaded, '' | + | Fabric API has an event that’s fired when loot tables are loaded, '' |
- | <code java> | + | <yarncode |
- | LootTableLoadingCallback.EVENT.register((resourceManager, | + | // No magic constants! |
- | if (" | + | private static final class_2960 COAL_ORE_LOOT_TABLE_ID = class_2246.COAL_ORE.getLootTableId(); |
+ | |||
+ | // Actual code | ||
+ | |||
+ | LootTableLoadingCallback.EVENT.register((resourceManager, | ||
+ | if (COAL_ORE_LOOT_TABLE_ID.equals(id)) { | ||
// Our code will go here | // Our code will go here | ||
} | } | ||
}); | }); | ||
- | </code> | + | </yarncode> |
===== Adding items to the table ===== | ===== Adding items to the table ===== | ||
Line 25: | Line 30: | ||
We can make a pool with '' | We can make a pool with '' | ||
- | <code java> | + | <yarncode |
- | LootTableLoadingCallback.EVENT.register((resourceManager, | + | LootTableLoadingCallback.EVENT.register((resourceManager, |
- | if (" | + | if (COAL_ORE_LOOT_TABLE_ID.equals(id)) { |
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder() | FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder() | ||
- | .withRolls(ConstantLootTableRange.create(1)); // Same as " | + | .method_352(class_44.method_32448(1)); // Same as " |
- | | + | |
} | } | ||
}); | }); | ||
- | </code> | + | </yarncode> |
Our pool doesn’t have any items yet, so we’ll make an item entry and add it to the pool, and we're done: | Our pool doesn’t have any items yet, so we’ll make an item entry and add it to the pool, and we're done: | ||
- | <code java> | + | <yarncode |
- | LootTableLoadingCallback.EVENT.register((resourceManager, | + | LootTableLoadingCallback.EVENT.register((resourceManager, |
- | if (" | + | if (COAL_ORE_LOOT_TABLE_ID.equals(id)) { |
FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder() | FabricLootPoolBuilder poolBuilder = FabricLootPoolBuilder.builder() | ||
- | .withRolls(ConstantLootTableRange.create(1)) | + | .method_352(class_44.method_32448(1)); |
- | .withEntry(ItemEntry.builder(Items.EGG)); | + | .method_351(class_77.method_411(class_1802.field_8803)); |
- | | + | |
} | } | ||
}); | }); | ||
- | </code> | + | </yarncode> |
{{: | {{: | ||
tutorial/adding_to_loot_tables.txt · Last modified: 2024/02/05 16:08 by mschae23