Custom Block Placement - TheNuclearNexus/SmithedLibDocs GitHub Wiki
Placement works by detecting when a block entity is placed containing a specific item. The full list of supported block entities can be found here.
Setup
The item
- Pick your block entity of choice
- Give it the proper nbt, replacing
example:test
with your block’s id
{BlockEntityTag:{Items:[{id:\"minecraft:stone\",Count:1b,Slot:0b,tag:{smithed:{block:{id:\"example:block\"}}}}]}}
Handle the placement
- Create a main
handler
function, this function runs at the block that was placed. The original blocks information is preserved, thus checking its block state is possible.- Example:
@tag smithed:core/place_block
execute if storage smd:core blockApi{id:”example:test”} run function {
summon armor_stand ~ ~ ~
setblock ~ ~ ~ barrel replace
}
I recommend placing all of your block placement logic within this handler function
Troubleshooting
If a particle appears when the block is placed, that means your pack isn’t handling the original block entity properly. Setting your smd.logLevel
to atleast 1 will show you the warning message in chat.