Search in sources :

Example 1 with IPostBlock

use of blusunrize.immersiveengineering.api.IPostBlock in project ImmersiveEngineering by BluSunrize.

the class BlockConnector method onBlockPlaced.

@Override
public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
    IBlockState ret = super.onBlockPlaced(world, pos, facing, hitX, hitY, hitZ, meta, placer);
    if (meta == BlockTypes_Connector.TRANSFORMER.getMeta()) {
        BlockPos pos2 = pos.offset(facing, -1);
        IBlockState placedAgainst = world.getBlockState(pos2);
        Block block = placedAgainst.getBlock();
        if (block instanceof IPostBlock && ((IPostBlock) block).canConnectTransformer(world, pos2))
            ret = ret.withProperty(IEProperties.BOOLEANS[1], true);
        TileEntity tile = world.getTileEntity(pos2);
        if (tile instanceof IPostBlock && ((IPostBlock) tile).canConnectTransformer(world, pos2))
            ret = ret.withProperty(IEProperties.BOOLEANS[1], true);
    }
    return ret;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) IPostBlock(blusunrize.immersiveengineering.api.IPostBlock) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) IPostBlock(blusunrize.immersiveengineering.api.IPostBlock)

Aggregations

IPostBlock (blusunrize.immersiveengineering.api.IPostBlock)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1