Snownee / Lychee

Minecraft data-driven in-world crafting mod.
https://www.curseforge.com/minecraft/mc-mods/lychee
28 stars 3 forks source link

[Suggestion] Add "repeat" post action #24

Closed juh9870 closed 2 years ago

juh9870 commented 2 years ago

Mod loader

Forge

Minecraft version

-

Mod version

-

Modloader version

-

Modpack info

No response

If bug:

If bug: The latest.log file

No response

Issue description

Please add "repeat" post action, aka the one that triggers its child multiple times. My use case is that Iw as trying to make a recipe that, upon item explosion, makes 9 rolls, each of them having 50% chance to give you an item. So you can end up with 0 or with 9, but most of the time you will get 4 or 5. I was able to replicate behavior using random node, but it required one recipe for an actual behavior, and anoher one for JEI, because behavior one was showing misleading and confusing info

Snownee commented 2 years ago

My use case is that Iw as trying to make a recipe that, upon item explosion, makes 9 rolls, each of them having 50% chance to give you an item. So you can end up with 0 or with 9, but most of the time you will get 4 or 5.

This is exactly the current behavior of "drop_item"

juh9870 commented 2 years ago

Can you please provide an example? If I try to add a contextual chance condition to drop item post action, it either drops all items or none at all. I'm on 1.18.2

Snownee commented 2 years ago
{
  "type": "drop_item",
  "item": "cod",
  "count": 5,
  "contextual": {
    "type": "chance",
    "chance": 0.5
  }
}
juh9870 commented 2 years ago

This doesn't work. I tried making this

onEvent("recipes", (event) => {
  event.custom({
    type: "lychee:item_exploding",
    item_in: Item.of('minecraft:stone').toJson(),
    post: [{
      "type": "drop_item",
      "item": "cobblestone",
      "count": 64,
      "contextual": {
        "type": "chance",
        "chance": 0.5
      }
    }]
  })
});

And it either drops 64 or drops 0, nothing in between, while I want it to roll that chance for every item in a count, so I would get an average of 32 in this case

juh9870 commented 2 years ago

So I have to resort to this script to make items drop roll chance for every item. It makes one ghost recipe for user info, and ugly actual recipe for mechanics. https://pastebin.com/AHsawsrk

Snownee commented 2 years ago

that example only works if the recipe can be repeated for more than one time. I can add range support for the "count" property if you want

juh9870 commented 2 years ago

That would be great too, but not quite my use case. I just want something like random node, but accepting only one argument and repeating post action N times. Maybe just allowrandom node to accept a single argument to allow it to function like repeat

juh9870 commented 2 years ago

So something like this

  event.custom({
    type: "lychee:item_exploding",
    item_in: Item.of("minecraft:stone").toJson(),
    post: [
      {
        type: "random",
        rolls: 64,
        entries: [
          {
            type: "drop_item",
            item: "cobblestone",
            count: 1,
            contextual: {
              type: "chance",
              chance: 0.5,
            },
          }
        ],
      },
    ],
  });

Because right now I have to write either what I shown in my previous message above, or do this


  event.custom({
    type: "lychee:item_exploding",
    item_in: Item.of("minecraft:stone").toJson(),
    post: [
      {
        type: "random",
        rolls: 64,
        entries: [
          {
            type: "drop_item",
            item: "cobblestone",
            count: 1,
            contextual: {
              type: "chance",
              chance: 0.5,
            },
          },
          {
            type: "drop_item",
            item: "cobblestone",
            count: 1,
            contextual: {
              type: "chance",
              chance: 0.5,
            },
          },
        ],
      },
    ],
  });

and having quite confusing JEI recipe info image

Snownee commented 2 years ago

implemented in 2.2.8