Unicopia/src/main/java/com/minelittlepony/unicopia/Unicopia.java

71 lines
2.4 KiB
Java
Raw Normal View History

package com.minelittlepony.unicopia;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.world.WorldTickCallback;
2020-05-19 12:43:57 +02:00
import net.fabricmc.fabric.api.loot.v1.FabricLootSupplier;
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
2020-05-19 12:43:57 +02:00
import net.minecraft.loot.LootTable;
import net.minecraft.resource.ResourceType;
2020-05-19 12:43:57 +02:00
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
2020-04-22 20:23:54 +02:00
import com.minelittlepony.unicopia.advancement.BOHDeathCriterion;
2020-04-15 19:06:45 +02:00
import com.minelittlepony.unicopia.block.UBlocks;
import com.minelittlepony.unicopia.command.Commands;
2020-04-15 19:06:45 +02:00
import com.minelittlepony.unicopia.container.UContainers;
import com.minelittlepony.unicopia.enchanting.Pages;
import com.minelittlepony.unicopia.item.UItems;
2020-04-22 20:23:54 +02:00
import com.minelittlepony.unicopia.mixin.CriterionsRegistry;
import com.minelittlepony.unicopia.network.Channel;
import com.minelittlepony.unicopia.recipe.URecipes;
import com.minelittlepony.unicopia.structure.UStructures;
2020-04-16 00:44:58 +02:00
public class Unicopia implements ModInitializer {
2020-04-25 13:32:33 +02:00
public static final Logger LOGGER = LogManager.getLogger();
2020-04-25 13:32:33 +02:00
private static Config CONFIG;
public static Config getConfig() {
if (CONFIG == null) {
CONFIG = new Config();
}
return CONFIG;
}
public Unicopia() {
getConfig();
}
@Override
public void onInitialize() {
Channel.bootstrap();
UTags.bootstrap();
Commands.bootstrap();
UBlocks.bootstrap();
UItems.bootstrap();
UContainers.bootstrap();
UStructures.bootstrap();
URecipes.bootstrap();
2020-04-22 20:23:54 +02:00
CriterionsRegistry.register(BOHDeathCriterion.INSTANCE);
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(Pages.instance());
WorldTickCallback.EVENT.register(AwaitTickQueue::tick);
2020-05-19 12:43:57 +02:00
LootTableLoadingCallback.EVENT.register((res, manager, id, supplier, setter) -> {
if (!"minecraft".contentEquals(id.getNamespace())) {
return;
}
Identifier modId = new Identifier("unicopiamc", id.getPath());
LootTable table = manager.getSupplier(modId);
if (table != LootTable.EMPTY) {
supplier.withPools(((FabricLootSupplier)table).getPools());
}
});
}
}