[Unsolved] Getting power level being supplied to Block

Discussion in 'Plugin Development' started by EasyMFnE, Jul 8, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    EasyMFnE

    I'm struggling to find a way to detect the level of power being supplied to a block.

    In the example, a comparator is being used to output a redstone power level of exactly 1.
    By my understanding, the method getBlockPower() in org.bukkit.block.Block is supposed to return the power level being supplied to the block. However, the method is returning 15 for the Sponge. (Signs show the return values of the method for various Blocks)
    [​IMG]

    A fellow member of the #bukkitdev IRC channel helpfully stated that I don't understand redstone physics, but then (less helpfully) failed to explain. What fundamentals (if any) am I misunderstanding, and how can I best get the level of current being supplied to a block?
     
  2. Offline

    intronate67

    Could you supply the method you are using?
     
  3. Offline

    EasyMFnE

    getBlockPower() from org.bukkit.block.Block
     
  4. Offline

    dsouzamatt

    EasyMFnE Do a little experiment. Change the comparator output strength and see whether the power level of the sponge changes.
     
  5. Offline

    Garris0n


    https://github.com/Bukkit/CraftBukk...bukkit/craftbukkit/block/CraftBlock.java#L366

    That question is fundamentally wrong. There could be any number of levels being supplied to the block by others around it. If you want the level of a block supplying power, get the level of that block.
     
  6. Offline

    EasyMFnE

    The example was an extreme simplification, with one power source. In practice I would consider all levels supplied and report the maximum.

    Therein lies another issue. The Block representing the redstone wire in my original example reports its power level as 15 when calling getBlockPower(). Interestingly enough: the grass block underneath said redstone accurately reports a power level of 1.

    Expanded information example, changed to simple switch/wire:
    [​IMG]
    (Note: piston extension event was cancelled)
    First line reports material, power via getBlockPower(), and location.
    Second line reports powered/indirect booleans via isBlockPowered() and isBlockIndirectlyPowered().
    Subsequent lines report:
    - the face of the sponge block being examined
    - the material of the neighbor in that direction
    - the power level of the sponge's face via getBlockFacePower(face)
    - the direct/indirect power status of sponge's face via isBlockFacePowered(face)/isBlockFaceIndirectlyPowered(face)
    - the reported power level of the neighboring block via getBlockPower()

    My understanding, through the documentation, is that the getBlockPower()/getBlockFacePower() methods: "Returns the redstone power being provided to this block [face]." Am I misinterpreting the purpose of the methods?

    I don't care which methods I need to use or what changes I have to make; I just want some way to reliably get the highest level current being supplied to the block, regardless of whether it comes through wire, switch, button, etc.
     
  7. Offline

    EasyMFnE

    Still unresolved. (bump)
     
  8. Offline

    EasyMFnE

    Bumping one (more|last) time.
     
Thread Status:
Not open for further replies.

Share This Page