Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hey forum,

 

so I'm writing my first mod and ran into another problem: I subscibe to eventChunkLoad and determine the surface of the chunks that I get. This works brilliantly in singleplayer (!event.world.isRemote). I can access and dump the data I need for my mod.

 

Then I built a production JAR using "gradlew build", placed it in my MinecraftForge mods/ directory and tried the exact same thing with an MP server. There, it doesn't work, however: eventChunkLoad() gets called, and event.chunk() yields a non-null chunk, but chunk.isChunkLoaded is always false and the chunk doesn't contain any data.

 

If someone could hint me as to what I'm doing wrong I'd greatly appreciate it.

 

Cheers,

Henrik

  • Author

So this problem persists and I really am extremely puzzled. Here's some code I have

 

@SubscribeEvent
public void eventChunkLoad(ChunkEvent.Load event) {		
	Chunk chunk = event.getChunk();
	if (chunk == null) {
		sink.debug("Chunk is null");
		return;
	}

	if (!chunk.isChunkLoaded) {
		sink.debug("Chunk " + chunk.xPosition + " / " + chunk.zPosition + " is not loaded (" + chunk.worldObj.getChunkProvider().getLoadedChunkCount() + " loaded chunks)");
		return;
	}

 

And my log shows this:

 

DEBUG: WorldLoad 0
DEBUG: Chunk 12 / 13 is not loaded (1 loaded chunks)
DEBUG: Chunk 7 / 16 is not loaded (2 loaded chunks)
DEBUG: Chunk 7 / 15 is not loaded (3 loaded chunks)
DEBUG: Chunk 7 / 14 is not loaded (4 loaded chunks)
DEBUG: Chunk 7 / 13 is not loaded (5 loaded chunks)
DEBUG: Chunk 7 / 12 is not loaded (6 loaded chunks)
DEBUG: Chunk 7 / 11 is not loaded (7 loaded chunks)
DEBUG: Chunk 7 / 10 is not loaded (8 loaded chunks)
DEBUG: Chunk 7 / 9 is not loaded (9 loaded chunks)
DEBUG: Chunk 7 / 8 is not loaded (10 loaded chunks)
DEBUG: Chunk 6 / 16 is not loaded (11 loaded chunks)
DEBUG: Chunk 6 / 15 is not loaded (12 loaded chunks)
DEBUG: Chunk 6 / 14 is not loaded (13 loaded chunks)
DEBUG: Chunk 6 / 13 is not loaded (14 loaded chunks)

 

So apparently the events fire whenever a chunk is loaded, but within that event I cannot access the chunk data (not loaded). The chunk provider however seems to think that all these chunks are loaded (and it increases nicely the loaded chunk count).

 

Does anyone have an idea what might be going on here? As said before, when I test from Eclipse on a SP server this problem is not existent at all!

 

Any help greatly appreciated,

Henrik

 

Hi

 

The answer lies in the vanilla code...

ChunkProviderClient::
   /**
     * loads or generates the chunk at the chunk location specified
     */
    public Chunk loadChunk(int p_73158_1_, int p_73158_2_)
    {
        Chunk chunk = new Chunk(this.worldObj, p_73158_1_, p_73158_2_);
        this.chunkMapping.add(ChunkCoordIntPair.chunkXZ2Int(p_73158_1_, p_73158_2_), chunk);
        this.chunkListing.add(chunk);
        net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkEvent.Load(chunk));
        chunk.isChunkLoaded = true;
        return chunk;
    }


Chunk::
   /**
     * Called when this Chunk is loaded by the ChunkProvider
     */
    public void onChunkLoad()
    {
        this.isChunkLoaded = true;
        this.worldObj.func_147448_a(this.chunkTileEntityMap.values());

        for (int i = 0; i < this.entityLists.length; ++i)
        {
            Iterator iterator = this.entityLists[i].iterator();

            while (iterator.hasNext())
            {
                Entity entity = (Entity)iterator.next();
                entity.onChunkLoad();
            }

            this.worldObj.addLoadedEntities(this.entityLists[i]);
        }
        MinecraftForge.EVENT_BUS.post(new ChunkEvent.Load(this));
    }

 

...it depends on what is triggering the load event...

 

-TGG

 

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.