aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/render
diff options
context:
space:
mode:
authorMartin Robertz <dream-master@gmx.net>2024-05-20 13:09:07 +0200
committerGitHub <noreply@github.com>2024-05-20 13:09:07 +0200
commitac27780ba64058b0e8b0bb0e2d9403eaa0c4c590 (patch)
tree5adc64e1fd1a222333e9a5100e9638aa549d2be5 /src/main/java/gregtech/common/render
parent5c15a6d67edec1555023c40a40411db3e3614773 (diff)
downloadGT5-Unofficial-ac27780ba64058b0e8b0bb0e2d9403eaa0c4c590.tar.gz
GT5-Unofficial-ac27780ba64058b0e8b0bb0e2d9403eaa0c4c590.tar.bz2
GT5-Unofficial-ac27780ba64058b0e8b0bb0e2d9403eaa0c4c590.zip
Reducing allocation (#2601)
* Add IAllSidedTexturedTileEntity to reduce memory overhead for ore textures (cherry picked from commit 274918800a3bf728e1db88e2d22b14cb6eb1a2e5) * Cache texture for ore, since it doesn't change during the game obviously (cherry picked from commit 45a2fe43f2cdb33fa7c0b05a4b8e4531fd2706a6) * Reduce allocations for inventory ores rendering (cherry picked from commit 5ed6526436e9b3a0586f37eac460f707636a102d) --------- Co-authored-by: SKProCH <skproch@yandex.ru>
Diffstat (limited to 'src/main/java/gregtech/common/render')
-rw-r--r--src/main/java/gregtech/common/render/GT_Renderer_Block.java24
1 files changed, 18 insertions, 6 deletions
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 0970687c4f..da0d68d555 100644
--- a/src/main/java/gregtech/common/render/GT_Renderer_Block.java
+++ b/src/main/java/gregtech/common/render/GT_Renderer_Block.java
@@ -46,6 +46,7 @@ import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.interfaces.ITexture;
import gregtech.api.interfaces.metatileentity.IMetaTileEntity;
+import gregtech.api.interfaces.tileentity.IAllSidedTexturedTileEntity;
import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.interfaces.tileentity.IPipeRenderedTileEntity;
import gregtech.api.interfaces.tileentity.ITexturedTileEntity;
@@ -88,6 +89,16 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler {
textureArray[5] = pipeRenderedTileEntity.getTextureCovered(EAST);
return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, textureArray);
}
+ if (tTileEntity instanceof IAllSidedTexturedTileEntity allSidedTexturedTileEntity) {
+ ITexture[] texture = allSidedTexturedTileEntity.getTexture(aBlock);
+ textureArray[0] = texture;
+ textureArray[1] = texture;
+ textureArray[2] = texture;
+ textureArray[3] = texture;
+ textureArray[4] = texture;
+ textureArray[5] = texture;
+ 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);
@@ -545,12 +556,13 @@ public class GT_Renderer_Block implements ISimpleBlockRenderingHandler {
aBlock.setBlockBoundsForItemRender();
aRenderer.setRenderBoundsFromBlock(aBlock);
// 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);
+ ITexture[] texture = tTileEntity.getTexture(aBlock);
+ renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, texture, true);
+ renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, texture, true);
+ renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, texture, true);
+ renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, texture, true);
+ renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, texture, true);
+ renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, texture, true);
// spotless:on
} else if (aMeta > 0 && (aMeta < GregTech_API.METATILEENTITIES.length)
&& aBlock instanceof GT_Block_Machines