Search in sources :

Example 1 with TileEntityAluminumWire

use of micdoodle8.mods.galacticraft.core.tile.TileEntityAluminumWire in project Galacticraft by micdoodle8.

the class BlockEnclosed method createNewTileEntity.

@Override
public TileEntity createNewTileEntity(World world, int metadata) {
    if (metadata == EnumEnclosedBlockType.TE_CONDUIT.getMeta()) {
    // TODO
    } else if (metadata == EnumEnclosedBlockType.OXYGEN_PIPE.getMeta()) {
        return new TileEntityFluidPipe();
    } else if (metadata <= 6) {
        if (CompatibilityManager.isIc2Loaded()) {
            try {
                Enum[] enums = (Enum[]) CompatibilityManager.classIC2cableType.getEnumConstants();
                Enum foundEnum = null;
                EnumEnclosedBlockType enclosedType = EnumEnclosedBlockType.byMetadata(metadata);
                for (Enum e : enums) {
                    if (e.name().equals(enclosedType.getIc2Enum())) {
                        foundEnum = e;
                        break;
                    }
                }
                CompatibilityManager.constructorIC2cableTE.setAccessible(true);
                return (TileEntity) CompatibilityManager.constructorIC2cableTE.newInstance(foundEnum, enclosedType.getIc2Insulation());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    } else if (metadata <= 12) {
        if (CompatibilityManager.isBCraftTransportLoaded()) {
            try {
                return blockPipeBC.createTileEntity(world, blockPipeBC.getDefaultState());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    } else if (metadata <= EnumEnclosedBlockType.ME_CABLE.getMeta()) {
        if (CompatibilityManager.isAppEngLoaded()) {
        // //Emulate Api.INSTANCE.partHelper().getCombinedInstance( TileCableBus.class.getName() )
        // try
        // {
        // IPartHelper apiPart = AEApi.instance().partHelper();
        // Class<?> clazzApiPart = Class.forName("appeng.core.api.ApiPart");
        // Class clazz = (Class) clazzApiPart.getDeclaredMethod("getCombinedInstance", String.class).invoke(apiPart, "appeng.tile.networking.TileCableBus");
        // //Needs to be: appeng.parts.layers.LayerITileStorageMonitorable_TileCableBus
        // return (TileEntity) clazz.newInstance();
        // }
        // catch (Exception e) { e.printStackTrace(); }
        }
    } else if (metadata <= EnumEnclosedBlockType.ALUMINUM_WIRE.getMeta()) {
        return new TileEntityAluminumWire(1);
    } else if (metadata <= EnumEnclosedBlockType.ALUMINUM_WIRE_HEAVY.getMeta()) {
        return new TileEntityAluminumWire(2);
    }
    return new TileEntityNull();
}
Also used : PropertyEnum(net.minecraft.block.properties.PropertyEnum) TileEntity(net.minecraft.tileentity.TileEntity) TileEntityAluminumWire(micdoodle8.mods.galacticraft.core.tile.TileEntityAluminumWire) TileEntityNull(micdoodle8.mods.galacticraft.core.tile.TileEntityNull) TileEntityFluidPipe(micdoodle8.mods.galacticraft.core.tile.TileEntityFluidPipe)

Aggregations

TileEntityAluminumWire (micdoodle8.mods.galacticraft.core.tile.TileEntityAluminumWire)1 TileEntityFluidPipe (micdoodle8.mods.galacticraft.core.tile.TileEntityFluidPipe)1 TileEntityNull (micdoodle8.mods.galacticraft.core.tile.TileEntityNull)1 PropertyEnum (net.minecraft.block.properties.PropertyEnum)1 TileEntity (net.minecraft.tileentity.TileEntity)1