fix BuildCraftCompat pipe override

This commit is contained in:
asiekierka 2014-12-13 19:08:30 +01:00
parent afe5e4efa5
commit 76c57b11b6
3 changed files with 54 additions and 12 deletions

View file

@ -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<? extends TileEntity> getPipeTile() {
Class<? extends TileEntity> tileClass;
if (Loader.isModLoaded("BuildCraft|Compat")) {
try {
tileClass = (Class<? extends TileEntity>) BCCompatHooks.class.getClassLoader().loadClass("buildcraft.transport.TileGenericPipeCompat");
} catch (Exception e) {
e.printStackTrace();
tileClass = TileGenericPipe.class;
}
} else {
tileClass = TileGenericPipe.class;
}
return tileClass;
}
}

View file

@ -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");

View file

@ -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");
}