#how can i make a script that acts like oneblock skyblock

20 messages · Page 1 of 1 (latest)

novel hazel
#

how can i make a script that acts like oneblock skyblock but adding all the mod items

keen daggerBOT
#

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

novel hazel
#

yes of

#

You place the block kubejs:one_block. (exemple)

When broken, it should:
Drop the broken block.

Replace itself with a new random block.

This repeats infinitely.

split notch
#

BlockEvents.broken + check block position?

grim zephyr
# novel hazel You place the block kubejs:one_block. (exemple) When broken, it should: Drop th...
const $RegistryAccessContainer = Java.loadClass("dev.latvian.mods.kubejs.util.RegistryAccessContainer")
const $Registries = Java.loadClass("net.minecraft.core.registries.Registries")
const allBlocks = $RegistryAccessContainer.of().access().lookupOrThrow($Registries.BLOCK).listElementIds().map(rk => Block.getBlock(rk.location())).toArray()

const startingBlockPos = new BlockPos(8, 63, 8)
LevelEvents.tick("minecraft:overworld", event => {
    const {level} = event
    const block = level.getBlock(startingBlockPos)
    if(block.blockState.air){
        block.set("dirt")
    }
})

const maxTry = 100
BlockEvents.broken(event => {
    const {block, block:{pos, blockState}, server, level, player, player:{mainHandItem}} = event
    if(!pos.equals(startingBlockPos)) return;
    const toDrop = player.hasCorrectToolForDrops(blockState, level, pos)
    const drops = toDrop ? block.getDrops(player, mainHandItem) : []
    const xpDrops = block.blockState.getExpDrop(level, pos, block.entity, player, mainHandItem)
    if(toDrop) block.createEntity("experience_orb").mergeNbt({Value: xpDrops}).spawn()

    drops.forEach(item => block.popItemFromFace(item, "up"))
    const random = Utils.newRandom(Utils.getSystemTime() - server.worldData.worldGenOptions().seed() + player.tickCount)
    function trySetBlock(){
        const nextBlock = allBlocks[random.nextInt(allBlocks.length)]
        block.set(nextBlock)
        if(!block.blockState.canSurvive(level, pos)) return false
        let blockSize = block.blockState.getCollisionShape(level, pos).toAabbs()[0]?.size || 0
        if(blockSize != 1) return false;
        return true    
    }
    let goodBlock = false
    for(let i = 0; i < maxTry; i ++){
        goodBlock = trySetBlock()
        if(goodBlock) break
    }
    if(!goodBlock) block.set("dirt")

    event.cancel()
})
#

This is just an example to start

#

You'd need to add some more stage-control or sth like that to make it a really playable thing

grim zephyr
novel hazel
grim zephyr
#

what do you mean start using it

novel hazel
# grim zephyr what do you mean `start using it`

I’ll try to explain:

So I’m using an empty world, where I want to start only with this block and it randomly generates several blocks of all installed mods.

This script you sent how I know if it’s working

grim zephyr
#

You tried breaking that block?

novel hazel
#

Lol… yes it’s working I’m só dumb
I was breaking the wrong block....

novel hazel
grim zephyr
# novel hazel How i can add a black list?

change the line 3 into const allBlocks = $RegistryAccessContainer.of().access().lookupOrThrow($Registries.BLOCK).listElementIds().map(rk => Block.getBlock(rk.location())).filter(block => !block.hasTag("kubejs:one_block_black_list")).toArray()

#

And you can add the tag "kubejs:one_block_black_list" to blocks

novel hazel
#

guys im geting a memory leak
[13Jun2025 22:44:42.299] [Render thread/INFO][com.mojang.blaze3d.platform.GlDebug/]: OpenGL debug message: id=1282, source=API, type=ERROR, severity=HIGH, message='GL_INVALID_OPERATION error generated. Depth formats do not match.'

how i can solve this?