aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/gregtech/common/render
diff options
context:
space:
mode:
authorRaven Szewczyk <git@eigenraven.me>2024-05-24 19:50:35 +0100
committerRaven Szewczyk <git@eigenraven.me>2024-05-24 19:50:35 +0100
commit6d1b2216464d4dad449ac6fcfec476832224a55e (patch)
tree526a0c15f7056313c80e6c0386e025e9b3f61781 /src/main/java/gtPlusPlus/xmod/gregtech/common/render
parentb5d35f40afa606ed1b07061dad82e0521a59c186 (diff)
downloadGT5-Unofficial-6d1b2216464d4dad449ac6fcfec476832224a55e.tar.gz
GT5-Unofficial-6d1b2216464d4dad449ac6fcfec476832224a55e.tar.bz2
GT5-Unofficial-6d1b2216464d4dad449ac6fcfec476832224a55e.zip
Merge addon sources
Diffstat (limited to 'src/main/java/gtPlusPlus/xmod/gregtech/common/render')
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_CapeRenderer.java500
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_FlaskRenderer.java107
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.java1250
3 files changed, 1857 insertions, 0 deletions
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
new file mode 100644
index 0000000000..a281a205d2
--- /dev/null
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_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.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<String, String> aData : CapeUtils.mOrangeCapes) {
+ if (aData.getKey()
+ .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) {
+ tResource = mCapes[0];
+ hasCape = true;
+ break;
+ }
+ }
+ }
+ if (!hasCape) {
+ for (Pair<String, String> aData : CapeUtils.mMiscCapes) {
+ if (aData.getKey()
+ .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) {
+ tResource = mCapes[1];
+ hasCape = true;
+ break;
+ }
+ }
+ }
+ if (!hasCape) {
+ for (Pair<String, String> aData : CapeUtils.mBetaTestCapes) {
+ if (aData.getKey()
+ .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) {
+ tResource = mCapes[2];
+ hasCape = true;
+ break;
+ }
+ }
+ }
+ if (!hasCape) {
+ for (Pair<String, String> aData : CapeUtils.mPatreonCapes) {
+ if (aData.getKey()
+ .equals(aPlayerUUID) || aPlayerName.equals(aData.getValue())) {
+ tResource = mCapes[3];
+ hasCape = true;
+ break;
+ }
+ }
+ }
+ if (!hasCape) {
+ for (Pair<String, String> 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<Pair<String, String>> mOrangeCapes = new AutoMap<>();
+ private static final AutoMap<Pair<String, String>> mMiscCapes = new AutoMap<>();
+ private static final AutoMap<Pair<String, String>> mBetaTestCapes = new AutoMap<>();
+ private static final AutoMap<Pair<String, String>> mPatreonCapes = new AutoMap<>();
+ private static final AutoMap<Pair<String, String>> 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<String> getDataFromCache() {
+ File aCacheFile = getCapeCache();
+ List<String> 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<String> aCacheData = getDataFromCache();
+ if (aCacheData != null && !aCacheData.isEmpty()) {
+ if (sAES == null) {
+ sAES = new AES();
+ }
+ AutoMap<String> aDecodedData = new AutoMap<>();
+ for (String aToDecode : aCacheData) {
+ aDecodedData.put(sAES.decode(aToDecode));
+ }
+ if (!aDecodedData.isEmpty()) {
+ AutoMap<Pair<String, String>> aCapeType1 = new AutoMap<>();
+ AutoMap<Pair<String, String>> aCapeType2 = new AutoMap<>();
+ AutoMap<Pair<String, String>> aCapeType3 = new AutoMap<>();
+ AutoMap<Pair<String, String>> aCapeType4 = new AutoMap<>();
+ AutoMap<Pair<String, String>> 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<String, String> 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<String, String> aUser : aCapeType1) {
+ Logger.INFO("Adding Generic cape for " + aUser.getKey());
+ mOrangeCapes.add(aUser);
+ }
+ }
+ if (!aCapeType2.isEmpty()) {
+ for (Pair<String, String> aUser : aCapeType2) {
+ Logger.INFO("Adding Blue cape for " + aUser.getKey());
+ mMiscCapes.add(aUser);
+ }
+ }
+ if (!aCapeType3.isEmpty()) {
+ for (Pair<String, String> aUser : aCapeType3) {
+ Logger.INFO("Adding Beta cape for " + aUser.getKey());
+ mBetaTestCapes.add(aUser);
+ }
+ }
+ if (!aCapeType4.isEmpty()) {
+ for (Pair<String, String> aUser : aCapeType4) {
+ Logger.INFO("Adding Patreon cape for " + aUser.getKey());
+ mPatreonCapes.add(aUser);
+ }
+ }
+ if (!aCapeType5.isEmpty()) {
+ for (Pair<String, String> 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
new file mode 100644
index 0000000000..0c9e59e2f2
--- /dev/null
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_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.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
new file mode 100644
index 0000000000..bfd16b4cc5
--- /dev/null
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/render/GTPP_Render_MachineBlock.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.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<ForgeDirection> 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<ForgeDirection, ITexture[]> texture = new EnumMap<>(ForgeDirection.class);
+ final EnumMap<ForgeDirection, ITexture[]> 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;
+ }
+}