#change default create water wheel skin

1 messages · Page 1 of 1 (latest)

tall peak
#

create's water wheel and large water wheel both can change what wood type is used for their textures by right clicking a plank onto them, and they both default to spruce. i am making a modpack set in the nether, so i wish to change the type that placed water wheels are by default to be crimson wood.
i'm guessing KubeJS has some sort of 'on block placed' event, and a water wheel's wood type is stored in its block entity's nbt data, so i figure all i'd have to do is detect when water wheels are placed and change the given nbt tag. however, i do not know how to actually go about this.
how would i go about changing the Material nbt tag, as shown in the screenshot below, in Create water wheels and large water wheels when the player/a Create deployer places them?
thanks in advance.~

warm summitBOT
#

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

gritty dustBOT
#

This is a list of all the events. Choose your version.

west willow
#
BlockEvents.placed('create:large_water_wheel', event=> {
//check if dimension is nether and nbt things
})
tall peak
#

yep yep, i actually found the event on the page the bot linked c:
do you have any examples handy of how one can change nbt in blocks?

west willow
#

you can get the dimension with event.level.minecraftLevel.dimension() if i am not wrong

#

event.item.nbt is nbt list

#

you can acces values like accesing variables in objects in js

#

you can do event.item.mergeNbt({Material:{Name:"*id here*"}})

#

it is event.item.nbt.mergr(tag) sory

tall peak
#

i see~
to clarify though, the Material nbt tag is in the block entity in the world, not the item as far as i'm aware

west willow
#

ah true

#

then it is event.block.entityData instead of event.item.nbt

#

you can use merge() method on the block entity data

tall peak
#

ah, okay~
so i created this script:```js
BlockEvents.placed('create:large_water_wheel', event => {
if (event.level.minecraftLevel.dimension() == "minecraft:the_nether") {
event.block.entityData.merge({Material:{Name:"minecraft:crimson_planks"}})
}
})

when i place a large water wheel, however, i get this error in `logs/kubejs/server.txt`:
`[14:32:03] [ERROR] ! #67: Error occurred while handling event 'BlockEvents.placed': TypeError: Cannot call method "dimension" of undefined (server_scripts:input_replacement.js#67)`
west willow
#

it says minecraftLevel is undefined hmm

#

i am launching my game rn

#

oh it is just event.level.dimension mb

glossy sierra
#

you can take a different approach to this aswell

#

you can simply make the recipes for water wheels output versions with a BlockEntityTag NBT tag that contains the NBT you want to apply when it's placed

#

though i suppose that only works the first time, as opposed to all

#

unless you do some loot shenanigans, that is

tall peak
#

yeah i was about to say, you'd have to add that nbt to the loot table as well

west willow
#

that also makes sense yes

tall peak
#

sona's approach does make the default skin dimension specific, which i like

#

i could even make them biome specific too, have say, warped be the default in warped forests

#

but first things first

#
BlockEvents.placed('create:large_water_wheel', event => {
    if (event.level.dimension == "minecraft:the_nether") {
        event.block.entityData.merge({Material:{Name:"minecraft:crimson_planks"}})
    }
})
```with this change, placed large water wheels are still spruce, and now nothing gets printed in `server.txt` about it
#

i added a console.log line immediately before the nbt changing line, and it did print to server.txt, implying that we're getting past the dimension check but not successfully modifying the nbt

west willow
#

hmm do you have probejs?

#

The event might be triggered before the placement so it there is no block to change its entity data

tall peak
west willow
#

i suggest installing it

#

i tested this event on 1.18.2 and it gave me entity data fine

tall peak
#

i see
according to this https://wiki.latvian.dev/books/kubejs-legacy/page/using-probejs, i would have to install and switch to vscode to use it, is the thing (currently using notepad++)
seems like a lot of hassle for what i'd imagine would just be confirmation that the event is getting triggered before the placement-

#

i shall try the recipe & loot table approach.~

west willow
#

hmm i can read the data correctly but cant override it

#

ahh wait a second

#

you can do block.set('block id')

tall peak
#

like this:```js
BlockEvents.placed('create:large_water_wheel', event => {
if (event.level.dimension == "minecraft:the_nether") {
block.set("minecraft:crimson_planks")
}
})

west willow
#

wait i figured out

#

block.setEntityData(block.entityData.merge({Material:{Name:"plank id here"}}))

west willow
tall peak
#

upon trying this:js BlockEvents.placed('create:large_water_wheel', event => { if (event.level.dimension == "minecraft:the_nether") { block.setEntityData(block.entityData.merge({Material: {Name: "minecraft:crimson_planks"}})) } }) it says block is not defined

#
BlockEvents.placed('create:large_water_wheel', event => {
    if (event.level.dimension == "minecraft:the_nether") {
        event.block.setEntityData(event.block.entityData.merge({Material: {Name: "minecraft:crimson_planks"}}))
    }
})
```this works!
#

the water wheel unfortunately briefly appears as the spruce textures before correcting itself, but it does turn into crimson wood~

#

i tried the recipe approach as well; it also flickers, so it seems that's just something i gotta cope with

west willow
#

const { player, block, item, hand, server, level } = event you can do that

#

instead of event.block you can use block

tall peak
#

gotcha.~

#

do you have any idea which approach would be more performant, between the recipe w/ nbt data and the script?

#

if the scripted approach doesn't have forseeable performance problems then i'll likely stick with it since i can define a different default per dimension

west willow
#

i would go with block place event

#

because with recipe thing when you break water wheel the texture disappears

tall peak
#

that's true, though that could be fixed by replacing the water wheel's loot table with one that drops water wheels with nbt

west willow
#

Ehhh complicated stuff. It can' have bugs. It is not heavy event anyway.

tall peak
#

gotcha
well anyways, this has been a success~ thank you!