diff --git a/common/buildcraft/BCCompatHooks.java b/common/buildcraft/BCCompatHooks.java new file mode 100644 index 00000000..453d494c --- /dev/null +++ b/common/buildcraft/BCCompatHooks.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team + * http://www.mod-buildcraft.com + * + * BuildCraft is distributed under the terms of the Minecraft Mod Public + * License 1.0, or MMPL. Please check the contents of the license located in + * http://www.mod-buildcraft.com/MMPL-1.0.txt + */ +package buildcraft; + +import net.minecraft.tileentity.TileEntity; +import cpw.mods.fml.common.Loader; +import buildcraft.transport.BlockGenericPipe; +import buildcraft.transport.TileGenericPipe; + +public class BCCompatHooks { + public static BlockGenericPipe createPipeBlock() { + BlockGenericPipe genericPipeBlock; + + if (Loader.isModLoaded("BuildCraft|Compat")) { + try { + genericPipeBlock = (BlockGenericPipe) BCCompatHooks.class.getClassLoader().loadClass("buildcraft.transport.BlockGenericPipeCompat").newInstance(); + } catch (Exception e) { + e.printStackTrace(); + genericPipeBlock = new BlockGenericPipe(); + } + } else { + genericPipeBlock = new BlockGenericPipe(); + } + + return genericPipeBlock; + } + + public static Class getPipeTile() { + Class tileClass; + + if (Loader.isModLoaded("BuildCraft|Compat")) { + try { + tileClass = (Class) BCCompatHooks.class.getClassLoader().loadClass("buildcraft.transport.TileGenericPipeCompat"); + } catch (Exception e) { + e.printStackTrace(); + tileClass = TileGenericPipe.class; + } + } else { + tileClass = TileGenericPipe.class; + } + + return tileClass; + } +} diff --git a/common/buildcraft/BuildCraftTransport.java b/common/buildcraft/BuildCraftTransport.java index 77e7103f..66c12257 100644 --- a/common/buildcraft/BuildCraftTransport.java +++ b/common/buildcraft/BuildCraftTransport.java @@ -366,17 +366,8 @@ public class BuildCraftTransport extends BuildCraftMod { pipeWaterproof.setUnlocalizedName("pipeWaterproof"); CoreProxy.proxy.registerItem(pipeWaterproof); - if (Loader.isModLoaded("BuildCraft|Compat")) { - try { - genericPipeBlock = (BlockGenericPipe) this.getClass().getClassLoader().loadClass("buildcraft.transport.BlockGenericPipeCompat").newInstance(); - } catch (Exception e) { - e.printStackTrace(); - genericPipeBlock = new BlockGenericPipe(); - } - } else { - genericPipeBlock = new BlockGenericPipe(); - } - + genericPipeBlock = BCCompatHooks.createPipeBlock(); + CoreProxy.proxy.registerBlock(genericPipeBlock.setBlockName("pipeBlock"), ItemBlock.class); pipeItemsWood = buildPipe(PipeItemsWood.class, "Wooden Transport Pipe", CreativeTabBuildCraft.PIPES, "plankWood", Blocks.glass, "plankWood"); diff --git a/common/buildcraft/transport/TransportProxy.java b/common/buildcraft/transport/TransportProxy.java index 566a660c..7b52eaeb 100644 --- a/common/buildcraft/transport/TransportProxy.java +++ b/common/buildcraft/transport/TransportProxy.java @@ -11,6 +11,7 @@ package buildcraft.transport; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.registry.GameRegistry; +import buildcraft.BCCompatHooks; import buildcraft.BuildCraftTransport; public class TransportProxy { @@ -21,7 +22,7 @@ public class TransportProxy { public void registerTileEntities() { // The first name here is the current TE name; the remaining names are old names used for backwards compatibility - GameRegistry.registerTileEntityWithAlternatives(TileGenericPipe.class, "net.minecraft.src.buildcraft.transport.GenericPipe", "net.minecraft.src.buildcraft.GenericPipe", "net.minecraft.src.buildcraft.transport.TileGenericPipe"); + GameRegistry.registerTileEntityWithAlternatives(BCCompatHooks.getPipeTile(), "net.minecraft.src.buildcraft.transport.GenericPipe", "net.minecraft.src.buildcraft.GenericPipe", "net.minecraft.src.buildcraft.transport.TileGenericPipe"); GameRegistry.registerTileEntity(TileFilteredBuffer.class, "net.minecraft.src.buildcraft.transport.TileFilteredBuffer"); }