Railroad Crossing Issues Support

All railroad crossings tend to experience malfunctions...

There are a few issues that may come up when making the crossings in-game or on servers. Let's discuss them here.

Railroad Crossing Gate Redstone Bug Of 2024:

Due to an OUTSTANDINGLY annoying railroad crossing gate-redstone bug, the railroad crossing gate will require some strange setup in order to get working properly.

Direction-wise, railroad crossings should not have to rely on redstone directional placement to work, yet it does when it didn't matter in Thingamajigs 1. In Thingamajigs 2, an issue was discovered during testing, and here is the explanation.

Here is the code (de-obfuscated source version) for Thingamajigs Railroadways 0.0.1 version that dictates the 'tick' logic and 'neighboring block' logic (other railroad blocks aren't this simple):

    @Override
    public void neighborChanged(BlockState bs, Level lvl, BlockPos bp, Block blk, BlockPos bp2, boolean bool1) {
        if(!lvl.isClientSide){
            boolean flag = bs.getValue(POWERED);
            if(flag != lvl.hasNeighborSignal(bp)){
                if(flag){
                    lvl.scheduleTick(bp,this,4);
                }
                else{
                    lvl.setBlock(bp,bs.cycle(POWERED), 2);
                }
            }
        }
    }

    @Override
    public void tick(BlockState bs, ServerLevel sl, BlockPos bp, RandomSource rs){
        Block blk = sl.getBlockState(bp.above()).getBlock();
        boolean flag2 = sl.hasNeighborSignal(bp);

        if(flag2){
            sl.setBlock(bp,bs.setValue(POWERED,true),2);
            sl.scheduleTick(bp.above(),blk,7,TickPriority.LOW);
        }
        else{
            sl.setBlock(bp,bs.setValue(POWERED,false),2);
            sl.scheduleTick(bp.above(),blk,7,TickPriority.LOW);
        }
    }

Currently, the code only needs these two methods in order to work properly for north and west directions. South and east directions don't work unless they both connect redstone dust wise (and are powered). The stale mate (that makes this bug hard to fix) is that adding ticking to the neighbor check method causes too many updates to occur at once, skipping them, which is bad. So the current code has been slowed down in the tick. 7 ticks will occur before the block above the gate gets a tick itself. This allows the gate to change state before the vertically aligned blocks are ticked, making it less likely for a half on-half off state to occur. There is no code race condition here, all code is safe for servers and local worlds.

Here is the setup that should work for any non-functional sides:

Redstone should be placed on all, two or one side(s) of the gate in order to activate it. When the gate receives no signal, it will turn off. North and west sides should only require one piece of redstone dust to power them. After that, if you want to hide the redstone as much as possible, put a torch under the ground beneath one of the sides of the redstone dust touching the gate, then, use whatever mods or vanilla redstone to create the logic for the gate when it should go up and down. Timers from some mods are recommended, but if you want have finer control over the railroad crossings, use other mods' switches to do the logic. Railroad Crossing Gates (and other vertical redstone components) cannot be connected to wireless redstone components from other mods, unless they support connecting to redstone directly (the block itself cannot be attached to block entities that send signals to the blocks using ids and such).

Detector rails, modded latching switches (or the copper bulb with a comparator), and redstone dust are the only basics you need for a nice rail-based crossing activation system. It even works in both directions of travel, due to the nature of how redstone works.

Hopefully in the future the issue will be solved, for now, use this temporary 'fairly elegant' solution.

Bells Ring Forever!

The railroad crossing bells should NEVER ring forever. If they are, report it to the issues tab in the Thingamajigs 2 Addons GitHub.

This was fixed during testing. The only reason why bells would ring forever is because a tick didn't get processed correctly and the bell should be broken and replaced. Bells are disabled on one block tall vertical redstone poles due to the fact that the bells have nothing to check for a signal but themselves at that point, which is a brief explanation as to how the vertical redstone logic works. In most scenarios, bells will reset themselves when ever an entire set of vertical redstone components are off below them (they only check the block directly below them if it is on or off). Bells skip checking cantilevers, along with other blocks which skip checking cantilevers, since they are full blocks that transmit redstone signals.

Stuff is stuttering or jumping!

This is a server-side occurrence and is probably caused by lag in the world ticks.

Slow servers will effect the visuals of the railroad crossing due to the values driving the model's animation. yAngle is the internal name of most railroad crossing blocks' rotation value.

The value that is effected mostly by server lag is the 'armAngle' value, found in the gate block itself.

The armAngle value is updated based on the block state of the block. If the block is powered, the value will be updated every tick till the target value is reached, usually when off, the target is start_arm_angle, and the on state makes the target value the end_arm_angle (it was reversed [originally being the other way around] as to fix some oddities with which way the arm was moving). If you change the start_arm_angle to a higher value, the gate will start more upwards. If the start_arm_angle is lowered, the gate will be up at a lower angle, towards the ground. Changing end_arm_angle is very limited in usefulness, so it's better to leave it at 0, the default value.

The default values for the block are:

starting_arm_angle = 1.35f

end_arm_angle = 0.0f

Remember these values, as they are the default.

Note that in creative mode, gates will keep their rotation facing angle, their gate up/down angle limits, and how long the gate is (along with the offset for the gate's length) if you 'pick-block' the block with the middle mouse button (or whatever your keybind is for the 'pick-block' function) while holding the 'sneak' key + 'command (macOS)/ctrl (Windows)' key.

'Blipping' Lights and Weird Startups

Lights may tend to flicker (alternate, not flash) quickly for about half a second or just a few ticks. This is normal behavior (and even exists in real life!). This is due to the ticks not being perfect (a partial tick was in progress when the block was checked for updates) when the lights turn on, so they quickly change texture.

What texture displays is depending on whether or not the amount of ticks that have passed during a cycle is equal to half the ticks that are allowed in a railroad crossing lights' cycle. This also has the side effect of making lights feel more natural and not static (and maybe a bit too realistic... oops).

This is an unintentional side effect with no known ways in which it would hurt performance. It was expected that per-chance the lights may blip with the new half-tick-based texture changing system. For now, just keep using the blocks normally as they will correct themselves.

If there is a bug or crash, report it to the Thingamajigs 2 Addon GitHub in the issues tab.

Last updated