Jump to content

[1.14.4] Comparing numerical BlockState conditions in loot tables


Xander402

Recommended Posts

Is it possible to write a loot table pool condition that will drop when a certain data value in BlockState is greater than a number? Look at this. All of these pools only differ with one digit (in the "age" parameter) :

    {
      "rolls": 1.0,
      "entries": [
        {
          "type": "minecraft:alternatives",
          "children": [
            {
              "type": "minecraft:item",
              "conditions": [
                {
                  "condition": "minecraft:block_state_property",
                  "block": "mod:avocado_tree",
                  "properties": {
                    "age": "2"
                  }
                }
              ],
              "functions": [
                {
                  "function": "minecraft:set_count",
                  "count": 2
                },
                {
                  "function": "minecraft:explosion_decay"
                }
              ],
              "name": "mod:avocado_seed"
            },
            {
              "type": "minecraft:item",
              "conditions": [
                {
                  "condition": "minecraft:block_state_property",
                  "block": "mod:avocado_tree",
                  "properties": {
                    "age": "3"
                  }
                }
              ],
              "functions": [
                {
                  "function": "minecraft:set_count",
                  "count": 2
                },
                {
                  "function": "minecraft:explosion_decay"
                }
              ],
              "name": "mod:avocado_seed"
            },
            {
              "type": "minecraft:item",
              "conditions": [
                {
                  "condition": "minecraft:block_state_property",
                  "block": "mod:avocado_tree",
                  "properties": {
                    "age": "4"
                  }
                }
              ],
              "functions": [
                {
                  "function": "minecraft:set_count",
                  "count": 2
                },
                {
                  "function": "minecraft:explosion_decay"
                }
              ],
              "name": "mod:avocado_seed"
            },
            {
              "type": "minecraft:item",
              "conditions": [
                {
                  "condition": "minecraft:block_state_property",
                  "block": "mod:avocado_tree",
                  "properties": {
                    "age": "5"
                  }
                }
              ],
              "functions": [
                {
                  "function": "minecraft:set_count",
                  "count": 2
                },
                {
                  "function": "minecraft:explosion_decay"
                }
              ],
              "name": "mod:avocado_seed"
            }
          ]
        }
      ]
    }

Is there a way to make it simpler? Something like this:

            {
              "type": "minecraft:item",
              "conditions": [
                {
                  "condition": "minecraft:block_state_property",
                  "block": "mod:avocado_tree",
                  "properties": {
                    "age": "(from 2 to 5)"
                  }
                }
              ],
              "functions": [
                {
                  "function": "minecraft:set_count",
                  "count": 2
                },
                {
                  "function": "minecraft:explosion_decay"
                }
              ],
              "name": "mod:avocado_seed"
            }

 

Edited by Xander402

A few bytes about me:

public class Xander402 extends Modder implements IForumMember {
    int javaExperience, moddingExperience;
    LearningWay preferredLearningWay;
    public Xander402() {
        this.javaExperience = BIG;
        this.moddingExperience = NOT_SO_BIG;
        this.preferredLearningWay = LearningWay.through("exampes");
      	super(/*displayName*/"Xander402", /*moddingSince*/"1.9", preferredLearningWay);
    }
    @Override
    public Goal getReasonOfJoining(Forum forum) { return new Goal(() -> { while (true) moddingExperience++; }); }
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.