#how to waterlogged in custom block by using custom components

1 messages · Page 1 of 1 (latest)

coral heart
#

When the player interacts with the custom leave with the water bucket item and it becomes waterlogged and solid like vanilla leaves. And how do I do that?

final tartan
#

@azure fern Sorry for ping you did make a custom block that can be waterlogged right?

azure fern
#

Yea

azure fern
magic crow
#

I wonder what else you could cheese with structure files

azure fern
azure fern
#

This is the waterlogging logic I made:

// Check if the selected item is a water bucket and the block is not waterlogged or double
            if (selectedItem?.typeId === 'minecraft:water_bucket' && !block.permutation.getState('kai:waterlogged') && !block.permutation.getState('kai:double')) {
                // Play sound effect
                player.playSound('bucket.empty_water');
                // If not in creative mode, replace water bucket with empty bucket
                if (player.getGameMode() !== "creative") {
                    equipment.setEquipment('Mainhand', new ItemStack('minecraft:bucket', 1));
                }
                // Set block to waterlogged and place corresponding structure
                block.setPermutation(block.permutation.withState('kai:waterlogged', true));
                const verticalHalf = block.permutation.getState('minecraft:vertical_half');
                // Split the block identifier and use only the part after the colon
                const slabType = block.typeId.split(':')[1];
                // These structures contains your slab waterlogged, made with an NBT editor
                const structureName = (verticalHalf === 'bottom') ? `mystructure:${slabType}_bottomSlab` : `mystructure:${slabType}_topSlab`;
                const { x, y, z } = block;
                world.structureManager.place(structureName, e.dimension, { x, y, z });
            }
magic crow
#

That's going to make my life so much easier

azure fern
#

Yeah

magic crow
azure fern
#

Probably

magic crow
#

Nice

coral heart
#

I mean simple way like . iswaterlogged = true, like that

azure fern
#

No that's not how it works

final tartan
coral heart
#

Well

slate coral
azure fern
#

Did you changed the identifier?

#

Of the slab without touching the mcstructure file or vice-versa?

slate coral
#

I opened the mcstructure and changed the block id to my custom blocks' ids.

slate coral
#

?

azure fern
azure fern
slate coral
#

The bottom two.

azure fern
slate coral
#

Larger text:

slate coral
#

Looking at this make me realize I need to remove "const verticalHalf = block.permutation.getState('minecraft:vertical_half');"

uneven kelpBOT
#
Please, no screenshots or photos!

Screenshots are hard to read, and photos even more so. This is especially true if you are using bridge or another tree editor, as this format obscures the JSON format.

We can help you best if you copy and paste your code here, or send it directly as a file.

slate coral
azure fern
# slate coral

You don't need .mystructure file extension but mystructure: namespace

slate coral
#

is "mystructure:" replaceable with my own namespace?

limber geyser
#

you'll get a namespace error

slate coral
#

It works! Thank you so much!

azure fern
#

No problem 👍

raw gull
#

@azure fern how to change ID

slate coral