getReceivedRedstonePower() returns incorrect values
CommandLeo opened this issue ยท 2 comments
getReceivedRedstonePower()
is currently used in /info block
and Scarpet power()
function.
There are 2 issues with how it works:
-
It should (arguably) not work with blocks that don't have varying signal strengths, as described in the Scarpet docs for
power()
:Numeric function, returning redstone power level at position
. Therefore it makes sense that it works only with redstone dust, comparators, daylight sensors and target blocks.
In this example running the command/info block <x> <y> <z> grep Redstone power
on the powered rail returnsRedstone power level: 15
even though rails don't have different signal strengths, they are either powered or unpowered. -
This a more serious issue:
power()
doesn't consider the fact that repeaters and comparators only take an input from behind. So by, for example, placing a redstone block next to a comparator and running/info block
on the comparator it will return a power level of 15.
What's even weirder is what happens when you try to search for getReceivedRedstonePower
in the mod's code. There are 4 results, including the definition of the function.
But in line 36 of RedstoneWireBlockMixin.java
apparently the function always returns 0?
Apart from the issues with how the function works, I've found out that power()
is actually slower than block_state(b, 'power')
, so in the current state power()
is completely useless.
getReceivedRedstonePower
is a vanilla method that checks the power that a block in the given position would receive, the block that's doing the call is expected to know where to look at (for example, comparators would look at the block behind IIRC, etc.
The get getReceivedRedstonePower()
in the mixin isn't a declaration of how it works, it's just a stub to be able to call it (if you check, you'll see it's annotated with @Shadow
, meaning that it will just call the method in the original class (since it's a mixin, java doesn't know that method exists, so that is provided to be able to use it). That class should have been abstract though so it didn't need to declare a body for the method, but whatever, that 0
isn't ever actually returned.
Probably docs would need to be updated. block_state(b, 'power')
is not the same, power should give you a number when you power a full block.