Search in sources :

Example 1 with BlockPostBase

use of mods.railcraft.common.blocks.aesthetics.post.BlockPostBase in project Railcraft by Railcraft.

the class BlockWire method getActualState.

@SuppressWarnings("deprecation")
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
    state = super.getActualState(state, worldIn, pos);
    Connection[] connections = new Connection[6];
    Arrays.fill(connections, Connection.NONE);
    for (EnumFacing side : EnumFacing.VALUES) {
        BlockPos neighborPos = pos.offset(side);
        IBlockState neighborState = WorldPlugin.getBlockState(worldIn, pos.offset(side));
        Block neighborBlock = neighborState.getBlock();
        if (neighborBlock instanceof IChargeBlock) {
            ChargeSpec chargeSpec = ((IChargeBlock) neighborBlock).getChargeSpecs(neighborState, worldIn, neighborPos).get(Charge.distribution);
            if (chargeSpec != null) {
                IChargeBlock.ConnectType connectType = chargeSpec.getConnectType();
                if (connectionMatcher.get(side).contains(connectType)) {
                    connections[side.ordinal()] = connectType == IChargeBlock.ConnectType.WIRE ? Connection.WIRE : Connection.PLUG;
                }
            }
        } else if (side.getAxis() == EnumFacing.Axis.Y && neighborBlock instanceof BlockPostBase) {
            connections[side.ordinal()] = Connection.PLUG;
        }
    }
    for (EnumFacing side : EnumFacing.VALUES) {
        state = state.withProperty(connectionProperties[side.ordinal()], connections[side.ordinal()]);
    }
    return state;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) IPostConnection(mods.railcraft.api.core.IPostConnection) Block(net.minecraft.block.Block) IChargeBlock(mods.railcraft.api.charge.IChargeBlock) BlockPos(net.minecraft.util.math.BlockPos) BlockPostBase(mods.railcraft.common.blocks.aesthetics.post.BlockPostBase) IChargeBlock(mods.railcraft.api.charge.IChargeBlock)

Example 2 with BlockPostBase

use of mods.railcraft.common.blocks.aesthetics.post.BlockPostBase in project Railcraft by Railcraft.

the class RenderBlockLamp method canConnect.

private boolean canConnect(IBlockAccess world, int x, int y, int z, EnumFacing side) {
    int sx = MiscTools.getXOnSide(x, side);
    int sy = MiscTools.getYOnSide(y, side);
    int sz = MiscTools.getZOnSide(z, side);
    if (world.isSideSolid(sx, sy, sz, side.getOpposite(), false))
        return true;
    if (side == EnumFacing.DOWN) {
        if (World.doesBlockHaveSolidTopSurface(world, sx, sy, sz))
            return true;
        if (world instanceof ChunkCache) {
            Block block = WorldPlugin.getBlock(world, sx, sy, sz);
            if (block != null && block.canPlaceTorchOnTop(Minecraft.getMinecraft().theWorld, sx, sy, sz))
                return true;
        }
    }
    Block block = WorldPlugin.getBlock(world, sx, sy, sz);
    return block instanceof BlockPostBase;
}
Also used : ChunkCache(net.minecraft.world.ChunkCache) Block(net.minecraft.block.Block) BlockPostBase(mods.railcraft.common.blocks.aesthetics.post.BlockPostBase)

Aggregations

BlockPostBase (mods.railcraft.common.blocks.aesthetics.post.BlockPostBase)2 Block (net.minecraft.block.Block)2 IChargeBlock (mods.railcraft.api.charge.IChargeBlock)1 IPostConnection (mods.railcraft.api.core.IPostConnection)1 IBlockState (net.minecraft.block.state.IBlockState)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1 ChunkCache (net.minecraft.world.ChunkCache)1