Skip to content

Instantly share code, notes, and snippets.

@codetaylor
Created July 18, 2019 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codetaylor/d9dbc36a3eb06a6e57fbb52ab176600c to your computer and use it in GitHub Desktop.
Save codetaylor/d9dbc36a3eb06a6e57fbb52ab176600c to your computer and use it in GitHub Desktop.

Goal: Replace any Redstone drops with the same number of Dirt.

ZenScript

import mods.dropt.Dropt;

Dropt.list("list_name")

  .add(Dropt.rule()
      .matchDrops([<minecraft:redstone>])
      .addDrop(Dropt.drop()
          .items([<minecraft:dirt>])
          .matchQuantity([<minecraft:redstone>])
      )
  );

JSON

{
  "rules": [
    {
      "match": {
        "drops": {
          "drops": [
            "minecraft:redstone"
          ]
        }
      },
      "drops": [
        {
          "item": {
            "items": [
              "minecraft:dirt"
            ],
            "matchQuantity": {
              "drops": [
                "minecraft:redstone"
              ]
            }
          }
        }
      ]
    }
  ]
}

DroptAPI

@SubscribeEvent
public void on(DroptLoadRulesEvent event) {

  List<IDroptRuleBuilder> list = new ArrayList<>();

  list.add(DroptAPI.rule()
      .matchDrops(new String[]{
          "minecraft:redstone"
      })
      .addDrops(new IDroptDropBuilder[]{
          DroptAPI.drop()
              .items(new String[] {
                  "minecraft:dirt"
              })
              .matchQuantity(new String[] {
                  "minecraft:redstone"
              })
      })
  );

  ResourceLocation resourceLocation = new ResourceLocation("my_mod_id", "rule_list_name");
  int priority = 0;
  DroptAPI.registerRuleList(resourceLocation, priority, list);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment