#Random ticks don't appear to be running on my falling blocks.

33 messages · Page 1 of 1 (latest)

upper charm
#
    // Define the properties for the falling clay block
    event.create('ulszsurvival:falling_dirt',"falling")
    .material('dirt')
    .soundType(SoundType.ROOTED_DIRT)
    .hardness(0.7)
    .resistance(0.6)
    .textureAll('minecraft:block/coarse_dirt')
    .tagBoth("minecraft:mineable/shovel")
    .tagBoth("artifacts:mineable/digging_claws")
    .tagBoth("minecraft:sculk_replaceable_world_gen")
    .tagBoth("minecraft:sculk_replaceable")
    .tagBoth("minecraft:axolotls_spawnable_on")
    .tagBoth("alexsmobs:seal_digables")
    .tagBoth("alexsmobs:crocodile_spawns")
    .tagBoth("minecraft:lush_ground_replaceable")
    .tagBoth("alexsmobs:platypus_spawns")
    .tagBoth("alexsmobs:fly_spawns")
    .tagBoth("alexsmobs:roadrunner_spawns")
    .tagBoth("alexsmobs:komodo_dragon_spawns")
    .tagBoth("alexsmobs:lobster_spawns")
    .tagBoth("alexsmobs:emu_spawns")
    .tagBoth("alexsmobs:mimic_octopus_spawns")
    .tagBoth("alexsmobs:alligator_snapping_turtle_spawns")
    .tagBoth("alexsmobs:mungus_replace_mushroom")
    .tagBoth("alexsmobs:leafcutter_pupa_usable_on")
    .tagBoth("forge:dirt")
    .tagBoth("alexsmobs:am_spawns")
    .tagBoth("artifacts:mineable/digging_claws")
    .tagBoth("minecraft:azalea_grows_on")
    .tagBoth("alexsmobs:kangaroo_spawns")
    .tagBoth("minecraft:dead_bush_may_place_on")
    .tagBoth("minecraft:convertable_to_mud")
    .tagBoth("minecraft:moss_replaceable")
    .tagBoth("minecraft:nether_carver_replaceables")
    .tagBoth("minecraft:enderman_holdable")
    .tagBoth("minecraft:bamboo_plantable_on")
    .tagBoth("immersive_weathering:sand_cave_floor")
    .tagBoth("minecraft:overworld_carver_replaceables")
    .tagBoth("minecraft:azalea_root_replaceable")
    .tagBoth("alexsmobs:seal_spawns")
    .tagBoth("minecraft:sculk_replaceable")
    .tagBoth("minecraft:dirt")
    .tagBoth("alexsmobs:anaconda_spawns")
    .tagBoth("minecraft:sculk_replaceable_world_gen")
    .tagBoth("alexsmobs:rattlesnake_spawns")
    .tagBoth("minecraft:mineable/shovel")
    .tagBoth("minecraft:big_dripleaf_placeable")
    .randomTick(tick =>{
      if (tick.block.down.id == "minecraft:air" || tick.block.down.id == "minecraft:cave_air"){
        //this is kinda a dumb way to do it :P
      }
      else {
          tick.block.set("minecraft:dirt")
          console.info("Running random tick on dirt, its dirt now")
      }
    })

I want my falling dirt to become normal dirt when its on the ground.
Anyway to accomplish what i want without using random ticks since random ticks don't seem to run on falling blocks.

chrome minnowBOT
#

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

upper charm
#

Or maybe it is running and i just cant see logs???

upper charm
#

Tried doing it in modification but turns out that is 1.20 kubejs 😦

#
    event.modify('ulszsurvival:falling_dirt', block => {
      block.setIsRandomlyTicking(true)
      block.setRandomTickCallback(tick =>{
        if (tick.block.down.id == "minecraft:air" || tick.block.down.id == "minecraft:cave_air"){
          //this is kinda a dumb way to do it :P
        }
        else {
            tick.block.set("minecraft:obsidian")
            console.info("Running random tick on dirt, its dirt now")
        }
      })
    })
upper charm
#

