2020-04-15 14:22:03 +02:00
|
|
|
package com.minelittlepony.unicopia;
|
2020-01-27 17:37:22 +01:00
|
|
|
|
|
|
|
import net.fabricmc.api.ModInitializer;
|
2020-09-22 15:11:20 +02:00
|
|
|
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;
|
|
|
|
|
2021-03-01 14:09:38 +01:00
|
|
|
import java.util.Optional;
|
|
|
|
|
2020-01-27 17:37:22 +01:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
2021-08-20 22:25:46 +02:00
|
|
|
import com.minelittlepony.unicopia.ability.data.tree.TreeTypeLoader;
|
2021-08-09 15:20:33 +02:00
|
|
|
import com.minelittlepony.unicopia.advancement.UCriteria;
|
2020-04-15 14:22:03 +02:00
|
|
|
import com.minelittlepony.unicopia.command.Commands;
|
2020-09-28 20:18:10 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.effect.UPotions;
|
2021-03-01 14:09:38 +01:00
|
|
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
2020-09-22 15:11:20 +02:00
|
|
|
import com.minelittlepony.unicopia.item.UItems;
|
2021-02-16 22:12:09 +01:00
|
|
|
import com.minelittlepony.unicopia.item.enchantment.UEnchantments;
|
2020-04-23 23:44:31 +02:00
|
|
|
import com.minelittlepony.unicopia.network.Channel;
|
2020-01-27 17:37:22 +01:00
|
|
|
|
2020-04-16 00:44:58 +02:00
|
|
|
public class Unicopia implements ModInitializer {
|
2020-04-25 13:32:33 +02:00
|
|
|
|
2020-01-27 17:37:22 +01:00
|
|
|
public static final Logger LOGGER = LogManager.getLogger();
|
|
|
|
|
2021-03-01 14:09:38 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Unicopia() {
|
|
|
|
getConfig();
|
|
|
|
}
|
|
|
|
|
2020-01-27 17:37:22 +01:00
|
|
|
@Override
|
|
|
|
public void onInitialize() {
|
2020-04-23 23:44:31 +02:00
|
|
|
Channel.bootstrap();
|
2020-01-27 17:37:22 +01:00
|
|
|
UTags.bootstrap();
|
2021-08-09 15:20:33 +02:00
|
|
|
UCriteria.bootstrap();
|
2021-08-19 19:52:35 +02:00
|
|
|
UEntities.bootstrap();
|
2020-01-27 17:37:22 +01:00
|
|
|
Commands.bootstrap();
|
2020-04-15 14:22:03 +02:00
|
|
|
|
2021-01-26 21:32:19 +01:00
|
|
|
ServerTickEvents.END_WORLD_TICK.register(w -> {
|
|
|
|
AwaitTickQueue.tick(w);
|
|
|
|
((BlockDestructionManager.Source)w).getDestructionManager().tick();
|
|
|
|
});
|
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);
|
2020-05-19 12:43:57 +02:00
|
|
|
|
2020-09-22 15:11:20 +02:00
|
|
|
UItems.bootstrap();
|
2020-09-28 20:18:10 +02:00
|
|
|
UPotions.bootstrap();
|
2020-01-27 17:37:22 +01:00
|
|
|
}
|
2021-03-01 14:09:38 +01:00
|
|
|
|
|
|
|
public interface SidedAccess {
|
|
|
|
Optional<Pony> getPony();
|
|
|
|
|
|
|
|
default Race getPlayerSpecies() {
|
|
|
|
return getPony().map(Pony::getSpecies).orElse(Race.HUMAN);
|
|
|
|
}
|
|
|
|
}
|
2020-01-27 17:37:22 +01:00
|
|
|
}
|