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

IntCache is used in GenLayer and its subclasses to cache int arrays. It's reseted in the front of biome-related methods such as getBiomesForGeneration or getBiomeGenAt. Now here comes a problem:

 

GenLayer.getInt is called in both CLIENT and SERVER sides. It's ok using a dedicated server. However, in intergrated server, CLIENT and SERVER sides are in two thread. So they may call a biome method at same time. That means, IntCache might be reseted in CLIENT thread while SERVER thread is using it! If unlucky, game crashes.

 

I suffered from the crash for a long time but coundn't find the reason. I got it just now as I put a printing current thread statement in my GenLayer.getInts method. I found out that it was called in both CLIENT and SERVER threads. I realized what was responsible for these crashes. Now I put one crash report fragment here:

 

---- Minecraft Crash Report ----
// Oops.

Time: 15-4-4 10:05 PM
Description: Getting biome

java.lang.ArrayIndexOutOfBoundsException: 114
at me.herbix.taoland.world.gen.layer.GenLayerByProperty.getInts(GenLayerByProperty.java:65)
at me.herbix.taoland.world.gen.layer.GenLayerZoom.getInts(GenLayerZoom.java:25)
at me.herbix.taoland.world.gen.layer.GenLayerZoom.getInts(GenLayerZoom.java:25)
at me.herbix.taoland.world.gen.layer.GenLayerZoom.getInts(GenLayerZoom.java:25)
at me.herbix.taoland.world.gen.layer.GenLayerZoom.getInts(GenLayerZoom.java:25)
at net.minecraft.world.gen.layer.GenLayerSmooth.getInts(GenLayerSmooth.java:23)
at me.herbix.taoland.world.gen.layer.GenLayerRiverMix.getInts(GenLayerRiverMix.java:18)
at net.minecraft.world.gen.layer.GenLayerVoronoiZoom.getInts(GenLayerVoronoiZoom.java:25)
at net.minecraft.world.biome.WorldChunkManager.getBiomeGenAt(WorldChunkManager.java:199)
at net.minecraft.world.biome.BiomeCache$Block.<init>(BiomeCache.java:106)
at net.minecraft.world.biome.BiomeCache.getBiomeCacheBlock(BiomeCache.java:37)
at net.minecraft.world.biome.BiomeCache.func_180284_a(BiomeCache.java:48)
at net.minecraft.world.biome.WorldChunkManager.func_180300_a(WorldChunkManager.java:75)
at net.minecraft.world.chunk.Chunk.getBiome(Chunk.java:1442)
at net.minecraft.world.World.getBiomeGenForCoordsBody(World.java:196)
at net.minecraft.world.WorldProvider.getBiomeGenForCoords(WorldProvider.java:429)
at net.minecraft.world.World.getBiomeGenForCoords(World.java:185)
at net.minecraftforge.client.ForgeHooksClient.getSkyBlendColour(ForgeHooksClient.java:388)
at net.minecraft.world.World.getSkyColorBody(World.java:1524)
at net.minecraft.world.WorldProvider.getSkyColor(WorldProvider.java:463)
at net.minecraft.world.World.getSkyColor(World.java:1511)
at net.minecraft.client.renderer.EntityRenderer.updateFogColor(EntityRenderer.java:1757)
at net.minecraft.client.renderer.EntityRenderer.renderWorldPass(EntityRenderer.java:1277)
at net.minecraft.client.renderer.EntityRenderer.renderWorld(EntityRenderer.java:1263)
at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1088)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1107)
at net.minecraft.client.Minecraft.run(Minecraft.java:376)
at net.minecraft.client.main.Main.main(Main.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)

 

Hmm.. IntCache shall not be access from CLIENT thread I thought, because generating biomes is a SERVER function. There must be some better way to implement ForgeHooksClient.getSkyBlendColour I suppose.

Author of Tao Land Mod.

width=200 height=69http://taoland.herbix.me/images/1/14/TaoLandLogo.png[/img]

Also, author of RenderTo

----

I'm not an English native speaker. I just try my best.

  • Author

Oops. I found out that vanilla EntityRenderer.addRainParticles uses World.getBiomeGenForCoords as well.

But I still doubt whether this would cause crash.

 

Edit: More and more CLIENT side uses found. That's not a mistake of ForgeHooksClient.getSkyBlendColour.

Author of Tao Land Mod.

width=200 height=69http://taoland.herbix.me/images/1/14/TaoLandLogo.png[/img]

Also, author of RenderTo

----

I'm not an English native speaker. I just try my best.

Actually everything (even other mods) that get the biome for specific coords uses that method.

It seems like one of those examples where Mojang didn't see the necessity (probably unintentional) to make it safe for multithreading...

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

  • Author

It seems like one of those examples where Mojang didn't see the necessity (probably unintentional) to make it safe for multithreading...

 

The strangest thing is that I didn't feel a vanilla crash caused by getInts. It only happens to my mod. I'm sure it's a multithreading problem, but not sure why crash occurs only in my mod.

Author of Tao Land Mod.

width=200 height=69http://taoland.herbix.me/images/1/14/TaoLandLogo.png[/img]

Also, author of RenderTo

----

I'm not an English native speaker. I just try my best.

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.