Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-11142

Placing a Redstone Torch/Block next to a rail junction does not change the rail direction

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Minecraft 17w50a
    • Snapshot 13w10a, Snapshot 13w10b, Minecraft 1.5.1, Minecraft 1.5.2, Snapshot 13w18c, Snapshot 13w19a, Minecraft 1.7.2, Minecraft 1.7.4, Minecraft 14w08a, Minecraft 14w20b, Minecraft 14w29b, Minecraft 14w30c, Minecraft 14w31a, Minecraft 1.8-pre1, Minecraft 1.8, Minecraft 1.8.1-pre3, Minecraft 1.8.8, Minecraft 15w33c, Minecraft 16w04a, Minecraft 1.9, Minecraft 1.9.1 Pre-Release 1, Minecraft 1.9.1 Pre-Release 2, Minecraft 1.9.1 Pre-Release 3, Minecraft 1.9.4, Minecraft 16w21a, Minecraft 1.11.2, Minecraft 1.12 Pre-Release 6, Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w43a, Minecraft 17w43b
    • Confirmed

      The bug

      Please look at the screenshots first to understand

      When you place three rails like I did and you place at the bifurcation a redstone torch it will not update the rail, BUT when you place it under the rail it works

      Code analysis

      The following is based on decompiled version of Minecraft 1.9 using MCP 9.24 beta. All method and class names are the names used in the decompiled version.

      The reason why this happens is very likely a wrong IBlockState being returned by the method net.minecraft.world.chunk.Chunk.setBlockState(BlockPos, IBlockState). The IBlockState it returns is the one from the block that was replaced. This means the rail is receives a neighbour update with air as source which does not update the rail.

      public IBlockState setBlockState(BlockPos pos, IBlockState state)
      {        
          int i = pos.getX() & 15;
          int j = pos.getY();
          int k = pos.getZ() & 15;
          int l = k << 4 | i;
      
          if (j >= this.precipitationHeightMap[l] - 1)
          {
              this.precipitationHeightMap[l] = -999;
          }
      
          int i1 = this.heightMap[l];
          IBlockState iblockstate = this.getBlockState(pos);
      
          if (iblockstate == state)
          {
              return null;
          }
          else
          {
              //...
              
              if (extendedblockstorage.get(i, j & 15, k).getBlock() != block)
              {
                  return null;
              }
              else
              {
                  //...
      
                  this.isModified = true;
                  // Replaced this; now returns the new state
                  //return iblockstate;
                  return state;
              }
          }
      }
      

      If this method is supposed to returns the old state, then methods like net.minecraft.block.BlockRedstoneTorch.onBlockAdded(World, BlockPos, IBlockState) are not working correctly because they pass themself which means at the end the new state is passed.
      Besides that the method net.minecraft.block.BlockRail.onNeighborChangedInternal(World, BlockPos, IBlockState, Block) will still not work correctly. It should test if the new placed block state provides power and if the rail was powered before (it looks like this is currently not tracked).

            Unassigned Unassigned
            marcono1234 [Mod] Marcono1234
            Votes:
            10 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:
              CHK: