mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-19 03:59:15 +00:00
Angelica Thread Safety
This commit is contained in:
1 parent
e9e63d6fc5
commit
06ec360694
15 files changed
+82
-38
No files matched your search
@@ -83,7 +83,7 @@ public class CTM {
|
||||
|
||||
public Optional<Boolean> disableObscuredFaceCheck = Optional.absent();
|
||||
|
||||
protected TIntObjectMap<Dir[]> submapMap = new TIntObjectHashMap<Dir[]>();
|
||||
protected TIntObjectMap<Dir[]> submapMap = new TIntObjectHashMap<>();
|
||||
protected EnumMap<Dir, Boolean> connectionMap = Maps.newEnumMap(Dir.class);
|
||||
|
||||
protected CTM() {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
package team.chisel.ctmlib;
|
||||
|
||||
import cpw.mods.fml.common.ModAPIManager;
|
||||
import team.chisel.Tags;
|
||||
|
||||
public class CTMLib {
|
||||
|
||||
public static final String VERSION = "GRADLETOKEN_VERSION";
|
||||
public static final String VERSION = Tags.VERSION;
|
||||
|
||||
private static boolean chiselPresent, chiselInitialized;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
|
||||
*/
|
||||
public class CTMRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
private int renderId;
|
||||
private final int renderId;
|
||||
|
||||
public CTMRenderer(int renderId) {
|
||||
this.renderId = renderId;
|
||||
|
||||
@@ -113,10 +113,11 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
private static double u, v, xDiff, yDiff, zDiff, uDiff, vDiff;
|
||||
|
||||
void render(RenderBlocksCTM inst, ForgeDirection normal, int cacheID) {
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
if (inst.enableAO) {
|
||||
Tessellator.instance
|
||||
.setColorOpaque_F(inst.redCache[cacheID], inst.grnCache[cacheID], inst.bluCache[cacheID]);
|
||||
Tessellator.instance.setBrightness(inst.lightingCache[cacheID]);
|
||||
tessellator.setColorOpaque_F(inst.redCache[cacheID], inst.grnCache[cacheID], inst.bluCache[cacheID]);
|
||||
tessellator.setBrightness(inst.lightingCache[cacheID]);
|
||||
}
|
||||
|
||||
u = cacheID == 1 || cacheID == 2 ? inst.maxU : inst.minU;
|
||||
@@ -151,7 +152,7 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
xDiff = yDiff = zDiff = 1;
|
||||
}
|
||||
|
||||
Tessellator.instance.addVertexWithUV(
|
||||
tessellator.addVertexWithUV(
|
||||
inst.renderMinX + (x * xDiff),
|
||||
inst.renderMinY + (y * yDiff),
|
||||
inst.renderMinZ + (z * zDiff),
|
||||
@@ -225,7 +226,6 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
renderMaxX = renderMaxY = renderMaxZ = 1;
|
||||
}
|
||||
|
||||
protected Tessellator tessellator = Tessellator.instance;
|
||||
protected double minU, maxU;
|
||||
protected double minV, maxV;
|
||||
protected int[] lightingCache = new int[4];
|
||||
@@ -253,16 +253,17 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
by = y;
|
||||
bz = z;
|
||||
meta = Minecraft.getMinecraft().theWorld.getBlockMetadata(x, y, z);
|
||||
final Tessellator tessellator = Tessellator.instance;
|
||||
|
||||
Tessellator.instance.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
Tessellator.instance.addTranslation(x, y, z);
|
||||
tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F);
|
||||
tessellator.addTranslation(x, y, z);
|
||||
if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) {
|
||||
setOverrideBlockTexture(rendererOld.overrideBlockTexture);
|
||||
}
|
||||
inWorld = true;
|
||||
boolean res = super.renderStandardBlock(block, x, y, z);
|
||||
inWorld = false;
|
||||
Tessellator.instance.addTranslation(-x, -y, -z);
|
||||
tessellator.addTranslation(-x, -y, -z);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@ import lombok.Getter;
|
||||
public class SubmapManagerCTM implements ISubmapManager {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static RenderBlocksCTM rb;
|
||||
private static final ThreadLocal<RenderBlocksCTM> renderBlocksThreadLocal = ThreadLocal
|
||||
.withInitial(RenderBlocksCTM::new);
|
||||
|
||||
@Getter
|
||||
private TextureSubmap submap, submapSmall;
|
||||
@@ -54,9 +55,7 @@ public class SubmapManagerCTM implements ISubmapManager {
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public RenderBlocks createRenderContext(RenderBlocks rendererOld, Block block, IBlockAccess world) {
|
||||
if (rb == null) {
|
||||
rb = new RenderBlocksCTM();
|
||||
}
|
||||
RenderBlocksCTM rb = renderBlocksThreadLocal.get();
|
||||
rb.setRenderBoundsFromBlock(block);
|
||||
rb.submap = submap;
|
||||
rb.submapSmall = submapSmall;
|
||||
|
||||
Reference in new issue
Block a user