Jump to content

Chunks, Saving Data to, And So on


Draco18s

Recommended Posts

So, I seem to have a strange problem saving data to the chunk its associated with when the chunk is saved and unloaded.

 

Basically:

 

[22:22:57] [server thread/INFO]: Saving and pausing game...

[22:22:57] [server thread/INFO]: Saving chunks for level 'Copy of ASDF'/Overworld

[22:23:02] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.util.TreeDataHooks:saveData:75]: Saving data for chunk [dim0](-4,0,16)

[22:23:02] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.util.TreeDataHooks:saveData:81]: Saving tree: Tree[-61,67,265] 693

[22:23:02] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.util.TreeDataHooks:saveData:81]: Saving tree: Tree[-58,64,271] 974

[22:23:07] [server thread/INFO]: Saving chunks for level 'Copy of ASDF'/Nether

[22:23:07] [server thread/INFO]: Saving chunks for level 'Copy of ASDF'/The End

[22:23:23] [Client thread/INFO] [sTDOUT]: [com.draco18s.wildlife.WildlifeEventHandler:chunkUnload:693]: Unloading Chunk: -4,16

[22:23:45] [server thread/INFO]: Saving and pausing game...

[22:23:45] [server thread/INFO]: Saving chunks for level 'Copy of ASDF'/Overworld

[22:23:48] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.util.TreeDataHooks:saveData:75]: Saving data for chunk [dim0](-4,0,16)

[22:23:54] [server thread/INFO]: Saving chunks for level 'Copy of ASDF'/Nether

[22:23:54] [server thread/INFO]: Saving chunks for level 'Copy of ASDF'/The End

 

The data is saved (22:23:02).

 

Then the data is unloaded (22:23:23) as the player moved out of range.

 

Then the data (which is now been removed from memory) is saved again (22:23:48), resulting in data loss.

 

WTH.  Why is an unloaded chunk receiving a ChunkSave event?  Why does

if(event.getChunk().isChunkLoaded)

still return true for this actually-unloaded chunk?

 

How the hell do I fix this?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Forge v1291

 

1.7.10

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

...that's odd, I thought I made sure to account for that.  But on that specific event, its missing.

 

Lets try this again.

 

Ah yes, that did it.  Thanks Diesieben. :)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

You need to ignore unload events from the client.

 

Ok, this fixed it for SSP, but not SMP.

 

[23:16:22] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.WildlifeEventHandler:chunkSave:343]: Saved chunk [dim0](21,0,14)

[23:16:22] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.util.TreeDataHooks:saveData:68]: Saved tree Tree[336,82,237] 956

[23:16:22] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.util.TreeDataHooks:saveData:68]: Saved tree Tree[342,84,233] 144

[23:18:10] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.util.TreeDataHooks:printChunkInfo:367]: Trees in chunk [dim0](21,0,14)

[23:18:10] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.util.TreeDataHooks:printChunkInfo:370]:    Tree[336,82,237] 968

[23:18:10] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.util.TreeDataHooks:printChunkInfo:370]:    Tree[342,84,233] 156

[23:20:23] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.WildlifeEventHandler:chunkUnload:366]: Unloaded chunk [dim0](21,0,14)

[23:20:23] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.WildlifeEventHandler:chunkSave:343]: Saved chunk [dim0](21,0,14)

[23:21:16] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.util.TreeDataHooks:printChunkInfo:367]: Trees in chunk [dim0](21,0,14)

[23:21:16] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.util.TreeDataHooks:printChunkInfo:374]:    [None]

 

Now what?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I found that when it unloads chunks, it saves the data directly after unloading the chunks.

Maybe it is causing the issue.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

I found that when it unloads chunks, it saves the data directly after unloading the chunks.

Maybe it is causing the issue.

 

Ok, so how do I fix it?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Clunky, but it should work.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

  • 2 weeks later...

For the love of god.

 

[13:08:51] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.WildlifeEventHandler:chunkGen:423]: Generated chunk [dim0](-17,0,-3)

[13:08:51] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.util.TreeDataHooks:addTree:146]: Tree[-262,66,-41] 1061 added to chunk [dim0](-17,0,-3)

[13:08:51] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.util.TreeDataHooks:addTree:146]: Tree[-261,66,-41] 7993 added to chunk [dim0](-17,0,-3)

