#how to waterlogged in custom block by using custom components
1 messages · Page 1 of 1 (latest)
I'm not really sure cause when you try to waterlogged a custom block it throws an error....
@azure fern Sorry for ping you did make a custom block that can be waterlogged right?
Yea
You have to place a waterlogged vanilla block and save it in a structure. Then replace the ID of the vanilla block with the ID of your custom leaves.
After that, you’ll just detect when a player interacts with your block using a water bucket, and load the structure, change the item to a bucket and play the water sound
This actually works?
I wonder what else you could cheese with structure files
Yeah it works, is what I made for my slab template, feel free to try it out https://github.com/Kaioga5/Kaioga-s-Block-Templates/tree/main/templates/1.20.80/slab
Awesome I will
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 });
}
Can you really just do id:${string}?
That's going to make my life so much easier
Yeah
Can it search tables when plugged in like that?
Probably
Nice
I mean simple way like . iswaterlogged = true, like that
No that's not how it works
Only works on vanilla blocks not custom sadly....
Well
I tried this template and my addon is complaining that the waterlogged block .mcstructures don't have a namespace. Is there any current fix?
Did you changed the identifier?
Of the slab without touching the mcstructure file or vice-versa?
I opened the mcstructure and changed the block id to my custom blocks' ids.
?
Don't fish for answers in other channels please
What error did you received?
The bottom two.
Let’s see the script
Looking at this make me realize I need to remove "const verticalHalf = block.permutation.getState('minecraft:vertical_half');"
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.
You don't need .mystructure file extension but mystructure: namespace
is "mystructure:" replaceable with my own namespace?
no
you'll get a namespace error
It works! Thank you so much!
No problem 👍
@azure fern how to change ID
open the .mcstructure file and navigate to [structure > palette > default > block_palette] and locate your placeholder waterlogged block and change the id to the id of your custom block.