In my life before family, I enjoyed the hobby of HO model railroading. Especially the operational aspects. Now that I am retired, I have returned to railroad modeling, but using Minecraft vanilla. I know there are many railroad mods available, but I like the challenge of vanilla. I am not interested in aesthetics.
I have created an operational railroad that can mostly be operated from a platform that I call the control center (picture of platform). The primary purpose of this posting is to demonstrate how to utilize command blocks to automate the switches and minecart launching docks. It assumes you know how to construct chests and hoppers, etc.
A command block can be used to wirelessly send a signal to another command block and have the command block emit a power pulse. This is how the launching docks are activated and how the switches can be set using a T flip-flop to provide persistency required in rail switch control.
Below is a setup of the command block to utilize vanilla wireless pulse. It is simple and compact. The code needed to send the signal and the code to receive, and therefor to pulse is following:
To Send: ‘scoreboard objectives add <NameObj> dummy’ The NameObj is your custom name for the action needed. Example: ‘scoreboard objectives add IronLaunch dummy’ The code is case sensitive. Put this command block at your control center.
To Receive: ‘scoreboard objectives remove <NameObj>’
When the send command block is activated, the receiving command block will emit a short pulse. Hook this to your launch block, or to a T Flip-Flop of your switch.
In order for the switch to be toggled, the signal must be amplified and attached to a T Flip-Flop redstone switch. Below is a picture of a simple compact T Flip-Flop that I use. In order for this to work, the cycles have to align such that the timer component T Flip-Flop may need to be adjusted by the duration of the signal, this can be accomplished with a signal duration extender using Redstone Repeaters (pictured above). I suppose you might be able to add items to the hopper, but I haven’t tried that. See the picture.
You may notice there are red and white (wool) blocks on top of my command blocks for switch setting and launch command. I use this to provide the visual indication of the switch setting. I have created an excel sheet that tells me what switches (colors) are needed to route my minecart to its destination. I will explain how to make this work.
At the end of the T Flip-Flop is a Redstone Lamp that indicates the power status of the rail switch. The lamp will have a ‘Lit’ attribute that will be ‘true’ or ‘false.’ You can use this attribute to control the color of the colored wool indicator.
In the picture below, you will want to capture the block coordinates from the ‘Looking at block:’ line. You will use this coordinate in the code used in a command block described subsequently.
The command block is purple indicating it is set to be a repeating command block. It is set to requires redstone (it would not work set to Always Activated). You will place a lever on it and power the lever and leave it powered.
The Console Command is as follows:
execute if block 168 69 -162 minecraft:redstone_lamp[lit=true] run setblock 199 87 -250 minecraft:green_wool replace
You will have another similar command block that will look at the same block, but if lit=false, will set the wool block to red.
Now when you change a rail switch the wool will change color to red or green. You will now be able to control minecart movement through your village.
I believe there is a range issue related to the wireless command blocks. I am not sure. I have a Bone Farm some distance away and I cannot get the Launch button to launch the minecart from my platform. However, I have an auxiliary control center about 75 blocks closer that it will work from. If anyone knows about this, please post a reply.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
In my life before family, I enjoyed the hobby of HO model railroading. Especially the operational aspects. Now that I am retired, I have returned to railroad modeling, but using Minecraft vanilla. I know there are many railroad mods available, but I like the challenge of vanilla. I am not interested in aesthetics.
I have created an operational railroad that can mostly be operated from a platform that I call the control center (picture of platform). The primary purpose of this posting is to demonstrate how to utilize command blocks to automate the switches and minecart launching docks. It assumes you know how to construct chests and hoppers, etc.
A command block can be used to wirelessly send a signal to another command block and have the command block emit a power pulse. This is how the launching docks are activated and how the switches can be set using a T flip-flop to provide persistency required in rail switch control.
Below is a setup of the command block to utilize vanilla wireless pulse. It is simple and compact. The code needed to send the signal and the code to receive, and therefor to pulse is following:
To Send: ‘scoreboard objectives add <NameObj> dummy’ The NameObj is your custom name for the action needed. Example: ‘scoreboard objectives add IronLaunch dummy’ The code is case sensitive. Put this command block at your control center.
To Receive: ‘scoreboard objectives remove <NameObj>’
When the send command block is activated, the receiving command block will emit a short pulse. Hook this to your launch block, or to a T Flip-Flop of your switch.
In order for the switch to be toggled, the signal must be amplified and attached to a T Flip-Flop redstone switch. Below is a picture of a simple compact T Flip-Flop that I use. In order for this to work, the cycles have to align such that the timer component T Flip-Flop may need to be adjusted by the duration of the signal, this can be accomplished with a signal duration extender using Redstone Repeaters (pictured above). I suppose you might be able to add items to the hopper, but I haven’t tried that. See the picture.
You may notice there are red and white (wool) blocks on top of my command blocks for switch setting and launch command. I use this to provide the visual indication of the switch setting. I have created an excel sheet that tells me what switches (colors) are needed to route my minecart to its destination. I will explain how to make this work.
At the end of the T Flip-Flop is a Redstone Lamp that indicates the power status of the rail switch. The lamp will have a ‘Lit’ attribute that will be ‘true’ or ‘false.’ You can use this attribute to control the color of the colored wool indicator.
In the picture below, you will want to capture the block coordinates from the ‘Looking at block:’ line. You will use this coordinate in the code used in a command block described subsequently.
The command block is purple indicating it is set to be a repeating command block. It is set to requires redstone (it would not work set to Always Activated). You will place a lever on it and power the lever and leave it powered.
The Console Command is as follows:
execute if block 168 69 -162 minecraft:redstone_lamp[lit=true] run setblock 199 87 -250 minecraft:green_wool replace
You will have another similar command block that will look at the same block, but if lit=false, will set the wool block to red.
Now when you change a rail switch the wool will change color to red or green. You will now be able to control minecart movement through your village.
I believe there is a range issue related to the wireless command blocks. I am not sure. I have a Bone Farm some distance away and I cannot get the Launch button to launch the minecart from my platform. However, I have an auxiliary control center about 75 blocks closer that it will work from. If anyone knows about this, please post a reply.