use of mods.railcraft.api.charge.IChargeBlock 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;
}
Aggregations