"match_tool" enchant check for entity loot table?



  • 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"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
    


  • 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
                          }
                        ]
                      }
                    }
                  }
                }
              ]
            }
          ]
        }
      ]
    }
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2