Skip to content

Commit 6872e63

Browse files
authored
Merge pull request #1 from serenyadev/master
add sniffer loot shit
2 parents 1405f33 + b7c3d4b commit 6872e63

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/main/java/net/flatkat/ancient_forgotten/AncientAndForgotten.java

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import net.flatkat.ancient_forgotten.block.ModBlocks;
66
import net.flatkat.ancient_forgotten.item.ModItemGroups;
77
import net.flatkat.ancient_forgotten.item.ModItems;
8+
import net.flatkat.ancient_forgotten.loot.ModLoot;
89
import org.slf4j.Logger;
910
import org.slf4j.LoggerFactory;
1011

@@ -26,5 +27,6 @@ public void onInitialize() {
2627

2728
ModItems.registerModItems();
2829
ModBlocks.registerModBlocks();
30+
ModLoot.init();
2931
}
3032
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package net.flatkat.ancient_forgotten.loot;
2+
3+
import net.fabricmc.fabric.api.event.Event;
4+
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
5+
import net.flatkat.ancient_forgotten.AncientAndForgotten;
6+
import net.flatkat.ancient_forgotten.item.ModItems;
7+
import net.minecraft.loot.entry.ItemEntry;
8+
import net.minecraft.loot.function.SetCountLootFunction;
9+
import net.minecraft.loot.provider.number.ConstantLootNumberProvider;
10+
import net.minecraft.util.Identifier;
11+
12+
public class ModLoot {
13+
14+
// TODO: Flatkat this is probs not the correct table, no idea what its called
15+
private static final Identifier SNIFFER_TABLE = new Identifier("minecraft:gameplay/sniffer_digging");
16+
17+
private static final Identifier SNIFFER_PHASE = new Identifier(AncientAndForgotten.MOD_ID, "sniffer_phase");
18+
19+
public static void init() {
20+
// Make sure this modification happens before other mods potentially add loot pools
21+
LootTableEvents.MODIFY.addPhaseOrdering(SNIFFER_PHASE, Event.DEFAULT_PHASE);
22+
LootTableEvents.MODIFY.register((resourceManager, lootManager, id, tableBuilder, source) -> {
23+
if(id.equals(SNIFFER_TABLE)) {
24+
tableBuilder.modifyPools(pool -> {
25+
pool.with(ItemEntry.builder(ModItems.RUBY).apply(SetCountLootFunction.builder(ConstantLootNumberProvider.create(1))));
26+
});
27+
}
28+
});
29+
}
30+
31+
32+
}

0 commit comments

Comments
 (0)