[13:08:51] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.util.TreeDataHooks:addTree:146]: Tree[-257,73,-48] 5064 added to chunk [dim0](-17,0,-3)

[13:11:17] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.WildlifeEventHandler:chunkUnload:433]: Unloaded chunk [dim0](-17,0,-3)

[13:11:22] [server thread/INFO] [sTDOUT]: [com.draco18s.wildlife.WildlifeEventHandler:chunkLoad:385]: Loaded chunk [dim0](-17,0,-3)

 

Now I have chunks that generate and never get a save call before they're unloaded.  This is just as bad as getting a save call after I purged the data from memory.

 

width=240 height=240http://static.fjcdn.com/pictures/Rage_562aea_329374.jpg[/img]

 

Do none of these events make god damn sense?  I should not have to build a data structure to track what chunks are in what state so that I don't inadvertently trash data I still need or overwrite good data with bad.  The game already freaking does this, but it can't be arsed to inform me!

 

I'm about ready to store the data in an indestructible bedrock-level tileentity.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

... I don't know why those issues can ever happen, from this code.. (Note that mine is 1.7.10.1160 so it can be different)

    /**
     * Unloads chunks that are marked to be unloaded. This is not guaranteed to unload every such chunk.
     */
    public boolean unloadQueuedChunks()
    {
        if (!this.worldObj.levelSaving)
        {
            for (ChunkCoordIntPair forced : this.worldObj.getPersistentChunks().keySet())
            {
                this.chunksToUnload.remove(ChunkCoordIntPair.chunkXZ2Int(forced.chunkXPos, forced.chunkZPos));
            }

            for (int i = 0; i < 100; ++i)
            {
                if (!this.chunksToUnload.isEmpty())
                {
                    Long olong = (Long)this.chunksToUnload.iterator().next();
                    Chunk chunk = (Chunk)this.loadedChunkHashMap.getValueByKey(olong.longValue());

                    if (chunk != null)
                    {
                        chunk.onChunkUnload();
                        this.safeSaveChunk(chunk);
                        this.safeSaveExtraChunkData(chunk);
                        this.loadedChunks.remove(chunk);
                        ForgeChunkManager.putDormantChunk(ChunkCoordIntPair.chunkXZ2Int(chunk.xPosition, chunk.zPosition), chunk);
                        if(loadedChunks.size() == 0 && ForgeChunkManager.getPersistentChunksFor(this.worldObj).size() == 0 && !DimensionManager.shouldLoadSpawn(this.worldObj.provider.dimensionId)){
                            DimensionManager.unloadWorld(this.worldObj.provider.dimensionId);
                            return currentChunkProvider.unloadQueuedChunks();
                        }
                    }

                    this.chunksToUnload.remove(olong);
                    this.loadedChunkHashMap.remove(olong.longValue());
                }
            }

            if (this.currentChunkLoader != null)
            {
                this.currentChunkLoader.chunkTick();
            }
        }

        return this.currentChunkProvider.unloadQueuedChunks();
    }

