Posted February 3, 201411 yr So one of the big justifications I get given for chunk loaders on servers (and also iirc the reason things like the buildcraft quarry chunk load) is that a lot of the automation stuff can break in horrible ways if the server has some of the chunks loaded, but not others (e.g. loads a chunk containing buildcraft combustion engines, but not the chunks containing the buildcraft water pumps that stop them exploding). So my idea is basically to merge a bunch of adjacent chunks into some kind of dependency group, and make forge load and unload them all at the same time (at least on the server, don't think it matters for the client too much?). Using the chunk loaded event I can check my dependency data, and with ForgeChunkManager can force any chunks I want to also load. However my issue is how to know when my force load "ticket" is the only thing keeping all the chunks in question loaded (the players have moved away). Like a "Ticket.isActivelyForcingChunkLoad(x,z)" method? I looked through the code, and couldn't really see anyway to determine that. The only thing I did find was in ChunkProviderServer.unloadQueuedChunks which I guess if chunksToUnload contains all the chunks that would normally be unloaded (not entirely certain, can't see how it is populated apart from the no players unloadAll case) I could in theory check to see if all my chunks are in that set, and then delete my ticket if they are. But there does not seem to any forge hook at that location for me to do so... So any other ways to check the chunk unload conditions / states?
February 3, 201411 yr You can use the ChunkUnloadEvent, I assume. Check that the chunk is in a group, if(all chunks in this group are in the "waiting unload" list) { unload the group} else {add the chunk to the "waiting unload" list}.
February 3, 201411 yr Author What event exactly are you thinking of? I searched through all the sources/api's I have and only came across org.bukkit.event.world.ChunkUnloadEvent, which obviously isn't useable for a forge mod. Forge has a net.minecraftforge.event.world.ChunkEvent.Unload but this is only sent if the chunk is really being unloaded (from ChunkProviderServer in the loop after the force load check loop), it also doesn't say what other chunks are being unloaded, and has no way to cancel the unload (I guess to prevent mods from working around the ticket/limit system since seems forge has gone with not trusting mods in that regard?).
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.