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;
|
2024-06-23 17:59:02 +02:00
|
|
|
import net.fabricmc.fabric.api.event.player.PlayerBlockBreakEvents;
|
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
|
|
|
|
2020-01-27 17:37:22 +01:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
2022-08-27 16:37:37 +02:00
|
|
|
import com.minelittlepony.unicopia.ability.Abilities;
|
2021-08-20 22:25:46 +02:00
|
|
|
import com.minelittlepony.unicopia.ability.data.tree.TreeTypeLoader;
|
2022-08-27 16:37:37 +02:00
|
|
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
2021-11-05 14:18:32 +01:00
|
|
|
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;
|
2020-04-15 14:22:03 +02:00
|
|
|
import com.minelittlepony.unicopia.command.Commands;
|
2023-09-10 23:14:27 +02:00
|
|
|
import com.minelittlepony.unicopia.compat.trinkets.TrinketsDelegate;
|
2022-09-12 01:46:48 +02:00
|
|
|
import com.minelittlepony.unicopia.container.SpellbookChapterLoader;
|
2022-08-27 16:37:37 +02:00
|
|
|
import com.minelittlepony.unicopia.container.UScreenHandlers;
|
2023-11-28 16:26:55 +01:00
|
|
|
import com.minelittlepony.unicopia.diet.DietsLoader;
|
2023-12-03 03:39:55 +01:00
|
|
|
import com.minelittlepony.unicopia.diet.affliction.AfflictionType;
|
2023-06-06 22:43:40 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.damage.UDamageTypes;
|
2024-06-23 17:59:02 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.effect.SeaponyGraceStatusEffect;
|
2020-09-28 20:18:10 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.effect.UPotions;
|
2023-09-02 19:34:57 +02:00
|
|
|
import com.minelittlepony.unicopia.entity.mob.UEntities;
|
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;
|
2022-08-27 16:37:37 +02:00
|
|
|
import com.minelittlepony.unicopia.particle.UParticles;
|
2023-04-30 11:46:33 +02:00
|
|
|
import com.minelittlepony.unicopia.server.world.BlockDestructionManager;
|
2024-09-19 22:27:53 +02:00
|
|
|
import com.minelittlepony.unicopia.server.world.Ether;
|
2023-04-30 13:34:20 +02:00
|
|
|
import com.minelittlepony.unicopia.server.world.NocturnalSleepManager;
|
2023-04-30 11:46:33 +02:00
|
|
|
import com.minelittlepony.unicopia.server.world.UGameRules;
|
2023-09-09 15:32:27 +02:00
|
|
|
import com.minelittlepony.unicopia.server.world.UWorldGen;
|
2023-04-30 11:46:33 +02:00
|
|
|
import com.minelittlepony.unicopia.server.world.WeatherConditions;
|
|
|
|
import com.minelittlepony.unicopia.server.world.ZapAppleStageStore;
|
2020-01-27 17:37:22 +01:00
|
|
|
|
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";
|
2020-01-27 17:37:22 +01: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();
|
2023-09-10 21:04:52 +02:00
|
|
|
try {
|
|
|
|
CONFIG.load();
|
|
|
|
} catch (IllegalStateException ignored) {
|
|
|
|
CONFIG.save();
|
|
|
|
}
|
2020-04-25 13:32:33 +02:00
|
|
|
}
|
|
|
|
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
|
|
|
|
2020-01-27 17:37:22 +01:00
|
|
|
@Override
|
|
|
|
public void onInitialize() {
|
2020-04-23 23:44:31 +02:00
|
|
|
Channel.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();
|
2024-02-24 14:06:32 +01:00
|
|
|
TrinketsDelegate.getInstance(null).bootstrap();
|
2020-04-15 14:22:03 +02:00
|
|
|
|
2021-01-26 21:32:19 +01:00
|
|
|
ServerTickEvents.END_WORLD_TICK.register(w -> {
|
|
|
|
((BlockDestructionManager.Source)w).getDestructionManager().tick();
|
2022-09-23 23:25:00 +02:00
|
|
|
ZapAppleStageStore.get(w).tick();
|
2022-10-12 15:46:15 +02:00
|
|
|
WeatherConditions.get(w).tick();
|
2024-09-19 22:27:53 +02:00
|
|
|
Ether.get(w).tick();
|
2023-08-13 11:04:09 +02:00
|
|
|
if (Debug.SPELLBOOK_CHAPTERS) {
|
2022-09-12 12:50:10 +02:00
|
|
|
SpellbookChapterLoader.INSTANCE.sendUpdate(w.getServer());
|
|
|
|
}
|
2023-08-13 11:04:09 +02:00
|
|
|
if (Debug.CHECK_GAME_VALUES) {
|
|
|
|
Debug.runTests(w);
|
|
|
|
}
|
2021-01-26 21:32:19 +01:00
|
|
|
});
|
2024-06-23 17:59:02 +02:00
|
|
|
PlayerBlockBreakEvents.AFTER.register(SeaponyGraceStatusEffect::processBlockChange);
|
2023-04-30 13:34:20 +02:00
|
|
|
NocturnalSleepManager.bootstrap();
|
|
|
|
|
2023-11-28 16:26:55 +01:00
|
|
|
registerServerDataReloaders(ResourceManagerHelper.get(ResourceType.SERVER_DATA));
|
2020-05-19 12:43:57 +02:00
|
|
|
|
2022-09-30 00:23:16 +02:00
|
|
|
UGameEvents.bootstrap();
|
2021-09-02 19:11:51 +02:00
|
|
|
UBlocks.bootstrap();
|
2023-11-10 19:14:26 +01:00
|
|
|
UPOIs.bootstrap();
|
2020-09-22 15:11:20 +02:00
|
|
|
UItems.bootstrap();
|
2020-09-28 20:18:10 +02:00
|
|
|
UPotions.bootstrap();
|
2022-08-27 16:37:37 +02:00
|
|
|
UParticles.bootstrap();
|
|
|
|
USounds.bootstrap();
|
|
|
|
Race.bootstrap();
|
|
|
|
SpellType.bootstrap();
|
2023-11-28 16:26:55 +01:00
|
|
|
AfflictionType.bootstrap();
|
2022-08-27 16:37:37 +02:00
|
|
|
Abilities.bootstrap();
|
|
|
|
UScreenHandlers.bootstrap();
|
2023-09-09 15:32:27 +02:00
|
|
|
UWorldGen.bootstrap();
|
2023-01-27 19:06:06 +01:00
|
|
|
UGameRules.bootstrap();
|
2023-06-06 22:43:40 +02:00
|
|
|
UDamageTypes.bootstrap();
|
2020-01-27 17:37:22 +01:00
|
|
|
}
|
2021-03-01 14:09:38 +01:00
|
|
|
|
2023-11-28 16:26:55 +01:00
|
|
|
private void registerServerDataReloaders(ResourceManagerHelper registry) {
|
|
|
|
registry.registerReloadListener(TreeTypeLoader.INSTANCE);
|
|
|
|
registry.registerReloadListener(UEnchantments.POISONED_JOKE);
|
|
|
|
registry.registerReloadListener(new TraitLoader());
|
|
|
|
registry.registerReloadListener(StateMapLoader.INSTANCE);
|
|
|
|
registry.registerReloadListener(SpellbookChapterLoader.INSTANCE);
|
|
|
|
registry.registerReloadListener(new DietsLoader());
|
|
|
|
}
|
2020-01-27 17:37:22 +01:00
|
|
|
}
|