Minecraft Maps / Minecart

Really smooth rail navigation with tickets.

  • 590 views, 2 today
  • 5
  • 2
  • 1
luigi_vampa's Avatar luigi_vampa
Level 52 : Grandmaster Dragonborn
176
I built a rail navigation system that works really well so I thought I'd post it, someone might find it useful!

As I'm from England and we drive on the left over here so can you! With that in mind you can see in the image that as you approach a junction there's a detector rail that powers a command block underneath. All the command blocks call the same 'test_ticket.mcfunction' that's stored in a datapack. What the function does is simply test to see if you've got a bit of paper named 'Ticket' in your hand with the Lore that represents a different station. 'S1 - S8' are the station names I've used for it but you can customise it how you like.

Command block script:

execute run function rail:test_ticket



test_ticket.mcfunction

#Station One
execute if entity @p[nbt={SelectedItem:{id:"minecraft:paper",tag:{display:{Name:'{"text":"Ticket"}',Lore:['{"text":"S1"}']}}}}] run function rail:s1

#Station Two
execute if entity @p[nbt={SelectedItem:{id:"minecraft:paper",tag:{display:{Name:'{"text":"Ticket"}',Lore:['{"text":"S2"}']}}}}] run function rail:s2

#Station Three
execute if entity @p[nbt={SelectedItem:{id:"minecraft:paper",tag:{display:{Name:'{"text":"Ticket"}',Lore:['{"text":"S3"}']}}}}] run function rail:s3

#Station Four
execute if entity @p[nbt={SelectedItem:{id:"minecraft:paper",tag:{display:{Name:'{"text":"Ticket"}',Lore:['{"text":"S4"}']}}}}] run function rail:s4

#Station Five
execute if entity @p[nbt={SelectedItem:{id:"minecraft:paper",tag:{display:{Name:'{"text":"Ticket"}',Lore:['{"text":"S5"}']}}}}] run function rail:s5

#Station Six
execute if entity @p[nbt={SelectedItem:{id:"minecraft:paper",tag:{display:{Name:'{"text":"Ticket"}',Lore:['{"text":"S6"}']}}}}] run function rail:s6

#Station Seven
execute if entity @p[nbt={SelectedItem:{id:"minecraft:paper",tag:{display:{Name:'{"text":"Ticket"}',Lore:['{"text":"S7"}']}}}}] run function rail:s7

#Station Eight
execute if entity @p[nbt={SelectedItem:{id:"minecraft:paper",tag:{display:{Name:'{"text":"Ticket"}',Lore:['{"text":"S8"}']}}}}] run function rail:s8

To the programmers out there, with neither a break/return option or a switch statement is there any way of improving that?


Then, depending on which ticket you're holding, it calls another function in the same tick that represents the journey to that station.

s1.mcfunction

# Junction One
execute if entity @p[x=1240,y=22,z=-820,distance=..6] run function rail:j1_north

# Junction Two
execute if entity @p[x=1263,y=22,z=-820,distance=..6] run function rail:j2_west

# Junction Three
execute if entity @p[x=1272,y=22,z=-820,distance=..6] run function rail:j3_west

# Junction Four
execute if entity @p[x=1297,y=22,z=-820,distance=..6] run function rail:j4_west

The station function then tests to see where on the rail network you are by proximity to the nearest junction (within 6 blocks in this case) and then calls a final function to set the tracks depending on which direction you need to go to get to that station.

j1_north.mcfunction

#N
setblock 1239 20 -823 minecraft:redstone_torch
#E
setblock 1242 20 -822 minecraft:air
#S
setblock 1241 20 -819 minecraft:redstone_torch
#W
setblock 1238 20 -820 minecraft:redstone_torch




End result means you can have half a dozen tickets in your hot bar and change destination mid journey by simply scrolling through your hot bar. You can jump on the rails from anywhere and the junction you next roll in to manages what ticket you've got and which direction you need to be going.

It does take a lot of initial configuring to begin with but having it all operate in one tick is worth it!

How you give out the tickets is down to you too. I've used the Citizens plugin to allow Steve to give them out but you could just make them or have another command block.

:D
Progress100% complete
Tags

Create an account or sign in to comment.

GivenToe
10/21/2019 8:40 pm
Level 34 : Artisan Architect
GivenToe's Avatar
I see you are still building from time to time. Nice to see. Thoughts about reviving VampaMC? Good ol days. I miss it a LOT. // PRICE (Changed username)
1
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome