mojira.dev
MC-8645

Redstone wire receiving level 1 power from a block, pointing at another block with wire on it will not power that block

Very very weird bug i've found. Everything is on the screenshot. The strength of the signal must be 1. I've placed some similar circuits to show the difference and demonstrate the bug better.

Code analysis

Comment

Related issues

Attachments

Comments

migrated
[media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media][media]
MiiNiPaa

Can confirm: if you break redstone on top of block with torch it work as it should, if you place it back it won't.

Kwin van der Veen

I can also confirm that this bug still exists in Minecraft 1.5.1.

Talven81

This appears to be a visual glitch. Since the power output is 1, it should not travel 2 blocks, however the side of the block with the redstone appears powered. I believe this is due to the side redstone being in the same block as the powered redstone piece.

qmagnet

This is fixed in 14w32d

Anon Ymus

Still an issue in 1.8.2-pre5. See MC-76971.

K

Can confirm for 16w39c.

[Mod] Neko

16w39c is already listed.

NeunEinser

Can confirm for 1.12

Oval

Confirmed for 1.13.1.

RedCMD

The problem is that when a redstone component (piston, redstone lamp, trapdoor, repeater etc) checks to see if redstone is pointing towards it
It actually checks to see if the dust is pointing away from it AND if it is not pointing to the left or right
(There's a separate check to see if the dust is a dot, rather than a line)
It should also check if the dust is pointing towards the component
There is a few performance optimizations that can be done at the same time

 

Inside BlockRedstoneWire.class, getSignal()
Currently, it runs this code...

  1. Checks if the block is shouldSignal, if false return 0 (this seems unneeded as getDirectSignal() already does the exact same check beforehand)

  2. Checks if the power level of dust equals 0, if true return 0 (Good)

  3. Checks if the direction is facing upwards (if there's a redstone component below the dust. Upwards is from the perspective of the component), if true return power level (Good)

  4. Runs for loop, checking each of the four horizontal directions to see if the dust should connect to that side and saves it to a list (This is unneeded as not all directions need to be checked resulting in extra unneeded lag)

  5. Checks list to see if the dust is connecting nowhere (dot). (This check should be done last to save on lag)

  6. Checks list to see if dust is pointing away from the redstone component AND if it's NOT pointing to the left OR right, if true returns power level

  7. else return 0

 

Here is my solution to the problem

  1. Check if the block is shouldSignal, if false return 0 (this may or may not be needed)

  2. Check if the direction is facing downwards (Downwards is from the perspective of the redstone component), if true return 0 (this is if the redstone component is on top of the redstone dust (won't be powered))

  3. Check if the power level of dust equals 0, if true return 0 (unchanged)

  4. Check if the direction is facing upwards, if true return power level (unchanged)

  5. Check if the dust can connect in the direction of the redstone component (isPowerSourceAt(direction.getOpposite()))), if true return power level (this check is for if the dust is a line)

  6. Check if it can connect to the left OR right, if true return 0 (this accounts if the dust is a dot or isn't pointing towards the redstone component)

  7. else return power level

 

This fix will also increase performance as it doesn't need to check if the dust can connect to the opposite side and it only checks the directions it could connect to as it needs them, rather than all at once and using wastefully

Below are different scenarios for a redstone lamp being powered or not powered by dust that has been redirected

The redstone dust is sitting on the gold block
A redstone lamp will be used to show where the dust is powering
Stone buttons will be used to redirect the dust
In some pictures, there is dust on top of the redstone lamp
Vanilla is on the left, fixed on the right

 

[media]

Check if the direction is facing downwards, if true return 0

 

[media]

Check if the power level of the dust equals 0, if true return 0

 

[media]

 
Check if the direction is facing upwards, if true return power level

 

[media]

[media]

Check if the dust can connect in the direction of the redstone component, if true return power level. (Vanilla doesn't have this check, so it returns 0)

 

[media]

Check if dust is pointing away from the redstone component AND NOT pointing to the left OR right, if true returns power level (Only vanilla has this check, I split this up to fix the bug and increase performance)

 

[media]

Check if the dust is connecting nowhere (dot) (Vanilla has this check, but my version has this check built into the next check)

 

[media]

Check if it can connect to the left OR right, if false return power level

 

[media]

else return 0

 

Some more pictures with vanilla on the left and fixed on the right

[media]

[media][media]

[media]

Notice how vanilla doesn't power the redstone lamp even though the dust is pointing towards it

And only if there is an isPowerSourceAt() on the other side of the lamp

[media]

 

Code using Mojang mappings

public int getSignal(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, Direction direction) {
    
    if(true) {  //Vanilla
        if (!this.shouldSignal) {
            return 0;
        }
        
        int n = blockState.getValue(POWER);
        if (n == 0) {
            return 0;
        }
        if (direction == Direction.UP) {
            return n;
        }
   
        EnumSet<Direction> enumSet = EnumSet.noneOf(Direction.class);
        for (Direction direction2 : Direction.Plane.HORIZONTAL) {
            if (this.isPowerSourceAt(blockGetter, blockPos, direction2))
                enumSet.add(direction2);
        }
        if (direction.getAxis().isHorizontal() && enumSet.isEmpty()) {
            return n;
        }
        if (enumSet.contains(direction) && !enumSet.contains(direction.getCounterClockWise()) && !enumSet.contains(direction.getClockWise())) {
            return n;
        }
        
        return 0;
        
    } else {    //Fixes MC-8645 and increases performance
       if (!this.shouldSignal) {   //This is already checked in getDirectSignal()
          return 0;
       }
   
       if (direction == Direction.DOWN) {
          return 0;
       }

       int n = blockState.getValue(POWER);
       if (n == 0) {
          return 0;
       }

       if (direction == Direction.UP) {
          return n;
       }
   
       if (this.isPowerSourceAt(blockGetter, blockPos, direction.getOpposite())) {
          return n;
       }
       if (this.isPowerSourceAt(blockGetter, blockPos, direction.getCounterClockWise() || this.isPowerSourceAt(blockGetter, blockPos, direction.getClockWise())) {
          return 0;
       }
       
       return n;
    }
}
T3sT3ro

! Seems to be resolved in 20w18a.

pokechu22

20w18a changelog:

A wire that is redirected to go over a block will now always provide power to the block. This is most noticeable when the wire has signal strength 1.

Anton Gromov

RedCMD

(Unassigned)

Confirmed

Redstone

redstone, redstone-comparator, redstone-dust, signal-decay, signal-strength

Snapshot 13w03a, Snapshot 13w04a, Snapshot 13w09c, Snapshot 13w10a, Minecraft 1.5, ..., Minecraft 1.13.1, 1.15.2, 20w11a, 20w12a, 20w17a

Minecraft 1.8, 20w18a

Retrieved