1

I would like to have shulkers be able to drop a second shell IF and ONLY IF they are killed with looting 4. I cannot seem to figure out how to do that. The only thing I can think of is having a "random chance with looting" table with a base chance of 0, but it only allows me to assign a number to be calculated per level, not only 4+.

Blocks are able to have a "table_bonus" which means you can assign custom values/chances based on the level of fortune. In the working loot table below (for gravel), I have made it so there is a 100% chance of getting flint with fortune 4. Can I do something similar for looting?

{
  "type": "minecraft:block",
  "pools": [
    {
      "rolls": 1,
      "bonus_rolls": 0,
      "entries": [
        {
          "type": "minecraft:alternatives",
          "children": [
            {
              "type": "minecraft:item",
              "name": "minecraft:gravel",
              "conditions": [
                {
                  "condition": "minecraft:match_tool",
                  "predicate": {
                    "enchantments": [
                      {
                        "enchantment": "minecraft:silk_touch",
                        "levels": {
                          "min": 1
                        }
                      }
                    ]
                  }
                }
              ]
            },
            {
              "type": "minecraft:alternatives",
              "children": [
                {
                  "type": "minecraft:item",
                  "name": "minecraft:flint",
                  "conditions": [
                    {
                      "condition": "minecraft:table_bonus",
                      "enchantment": "minecraft:fortune",
                      "chances": [
                        0.08,
                        0.15,
                        0.2,
                        0.3,
                        1
                      ]
                    }
                  ]
                },
                {
                  "type": "minecraft:item",
                  "name": "minecraft:gravel"
                }
              ],
              "conditions": [
                {
                  "condition": "minecraft:survives_explosion"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}

2 Answers 2

2

Nevermind I figured it out.

As you can see, I just used the same check that creepers use when dropping discs (killer), and then I can specify killer nbt:

{
  "type": "minecraft:entity",
  "pools": [
    {
      "rolls": 1,
      "bonus_rolls": 0,
      "entries": [
        {
          "type": "minecraft:item",
          "name": "minecraft:shulker_shell",
          "conditions": [
            {
              "condition": "minecraft:random_chance_with_looting",
              "chance": 0.3,
              "looting_multiplier": 0.05
            }
          ]
        }
      ]
    },
    {
      "rolls": 1,
      "entries": [
        {
          "type": "minecraft:item",
          "name": "minecraft:shulker_shell",
          "conditions": [
            {
              "condition": "minecraft:entity_properties",
              "entity": "killer",
              "predicate": {
                "type": "minecraft:player",
                "equipment": {
                  "mainhand": {
                    "enchantments": [
                      {
                        "enchantment": "minecraft:looting",
                        "levels": 4
                      }
                    ]
                  }
                }
              }
            }
          ]
        }
      ]
    }
  ]
}
0

Disclaimer: I haven't tested this in game, nor have I made any loot tables before. I have just studied the format.

This loot table has a pool of one, which has two alternatives. The first has the condition that the tool (or in this case weapon) is enchanted with looting 4+, and the item modifier to set the count to 2. The second alternative is the default to give you one shell. The game will pick the first alternative that matches.

{
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "alternatives",
          "children": [
            {
              "type": "item",
              "name": "minecraft:shulker_shell",
              "conditions": [
                {
                  "condition": "match_tool",
                  "predicate": {
                    "enchantments": [
                      {
                        "enchantment": "looting",
                        "levels": {
                          "range_min": 4
                        }
                      }
                    ]
                  }
                }
              ],
              "functions": [
                  {
                    "function": "set_count",
                    "count": 2
                  }
              ]
            },
            {
              "type": "item",
              "name": "minecraft:shulker_shell"
            }
          ]
        }
      ]
    }
  ]
}

I found these resources helpful:

2
  • Apparently match tool is not a valid tag for entities, so thats what prompted this question.
    – Aceplante
    Commented Feb 17, 2022 at 5:48
  • the problem with this is that the first resource is for Bedrock, not Java, which are two entirely different fruits.
    – xTerrene
    Commented Feb 17, 2022 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.