One other possibility would be that I could instead track the falling block entity that is associated than switch the block when it lands, if anyone can do that heh,

upper charm
#

Okay!

#

SO i tried something different, i tried to see if i couldf us eteh entity leave event to modify the block

#

Eg when the entity lands

#

However, there is an issue

#

It crashes with a concurrent modifcation event eventually

#

Seems to always do it on an air block

#

Unclear why

#

ForgeEvents.onEvent("net.minecraftforge.event.entity.EntityLeaveLevelEvent", e =>{
    if (e.entity.entityType == "entity.minecraft.falling_block"){
        //e.level.setBlockAndUpdate(e. Blocks.OBSIDIAN.defaultBlockState())
        console.info("I am a falling block")
        let newEntity = e.getEntity()
        console.info(newEntity.UUID)
        console.info(newEntity.x)
        console.info(newEntity.y)
        console.info(newEntity.z)
        let newLevel = e.getLevel()
        let pos = new BlockPos(newEntity.x,newEntity.y,newEntity.z)
        console.info(newLevel.getBlockState(pos))
    }
})
#

Air is most certainly not a falling block

#

lol

#

Weird thing is

#

im not modifying anything

#

so

#

why youc rash with concurrent modifcation when im just readonlying this

#

It runs forever if i dont do anything useful (like actually trying to get a block id or something heh)

upper charm
#

this sorta worked

#
ForgeEvents.onEvent("net.minecraftforge.event.entity.EntityLeaveLevelEvent", e =>{
    if (e.entity.entityType == "entity.minecraft.falling_block"){
        //e.level.setBlockAndUpdate(e. Blocks.OBSIDIAN.defaultBlockState())
        let newEntity = e.getEntity()
        let newLevel = e.getLevel()
        let pos = new BlockPos(newEntity.x,newEntity.y,newEntity.z)
        console.info(pos)
        // Schedule the block change for the next tick
        newLevel.server.scheduleInTicks(1, _ => {
            newLevel.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState())
        })
    }
})
#

the block entity kinda stays there and glitches out 😛

#
ForgeEvents.onEvent("net.minecraftforge.event.entity.EntityLeaveLevelEvent", e =>{
    if (e.entity.entityType == "entity.minecraft.falling_block"){
        //e.level.setBlockAndUpdate(e. Blocks.OBSIDIAN.defaultBlockState())
        let newEntity = e.getEntity()
        let newLevel = e.getLevel()
        let pos = new BlockPos(newEntity.x,newEntity.y,newEntity.z)
        console.info(pos)
        // Schedule the block change for the next tick
        if (newLevel.server){
            newLevel.server.scheduleInTicks(1, _ => {
                newLevel.setBlockAndUpdate(pos, Blocks.OBSIDIAN.defaultBlockState())
            })
        }

    }
})
#

this does exactly what i need it to do

#

now i just need to check a coupel things and set them to the right types of blocks and i can put it in exampel scripts as it being totally cursed

#

😄

#

final script for my purposes, there is a minor issue, if it never gets a chance to turn into sa falling block (eg placed direct on ground) then it doesnt switch, but that can be handled in a place event.

#
let fallingToPlaced = {
    "ulszsurvival:falling_dirt":"minecraft:dirt",
    "ulszsurvival:falling_clay":"minecraft:clay",
}
ForgeEvents.onEvent("net.minecraftforge.event.entity.EntityLeaveLevelEvent", e =>{
    if (e.entity.entityType == "entity.minecraft.falling_block"){
        //e.level.setBlockAndUpdate(e. Blocks.OBSIDIAN.defaultBlockState())
        let newEntity = e.getEntity()
        let newLevel = e.getLevel()
        let pos = new BlockPos(newEntity.x,newEntity.y,newEntity.z)
        console.info(pos)
        // Schedule the block change for the next tick
        if (!newLevel.isClientSide()){
            newLevel.server.scheduleInTicks(1, _ => {
                let newBlock = Block.getBlock(fallingToPlaced[newLevel.getBlock(pos).id]).defaultBlockState();
                newLevel.setBlockAndUpdate(pos,newBlock)
            })
        }

    }
})