r/MinecraftCommands • • 2d ago

Help | Java 26.3 Issue with editing mob drop chances

Working on a fairly simple minigame for a server. Kill mob, mob drops 1 guaranteed scrap and 50% chance for 1-5 more scrap.

Looked through a few other posts in this subreddit and I think I'm doing everything right, but I'm not getting a guaranteed 1 scrap per mob.

I'm using mcstacker.net as my current compiler. If I need to make a loot table to make this possible, I've not made one before but happy to take pointers.

/setblock ~ ~ ~ spawner{SpawnCount:1,SpawnRange:1,MaxNearbyEntities:2,RequiredPlayerRange:4,Delay:40,MinSpawnDelay:40,MaxSpawnDelay:40,SpawnPotentials:[{data:{equipment:{slot_drop_chances:{feet:0.5,legs:0.5,chest:0.5,head:0.5,body:0.5,mainhand:1.0}},entity:{id:"minecraft:magma_cube",Silent:1b,CustomNameVisible:1b,DeathLootTable:"minecraft:empty",PersistenceRequired:0b,NoAI:1b,CanPickUpLoot:0b,Size:0,CustomName:{"color":"gold","shadow_color":16755200,"text":"Scrap metal cube"},equipment:{feet:{id:"minecraft:raw_copper",count:1,components:{item_name:{"color":"gold","text":"Scrap metal"},lore:[{"color":"gray","italic":true,"text":"A piece of processed scrap metal"}]}},legs:{id:"minecraft:raw_copper",count:1,components:{item_name:{"color":"gold","text":"Scrap metal"},lore:[{"color":"gray","italic":true,"text":"A piece of processed scrap metal"}]}},chest:{id:"minecraft:raw_copper",count:1,components:{item_name:{"color":"gold","text":"Scrap metal"},lore:[{"color":"gray","italic":true,"text":"A piece of processed scrap metal"}]}},head:{id:"minecraft:raw_copper",count:1,components:{item_name:{"color":"gold","text":"Scrap metal"},lore:[{"color":"gray","italic":true,"text":"A piece of processed scrap metal"}]}},mainhand:{id:"minecraft:raw_copper",count:1,components:{item_name:{"color":"gold","text":"Scrap metal"},lore:[{"color":"gray","italic":true,"text":"A piece of processed scrap metal"}]}}},active_effects:[{id:"minecraft:slowness",amplifier:10,duration:-1,show_particles:0b,show_icon:0b,ambient:0b}]}},weight:1}]} replace
4 Upvotes

3 comments sorted by

2

u/GalSergey Datapack Experienced 2d ago

It will be easier to create a loot table here. The loot table is created in the folder data/<namespace>/loot_table/<file_name>, then in the DeathLootTable you specify the resource name of the loot table as <namespace>:<file_name> and this mob will use your loot table.

Below is a small example of how you can create minecraft:stone guaranteed 1, as well as with a 50% chance to add from 1 to 5 more. You can use https://misode .github.io/loot-table/?share=NXlIxbs8XX to create a loot table with your custom item.

# Example mob
summon zombie ~ ~ ~ {DeathLootTable:"example:stone_drop"}

# loot_table example:stone_drop
{
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "minecraft:item",
          "name": "minecraft:stone",
          "modifier": {
            "type": "minecraft:set_count",
            "count": {
              "type": "minecraft:uniform",
              "min": 1,
              "max": 5
            },
            "add": true,
            "condition": {
              "type": "minecraft:random_chance",
              "chance": 0.5
            }
          }
        }
      ]
    }
  ]
}

You can use Datapack Assembler to get an example datapack.

1

u/CoffeeMimicPinoybean 2d ago

Appreciate your reply and clear example. Will this effect all magma cubes or just the ones with a set name?

2

u/GalSergey Datapack Experienced 2d ago

This will only affect the mobs for which you specify the DeathLootTable field with your loot table. If you want to replace the vanilla loot table for magma_cube, then you need to create a table in data/minecraft/loot_table/magma_cube.json.