mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-10-26 11:27:38 +00:00
Switch away from Forge's loot modifiers
We switched to Forge's loot modifier system in the 1.20 update, as LootTable.addPool had been removed. Turns out this was by accident, and so we switch back to the previous implementation, as it's much simpler and efficient.
This commit is contained in:
@@ -23,7 +23,11 @@ import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
||||
import net.minecraft.world.level.storage.loot.LootPool;
|
||||
import net.minecraft.world.level.storage.loot.entries.LootTableReference;
|
||||
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
@@ -71,7 +75,7 @@ public final class CommonHooks {
|
||||
|
||||
public static final ResourceLocation TREASURE_DISK_LOOT = new ResourceLocation(ComputerCraftAPI.MOD_ID, "treasure_disk");
|
||||
|
||||
public static final Set<ResourceLocation> TREASURE_DISK_LOOT_TABLES = Set.of(
|
||||
private static final Set<ResourceLocation> TREASURE_DISK_LOOT_TABLES = Set.of(
|
||||
BuiltInLootTables.SIMPLE_DUNGEON,
|
||||
BuiltInLootTables.ABANDONED_MINESHAFT,
|
||||
BuiltInLootTables.STRONGHOLD_CORRIDOR,
|
||||
@@ -84,6 +88,16 @@ public final class CommonHooks {
|
||||
BuiltInLootTables.VILLAGE_CARTOGRAPHER
|
||||
);
|
||||
|
||||
public static @Nullable LootPool.Builder getExtraLootPool(ResourceLocation lootTable) {
|
||||
if (!lootTable.getNamespace().equals("minecraft") || !TREASURE_DISK_LOOT_TABLES.contains(lootTable)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return LootPool.lootPool()
|
||||
.add(LootTableReference.lootTableReference(TREASURE_DISK_LOOT))
|
||||
.setRolls(ConstantValue.exactly(1));
|
||||
}
|
||||
|
||||
public static void onDatapackReload(BiConsumer<String, PreparableReloadListener> addReload) {
|
||||
addReload.accept("mounts", ResourceMount.RELOAD_LISTENER);
|
||||
addReload.accept("turtle_upgrades", TurtleUpgrades.instance());
|
||||
|
||||
Reference in New Issue
Block a user