ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/util/compat/CompatUtil.java

50 lines
2 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
2016-05-16 22:52:27 +02:00
* This file ("CompatUtil.java") is part of the Actually Additions mod for Minecraft.
2015-08-29 14:33:25 +02:00
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
2015-08-29 14:33:25 +02:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2017-01-01 16:23:26 +01:00
* © 2015-2017 Ellpeck
2015-08-29 14:33:25 +02:00
*/
2016-06-17 14:00:52 +02:00
package de.ellpeck.actuallyadditions.mod.util.compat;
2015-06-28 03:12:32 +02:00
2018-03-07 03:08:25 +01:00
import net.minecraft.client.gui.inventory.GuiCrafting;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ContainerWorkbench;
2018-03-23 03:53:13 +01:00
import net.minecraft.nbt.NBTTagCompound;
2018-03-07 03:08:25 +01:00
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Loader;
2018-03-23 03:53:13 +01:00
import net.minecraftforge.fml.common.event.FMLInterModComms;
2018-03-17 00:07:15 +01:00
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
2015-06-28 03:12:32 +02:00
2018-03-07 03:08:25 +01:00
public final class CompatUtil {
2015-06-28 03:12:32 +02:00
2018-03-23 03:53:13 +01:00
static boolean fb = Loader.isModLoaded("fastbench");
2018-03-07 03:08:25 +01:00
2018-03-23 03:53:13 +01:00
@SideOnly(Side.CLIENT)
public static Object getCrafterGuiElement(EntityPlayer player, World world, int x, int y, int z) {
if (fb) return CompatFastBench.getFastBenchGui(player, world, x, y, z);
return new GuiCrafting(player.inventory, world, new BlockPos(x, y, z));
}
2018-03-07 03:08:25 +01:00
2018-03-23 03:53:13 +01:00
public static Object getCrafterContainerElement(EntityPlayer player, World world, int x, int y, int z) {
if (fb) return CompatFastBench.getFastBenchContainer(player, world, x, y, z);
return new ContainerWorkbench(player.inventory, world, new BlockPos(x, y, z)) {
public boolean canInteractWith(EntityPlayer playerIn) {
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);
}
2015-06-28 03:12:32 +02:00
}