aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r--src/main/java/gregtech/common/GT_Client.java2
-rw-r--r--src/main/java/gregtech/common/render/GT_Renderer_Block.java276
2 files changed, 67 insertions, 211 deletions
diff --git a/src/main/java/gregtech/common/GT_Client.java b/src/main/java/gregtech/common/GT_Client.java
index a4d41366d4..4cb063b3b5 100644
--- a/src/main/java/gregtech/common/GT_Client.java
+++ b/src/main/java/gregtech/common/GT_Client.java
@@ -622,7 +622,7 @@ public class GT_Client extends GT_Proxy implements Runnable {
@Override
public void onLoad() {
super.onLoad();
- new GT_Renderer_Block();
+ GT_Renderer_Block.register();
new GT_MultiTile_Renderer();
new GT_RenderDrone();
metaGeneratedItemRenderer = new GT_MetaGenerated_Item_Renderer();
diff --git a/src/main/java/gregtech/common/render/GT_Renderer_Block.java b/src/main/java/gregtech/common/render/GT_Renderer_Block.java
index 7ed875aa00..0970687c4f 100644
--- a/src/main/java/gregtech/common/render/GT_Renderer_Block.java
+++ b/src/main/java/gregtech/common/render/GT_Renderer_Block.java
@@ -36,6 +36,8 @@ import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
+import com.gtnewhorizons.angelica.api.ThreadSafeISBRH;
+
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.relauncher.Side;
@@ -53,6 +55,7 @@ import gregtech.common.blocks.GT_Block_Machines;
import gregtech.common.blocks.GT_Block_Ores_Abstract;
import gregtech.common.blocks.GT_TileEntity_Ores;
+@ThreadSafeISBRH(perThread = true)
public class GT_Renderer_Block implements ISimpleBlockRenderingHandler {
public static final float blockMin = 0.0F;
@@ -60,52 +63,44 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler {
private static final float coverThickness = blockMax / 8.0F;
private static final float coverInnerMin = blockMin + coverThickness;
private static final float coverInnerMax = blockMax - coverThickness;
+
+ @Deprecated
public static GT_Renderer_Block INSTANCE;
- public final int mRenderID;
+ public static int mRenderID;
- public GT_Renderer_Block() {
- this.mRenderID = RenderingRegistry.getNextAvailableRenderId();
- INSTANCE = this;
- RenderingRegistry.registerBlockHandler(this);
+ public static void register() {
+ mRenderID = RenderingRegistry.getNextAvailableRenderId();
+ INSTANCE = new GT_Renderer_Block();
+ RenderingRegistry.registerBlockHandler(INSTANCE);
}
- public static boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock,
+ private final ITexture[][] textureArray = new ITexture[6][];
+
+ public boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock,
RenderBlocks aRenderer) {
final TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ);
- if ((tTileEntity instanceof IPipeRenderedTileEntity)) {
- return renderStandardBlock(
- aWorld,
- aX,
- aY,
- aZ,
- aBlock,
- aRenderer,
- new ITexture[][] { ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered(DOWN),
- ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered(UP),
- ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered(NORTH),
- ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered(SOUTH),
- ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered(WEST),
- ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered(EAST) });
- }
- if ((tTileEntity instanceof ITexturedTileEntity)) {
- return renderStandardBlock(
- aWorld,
- aX,
- aY,
- aZ,
- aBlock,
- aRenderer,
- new ITexture[][] { ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, DOWN),
- ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, UP),
- ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, NORTH),
- ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, SOUTH),
- ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, WEST),
- ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, EAST) });
+ if (tTileEntity instanceof IPipeRenderedTileEntity pipeRenderedTileEntity) {
+ textureArray[0] = pipeRenderedTileEntity.getTextureCovered(DOWN);
+ textureArray[1] = pipeRenderedTileEntity.getTextureCovered(UP);
+ textureArray[2] = pipeRenderedTileEntity.getTextureCovered(NORTH);
+ textureArray[3] = pipeRenderedTileEntity.getTextureCovered(SOUTH);
+ textureArray[4] = pipeRenderedTileEntity.getTextureCovered(WEST);
+ textureArray[5] = pipeRenderedTileEntity.getTextureCovered(EAST);
+ return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, textureArray);
+ }
+ if (tTileEntity instanceof ITexturedTileEntity texturedTileEntity) {
+ textureArray[0] = texturedTileEntity.getTexture(aBlock, DOWN);
+ textureArray[1] = texturedTileEntity.getTexture(aBlock, UP);
+ textureArray[2] = texturedTileEntity.getTexture(aBlock, NORTH);
+ textureArray[3] = texturedTileEntity.getTexture(aBlock, SOUTH);
+ textureArray[4] = texturedTileEntity.getTexture(aBlock, WEST);
+ textureArray[5] = texturedTileEntity.getTexture(aBlock, EAST);
+ return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, textureArray);
}
return false;
}
- public static boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock,
+ public boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock,
RenderBlocks aRenderer, ITexture[][] aTextures) {
aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax);
aRenderer.setRenderBoundsFromBlock(aBlock);
@@ -119,7 +114,11 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler {
return true;
}
- public static boolean renderPipeBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock,
+ final ITexture[][] tIcons = new ITexture[VALID_DIRECTIONS.length][];
+ final ITexture[][] tCovers = new ITexture[VALID_DIRECTIONS.length][];
+ final boolean[] tIsCovered = new boolean[VALID_DIRECTIONS.length];
+
+ public boolean renderPipeBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock,
IPipeRenderedTileEntity aTileEntity, RenderBlocks aRenderer) {
final byte aConnections = aTileEntity.getConnections();
if ((aConnections & (HAS_FRESHFOAM | HAS_HARDENEDFOAM)) != 0) {
@@ -132,17 +131,13 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler {
// Range of block occupied by pipe
final float pipeMin = (blockMax - thickness) / 2.0F;
final float pipeMax = blockMax - pipeMin;
- final boolean[] tIsCovered = new boolean[VALID_DIRECTIONS.length];
+
for (int i = 0; i < VALID_DIRECTIONS.length; i++) {
- tIsCovered[i] = (aTileEntity.getCoverIDAtSide(ForgeDirection.getOrientation(i)) != 0);
- }
+ final ForgeDirection iSide = VALID_DIRECTIONS[i];
+ tIsCovered[i] = (aTileEntity.getCoverIDAtSide(iSide) != 0);
+ tCovers[i] = aTileEntity.getTexture(aBlock, iSide);
+ tIcons[i] = aTileEntity.getTextureUncovered(iSide);
- final ITexture[][] tIcons = new ITexture[VALID_DIRECTIONS.length][];
- final ITexture[][] tCovers = new ITexture[VALID_DIRECTIONS.length][];
- for (final ForgeDirection iSide : ForgeDirection.VALID_DIRECTIONS) {
- final int iOrdinalSide = iSide.ordinal();
- tCovers[iOrdinalSide] = aTileEntity.getTexture(aBlock, iSide);
- tIcons[iOrdinalSide] = aTileEntity.getTextureUncovered(iSide);
}
switch (aConnections) {
@@ -535,6 +530,8 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler {
}
}
+ final GT_TileEntity_Ores tTileEntity = new GT_TileEntity_Ores();
+
@Override
public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) {
aRenderer.enableAO = false;
@@ -543,65 +540,18 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler {
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
if (aBlock instanceof GT_Block_Ores_Abstract) {
- final GT_TileEntity_Ores tTileEntity = new GT_TileEntity_Ores();
tTileEntity.mMetaData = ((short) aMeta);
aBlock.setBlockBoundsForItemRender();
aRenderer.setRenderBoundsFromBlock(aBlock);
- renderNegativeYFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- tTileEntity.getTexture(aBlock, ForgeDirection.DOWN),
- true);
- renderPositiveYFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- tTileEntity.getTexture(aBlock, ForgeDirection.UP),
- true);
- renderNegativeZFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- tTileEntity.getTexture(aBlock, ForgeDirection.NORTH),
- true);
- renderPositiveZFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- tTileEntity.getTexture(aBlock, ForgeDirection.SOUTH),
- true);
- renderNegativeXFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- tTileEntity.getTexture(aBlock, ForgeDirection.WEST),
- true);
- renderPositiveXFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- tTileEntity.getTexture(aBlock, ForgeDirection.EAST),
- true);
+ // spotless:off
+ renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, ForgeDirection.DOWN), true);
+ renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, ForgeDirection.UP), true);
+ renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, ForgeDirection.NORTH), true);
+ renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, ForgeDirection.SOUTH), true);
+ renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, ForgeDirection.WEST), true);
+ renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, ForgeDirection.EAST), true);
+ // spotless:on
} else if (aMeta > 0 && (aMeta < GregTech_API.METATILEENTITIES.length)
&& aBlock instanceof GT_Block_Machines
&& (GregTech_API.METATILEENTITIES[aMeta] != null)
@@ -629,6 +579,7 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler {
final IGregTechTileEntity iGregTechTileEntity = tMetaTileEntity.getBaseMetaTileEntity();
+ // spotless:off
if ((iGregTechTileEntity instanceof IPipeRenderedTileEntity renderedPipe)
&& (tMetaTileEntity instanceof MetaPipeEntity pipeEntity)) {
final float tThickness = renderedPipe.getThickNess();
@@ -637,116 +588,21 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler {
aBlock.setBlockBounds(blockMin, pipeMin, pipeMin, blockMax, pipeMax, pipeMax);
aRenderer.setRenderBoundsFromBlock(aBlock);
- renderNegativeYFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- pipeEntity.getTexture(iGregTechTileEntity, DOWN, (CONNECTED_WEST | CONNECTED_EAST), -1, false, false),
- true);
- renderPositiveYFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- pipeEntity.getTexture(iGregTechTileEntity, UP, (CONNECTED_WEST | CONNECTED_EAST), -1, false, false),
- true);
- renderNegativeZFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- pipeEntity.getTexture(iGregTechTileEntity, NORTH, (CONNECTED_WEST | CONNECTED_EAST), -1, false, false),
- true);
- renderPositiveZFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- pipeEntity.getTexture(iGregTechTileEntity, SOUTH, (CONNECTED_WEST | CONNECTED_EAST), -1, false, false),
- true);
- renderNegativeXFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- pipeEntity.getTexture(iGregTechTileEntity, WEST, (CONNECTED_WEST | CONNECTED_EAST), -1, true, false),
- true);
- renderPositiveXFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- pipeEntity.getTexture(iGregTechTileEntity, EAST, (CONNECTED_WEST | CONNECTED_EAST), -1, true, false),
- true);
+ renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, pipeEntity.getTexture(iGregTechTileEntity, DOWN, (CONNECTED_WEST | CONNECTED_EAST), -1, false, false), true);
+ renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, pipeEntity.getTexture(iGregTechTileEntity, UP, (CONNECTED_WEST | CONNECTED_EAST), -1, false, false), true);
+ renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, pipeEntity.getTexture(iGregTechTileEntity, NORTH, (CONNECTED_WEST | CONNECTED_EAST), -1, false, false), true);
+ renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, pipeEntity.getTexture(iGregTechTileEntity, SOUTH, (CONNECTED_WEST | CONNECTED_EAST), -1, false, false), true);
+ renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, pipeEntity.getTexture(iGregTechTileEntity, WEST, (CONNECTED_WEST | CONNECTED_EAST), -1, true, false), true);
+ renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, pipeEntity.getTexture(iGregTechTileEntity, EAST, (CONNECTED_WEST | CONNECTED_EAST), -1, true, false), true);
} else {
- renderNegativeYFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- tMetaTileEntity.getTexture(iGregTechTileEntity, DOWN, WEST, -1, true, false),
- true);
- renderPositiveYFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- tMetaTileEntity.getTexture(iGregTechTileEntity, UP, WEST, -1, true, false),
- true);
- renderNegativeZFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- tMetaTileEntity.getTexture(iGregTechTileEntity, NORTH, WEST, -1, true, false),
- true);
- renderPositiveZFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- tMetaTileEntity.getTexture(iGregTechTileEntity, SOUTH, WEST, -1, true, false),
- true);
- renderNegativeXFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- tMetaTileEntity.getTexture(iGregTechTileEntity, WEST, WEST, -1, true, false),
- true);
- renderPositiveXFacing(
- null,
- aRenderer,
- aBlock,
- 0,
- 0,
- 0,
- tMetaTileEntity.getTexture(iGregTechTileEntity, EAST, WEST, -1, true, false),
- true);
- }
+ renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, DOWN, WEST, -1, true, false), true);
+ renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, UP, WEST, -1, true, false), true);
+ renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, NORTH, WEST, -1, true, false), true);
+ renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, SOUTH, WEST, -1, true, false), true);
+ renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, WEST, WEST, -1, true, false), true);
+ renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, EAST, WEST, -1, true, false), true);
+ }
+ // spotless:on
}
public static void renderNegativeYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY,