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

90 lines
3.4 KiB
Java
Raw Normal View History

package com.minelittlepony.unicopia;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerTickEvents;
2021-02-13 12:50:24 +01:00
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.minecraft.resource.ResourceType;
2022-08-27 15:07:29 +02:00
import net.minecraft.util.Identifier;
2021-02-13 12:50:24 +01:00
import java.util.Optional;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.minelittlepony.unicopia.ability.Abilities;
2021-08-20 22:25:46 +02:00
import com.minelittlepony.unicopia.ability.data.tree.TreeTypeLoader;
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
import com.minelittlepony.unicopia.ability.magic.spell.trait.TraitLoader;
2021-08-09 15:20:33 +02:00
import com.minelittlepony.unicopia.advancement.UCriteria;
2021-09-02 19:11:51 +02:00
import com.minelittlepony.unicopia.block.UBlocks;
2022-08-29 14:46:59 +02:00
import com.minelittlepony.unicopia.block.state.StateMapLoader;
import com.minelittlepony.unicopia.command.Commands;
import com.minelittlepony.unicopia.container.SpellbookChapterLoader;
import com.minelittlepony.unicopia.container.UScreenHandlers;
import com.minelittlepony.unicopia.entity.UEntities;
import com.minelittlepony.unicopia.entity.effect.UPotions;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.item.UItems;
import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
import com.minelittlepony.unicopia.network.Channel;
import com.minelittlepony.unicopia.particle.UParticles;
2020-04-16 00:44:58 +02:00
public class Unicopia implements ModInitializer {
2022-08-27 15:07:29 +02:00
public static final String DEFAULT_NAMESPACE = "unicopia";
public static final Logger LOGGER = LogManager.getLogger();
public static SidedAccess SIDE = Optional::empty;
2020-04-25 13:32:33 +02:00
private static Config CONFIG;
public static Config getConfig() {
if (CONFIG == null) {
CONFIG = new Config();
}
return CONFIG;
}
2022-08-27 15:07:29 +02:00
public static Identifier id(String name) {
return new Identifier(DEFAULT_NAMESPACE, name);
}
2020-04-25 13:32:33 +02:00
@Override
public void onInitialize() {
Channel.bootstrap();
UTags.bootstrap();
2021-08-09 15:20:33 +02:00
UCriteria.bootstrap();
2021-08-19 19:52:35 +02:00
UEntities.bootstrap();
Commands.bootstrap();
2021-01-26 21:32:19 +01:00
ServerTickEvents.END_WORLD_TICK.register(w -> {
((BlockDestructionManager.Source)w).getDestructionManager().tick();
if (SpellbookChapterLoader.DEBUG) {
SpellbookChapterLoader.INSTANCE.sendUpdate(w.getServer());
}
2021-01-26 21:32:19 +01:00
});
2021-02-13 12:50:24 +01:00
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(TreeTypeLoader.INSTANCE);
2021-02-17 20:46:07 +01:00
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(UEnchantments.POISONED_JOKE);
2022-09-10 17:02:30 +02:00
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(new TraitLoader());
2022-08-29 14:46:59 +02:00
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(StateMapLoader.INSTANCE);
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(SpellbookChapterLoader.INSTANCE);
2020-05-19 12:43:57 +02:00
2021-09-02 19:11:51 +02:00
UBlocks.bootstrap();
UItems.bootstrap();
UPotions.bootstrap();
UParticles.bootstrap();
USounds.bootstrap();
Race.bootstrap();
SpellType.bootstrap();
Abilities.bootstrap();
UScreenHandlers.bootstrap();
}
public interface SidedAccess {
Optional<Pony> getPony();
default Race getPlayerSpecies() {
return getPony().map(Pony::getSpecies).orElse(Race.HUMAN);
}
}
}