"Leaf" Decay for Custom Blocks

Upvotes: 4
Issue description

As the title suggests, adding an option for decay in blocks.

Basically trying to emulate what vanilla leaves do when a player cuts down a tree; many MCreator modders I've seen have been looking for a way to do this, to avoid floating trees. I feel this could be implemented in the block creation element editor with a check box and (if checked) setting which block acts as the "wood" for the given "leaf". I hope that makes sense.

Also I'm not sure if I'm blind but if adding above isn't possible then perhaps adding a a component that checks in a radius around a block is? That component by itself would make emulating leaf decay a possibility with MCreator, as one could just make it so a block checks a given radius around it for another block, and then staying spawned in or decaying from there. The [get block] component kind of does this, but only checks at the given xyz location rather than over an area to what I've experienced using it ^^;

Attachment Size
LeafDecayProcedure1.16 KB 1.16 KB
Check for block in 6x6x6 box1.03 KB 1.03 KB
Check for Block -- fixed without entity requirement1.08 KB 1.08 KB

Issue comments

"For checking blocks in "area", you can use do n times block and nest three of them to check in x, y and z axis"

What's this?

Developer Submitted by Klemen on Fri, 04/19/2019 - 13:57

  1. Create 3 local variables: offx, offy and offz, set them to -3
  2. Use repeat n times, say 6 times procedure block (check in range +/- 3 blocks square)
  3. Using math blocks, increase offx here by 1
  4. Place another one in it
  5. Using math blocks, increase offy here by 1
  6. And another one inside previous one
  7. Using math blocks, increase offz here by 1
  8. Check for the block at x + offx, y + offy and z + offz

Soo... something like this maybe? Tried following your steps as best as I could Klemen, albeit I'm still a lil confused hehe ^^; I'm pretty new to the whole procedure thing I've only made simple ones that can spawn saplings and stuff when blocks are broken, and followed the video guides for anything more complicated, so I really don't know if this is correct.


Edit --- Actually I will say that I did attempt to load up a client test environment and it failed compiling because of this procedure despite there not being any errors given, so I'm outta ideas for now. Any pointers would be appreciated <3 I plan on releasing the procedure as a importable template for others to use in the future as well so there can be no more floating trees!


and yea I know there's that one empty slot near the bottom I honestly didn't know what to put there, as I want it to do nothing if the given wood block is within the radius of the leaf ;;;;;;;; but no errors showed up so I assumed it was fine like that? I dunno q.q I'm really hopeless when it comes to coding won't lie-



Developer Submitted by Klemen on Mon, 04/22/2019 - 18:27

How do you mean no errors given? So it works?

Regarding the procedure, you need to put the if block in the actual loop. Add another logic variable, say woodFound and set it to false by default. Then inside the most inner loop, use the if to check if the block is wood. If it is, set the woodFound to true.

Outside the loop, check if the woodFound is false, and if it is, remove the leaf block.

What this does, it iterates all the blocks in 6x6x6 area and if any of them is your custom block, it sets the woodFound to true. If this is not the case, the variable remains false and in this case the leaf is removed.

Developer Submitted by Klemen on Tue, 04/23/2019 - 09:53

Not really the radius, but the size of the box it will check. It will check in a box of 6x6x6 size for a custom block and if it is not there, the leaf block is removed.

No errors given as when I was creating the procedure it never said anything was wrong/missing, yet when I attempted to load up the test client recompile failed due to it~

And thank you for the corrections, I will let you know if I need anymore help!!


Developer Submitted by Klemen on Wed, 04/24/2019 - 11:42

Do you have all the variables you use on the list of local variables?

I do, the only variables I have are OffX, OffY, OffZ, and WoodFound. The offsets are number variables and WoodFound is a logic variable as you had suggested.

Developer Submitted by Klemen on Thu, 04/25/2019 - 16:26

Sporadic Splash, could you please export the procedure and attach it to the issue so I can check? Thanks!

I went ahead and exported + attached both the procedure by itself, as well as my entire mod's workspace. I hope me exporting it with my mod's elements doesn't mess anything up when you import it into your MCreator workspace (Hence why I've also provided my entire workspace in case it does happen, the procedure you're looking for is the last thing in the workspace btw!)

I also found the problem, was an error on my part that I didn't happen to see! There was a x+1 component missing, so I went ahead and plugged it in and the variable error disappeared, but the problem still remains and the leaf block will not remain even when placed right up against the wood. I hope you work your magic and find the solution with no problems!

Developer Submitted by Klemen on Sat, 04/27/2019 - 12:09

There were some logical/procedural errors (issues) with your procedure, I have attached a fixed procedure (leaf decay fixed 1), but I did not have the time to test it out yet, but it should work.

Please report back if it works and it if does I will consider adding this procedure to templates.

Ok i will try it out in a few minutes, If it work, Add it in Template Library, it would be useful

Wait, I check it now and you didn't attach it? I don't see LeafDecayFixed1

Developer Submitted by Klemen on Sat, 04/27/2019 - 16:59

Sorry, it is now attached.