mojira.dev
MC-11142

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

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).

Related issues

Attachments

Comments

migrated
[media][media]
migrated

Confirmed.

migrated

This has been described previosly in [MC-8581|MC-8581] (and maybe elsewhere too).

migrated

Still not fixed as of 1.5.2pre.
To clarify, if you place a torch adjacent to a t-rail, the t-rail actually can change direction when said torch is controlled by some signal. Placing and removing the torch, however, does not affect t-rail direction even when the circuit that provides that signal exists. In such case t-rail also disregards a zero-tick pulse created on torch placement when the circuit is on.

migrated

Confirmed for 14w18b.

migrated

Confirmed for 15w33c

SunCat

Still in 1.9.1-pre3

SunCat

Still in 16w21a

migrated

Still in 1.12

SunCat

@unknown, 1.12 is outdated, and a newer version (1.12.1) was already marked as affected

NeunEinser

Can confirm for 17w43a/b

NeunEinser

Fixed in recent snapshots (tested in 17w50a)

migrated

This bug has re-appeared in 1.14.4

marcono1234

@@unknown, you are right, thank you very much. I have cloned the report as MC-167257 since this report is so old and the bug has been fixed a rather long time ago.
Do you want to become the reporter of the new report and keep it up to date?

migrated

This is happening in 1.15.2.

NeunEinser

@unknown See MC-167257.

marcono1234

(Unassigned)

Confirmed

rail, redstone, redstone_block, redstone_torch

Snapshot 13w10a, Snapshot 13w10b, Minecraft 1.5.1, Minecraft 1.5.2, Snapshot 13w18c, ..., Minecraft 1.12 Pre-Release 6, Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w43a, Minecraft 17w43b

Minecraft 17w50a

Retrieved