Leaf replacement in neighboring chunks on Chunk Generate event

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Skuli

New Member
May 12, 2017
9
0
0
Minecraft 1.11.2
Skript v2.2-dev26f
Umbaska v3.3
SkQuery-Lime 1.11
SkStuff v1.6.4.1
Skellett v1.9.0e

I'm tinkering with the chunk generate event to remove leaves from trees. It's slow, but I'm just playing around right now.

When the chunk generates, I'm looping through all the blocks and setting any "leaf" blocks to "air":

code_language.skript:
on chunk generate:
        loop blocks within event-chunk:
                if loop-block-1 is leaves:
                        set loop-block-1 to air

I'm sure this is a terrible idea performance-wise, I'm sure there's much better ways to do this, but I'll get to that eventually. What I'm struggling with is that trees frequently generate in a specific chunk, but leaves overlap in nearby already generated chunks, and I'm unable to capture that event and remove those trees.

Any suggestions? Is there a syntax that works for event-chunk's neighboring chunks? I've tried variations on "loop blocks within chunk north of event-chunk" and whatnot, to no avail:

Code:
       loop blocks within chunk north of event-chunk:
               if loop-block-1 is leaves:
                       set loop-block-1 to air

*edit*

Never mind, this works:

Code:
on chunk generate:
       loop blocks within event-chunk:
               if loop-block-1 is leaves:
                       set loop-block-1 to air
       set {_loc} to block at 8, 1, 8 in event-chunk

       loop blocks within chunk north of {_loc}:
               if loop-block-1 is leaves:
                       set loop-block-1 to air

It's really, REALLY slow though, even with just one cardinal direction. It'll be about 4x slower once I factor in all four directions AND diagonals...
 
Why don't use a world generator? is better than this code.
 
Status
Not open for further replies.