#Technical question regarding block break events

4 messages · Page 1 of 1 (latest)

rocky pilot
#

So I am using this script:

BlockEvents.broken('minecraft:grass', event => {
  if (Math.random() < 0.05) {
    event.block.popItemFromFace(Item.of('meds_and_herbs:seedscotton'), 'up');
  }
  if (Math.random() < 0.05) {
    event.block.popItemFromFace(Item.of('minecraft:sugar_cane'), 'up');
  }
  if (Math.random() < 0.05) {
    event.block.popItemFromFace(Item.of('actuallyadditions:coffee_beans'), 'up');
  }
  if (Math.random() < 0.05) {
    event.block.popItemFromFace(Item.of('actuallyadditions:canola_seeds'), 'up');
  }
  if (Math.random() < 0.05) {
    event.block.popItemFromFace(Item.of('actuallyadditions:rice_seeds'), 'up');
  }
  if (Math.random() < 0.05) {
    event.block.popItemFromFace(Item.of('actuallyadditions:flax_seeds'), 'up');
  }
});

BlockEvents.broken('#minecraft:leaves', event => {
  if (Math.random() < 0.01) {
    event.block.popItemFromFace(Item.of('gtceu:rubber_sapling'), 'up');
  }
  if (Math.random() < 0.01) {
    event.block.popItemFromFace(Item.of('integrateddynamics:menril_sapling'), 'up');
  }
});```
The top part, for seeds and such, works just fine, but the bottom part seems to apply itself to all blocks in the game
I am suspecting this is due to it using a tag, but I wanted conformation, and also ask if anyone knows of a way to circumvent this. Currently my idea is to use a `[].forEach(type => {})` and just input all the block id's from the tag leaves in there. If anyone has a better idea, or knows why my stuff is breaking, I would gladly hear it (I also have LootJS installed, if there is a more convenient solution using that)
unique mortarBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

wintry dove
#

If it applies to all blocks that means the id provided in the event line isn’t found

#

Which is because you cannot use tags there