use of com.bluepowermod.api.gate.IAnalogueComparatorReadout in project BluePower by Qmunity.
the class GateComparator method doLogic.
@Override
public void doLogic() {
byte power = back().getInput();
ForgeDirection d = back().getDirection().toForgeDirection(getFace(), getRotation());
Vec3i a = new Vec3i(getX(), getY(), getZ(), getWorld()).add(d);
Block ba = a.getBlock(false);
if (ba.hasComparatorInputOverride())
power = (byte) MathHelper.map(ba.getComparatorInputOverride(getWorld(), a.getX(), a.getY(), a.getZ(), d.getOpposite().ordinal()), 0, 15, 0, 255);
if (ba instanceof IAnalogueComparatorReadout && ((IAnalogueComparatorReadout) ba).hasAnalogueComparatorInputOverride())
power = ((IAnalogueComparatorReadout) ba).getAnalogueComparatorInputOverride(getWorld(), a.getX(), a.getY(), a.getZ(), d.getOpposite().ordinal());
if (ba.isOpaqueCube()) {
Vec3i b = a.getRelative(d);
Block bb = b.getBlock(false);
if (bb.hasComparatorInputOverride())
power = (byte) MathHelper.map(bb.getComparatorInputOverride(getWorld(), b.getX(), b.getY(), b.getZ(), d.getOpposite().ordinal()), 0, 15, 0, 255);
if (bb instanceof IAnalogueComparatorReadout && ((IAnalogueComparatorReadout) bb).hasAnalogueComparatorInputOverride())
power = ((IAnalogueComparatorReadout) bb).getAnalogueComparatorInputOverride(getWorld(), b.getX(), b.getY(), b.getZ(), d.getOpposite().ordinal());
}
t1.setState(left().getInput() == 0);
t2.setState(right().getInput() == 0);
w.setPower((byte) (255 - (power & 0xFF)));
t3.setState(power != 0);
front().setOutput((byte) Math.max((power & 0xFF) - Math.max(left().getInput() & 0xFF, right().getInput() & 0xFF), 0));
}
Aggregations