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;
}
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;
}
Aggregations