2018-09-12 01:29:49 +02:00
|
|
|
package com.minelittlepony.unicopia;
|
|
|
|
|
2018-09-27 22:12:32 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2018-09-19 09:09:30 +02:00
|
|
|
import net.minecraft.item.crafting.IRecipe;
|
2019-01-06 22:31:34 +01:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.world.World;
|
2019-01-29 14:22:36 +01:00
|
|
|
import net.minecraft.world.biome.Biome;
|
2019-02-16 16:49:55 +01:00
|
|
|
import net.minecraftforge.common.MinecraftForge;
|
2018-09-12 01:29:49 +02:00
|
|
|
import net.minecraftforge.fml.common.Mod;
|
|
|
|
import net.minecraftforge.fml.common.Mod.EventHandler;
|
|
|
|
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
2019-01-10 18:46:40 +01:00
|
|
|
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
2018-09-12 01:29:49 +02:00
|
|
|
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
2019-02-22 19:48:36 +01:00
|
|
|
import net.minecraftforge.fml.common.event.FMLServerAboutToStartEvent;
|
2018-09-12 01:29:49 +02:00
|
|
|
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
2019-01-10 18:46:40 +01:00
|
|
|
import net.minecraftforge.fml.common.network.IGuiHandler;
|
|
|
|
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.function.Function;
|
|
|
|
|
2019-01-30 11:26:00 +01:00
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
2019-01-10 18:46:40 +01:00
|
|
|
import com.google.gson.JsonObject;
|
2018-09-12 01:29:49 +02:00
|
|
|
import com.minelittlepony.jumpingcastle.api.IChannel;
|
|
|
|
import com.minelittlepony.jumpingcastle.api.JumpingCastle;
|
2018-09-19 09:09:30 +02:00
|
|
|
import com.minelittlepony.unicopia.advancements.UAdvancements;
|
2018-09-12 01:29:49 +02:00
|
|
|
import com.minelittlepony.unicopia.command.Commands;
|
2019-02-20 14:13:04 +01:00
|
|
|
import com.minelittlepony.unicopia.enchanting.AffineIngredients;
|
2019-02-08 16:56:28 +01:00
|
|
|
import com.minelittlepony.unicopia.enchanting.Pages;
|
2019-01-10 18:46:40 +01:00
|
|
|
import com.minelittlepony.unicopia.enchanting.SpellRecipe;
|
2019-01-07 09:34:58 +01:00
|
|
|
import com.minelittlepony.unicopia.forgebullshit.FBS;
|
2019-02-17 00:08:19 +01:00
|
|
|
import com.minelittlepony.unicopia.init.UEntities;
|
|
|
|
import com.minelittlepony.unicopia.init.UItems;
|
2019-01-10 18:46:40 +01:00
|
|
|
import com.minelittlepony.unicopia.inventory.gui.ContainerSpellBook;
|
|
|
|
import com.minelittlepony.unicopia.inventory.gui.GuiSpellBook;
|
2018-09-12 01:29:49 +02:00
|
|
|
import com.minelittlepony.unicopia.network.MsgPlayerAbility;
|
|
|
|
import com.minelittlepony.unicopia.network.MsgPlayerCapabilities;
|
2018-09-12 22:37:06 +02:00
|
|
|
import com.minelittlepony.unicopia.network.MsgRequestCapabilities;
|
2018-09-12 01:29:49 +02:00
|
|
|
import com.minelittlepony.unicopia.power.PowersRegistry;
|
2019-01-10 18:46:40 +01:00
|
|
|
import com.minelittlepony.unicopia.util.crafting.CraftingManager;
|
2019-02-21 12:56:05 +01:00
|
|
|
import com.minelittlepony.unicopia.world.Hooks;
|
2019-02-09 19:50:01 +01:00
|
|
|
import com.minelittlepony.unicopia.world.UWorld;
|
2018-09-12 01:29:49 +02:00
|
|
|
|
2019-01-08 09:33:46 +01:00
|
|
|
@Mod(
|
|
|
|
modid = Unicopia.MODID,
|
|
|
|
name = Unicopia.NAME,
|
|
|
|
version = Unicopia.VERSION,
|
2019-02-18 18:48:06 +01:00
|
|
|
dependencies = "required-after:jumpingcastle;after:baubles"
|
2019-01-08 09:33:46 +01:00
|
|
|
)
|
2019-01-10 18:46:40 +01:00
|
|
|
public class Unicopia implements IGuiHandler {
|
2018-09-12 01:29:49 +02:00
|
|
|
public static final String MODID = "unicopia";
|
|
|
|
public static final String NAME = "@NAME@";
|
|
|
|
public static final String VERSION = "@VERSION@";
|
|
|
|
|
2019-01-30 11:26:00 +01:00
|
|
|
public static final Logger log = LogManager.getLogger();
|
2018-09-12 01:29:49 +02:00
|
|
|
|
2019-02-17 00:08:19 +01:00
|
|
|
private static IChannel channel;
|
2018-09-24 21:37:50 +02:00
|
|
|
|
2019-03-05 11:45:56 +01:00
|
|
|
private static CraftingManager craftingManager = new CraftingManager(MODID, "enchanting") {
|
|
|
|
@Override
|
|
|
|
protected void registerRecipeTypes(Map<String, Function<JsonObject, IRecipe>> types) {
|
|
|
|
super.registerRecipeTypes(types);
|
|
|
|
|
|
|
|
types.put("unicopia:crafting_spell", SpellRecipe::deserialize);
|
|
|
|
|
|
|
|
AffineIngredients.instance().load();
|
|
|
|
}
|
|
|
|
};
|
2019-01-10 18:46:40 +01:00
|
|
|
|
2019-02-17 00:08:19 +01:00
|
|
|
public static CraftingManager getCraftingManager() {
|
|
|
|
return craftingManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static IChannel getConnection() {
|
|
|
|
return channel;
|
|
|
|
}
|
2019-02-16 16:49:55 +01:00
|
|
|
|
2018-09-12 01:29:49 +02:00
|
|
|
@EventHandler
|
|
|
|
public void preInit(FMLPreInitializationEvent event) {
|
2019-01-13 21:07:44 +01:00
|
|
|
UConfig.init(event.getModConfigurationDirectory());
|
2019-02-17 00:08:19 +01:00
|
|
|
UClient.instance().preInit();
|
2019-02-16 16:49:55 +01:00
|
|
|
UWorld.instance().init();
|
|
|
|
|
2019-02-21 12:56:05 +01:00
|
|
|
MinecraftForge.TERRAIN_GEN_BUS.register(Hooks.class);
|
2019-02-16 16:49:55 +01:00
|
|
|
}
|
|
|
|
|
2019-02-22 19:48:36 +01:00
|
|
|
@EventHandler
|
|
|
|
public void onServerCreated(FMLServerAboutToStartEvent event) {
|
|
|
|
Fixes.init(event.getServer().getDataFixer());
|
|
|
|
}
|
|
|
|
|
2019-02-17 00:08:19 +01:00
|
|
|
@EventHandler
|
|
|
|
public void onServerStart(FMLServerStartingEvent event) {
|
|
|
|
Commands.init(event);
|
2018-09-24 21:37:50 +02:00
|
|
|
}
|
|
|
|
|
2018-09-12 01:29:49 +02:00
|
|
|
@EventHandler
|
|
|
|
public void init(FMLInitializationEvent event) {
|
2018-09-25 00:22:04 +02:00
|
|
|
channel = JumpingCastle.subscribeTo(MODID, () -> {})
|
2018-09-20 22:49:10 +02:00
|
|
|
.listenFor(MsgRequestCapabilities.class)
|
|
|
|
.listenFor(MsgPlayerCapabilities.class)
|
|
|
|
.listenFor(MsgPlayerAbility.class);
|
2018-09-12 01:29:49 +02:00
|
|
|
|
|
|
|
PowersRegistry.instance().init();
|
|
|
|
|
2018-09-19 09:09:30 +02:00
|
|
|
UAdvancements.init();
|
|
|
|
|
2018-09-12 01:29:49 +02:00
|
|
|
FBS.init();
|
2019-01-10 18:46:40 +01:00
|
|
|
|
|
|
|
NetworkRegistry.INSTANCE.registerGuiHandler(this, this);
|
2019-01-30 11:26:00 +01:00
|
|
|
|
2019-02-17 00:08:19 +01:00
|
|
|
UClient.instance().init();
|
2019-01-10 18:46:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@EventHandler
|
|
|
|
public void posInit(FMLPostInitializationEvent event) {
|
2019-03-05 11:45:56 +01:00
|
|
|
craftingManager.load();
|
2019-01-29 14:22:36 +01:00
|
|
|
|
2019-02-08 16:56:28 +01:00
|
|
|
Pages.instance().load();
|
|
|
|
|
2019-01-29 14:22:36 +01:00
|
|
|
Biome.REGISTRY.forEach(UEntities::registerSpawnEntries);
|
2019-02-17 00:08:19 +01:00
|
|
|
UClient.instance().posInit();
|
2019-02-01 17:29:58 +01:00
|
|
|
|
|
|
|
UItems.fixRecipes();
|
2018-09-12 01:29:49 +02:00
|
|
|
}
|
|
|
|
|
2019-01-10 18:46:40 +01:00
|
|
|
@Override
|
|
|
|
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
|
|
|
switch (ID) {
|
|
|
|
case 0: return new ContainerSpellBook(player.inventory, world, new BlockPos(x, y, z));
|
|
|
|
default: return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
|
|
|
switch (ID) {
|
|
|
|
case 0: return new GuiSpellBook(player);
|
|
|
|
default: return null;
|
|
|
|
}
|
|
|
|
}
|
2018-09-12 01:29:49 +02:00
|
|
|
}
|