tunnel.js

tunnel.js is a Minecraft WorldEdit craftscript that I made to create a tunnel in Minecraft. (Script download link / instructions download link)

tunnel screenshot

Why a tunnel? I just like making tunnels and then sitting in a cart travelling along the tunnel, admiring the scenery. I find it very relaxing.

Digging tunnels, or even using several WorldEdit commands, is a bit tedious so I decided to make a script (even before I knew that craftscripts existed) to easily and quickly make tunnels.

Contents: [ How to use tunnel.js ] [ What tunnel.js does ] [ Glitchyness ] [ “Failed to execute Script timed out” ] [ Before using tunnel.js ] [ Acknowledgements ] [ Disclaimer / About me ]

How to use tunnel.js

The following instructions assume that you can (and do) already run craftscripts on your Minecraft. If you cannot, please skip to the ‘Before using tunnel.js’ section and come back here when you get all that sorted out.

1. At the console you can type the command “/cs tunnel.js” to get the correct parameter usage.

The script parameters are:

a. Length - compulsory, a minimum of 3 blocks
b. Height - compulsory, a minimum of 3 blocks
c. Width - compulsory, a minimum of 3 blocks and an odd number (so player is centred)
d. Features - optional, 1 = Torches, 2 = Powered rail, 4 = Teleport to end of tunnel - add the numbers to combine features e.g. 3 (1 + 2) = Torches & Powered rail - or leave blank for a blank tunnel (gets a bit dark under ground though!)

2. The command “/cs tunnel.js 100 10 5 3” will create a tunnel 100 blocks long,10 blocks high, 5 blocks wide and it will have torches and powered rails.

tunnel screenshot


3. That’s essentially it.

What tunnel.js does

This script makes a tunnel by turning everything into air.

If there is water or lava around (or sand or gravel above) the tunnel, it will turn it into glass (to stop the water / lava / etc running into the tunnel). The tunnel starts 1 block behind the player and moves forward (very fast), making the tunnel as it goes.

The tunnel floor is made of glass (except if you nominate the tunnel feature ‘Powered rail’, in which case the centre of the glass floor is brick with the rail on top).

tunnel screenshot

The tunnel starts 1 block behind the player, with the floor of the tunnel immediately under the feet of the player (i.e. the player is standing on the floor of the tunnel). If the player is under water, this will ensure that there is a wall (of glass) behind them.

As water and lava can flow, the script creates a small glass ‘sidewall’ (for the sides) or umbrella (for the top) before and after the water / lava to prevent it flowing into the tunnel.

tunnel screenshot

Glitchyness

Sometimes (on long / large tunnels) the script will not work perfectly and some water, lava, sand or gravel will get into the tunnel (it’s annoying). If this happens, just redo the script and that usually fixes it.

tunnel screenshottunnel screenshot

“Failed to execute Script timed out”

This time-out error occurs when the tunnel is ‘too big’ and Minecraft (WorldEdit really) will abort the script if it is taking too long.

By default the setting is "scripting-timeout=3000" (ms = 3 seconds). Try increasing this setting to 10000 (10k) to enable you to build bigger tunnels (change in “…\.minecraft\config\worldedit\worldedit.properties”).
On my old / slow PC (with “scripting-timeout=10000" / 10k), ‘too big’ is about 200,000 blocks (e.g. L=2000 x H=10 x W=10 = 200k).

If the script aborts, it may look like it worked but as you go along you may find it didn’t complete properly. You can do an “/undo” and run the script again but make the tunnel shorter / smaller.

tunnel screenshot

If you feel lucky, you can just move forward and if you encounter any weirdness, just run the script again (like in ‘Glitchyness’ above).

Before using tunnel.js

To use a craftscript you need to have installed and configured: Minecraft, WorldEdit and Rhino (a JavaScript engine - required for scripting support).

Note: It is beyond the scope of these instructions to cover the acquisition, installation and configuration of these. Each of them can be tricky. If you need help, Google is your friend.

Having said that, here are some links that may be helpful:

Minecraft: https://help.mojang.com/customer/en/portal/articles/325947-where-can-i-buy-minecraft-

WorldEdit: http://wiki.sk89q.com/wiki/WorldEdit, http://wiki.sk89q.com/wiki/WorldEdit/Installation/Single_player

Rhino: http://wiki.sk89q.com/wiki/WorldEdit/Scripting/Development, http://wiki.sk89q.com/wiki/WorldEdit/Installation/Single_player

Update 17JUN18: A couple of days after uploading this page I installed Minecraft etc onto my Linux laptop and found that there no real good 'install and config' instructions out there (there are many but they are not good - especially for Rhino which is mandatory) so over the next week or three I will compile some instructions on how to install and configure Minecraft, WorldEdit (and Forge) and Rhino. To be notified when I get this done, 'watch' my forum post (http://forum.enginehub.org/threads/new-craftscript-tunnel-js-makes-a-tunnel.26452/) as I will update it when I add the 'config and install' instructions.

Acknowledgements

In constructing this script I studied and incorporated some great ideas from (mainly) the following creators.

inHaze

http://inhaze.net
https://www.planetminecraft.com/member/inhaze/
script: Build Commands for WorldEdit - Copyright (C) 2015 inHaze http://inhaze.net/resources/build_commands/

sk89q

http://www.sk89q.com
http://wiki.sk89q.com/wiki/WorldEdit
script: Quick shot music layout - Copyright (C) 2011 sk89q https://searchcode.com/codesearch/view/7410991/

boy0001

http://boydti.com/
script: Fast Async WorldEdit https://www.spigotmc.org/resources/fast-async-worldedit-voxelsniper.13932/ https://github.com/boy0001/FastAsyncWorldedit

Disclaimer / About me

I am not a Minecraft, WorldEdit or programming / JavaScript expert - I would describe myself as ‘novice’ at best, in all of these.

I cannot help solve your Minecraft, WorldEdit or programming / JavaScript problems (I hardly know what I am doing myself much of the time). Try Google or some of the forums that are out there (some are linked on the pages of other creators that I acknowledged).

If you have any problems running my script, I doubt I can help you. It runs on my configuration (fairly modest specs / see below) – your configuration is your problem.

HP PC – AMD 3.7GHz, 8GB, AMD Radeon R5, WIN10 64-bit
Minecraft Java Edition (fow Windows 10), Forge 1.12.2-forge1.12.2-14.23.4.2705, WorldEdit 6.1.8-SNAPSHOT

HP Notebook Pavilion DV9000 - Intel Core 2 Duo, T7500 2.20GHx x 2, Geforce 8600M, 2G, Ubuntu 16.04 LTS, 64-bit, Java Version: 1.8.0_171, Oracle Corporation
Minecraft Java Edition, MinecraftForge v14.23.4.2708, WorldEdit 6.1.8-SNAPSHOT (updated 17JUN18)

I wrote this script by studying other (very good) scripts (see above where I acknowledge some coders) and leaning hard on Google.

I understand that (probably) much of my code could be improved. If you wish, please feel free to improve / change it to suit your needs. If you do, please send me a copy of your code as I would like to see what you have done and learn from your work.

If you have any suggestions or ideas regarding my script, feel free to let me know.

You can find this document, the script and other stuff at http://bmcbeth.com/tunnel. This location is also in the header-code of the script.

Feel free to email me at email@bmcbeth.com

Cheers.

(Page created 09JUN18. Last updated 17JUN18 (added laptop specs etc and message about creating install / config instructions soon).