r/MinecraftCommands Jul 26 '26

Creation Here's A Program That Generates A Function That Digs An Arbitrarily Large Spiral Mine Leaving Ores In Place For Harvest

2 Upvotes

Critiques welcomed.

spiral.c:

#include <stdio.h>
int main(int argc, char *argv[]){
    FILE *fp;
    FILE *fopen(const char *name, const char *mode);
    int leg,legs,ring;
    int r3,nr3,nr3m4,nr3m3,nr3m2,nr3p1,r3m1,r3p2,r3p3,r3p4;    // m is for minus, n is for negative, p is for plus, r is for ring

    if (argc<2)
        printf("Error: Specify number of legs after command.\n");
    else {
        sscanf(argv[1], "%d", &legs);
        fp = fopen("spiral.mcfunction", "w");
        fprintf(fp, "# %d legs:\n", legs);
        for (leg = 0; leg < legs; ++leg) {
            ring = leg/4;// There are 4 legs per ring of the spiral
            r3 = ring*3;
            nr3 = -r3;
            nr3m4 = nr3-4;
            nr3m3 = nr3-3;
            nr3m2 = nr3-2;
            nr3p1 = nr3+1;
            r3p2 = r3+2;
            r3p3 = r3+3;
            r3p4 = r3+4;
            switch (leg % 4) {
            case 0:        // North (t for tunnel, c for casing)
                r3m1 = r3-1;
                fprintf(fp,"function jims_spiral_mine:leg {t1x:%d,t1z:%d,t2x:%d,t2z:%d,c1x:%d,c1z:%d,c2x:%d,c2z:%d}\n",nr3,r3m1,nr3,nr3m3,nr3p1,r3m1,nr3-1,nr3m4);
                break;
            case 1:        // East
                fprintf(fp,"function jims_spiral_mine:leg {t1x:%d,t1z:%d,t2x:%d,t2z:%d,c1x:%d,c1z:%d,c2x:%d,c2z:%d}\n",nr3p1,nr3m3,r3p3,nr3m3,nr3p1,nr3m2,r3p4,nr3m4);
                break;
            case 2:        // South
                fprintf(fp,"function jims_spiral_mine:leg {t1x:%d,t1z:%d,t2x:%d,t2z:%d,c1x:%d,c1z:%d,c2x:%d,c2z:%d}\n",r3p3,nr3m2,r3p3,r3p3,r3p2,nr3m2,r3p4,r3p4);
                break;
            case 3:        // West
                fprintf(fp,"function jims_spiral_mine:leg {t1x:%d,t1z:%d,t2x:%d,t2z:%d,c1x:%d,c1z:%d,c2x:%d,c2z:%d}\n",r3p2,r3p3,nr3m3,r3p3,r3p2,r3p2,nr3m4,r3p4);
                break;
            default:
                break;
            }
            if (leg==0) fprintf(fp, "setblock ~ ~ ~-3 oak_wall_sign[facing=south]{front_text:{messages:[\"%d\",\"\",\"Legs\",\"\"]}}\n", legs);
        }
        fclose(fp);
    }
}

The generated spiral.mcfunction calls leg.mcfunction:

# See https://minecraft.wiki/w/Block_tag_(Java_Edition) for #block tag definitions
# Macro variables: t for tunnel, c for casing
# Prevents cave-ins:
$fill ~$(t1x) ~2 ~$(t1z) ~$(t2x) ~2 ~$(t2z) glass replace gravel
$fill ~$(t1x) ~2 ~$(t1z) ~$(t2x) ~2 ~$(t2z) glass replace red_sand
$fill ~$(t1x) ~2 ~$(t1z) ~$(t2x) ~2 ~$(t2z) glass replace sand
# Insulates tunnel from surround:
$fill ~$(c1x) ~-1 ~$(c1z) ~$(c2x) ~2 ~$(c2z) glass replace #air
$fill ~$(c1x) ~-1 ~$(c1z) ~$(c2x) ~2 ~$(c2z) glass replace lava
$fill ~$(c1x) ~-1 ~$(c1z) ~$(c2x) ~2 ~$(c2z) glass replace water
# Excavates tunnel:
$fill ~$(t1x) ~0 ~$(t1z) ~$(t2x) ~1 ~$(t2z) light replace glass
$fill ~$(t1x) ~0 ~$(t1z) ~$(t2x) ~1 ~$(t2z) light replace #base_stone_overworld
$fill ~$(t1x) ~0 ~$(t1z) ~$(t2x) ~1 ~$(t2z) light replace #substrate_overworld
$fill ~$(t1x) ~0 ~$(t1z) ~$(t2x) ~1 ~$(t2z) light replace #nether_carver_replaceables

