Search in sources :

Example 61 with IBlockState

use of net.minecraft.block.state.IBlockState in project Railcraft by Railcraft.

the class TileRockCrusher method isMapPositionValid.

@Override
protected boolean isMapPositionValid(BlockPos pos, char mapPos) {
    IBlockState state = WorldPlugin.getBlockState(worldObj, pos);
    Block block = state.getBlock();
    int meta = block.getMetaFromState(state);
    switch(mapPos) {
        case // Other
        'O':
            if (block == getBlockType() && meta == getBlockMetadata())
                return false;
            break;
        // Window
        case 'D':
        // Block
        case 'B':
        // Block
        case 'a':
        // Block
        case 'b':
        // Block
        case 'c':
        // Block
        case 'd':
        // Block
        case 'e':
        // Block
        case 'f':
        // Block
        case 'g':
        case // Block
        'h':
            if (block != getBlockType() || meta != getBlockMetadata())
                return false;
            break;
        case // Air
        'A':
            if (!worldObj.isAirBlock(pos))
                return false;
            break;
    }
    return true;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) TileMultiBlock(mods.railcraft.common.blocks.machine.TileMultiBlock)

Example 62 with IBlockState

use of net.minecraft.block.state.IBlockState 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 63 with IBlockState

use of net.minecraft.block.state.IBlockState 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)

Example 64 with IBlockState

use of net.minecraft.block.state.IBlockState in project Railcraft by Railcraft.

the class TileBoilerFireboxSolid method placeSolidBoiler.

public static void placeSolidBoiler(World world, BlockPos pos, int width, int height, boolean highPressure, int water, List<ItemStack> 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_SOLID.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 TileBoilerFireboxSolid) {
                TileBoilerFireboxSolid master = (TileBoilerFireboxSolid) tile;
                master.tankWater.setFluid(Fluids.WATER.get(water));
                InventoryMapper masterFuel = InventoryMapper.make(master.inventory, SLOT_BURN, 4);
                for (ItemStack stack : fuel) {
                    InvTools.moveItemStack(stack, masterFuel);
                }
            }
            return;
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) HashMap(java.util.HashMap) InventoryMapper(mods.railcraft.common.util.inventory.wrappers.InventoryMapper) MultiBlockPattern(mods.railcraft.common.blocks.machine.MultiBlockPattern) ItemStack(net.minecraft.item.ItemStack)

Example 65 with IBlockState

use of net.minecraft.block.state.IBlockState in project Railcraft by Railcraft.

the class TileBlastFurnace method isMapPositionValid.

@Override
protected boolean isMapPositionValid(BlockPos pos, char mapPos) {
    IBlockState state = worldObj.getBlockState(pos);
    Block block = state.getBlock();
    int meta = block.getMetaFromState(state);
    switch(mapPos) {
        case 'O':
            if (block != RailcraftBlocks.MACHINE_ALPHA.block() || meta != getBlockMetadata())
                return true;
            break;
        case 'B':
        case 'W':
            if (block == RailcraftBlocks.MACHINE_ALPHA.block() && meta == getBlockMetadata())
                return true;
            break;
        case 'A':
            if (block.isAir(state, worldObj, pos) || state.getMaterial() == Material.LAVA)
                return true;
            break;
    }
    return false;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) TileMultiBlock(mods.railcraft.common.blocks.machine.TileMultiBlock)

Aggregations

IBlockState (net.minecraft.block.state.IBlockState)2979 BlockPos (net.minecraft.util.math.BlockPos)1194 Block (net.minecraft.block.Block)797 ItemStack (net.minecraft.item.ItemStack)517 EnumFacing (net.minecraft.util.EnumFacing)420 TileEntity (net.minecraft.tileentity.TileEntity)339 World (net.minecraft.world.World)255 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)171 EntityPlayer (net.minecraft.entity.player.EntityPlayer)136 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)126 ArrayList (java.util.ArrayList)125 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)121 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)95 Entity (net.minecraft.entity.Entity)94 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)93 ItemBlock (net.minecraft.item.ItemBlock)89 BlockPos (net.minecraft.util.BlockPos)84 Random (java.util.Random)82 Vec3d (net.minecraft.util.math.Vec3d)81 RayTraceResult (net.minecraft.util.math.RayTraceResult)76