#Randomize Items

1 messages · Page 1 of 1 (latest)

night stump
#

i want to make a script for 1.20.1 just for fun and was wondering if its possible to make a script that randomizes block drops but keeps the same drop if you break the same block but is difenent on difrent seeds if that makes any sence

hidden kestrelBOT
#

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

night stump
#

i wanted to do it myself so that modded items will function with it

#

i forgot to tag this with addon related

tardy mural
#
ServerEvents.loaded(event => {
  let pData = event.server.persistentData
  if(!pData.blockDrops){
    pData.blockDrops = {}
    let itemBlacklist = ["minecraft:bedrock", ...]
    let items = Ingredient.all.itemIds.filter(el => !itemBlacklist.includes(el))
    Ingredient.all.stacks.forEach(item => {
      if(!item.isBlock()) continue
      let randomIndex = Math.floor(Math.random() * items.length)
      pData.blockDrops[item.id] = items[randomIndex]
      items.splice(randomIndex, 1)
    })
  }
})

LootJS.modifiers((event) => {
  let pData = event.server.persistentData
  for(let [block, drop] of Object.entries(pData.blockDrops)){
    event
      .addBlockLootModifier(block)
      .removeLoot(Ingredient.all)
      .addLoot(drop)
  }
});
#

This won't work for Fortune and silktouch, but it should randomize the drops

#

Make Sure to extend the list of black listed items

night stump
#

okay thanks ill that

night stump
#

i didnt work and i have tried to get it to but i cant get it to work

night stump
#

then after i fix a bunch of errors
let randomIndex = Math.floor(Math.random() * items.length)
is invalid