-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added Pocket Sand to the husk loot table
- Loading branch information
1 parent
adba2ae
commit 8d7df2f
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/net/skywalker8510/pocketsand/util/ModLootTableModifiers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package net.skywalker8510.pocketsand.util; | ||
|
||
import net.fabricmc.fabric.api.loot.v2.LootTableEvents; | ||
import net.minecraft.loot.LootPool; | ||
import net.minecraft.loot.condition.RandomChanceLootCondition; | ||
import net.minecraft.loot.entry.ItemEntry; | ||
import net.minecraft.loot.function.SetCountLootFunction; | ||
import net.minecraft.loot.provider.number.ConstantLootNumberProvider; | ||
import net.minecraft.loot.provider.number.UniformLootNumberProvider; | ||
import net.minecraft.util.Identifier; | ||
import net.skywalker8510.pocketsand.Item.ModItems; | ||
import net.skywalker8510.pocketsand.PocketSand; | ||
|
||
public class ModLootTableModifiers { | ||
|
||
private static final Identifier HUSK_LOOT_TABLE_ID = | ||
new Identifier("minecraft","entities/husk"); | ||
|
||
public static void modifyLootTables() { | ||
|
||
PocketSand.LOGGER.info("Registering Loot Tables for " + PocketSand.MOD_ID); | ||
|
||
LootTableEvents.MODIFY.register((key, tableBuilder, source) -> { | ||
// Let's only modify built-in loot tables and leave data pack loot tables untouched by checking the source. | ||
// We also check that the loot table ID is equal to the ID we want. | ||
if (source.isBuiltin() && HUSK_LOOT_TABLE_ID.equals(key)) { | ||
// We make the pool and add an item | ||
LootPool.Builder poolBuilder = LootPool.builder() | ||
.rolls(ConstantLootNumberProvider.create(1)) | ||
.conditionally(RandomChanceLootCondition.builder(1f)) | ||
.with(ItemEntry.builder(ModItems.POCKET_SAND)) | ||
.apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(2.0f, 5.0f)).build()); | ||
tableBuilder.pool(poolBuilder.build()); | ||
} | ||
}); | ||
} | ||
} |