r/MinecraftCommands • • 3d ago

Help | Java 26.3 Silk touch spawners + loot tables

Can anyone explain to me in small words why using match_tool in a loot table doesn't seem to work on spawners?

I'm trying to make a (theoretically, though probably not actually) simple java datapack for 26.3 that lets you break spawners to get mob loot. But I am also extremely beginner level with datapacks, so when my first try didn't work I just tried copying over the loot table for stone to spawners to edit that, and that worked fine - except that it always dropped stone whether I used a silk touch tool or not.

I tried swapping in the melon loot table instead of stone, and it did the same thing - whole melons every time I broke a spawner. The enchants work fine on stone and melon blocks with the exact same loot tables! And if I took out the match_tool conditions, everything worked as expected with the spawner, too, it's just once it tried to check for silk touch on a spawner it acted like every pick was silk touch.

I assumed this was just me not knowing what the heck I was doing but I did some poking around on Reddit and Modrinth, and it looks like everybody else's "use silk touch on spawners" datapacks are broken this way too, unless they do something fancy with functions instead of just using the loot table. But I didn't see anyone explaining why.

So - is there something special about how some blocks' loot tables use conditions? Or is it just a bug with spawners? Is it something I will need to worry about if I want to use other conditions/predicates on spawner loot that work on other blocks? Am I just useless? pls help.

3 Upvotes

9 comments sorted by

2

u/GalSergey Datapack Experienced 3d ago
{
  "type": "minecraft:block",
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "minecraft:item",
          "name": "minecraft:spawner",
          "condition": {
            "type": "minecraft:match_tool",
            "predicate": {
              "predicates": {
                "minecraft:enchantments": [
                  {
                    "enchantments": "minecraft:silk_touch",
                    "levels": {
                      "min": 1
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  ],
  "random_sequence": "minecraft:blocks/spawner"
}

1

u/commensally 3d ago edited 3d ago

I can't test right now but that looks just like the one that drops the silk touch block for unenchanted tools for me, yeah

1

u/commensally 2d ago

Okay! I have tested it and that works, thanks so much. So can anyone explain to me why that works but copying over the default loot table for stone doesn't?

1

u/GalSergey Datapack Experienced 2d ago

It is possible that you based your setup on a loot table intended for a different version. Without seeing the specific loot table you tried to use, I cannot say for sure.

1

u/commensally 2d ago

I pulled it from the 26.3 files in my current install, so I doubt it?

1

u/GatKong 3d ago

Not being able to collect spawners is hardcoded. Even work-arounds have to get creative to make it happen.

2

u/commensally 3d ago

It's really easy to do a datapack that just drops an empty spawner when you break a spawner, actually? Like. Trivially easy. The tricky part is getting it to *only* do it for Silk Touch, apparently.

Getting it to preserve the nbt data of the spawner is tricky, yeah. But I don't even want it to drop spawners, I want it to break but drop different non-spawner loot depending on what enchantments you have.

2

u/c_dubs063 Command Experienced 3d ago

I've definitely gotten this to work in the past, I can tinker with it tonight when I get home a little later if you still need help by then.

One thing to note though, I dont think it will work for getting, say, a zombie spawner specifically. You'll just get a spawner which defaults to a pig spawner. If you want to copy specifically the type of spawner you pick up, you'll need to do some clever functions/commands to make it work the way you want. But now that nbt was replaced by components, maybe that has changed. I can experiment later.

2

u/commensally 3d ago edited 2d ago

I don't want spawners at all, actually! I'm just trying to practice by making a datapack for my Peaceful forever world that makes spawners useful for something by making them drop rare loot when broken, like string and bones and flesh and magma cream - it's Peaceful after all.

(All the data packs I found to try to copy from do drop empty spawners, but they're all broken in this other way too.)  I can already get my loot with a basic loot pool, but I wanted to try to level up by making it drop different loot with Silk Touch, and I hit this and got stuck.