#Custom oxidizing blocks

103 messages · Page 1 of 1 (latest)

silent pike
#

Is it possible to make natural weathering like copper blocks do, for other blocks using kubejs?

upper cliffBOT
#

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

raven tendon
#

like that```js
onEvent('block.registry', event => {

//create a block with randomTick so every random tick will update all code inside of .randomTick

event.create('test_block_oxide').randomTick(tick => {

        //condition to reduce the chance
    if (Math.floor(Math.random() * 10) == 1) { 
        
        //set the block with another one
        tick.block.set('kubejs:test_block_weathered_oxide')
    }

})

//you can make more blocks like vanilla copper blocks

event.create('test_block_weathered_oxide').randomTick(tick => {
    if (Math.floor(Math.random() * 10) == 1) {
        tick.block.set('minecraft:stone')
    }

})

})

silent pike
#

Interesting, this is server events, right?

raven tendon
silent pike
#

Yeah no, that's not what I mean. How do you check conditions, and more over, how do you change block state?

#

Startup script executed single time during initial launch, isn't it?

raven tendon
raven tendon
silent pike
#

Okay, I see what you mean now

#

One more though

#

Is vanilla copper random tick based?

#

Wouldn't it cause lots of lag if loaded tons of it?

raven tendon
raven tendon
slow heron
#

It would cause lag If you placed millions or tens of millions or more

silent pike
#

True, but still its gonna update every r.tick?

slow heron
#

So one every now and then

silent pike
#

Okay then I don't really care and just do r.tick, good to know

slow heron
#

Maybe IT won't even cause lag, I'm Not Sure abotu the specifics of how it works

silent pike
#

Me neither, I don't know how expensive is random tick

#

Seems like vanilla copper does not lag that much so

silent pike
#

I see that you add new block, ass well as condition and replacement

#

But how is that detecting the block in the first place

#

Or should I say, do I need to create new (weathered versions) of blocks? What if I already have them?

raven tendon
silent pike
#

I see, same as in the first one

#

But you create new block with ability to age

#

If I understand this correctly, the method is

create block A
if condition, replace block A with block B

#

This is simple

#

But

#

I have block A already in the game

#

That comes from another mod

#

I.e. bronze block

#

I'm assuming I'd have to make my own bronze block

raven tendon
raven tendon
silent pike
#

Yeah I was about to ask if e.modify can work like that

#

Can't test it rn

raven tendon
#

ok yes , it can override blocks

neon furnaceBOT
#

Paste version of script.js from @raven tendon

raven tendon
#

only thing that you need was using same id and it work as same

raven tendon
silent pike
#

I'll test that later with custom blocks shouldn't be different in theory, thanks in advance

raven tendon
raven tendon
silent pike
slow heron
#

Yeah, because you're Re registering a already existing/ Vanilla block

raven tendon
silent pike
#

Yeah it won't let override vanilla blocks at all

#

Same with blocks from other mods

#

Won't happen

silent pike
raven tendon
silent pike
neon furnaceBOT
#

Paste version of latest.log from @silent pike

raven tendon
#

[22Feb2024 20:24:05.683] [Render thread/ERROR] [net.minecraftforge.registries.GameData/REGISTRIES]: Registry replacements for vanilla block 'minecraft:stone' must not change the number or order of blockstates.
mh.. startup script that you have used?

#

ok found out why it dont work : overriding a block with new blockstate properties dont work

#

probably you will try without using blockstates

silent pike
#

Well for now I guess I'll have to work with custom bronze blocks, which is a shame but still something. Just have to figure how to prevent oxidation using wax

#

Not entirely sure how to keep track if block was clicked with wax

#

Well, actually, nvm in vanilla it's actually a new set of blocks

#

Waxed and non waxed

#

So I could just replace it again with other block if clicked

#

That is solved

#

Still, I'd really love to be able to age, for example, sheet metals from IE

#

I'll continue tinkering with stuff, but let me know if you find something too

silent pike
#

Okay I'm now having issue making a cooldown when waxing off a block, for example when right clicking a waxed, fully oxidized block it removes wax and oxide simultaneously

#

I can't make firstRightClicked check to get working

silent pike
#

One sec

neon furnaceBOT
#

Paste version of message.txt from @silent pike

silent pike
#

If line 29 is executed, shouldn't it just terminate all below?

raven tendon
# silent pike

try to add event.hand == 'MAIN_HAND' on all if , maybe it was caused by double click of offhand

silent pike
#

Tried that too, it's better but it skips like 2 steps

#

Like, r.click on waxed oxidized block makes it dewaxed weathered block

#

It does 2 steps at once yeah

#

Also, off hand is empty, and doesn't satisfy event.player.mainHandItem == "minecraft:honeycomb"

#

Or is it?

raven tendon
silent pike
#

You mean if (event.player.hand != 'OFF_HAND'), right?

raven tendon
silent pike
raven tendon
silent pike
#

Yep, tried if (event.player.hand != 'OFF_HAND') and it works now smh

#

But now I can't use off hand to wax it off lmao

raven tendon
#

or just something of more dynamic

silent pike
#

I feel like it's possible to fix with xor but I can't find that op in js

#

Is that a thing even?

#

To me it still confusing why it shoul matter in the first place, when I specifically check if it's right clicked with item, not just empty hand

#

Alright, thanks regardless, that's really helpful

silent pike