From 1b820de08a05070909a267e17f033fcf58ac8710 Mon Sep 17 00:00:00 2001 From: NotAPenguin Date: Mon, 2 Sep 2024 23:17:17 +0200 Subject: The Great Renaming (#3014) * move kekztech to a single root dir * move detrav to a single root dir * move gtnh-lanthanides to a single root dir * move tectech and delete some gross reflection in gt++ * remove more reflection inside gt5u * delete more reflection in gt++ * fix imports * move bartworks and bwcrossmod * fix proxies * move galactigreg and ggfab * move gtneioreplugin * try to fix gt++ bee loader * apply the rename rules to BW * apply rename rules to bwcrossmod * apply rename rules to detrav scanner mod * apply rename rules to galacticgreg * apply rename rules to ggfab * apply rename rules to goodgenerator * apply rename rules to gtnh-lanthanides * apply rename rules to gt++ * apply rename rules to kekztech * apply rename rules to kubatech * apply rename rules to tectech * apply rename rules to gt apply the rename rules to gt * fix tt import * fix mui hopefully * fix coremod except intergalactic * rename assline recipe class * fix a class name i stumbled on * rename StructureUtility to GTStructureUtility to prevent conflict with structurelib * temporary rename of GTTooltipDataCache to old name * fix gt client/server proxy names --- .../xmod/gregtech/common/render/CapeRenderer.java | 500 ++++++++ .../xmod/gregtech/common/render/FlaskRenderer.java | 107 ++ .../gregtech/common/render/GTPP_CapeRenderer.java | 500 -------- .../gregtech/common/render/GTPP_FlaskRenderer.java | 107 -- .../common/render/GTPP_Render_MachineBlock.java | 1250 -------------------- .../common/render/MachineBlockRenderer.java | 1250 ++++++++++++++++++++ 6 files changed, 1857 insertions(+), 1857 deletions(-) create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/render/CapeRenderer.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/render/FlaskRenderer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java delete mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java create mode 100644 src/main/java/gtPlusPlus/xmod/gregtech/common/render/MachineBlockRenderer.java (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/common/render') diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/CapeRenderer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/CapeRenderer.java new file mode 100644 index 0000000000..f9ec4b9433 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/CapeRenderer.java @@ -0,0 +1,500 @@ +package gtPlusPlus.xmod.gregtech.common.render; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Date; +import java.util.List; +import java.util.concurrent.ForkJoinPool; + +import net.minecraft.client.entity.AbstractClientPlayer; +import net.minecraft.client.model.ModelBiped; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.renderer.entity.RenderPlayer; +import net.minecraft.potion.Potion; +import net.minecraft.util.MathHelper; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.client.event.RenderPlayerEvent; + +import org.apache.commons.io.IOUtils; +import org.lwjgl.opengl.GL11; + +import gregtech.api.util.GTUtility; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.api.objects.data.Pair; +import gtPlusPlus.core.lib.GTPPCore; +import gtPlusPlus.core.lib.GTPPCore.ConfigSwitches; +import gtPlusPlus.core.proxy.ClientProxy; +import gtPlusPlus.core.util.data.AES; +import gtPlusPlus.core.util.data.FileUtils; +import gtPlusPlus.core.util.math.MathUtils; + +public class CapeRenderer extends RenderPlayer { + + private static final ResourceLocation[] mCapes = { new ResourceLocation("miscutils:textures/OrangeHD.png"), + new ResourceLocation("miscutils:textures/FancyCapeHD.png"), + new ResourceLocation("miscutils:textures/TesterCapeHD.png"), + new ResourceLocation("miscutils:textures/PatreonCapeHD.png"), + new ResourceLocation("miscutils:textures/DevCapeHD.png"), }; + + private final boolean mInit; + + public CapeRenderer() { + mInit = init(); + } + + private boolean init() { + if (mInit) { + return false; + } + return CapeUtils.init(); + } + + private static boolean hasResourceChecked = false; + private static boolean hasSetRenderer = false; + private boolean hasCape = false; + private ResourceLocation tResource = null; + + public synchronized void receiveRenderSpecialsEvent(RenderPlayerEvent.Specials.Pre aEvent) { + + // Check we have set Render Manager + if (this.renderManager == null) { + hasSetRenderer = false; + } + + // Set Render Manager + if (!hasSetRenderer) { + if (RenderManager.instance != null) { + setRenderManager(RenderManager.instance); + hasSetRenderer = true; + } + } + + // Actually Render + if (hasSetRenderer) { + + // We have capes turned off, so let's not render. + if (!ConfigSwitches.enableCustomCapes) { + return; + } + + if (!CapeUtils.mapsPopulated) { + if (!CapeUtils.cacheReady) { + return; + } + CapeUtils.writeCacheToMaps(); + CapeUtils.mapsPopulated = true; + } + + // We have already checked if this player has a cape, but since they do not, we best not render. + if (hasResourceChecked) { + if (!hasCape && !GTPPCore.DEVENV) { + return; + } + } + + // Allocate client player object + AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; + + // Make sure we don't keep checking on clients who dont have capes. + if (!hasResourceChecked) { + + // Get players UUID + String aPlayerUUID = aPlayer != null ? aPlayer.getGameProfile() + .getId() + .toString() : "BAD"; + + // If for whatever reason this fails, we just exit early. + if (aPlayerUUID.equals("BAD")) { + return; + } + + // Automatically allocate a Dev cape while in Dev mode. + if (tResource == null && GTPPCore.DEVENV) { + tResource = mCapes[4]; + hasCape = true; + } + + String aPlayerName = ClientProxy.playerName; + + // Check cape lists for the cape this player owns. + if (!hasCape) { + for (Pair aData : CapeUtils.mOrangeCapes) { + if (aData.getKey() + .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { + tResource = mCapes[0]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair aData : CapeUtils.mMiscCapes) { + if (aData.getKey() + .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { + tResource = mCapes[1]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair aData : CapeUtils.mBetaTestCapes) { + if (aData.getKey() + .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { + tResource = mCapes[2]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair aData : CapeUtils.mPatreonCapes) { + if (aData.getKey() + .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { + tResource = mCapes[3]; + hasCape = true; + break; + } + } + } + if (!hasCape) { + for (Pair aData : CapeUtils.mDevCapes) { + if (aData.getKey() + .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { + tResource = mCapes[4]; + hasCape = true; + break; + } + } + } + hasResourceChecked = true; + } + + if (hasResourceChecked) { + // We have met all the conditions, let's render that cape. + renderCapeOnPlayer(aEvent, aPlayer); + } + } + } + + private boolean renderCapeOnPlayer(RenderPlayerEvent.Specials.Pre aEvent, AbstractClientPlayer aPlayer) { + float aPartialTicks = aEvent.partialRenderTick; + try { + if (tResource == null && GTPPCore.DEVENV) { + tResource = mCapes[3]; + } + + // If player is invisible, don't render. + if (GTUtility.getFullInvisibility(aPlayer) || aPlayer.isInvisible() + || GTUtility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id))) { + aEvent.setCanceled(true); + return false; + } + + if ((tResource != null) && (!aPlayer.getHideCape())) { + bindTexture(tResource); + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.0F, 0.125F); + double d0 = aPlayer.field_71091_bM + (aPlayer.field_71094_bP - aPlayer.field_71091_bM) * aPartialTicks + - (aPlayer.prevPosX + (aPlayer.posX - aPlayer.prevPosX) * aPartialTicks); + double d1 = aPlayer.field_71096_bN + (aPlayer.field_71095_bQ - aPlayer.field_71096_bN) * aPartialTicks + - (aPlayer.prevPosY + (aPlayer.posY - aPlayer.prevPosY) * aPartialTicks); + double d2 = aPlayer.field_71097_bO + (aPlayer.field_71085_bR - aPlayer.field_71097_bO) * aPartialTicks + - (aPlayer.prevPosZ + (aPlayer.posZ - aPlayer.prevPosZ) * aPartialTicks); + float f6 = aPlayer.prevRenderYawOffset + + (aPlayer.renderYawOffset - aPlayer.prevRenderYawOffset) * aPartialTicks; + double d3 = MathHelper.sin(f6 * GTPPCore.PI / 180.0F); + double d4 = -MathHelper.cos(f6 * GTPPCore.PI / 180.0F); + float f7 = (float) d1 * 10.0F; + float f8 = (float) (d0 * d3 + d2 * d4) * 100.0F; + float f9 = (float) (d0 * d4 - d2 * d3) * 100.0F; + if (f7 < -6.0F) { + f7 = -6.0F; + } + if (f7 > 32.0F) { + f7 = 32.0F; + } + if (f8 < 0.0F) { + f8 = 0.0F; + } + float f10 = aPlayer.prevCameraYaw + (aPlayer.cameraYaw - aPlayer.prevCameraYaw) * aPartialTicks; + f7 += MathHelper.sin( + (aPlayer.prevDistanceWalkedModified + + (aPlayer.distanceWalkedModified - aPlayer.prevDistanceWalkedModified) * aPartialTicks) * 6.0F) + * 32.0F + * f10; + if (aPlayer.isSneaking()) { + f7 += 25.0F; + } + GL11.glRotatef(6.0F + f8 / 2.0F + f7, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(f9 / 2.0F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-f9 / 2.0F, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); + ((ModelBiped) this.mainModel).renderCloak(0.0625F); + GL11.glPopMatrix(); + return true; + } + } catch (Throwable e) { + + } + return false; + } + + private static class CapeUtils { + + private static char SPLIT_CHARACTER = '§'; + private static AES sAES; + private static volatile boolean cacheReady = false; + private static boolean mapsPopulated = false; + + // UUID - Username + private static final AutoMap> mOrangeCapes = new AutoMap<>(); + private static final AutoMap> mMiscCapes = new AutoMap<>(); + private static final AutoMap> mBetaTestCapes = new AutoMap<>(); + private static final AutoMap> mPatreonCapes = new AutoMap<>(); + private static final AutoMap> mDevCapes = new AutoMap<>(); + + private static boolean init() { + CapeUtils.handleOldCapeCache(); + if (GTPPCore.DEVENV) { + return true; + } + ForkJoinPool.commonPool() + .execute(() -> { + try { + if (shouldDownloadCapeList()) { + downloadCapeList(); + } + } catch (Exception ignored) {} + cacheReady = true; + }); + return true; + } + + private static boolean shouldDownloadCapeList() { + if (!doesCapeCacheExistLocally()) { + return true; + } + if (isCapeCacheWeekOld()) { + return true; + } + return false; + } + + private static boolean isCapeCacheWeekOld() { + if (!doesCapeCacheExistLocally()) { + return true; + } else { + File dat = CapeUtils.getCapeCache(); + Date dateLastMod = new Date(dat.lastModified()); + Date dateNow = new Date(System.currentTimeMillis() - (7l * 24 * 60 * 60 * 1000)); + if (dateLastMod.before(dateNow)) { + return true; + } + } + return false; + } + + private static void downloadCapeList() { + try { + File dat = getCapeCache(); + File temp = allocateTempFile(); + InputStream inputStream = new URL("https://alkcorp.overminddl1.com/CapeCache.dat").openStream(); + FileOutputStream fileOS = new FileOutputStream(temp); + IOUtils.copy(inputStream, fileOS); + if (isDownloadedCapeListBigger(temp)) { + fileOS = new FileOutputStream(dat); + IOUtils.copy(inputStream, fileOS); + } + } catch (Throwable t) { + Logger.INFO("Unable to download GT++ cape list."); + } + } + + private static boolean isDownloadedCapeListBigger(File aFile) { + double aExistingFileSize = (doesCapeCacheExistLocally() ? getCapeCache().length() : 0); + double aNewFileSize = aFile.length(); + if (aNewFileSize > aExistingFileSize) { + return true; + } + return false; + } + + private static void handleOldCapeCache() { + File aCacheFile = FileUtils.getFile("GTPP", "dat"); + if (FileUtils.doesFileExist(aCacheFile)) { + aCacheFile.delete(); + } + } + + private static boolean doesCapeCacheExistLocally() { + File aCacheFile = FileUtils.getFile("CapeCache", "dat"); + if (FileUtils.doesFileExist(aCacheFile)) { + return true; + } + return false; + } + + private static File getCapeCache() { + File aCacheFile = FileUtils.getFile("CapeCache", "dat"); + if (FileUtils.doesFileExist(aCacheFile)) { + FileUtils.createFile(aCacheFile); + } + return aCacheFile; + } + + public static final List getDataFromCache() { + File aCacheFile = getCapeCache(); + List aCache = FileUtils.readLines(aCacheFile); + if (aCache != null && !aCache.isEmpty()) { + return aCache; + } + return new AutoMap<>(); + } + + private static File allocateTempFile() { + File tempFile = null; + try { + tempFile = File.createTempFile("gtpp-", null); + } catch (IOException e) { + e.printStackTrace(); + } + if (tempFile == null) { + tempFile = FileUtils + .createFile("", "gtpp-" + MathUtils.randInt(Short.MAX_VALUE, (Integer.MAX_VALUE / 2)), "tmp"); + } + tempFile.deleteOnExit(); + return tempFile; + } + + public static final void writeCacheToMaps() { + List aCacheData = getDataFromCache(); + if (aCacheData != null && !aCacheData.isEmpty()) { + if (sAES == null) { + sAES = new AES(); + } + AutoMap aDecodedData = new AutoMap<>(); + for (String aToDecode : aCacheData) { + aDecodedData.put(sAES.decode(aToDecode)); + } + if (!aDecodedData.isEmpty()) { + AutoMap> aCapeType1 = new AutoMap<>(); + AutoMap> aCapeType2 = new AutoMap<>(); + AutoMap> aCapeType3 = new AutoMap<>(); + AutoMap> aCapeType4 = new AutoMap<>(); + AutoMap> aCapeType5 = new AutoMap<>(); + boolean didProcessStringData = false; + Logger.INFO("Decoded String Count: " + aDecodedData.size()); + for (String aToSplit : aDecodedData) { + String[] aSplitData = aToSplit.split("" + SPLIT_CHARACTER); + if (aSplitData != null && aSplitData.length >= 2) { + if (aSplitData[0] != null) { + Integer aCapeTypeID2 = Integer.parseInt(aSplitData[0]); + if (aCapeTypeID2 != null) { + int aCapeTypeID = aCapeTypeID2; + Pair aFinalString = new Pair<>( + "UUID: " + aSplitData[1], + "Username: " + + (aSplitData[2] != null && aSplitData[0].length() > 0 ? aSplitData[2] + : "Not Specified")); + Logger.INFO("Cape Type: " + aCapeTypeID); + switch (aCapeTypeID) { + case 0 -> { + aCapeType1.add(aFinalString); + Logger.INFO( + "Added user to map " + aCapeTypeID + + ", map now holds " + + aCapeType1.size() + + " users."); + } + case 1 -> { + aCapeType2.add(aFinalString); + Logger.INFO( + "Added user to map " + aCapeTypeID + + ", map now holds " + + aCapeType2.size() + + " users."); + } + case 2 -> { + aCapeType3.add(aFinalString); + Logger.INFO( + "Added user to map " + aCapeTypeID + + ", map now holds " + + aCapeType3.size() + + " users."); + } + case 3 -> { + aCapeType4.add(aFinalString); + Logger.INFO( + "Added user to map " + aCapeTypeID + + ", map now holds " + + aCapeType4.size() + + " users."); + } + case 4 -> { + aCapeType5.add(aFinalString); + Logger.INFO( + "Added user to map " + aCapeTypeID + + ", map now holds " + + aCapeType5.size() + + " users."); + } + default -> {} + } + } + } + } + } + if (!aCapeType1.isEmpty() || !aCapeType2.isEmpty() + || !aCapeType3.isEmpty() + || !aCapeType4.isEmpty() + || !aCapeType5.isEmpty()) { + didProcessStringData = true; + } else { + // did not process any data + } + if (didProcessStringData) { + if (!aCapeType1.isEmpty()) { + for (Pair aUser : aCapeType1) { + Logger.INFO("Adding Generic cape for " + aUser.getKey()); + mOrangeCapes.add(aUser); + } + } + if (!aCapeType2.isEmpty()) { + for (Pair aUser : aCapeType2) { + Logger.INFO("Adding Blue cape for " + aUser.getKey()); + mMiscCapes.add(aUser); + } + } + if (!aCapeType3.isEmpty()) { + for (Pair aUser : aCapeType3) { + Logger.INFO("Adding Beta cape for " + aUser.getKey()); + mBetaTestCapes.add(aUser); + } + } + if (!aCapeType4.isEmpty()) { + for (Pair aUser : aCapeType4) { + Logger.INFO("Adding Patreon cape for " + aUser.getKey()); + mPatreonCapes.add(aUser); + } + } + if (!aCapeType5.isEmpty()) { + for (Pair aUser : aCapeType5) { + Logger.INFO("Adding Dev cape for " + aUser.getKey()); + mDevCapes.add(aUser); + } + } + } + } else { + // No data decoded + } + } else { + // Nothing was cached? + } + } + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/FlaskRenderer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/FlaskRenderer.java new file mode 100644 index 0000000000..20d904ae80 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/FlaskRenderer.java @@ -0,0 +1,107 @@ +package gtPlusPlus.xmod.gregtech.common.render; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.ItemRenderer; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraftforge.client.IItemRenderer; +import net.minecraftforge.client.MinecraftForgeClient; +import net.minecraftforge.fluids.FluidStack; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.common.items.ItemVolumetricFlask; +import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import ic2.core.util.DrawUtil; + +@SideOnly(cpw.mods.fml.relauncher.Side.CLIENT) +public final class FlaskRenderer implements net.minecraftforge.client.IItemRenderer { + + public FlaskRenderer() { + MinecraftForgeClient.registerItemRenderer(GregtechItemList.VOLUMETRIC_FLASK_8k.getItem(), this); + MinecraftForgeClient.registerItemRenderer(GregtechItemList.VOLUMETRIC_FLASK_32k.getItem(), this); + } + + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return type != ItemRenderType.FIRST_PERSON_MAP; + } + + @Override + public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) { + return type == ItemRenderType.ENTITY; + } + + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + ItemVolumetricFlask cell = (ItemVolumetricFlask) item.getItem(); + + int aType = cell.getMaxCapacity() == 8000 ? 0 : 1; + IIcon icon = item.getIconIndex(); + GL11.glEnable(3042); + GL11.glEnable(3008); + if (type.equals(ItemRenderType.ENTITY)) { + GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); + GL11.glRotated(90.0D, 0.0D, 1.0D, 0.0D); + GL11.glTranslated(-0.5D, -0.6D, 0.0D); + } else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) { + GL11.glTranslated(1.0D, 1.0D, 0.0D); + GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); + } else if (type.equals(ItemRenderType.EQUIPPED)) { + GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); + GL11.glTranslated(-1.0D, -1.0D, 0.0D); + } + + FluidStack fs = cell.getFluid(item); + if (fs != null) { + IIcon iconWindow = cell.iconWindow; + IIcon fluidicon = fs.getFluid() + .getIcon(fs); + int fluidColor = fs.getFluid() + .getColor(fs); + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(0, 1); + if (type.equals(ItemRenderType.INVENTORY)) { + DrawUtil.renderIcon(iconWindow, 16.0D, 0.0D, 0.0F, 0.0F, -1.0F); + } else { + DrawUtil.renderIcon(iconWindow, 1.0D, -0.001D, 0.0F, 0.0F, 1.0F); + DrawUtil.renderIcon(iconWindow, 1.0D, -0.0615D, 0.0F, 0.0F, -1.0F); + } + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); + GL11.glBlendFunc(770, 771); + GL11.glDepthFunc(514); + GL11.glColor3ub((byte) (fluidColor >> 16), (byte) (fluidColor >> 8), (byte) fluidColor); + if (type.equals(ItemRenderType.INVENTORY)) { + DrawUtil.renderIcon(fluidicon, 16.0D, 0.0D, 0.0F, 0.0F, -1.0F); + } else { + DrawUtil.renderIcon(fluidicon, 1.0D, -0.001D, 0.0F, 0.0F, 1.0F); + DrawUtil.renderIcon(fluidicon, 1.0D, -0.0615D, 0.0F, 0.0F, -1.0F); + } + + GL11.glColor3ub((byte) -1, (byte) -1, (byte) -1); + GL11.glDepthFunc(515); + } + + Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); + GL11.glBlendFunc(770, 771); + if (type.equals(ItemRenderType.INVENTORY)) { + DrawUtil.renderIcon(icon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); + } else { + ItemRenderer.renderItemIn2D( + Tessellator.instance, + icon.getMaxU(), + icon.getMinV(), + icon.getMinU(), + icon.getMaxV(), + icon.getIconWidth(), + icon.getIconHeight(), + 0.0625F); + } + GL11.glDisable(3008); + GL11.glDisable(3042); + } +} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java deleted file mode 100644 index a281a205d2..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java +++ /dev/null @@ -1,500 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.render; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Date; -import java.util.List; -import java.util.concurrent.ForkJoinPool; - -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.model.ModelBiped; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.entity.RenderPlayer; -import net.minecraft.potion.Potion; -import net.minecraft.util.MathHelper; -import net.minecraft.util.ResourceLocation; -import net.minecraftforge.client.event.RenderPlayerEvent; - -import org.apache.commons.io.IOUtils; -import org.lwjgl.opengl.GL11; - -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.lib.CORE.ConfigSwitches; -import gtPlusPlus.core.proxy.ClientProxy; -import gtPlusPlus.core.util.data.AES; -import gtPlusPlus.core.util.data.FileUtils; -import gtPlusPlus.core.util.math.MathUtils; - -public class GTPP_CapeRenderer extends RenderPlayer { - - private static final ResourceLocation[] mCapes = { new ResourceLocation("miscutils:textures/OrangeHD.png"), - new ResourceLocation("miscutils:textures/FancyCapeHD.png"), - new ResourceLocation("miscutils:textures/TesterCapeHD.png"), - new ResourceLocation("miscutils:textures/PatreonCapeHD.png"), - new ResourceLocation("miscutils:textures/DevCapeHD.png"), }; - - private final boolean mInit; - - public GTPP_CapeRenderer() { - mInit = init(); - } - - private boolean init() { - if (mInit) { - return false; - } - return CapeUtils.init(); - } - - private static boolean hasResourceChecked = false; - private static boolean hasSetRenderer = false; - private boolean hasCape = false; - private ResourceLocation tResource = null; - - public synchronized void receiveRenderSpecialsEvent(RenderPlayerEvent.Specials.Pre aEvent) { - - // Check we have set Render Manager - if (this.renderManager == null) { - hasSetRenderer = false; - } - - // Set Render Manager - if (!hasSetRenderer) { - if (RenderManager.instance != null) { - setRenderManager(RenderManager.instance); - hasSetRenderer = true; - } - } - - // Actually Render - if (hasSetRenderer) { - - // We have capes turned off, so let's not render. - if (!ConfigSwitches.enableCustomCapes) { - return; - } - - if (!CapeUtils.mapsPopulated) { - if (!CapeUtils.cacheReady) { - return; - } - CapeUtils.writeCacheToMaps(); - CapeUtils.mapsPopulated = true; - } - - // We have already checked if this player has a cape, but since they do not, we best not render. - if (hasResourceChecked) { - if (!hasCape && !CORE.DEVENV) { - return; - } - } - - // Allocate client player object - AbstractClientPlayer aPlayer = (AbstractClientPlayer) aEvent.entityPlayer; - - // Make sure we don't keep checking on clients who dont have capes. - if (!hasResourceChecked) { - - // Get players UUID - String aPlayerUUID = aPlayer != null ? aPlayer.getGameProfile() - .getId() - .toString() : "BAD"; - - // If for whatever reason this fails, we just exit early. - if (aPlayerUUID.equals("BAD")) { - return; - } - - // Automatically allocate a Dev cape while in Dev mode. - if (tResource == null && CORE.DEVENV) { - tResource = mCapes[4]; - hasCape = true; - } - - String aPlayerName = ClientProxy.playerName; - - // Check cape lists for the cape this player owns. - if (!hasCape) { - for (Pair aData : CapeUtils.mOrangeCapes) { - if (aData.getKey() - .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { - tResource = mCapes[0]; - hasCape = true; - break; - } - } - } - if (!hasCape) { - for (Pair aData : CapeUtils.mMiscCapes) { - if (aData.getKey() - .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { - tResource = mCapes[1]; - hasCape = true; - break; - } - } - } - if (!hasCape) { - for (Pair aData : CapeUtils.mBetaTestCapes) { - if (aData.getKey() - .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { - tResource = mCapes[2]; - hasCape = true; - break; - } - } - } - if (!hasCape) { - for (Pair aData : CapeUtils.mPatreonCapes) { - if (aData.getKey() - .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { - tResource = mCapes[3]; - hasCape = true; - break; - } - } - } - if (!hasCape) { - for (Pair aData : CapeUtils.mDevCapes) { - if (aData.getKey() - .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) { - tResource = mCapes[4]; - hasCape = true; - break; - } - } - } - hasResourceChecked = true; - } - - if (hasResourceChecked) { - // We have met all the conditions, let's render that cape. - renderCapeOnPlayer(aEvent, aPlayer); - } - } - } - - private boolean renderCapeOnPlayer(RenderPlayerEvent.Specials.Pre aEvent, AbstractClientPlayer aPlayer) { - float aPartialTicks = aEvent.partialRenderTick; - try { - if (tResource == null && CORE.DEVENV) { - tResource = mCapes[3]; - } - - // If player is invisible, don't render. - if (GT_Utility.getFullInvisibility(aPlayer) || aPlayer.isInvisible() - || GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id))) { - aEvent.setCanceled(true); - return false; - } - - if ((tResource != null) && (!aPlayer.getHideCape())) { - bindTexture(tResource); - GL11.glPushMatrix(); - GL11.glTranslatef(0.0F, 0.0F, 0.125F); - double d0 = aPlayer.field_71091_bM + (aPlayer.field_71094_bP - aPlayer.field_71091_bM) * aPartialTicks - - (aPlayer.prevPosX + (aPlayer.posX - aPlayer.prevPosX) * aPartialTicks); - double d1 = aPlayer.field_71096_bN + (aPlayer.field_71095_bQ - aPlayer.field_71096_bN) * aPartialTicks - - (aPlayer.prevPosY + (aPlayer.posY - aPlayer.prevPosY) * aPartialTicks); - double d2 = aPlayer.field_71097_bO + (aPlayer.field_71085_bR - aPlayer.field_71097_bO) * aPartialTicks - - (aPlayer.prevPosZ + (aPlayer.posZ - aPlayer.prevPosZ) * aPartialTicks); - float f6 = aPlayer.prevRenderYawOffset - + (aPlayer.renderYawOffset - aPlayer.prevRenderYawOffset) * aPartialTicks; - double d3 = MathHelper.sin(f6 * CORE.PI / 180.0F); - double d4 = -MathHelper.cos(f6 * CORE.PI / 180.0F); - float f7 = (float) d1 * 10.0F; - float f8 = (float) (d0 * d3 + d2 * d4) * 100.0F; - float f9 = (float) (d0 * d4 - d2 * d3) * 100.0F; - if (f7 < -6.0F) { - f7 = -6.0F; - } - if (f7 > 32.0F) { - f7 = 32.0F; - } - if (f8 < 0.0F) { - f8 = 0.0F; - } - float f10 = aPlayer.prevCameraYaw + (aPlayer.cameraYaw - aPlayer.prevCameraYaw) * aPartialTicks; - f7 += MathHelper.sin( - (aPlayer.prevDistanceWalkedModified - + (aPlayer.distanceWalkedModified - aPlayer.prevDistanceWalkedModified) * aPartialTicks) * 6.0F) - * 32.0F - * f10; - if (aPlayer.isSneaking()) { - f7 += 25.0F; - } - GL11.glRotatef(6.0F + f8 / 2.0F + f7, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(f9 / 2.0F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(-f9 / 2.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); - ((ModelBiped) this.mainModel).renderCloak(0.0625F); - GL11.glPopMatrix(); - return true; - } - } catch (Throwable e) { - - } - return false; - } - - private static class CapeUtils { - - private static char SPLIT_CHARACTER = '§'; - private static AES sAES; - private static volatile boolean cacheReady = false; - private static boolean mapsPopulated = false; - - // UUID - Username - private static final AutoMap> mOrangeCapes = new AutoMap<>(); - private static final AutoMap> mMiscCapes = new AutoMap<>(); - private static final AutoMap> mBetaTestCapes = new AutoMap<>(); - private static final AutoMap> mPatreonCapes = new AutoMap<>(); - private static final AutoMap> mDevCapes = new AutoMap<>(); - - private static boolean init() { - CapeUtils.handleOldCapeCache(); - if (CORE.DEVENV) { - return true; - } - ForkJoinPool.commonPool() - .execute(() -> { - try { - if (shouldDownloadCapeList()) { - downloadCapeList(); - } - } catch (Exception ignored) {} - cacheReady = true; - }); - return true; - } - - private static boolean shouldDownloadCapeList() { - if (!doesCapeCacheExistLocally()) { - return true; - } - if (isCapeCacheWeekOld()) { - return true; - } - return false; - } - - private static boolean isCapeCacheWeekOld() { - if (!doesCapeCacheExistLocally()) { - return true; - } else { - File dat = CapeUtils.getCapeCache(); - Date dateLastMod = new Date(dat.lastModified()); - Date dateNow = new Date(System.currentTimeMillis() - (7l * 24 * 60 * 60 * 1000)); - if (dateLastMod.before(dateNow)) { - return true; - } - } - return false; - } - - private static void downloadCapeList() { - try { - File dat = getCapeCache(); - File temp = allocateTempFile(); - InputStream inputStream = new URL("https://alkcorp.overminddl1.com/CapeCache.dat").openStream(); - FileOutputStream fileOS = new FileOutputStream(temp); - IOUtils.copy(inputStream, fileOS); - if (isDownloadedCapeListBigger(temp)) { - fileOS = new FileOutputStream(dat); - IOUtils.copy(inputStream, fileOS); - } - } catch (Throwable t) { - Logger.INFO("Unable to download GT++ cape list."); - } - } - - private static boolean isDownloadedCapeListBigger(File aFile) { - double aExistingFileSize = (doesCapeCacheExistLocally() ? getCapeCache().length() : 0); - double aNewFileSize = aFile.length(); - if (aNewFileSize > aExistingFileSize) { - return true; - } - return false; - } - - private static void handleOldCapeCache() { - File aCacheFile = FileUtils.getFile("GTPP", "dat"); - if (FileUtils.doesFileExist(aCacheFile)) { - aCacheFile.delete(); - } - } - - private static boolean doesCapeCacheExistLocally() { - File aCacheFile = FileUtils.getFile("CapeCache", "dat"); - if (FileUtils.doesFileExist(aCacheFile)) { - return true; - } - return false; - } - - private static File getCapeCache() { - File aCacheFile = FileUtils.getFile("CapeCache", "dat"); - if (FileUtils.doesFileExist(aCacheFile)) { - FileUtils.createFile(aCacheFile); - } - return aCacheFile; - } - - public static final List getDataFromCache() { - File aCacheFile = getCapeCache(); - List aCache = FileUtils.readLines(aCacheFile); - if (aCache != null && !aCache.isEmpty()) { - return aCache; - } - return new AutoMap<>(); - } - - private static File allocateTempFile() { - File tempFile = null; - try { - tempFile = File.createTempFile("gtpp-", null); - } catch (IOException e) { - e.printStackTrace(); - } - if (tempFile == null) { - tempFile = FileUtils - .createFile("", "gtpp-" + MathUtils.randInt(Short.MAX_VALUE, (Integer.MAX_VALUE / 2)), "tmp"); - } - tempFile.deleteOnExit(); - return tempFile; - } - - public static final void writeCacheToMaps() { - List aCacheData = getDataFromCache(); - if (aCacheData != null && !aCacheData.isEmpty()) { - if (sAES == null) { - sAES = new AES(); - } - AutoMap aDecodedData = new AutoMap<>(); - for (String aToDecode : aCacheData) { - aDecodedData.put(sAES.decode(aToDecode)); - } - if (!aDecodedData.isEmpty()) { - AutoMap> aCapeType1 = new AutoMap<>(); - AutoMap> aCapeType2 = new AutoMap<>(); - AutoMap> aCapeType3 = new AutoMap<>(); - AutoMap> aCapeType4 = new AutoMap<>(); - AutoMap> aCapeType5 = new AutoMap<>(); - boolean didProcessStringData = false; - Logger.INFO("Decoded String Count: " + aDecodedData.size()); - for (String aToSplit : aDecodedData) { - String[] aSplitData = aToSplit.split("" + SPLIT_CHARACTER); - if (aSplitData != null && aSplitData.length >= 2) { - if (aSplitData[0] != null) { - Integer aCapeTypeID2 = Integer.parseInt(aSplitData[0]); - if (aCapeTypeID2 != null) { - int aCapeTypeID = aCapeTypeID2; - Pair aFinalString = new Pair<>( - "UUID: " + aSplitData[1], - "Username: " - + (aSplitData[2] != null && aSplitData[0].length() > 0 ? aSplitData[2] - : "Not Specified")); - Logger.INFO("Cape Type: " + aCapeTypeID); - switch (aCapeTypeID) { - case 0 -> { - aCapeType1.add(aFinalString); - Logger.INFO( - "Added user to map " + aCapeTypeID - + ", map now holds " - + aCapeType1.size() - + " users."); - } - case 1 -> { - aCapeType2.add(aFinalString); - Logger.INFO( - "Added user to map " + aCapeTypeID - + ", map now holds " - + aCapeType2.size() - + " users."); - } - case 2 -> { - aCapeType3.add(aFinalString); - Logger.INFO( - "Added user to map " + aCapeTypeID - + ", map now holds " - + aCapeType3.size() - + " users."); - } - case 3 -> { - aCapeType4.add(aFinalString); - Logger.INFO( - "Added user to map " + aCapeTypeID - + ", map now holds " - + aCapeType4.size() - + " users."); - } - case 4 -> { - aCapeType5.add(aFinalString); - Logger.INFO( - "Added user to map " + aCapeTypeID - + ", map now holds " - + aCapeType5.size() - + " users."); - } - default -> {} - } - } - } - } - } - if (!aCapeType1.isEmpty() || !aCapeType2.isEmpty() - || !aCapeType3.isEmpty() - || !aCapeType4.isEmpty() - || !aCapeType5.isEmpty()) { - didProcessStringData = true; - } else { - // did not process any data - } - if (didProcessStringData) { - if (!aCapeType1.isEmpty()) { - for (Pair aUser : aCapeType1) { - Logger.INFO("Adding Generic cape for " + aUser.getKey()); - mOrangeCapes.add(aUser); - } - } - if (!aCapeType2.isEmpty()) { - for (Pair aUser : aCapeType2) { - Logger.INFO("Adding Blue cape for " + aUser.getKey()); - mMiscCapes.add(aUser); - } - } - if (!aCapeType3.isEmpty()) { - for (Pair aUser : aCapeType3) { - Logger.INFO("Adding Beta cape for " + aUser.getKey()); - mBetaTestCapes.add(aUser); - } - } - if (!aCapeType4.isEmpty()) { - for (Pair aUser : aCapeType4) { - Logger.INFO("Adding Patreon cape for " + aUser.getKey()); - mPatreonCapes.add(aUser); - } - } - if (!aCapeType5.isEmpty()) { - for (Pair aUser : aCapeType5) { - Logger.INFO("Adding Dev cape for " + aUser.getKey()); - mDevCapes.add(aUser); - } - } - } - } else { - // No data decoded - } - } else { - // Nothing was cached? - } - } - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java deleted file mode 100644 index 0c9e59e2f2..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java +++ /dev/null @@ -1,107 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.render; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ItemRenderer; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraftforge.client.IItemRenderer; -import net.minecraftforge.client.MinecraftForgeClient; -import net.minecraftforge.fluids.FluidStack; - -import org.lwjgl.opengl.GL11; - -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.common.items.GT_VolumetricFlask; -import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; -import ic2.core.util.DrawUtil; - -@SideOnly(cpw.mods.fml.relauncher.Side.CLIENT) -public final class GTPP_FlaskRenderer implements net.minecraftforge.client.IItemRenderer { - - public GTPP_FlaskRenderer() { - MinecraftForgeClient.registerItemRenderer(GregtechItemList.VOLUMETRIC_FLASK_8k.getItem(), this); - MinecraftForgeClient.registerItemRenderer(GregtechItemList.VOLUMETRIC_FLASK_32k.getItem(), this); - } - - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) { - return type != ItemRenderType.FIRST_PERSON_MAP; - } - - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, IItemRenderer.ItemRendererHelper helper) { - return type == ItemRenderType.ENTITY; - } - - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) { - GT_VolumetricFlask cell = (GT_VolumetricFlask) item.getItem(); - - int aType = cell.getMaxCapacity() == 8000 ? 0 : 1; - IIcon icon = item.getIconIndex(); - GL11.glEnable(3042); - GL11.glEnable(3008); - if (type.equals(ItemRenderType.ENTITY)) { - GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); - GL11.glRotated(90.0D, 0.0D, 1.0D, 0.0D); - GL11.glTranslated(-0.5D, -0.6D, 0.0D); - } else if (type.equals(ItemRenderType.EQUIPPED_FIRST_PERSON)) { - GL11.glTranslated(1.0D, 1.0D, 0.0D); - GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); - } else if (type.equals(ItemRenderType.EQUIPPED)) { - GL11.glRotated(180.0D, 0.0D, 0.0D, 1.0D); - GL11.glTranslated(-1.0D, -1.0D, 0.0D); - } - - FluidStack fs = cell.getFluid(item); - if (fs != null) { - IIcon iconWindow = cell.iconWindow; - IIcon fluidicon = fs.getFluid() - .getIcon(fs); - int fluidColor = fs.getFluid() - .getColor(fs); - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glBlendFunc(0, 1); - if (type.equals(ItemRenderType.INVENTORY)) { - DrawUtil.renderIcon(iconWindow, 16.0D, 0.0D, 0.0F, 0.0F, -1.0F); - } else { - DrawUtil.renderIcon(iconWindow, 1.0D, -0.001D, 0.0F, 0.0F, 1.0F); - DrawUtil.renderIcon(iconWindow, 1.0D, -0.0615D, 0.0F, 0.0F, -1.0F); - } - - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture); - GL11.glBlendFunc(770, 771); - GL11.glDepthFunc(514); - GL11.glColor3ub((byte) (fluidColor >> 16), (byte) (fluidColor >> 8), (byte) fluidColor); - if (type.equals(ItemRenderType.INVENTORY)) { - DrawUtil.renderIcon(fluidicon, 16.0D, 0.0D, 0.0F, 0.0F, -1.0F); - } else { - DrawUtil.renderIcon(fluidicon, 1.0D, -0.001D, 0.0F, 0.0F, 1.0F); - DrawUtil.renderIcon(fluidicon, 1.0D, -0.0615D, 0.0F, 0.0F, -1.0F); - } - - GL11.glColor3ub((byte) -1, (byte) -1, (byte) -1); - GL11.glDepthFunc(515); - } - - Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture); - GL11.glBlendFunc(770, 771); - if (type.equals(ItemRenderType.INVENTORY)) { - DrawUtil.renderIcon(icon, 16.0D, 0.001D, 0.0F, 0.0F, -1.0F); - } else { - ItemRenderer.renderItemIn2D( - Tessellator.instance, - icon.getMaxU(), - icon.getMinV(), - icon.getMinU(), - icon.getMaxV(), - icon.getIconWidth(), - icon.getIconHeight(), - 0.0625F); - } - GL11.glDisable(3008); - GL11.glDisable(3042); - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java deleted file mode 100644 index bfd16b4cc5..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java +++ /dev/null @@ -1,1250 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.render; - -import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_DOWN; -import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_EAST; -import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_NORTH; -import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_SOUTH; -import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_UP; -import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_WEST; -import static gregtech.api.interfaces.metatileentity.IConnectable.HAS_FOAM; -import static gregtech.api.interfaces.metatileentity.IConnectable.NO_CONNECTION; -import static net.minecraftforge.common.util.ForgeDirection.DOWN; -import static net.minecraftforge.common.util.ForgeDirection.EAST; -import static net.minecraftforge.common.util.ForgeDirection.NORTH; -import static net.minecraftforge.common.util.ForgeDirection.SOUTH; -import static net.minecraftforge.common.util.ForgeDirection.UP; -import static net.minecraftforge.common.util.ForgeDirection.WEST; - -import java.util.EnumMap; -import java.util.EnumSet; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; -import net.minecraftforge.common.util.ForgeDirection; - -import org.lwjgl.opengl.GL11; - -import cpw.mods.fml.client.registry.RenderingRegistry; -import gregtech.api.GregTech_API; -import gregtech.api.interfaces.ITexture; -import gregtech.api.interfaces.metatileentity.IMetaTileEntity; -import gregtech.api.interfaces.tileentity.IGregTechTileEntity; -import gregtech.api.interfaces.tileentity.IPipeRenderedTileEntity; -import gregtech.api.interfaces.tileentity.ITexturedTileEntity; -import gregtech.api.metatileentity.MetaPipeEntity; -import gregtech.common.blocks.GT_Block_Machines; -import gregtech.common.render.GT_Renderer_Block; -import gtPlusPlus.xmod.gregtech.common.helpers.GT_MethodHelper; - -public class GTPP_Render_MachineBlock extends GT_Renderer_Block { - - public static GTPP_Render_MachineBlock INSTANCE; - public final int mRenderID = RenderingRegistry.getNextAvailableRenderId(); - - public GTPP_Render_MachineBlock() { - INSTANCE = this; - RenderingRegistry.registerBlockHandler(this); - } - - private static ITexture[] getTexture(IMetaTileEntity tile, ForgeDirection side, ForgeDirection facing, - int colorIndex, boolean active, boolean arg5) { - final IGregTechTileEntity gtTile = tile.getBaseMetaTileEntity(); - return tile.getTexture(gtTile, side, facing, (byte) colorIndex, active, arg5); - } - - private static ITexture[] getTexture(IMetaTileEntity tile, ForgeDirection side, int facingMask, int colorIndex, - boolean active, boolean arg5) { - final MetaPipeEntity gtTile = (MetaPipeEntity) tile.getBaseMetaTileEntity(); - return gtTile.getTexture((IGregTechTileEntity) tile, side, facingMask, colorIndex, active, arg5); - } - - private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, RenderBlocks aRenderer) { - if (aMeta > 0 && aMeta < GregTech_API.METATILEENTITIES.length) { - IMetaTileEntity tMetaTileEntity = GregTech_API.METATILEENTITIES[aMeta]; - if (tMetaTileEntity != null) { - aBlock.setBlockBoundsForItemRender(); - aRenderer.setRenderBoundsFromBlock(aBlock); - GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - if (tMetaTileEntity.getBaseMetaTileEntity() instanceof IPipeRenderedTileEntity pipeRenderedTile) { - float tThickness = pipeRenderedTile.getThickNess(); - float sp = (1.0F - tThickness) / 2.0F; - aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); - renderNegativeYFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, DOWN, 0b001001, -1, false, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); - renderPositiveYFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, UP, 0b001001, -1, false, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); - renderNegativeZFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.NORTH, 0b001001, -1, false, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); - renderPositiveZFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.SOUTH, 0b001001, -1, false, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); - renderNegativeXFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.WEST, 0b001001, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); - renderPositiveXFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.EAST, 0b001001, -1, true, false), - true); - Tessellator.instance.draw(); - } else { - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); - renderNegativeYFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, DOWN, ForgeDirection.WEST, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); - renderPositiveYFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, UP, ForgeDirection.WEST, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); - renderNegativeZFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.NORTH, ForgeDirection.WEST, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); - renderPositiveZFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.SOUTH, ForgeDirection.WEST, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); - renderNegativeXFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.WEST, ForgeDirection.WEST, -1, true, false), - true); - Tessellator.instance.draw(); - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); - renderPositiveXFacing( - null, - aRenderer, - aBlock, - 0, - 0, - 0, - getTexture(tMetaTileEntity, ForgeDirection.EAST, ForgeDirection.WEST, -1, true, false), - true); - Tessellator.instance.draw(); - } - - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } - } - } - - public boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, - RenderBlocks aRenderer) { - TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); - - return tTileEntity instanceof ITexturedTileEntity - ? renderStandardBlock( - aWorld, - aX, - aY, - aZ, - aBlock, - aRenderer, - new ITexture[][] { GT_MethodHelper.getTexture(tTileEntity, aBlock, DOWN), - GT_MethodHelper.getTexture(tTileEntity, aBlock, UP), - GT_MethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.NORTH), - GT_MethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.SOUTH), - GT_MethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.WEST), - GT_MethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.EAST) }) - : false; - } - - public boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, - RenderBlocks aRenderer, ITexture[][] aTextures) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[DOWN.ordinal()], true); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[UP.ordinal()], true); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.NORTH.ordinal()], true); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.SOUTH.ordinal()], true); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.WEST.ordinal()], true); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.EAST.ordinal()], true); - return true; - } - - public boolean renderPipeBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, - IPipeRenderedTileEntity aTileEntity, RenderBlocks aRenderer) { - final int aConnections = aTileEntity.getConnections(); - if ((aConnections & HAS_FOAM) != 0) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); - } else { - float tThickness = aTileEntity.getThickNess(); - if (tThickness >= 0.99F) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); - } else { - float sp = (1.0F - tThickness) / 2.0F; - int connexionSidesBits = 0; - - for (int ordinalSide = 0; ordinalSide < 6; ++ordinalSide) { - if ((aConnections & 1 << ordinalSide) != 0) { - connexionSidesBits = connexionSidesBits | 1 << (ordinalSide + 2) % 6; - } - } - - final EnumSet coveredSides = EnumSet.noneOf(ForgeDirection.class); - - for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - if (aTileEntity.getCoverIDAtSide(side) != 0) coveredSides.add(side); - } - - if (coveredSides.containsAll(EnumSet.of(DOWN, UP, NORTH, SOUTH, WEST, EAST))) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); - } else { - final EnumMap texture = new EnumMap<>(ForgeDirection.class); - final EnumMap textureUncovered = new EnumMap<>(ForgeDirection.class); - - for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { - texture.put(side, GT_MethodHelper.getTexture((TileEntity) aTileEntity, aBlock, side)); - textureUncovered.put(side, aTileEntity.getTextureUncovered(side)); - } - - switch (connexionSidesBits) { - case NO_CONNECTION -> { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - } - case (CONNECTED_DOWN | CONNECTED_UP) -> { - aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - if (!coveredSides.contains(WEST)) { - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - } - if (!coveredSides.contains(EAST)) { - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - } - } - case (CONNECTED_NORTH | CONNECTED_SOUTH) -> { - aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, 1.0F, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - if (!coveredSides.contains(DOWN)) { - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - } - if (!coveredSides.contains(UP)) { - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - } - } - case (CONNECTED_WEST | CONNECTED_EAST) -> { - aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - if (!coveredSides.contains(NORTH)) { - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - } - if (!coveredSides.contains(SOUTH)) { - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - } - } - default -> { - if ((connexionSidesBits & CONNECTED_DOWN) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - } else { - aBlock.setBlockBounds(0.0F, sp, sp, sp, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - if (!coveredSides.contains(WEST)) { - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - } - } - if ((connexionSidesBits & CONNECTED_UP) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - } else { - aBlock.setBlockBounds(sp + tThickness, sp, sp, 1.0F, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - if (!coveredSides.contains(EAST)) { - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - } - } - if ((connexionSidesBits & CONNECTED_NORTH) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - } else { - aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, sp, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - if (!coveredSides.contains(DOWN)) { - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - } - } - if ((connexionSidesBits & CONNECTED_SOUTH) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - } else { - aBlock.setBlockBounds(sp, sp + tThickness, sp, sp + tThickness, 1.0F, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - if (!coveredSides.contains(UP)) { - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - } - } - if ((connexionSidesBits & CONNECTED_WEST) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - } else { - aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, sp); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - if (!coveredSides.contains(NORTH)) { - renderNegativeZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(NORTH), - false); - } - } - if ((connexionSidesBits & CONNECTED_EAST) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - } else { - aBlock.setBlockBounds(sp, sp, sp + tThickness, sp + tThickness, sp + tThickness, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(DOWN), - false); - renderPositiveYFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(UP), - false); - renderNegativeXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(WEST), - false); - renderPositiveXFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(EAST), - false); - if (!coveredSides.contains(SOUTH)) { - renderPositiveZFacing( - aWorld, - aRenderer, - aBlock, - aX, - aY, - aZ, - textureUncovered.get(SOUTH), - false); - } - } - } - } - - if (coveredSides.contains(DOWN)) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); - if (!coveredSides.contains(NORTH)) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); - } - - if (!coveredSides.contains(SOUTH)) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); - } - - if (!coveredSides.contains(WEST)) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); - } - - if (!coveredSides.contains(EAST)) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); - } - } - - if (coveredSides.contains(UP)) { - aBlock.setBlockBounds(0.0F, 0.875F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); - if (!coveredSides.contains(NORTH)) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); - } - - if (!coveredSides.contains(SOUTH)) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); - } - - if (!coveredSides.contains(WEST)) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); - } - - if (!coveredSides.contains(EAST)) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); - } - } - - if (coveredSides.contains(NORTH)) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.125F); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!coveredSides.contains(DOWN)) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); - } - - if (!coveredSides.contains(UP)) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); - } - - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); - if (!coveredSides.contains(WEST)) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); - } - - if (!coveredSides.contains(EAST)) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); - } - } - - if (coveredSides.contains(SOUTH)) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.875F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!coveredSides.contains(DOWN)) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); - } - - if (!coveredSides.contains(UP)) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); - } - - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); - if (!coveredSides.contains(WEST)) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); - } - - if (!coveredSides.contains(EAST)) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); - } - } - - if (coveredSides.contains(WEST)) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 0.125F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!coveredSides.contains(DOWN)) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); - } - - if (!coveredSides.contains(UP)) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); - } - - if (!coveredSides.contains(NORTH)) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); - } - - if (!coveredSides.contains(SOUTH)) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); - } - - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); - } - - if (coveredSides.contains(EAST)) { - aBlock.setBlockBounds(0.875F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - if (!coveredSides.contains(DOWN)) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); - } - - if (!coveredSides.contains(UP)) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); - } - - if (!coveredSides.contains(NORTH)) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); - } - - if (!coveredSides.contains(SOUTH)) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); - } - - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); - } - - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - return true; - } - } - } - } - - public static void renderNegativeYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY - 1, aZ, 0)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY - 1 : aY, aZ)); - } - - if (aIcon != null) { - for (ITexture iTexture : aIcon) { - if (iTexture != null) { - iTexture.renderYNeg(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public static void renderPositiveYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY + 1, aZ, 1)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY + 1 : aY, aZ)); - } - - if (aIcon != null) { - for (ITexture iTexture : aIcon) { - if (iTexture != null) { - iTexture.renderYPos(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public static void renderNegativeZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ - 1, 2)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ - 1 : aZ)); - } - - aRenderer.flipTexture = !aFullBlock; - if (aIcon != null) { - for (ITexture iTexture : aIcon) { - if (iTexture != null) { - iTexture.renderZNeg(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public static void renderPositiveZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ + 1, 3)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ + 1 : aZ)); - } - - if (aIcon != null) { - for (ITexture iTexture : aIcon) { - if (iTexture != null) { - iTexture.renderZPos(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public static void renderNegativeXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX - 1, aY, aZ, 4)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX - 1 : aX, aY, aZ)); - } - - if (aIcon != null) { - for (ITexture iTexture : aIcon) { - if (iTexture != null) { - iTexture.renderXNeg(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - public static void renderPositiveXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, - int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld != null) { - if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX + 1, aY, aZ, 5)) { - return; - } - - Tessellator.instance - .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX + 1 : aX, aY, aZ)); - } - - aRenderer.flipTexture = !aFullBlock; - if (aIcon != null) { - for (ITexture iTexture : aIcon) { - if (iTexture != null) { - iTexture.renderXPos(aRenderer, aBlock, aX, aY, aZ); - } - } - } - - aRenderer.flipTexture = false; - } - - @Override - public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { - aMeta += 30400; - if (aBlock instanceof GT_Block_Machines) { - if (aMeta > 0 && aMeta < GregTech_API.METATILEENTITIES.length - && GregTech_API.METATILEENTITIES[aMeta] != null - && !GregTech_API.METATILEENTITIES[aMeta].renderInInventory(aBlock, aMeta, aRenderer)) { - renderNormalInventoryMetaTileEntity(aBlock, aMeta, aRenderer); - } - } - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } - - @Override - public boolean renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int aModelID, - RenderBlocks aRenderer) { - TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); - return aTileEntity == null ? false - : (aTileEntity instanceof IGregTechTileEntity - && ((IGregTechTileEntity) aTileEntity).getMetaTileEntity() != null - && ((IGregTechTileEntity) aTileEntity).getMetaTileEntity() - .renderInWorld(aWorld, aX, aY, aZ, aBlock, aRenderer) - ? true - : (aTileEntity instanceof IPipeRenderedTileEntity - ? renderPipeBlock( - aWorld, - aX, - aY, - aZ, - aBlock, - (IPipeRenderedTileEntity) aTileEntity, - aRenderer) - : renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer))); - } - - @Override - public boolean shouldRender3DInInventory(int aModel) { - return true; - } - - @Override - public int getRenderId() { - return this.mRenderID; - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/render/MachineBlockRenderer.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/MachineBlockRenderer.java new file mode 100644 index 0000000000..7ce7002738 --- /dev/null +++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/MachineBlockRenderer.java @@ -0,0 +1,1250 @@ +package gtPlusPlus.xmod.gregtech.common.render; + +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_DOWN; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_EAST; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_NORTH; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_SOUTH; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_UP; +import static gregtech.api.interfaces.metatileentity.IConnectable.CONNECTED_WEST; +import static gregtech.api.interfaces.metatileentity.IConnectable.HAS_FOAM; +import static gregtech.api.interfaces.metatileentity.IConnectable.NO_CONNECTION; +import static net.minecraftforge.common.util.ForgeDirection.DOWN; +import static net.minecraftforge.common.util.ForgeDirection.EAST; +import static net.minecraftforge.common.util.ForgeDirection.NORTH; +import static net.minecraftforge.common.util.ForgeDirection.SOUTH; +import static net.minecraftforge.common.util.ForgeDirection.UP; +import static net.minecraftforge.common.util.ForgeDirection.WEST; + +import java.util.EnumMap; +import java.util.EnumSet; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +import org.lwjgl.opengl.GL11; + +import cpw.mods.fml.client.registry.RenderingRegistry; +import gregtech.api.GregTechAPI; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.metatileentity.IMetaTileEntity; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.interfaces.tileentity.IPipeRenderedTileEntity; +import gregtech.api.interfaces.tileentity.ITexturedTileEntity; +import gregtech.api.metatileentity.MetaPipeEntity; +import gregtech.common.blocks.BlockMachines; +import gregtech.common.render.GTRendererBlock; +import gtPlusPlus.xmod.gregtech.common.helpers.GTMethodHelper; + +public class MachineBlockRenderer extends GTRendererBlock { + + public static MachineBlockRenderer INSTANCE; + public final int mRenderID = RenderingRegistry.getNextAvailableRenderId(); + + public MachineBlockRenderer() { + INSTANCE = this; + RenderingRegistry.registerBlockHandler(this); + } + + private static ITexture[] getTexture(IMetaTileEntity tile, ForgeDirection side, ForgeDirection facing, + int colorIndex, boolean active, boolean arg5) { + final IGregTechTileEntity gtTile = tile.getBaseMetaTileEntity(); + return tile.getTexture(gtTile, side, facing, (byte) colorIndex, active, arg5); + } + + private static ITexture[] getTexture(IMetaTileEntity tile, ForgeDirection side, int facingMask, int colorIndex, + boolean active, boolean arg5) { + final MetaPipeEntity gtTile = (MetaPipeEntity) tile.getBaseMetaTileEntity(); + return gtTile.getTexture((IGregTechTileEntity) tile, side, facingMask, colorIndex, active, arg5); + } + + private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, RenderBlocks aRenderer) { + if (aMeta > 0 && aMeta < GregTechAPI.METATILEENTITIES.length) { + IMetaTileEntity tMetaTileEntity = GregTechAPI.METATILEENTITIES[aMeta]; + if (tMetaTileEntity != null) { + aBlock.setBlockBoundsForItemRender(); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + if (tMetaTileEntity.getBaseMetaTileEntity() instanceof IPipeRenderedTileEntity pipeRenderedTile) { + float tThickness = pipeRenderedTile.getThickNess(); + float sp = (1.0F - tThickness) / 2.0F; + aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); + renderNegativeYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, DOWN, 0b001001, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); + renderPositiveYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, UP, 0b001001, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); + renderNegativeZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.NORTH, 0b001001, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); + renderPositiveZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.SOUTH, 0b001001, -1, false, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); + renderNegativeXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.WEST, 0b001001, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); + renderPositiveXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.EAST, 0b001001, -1, true, false), + true); + Tessellator.instance.draw(); + } else { + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); + renderNegativeYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, DOWN, ForgeDirection.WEST, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); + renderPositiveYFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, UP, ForgeDirection.WEST, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); + renderNegativeZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.NORTH, ForgeDirection.WEST, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); + renderPositiveZFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.SOUTH, ForgeDirection.WEST, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); + renderNegativeXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.WEST, ForgeDirection.WEST, -1, true, false), + true); + Tessellator.instance.draw(); + Tessellator.instance.startDrawingQuads(); + Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); + renderPositiveXFacing( + null, + aRenderer, + aBlock, + 0, + 0, + 0, + getTexture(tMetaTileEntity, ForgeDirection.EAST, ForgeDirection.WEST, -1, true, false), + true); + Tessellator.instance.draw(); + } + + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + } + } + + public boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, + RenderBlocks aRenderer) { + TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + + return tTileEntity instanceof ITexturedTileEntity + ? renderStandardBlock( + aWorld, + aX, + aY, + aZ, + aBlock, + aRenderer, + new ITexture[][] { GTMethodHelper.getTexture(tTileEntity, aBlock, DOWN), + GTMethodHelper.getTexture(tTileEntity, aBlock, UP), + GTMethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.NORTH), + GTMethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.SOUTH), + GTMethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.WEST), + GTMethodHelper.getTexture(tTileEntity, aBlock, ForgeDirection.EAST) }) + : false; + } + + public boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, + RenderBlocks aRenderer, ITexture[][] aTextures) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[DOWN.ordinal()], true); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[UP.ordinal()], true); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.NORTH.ordinal()], true); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.SOUTH.ordinal()], true); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.WEST.ordinal()], true); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[ForgeDirection.EAST.ordinal()], true); + return true; + } + + public boolean renderPipeBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, + IPipeRenderedTileEntity aTileEntity, RenderBlocks aRenderer) { + final int aConnections = aTileEntity.getConnections(); + if ((aConnections & HAS_FOAM) != 0) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } else { + float tThickness = aTileEntity.getThickNess(); + if (tThickness >= 0.99F) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } else { + float sp = (1.0F - tThickness) / 2.0F; + int connexionSidesBits = 0; + + for (int ordinalSide = 0; ordinalSide < 6; ++ordinalSide) { + if ((aConnections & 1 << ordinalSide) != 0) { + connexionSidesBits = connexionSidesBits | 1 << (ordinalSide + 2) % 6; + } + } + + final EnumSet coveredSides = EnumSet.noneOf(ForgeDirection.class); + + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (aTileEntity.getCoverIDAtSide(side) != 0) coveredSides.add(side); + } + + if (coveredSides.containsAll(EnumSet.of(DOWN, UP, NORTH, SOUTH, WEST, EAST))) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + } else { + final EnumMap texture = new EnumMap<>(ForgeDirection.class); + final EnumMap textureUncovered = new EnumMap<>(ForgeDirection.class); + + for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + texture.put(side, GTMethodHelper.getTexture((TileEntity) aTileEntity, aBlock, side)); + textureUncovered.put(side, aTileEntity.getTextureUncovered(side)); + } + + switch (connexionSidesBits) { + case NO_CONNECTION -> { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + } + case (CONNECTED_DOWN | CONNECTED_UP) -> { + aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + if (!coveredSides.contains(WEST)) { + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + } + if (!coveredSides.contains(EAST)) { + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + } + } + case (CONNECTED_NORTH | CONNECTED_SOUTH) -> { + aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, 1.0F, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + if (!coveredSides.contains(DOWN)) { + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + } + if (!coveredSides.contains(UP)) { + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + } + } + case (CONNECTED_WEST | CONNECTED_EAST) -> { + aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + if (!coveredSides.contains(NORTH)) { + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + } + if (!coveredSides.contains(SOUTH)) { + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + } + } + default -> { + if ((connexionSidesBits & CONNECTED_DOWN) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + } else { + aBlock.setBlockBounds(0.0F, sp, sp, sp, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + if (!coveredSides.contains(WEST)) { + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + } + } + if ((connexionSidesBits & CONNECTED_UP) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + } else { + aBlock.setBlockBounds(sp + tThickness, sp, sp, 1.0F, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + if (!coveredSides.contains(EAST)) { + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + } + } + if ((connexionSidesBits & CONNECTED_NORTH) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + } else { + aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, sp, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + if (!coveredSides.contains(DOWN)) { + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + } + } + if ((connexionSidesBits & CONNECTED_SOUTH) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + } else { + aBlock.setBlockBounds(sp, sp + tThickness, sp, sp + tThickness, 1.0F, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + if (!coveredSides.contains(UP)) { + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + } + } + if ((connexionSidesBits & CONNECTED_WEST) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + } else { + aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, sp); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + if (!coveredSides.contains(NORTH)) { + renderNegativeZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(NORTH), + false); + } + } + if ((connexionSidesBits & CONNECTED_EAST) == 0) { + aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + } else { + aBlock.setBlockBounds(sp, sp, sp + tThickness, sp + tThickness, sp + tThickness, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(DOWN), + false); + renderPositiveYFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(UP), + false); + renderNegativeXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(WEST), + false); + renderPositiveXFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(EAST), + false); + if (!coveredSides.contains(SOUTH)) { + renderPositiveZFacing( + aWorld, + aRenderer, + aBlock, + aX, + aY, + aZ, + textureUncovered.get(SOUTH), + false); + } + } + } + } + + if (coveredSides.contains(DOWN)) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); + if (!coveredSides.contains(NORTH)) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); + } + + if (!coveredSides.contains(SOUTH)) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); + } + + if (!coveredSides.contains(WEST)) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); + } + + if (!coveredSides.contains(EAST)) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(DOWN), false); + } + } + + if (coveredSides.contains(UP)) { + aBlock.setBlockBounds(0.0F, 0.875F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); + if (!coveredSides.contains(NORTH)) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); + } + + if (!coveredSides.contains(SOUTH)) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); + } + + if (!coveredSides.contains(WEST)) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); + } + + if (!coveredSides.contains(EAST)) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(UP), false); + } + } + + if (coveredSides.contains(NORTH)) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.125F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!coveredSides.contains(DOWN)) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); + } + + if (!coveredSides.contains(UP)) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); + } + + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); + if (!coveredSides.contains(WEST)) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); + } + + if (!coveredSides.contains(EAST)) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(NORTH), false); + } + } + + if (coveredSides.contains(SOUTH)) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.875F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!coveredSides.contains(DOWN)) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); + } + + if (!coveredSides.contains(UP)) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); + } + + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); + if (!coveredSides.contains(WEST)) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); + } + + if (!coveredSides.contains(EAST)) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(SOUTH), false); + } + } + + if (coveredSides.contains(WEST)) { + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 0.125F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!coveredSides.contains(DOWN)) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); + } + + if (!coveredSides.contains(UP)) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); + } + + if (!coveredSides.contains(NORTH)) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); + } + + if (!coveredSides.contains(SOUTH)) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); + } + + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(WEST), false); + } + + if (coveredSides.contains(EAST)) { + aBlock.setBlockBounds(0.875F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + if (!coveredSides.contains(DOWN)) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); + } + + if (!coveredSides.contains(UP)) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); + } + + if (!coveredSides.contains(NORTH)) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); + } + + if (!coveredSides.contains(SOUTH)) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); + } + + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, texture.get(EAST), false); + } + + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + return true; + } + } + } + } + + public static void renderNegativeYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY - 1, aZ, 0)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY - 1 : aY, aZ)); + } + + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderYNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderPositiveYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY + 1, aZ, 1)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aFullBlock ? aY + 1 : aY, aZ)); + } + + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderYPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderNegativeZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ - 1, 2)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ - 1 : aZ)); + } + + aRenderer.flipTexture = !aFullBlock; + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderZNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderPositiveZFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ + 1, 3)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ + 1 : aZ)); + } + + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderZPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderNegativeXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX - 1, aY, aZ, 4)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX - 1 : aX, aY, aZ)); + } + + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderXNeg(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + public static void renderPositiveXFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, + int aZ, ITexture[] aIcon, boolean aFullBlock) { + if (aWorld != null) { + if (aFullBlock && !aBlock.shouldSideBeRendered(aWorld, aX + 1, aY, aZ, 5)) { + return; + } + + Tessellator.instance + .setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX + 1 : aX, aY, aZ)); + } + + aRenderer.flipTexture = !aFullBlock; + if (aIcon != null) { + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderXPos(aRenderer, aBlock, aX, aY, aZ); + } + } + } + + aRenderer.flipTexture = false; + } + + @Override + public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { + aMeta += 30400; + if (aBlock instanceof BlockMachines) { + if (aMeta > 0 && aMeta < GregTechAPI.METATILEENTITIES.length + && GregTechAPI.METATILEENTITIES[aMeta] != null + && !GregTechAPI.METATILEENTITIES[aMeta].renderInInventory(aBlock, aMeta, aRenderer)) { + renderNormalInventoryMetaTileEntity(aBlock, aMeta, aRenderer); + } + } + aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aRenderer.setRenderBoundsFromBlock(aBlock); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + @Override + public boolean renderWorldBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, int aModelID, + RenderBlocks aRenderer) { + TileEntity aTileEntity = aWorld.getTileEntity(aX, aY, aZ); + return aTileEntity == null ? false + : (aTileEntity instanceof IGregTechTileEntity + && ((IGregTechTileEntity) aTileEntity).getMetaTileEntity() != null + && ((IGregTechTileEntity) aTileEntity).getMetaTileEntity() + .renderInWorld(aWorld, aX, aY, aZ, aBlock, aRenderer) + ? true + : (aTileEntity instanceof IPipeRenderedTileEntity + ? renderPipeBlock( + aWorld, + aX, + aY, + aZ, + aBlock, + (IPipeRenderedTileEntity) aTileEntity, + aRenderer) + : renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer))); + } + + @Override + public boolean shouldRender3DInInventory(int aModel) { + return true; + } + + @Override + public int getRenderId() { + return this.mRenderID; + } +} -- cgit