Make rendering blocks thread safe with Angelica (#65)

This commit is contained in:
DarkShadow44 authored and GitHub committed 2025-09-05 09:48:11 +02:00
1 parent 4ce0134bed
commit 40144a0fa5
6 files changed
+57 -18

No files matched your search

@@ -16,7 +16,13 @@ import team.chisel.ctmlib.TextureSubmap;
public class SubmapManagerSlab implements ISubmapManager {
@SideOnly(Side.CLIENT)
private RenderBlocksCTM rb;
private static ThreadLocal<RenderBlocksCTM> renderBlocksThreadLocal;
private static void initStatics() {
if (renderBlocksThreadLocal == null) {
renderBlocksThreadLocal = ThreadLocal.withInitial(RenderBlocksCTM::new);
}
}
private TextureSubmap submap;
private TextureSubmap submapSmall;
@@ -49,9 +55,8 @@ public class SubmapManagerSlab implements ISubmapManager {
@Override
@SideOnly(Side.CLIENT)
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
if (rb == null) {
rb = new RenderBlocksCTM();
}
initStatics();
RenderBlocksCTM rb = renderBlocksThreadLocal.get();
rb.setRenderBoundsFromBlock(block);
rb.submap = submap;
rb.submapSmall = submapSmall;