NaturesAura/src/main/java/de/ellpeck/naturesaura/NaturesAura.java

118 lines
3.8 KiB
Java
Raw Normal View History

2018-10-13 20:35:18 +02:00
package de.ellpeck.naturesaura;
2018-11-11 13:26:19 +01:00
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.container.IAuraContainer;
import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge;
2019-02-17 22:51:05 +01:00
import de.ellpeck.naturesaura.api.misc.IWorldData;
2018-10-13 23:46:30 +02:00
import de.ellpeck.naturesaura.blocks.ModBlocks;
2018-11-07 13:33:49 +01:00
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.chunk.effect.DrainSpotEffects;
2018-10-19 14:35:25 +02:00
import de.ellpeck.naturesaura.compat.Compat;
import de.ellpeck.naturesaura.events.CommonEvents;
2018-10-14 17:46:00 +02:00
import de.ellpeck.naturesaura.items.ModItems;
2018-10-14 14:27:18 +02:00
import de.ellpeck.naturesaura.packet.PacketHandler;
2018-11-29 17:58:47 +01:00
import de.ellpeck.naturesaura.potion.ModPotions;
2019-11-04 19:08:49 +01:00
import de.ellpeck.naturesaura.proxy.ClientProxy;
2018-10-13 20:35:18 +02:00
import de.ellpeck.naturesaura.proxy.IProxy;
2019-11-04 19:08:49 +01:00
import de.ellpeck.naturesaura.proxy.ServerProxy;
2018-10-16 01:36:30 +02:00
import de.ellpeck.naturesaura.recipes.ModRecipes;
2018-10-13 20:35:18 +02:00
import de.ellpeck.naturesaura.reg.ModRegistry;
2019-10-20 22:30:49 +02:00
import net.minecraft.item.ItemGroup;
2018-10-13 20:35:18 +02:00
import net.minecraft.item.ItemStack;
2019-11-04 19:08:49 +01:00
import net.minecraft.util.ResourceLocation;
2018-10-16 11:49:30 +02:00
import net.minecraftforge.common.MinecraftForge;
2019-11-04 19:08:49 +01:00
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
2018-10-13 20:35:18 +02:00
import net.minecraftforge.fml.common.Mod;
2019-11-04 19:08:49 +01:00
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
2018-10-13 20:35:18 +02:00
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
2018-12-01 18:56:05 +01:00
import java.util.Locale;
2019-11-04 19:08:49 +01:00
@Mod(NaturesAura.MOD_ID)
2018-10-13 20:35:18 +02:00
public final class NaturesAura {
public static final String MOD_ID = NaturesAuraAPI.MOD_ID;
2018-12-01 18:56:05 +01:00
public static final String MOD_ID_UPPER = MOD_ID.toUpperCase(Locale.ROOT);
2018-10-13 20:35:18 +02:00
public static final String MOD_NAME = "Nature's Aura";
public static final String VERSION = "@VERSION@";
public static final Logger LOGGER = LogManager.getLogger(MOD_NAME);
2019-03-19 17:21:06 +01:00
public static NaturesAura instance;
2019-11-04 19:08:49 +01:00
public NaturesAura() {
instance = this;
IEventBus eventBus = FMLJavaModLoadingContext.get().getModEventBus();
eventBus.addListener(this::setup);
}
public static IProxy proxy = DistExecutor.runForDist(() -> ClientProxy::new, () -> ServerProxy::new);
2018-10-13 20:35:18 +02:00
2019-10-20 22:30:49 +02:00
public static final ItemGroup CREATIVE_TAB = new ItemGroup(MOD_ID) {
2018-10-13 20:35:18 +02:00
@Override
public ItemStack createIcon() {
return new ItemStack(ModItems.GOLD_LEAF);
2018-10-13 20:35:18 +02:00
}
};
2019-11-04 19:08:49 +01:00
public static ResourceLocation createRes(String resource) {
return new ResourceLocation(MOD_ID, resource);
}
public void setup(FMLCommonSetupEvent event) {
preInit(event);
init(event);
postInit(event);
}
public void preInit(FMLCommonSetupEvent event) {
2018-11-11 13:26:19 +01:00
NaturesAuraAPI.setInstance(new InternalHooks());
2018-11-12 22:04:40 +01:00
Helper.registerCap(IAuraContainer.class);
Helper.registerCap(IAuraRecharge.class);
Helper.registerCap(IAuraChunk.class);
2019-02-17 22:51:05 +01:00
Helper.registerCap(IWorldData.class);
2018-10-20 21:19:08 +02:00
2018-10-13 23:46:30 +02:00
new ModBlocks();
2018-10-14 17:46:00 +02:00
new ModItems();
2018-11-29 17:58:47 +01:00
new ModPotions();
2018-10-16 01:36:30 +02:00
2018-11-11 16:50:51 +01:00
Compat.preInit();
2018-10-14 14:27:18 +02:00
PacketHandler.init();
new Multiblocks();
2018-10-16 01:36:30 +02:00
MinecraftForge.EVENT_BUS.register(new CommonEvents());
2018-10-16 01:36:30 +02:00
2018-10-13 20:35:18 +02:00
proxy.preInit(event);
}
2019-11-04 19:08:49 +01:00
public void init(FMLCommonSetupEvent event) {
2018-11-20 19:59:18 +01:00
ModConfig.initOrReload(false);
2018-10-16 01:36:30 +02:00
ModRecipes.init();
2018-10-13 20:35:18 +02:00
ModRegistry.init(event);
DrainSpotEffects.init();
2018-10-16 01:36:30 +02:00
2018-10-13 20:35:18 +02:00
proxy.init(event);
}
2019-11-04 19:08:49 +01:00
public void postInit(FMLCommonSetupEvent event) {
2018-11-11 16:50:51 +01:00
Compat.postInit();
2018-10-13 20:35:18 +02:00
proxy.postInit(event);
2018-10-28 16:21:43 +01:00
if (ModConfig.enabledFeatures.removeDragonBreathContainerItem) {
2019-11-04 19:08:49 +01:00
// TODO Items.DRAGON_BREATH.setContainerItem(null);
2018-10-28 16:21:43 +01:00
}
2018-10-13 20:35:18 +02:00
}
public void serverStarting(FMLServerStartingEvent event) {
2019-11-04 19:08:49 +01:00
// TODO event.registerServerCommand(new CommandAura());
}
2019-11-04 19:08:49 +01:00
2018-10-13 20:35:18 +02:00
}