While making my Minecraft map generator I noticed that creating huge cave systems makes Minecraft take an awfiully lot of time to load the map. It also makes Minecraft server lag.
I've found out why this happens. It's a bug in Minecraft itself.
When a chunk is loaded, light is partially recalculated for it. The problem happens when the adjacent chunks are not loaded. Minecraft thinks there is a huge void that cuts the cave, and lets the light from it enter the cave. As a result, it has to recalculate light every time it loads a chunk. It takes too much time, and it's useless.
I fixed it by making Minecraft not recalculate any lighting on chunk loads. Now it loads my maps as fast as normal ones, and it even loads normal maps a bit faster. Since chunk loading is faster, it increases overall performance, which is good :tongue.gif:
- Open a file browser window.
- Type %appdata%/.minecraft/bin on the address bar.
- Open minecraft.jar with 7zip/winrar/whatever. Don't use IZArc, it won't work.
- Delete the META-INF folder
- Drag ib.class to the jar, replacing the old one.
- Close the jar
- Launch MC and enjoy fast loading times!
Installation - Server mod
- Open minecraft_server.jar with 7zip/winrar/whatever. Don't use IZArc, it won't work.
- DO NOT DELETE the META-INF folder
- Drag me.class to the jar, replacing the old one.
- Close the jar
- Launch the server and enjoy a server with a bit less lag!
Source code
It's useless to release any source code sine the only thing I did was edit the jar with MCPack and replace the following function (named differently on client and server) with an empty function:
If you're the author of a mod (for example an optimization one) and want to integrate this with yours, feel completely free to do so. No credit is needed, but it'd be apreciated :biggrin.gif:
Credits
Me: for debugging and finding the bug
Minecraft Coder Pack: *Awesome* toolkit. It helped me get started in modding from scratch, without having to worry about the headache-inducing obfuscation stuff.
ib.class (and me.class in server) is the Chunk class
I'm afraid you'll have to merge it yourself. If you want to try, decompile the ib.class and empty that function.
For curiosity, what's the mod that's using ib.class ?
Interesting idea. I hope this works well. Trying it now, but it only seems to improve performance very slightly, and I can get around 3 - 4 FPS using this with Optimine and McRegion.
Can this mod completely eliminate lag on laptops?
ib.class (and me.class in server) is the Chunk class
I'm afraid you'll have to merge it yourself. If you want to try, decompile the ib.class and empty that function.
For curiosity, what's the mod that's using ib.class ?
the mod is the More ID's mod
too critical for me not to use
well, will try your mod next time I rebuild my jar
Works great. Especially for custom generated maps with weird terrain, like the epic caves and floaty island maps (Whatever they were called.)
Would you, the creator, or perhaps someone else who has a Twitter account (I don't) tweet Jeb http://twitter.com/jeb_# about this? Seeing as how he recently incorporated McRegions and the terrain bug fix submitted by the community into the next build, he may be interested in this as well.
UPDATE: I installed the server version on my private server since I was unsure if the client version would conflict with some other mods I had. Man, I had some more time to mess around with it and I don't know if I'm just imaging things but it seems a lot less laggy. The only minor issue I've noticed is that it takes slightly longer to log into the server. But that may be circumstantial.
So I decided to go for it and try this mod on my client despite all the other mods I have installed and wow, I'm glad I did. Not only is it slightly faster, but it seems like some of the regular lighting related bugs I've been seeing are no longer present with this mod installed. Like the ultra dark areas around underground lava pools - Totally fixed.
For the record I have Better Light & Grass, the Mip-Map mod, the terrain generation bug fix, and Wild Grass installed alongside this - No visible conflicts yet.
Wow! Thanks everyone for your replies! I didn't think something so simple would help so many people.
Quote from DraxisWuf »
Would you, the creator, or perhaps someone else who has a Twitter account (I don't) tweet Jeb http://twitter.com/jeb_# about this? Seeing as how he recently incorporated McRegions and the terrain bug fix submitted by the community into the next build, he may be interested in this as well.
Oh, yes please. Someone with a twiter account please tweet him. I don't have one neither.
Quote from DraxisWuf »
UPDATE: I installed the server version on my private server since I was unsure if the client version would conflict with some other mods I had. Man, I had some more time to mess around with it and I don't know if I'm just imaging things but it seems a lot less laggy. The only minor issue I've noticed is that it takes slightly longer to log into the server. But that may be circumstantial.
I noticed the longer login times when testing it locally. I don't know what's the cause. It seems related to the "online-mode" setting. If it's set to false, the login is as fast as on an unmodded server. You might want to try that if you're running a private server, but for public servers this could be a problem.
Wow! Thanks everyone for your replies! I didn't think something so simple would help so many people.
Quote from DraxisWuf »
Would you, the creator, or perhaps someone else who has a Twitter account (I don't) tweet Jeb http://twitter.com/jeb_# about this? Seeing as how he recently incorporated McRegions and the terrain bug fix submitted by the community into the next build, he may be interested in this as well.
Oh, yes please. Someone with a twiter account please tweet him. I don't have one neither.
Quote from DraxisWuf »
UPDATE: I installed the server version on my private server since I was unsure if the client version would conflict with some other mods I had. Man, I had some more time to mess around with it and I don't know if I'm just imaging things but it seems a lot less laggy. The only minor issue I've noticed is that it takes slightly longer to log into the server. But that may be circumstantial.
I noticed the longer login times when testing it locally. I don't know what's the cause. It seems related to the "online-mode" setting. If it's set to false, the login is as fast as on an unmodded server. You might want to try that if you're running a private server, but for public servers this could be a problem.
I tweeted Jeb_ for you. My twitter is Vibbix BTW... here the post:
@jeb_ There are some bugs with the lighting that are causing maps with huge caves to be slow This mod seems to fix it: Link Removed
For multiplayer, if a server is running the mod, does every client connecting to the server need to have it to benefit, or does only the server need to be running it?
For multiplayer, if a server is running the mod, does every client connecting to the server need to have it to benefit, or does only the server need to be running it?
Nope - Since it's dealing with a generation bug, and in multiplayer the map generation is all handled by the server, the client's don't need the patch.
Amiright?
EDIT: Also, Dirbaio, would you mind posting this on Get Satisfaction (http://getsatisfaction.com/mojang) as well? You can definitely explain the problem and how you fixed it better than anyone else.
And might I suggest renaming it the 'Minecraft Lighting Optimization/Bugfix' - Just so as not to confuse people who may be passing this up as some kind of 'Lite Optimization' for Minecraft.
I'll try to do it tomorrow. It's not complicated :biggrin.gif:
Quote from DraxisWuf »
Quote from Bobikus »
For multiplayer, if a server is running the mod, does every client connecting to the server need to have it to benefit, or does only the server need to be running it?
Nope - Since it's dealing with a generation bug, and in multiplayer the map generation is all handled by the server, the client's don't need the patch.
Amiright?
Yes, you are. I'm using it in my private server and none of my friends have modded their clients, and it works fine.
I've found out why this happens. It's a bug in Minecraft itself.
When a chunk is loaded, light is partially recalculated for it. The problem happens when the adjacent chunks are not loaded. Minecraft thinks there is a huge void that cuts the cave, and lets the light from it enter the cave. As a result, it has to recalculate light every time it loads a chunk. It takes too much time, and it's useless.
I fixed it by making Minecraft not recalculate any lighting on chunk loads. Now it loads my maps as fast as normal ones, and it even loads normal maps a bit faster. Since chunk loading is faster, it increases overall performance, which is good :tongue.gif:
Downloads
Client 1.2_02 mod: http://omg.dirbaio.net/lightmod/ib.class
Server 1.2_01 mod: http://omg.dirbaio.net/lightmod/me.class
Be careful with the server mod: I haven't tested it extensively, but it seems stable now.
Installation - Client mod
- Open a file browser window.
- Type %appdata%/.minecraft/bin on the address bar.
- Open minecraft.jar with 7zip/winrar/whatever. Don't use IZArc, it won't work.
- Delete the META-INF folder
- Drag ib.class to the jar, replacing the old one.
- Close the jar
- Launch MC and enjoy fast loading times!
Installation - Server mod
- Open minecraft_server.jar with 7zip/winrar/whatever. Don't use IZArc, it won't work.
- DO NOT DELETE the META-INF folder
- Drag me.class to the jar, replacing the old one.
- Close the jar
- Launch the server and enjoy a server with a bit less lag!
Source code
It's useless to release any source code sine the only thing I did was edit the jar with MCPack and replace the following function (named differently on client and server) with an empty function:
Client: Chunk.func_4143_d()
Server: Chunk.func_4053_c()
If you're the author of a mod (for example an optimization one) and want to integrate this with yours, feel completely free to do so. No credit is needed, but it'd be apreciated :biggrin.gif:
Credits
Me: for debugging and finding the bug
Minecraft Coder Pack: *Awesome* toolkit. It helped me get started in modding from scratch, without having to worry about the headache-inducing obfuscation stuff.
will have to go through and tear apart my jar to try this
might help me with lag- wild grass and coral mod both cause insanely slow world generation played together
think your lighting mod might help
what does ib.class effect?
maybe that will help me narrow down which mods use it
edit- found only one mod in my list that uses ib.class
more id's
sorry, need more id's for too many mods
merged ib.class possible?
we need Spawn Control Mod!
please click link-
viewtopic.php?f=25&t=104204
I'm afraid you'll have to merge it yourself. If you want to try, decompile the ib.class and empty that function.
For curiosity, what's the mod that's using ib.class ?
Can this mod completely eliminate lag on laptops?
- Mistakes were made.
AdvHud Mod @Jetstream395
the mod is the More ID's mod
too critical for me not to use
well, will try your mod next time I rebuild my jar
see if it helps with the laggy chunks
maybe someone will do a merged class
if I did it, my computer would probably melt
but good code catch there
do want to try it
we need Spawn Control Mod!
please click link-
viewtopic.php?f=25&t=104204
Would you, the creator, or perhaps someone else who has a Twitter account (I don't) tweet Jeb http://twitter.com/jeb_# about this? Seeing as how he recently incorporated McRegions and the terrain bug fix submitted by the community into the next build, he may be interested in this as well.
UPDATE: I installed the server version on my private server since I was unsure if the client version would conflict with some other mods I had. Man, I had some more time to mess around with it and I don't know if I'm just imaging things but it seems a lot less laggy. The only minor issue I've noticed is that it takes slightly longer to log into the server. But that may be circumstantial.
Your explanation was clear and it makes sense.
For the record I have Better Light & Grass, the Mip-Map mod, the terrain generation bug fix, and Wild Grass installed alongside this - No visible conflicts yet.
Oh, yes please. Someone with a twiter account please tweet him. I don't have one neither.
I noticed the longer login times when testing it locally. I don't know what's the cause. It seems related to the "online-mode" setting. If it's set to false, the login is as fast as on an unmodded server. You might want to try that if you're running a private server, but for public servers this could be a problem.
I tweeted Jeb_ for you. My twitter is Vibbix BTW... here the post:
@jeb_ There are some bugs with the lighting that are causing maps with huge caves to be slow This mod seems to fix it: Link Removed
Nope - Since it's dealing with a generation bug, and in multiplayer the map generation is all handled by the server, the client's don't need the patch.
Amiright?
EDIT: Also, Dirbaio, would you mind posting this on Get Satisfaction (http://getsatisfaction.com/mojang) as well? You can definitely explain the problem and how you fixed it better than anyone else.
And might I suggest renaming it the 'Minecraft Lighting Optimization/Bugfix' - Just so as not to confuse people who may be passing this up as some kind of 'Lite Optimization' for Minecraft.
I'll try to do it tomorrow. It's not complicated :biggrin.gif:
Yes, you are. I'm using it in my private server and none of my friends have modded their clients, and it works fine.