So it surely unloads the chunk before it saves the chunk data..

  (Chunk#onChunkUnload surely marks the chunk as unloaded)

The only another way the ChunkSave event got called is WorldServer#saveAllChunks(), which is only called when world is saved..

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

So it surely unloads the chunk before it saves the chunk data..

  (Chunk#onChunkUnload surely marks the chunk as unloaded)

The only another way the ChunkSave event got called is WorldServer#saveAllChunks(), which is only called when world is saved..

 

So, in other words, I need two events to happen for me to safely say "this data is no longer relevant."  First a chunkUnload, then a chunkSave (but watch out, saves can happen any time!)

 

Yeah.  While I'm sure that that makes sense, its a complete hassle from a "I want this to work" perspective.  E.g. "chunkUnload" should be the last thing that happens to a chunk before it's loaded again.  The event should be telling mods "this chunk is leaving, whatever cleanup you need to do, do it."

 

       loaded
          V
gen -> (active) <-> save
                     V
                  unloaded

 

Instead, the flow chart actually looks like this:

 

       loaded
          V
gen -> (active) <-> save
          V
       unloaded -> save

 

Note the two instances of "save."  They are not identical, but it is impossible to tell the difference between them without storing extra data as the events trigger.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

I'll just throw this in here:

"Just" use a WeakHashMap and don't even bother handling the unload.

 

Can't.  The save/load and tick operations happen on separate threads (that is, strait up using a HashMap causes concurrent modification exceptions) and there is no "ConcurrentWeakHashMap."

 

Not to mention that I tick the data, so its kind of important to know if the chunk the data is associated with is active.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

While exploring this path, I found the following: onChunkUnload sets

isChunkLoaded

to false. So in chunk unload you do nothing. Then in chunk save you check if isChunkLoaded is false and if so unload your data (you don't even need the WeakHashMap then).

 

Thanks for the digging, as always, diesieben07.

I've only managed to glean so much from the SRG'd vanilla source on my own.  Most of what I've figured out has been from observing the behavior of a single chunk as I interact with the system and with suggestions as I run into stumbling blocks.

 

There's a number of headaches going on with this code, and this is only one part of it.  It seems that even with a 3-chunk-deferred-radius for the generation of the data, it still doesn't find all of the trees, especially in a jungle.  Neither Keybounce nor I can figure out why.  But that's a problem for another thread.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • BALON168🎈: Situs Slot Gacor Terbaik, Termewah, dan Tergacor 2024 dengan RTP 99,99% Mudah Maxwin Jika Anda pencinta judi online, mencari situs yang dapat diandalkan dan memberikan pengalaman bermain yang memuaskan tentu menjadi prioritas. Salah satu opsi terbaik yang patut dipertimbangkan adalah BALON168🎈. Situs ini tidak hanya menawarkan berbagai permainan slot yang menarik, tetapi juga mempersembahkan keunggulan dan kenyamanan bagi para pemainnya. Keunggulan BALON168🎈 BALON168🎈 tidak hanya sekadar situs slot online biasa. Dengan reputasi yang solid dan terpercaya, BALON168🎈 telah menjadi destinasi favorit bagi para penggemar judi online di tahun 2024. Keunggulan yang ditawarkan mencakup: 1. RTP Tinggi 99,99% Salah satu hal yang membuat BALON168🎈 menonjol adalah tingkat pengembalian (RTP) yang luar biasa tinggi, mencapai 99,99%. Ini berarti pemain memiliki peluang besar untuk memenangkan hadiah besar setiap kali mereka memutar gulungan di slot BALON168🎈. 2. Permainan Slot Gacor BALON168🎈 dikenal sebagai situs slot gacor terbaik di tahun 2024. "Gacor" adalah istilah yang digunakan untuk mesin slot yang sering memberikan kemenangan kepada pemainnya. Dengan koleksi permainan slot yang beragam dan sering memberikan jackpot besar, BALON168🎈 memastikan pengalaman bermain yang memuaskan bagi para pengunjungnya. 3. Maxwin yang Mudah Di BALON168🎈, peluang maxwin tidak hanya menjadi impian belaka. Dengan fitur yang mudah dimengerti dan diakses, pemain memiliki kesempatan yang besar untuk meraih kemenangan maksimum dalam setiap permainan yang mereka mainkan. Keamanan dan Kepuasan Pemain BALON168🎈 mengutamakan keamanan dan kepuasan para pemainnya. Dengan sistem keamanan terkini dan perlindungan data yang canggih, para pemain dapat bermain dengan tenang tanpa khawatir tentang privasi dan keamanan mereka. Layanan pelanggan yang responsif dan ramah juga selalu siap membantu para pemain dalam setiap masalah atau pertanyaan yang mereka miliki.       ❱❱❱❱❱ DAFTAR DI SINI ❰❰❰❰❰ ❱❱❱❱❱ DAFTAR AKUN PRO ❰❰❰❰❰ ❱❱❱❱❱ DAFTAR AKUN VIP ❰❰❰❰❰            
    • LadangToto2 adalah pilihan terbaik bagi Anda yang mencari pengalaman bermain slot gacor dengan transaksi mudah menggunakan Bank Mestika. Berikut adalah beberapa alasan mengapa Anda harus memilih LadangToto2: Slot Gacor Terbaik Kami menyajikan koleksi slot gacor terbaik yang menawarkan kesenangan bermain dan peluang kemenangan besar. Dengan fitur-fitur unggulan dan tema-tema menarik, setiap putaran permainan akan memberikan Anda pengalaman yang tak terlupakan. Transaksi Mudah dengan Bank Mestika Kami menyediakan layanan transaksi mudah melalui Bank Mestika untuk kenyamanan dan keamanan Anda. Dengan proses yang cepat dan efisien, Anda dapat melakukan deposit dan penarikan dana dengan lancar dan tanpa hambatan. Hadiah Hingga 100 Juta LadangToto2 memberikan kesempatan untuk meraih hadiah hingga 100 juta dalam kemenangan. Dengan jackpot dan hadiah-hadiah besar yang ditawarkan, setiap putaran permainan bisa menjadi peluang untuk meraih keberuntungan besar.  
    • Mengapa Memilih LadangToto? LadangToto adalah pilihan terbaik bagi Anda yang mencari pengalaman bermain slot gacor WD Maxwin dengan transaksi mudah menggunakan Bank BNI. Berikut adalah beberapa alasan mengapa Anda harus memilih LadangToto: Slot Gacor WD Maxwin Terbaik Kami menyajikan koleksi slot gacor WD Maxwin terbaik yang menawarkan kesenangan bermain dan peluang kemenangan besar. Dengan fitur-fitur unggulan dan tema-tema menarik, setiap putaran permainan akan memberikan Anda pengalaman yang tak terlupakan. Transaksi Mudah dengan Bank BNI Kami menyediakan layanan transaksi mudah melalui Bank BNI untuk kenyamanan dan keamanan Anda. Dengan proses yang cepat dan efisien, Anda dapat melakukan deposit dan penarikan dana dengan lancar dan tanpa hambatan.  
    • Akun Pro Kamboja adalah pilihan terbaik bagi Anda yang mencari pengalaman bermain slot Maxwin dengan transaksi mudah menggunakan Bank Lampung. Berikut adalah beberapa alasan mengapa Anda harus memilih Akun Pro Kamboja: Slot Maxwin Terbaik Kami menyajikan koleksi slot Maxwin terbaik yang menawarkan kesenangan bermain dan peluang kemenangan besar. Dengan fitur-fitur unggulan dan tema-tema menarik, setiap putaran permainan akan memberikan Anda pengalaman yang tak terlupakan. Transaksi Mudah dengan Bank Lampung Kami menyediakan layanan transaksi mudah melalui Bank Lampung untuk kenyamanan dan keamanan Anda. Dengan proses yang cepat dan efisien, Anda dapat melakukan deposit dan penarikan dana dengan lancar dan tanpa hambatan. Anti Rungkat Akun Pro Kamboja memberikan jaminan "anti rungkat" kepada para pemainnya. Dengan fitur ini, Anda dapat merasakan sensasi bermain dengan percaya diri, karena kami memastikan pengalaman bermain yang adil dan menyenangkan bagi semua pemain.  
    • BINGO188: Destinasi Terbaik untuk Pengalaman Slot yang Terjamin Selamat datang di BINGO188, tempat terbaik bagi para pecinta slot yang mencari pengalaman bermain yang terjamin dan penuh kemenangan. Di sini, kami menawarkan fitur unggulan yang dirancang untuk memastikan kepuasan dan keamanan Anda. Situs Slot Garansi Kekalahan 100 Kami memahami bahwa kadang-kadang kekalahan adalah bagian dari permainan. Namun, di BINGO188, kami memberikan jaminan keamanan dengan fitur garansi kekalahan 100. Jika Anda mengalami kekalahan, kami akan mengembalikan saldo Anda secara penuh. Kemenangan atau uang kembali, kami memastikan Anda tetap merasa aman dan nyaman. Bebas IP Tanpa TO Nikmati kebebasan bermain tanpa batasan IP dan tanpa harus khawatir tentang TO (Turn Over) di BINGO188. Fokuslah pada permainan Anda dan rasakan sensasi kemenangan tanpa hambatan. Server Thailand Paling Gacor Hari Ini Bergabunglah dengan server terbaik di Thailand hanya di BINGO188! Dengan tingkat kemenangan yang tinggi dan pengalaman bermain yang lancar, server kami dijamin akan memberikan Anda pengalaman slot yang tak tertandingi. Kesimpulan BINGO188 adalah pilihan terbaik bagi Anda yang menginginkan pengalaman bermain slot yang terjamin dan penuh kemenangan. Dengan fitur situs slot garansi kekalahan 100, bebas IP tanpa TO, dan server Thailand paling gacor hari ini, kami siap memberikan Anda pengalaman bermain yang aman, nyaman, dan menguntungkan. Bergabunglah sekarang dan mulailah petualangan slot Anda di BINGO188!
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.