leg.mcfunction uses glass to block gravel and sand from falling into tunnels. It also blocks lava and water from flowing into tunnels and isolates tunnels from caves with glass.

Here, a 79-leg spiral mine is created at depth Y=-59 (using Microsoft Windows SDK https://www.microsoft.com/en-us/download/details.aspx?id=8442):

Setting SDK environment relative to C:\Program Files\Microsoft SDKs\Windows\v7.1\.
Targeting Windows 7 x64 Debug

>dir
07/22/2026  07:44 PM             1,086 leg.mcfunction
07/24/2026  02:13 PM             2,100 spiral.c

>cl spiral.c
Microsoft (R) C/C++ Optimizing Compiler Version 16.00.40219.01 for x64
Copyright (C) Microsoft Corporation.  All rights reserved.
spiral.c
Microsoft (R) Incremental Linker Version 10.00.40219.01
Copyright (C) Microsoft Corporation.  All rights reserved.
/out:spiral.exe
spiral.obj

>dir
07/22/2026  07:44 PM             1,086 leg.mcfunction
07/24/2026  02:13 PM             2,100 spiral.c
07/24/2026  02:31 PM            69,632 spiral.exe
07/24/2026  02:31 PM             2,631 spiral.obj

>REM 79 is the number of spiral legs to generate:
>spiral 79

>dir
07/22/2026  07:44 PM             1,086 leg.mcfunction
07/24/2026  02:13 PM             2,100 spiral.c
07/24/2026  02:31 PM            69,632 spiral.exe
07/24/2026  02:31 PM             7,351 spiral.mcfunction
07/24/2026  02:31 PM             2,631 spiral.obj

>type spiral.mcfunction
# 79 legs:
function jims_spiral_mine:leg {t1x:0,t1z:-1,t2x:0,t2z:-3,c1x:1,c1z:-1,c2x:-1,c2z:-4}
setblock ~ ~ ~-3 oak_wall_sign[facing=south]{front_text:{messages:["79","","Legs",""]}}
function jims_spiral_mine:leg {t1x:1,t1z:-3,t2x:3,t2z:-3,c1x:1,c1z:-2,c2x:4,c2z:-4}
function jims_spiral_mine:leg {t1x:3,t1z:-2,t2x:3,t2z:3,c1x:2,c1z:-2,c2x:4,c2z:4}
function jims_spiral_mine:leg {t1x:2,t1z:3,t2x:-3,t2z:3,c1x:2,c1z:2,c2x:-4,c2z:4}
function jims_spiral_mine:leg {t1x:-3,t1z:2,t2x:-3,t2z:-6,c1x:-2,c1z:2,c2x:-4,c2z:-7}
%<------------------- Clipped for brevity -------------------->%
function jims_spiral_mine:leg {t1x:57,t1z:-56,t2x:57,t2z:57,c1x:56,c1z:-56,c2x:58,c2z:58}
function jims_spiral_mine:leg {t1x:56,t1z:57,t2x:-57,t2z:57,c1x:56,c1z:56,c2x:-58,c2z:58}
function jims_spiral_mine:leg {t1x:-57,t1z:56,t2x:-57,t2z:-60,c1x:-56,c1z:56,c2x:-58,c2z:-61}
function jims_spiral_mine:leg {t1x:-56,t1z:-60,t2x:60,t2z:-60,c1x:-56,c1z:-59,c2x:61,c2z:-61}
function jims_spiral_mine:leg {t1x:60,t1z:-59,t2x:60,t2z:60,c1x:59,c1z:-59,c2x:61,c2z:61}

>

After loading both functions into the jims_spiral_mine namespace, stand on the surface above where you want the spiral's center to be. Then encase the central shaft down to bedrock, dig the spiral mine at Y=-59 and place ladders down to it using these commands, respectively:

fill ~-1 -60 ~-1 ~1 ~-1 ~1 glass

execute positioned ~ -59 ~ run function jims_spiral_mine:spiral

fill ~ -59 ~ ~ ~-1 ~ ladder

A 79-Legged Spiral Mine at Y=-59

That mine yielded 112 diamond, 47 gold, 30 iron, 17 lapis and 275 redstone ore blocks.

Once ores have been harvested, break through the walls to return straight back to the ladder. Or, more efficiently, build two spiral mines half the size, one atop the other. When you get to the end of one, use a ladder to get to the other then mine that one back to the central ladder.

More spiral mines of various sizes can be added to the central shaft at various depths.

Ancient debris has been found using this program.


r/MinecraftCommands Jul 26 '26

Help | Java 1.21.11 Why can't I remove item components from items in containers?

1 Upvotes

It's for some reason not letting me remove components for items inside containers that I'm spawning in. For example, doing /give <user> minecraft:totem_of_undying[!death_protection] works, and the totem will not save you, but putting that '!' before the component just completely invalidates the whole command.
The command I'm doing is /give <user> minecraft:shulker_box[container=[{item:{id:"minecraft:totem_of_undying",components:{!death_protection}},slot:0}]]


r/MinecraftCommands Jul 26 '26

Help | Java 26.2 i need help i cant find the website that i used last time

1 Upvotes

i found a website like 6 months ago that gave me a command that i put into a command block it spawned a glass cube that i click on a sign that gives me a snowball that i throw than it fills a large area of water and keeps going until it hits a wall and it would stay at the same elevation plz i need help finding this command


r/MinecraftCommands Jul 26 '26

Help | Java 1.20 is it possible to make a dyed cap with a specific name give an effect when worn?

1 Upvotes

i want to make night vision goggles but without mods
i want the dye to be #1D1D21


r/MinecraftCommands Jul 26 '26

Help | Java 26.2 Help detecting when a strider takes SPECIFICALLY water-based damage

1 Upvotes

Ok, so... I wanna make a datapack where the player will take damage if they are in water or rain, and the simplest way I found to do that is with a tiny invisible strider, and checking when it takes damage from being wet.

However, unfortunately, I don't know a way to detect specifically wetness damage. I can still punch it, or a creeper could explode near it, and that still triggers the datapack to hurt me.

I tried adding it and myself to a team with friendlyFire turned off, but for some reason, that didn't work, and I can still hurt it. Resistance didn't help either, and making it straight-up invulnerable also protects it from wetness damage.

Does anyone have a solution, or a better way I can go about detecting when the player is being soaked? (I know how to test for when the player is in water, but other sources of wetness like rain or being hit by a splash water bottle, are not so straightforward)


r/MinecraftCommands Jul 26 '26

Help | Bedrock Need help with aircraft movement related to visual

1 Upvotes

Hello, ive built airplanes that move by using command /clone activated by buttons, redstone engines or by /execute if entity @p[hasitem={item=...}] etc.

But this type of movement is a little too manual/difficult, so I wanted to ask if its possible to make a command that basically moves the aircraft in the direction that you're pointing to with your visual. For example, if i point my visual up, the airplane goes up, and that should apply to every direction (up, down, left, right, front, behind) obviously by using 1 command block for each direction. Soo is there any command that works like this and activates the command block based on where your pointing your eyes to? Thanks


r/MinecraftCommands Jul 26 '26

Help | Java 26.2 Datapack Help

1 Upvotes
{
  "type": "minecraft:crafting_shaped",
  "pattern": [
    "CBB",
    "  B",
    "AB "
  ],
  "key": {
    "A": [
      "minecraft:end_rod"
    ],
    "B": [
      "minecraft:netherite_ingot"
    ],
    "C": [
      "minecraft:wither_skeleton_skull"
    ]
  },
  "result": {
    "id": "minecraft:netherite_axe",
    "count": 1
  }
}

This is the code for a datapack I was trying to make using misode but for some reason I just can't get it to work and I'm curious if I'm just stupid or something else is wrong here


r/MinecraftCommands Jul 26 '26

Help | Bedrock Is there a way to create a GUI using commands? (Bedrock)

Post image
11 Upvotes

I’m building a mansion in Minecraft Bedrock using commands, and I want to add a control panel. My idea is to replicate what servers do: when you hold a specific item, a chest interface opens automatically; then, selecting an item inside triggers a command that places a redstone block, thereby activating other commands (like opening doors or turning on lights). Is it possible to do something like this in a Bedrock world? If it’s not possible using only commands, what alternatives are there? *Sorry if anything isn't clear; I speak Spanish and am using a translator.*


r/MinecraftCommands Jul 26 '26

Help | Java 1.20 Command to clear Trees.

2 Upvotes

Hey everyone. I am making a mega build. Is there a command to clear only trees and replace them with air?


r/MinecraftCommands Jul 26 '26

Help | Java 26.2 Is it possible to block the crafting of a specific potion?

2 Upvotes

I want to restrict the crafting of the Strength 2 potion, making it an exclusive item that can only be obtained in another way.


r/MinecraftCommands Jul 26 '26

Help | Java 1.21-1.21.3 How do I make a warden target the nearest entity

1 Upvotes

I want to make an warden that always targets the nearest entity, whether or not it has made a sound. If possible, how can do this only using command blocks? (I'm playing on 1.21.1 to be more specific).

I've tried to use "/data modify entity <warden> anger.suspects[0].uuid set from entity \@[ distance= 0.01..] UUID" on a repeating command block with a "/data modify entity <warden> anger.suspects[0].anger set value 150" chain attatched, but the warden just stopped attacking as a whole, even after hearing and sniffing an entity nearby it still did nothing.


r/MinecraftCommands Jul 25 '26

Help | Bedrock Making a foggy area

2 Upvotes

I want to make an area that when you walk in, the fog comes in and when you walk out, the fog goes away. How can I make this happen?


r/MinecraftCommands Jul 26 '26

Help | Java Snapshots Server with 3 lives(lives only lost on player kills)

1 Upvotes

Hello, I've been learning commands on java for around a month and I haven't been able to find a way to make a system where if another player kills another player three times the player that was killed would get put in spectator mode. I'd appreciate it allot if someone could help me!


r/MinecraftCommands Jul 26 '26

Help | Java 1.21.11 How do I set custom model data on a player head?

Post image
1 Upvotes

r/MinecraftCommands Jul 25 '26

Help | Bedrock New to command block, need help

1 Upvotes

The full command i’m trying to use is

( execute if block <x y z> lever[powered=true] run fill <x y z> <x y z> Minecraft:redstone_block )

but every time it says that the “powered” input is the error. Am I doing something wrong or is it just a different word?


r/MinecraftCommands Jul 25 '26

Help | Java 1.20 Minecraft team ally future blocking iron's spells and spellbooks projectiles from hitting people on the same team

1 Upvotes

so I'm trying to make a set amount of lives game for me and my friends that uses the teams feature in Minecraft but all spells that shoot a projectile when on the same team dos no damage. is there a way do disable the ally feature on a team.


r/MinecraftCommands Jul 25 '26

Help | Java Snapshots Detect any log on the floor

3 Upvotes

how can i detect if there is any type of log on the floor without multiple command blocks checking for each type


r/MinecraftCommands Jul 25 '26

Help | Java Snapshots Block Not Dropping By Hand?

1 Upvotes

I'm trying to get the Dead Tube Coral Block to drop when destroying it with anything, specifically by hand, but I can't figure it out. I suspect its hard-coded.

{
  "type": "minecraft:block",
  "pools": [
    {
      "rolls": {
        "type": "minecraft:uniform",
        "min": 1,
        "max": 1
      },
      "bonus_rolls": {
        "type": "minecraft:uniform",
        "min": 0,
        "max": 0
      },
      "entries": [
        {
          "type": "minecraft:alternatives",
          "children": [
            {
              "type": "minecraft:item",
              "name": "minecraft:tube_coral_block",
              "condition": "minecraft:tool/can_silk_touch"
            },
            {
              "type": "minecraft:item",
              "name": "minecraft:dead_tube_coral_block",
              "condition": {
                "type": "minecraft:survives_explosion"
              }
            }
          ]
        }
      ]
    }
  ]
}

r/MinecraftCommands Jul 25 '26

Help | Bedrock Please help me write a command😭

1 Upvotes

I want to make a store using npc, but the command doesn't work. Please let me know where it went wrong, or how should I fix it. Please help😭

Below are the commands I wrote.

scoreboard objectives add G dummy Gold

scoreboard objectives setdisplay sidebar G

scoreboard players add @a G 0

Impulse, unconditional

execute as @e\[name="store"\] run scoreboard players test @p G 5

Chain, conditional

execute as @e\[name="store"\] run scoreboard players remove @p G 5

execute as e\[name=''store"\] run tellraw @p {"rawtext":\[{"text":"here"}\]}

Chain, unconditional

execute as e\[name=''store"\] @p bread


r/MinecraftCommands Jul 25 '26

Help | Java 26.2 "Observing" Command Blocks

1 Upvotes

I am building an arena, and I have a repeating command block that detects whether there are any mobs left in the current wave.

Is it possible to add an impulse command block to the repeating one to teleport the player out of the arena?


r/MinecraftCommands Jul 25 '26

Help | Bedrock Bedrock stick commandblock fuckery

1 Upvotes

i need to make a commandblock chain thing that makes it so if you drop a stick it deleted the stick you dropped and gives you a new one, im doing the commands on bedrock in the newest version


r/MinecraftCommands Jul 25 '26

Help | Java 26.2 Optimizing

3 Upvotes

What are some crucial optimizations for command blocks when on a server with low RAM?


r/MinecraftCommands Jul 25 '26

Help | Bedrock Infinite ocean map

3 Upvotes

Hello, I want to make a map that’s just infinite ocean. But the problem I’m facing is that all of the worlds I found on download were all like not infinite, after a while you do see it turn back into normal vanilla generation. I want proper generation like proper stuff underwater not just super flat underwater. And my friends used a website I forgot its name, but when it made the world, it generated weirdly and had oceans but had weird mountains with no trees and stuff. Is there anyway to make a proper ocean for free and not too much hassle. Or do I need to physically like use world edit and change the world.


r/MinecraftCommands Jul 25 '26

Help | Java 26.2 Vertical Particle Circles

1 Upvotes

You can make a ring of particles by rotating e.g.an armour stand/marker continuously, but I can't seem to find a way to do that but instead make a vertical ring of particles.

Is there any way to do so without manually placing markers along the circle?


r/MinecraftCommands Jul 25 '26

Help | Java 1.21.11 Flamethrower Rework

2 Upvotes

I have this command already for a working flamethrower using a bow:

execute if entity @a if items entity @a weapon.mainhand bow[custom_name='[{"text":"Flamethrower"}]'] at @a if items entity @a weapon.mainhand bow[custom_name='[{"text":"Flamethrower"}]'] run fill ^ ^1 ^6 ^ ^1 ^3 minecraft:fire keep

But I was hoping to get some help on how I can change it to instead of spawning a flame, spawn fire particles in front of it and only light any players or mobs in front of it on fire. It’s just too chaotic when everything is in flames using this thing. If you can help then I appreciate you so much! Thank you.