Loot table based on NBT data



  • So I would like to have phantoms drop extra membranes the larger they are, except it seems like the min/max is ignored? When I kill regular phantoms with looting 3 for example I usually get 4 membranes?

    Here it is:

    {
      "type": "minecraft:entity",
      "pools": [
        {
          "rolls": 1,
          "bonus_rolls": 0,
          "entries": [
            {
              "type": "minecraft:item",
              "name": "minecraft:phantom_membrane",
              "functions": [
                {
                  "function": "minecraft:set_count",
                  "count": {
                    "type": "minecraft:uniform",
                    "min": 0,
                    "max": 1.0
                  },
                  "add": false
                },
                {
                  "function": "minecraft:looting_enchant",
                  "count": {
                    "type": "minecraft:uniform",
                    "min": 0,
                    "max": 1.0
                  }
                }
              ]
            }
          ],
          "conditions": [
            {
              "condition": "minecraft:killed_by_player",
              "inverse": true
            }
          ]
        },
        {
          "rolls": 1,
          "entries": [
            {
              "type": "minecraft:item",
              "name": "minecraft:phantom_membrane",
              "functions": [
                {
                  "function": "minecraft:set_count",
                  "count": 2.0,
                  "add": true,
                  "conditions": [
                    {
                      "condition": "minecraft:entity_properties",
                      "entity": "this",
                      "predicate": {
                        "nbt": "{Size:3}"
                      }
                    }
                  ]
                }
              ],
              "conditions": [
                {
                  "condition": "minecraft:killed_by_player",
                  "inverse": true
                }
              ]
            }
          ]
        },
        {
          "rolls": 1,
          "entries": [
            {
              "type": "minecraft:item",
              "name": "minecraft:phantom_membrane",
              "functions": [
                {
                  "function": "minecraft:set_count",
                  "count": 4.0,
                  "add": true,
                  "conditions": [
                    {
                      "condition": "minecraft:entity_properties",
                      "entity": "this",
                      "predicate": {
                        "nbt": "{Size:5}"
                      }
                    }
                  ]
                }
              ],
              "conditions": [
                {
                  "condition": "minecraft:killed_by_player",
                  "inverse": true
                }
              ]
            }
          ]
        },
        {
          "rolls": 1,
          "entries": [
            {
              "type": "minecraft:item",
              "name": "minecraft:phantom_membrane",
              "functions": [
                {
                  "function": "minecraft:set_count",
                  "count": 6.0,
                  "add": true,
                  "conditions": [
                    {
                      "condition": "minecraft:entity_properties",
                      "entity": "this",
                      "predicate": {
                        "nbt": "{Size:7}"
                      }
                    }
                  ]
                }
              ],
              "conditions": [
                {
                  "condition": "minecraft:killed_by_player",
                  "inverse": true
                }
              ]
            }
          ]
        },
        {
          "rolls": 1,
          "entries": [
            {
              "type": "minecraft:item",
              "name": "minecraft:phantom_membrane",
              "functions": [
                {
                  "function": "minecraft:set_count",
                  "count": 10.0,
                  "add": true,
                  "conditions": [
                    {
                      "condition": "minecraft:entity_properties",
                      "entity": "this",
                      "predicate": {
                        "nbt": "{Size:20}"
                      }
                    }
                  ]
                }
              ]
            }
          ],
          "conditions": [
            {
              "condition": "minecraft:killed_by_player",
              "inverse": true
            }
          ]
        }
      ]
    }
    



  • Edit, I was just being stupid. As you can see, the final "killed by player check" is outside the final pool's "function" brackets.

    The final and working loot table is successfully able to drop specific loot based on nbt data just as I had hoped and is listed below:

    {
      "type": "minecraft:entity",
      "pools": [
        {
          "rolls": 1,
          "bonus_rolls": 0,
          "entries": [
            {
              "type": "minecraft:item",
              "name": "minecraft:phantom_membrane",
              "functions": [
                {
                  "function": "minecraft:set_count",
                  "count": {
                    "type": "minecraft:uniform",
                    "min": 0,
                    "max": 1
                  },
                  "add": false
                },
                {
                  "function": "minecraft:looting_enchant",
                  "count": {
                    "type": "minecraft:uniform",
                    "min": 0,
                    "max": 1
                  }
                }
              ]
            }
          ],
          "conditions": [
            {
              "condition": "minecraft:killed_by_player"
            }
          ]
        },
        {
          "rolls": 1,
          "entries": [
            {
              "type": "minecraft:item",
              "name": "minecraft:phantom_membrane",
              "functions": [
                {
                  "function": "minecraft:set_count",
                  "count": 0,
                  "add": false,
                  "conditions": [
                    {
                      "condition": "minecraft:entity_properties",
                      "entity": "this",
                      "predicate": {
                        "nbt": "{Size:0}"
                      }
                    }
                  ]
                },
                {
                  "function": "minecraft:set_count",
                  "count": 2,
                  "add": false,
                  "conditions": [
                    {
                      "condition": "minecraft:entity_properties",
                      "entity": "this",
                      "predicate": {
                        "nbt": "{Size:3}"
                      }
                    }
                  ]
                },
                {
                  "function": "minecraft:set_count",
                  "count": 4,
                  "add": false,
                  "conditions": [
                    {
                      "condition": "minecraft:entity_properties",
                      "entity": "this",
                      "predicate": {
                        "nbt": "{Size:5}"
                      }
                    }
                  ]
                },
                {
                  "function": "minecraft:set_count",
                  "count": 6,
                  "add": false,
                  "conditions": [
                    {
                      "condition": "minecraft:entity_properties",
                      "entity": "this",
                      "predicate": {
                        "nbt": "{Size:7}"
                      }
                    }
                  ]
                },
                {
                  "function": "minecraft:set_count",
                  "count": 10,
                  "add": false,
                  "conditions": [
                    {
                      "condition": "minecraft:entity_properties",
                      "entity": "this",
                      "predicate": {
                        "nbt": "{Size:20}"
                      }
                    }
                  ]
                }
              ],
              "conditions": [
                {
                  "condition": "minecraft:killed_by_player"
                }
              ]
            }
          ]
        }
      ]
    }
    




Suggested Topics

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