Search in sources :

Example 1 with MultiBlockPattern

use of mods.railcraft.common.blocks.machine.MultiBlockPattern in project Railcraft by Railcraft.

the class TileTankBase method placeIronTank.

public static void placeIronTank(World world, BlockPos pos, int patternIndex, FluidStack fluid) {
    MultiBlockPattern pattern = TileTankBase.patterns.get(patternIndex);
    Map<Character, IBlockState> blockMapping = new HashMap<Character, IBlockState>();
    blockMapping.put('B', EnumMachineBeta.TANK_IRON_WALL.getDefaultState());
    blockMapping.put('W', EnumMachineBeta.TANK_IRON_GAUGE.getDefaultState());
    TileEntity tile = pattern.placeStructure(world, pos, blockMapping);
    if (tile instanceof TileTankBase) {
        TileTankBase master = (TileTankBase) tile;
        master.tank.setFluid(fluid);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) HashMap(java.util.HashMap) MultiBlockPattern(mods.railcraft.common.blocks.machine.MultiBlockPattern)

Example 2 with MultiBlockPattern

use of mods.railcraft.common.blocks.machine.MultiBlockPattern in project Railcraft by Railcraft.

the class TileTankBase method buildPatterns.

private static List<MultiBlockPattern> buildPatterns() {
    List<MultiBlockPattern> pats = new ArrayList<MultiBlockPattern>();
    boolean client = FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT;
    // 3x3
    int xOffset = 2;
    int yOffset = 0;
    int zOffset = 2;
    char[][] bottom = { { 'O', 'O', 'O', 'O', 'O' }, { 'O', 'B', 'B', 'B', 'O' }, { 'O', 'B', 'M', 'B', 'O' }, { 'O', 'B', 'B', 'B', 'O' }, { 'O', 'O', 'O', 'O', 'O' } };
    char[][] middle = { { 'O', 'O', 'O', 'O', 'O' }, { 'O', 'B', 'W', 'B', 'O' }, { 'O', 'W', 'A', 'W', 'O' }, { 'O', 'B', 'W', 'B', 'O' }, { 'O', 'O', 'O', 'O', 'O' } };
    char[][] top = { { 'O', 'O', 'O', 'O', 'O' }, { 'O', 'B', 'B', 'B', 'O' }, { 'O', 'B', 'T', 'B', 'O' }, { 'O', 'B', 'B', 'B', 'O' }, { 'O', 'O', 'O', 'O', 'O' } };
    char[][] border = { { 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O' } };
    for (int i = 4; i <= 8; i++) {
        char[][][] map = buildMap(i, bottom, middle, top, border);
        AxisAlignedBB entityCheck = new AxisAlignedBB(0, 1, 0, 1, i - 1, 1);
        pats.add(buildPattern(map, xOffset, yOffset, zOffset, entityCheck));
    }
    // 5x5
    if (client || RailcraftConfig.getMaxTankSize() >= 5) {
        xOffset = zOffset = 3;
        bottom = new char[][] { { 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'B', 'B', 'B', 'B', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'M', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'B', 'B', 'B', 'B', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O' } };
        middle = new char[][] { { 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'W', 'A', 'A', 'A', 'W', 'O' }, { 'O', 'W', 'A', 'A', 'A', 'W', 'O' }, { 'O', 'W', 'A', 'A', 'A', 'W', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O' } };
        top = new char[][] { { 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'B', 'B', 'B', 'B', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'T', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'B', 'B', 'B', 'B', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O' } };
        border = new char[][] { { 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O' } };
        for (int i = 4; i <= 8; i++) {
            char[][][] map = buildMap(i, bottom, middle, top, border);
            AxisAlignedBB entityCheck = new AxisAlignedBB(-1, 1, -1, 2, i - 1, 2);
            pats.add(buildPattern(map, xOffset, yOffset, zOffset, entityCheck));
        }
    }
    // 7x7
    if (client || RailcraftConfig.getMaxTankSize() >= 7) {
        xOffset = zOffset = 4;
        bottom = new char[][] { { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'M', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' } };
        middle = new char[][] { { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'W', 'A', 'A', 'A', 'A', 'A', 'W', 'O' }, { 'O', 'W', 'A', 'A', 'A', 'A', 'A', 'W', 'O' }, { 'O', 'W', 'A', 'A', 'A', 'A', 'A', 'W', 'O' }, { 'O', 'W', 'A', 'A', 'A', 'A', 'A', 'W', 'O' }, { 'O', 'W', 'A', 'A', 'A', 'A', 'A', 'W', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' } };
        top = new char[][] { { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'T', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' } };
        border = new char[][] { { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' } };
        for (int i = 4; i <= 8; i++) {
            char[][][] map = buildMap(i, bottom, middle, top, border);
            AxisAlignedBB entityCheck = new AxisAlignedBB(-2, 1, -2, 3, i - 1, 3);
            pats.add(buildPattern(map, xOffset, yOffset, zOffset, entityCheck));
        }
    }
    // 9x9
    if (client || RailcraftConfig.getMaxTankSize() >= 9) {
        xOffset = zOffset = 5;
        bottom = new char[][] { { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'M', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' } };
        middle = new char[][] { { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'W', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'W', 'O' }, { 'O', 'W', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'W', 'O' }, { 'O', 'W', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'W', 'O' }, { 'O', 'W', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'W', 'O' }, { 'O', 'W', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'W', 'O' }, { 'O', 'W', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'W', 'O' }, { 'O', 'W', 'A', 'A', 'A', 'A', 'A', 'A', 'A', 'W', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' } };
        top = new char[][] { { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'T', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'W', 'W', 'W', 'W', 'W', 'W', 'W', 'B', 'O' }, { 'O', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' } };
        border = new char[][] { { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' }, { 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O', 'O' } };
        for (int i = 4; i <= 8; i++) {
            char[][][] map = buildMap(i, bottom, middle, top, border);
            AxisAlignedBB entityCheck = new AxisAlignedBB(-3, 1, -3, 4, i - 1, 4);
            pats.add(buildPattern(map, xOffset, yOffset, zOffset, entityCheck));
        }
    }
    return pats;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ArrayList(java.util.ArrayList) MultiBlockPattern(mods.railcraft.common.blocks.machine.MultiBlockPattern)

Example 3 with MultiBlockPattern

use of mods.railcraft.common.blocks.machine.MultiBlockPattern in project Railcraft by Railcraft.

the class TileRockCrusher method placeRockCrusher.

public static void placeRockCrusher(World world, BlockPos pos, int patternIndex, List<ItemStack> input, List<ItemStack> output) {
    MultiBlockPattern pattern = TileRockCrusher.patterns.get(patternIndex);
    Map<Character, IBlockState> blockMapping = new HashMap<Character, IBlockState>();
    IBlockState state = EnumMachineAlpha.ROCK_CRUSHER.getDefaultState();
    blockMapping.put('B', state);
    blockMapping.put('D', state);
    blockMapping.put('a', state);
    blockMapping.put('b', state);
    blockMapping.put('c', state);
    blockMapping.put('d', state);
    blockMapping.put('e', state);
    blockMapping.put('f', state);
    blockMapping.put('h', state);
    TileEntity tile = pattern.placeStructure(world, pos, blockMapping);
    if (tile instanceof TileRockCrusher) {
        TileRockCrusher master = (TileRockCrusher) tile;
        for (int slot = 0; slot < 9; slot++) {
            if (input != null && slot < input.size())
                master.inv.setInventorySlotContents(TileRockCrusher.SLOT_INPUT + slot, input.get(slot));
            if (output != null && slot < output.size())
                master.inv.setInventorySlotContents(TileRockCrusher.SLOT_OUTPUT + slot, output.get(slot));
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) MultiBlockPattern(mods.railcraft.common.blocks.machine.MultiBlockPattern)

Example 4 with MultiBlockPattern

use of mods.railcraft.common.blocks.machine.MultiBlockPattern in project Railcraft by Railcraft.

the class TileSteamOven method placeSteamOven.

public static void placeSteamOven(World world, BlockPos pos, @Nullable List<ItemStack> input, @Nullable List<ItemStack> output) {
    MultiBlockPattern pattern = TileSteamOven.patterns.get(0);
    Map<Character, IBlockState> blockMapping = new HashMap<Character, IBlockState>();
    blockMapping.put('B', EnumMachineAlpha.STEAM_OVEN.getDefaultState());
    TileEntity tile = pattern.placeStructure(world, pos, blockMapping);
    if (tile instanceof TileSteamOven) {
        TileSteamOven master = (TileSteamOven) tile;
        for (int slot = 0; slot < 9; slot++) {
            if (input != null && slot < input.size())
                master.inv.setInventorySlotContents(TileSteamOven.SLOT_INPUT + slot, input.get(slot));
            if (output != null && slot < output.size())
                master.inv.setInventorySlotContents(TileSteamOven.SLOT_OUTPUT + slot, output.get(slot));
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) MultiBlockPattern(mods.railcraft.common.blocks.machine.MultiBlockPattern)

Example 5 with MultiBlockPattern

use of mods.railcraft.common.blocks.machine.MultiBlockPattern in project Railcraft by Railcraft.

the class TileBoilerFireboxFluid method placeFluidBoiler.

public static void placeFluidBoiler(World world, BlockPos pos, int width, int height, boolean highPressure, int water, FluidStack fuel) {
    for (MultiBlockPattern pattern : TileBoiler.patterns) {
        if (pattern.getPatternHeight() - 3 == height && pattern.getPatternWidthX() - 2 == width) {
            Map<Character, IBlockState> blockMapping = new HashMap<Character, IBlockState>();
            blockMapping.put('F', EnumMachineBeta.BOILER_FIREBOX_FLUID.getDefaultState());
            blockMapping.put('H', highPressure ? EnumMachineBeta.BOILER_TANK_HIGH_PRESSURE.getDefaultState() : EnumMachineBeta.BOILER_TANK_LOW_PRESSURE.getDefaultState());
            TileEntity tile = pattern.placeStructure(world, pos, blockMapping);
            if (tile instanceof TileBoilerFireboxFluid) {
                TileBoilerFireboxFluid master = (TileBoilerFireboxFluid) tile;
                master.tankWater.setFluid(Fluids.WATER.get(water));
                master.tankFuel.setFluid(fuel);
            }
            return;
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) HashMap(java.util.HashMap) MultiBlockPattern(mods.railcraft.common.blocks.machine.MultiBlockPattern)

Aggregations

MultiBlockPattern (mods.railcraft.common.blocks.machine.MultiBlockPattern)11 IBlockState (net.minecraft.block.state.IBlockState)10 TileEntity (net.minecraft.tileentity.TileEntity)9 HashMap (java.util.HashMap)8 ArrayList (java.util.ArrayList)1 InventoryMapper (mods.railcraft.common.util.inventory.wrappers.InventoryMapper)1 ItemStack (net.minecraft.item.ItemStack)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1