Topic category: Help with Minecraft modding (Java Edition)
This is direct a follow-up to topic responses here: (Link 1) https://mcreator.net/comment/265522 and here: (Link 2) https://mcreator.net/forum/108847/arrow-sound-projectile-hit. A similar issue from another user can be found here: (Link 3) https://mcreator.net/forum/77426/placereplace-block-creates-ghost-block
Basically, the place/replace (setBlock) functions do not work correctly when inside a code block that takes some dependency variable and requires a return value. For example, here is some working code (similar to my actual code) that places a ghost block instead of a real block: (Link 4) https://imgur.com/a/mcreator-code-7-28-2024-Bsw0Zh8
Some caveats with this code:
1. The block is being placed by a procedure that detects when a custom particle hits the ground. The bounding box parameters for this particle may be badly chosen. An image for the particle setup is in the same Imgur link as Link 4 (see above).
2. The block being placed has a custom model with a bounding box of x: [0, 16] y: [0, 0.25], z: [0, 16] (just like redstone dust). The full JSON is as follows:
{
"credit": "Made with Blockbench",
"textures": {
"1": "my_mod:blocks/guano_splotch",
"particle": "my_mod:blocks/guano_splotch
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 0.25, 16],
"faces": {
"north": {"uv": [0, 0, 16, 0.25], "texture": "#1"},
"east": {"uv": [0, 0, 16, 0.25], "texture": "#1"},
"south": {"uv": [0, 0, 16, 0.25], "texture": "#1"},
"west": {"uv": [0, 0, 16, 0.25], "texture": "#1"},
"up": {"uv": [0, 0, 16, 16], "texture": "#1"},
"down": {"uv": [0, 0, 16, 16], "texture": "#1"}
}
}
]
}
Aside from that, I have tried changing each y value in the code (Link 4) to be y +/- some value, but no values that I choose work. The only reason I have [y - 0.5] in there at all is because the particle's onGround boolean doesn't seem to go off until the particle is inside the ground block; if the code were instead "If [Is block at x: [x] y: [y] z: [z] solid] Do [Place <block> at x: [x] y: [y + 1] z: [z]]", the block doesn't get placed at all unless a block is placed where the particle is currently located as it is falling (or the particle is spawned inside the ground block). This code was my first attempt at this and it didn't work, hence the current code in Link 4.
My guess as to what's wrong is either the bounding box for the particle is bad, or there is a bug in Forge regarding the place/replace block procedure (setBlock method). If it's the latter, I am probably out of luck.
Any advice would be greatly appreciated. Literally all I want is for my falling particle to place a block when it hits the top of another block! I would use an entity instead of a particle but the placed block is supposed to be farmable, so if all the particles were entities instead, that is terrible for performance.
EDIT: Solved and made into a tutorial here: https://mcreator.net/forum/109201/tutorial-farmables-falling-particles-how-do-something-server-side-client-side-particle.
So, an update: The place block code literally does not function server-side. How do you handle server-side/client-side disparities in MCreator?
Another update. For anyone in the future trying to do something similar to this: It is impossible. Particles are exclusively client-side. Using the place block procedure on the client-side will naturally place a ghost block. There is no solution. If you want to do what I am doing, you will have to use a projectile instead.
Link to my projectile troubles if you want to know more about that: https://mcreator.net/forum/108847/arrow-sound-projectile-hit