aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorJason Mitchell <mitchej@gmail.com>2024-03-04 02:20:48 -0800
committerGitHub <noreply@github.com>2024-03-04 11:20:48 +0100
commitf3712d3b8dd556087b786a8918904792be231e16 (patch)
treed2d86517c3a8a137398e5fc56892200cbb4931b6 /src/main
parentdc0eb86a4737b73b3bdbf39c6916c19c3aaa8af4 (diff)
downloadGT5-Unofficial-f3712d3b8dd556087b786a8918904792be231e16.tar.gz
GT5-Unofficial-f3712d3b8dd556087b786a8918904792be231e16.tar.bz2
GT5-Unofficial-f3712d3b8dd556087b786a8918904792be231e16.zip
Maybe thread safe (#2523)
* Maybe thread safe * While we're at it, let's reduce allocations by a few orders of magnitude. ~1gb -> 1mb in testing for similar time periods. * use return value of add() again * That's apparently not available on the server side * Spotless apply for branch maybe-thread-safe for #2523 (#2524) spotlessApply --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/gregtech/api/GregTech_API.java5
-rw-r--r--src/main/java/gregtech/api/threads/GT_Runnable_Cable_Update.java40
-rw-r--r--src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java101
-rw-r--r--src/main/java/gregtech/common/GT_Client.java2
-rw-r--r--src/main/java/gregtech/common/render/GT_Renderer_Block.java276
5 files changed, 159 insertions, 265 deletions
diff --git a/src/main/java/gregtech/api/GregTech_API.java b/src/main/java/gregtech/api/GregTech_API.java
index 2e39cd2181..47c99403ab 100644
--- a/src/main/java/gregtech/api/GregTech_API.java
+++ b/src/main/java/gregtech/api/GregTech_API.java
@@ -31,7 +31,6 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import com.google.common.collect.Multimap;
@@ -408,7 +407,7 @@ public class GregTech_API {
*/
public static boolean causeMachineUpdate(World aWorld, int aX, int aY, int aZ) {
if (aWorld != null && !aWorld.isRemote && !isDummyWorld(aWorld)) { // World might be null during World-gen
- GT_Runnable_MachineBlockUpdate.setMachineUpdateValues(aWorld, new ChunkCoordinates(aX, aY, aZ));
+ GT_Runnable_MachineBlockUpdate.setMachineUpdateValues(aWorld, aX, aY, aZ);
return true;
}
return false;
@@ -419,7 +418,7 @@ public class GregTech_API {
if (aWorld == null || aWorld.isRemote || isDummyWorld(aWorld)) {
return false;
} // World might be null during World-gen
- GT_Runnable_Cable_Update.setCableUpdateValues(aWorld, new ChunkCoordinates(aX, aY, aZ));
+ GT_Runnable_Cable_Update.setCableUpdateValues(aWorld, aX, aY, aZ);
return true;
}
diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_Cable_Update.java b/src/main/java/gregtech/api/threads/GT_Runnable_Cable_Update.java
index 31c3c56aa8..4375d21e40 100644
--- a/src/main/java/gregtech/api/threads/GT_Runnable_Cable_Update.java
+++ b/src/main/java/gregtech/api/threads/GT_Runnable_Cable_Update.java
@@ -1,7 +1,6 @@
package gregtech.api.threads;
import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
@@ -13,29 +12,34 @@ import gregtech.common.GT_Proxy;
public class GT_Runnable_Cable_Update extends GT_Runnable_MachineBlockUpdate {
- protected GT_Runnable_Cable_Update(World aWorld, ChunkCoordinates aCoords) {
- super(aWorld, aCoords);
+ protected GT_Runnable_Cable_Update(World aWorld, int posX, int posY, int posZ) {
+ super(aWorld, posX, posY, posZ);
}
- public static void setCableUpdateValues(World aWorld, ChunkCoordinates aCoords) {
+ public static void setCableUpdateValues(World aWorld, int posX, int posY, int posZ) {
if (isEnabled) {
- EXECUTOR_SERVICE.submit(new GT_Runnable_Cable_Update(aWorld, aCoords));
+ EXECUTOR_SERVICE.submit(new GT_Runnable_Cable_Update(aWorld, posX, posY, posZ));
}
}
@Override
public void run() {
+ int posX, posY, posZ;
try {
while (!tQueue.isEmpty()) {
- final ChunkCoordinates aCoords = tQueue.poll();
+ final long packedCoords = tQueue.dequeueLong();
+ posX = unpackLongX(packedCoords);
+ posY = unpackLongY(packedCoords);
+ posZ = unpackLongZ(packedCoords);
+
final TileEntity tTileEntity;
GT_Proxy.TICK_LOCK.lock();
try {
// we dont want to go over cables that are in unloaded chunks
// keeping the lock just to make sure no CME happens
- if (world.blockExists(aCoords.posX, aCoords.posY, aCoords.posZ)) {
- tTileEntity = world.getTileEntity(aCoords.posX, aCoords.posY, aCoords.posZ);
+ if (world.blockExists(posX, posY, posZ)) {
+ tTileEntity = world.getTileEntity(posX, posY, posZ);
} else {
tTileEntity = null;
}
@@ -51,22 +55,24 @@ public class GT_Runnable_Cable_Update extends GT_Runnable_MachineBlockUpdate {
// only add blocks the cable is connected to
if (tTileEntity instanceof BaseMetaPipeEntity metaPipe
&& metaPipe.getMetaTileEntity() instanceof GT_MetaPipeEntity_Cable cable) {
- ChunkCoordinates tCoords;
- for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
+ for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
+ final ForgeDirection side = ForgeDirection.VALID_DIRECTIONS[i];
if (cable.isConnectedAtSide(side)) {
- if (visited.add(
- tCoords = new ChunkCoordinates(
- aCoords.posX + side.offsetX,
- aCoords.posY + side.offsetY,
- aCoords.posZ + side.offsetZ)))
- tQueue.add(tCoords);
+ final long tCoords = asLong(posX + side.offsetX, posY + side.offsetY, posZ + side.offsetZ);
+ if (visited.add(tCoords)) {
+ tQueue.enqueue(tCoords);
+ }
}
}
}
}
} catch (Exception e) {
GT_Mod.GT_FML_LOGGER.error(
- "Well this update was broken... " + mCoords
+ "Well this update was broken... " + initialX
+ + ", "
+ + initialY
+ + ", "
+ + initialZ
+ ", mWorld={"
+ world.getProviderName()
+ " @dimId "
diff --git a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java
index ceb6adfa7a..3670655eaf 100644
--- a/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java
+++ b/src/main/java/gregtech/api/threads/GT_Runnable_MachineBlockUpdate.java
@@ -1,30 +1,59 @@
package gregtech.api.threads;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.Queue;
-import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
+import net.minecraftforge.common.util.ForgeDirection;
import gregtech.GT_Mod;
import gregtech.api.GregTech_API;
import gregtech.api.interfaces.tileentity.IMachineBlockUpdateable;
import gregtech.common.GT_Proxy;
+import it.unimi.dsi.fastutil.longs.LongArrayFIFOQueue;
+import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
+import it.unimi.dsi.fastutil.longs.LongSet;
public class GT_Runnable_MachineBlockUpdate implements Runnable {
+ // Borrowed from Angelica until moving to GTNHLib or something
+ final static int SIZE_BITS_X = 26; // 1 + log2(MathHelper.roundUpToPowerOfTwo(30000000), RoundingMode.UNNECESSARY);
+ final static int SIZE_BITS_Z = SIZE_BITS_X;
+ final static int SIZE_BITS_Y = 64 - SIZE_BITS_X - SIZE_BITS_Z;
+ final static long BITS_X = (1L << SIZE_BITS_X) - 1L;
+ final static long BITS_Y = (1L << SIZE_BITS_Y) - 1L;
+ final static long BITS_Z = (1L << SIZE_BITS_Z) - 1L;
+ final static int BIT_SHIFT_Z = SIZE_BITS_Y;
+ final static int BIT_SHIFT_X = SIZE_BITS_Y + SIZE_BITS_Z;
+
+ static long asLong(int x, int y, int z) {
+ long l = 0L;
+ l |= ((long) x & BITS_X) << BIT_SHIFT_X;
+ l |= ((long) y & BITS_Y) << 0;
+ l |= ((long) z & BITS_Z) << BIT_SHIFT_Z;
+ return l;
+ }
+
+ public static int unpackLongX(long packedPos) {
+ return (int) (packedPos << 64 - BIT_SHIFT_X - SIZE_BITS_X >> 64 - SIZE_BITS_X);
+ }
+
+ public static int unpackLongY(long packedPos) {
+ return (int) (packedPos << 64 - SIZE_BITS_Y >> 64 - SIZE_BITS_Y);
+ }
+
+ public static int unpackLongZ(long packedPos) {
+ return (int) (packedPos << 64 - BIT_SHIFT_Z - SIZE_BITS_Z >> 64 - SIZE_BITS_Z);
+ }
+
// used by runner thread
- protected final ChunkCoordinates mCoords;
+ protected final int initialX, initialY, initialZ;
protected final World world;
- protected final Set<ChunkCoordinates> visited = new HashSet<>(80);
- protected final Queue<ChunkCoordinates> tQueue = new LinkedList<>();
+ protected final LongSet visited = new LongOpenHashSet();
+ protected final LongArrayFIFOQueue tQueue = new LongArrayFIFOQueue();
// Threading
private static final ThreadFactory THREAD_FACTORY = r -> {
@@ -35,11 +64,14 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable {
protected static ExecutorService EXECUTOR_SERVICE;
// This class should never be initiated outside of this class!
- protected GT_Runnable_MachineBlockUpdate(World aWorld, ChunkCoordinates aCoords) {
+ protected GT_Runnable_MachineBlockUpdate(World aWorld, int posX, int posY, int posZ) {
this.world = aWorld;
- this.mCoords = aCoords;
- visited.add(aCoords);
- tQueue.add(aCoords);
+ this.initialX = posX;
+ this.initialY = posY;
+ this.initialZ = posZ;
+ final long coords = asLong(posX, posY, posZ);
+ visited.add(coords);
+ tQueue.enqueue(coords);
}
public static boolean isEnabled() {
@@ -69,9 +101,9 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable {
protected static boolean isEnabled = true;
protected static final ThreadLocal<Boolean> perThreadEnable = ThreadLocal.withInitial(() -> true);
- public static void setMachineUpdateValues(World aWorld, ChunkCoordinates aCoords) {
+ public static void setMachineUpdateValues(World aWorld, int posX, int posY, int posZ) {
if (isEnabled() && isCurrentThreadEnabled()) {
- EXECUTOR_SERVICE.submit(new GT_Runnable_MachineBlockUpdate(aWorld, aCoords));
+ EXECUTOR_SERVICE.submit(new GT_Runnable_MachineBlockUpdate(aWorld, posX, posY, posZ));
}
}
@@ -116,9 +148,14 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable {
@Override
public void run() {
+ int posX, posY, posZ;
try {
while (!tQueue.isEmpty()) {
- final ChunkCoordinates aCoords = tQueue.poll();
+ final long packedCoords = tQueue.dequeueLong();
+ posX = unpackLongX(packedCoords);
+ posY = unpackLongY(packedCoords);
+ posZ = unpackLongZ(packedCoords);
+
final TileEntity tTileEntity;
final boolean isMachineBlock;
@@ -128,10 +165,9 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable {
// ConcurrentModificationException. So, lock that shit.
GT_Proxy.TICK_LOCK.lock();
try {
- tTileEntity = world.getTileEntity(aCoords.posX, aCoords.posY, aCoords.posZ);
- isMachineBlock = GregTech_API.isMachineBlock(
- world.getBlock(aCoords.posX, aCoords.posY, aCoords.posZ),
- world.getBlockMetadata(aCoords.posX, aCoords.posY, aCoords.posZ));
+ tTileEntity = world.getTileEntity(posX, posY, posZ);
+ isMachineBlock = GregTech_API
+ .isMachineBlock(world.getBlock(posX, posY, posZ), world.getBlockMetadata(posX, posY, posZ));
} finally {
GT_Proxy.TICK_LOCK.unlock();
}
@@ -148,25 +184,22 @@ public class GT_Runnable_MachineBlockUpdate implements Runnable {
|| (tTileEntity instanceof IMachineBlockUpdateable
&& ((IMachineBlockUpdateable) tTileEntity).isMachineBlockUpdateRecursive())
|| isMachineBlock) {
- ChunkCoordinates tCoords;
-
- if (visited.add(tCoords = new ChunkCoordinates(aCoords.posX + 1, aCoords.posY, aCoords.posZ)))
- tQueue.add(tCoords);
- if (visited.add(tCoords = new ChunkCoordinates(aCoords.posX - 1, aCoords.posY, aCoords.posZ)))
- tQueue.add(tCoords);
- if (visited.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY + 1, aCoords.posZ)))
- tQueue.add(tCoords);
- if (visited.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY - 1, aCoords.posZ)))
- tQueue.add(tCoords);
- if (visited.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY, aCoords.posZ + 1)))
- tQueue.add(tCoords);
- if (visited.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY, aCoords.posZ - 1)))
- tQueue.add(tCoords);
+ for (int i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
+ final ForgeDirection side = ForgeDirection.VALID_DIRECTIONS[i];
+ final long tCoords = asLong(posX + side.offsetX, posY + side.offsetY, posZ + side.offsetZ);
+ if (visited.add(tCoords)) {
+ tQueue.enqueue(tCoords);
+ }
+ }
}
}
} catch (Exception e) {
GT_Mod.GT_FML_LOGGER.error(
- "Well this update was broken... " + mCoords
+ "Well this update was broken... " + initialX
+ + ", "
+ + initialY
+ + ", "
+ + initialZ
+ ", mWorld={"
+ world.getProviderName()
+ " @dimId "
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,