use of mcmultipart.multipart.IRedstonePart in project Charset by CharsetMC.
the class WireUtils method getRedstoneLevel.
public static int getRedstoneLevel(World world, BlockPos pos, IBlockState state, EnumFacing facing, WireFace face, boolean weak) {
int power = 0;
IMultipartContainer container = MultipartHelper.getPartContainer(world, pos);
if (container != null) {
if (getWire(container, face) != null || getWire(container, WireFace.get(facing.getOpposite())) != null) {
return 0;
}
for (IMultipart part : container.getParts()) {
if (!(part instanceof PartWireBase)) {
if (part instanceof IRedstonePart) {
power = Math.max(power, ((IRedstonePart) part).getWeakSignal(facing.getOpposite()));
}
}
}
}
if (MultipartUtils.hasCapability(Capabilities.REDSTONE_EMITTER, world, pos, WireUtils.getSlotForFace(face), facing)) {
power = Math.max(power, MultipartUtils.getCapability(Capabilities.REDSTONE_EMITTER, world, pos, WireUtils.getSlotForFace(face), facing).getRedstoneSignal());
}
Block block = state.getBlock();
if (power == 0) {
if (weak) {
if (block instanceof BlockRedstoneWire && face == WireFace.DOWN) {
return state.getValue(BlockRedstoneWire.POWER);
}
return block.shouldCheckWeakPower(world, pos, facing) ? block.getStrongPower(world, pos, state, facing) : block.getWeakPower(world, pos, state, facing);
} else {
return block.getStrongPower(world, pos, state, facing);
}
} else {
return power;
}
}
Aggregations