Safebranch - A mining program

Started by justinjah91, Aug 23, 2022, 04:04 PM

Previous topic - Next topic

justinjah91

This program is designed to create a SAFE branch mine with 3x3 hallways, with multiple turtles working in tandem. The turtles will seal off any holes in the walls and will light the mine as they dig it, ensuring that no mobs get into your mine! They will also seal off any lava or water so your mine does not flood [See note 1]. Each turtle is responsible for either a branch or the main trunk of the mine. It is recommended to use at least 3 turtles (one for the main trunk and one for a branch on each side of the trunk), but fewer can be used with some manual repositioning. How it works:

  • The turtle will mine out a 3x3 area. As it does so, it will compare the blocks in the walls with whatever is placed in its first slot. If that block does not match slot 1, it will be replaced with whatever is in slot 2. For example, I use this with stone in slot 1 and cobblestone in slot 2 (deepslate and cobbled deepslate work equally well). This means that anything in the walls that ISN'T stone will be replaced with cobblestone. If you were to place cobblestone in slots 1 and 2, the walls would end up being solid cobblestone. As it mines out these slices, a turtle will place torches so that the tunnel remains safe from mob spawns. For optimum torch utilization, users need to do a bit of math.

The code: https://pastebin.com/XYMvEYDB

          * For MC versions before 1.18, tunnels should be of length 10n + 4 (where n is an integer 1, 2, ...)
          * For MC versions 1.18+, tunnels should be of length 24n + 11

  • Before beginning each 3x3 slice of a tunnel, the turtle will check to make sure it has enough materials to adequately complete that slice. If it does not, it will return to the beginning of the branch mine to resupply. If the turtle's inventory gets full, it will also return to this position to unload.
  • When the turtles are finished with mining out the branches, they will return to the main trunk and position themselves for the next branch. The user will need to specify the direction that the turtle will need to go (either right or left) to reach the next tunnel position.
  • Lastly, more than 1 turtle can be assigned to work on each side of the main trunk (each working on their own tunnels). The number of turtles needs to be specified by the user.

For specifics of the setup, go to https://imgur.com/a/GJglvsW

Calling sequence: Safebranch <type> <length> <direction> <# of turtles> <min light lvl>
  • <type> can be "side" or "main"
  • <length> is the length of the tunnel you want mined
  • <direction> is the direction the turtle should go when finished (l or r). This argument may be omitted for "main" tunnels
  • Note that this direction is from the turtle's perspective. A turtle on the left side of the branch mine should probably move to the right when they finish their branch
  • <# of turtles> is the number of turtles on this side of the main tunnel. This argument may be omitted for "main" tunnels
          * Should be at least 1, but can be as many as you like
  • <min light lvl> is the minimum light level that you want to allow in your mine. This argument may be omitted for "main" tunnels. To block mob spawns:
          * For MC versions lower than 1.18, this should be greater than or equal to 8
          * For 1.18+, it should be greater than or equal to 1.

[Note 1] More recent versions of CC (for minecraft 1.13+) include the ability to waterlog turtles. While this may not cause an issue for small pockets of water, it WILL cause issues for larger pockets or aquifers. There is no way to combat this unless the devs add an option to disable waterlogging. For this reason, I recommend digging a small 1x1x1 hole in the floor at the start of each tunnel to stop any floods that do occur. I know it is annoying to have water sources in the tunnel (it drives me crazy), but in these versions of CC the turtles are incapable of directly removing water. All workarounds that I have considered involve silly things, like giving the turtles sponges and/or buckets, thus taking up valuable inventory space and reducing their effectiveness as mining turtles. For the time being, I suggest using some water proof light source in slot 3 (like lanterns or glowstone). These sorts of workarounds should NOT be necessary on 1.12 and earlier.

The code: https://pastebin.com/XYMvEYDB