Fabric API

Fabric API

152M Downloads

RenderType$CompositeRenderType cannot be cast to class ChunkSectionLayer when rendering custom rail

NemoOnGH opened this issue ยท 1 comments

commented

Hey,
I tried asking in the Discord and looked into the discussions to see if I get some more information regarding this issue, unfortunately I couldn't.

Issue

After updating my mod from 1.21.5 to 1.21.7 I regularly (but not all the time) get the following issue when trying to render a custom rail:

class net.minecraft.client.renderer.RenderType$CompositeRenderType cannot be cast to class net.minecraft.client.renderer.chunk.ChunkSectionLayer

I put the full stacktrace below.

My Testing

I did some testing and got these results:

  • Searching/rendering for a custom rail in the creative inventory without having the item in the inventory will cause always or almost always a crash.
  • Searching/rendering for a custom block, works all the time without a crash
  • Waiting in the main menu (I waited for 30 sec), then joining the world, makes you able to search/render for the custom rail without any crash -> seems to be consistent
  • If I join the world immediately, then wait 30 sec and try to search/render the custom rail, it will crash almost always to always
  • If I put the rail into my inv, sometimes I can join immediately, sometimes it crashes
  • Just having the rail placed, but not having it in the inventory, most of the time leads to a crash
  • Waiting in the menu is the only consistent way to join without having a crash

Could this be a bug in Fabric or am I missing something?
This sounds to me that something takes too much time and then the rendering isn't handled properly

I don't have this issue on other mod loaders, which use the same code except for the rendering part

Stacktrace

java.lang.ClassCastException: class net.minecraft.client.renderer.RenderType$CompositeRenderType cannot be cast to class net.minecraft.client.renderer.chunk.ChunkSectionLayer (net.minecraft.client.renderer.RenderType$CompositeRenderType and net.minecraft.client.renderer.chunk.ChunkSectionLayer are in unnamed module of loader 'knot' @185d8b6)
	at knot//net.minecraft.client.renderer.ItemBlockRenderTypes.getChunkRenderType(ItemBlockRenderTypes.java:396)
	at knot//net.minecraft.client.renderer.ItemBlockRenderTypes.getRenderType(ItemBlockRenderTypes.java:422)
	at knot//net.minecraft.client.renderer.ItemBlockRenderTypes.getRenderType(ItemBlockRenderTypes.java:433)
	at knot//net.minecraft.client.renderer.item.BlockModelWrapper.update(BlockModelWrapper.java:81)
	at knot//net.minecraft.client.renderer.item.ItemModelResolver.appendItemLayers(ItemModelResolver.java:54)
	at knot//net.minecraft.client.renderer.item.ItemModelResolver.updateForTopItem(ItemModelResolver.java:44)
	at knot//net.minecraft.client.renderer.entity.ItemRenderer.renderStatic(ItemRenderer.java:142)
	at knot//net.minecraft.client.renderer.ItemInHandRenderer.renderItem(ItemInHandRenderer.java:174)
	at knot//net.minecraft.client.renderer.ItemInHandRenderer.renderArmWithItem(ItemInHandRenderer.java:633)
	at knot//net.minecraft.client.renderer.ItemInHandRenderer.renderHandsWithItems(ItemInHandRenderer.java:411)
	at knot//net.minecraft.client.renderer.GameRenderer.renderItemInHand(GameRenderer.java:455)
	at knot//net.minecraft.client.renderer.GameRenderer.renderLevel(GameRenderer.java:745)
	at knot//net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:506)
	at knot//net.minecraft.client.Minecraft.runTick(Minecraft.java:1361)
	at knot//net.minecraft.client.Minecraft.run(Minecraft.java:947)
	at knot//net.minecraft.client.main.Main.main(Main.java:265)
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:480)
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
	at net.fabricmc.devlaunchinjector.Main.main(Main.java:86)
commented

Issue was on my side. I oversaw something, sorry