(too many) Monsters in infdev and further reports

Infdev’s been updated with monsters and animals. Animals spawn during the days, monsters during the nights. There’s quite a lot of them..

Now some reports and explanations, in case you want deeper more detailed information:

The lighting bug:
The lighting code had a quick escape test that checked if the area being affected is even in a loaded chunk at all. So the test was something like

if (isChunkLoadedAt(x, y, z)) return;

Unfortunately, that does exactly opposite of what I wanted it do so, so lighting tests would only propagate into unloaded chunks instead of the other way around. This caused increased memory usage and caused the weird black shadows under overhangs in certain situations.

After adding a single ! and reverting a LOT of pointless debugging, lighting now works again. Yay.

The new trees:
Paul Spooner made a really cool map mod that converted trees into much fluffier organic beasts. We got in contact over email, and even though I almost always turn down offers for help, I was so impressed with what he had done, I just had to have it in the game. So we collaborated for a bit, and here we are!

I’m probably going to add a special “branch” block that looks better than the weird floating trunk bits the trees have now, and while doing so, I will make the entire tree go away again if you destroy the central trunk.

I’m also probably going to add a setting for making the leaves faster to render.. They cause a LOT of polygons at the moment. ;)

The desk scratch:


Monsters not spawning in infdev:
I changed the mob spawner to take a List> instead of manually figuring out what mobs to spawn and directly calling the constructors. This made the obfuscator remove the constructors as they were never directly called (but rather via Class.newInstance()), and as a result, no mobs could spawn.

I would’ve found this faster if oracle hadn’t broken the Tool -> Java Console thing in firefox..

The plan for optimization:
The majorest problem right now is that level generation takes up a LOT of time, causing annoying fps drops when moving into new areas.

So I’ll make a small program that only generates a minecraft level from scratch, using a fixed seed. I’ll time it, then run it through a profiler. After finding the bottlenecks, I’ll either optimize them or work around them.

Once the level generator runs faster, I’ll split it up into an asynchronous task so that even if it takes time to run (say, on an older computer), the game should still be relatively smooth and load chunks gradually over time instead.
The nice thing about this is that if I prioritize them by distance to the player, you’ll never be able to run out into empty void since the number of chunks near the player is faaar lower than the number of chunks further away.

posted 13 years ago