[SPIGOT-3818] Redstone Torches return inconsistent BlockPower() value Created: 13/Feb/18  Updated: 14/Feb/18

Status: Open
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Reg Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: redstone, torch
Environment:

Spigot 1.8.8 and 1.12.2

Windows.


Attachments: PNG File 2018-02-13_18.03.01.png     PNG File 2018-02-13_18.03.22.png     PNG File 2018-02-13_18.03.51.png     PNG File 2018-02-13_18.06.46.png     GIF File TorchPower.gif    

 Description   

Redstone Torch BlockPower() returned values are inconsistent.

If torch is powered (through the block it's attached to), its BlockPower() value is 15.

If torch is unpowered, its BlockPower() value is 0,

unless

it is connected to (and therefore powering) at least two more pieces of redstone wire, in which case its BlockPower() value is 15.

Now, i've been scratching my head, trying to work out if this is intended behaviour but I can't see how it would be.  See attached gif for clarification.



 Comments   
Comment by Reg [ 14/Feb/18 ]

I'm not really sure that I have enough knowledge to do that, much as I'd like to help out.

Besides, what is the actual goal here?  Do you agree that getBlockPower() should return the actual power level of the block in question (as opposed to the maximum power at any of its faces)?  If no, I really think we need another function that does provide that functionality.

 

Comment by md_5 [ 13/Feb/18 ]

Feel free to provide a pull request fixing the method.
You can find instructions in readme.md

Comment by Reg [ 13/Feb/18 ]

Edit:

I'm now even more confused.  I've been testing getBlockPower() and the behaviour of this thing seems to be all over the place.

One would expect a method named getBlockPower to return the power of a block.  It doesn't.  If a BlockFace is provided, it returns the power level of the block adjacent to that face of the block in question.  Fair enough I guess.  If you don't specify a BlockFace it returns the power level of BlockFace.SELF which according to the Javadocs means "the block itself".  BlockFace.SELF appears in many cases to return the highest power level being provided to any face of the block in question, but not always.  See images below for examples of where this behaviour fails:

Actual power level = 10, only one face powered at level 11, getBlockPower returns 15.

 

Actual power = 15.  Power from West at 15, power from East 14.  getBlockPower returns 14.

 

No power at any of the faces of this torch.  Power level 13 powering West face of the block it's attached to.  getBlockPower returns 15.

 

Four faces powered, strongest 14.  getBlockPower returns 14.  But wait, why do BlockFace.UP and DOWN report power level 15 when they aren't being powered by anything?

So what on earth is actually supposed to be going on here?  This function seems to be completely broken.

I actually ended up here becuase I wanted a method that would return the current power level of a block (the same number as displayed in the F3 screen when looking at a block).  It seems to me that the default result of this function (with no BlockFace parameter) should be to do just that.  If you want to know the strongest input power of a block you can loop through the BlockFace enum and find the highest value quite easily.  I should think needing a block's actual redstone power level would come up far more often than needing to know it's highest input.

Or have I gone loco in Acapulco?

Comment by Reg [ 13/Feb/18 ]

That's using block.getBlockPower() without specifiying a face, by the way.

Generated at Mon Dec 15 11:24:03 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.