Started by
TropicalPanda
on
Topic category: Help with Minecraft modding (Java Edition)
Hello, is it possible for me to make a custom block that can only be placed on solid ground, similar to carpet blocks? I didn't see anything related to this while looking through the editor, so is there any specific java code I can manually input to give my block these properties? Any help would be much appreciated!
MCreator version: 2023.3
Forge version: 1.20.1
Edited by TropicalPanda on Mon, 09/18/2023 - 19:34
Put this on update tick of your block. this will make it so it cannot be placed on anything except solid blocks underneath. Remove the liquid if you want it to be placed on that block. Also if you want to make it so it can't be placed on any block even air in any amount of y direction, you'll have to use y-1*y+random) for up and y-1*y-random like shown in second pic. Add that to any or all below for ultimate removal of your block. Hope this helps.
I forgot to mention you can also just put your material as carpet in the block gui to make it work like the carpet, but you wouldn't be able to push it or pull it with a piston then.
Thanks for the reply. Correct me if I'm wrong, but it seems like that procedure will allow the block to be placed, but immediately break it afterwards if it's not on a flat surface. I want the block to be not placeable in the air to begin with, like how right-clicking to place a carpet in midair results in no action at all.
I tried the carpet material method, but my block is still placeable in midair, unfortunately. It didn't seem to do much of anything.
it'll try to place but break immediately yes but it won't even leave anything, Their is no known way to prevent a block from being placed period unless you use code. And for that I would recommend using chatgpt and knowing how code works. Other wise, this is the best method.