RandomMcSomethin / fallingleaves

MIT License
43 stars 20 forks source link

[Suggestion] Add configurable particle distance #31

Open natopotato390 opened 2 years ago

natopotato390 commented 2 years ago

Please immediately correct me if I'm wrong and this isn't possible :)

If the particle distance is limited inside the mod itself and not by Minecraft's particle system in general... An option to change the distance at which particles will spawn would be super handy.

Currently the distance is a bit lacking in my opinion. Even so, an option to reduce it further could be of use as well.

Fourmisain commented 2 years ago

tl;dr It's complicated.

The mod is currently spawning the particles through the vanilla block's "random display ticks" - basically, every client tick, a diabolical number of random blocks around the player are display ticked (666 blocks, once within radius 16, another time within radius 32), which is used for all kinds of different particle and sound effects.

I did some math and this is what the vanilla display tick distribution (in one dimension) looks like:

dist

So most blocks are ticked right around the player and the chance falls off to 0 at a distance of 32 blocks.

Practically speaking though, the falloff is way worse. Imagine e.g. standing in a forest. If you put a sphere with a small radius around the player, you'll find lots of leaf blocks on its boundary. If you now increase the size of the sphere, you'll notice that a large part of its boundary will go into the air above the trees or below the ground, so you'll generally find less leaf blocks inside it. That means the chance for leaf blocks that are far away to be randomly selected is naturally much lower - with no obvious way to "fix" that.

We could theoretically increase the leaf spawn chance based on distance and we could also add our own (optional) "ticks" to specifically spawn leaves for higher distances than 32 blocks, but the issue is that it is not obvious at all how exactly the numbers should be chosen.

I might think about this a little more. I was originally also thinking about the distribution stuff while implementing the "starting spawn radius", which I'm also not quite satisfied with (because it reduces the average number of leaves).

natopotato390 commented 2 years ago

Thanks for all that info, really good detailing on what's going on!

I'll be honest and say I don't know much about the particle/display systems in Minecraft, but I'm assuming from your info that you can only use a spherical radius around the player with the display ticking.

Really the best area for testing leaves would be in a cuboid or cylinder above the player leaves_area 1 block above the player since most leaves below there will be touching the ground anyways.

Players wont really notice leaves falling below them so this saves block checking time. Height of the areas could even be biome dependent

Looks like unfortunately for a solution like this one you'd have to use an entirely different system for spawning particles In order to get the distribution right as well as the special shape of area to check around the player.

Dealing with that display tick distribution seems like a real hacky way of doing things and not a great permanent solution

Just some ideas :) Could be fun to toy around with other systems/ways of doing this, might open up more control