aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Mitchell <jason@puzzle.io>2024-03-09 09:24:14 -0800
committerGitHub <noreply@github.com>2024-03-09 09:24:14 -0800
commit50dfbb44acdd28bc183dc58b9cd40d5ba5121685 (patch)
treed1af73a863cebf5f31cc7859c5cb351ecbf81cdc /src
parent4ed426e1cb3c63b4d0fa5387da78cd7618b9ee50 (diff)
downloadGT5-Unofficial-50dfbb44acdd28bc183dc58b9cd40d5ba5121685.tar.gz
GT5-Unofficial-50dfbb44acdd28bc183dc58b9cd40d5ba5121685.tar.bz2
GT5-Unofficial-50dfbb44acdd28bc183dc58b9cd40d5ba5121685.zip
Seems slightly more threadsafe (#1)
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java91
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererGlasBlock.java42
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java8
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java2
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks2.java2
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java4
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java2
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java3
8 files changed, 65 insertions, 89 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java
index d45262ad16..99733ef212 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/BW_Renderer_Block_Ores.java
@@ -30,18 +30,26 @@ import org.lwjgl.opengl.GL11;
import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Block_TE;
import com.github.bartimaeusnek.bartworks.system.material.BW_MetaGenerated_Blocks;
+import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import gregtech.GT_Mod;
+@ThreadSafeISBRH(perThread = true)
public class BW_Renderer_Block_Ores implements ISimpleBlockRenderingHandler {
- public static BW_Renderer_Block_Ores INSTANCE = new BW_Renderer_Block_Ores();
- public final int mRenderID = RenderingRegistry.getNextAvailableRenderId();
+ public static BW_Renderer_Block_Ores INSTANCE;
+ public static int renderID;
public static final float blockMin = 0.0F;
public static final float blockMax = 1.0F;
+ public static void register() {
+ renderID = RenderingRegistry.getNextAvailableRenderId();
+ INSTANCE = new BW_Renderer_Block_Ores();
+ RenderingRegistry.registerBlockHandler(INSTANCE);
+ }
+
@Override
public void renderInventoryBlock(Block aBlock, int aMeta, int modelId, RenderBlocks aRenderer) {
BW_MetaGenerated_Block_TE tTileEntity = ((BW_MetaGenerated_Blocks) aBlock).getProperTileEntityForRendering();
@@ -112,71 +120,32 @@ public class BW_Renderer_Block_Ores implements ISimpleBlockRenderingHandler {
aRenderer.useInventoryTint = false;
}
+ // spotless:off
@Override
- public boolean renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int modelId,
- RenderBlocks aRenderer) {
- BW_MetaGenerated_Block_TE tTileEntity = ((BW_MetaGenerated_Blocks) aBlock).getProperTileEntityForRendering();
- tTileEntity.mMetaData = ((BW_MetaGenerated_Block_TE) aWorld.getTileEntity(aX, aY, aZ)).mMetaData;
+ public boolean renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int modelId, RenderBlocks aRenderer) {
+ BW_MetaGenerated_Blocks tBlock = (BW_MetaGenerated_Blocks) aBlock;
+ if(tBlock == null) return false;
+
+ BW_MetaGenerated_Block_TE fakeTileEntity = tBlock.getProperTileEntityForRendering(); // meh
+ if(fakeTileEntity == null) return false;
+
+ BW_MetaGenerated_Block_TE actualTileEntity = (BW_MetaGenerated_Block_TE) aWorld.getTileEntity(aX, aY, aZ);
+ if(actualTileEntity == null) return false;
+
+ fakeTileEntity.mMetaData = actualTileEntity.mMetaData;
aRenderer.useInventoryTint = false;
aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax);
aRenderer.enableAO = Minecraft.isAmbientOcclusionEnabled() && GT_Mod.gregtechproxy.mRenderTileAmbientOcclusion;
aRenderer.setRenderBoundsFromBlock(aBlock);
- renderNegativeYFacing(
- aWorld,
- aRenderer,
- aBlock,
- aX,
- aY,
- aZ,
- tTileEntity.getTexture(aBlock, ForgeDirection.DOWN),
- true);
- renderPositiveYFacing(
- aWorld,
- aRenderer,
- aBlock,
- aX,
- aY,
- aZ,
- tTileEntity.getTexture(aBlock, ForgeDirection.UP),
- true);
- renderNegativeZFacing(
- aWorld,
- aRenderer,
- aBlock,
- aX,
- aY,
- aZ,
- tTileEntity.getTexture(aBlock, ForgeDirection.NORTH),
- true);
- renderPositiveZFacing(
- aWorld,
- aRenderer,
- aBlock,
- aX,
- aY,
- aZ,
- tTileEntity.getTexture(aBlock, ForgeDirection.SOUTH),
- true);
- renderNegativeXFacing(
- aWorld,
- aRenderer,
- aBlock,
- aX,
- aY,
- aZ,
- tTileEntity.getTexture(aBlock, ForgeDirection.WEST),
- true);
- renderPositiveXFacing(
- aWorld,
- aRenderer,
- aBlock,
- aX,
- aY,
- aZ,
- tTileEntity.getTexture(aBlock, ForgeDirection.EAST),
- true);
+ renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.DOWN), true);
+ renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.UP), true);
+ renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.NORTH), true);
+ renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.SOUTH), true);
+ renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.WEST), true);
+ renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, fakeTileEntity.getTexture(aBlock, ForgeDirection.EAST), true);
return true;
}
+ // spotless:on
@Override
public boolean shouldRender3DInInventory(int modelId) {
@@ -185,6 +154,6 @@ public class BW_Renderer_Block_Ores implements ISimpleBlockRenderingHandler {
@Override
public int getRenderId() {
- return this.mRenderID;
+ return renderID;
}
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererGlasBlock.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererGlasBlock.java
index de1d90a3f4..ce87e4a68a 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererGlasBlock.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererGlasBlock.java
@@ -23,6 +23,7 @@ import org.lwjgl.opengl.GL11;
import com.github.bartimaeusnek.bartworks.common.blocks.BW_GlasBlocks;
import com.github.bartimaeusnek.bartworks.common.blocks.BW_GlasBlocks2;
import com.github.bartimaeusnek.bartworks.common.loaders.ItemRegistry;
+import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
@@ -30,10 +31,17 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
+@ThreadSafeISBRH(perThread = false)
public class RendererGlasBlock implements ISimpleBlockRenderingHandler {
- public static final int RID = RenderingRegistry.getNextAvailableRenderId();
- public static final RendererGlasBlock instance = new RendererGlasBlock();
+ public static int renderID;
+ public static RendererGlasBlock INSTANCE;
+
+ public static void register() {
+ renderID = RenderingRegistry.getNextAvailableRenderId();
+ INSTANCE = new RendererGlasBlock();
+ RenderingRegistry.registerBlockHandler(INSTANCE);
+ }
@Override
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
@@ -69,33 +77,27 @@ public class RendererGlasBlock implements ISimpleBlockRenderingHandler {
GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
+ // spotless:off
@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId,
- RenderBlocks renderer) {
+ RenderBlocks renderer) {
if (block instanceof BW_GlasBlocks) {
renderer.renderStandardBlock(ItemRegistry.bw_fake_glasses, x, y, z);
- renderer.renderStandardBlockWithColorMultiplier(
- block,
- x,
- y,
- z,
- ((BW_GlasBlocks) block).getColor(world.getBlockMetadata(x, y, z))[0] / 255f,
- ((BW_GlasBlocks) block).getColor(world.getBlockMetadata(x, y, z))[1] / 255f,
- ((BW_GlasBlocks) block).getColor(world.getBlockMetadata(x, y, z))[2] / 255f);
+ renderer.renderStandardBlockWithColorMultiplier(block, x, y, z,
+ ((BW_GlasBlocks) block).getColor(world.getBlockMetadata(x, y, z))[0] / 255f,
+ ((BW_GlasBlocks) block).getColor(world.getBlockMetadata(x, y, z))[1] / 255f,
+ ((BW_GlasBlocks) block).getColor(world.getBlockMetadata(x, y, z))[2] / 255f);
}
if (block instanceof BW_GlasBlocks2) {
renderer.renderStandardBlock(ItemRegistry.bw_fake_glasses2, x, y, z);
- renderer.renderStandardBlockWithColorMultiplier(
- block,
- x,
- y,
- z,
- ((BW_GlasBlocks2) block).getColor(world.getBlockMetadata(x, y, z))[0] / 255f,
- ((BW_GlasBlocks2) block).getColor(world.getBlockMetadata(x, y, z))[1] / 255f,
- ((BW_GlasBlocks2) block).getColor(world.getBlockMetadata(x, y, z))[2] / 255f);
+ renderer.renderStandardBlockWithColorMultiplier(block, x, y, z,
+ ((BW_GlasBlocks2) block).getColor(world.getBlockMetadata(x, y, z))[0] / 255f,
+ ((BW_GlasBlocks2) block).getColor(world.getBlockMetadata(x, y, z))[1] / 255f,
+ ((BW_GlasBlocks2) block).getColor(world.getBlockMetadata(x, y, z))[2] / 255f);
}
return true;
}
+ // spotless:on
@Override
public boolean shouldRender3DInInventory(int modelId) {
@@ -104,6 +106,6 @@ public class RendererGlasBlock implements ISimpleBlockRenderingHandler {
@Override
public int getRenderId() {
- return RendererGlasBlock.RID;
+ return RendererGlasBlock.renderID;
}
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java
index 6e1bffcd08..6af2f2df7d 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/client/renderer/RendererSwitchingColorFluid.java
@@ -28,12 +28,14 @@ import com.github.bartimaeusnek.bartworks.common.blocks.BioFluidBlock;
import com.github.bartimaeusnek.bartworks.common.loaders.FluidLoader;
import com.github.bartimaeusnek.bartworks.common.tileentities.multis.GT_TileEntity_BioVat;
import com.github.bartimaeusnek.bartworks.util.Coords;
+import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
+@ThreadSafeISBRH(perThread = false)
public class RendererSwitchingColorFluid implements ISimpleBlockRenderingHandler {
private static final float LIGHT_Y_NEG = 0.5f;
@@ -43,7 +45,11 @@ public class RendererSwitchingColorFluid implements ISimpleBlockRenderingHandler
private static final float THREE_QUARTERS_FILLED = 0.875f;
private static final double RENDER_OFFSET = 0.0010000000474974513;
- public static RendererSwitchingColorFluid instance = new RendererSwitchingColorFluid();
+ public static RendererSwitchingColorFluid instance;
+
+ public static void register() {
+ instance = new RendererSwitchingColorFluid();
+ }
private float getFluidHeightAverage(float[] flow) {
float total = 0.0f;
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java
index a2f5e520b9..5c596a0b5e 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks.java
@@ -172,7 +172,7 @@ public class BW_GlasBlocks extends BW_Blocks {
@Override
public int getRenderType() {
- if (!this.fake && SideReference.Side.Client) return RendererGlasBlock.RID;
+ if (!this.fake && SideReference.Side.Client) return RendererGlasBlock.renderID;
return 0;
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks2.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks2.java
index 337db90324..24033787c4 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks2.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/blocks/BW_GlasBlocks2.java
@@ -164,7 +164,7 @@ public class BW_GlasBlocks2 extends BW_Blocks {
@Override
public int getRenderType() {
- if (!this.fake && SideReference.Side.Client) return RendererGlasBlock.RID;
+ if (!this.fake && SideReference.Side.Client) return RendererGlasBlock.renderID;
return 0;
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java
index 0c92005f6f..c843297771 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/loaders/FluidLoader.java
@@ -104,8 +104,8 @@ public class FluidLoader {
GameRegistry.registerBlock(bioFluidBlock, "coloredFluidBlock");
GameRegistry.registerTileEntity(BWTileEntityDimIDBridge.class, "bwTEDimIDBridge");
if (SideReference.Side.Client) {
- RenderingRegistry.registerBlockHandler(RendererSwitchingColorFluid.instance);
- RenderingRegistry.registerBlockHandler(RendererGlasBlock.instance);
+ RendererSwitchingColorFluid.register();
+ RendererGlasBlock.register();
}
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java
index c9dd83db6c..84bcb5ffef 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/BW_MetaGenerated_Blocks.java
@@ -87,7 +87,7 @@ public abstract class BW_MetaGenerated_Blocks extends BW_TileEntityContainer {
@Override
public int getRenderType() {
if (BW_Renderer_Block_Ores.INSTANCE == null) return super.getRenderType();
- return BW_Renderer_Block_Ores.INSTANCE.mRenderID;
+ return BW_Renderer_Block_Ores.INSTANCE.renderID;
}
@Override
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java
index b9855ab1a3..19e7437524 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/WerkstoffLoader.java
@@ -121,7 +121,6 @@ import com.github.bartimaeusnek.bartworks.util.log.DebugLog;
import com.github.bartimaeusnek.crossmod.cls.CLSCompat;
import com.google.common.collect.HashBiMap;
-import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.ProgressManager;
import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.enums.Element;
@@ -1737,7 +1736,7 @@ public class WerkstoffLoader {
}
static void gameRegistryHandler() {
- if (SideReference.Side.Client) RenderingRegistry.registerBlockHandler(BW_Renderer_Block_Ores.INSTANCE);
+ if (SideReference.Side.Client) BW_Renderer_Block_Ores.register();
GameRegistry.registerTileEntity(BW_MetaGeneratedOreTE.class, "bw.blockoresTE");
GameRegistry.registerTileEntity(BW_MetaGeneratedSmallOreTE.class, "bw.blockoresSmallTE");