@@ -0,0 +1,1994 @@
+package com.infinityraider.infinitylib.render;%0A%0Aimport com.google.common.collect.ImmutableList;%0Aimport com.google.common.collect.Maps;%0Aimport net.minecraft.client.renderer.model.BakedQuad;%0Aimport net.minecraft.util.Direction;%0Aimport net.minecraftforge.api.distmarker.Dist;%0Aimport net.minecraftforge.api.distmarker.OnlyIn;%0A%0Aimport javax.annotation.Nullable;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0Aimport java.util.Map;%0Aimport java.util.function.Function;%0A%0A@OnlyIn(Dist.CLIENT)%0Apublic class QuadCache %7B%0A    private final Map%3CDirection, SafeQuadStore%3E dirQuads;%0A    private final SafeQuadStore nullQuads;%0A%0A    public QuadCache(Function%3CDirection, List%3CBakedQuad%3E%3E quadBaker) %7B%0A        this.dirQuads = Maps.newConcurrentMap();%0A        Arrays.stream(Direction.values()).forEach(face -%3E dirQuads.put(face, new SafeQuadStore(face, quadBaker)));%0A        this.nullQuads = new SafeQuadStore(null, quadBaker);%0A    %7D%0A%0A    public List%3CBakedQuad%3E getQuads(@Nullable Direction face) %7B%0A        return face == null ? this.nullQuads.getQuads() : this.dirQuads.get(face).getQuads();%0A    %7D%0A%0A    private static final class SafeQuadStore %7B%0A        private final Direction face;%0A        private final Function%3CDirection, List%3CBakedQuad%3E%3E quadBaker;%0A%0A        private List%3CBakedQuad%3E quads;%0A        private boolean baking;%0A%0A        private SafeQuadStore(@Nullable Direction face, Function%3CDirection, List%3CBakedQuad%3E%3E quadBaker) %7B%0A            this.face = face;%0A            this.quadBaker = quadBaker;%0A        %7D%0A%0A        @Nullable%0A        public Direction getFace() %7B%0A            return this.face;%0A        %7D%0A%0A        public List%3CBakedQuad%3E getQuads() %7B%0A            if (this.quads == null) %7B%0A                if (this.baking) %7B%0A                    return ImmutableList.of();%0A                %7D else %7B%0A                    this.baking = true;%0A                    this.quads = ImmutableList.copyOf(this.quadBaker.apply(this.getFace()));%0A                %7D%0A            %7D%0A            return this.quads;%0A        %7D%0A    %7D%0A%7D%0A

Create threadsafe QuadCache