-
Notifications
You must be signed in to change notification settings - Fork 81
/
NaturaLootTableProvider.java
50 lines (42 loc) · 1.91 KB
/
NaturaLootTableProvider.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package com.progwml6.natura.common.data.loot;
import com.google.common.collect.ImmutableList;
import com.mojang.datafixers.util.Pair;
import com.progwml6.natura.Natura;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.LootTables;
import net.minecraft.world.level.storage.loot.ValidationContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSet;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Supplier;
public class NaturaLootTableProvider extends LootTableProvider {
private LootTableProvider x;
private final List<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootContextParamSet>> lootTables = ImmutableList.of(Pair.of(BlockLootTableProvider::new, LootContextParamSets.BLOCK));
public NaturaLootTableProvider(DataGenerator gen) {
super(gen);
}
@Override
protected List<Pair<Supplier<Consumer<BiConsumer<ResourceLocation, LootTable.Builder>>>, LootContextParamSet>> getTables() {
return lootTables;
}
@Override
protected void validate(Map<ResourceLocation, LootTable> map, ValidationContext validationtracker) {
map.forEach((loc, table) -> LootTables.validate(validationtracker, loc, table));
// Remove vanilla's tables, which we also loaded so we can redirect stuff to them.
// This ensures the remaining generator logic doesn't write those to files.
map.keySet().removeIf((loc) -> !loc.getNamespace().equals(Natura.MOD_ID));
}
/**
* Gets a name for this provider, to use in logging.
*/
@Override
public String getName() {
return "Natura LootTables";
}
}