#How to modify block's fallenOn?

12 messages · Page 1 of 1 (latest)

crystal ibex
#
BlockEvents.modification((event) => {
  event.modify("grass_block", (block) => {
    block.blockBuilder.fallenOn((event) => {
      event.entity.tell("You fell on grass block!");
      if (Math.random() < 0.25) {
        event.entity.tell("Block changed to dirt! (25% chance)");
        event.block.set("dirt")
      }
    })
  })
})
``````js
[01:19:27] [ERROR] ! index.js#12: Error in 'BlockEvents.modification': TypeError: Cannot call method "fallenOn" of null
lean oxideBOT
#

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

restive cosmos
restive cosmos
# crystal ibex ```js BlockEvents.modification((event) => { event.modify("grass_block", (block...
ForgeEvents.onEvent('net.minecraftforge.event.entity.living.LivingFallEvent', event => {
    global.blockfall(event)
})
Java.loadClass('net.minecraftforge.event.entity.living.LivingFallEvent')
/**
 * 
 * @param {Internal.LivingFallEvent} event 
 */
global.blockfall = event => {
    event.entity.tell(`You fell on ${event.entity.block.down}!`);
    if (Math.random() < 0.25) {
        event.entity.tell("Block changed to dirt! (25% chance)");
        event.entity.block.down.set("dirt")
    }
}``` ![heh](https://cdn.discordapp.com/emojis/504730156792021002.webp?size=128 "heh")
crystal ibex
restive cosmos
#

also

crystal ibex
#

so I can't modify fallenOn?

restive cosmos
#

it looks like the blockbuilder is null there on startup js BlockEvents.modification((event) => { event.modify("minecraft:grass_block", (block) => { if (block.blockBuilder == null) return block.blockBuilder.fallenOn(event => { global.blockfall(event) }) }) })

#

this doesnt result in the error

#

it looks like the functionality is all the same minecraft-code-wise

crystal ibex
#

oh~

restive cosmos
#

ye