This commit is contained in:
Shadows_of_Fire 2018-03-22 22:53:13 -04:00
parent b0efb95e4d
commit 88daf6683d
2 changed files with 35 additions and 25 deletions

View file

@ -37,6 +37,7 @@ import de.ellpeck.actuallyadditions.mod.recipe.TreasureChestHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker; import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
@ -54,7 +55,7 @@ import net.minecraftforge.fml.common.event.FMLServerStartedEvent;
import net.minecraftforge.fml.common.event.FMLServerStoppedEvent; import net.minecraftforge.fml.common.event.FMLServerStoppedEvent;
@Mod(modid = ModUtil.MOD_ID, name = ModUtil.NAME, version = ModUtil.VERSION, guiFactory = "de.ellpeck.actuallyadditions.mod.config.GuiFactory", acceptedMinecraftVersions = "[1.12, 1.13)") @Mod(modid = ModUtil.MOD_ID, name = ModUtil.NAME, version = ModUtil.VERSION, guiFactory = "de.ellpeck.actuallyadditions.mod.config.GuiFactory", acceptedMinecraftVersions = "[1.12, 1.13)")
public class ActuallyAdditions{ public class ActuallyAdditions {
@Instance(ModUtil.MOD_ID) @Instance(ModUtil.MOD_ID)
public static ActuallyAdditions instance; public static ActuallyAdditions instance;
@ -64,20 +65,20 @@ public class ActuallyAdditions{
public static boolean commonCapsLoaded; public static boolean commonCapsLoaded;
static{ static {
//For some reason, this has to be done here //For some reason, this has to be done here
FluidRegistry.enableUniversalBucket(); FluidRegistry.enableUniversalBucket();
} }
@EventHandler @EventHandler
public void preInit(FMLPreInitializationEvent event){ public void preInit(FMLPreInitializationEvent event) {
ModUtil.LOGGER.info("Starting PreInitialization Phase..."); ModUtil.LOGGER.info("Starting PreInitialization Phase...");
ActuallyAdditionsAPI.methodHandler = new MethodHandler(); ActuallyAdditionsAPI.methodHandler = new MethodHandler();
ActuallyAdditionsAPI.connectionHandler = new LaserRelayConnectionHandler(); ActuallyAdditionsAPI.connectionHandler = new LaserRelayConnectionHandler();
Lenses.init(); Lenses.init();
InitBooklet.preInit(); InitBooklet.preInit();
CompatUtil.registerCraftingTweaks();
commonCapsLoaded = Loader.isModLoaded("commoncapabilities"); commonCapsLoaded = Loader.isModLoaded("commoncapabilities");
MinecraftForge.EVENT_BUS.register(new RegistryHandler()); MinecraftForge.EVENT_BUS.register(new RegistryHandler());
@ -94,7 +95,7 @@ public class ActuallyAdditions{
} }
@EventHandler @EventHandler
public void init(FMLInitializationEvent event){ public void init(FMLInitializationEvent event) {
ModUtil.LOGGER.info("Starting Initialization Phase..."); ModUtil.LOGGER.info("Starting Initialization Phase...");
BannerHelper.init(); BannerHelper.init();
@ -113,7 +114,7 @@ public class ActuallyAdditions{
} }
@EventHandler @EventHandler
public void postInit(FMLPostInitializationEvent event){ public void postInit(FMLPostInitializationEvent event) {
ModUtil.LOGGER.info("Starting PostInitialization Phase..."); ModUtil.LOGGER.info("Starting PostInitialization Phase...");
ItemCoffee.initIngredients(); ItemCoffee.initIngredients();
@ -128,23 +129,23 @@ public class ActuallyAdditions{
proxy.postInit(event); proxy.postInit(event);
ConfigurationHandler.redefineConfigs(); ConfigurationHandler.redefineConfigs();
ModUtil.LOGGER.info("PostInitialization Finished."); ModUtil.LOGGER.info("PostInitialization Finished.");
} }
@EventHandler @EventHandler
public void serverStarted(FMLServerStartedEvent event){ public void serverStarted(FMLServerStartedEvent event) {
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
if(server != null){ if (server != null) {
World world = server.getEntityWorld(); World world = server.getEntityWorld();
if(world != null && !world.isRemote){ if (world != null && !world.isRemote) {
WorldData.get(world, true).markDirty(); WorldData.get(world, true).markDirty();
} }
} }
} }
@EventHandler @EventHandler
public void serverStopped(FMLServerStoppedEvent event){ public void serverStopped(FMLServerStoppedEvent event) {
WorldData.clear(); WorldData.clear();
} }
} }

View file

@ -13,28 +13,37 @@ package de.ellpeck.actuallyadditions.mod.util.compat;
import net.minecraft.client.gui.inventory.GuiCrafting; import net.minecraft.client.gui.inventory.GuiCrafting;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ContainerWorkbench; import net.minecraft.inventory.ContainerWorkbench;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraftforge.fml.common.Loader; import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
public final class CompatUtil { public final class CompatUtil {
static boolean fb = Loader.isModLoaded("fastbench"); static boolean fb = Loader.isModLoaded("fastbench");
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public static Object getCrafterGuiElement(EntityPlayer player, World world, int x, int y, int z) { public static Object getCrafterGuiElement(EntityPlayer player, World world, int x, int y, int z) {
if (fb) return CompatFastBench.getFastBenchGui(player, world, x, y, z); if (fb) return CompatFastBench.getFastBenchGui(player, world, x, y, z);
return new GuiCrafting(player.inventory, world, new BlockPos(x, y, z)); return new GuiCrafting(player.inventory, world, new BlockPos(x, y, z));
} }
public static Object getCrafterContainerElement(EntityPlayer player, World world, int x, int y, int z) { public static Object getCrafterContainerElement(EntityPlayer player, World world, int x, int y, int z) {
if (fb) return CompatFastBench.getFastBenchContainer(player, world, x, y, z); if (fb) return CompatFastBench.getFastBenchContainer(player, world, x, y, z);
return new ContainerWorkbench(player.inventory, world, new BlockPos(x, y, z)) { return new ContainerWorkbench(player.inventory, world, new BlockPos(x, y, z)) {
public boolean canInteractWith(EntityPlayer playerIn) { public boolean canInteractWith(EntityPlayer playerIn) {
return true; return true;
} }
}; };
} }
public static void registerCraftingTweaks() {
NBTTagCompound t = new NBTTagCompound();
if (fb) t.setString("ContainerClass", "de.ellpeck.actuallyadditions.mod.util.compat.CompatFastBench$1");
else t.setString("ContainerClass", "de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil$1");
FMLInterModComms.sendMessage("craftingtweaks", "RegisterProvider", t);
}
} }