#Custom oxidizing blocks
103 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
you can try using random tick
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')
}
})
})
Interesting, this is server events, right?
block registry -> all startup script
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?
yes but blocks can be triggered by random tick like crops
you can see on wiki that there are many more example that can be modified to make what you want
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?
probably
i dont think due there are only blocks not tile entity blocks
It would cause lag If you placed millions or tens of millions or more
True, but still its gonna update every r.tick?
On a Random tick
So one every now and then
Rookie numbers
Okay then I don't really care and just do r.tick, good to know
Maybe IT won't even cause lag, I'm Not Sure abotu the specifics of how it works
Me neither, I don't know how expensive is random tick
Seems like vanilla copper does not lag that much so
I don't really understand how this supposed to work, and it doesn't work
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?
logs?
you can change the id , its like a setblock so you could do like second example where it will replaced with minecraft:stone
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
ok i have understand mh..
or just override -> idk if work as same like modification event so i will try and send you the code
Paste version of script.js from @raven tendon
only thing that you need was using same id and it work as same
*test script on a istance with only kubejs overriding a vanilla block
I'll test that later with custom blocks shouldn't be different in theory, thanks in advance
also if can be useful , to detect blocks around like how work vanilla copper block you can use tick.level.getBlock(x, y ,z) (i dont remember if it change on 1.18)
it change block if block on top is granitejs onEvent('block.registry', event => { event.create('minecraft:stone').randomTick(tick => { if(tick.level.getBlock(tick.block.x,tick.block.y+1,tick.block.z) == 'minecraft:granite') return tick.block.set('minecraft:dirt') }) })
Ugh it won't even start up, it yields "Invalid vanilla replacement"
Yeah, because you're Re registering a already existing/ Vanilla block
very strange , it work on my test.. , can you share logs?
Yeah it won't let override vanilla blocks at all
Same with blocks from other mods
Won't happen
So is it possible to modify existing blocks or not?
logs? (it's strange due it work , idk if other mods could make other stuff)
Paste version of latest.log from @silent pike
[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
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
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
code?
Paste version of message.txt from @silent pike
If line 29 is executed, shouldn't it just terminate all below?
try to add event.hand == 'MAIN_HAND' on all if , maybe it was caused by double click of offhand
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?
same with if (event.player.hand == 'OFF_HAND') return; ? (ik that can fix as same but to try all possible way)
You mean if (event.player.hand != 'OFF_HAND'), right?
without player.hand filter , it could use all hands
Even if off hand does not have required item?
yes [it cause on a my script many issue]
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
you will try making another event where you switch if condition
or just something of more dynamic
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
maybe ^ ?
np
Oh yeah that works! Thanks!