diff options
author | Kiwi <42833050+Kiwi233@users.noreply.github.com> | 2021-07-05 22:06:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-05 22:06:44 +0800 |
commit | 4eaefbb5455dc3402b43dcbf6cba208cea4e301a (patch) | |
tree | b7e34b2e20af663cdd72c616fd7424301304e3e4 /src/main/java/gregtech/common/render | |
parent | 36406947fc5c0de1ee71da2644ec057b5fbc8d25 (diff) | |
parent | 703a8930bee25b1f908e9c4ea4f52cef24337d03 (diff) | |
download | GT5-Unofficial-4eaefbb5455dc3402b43dcbf6cba208cea4e301a.tar.gz GT5-Unofficial-4eaefbb5455dc3402b43dcbf6cba208cea4e301a.tar.bz2 GT5-Unofficial-4eaefbb5455dc3402b43dcbf6cba208cea4e301a.zip |
Merge pull request #3 from GTNewHorizons/experimental
gregtech-5.09.35.00
Diffstat (limited to 'src/main/java/gregtech/common/render')
13 files changed, 1401 insertions, 467 deletions
diff --git a/src/main/java/gregtech/common/render/GT_CapeRenderer.java b/src/main/java/gregtech/common/render/GT_CapeRenderer.java index be95d7fb04..713254046e 100644 --- a/src/main/java/gregtech/common/render/GT_CapeRenderer.java +++ b/src/main/java/gregtech/common/render/GT_CapeRenderer.java @@ -15,8 +15,7 @@ import org.lwjgl.opengl.GL11; import java.util.Collection; -public class GT_CapeRenderer - extends RenderPlayer { +public class GT_CapeRenderer extends RenderPlayer { private final ResourceLocation[] mCapes = { new ResourceLocation("gregtech:textures/BrainTechCape.png"), new ResourceLocation("gregtech:textures/GregTechCape.png"), new ResourceLocation("gregtech:textures/MrBrainCape.png"), @@ -41,7 +40,7 @@ public class GT_CapeRenderer if (aPlayer.isInvisible()) { return; } - if (GT_Utility.getPotion(aPlayer, Integer.valueOf(Potion.invisibility.id).intValue())) { + if (GT_Utility.getPotion(aPlayer, Potion.invisibility.id)) { return; } try { diff --git a/src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java b/src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java new file mode 100644 index 0000000000..fdd20026ab --- /dev/null +++ b/src/main/java/gregtech/common/render/GT_CopiedBlockTexture.java @@ -0,0 +1,123 @@ +package gregtech.common.render; + +import gregtech.api.interfaces.IBlockContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.util.LightingHelper; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; + +class GT_CopiedBlockTexture implements ITexture, IBlockContainer { + private final Block mBlock; + private final byte mSide, mMeta; + + GT_CopiedBlockTexture(Block aBlock, int aSide, int aMeta, short[] aRGBa, boolean allowAlpha) { + if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GT_CopiedBlockTexture"); + mBlock = aBlock; + mSide = (byte) aSide; + mMeta = (byte) aMeta; + } + + private IIcon getIcon(int aSide) { + if (mSide == 6) return mBlock.getIcon(aSide, mMeta); + return mBlock.getIcon(mSide, mMeta); + } + + @Override + public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + IIcon aIcon = getIcon(ForgeDirection.EAST.ordinal()); + aRenderer.field_152631_f = true; + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 1.0f, 0.0f, 0.0f); + new LightingHelper(aRenderer) + .setupLightingXPos(aBlock, aX, aY, aZ) + .setupColor(ForgeDirection.EAST.ordinal(), 0xffffff); + aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, aIcon); + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + aRenderer.field_152631_f = false; + } + + @Override + public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, -1.0f, 0.0f, 0.0f); + IIcon aIcon = getIcon(ForgeDirection.WEST.ordinal()); + new LightingHelper(aRenderer) + .setupLightingXNeg(aBlock, aX, aY, aZ) + .setupColor(ForgeDirection.WEST.ordinal(), 0xffffff); + aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, aIcon); + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + } + + @Override + public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 0.0f, 1.0f, 0.0f); + IIcon aIcon = getIcon(ForgeDirection.UP.ordinal()); + new LightingHelper(aRenderer) + .setupLightingYPos(aBlock, aX, aY, aZ) + .setupColor(ForgeDirection.UP.ordinal(), 0xffffff); + aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, aIcon); + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + } + + @Override + public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f); + IIcon aIcon = getIcon(ForgeDirection.DOWN.ordinal()); + new LightingHelper(aRenderer) + .setupLightingYNeg(aBlock, aX, aY, aZ) + .setupColor(ForgeDirection.DOWN.ordinal(), 0xffffff); + aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, aIcon); + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + } + + @Override + public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 0.0f, 0.0f, 1.0f); + IIcon aIcon = getIcon(ForgeDirection.SOUTH.ordinal()); + new LightingHelper(aRenderer) + .setupLightingZPos(aBlock, aX, aY, aZ) + .setupColor(ForgeDirection.SOUTH.ordinal(), 0xffffff); + aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, aIcon); + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + } + + @Override + public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 0.0f, 0.0f, -1.0f); + IIcon aIcon = getIcon(ForgeDirection.NORTH.ordinal()); + aRenderer.field_152631_f = true; + new LightingHelper(aRenderer) + .setupLightingZNeg(aBlock, aX, aY, aZ) + .setupColor(ForgeDirection.NORTH.ordinal(), 0xffffff); + aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, aIcon); + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + aRenderer.field_152631_f = false; + } + + @Override + public boolean isValidTexture() { + return mBlock != null; + } + + @Override + public Block getBlock() { + return mBlock; + } + + @Override + public byte getMeta() { + return mMeta; + } +} diff --git a/src/main/java/gregtech/common/render/GT_FlaskRenderer.java b/src/main/java/gregtech/common/render/GT_FlaskRenderer.java index 8b1f505314..7ba4d8e037 100644 --- a/src/main/java/gregtech/common/render/GT_FlaskRenderer.java +++ b/src/main/java/gregtech/common/render/GT_FlaskRenderer.java @@ -21,15 +21,18 @@ public final class GT_FlaskRenderer implements net.minecraftforge.client.IItemRe MinecraftForgeClient.registerItemRenderer(ItemList.VOLUMETRIC_FLASK.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(); IIcon icon = item.getIconIndex(); @@ -86,4 +89,4 @@ public final class GT_FlaskRenderer implements net.minecraftforge.client.IItemRe GL11.glDisable(3008); GL11.glDisable(3042); } -}
\ No newline at end of file +} diff --git a/src/main/java/gregtech/common/render/GT_MetaGenerated_Item_Renderer.java b/src/main/java/gregtech/common/render/GT_MetaGenerated_Item_Renderer.java index b8b7a121f2..6e4aadc938 100644 --- a/src/main/java/gregtech/common/render/GT_MetaGenerated_Item_Renderer.java +++ b/src/main/java/gregtech/common/render/GT_MetaGenerated_Item_Renderer.java @@ -17,8 +17,7 @@ import org.lwjgl.opengl.GL11; import java.util.Iterator; -public class GT_MetaGenerated_Item_Renderer - implements IItemRenderer { +public class GT_MetaGenerated_Item_Renderer implements IItemRenderer { public GT_MetaGenerated_Item_Renderer() { GT_MetaGenerated_Item tItem; for (Iterator i$ = GT_MetaGenerated_Item.sInstances.values().iterator(); i$.hasNext(); MinecraftForgeClient.registerItemRenderer(tItem, this)) { @@ -26,6 +25,7 @@ public class GT_MetaGenerated_Item_Renderer } } + @Override public boolean handleRenderType(ItemStack aStack, IItemRenderer.ItemRenderType aType) { if ((GT_Utility.isStackInvalid(aStack)) || (aStack.getItemDamage() < 0)) { return false; @@ -33,6 +33,7 @@ public class GT_MetaGenerated_Item_Renderer return (aType == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) || (aType == IItemRenderer.ItemRenderType.INVENTORY) || (aType == IItemRenderer.ItemRenderType.EQUIPPED) || (aType == IItemRenderer.ItemRenderType.ENTITY); } + @Override public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType aType, ItemStack aStack, IItemRenderer.ItemRendererHelper aHelper) { if (GT_Utility.isStackInvalid(aStack)) { return false; @@ -40,6 +41,7 @@ public class GT_MetaGenerated_Item_Renderer return aType == IItemRenderer.ItemRenderType.ENTITY; } + @Override public void renderItem(IItemRenderer.ItemRenderType type, ItemStack aStack, Object... data) { if (GT_Utility.isStackInvalid(aStack)) { return; diff --git a/src/main/java/gregtech/common/render/GT_MetaGenerated_Tool_Renderer.java b/src/main/java/gregtech/common/render/GT_MetaGenerated_Tool_Renderer.java index 4f869fa149..a57f97792c 100644 --- a/src/main/java/gregtech/common/render/GT_MetaGenerated_Tool_Renderer.java +++ b/src/main/java/gregtech/common/render/GT_MetaGenerated_Tool_Renderer.java @@ -15,8 +15,7 @@ import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.client.MinecraftForgeClient; import org.lwjgl.opengl.GL11; -public class GT_MetaGenerated_Tool_Renderer - implements IItemRenderer { +public class GT_MetaGenerated_Tool_Renderer implements IItemRenderer { public GT_MetaGenerated_Tool_Renderer() { for (GT_MetaGenerated_Tool tItem : GT_MetaGenerated_Tool.sInstances.values()) { if (tItem != null) { @@ -25,6 +24,7 @@ public class GT_MetaGenerated_Tool_Renderer } } + @Override public boolean handleRenderType(ItemStack aStack, IItemRenderer.ItemRenderType aType) { if ((GT_Utility.isStackInvalid(aStack)) || (aStack.getItemDamage() < 0)) { return false; @@ -32,6 +32,7 @@ public class GT_MetaGenerated_Tool_Renderer return (aType == IItemRenderer.ItemRenderType.EQUIPPED_FIRST_PERSON) || (aType == IItemRenderer.ItemRenderType.INVENTORY) || (aType == IItemRenderer.ItemRenderType.EQUIPPED) || (aType == IItemRenderer.ItemRenderType.ENTITY); } + @Override public boolean shouldUseRenderHelper(IItemRenderer.ItemRenderType aType, ItemStack aStack, IItemRenderer.ItemRendererHelper aHelper) { if (GT_Utility.isStackInvalid(aStack)) { return false; @@ -39,6 +40,7 @@ public class GT_MetaGenerated_Tool_Renderer return aType == IItemRenderer.ItemRenderType.ENTITY; } + @Override public void renderItem(IItemRenderer.ItemRenderType aType, ItemStack aStack, Object... data) { if (GT_Utility.isStackInvalid(aStack)) { return; @@ -143,14 +145,14 @@ public class GT_MetaGenerated_Tool_Renderer } } Long[] tStats = aItem.getElectricStats(aStack); - if ((tStats != null) && (tStats[3].longValue() < 0L)) { + if ((tStats != null) && (tStats[3] < 0L)) { long tCharge = aItem.getRealCharge(aStack); if (tCharge <= 0L) { aIcon = gregtech.api.enums.Textures.ItemIcons.ENERGY_BAR[0]; - } else if (tCharge >= tStats[0].longValue()) { + } else if (tCharge >= tStats[0]) { aIcon = gregtech.api.enums.Textures.ItemIcons.ENERGY_BAR[8]; } else { - aIcon = gregtech.api.enums.Textures.ItemIcons.ENERGY_BAR[(7 - (int) java.lang.Math.max(0L, java.lang.Math.min(6L, (tStats[0].longValue() - tCharge) * 7L / tStats[0].longValue())))]; + aIcon = gregtech.api.enums.Textures.ItemIcons.ENERGY_BAR[(7 - (int) java.lang.Math.max(0L, java.lang.Math.min(6L, (tStats[0] - tCharge) * 7L / tStats[0])))]; } } else { aIcon = null; diff --git a/src/main/java/gregtech/common/render/GT_MultiTexture.java b/src/main/java/gregtech/common/render/GT_MultiTexture.java new file mode 100644 index 0000000000..eadcb39573 --- /dev/null +++ b/src/main/java/gregtech/common/render/GT_MultiTexture.java @@ -0,0 +1,58 @@ +package gregtech.common.render; + +import gregtech.api.interfaces.ITexture; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; + +/** + * <p>Lets Multiple ITextures Render overlay over each other.<</p> + * <p>I should have done this much earlier...</p> + */ +class GT_MultiTexture implements ITexture { + protected final ITexture[] mTextures; + + GT_MultiTexture(ITexture... aTextures) { + mTextures = aTextures; + } + + @Override + public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + for (ITexture tTexture : mTextures) + if (tTexture != null && tTexture.isValidTexture()) tTexture.renderXPos(aRenderer, aBlock, aX, aY, aZ); + } + + @Override + public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + for (ITexture tTexture : mTextures) + if (tTexture != null && tTexture.isValidTexture()) tTexture.renderXNeg(aRenderer, aBlock, aX, aY, aZ); + } + + @Override + public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + for (ITexture tTexture : mTextures) + if (tTexture != null && tTexture.isValidTexture()) tTexture.renderYPos(aRenderer, aBlock, aX, aY, aZ); + } + + @Override + public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + for (ITexture tTexture : mTextures) + if (tTexture != null && tTexture.isValidTexture()) tTexture.renderYNeg(aRenderer, aBlock, aX, aY, aZ); + } + + @Override + public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + for (ITexture tTexture : mTextures) + if (tTexture != null && tTexture.isValidTexture()) tTexture.renderZPos(aRenderer, aBlock, aX, aY, aZ); + } + + @Override + public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + for (ITexture tTexture : mTextures) + if (tTexture != null && tTexture.isValidTexture()) tTexture.renderZNeg(aRenderer, aBlock, aX, aY, aZ); + } + + @Override + public boolean isValidTexture() { + return true; + } +} diff --git a/src/main/java/gregtech/common/render/GT_RenderedGlowTexture.java b/src/main/java/gregtech/common/render/GT_RenderedGlowTexture.java new file mode 100644 index 0000000000..899e4d7c5d --- /dev/null +++ b/src/main/java/gregtech/common/render/GT_RenderedGlowTexture.java @@ -0,0 +1,213 @@ +package gregtech.common.render; + +import gregtech.GT_Mod; +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.IColorModulationContainer; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; + +import static gregtech.api.util.LightingHelper.MAX_BRIGHTNESS; + +/** + * This {@link ITexture} implementation renders texture with max brightness to glow in the dark. + */ + +class GT_RenderedGlowTexture implements ITexture, IColorModulationContainer { + protected final IIconContainer mIconContainer; + private final short[] mRGBa; + + GT_RenderedGlowTexture(IIconContainer aIcon, short[] aRGBa, boolean allowAlpha) { + if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GT_RenderedTexture"); + mIconContainer = GT_Mod.gregtechproxy.mRenderGlowTextures ? aIcon : BlockIcons.VOID; + mRGBa = aRGBa; + } + + @Override + public short[] getRGBA() { + return mRGBa; + } + + @Override + public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + if (aRenderer.useInventoryTint) return; // TODO: Remove this once all addons have migrated to the new Texture API + if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; + final boolean enableAO = aRenderer.enableAO; + aRenderer.enableAO = false; + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, -1.0f, 0.0f, 0.0f); + Tessellator.instance.setBrightness(MAX_BRIGHTNESS); + Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]); + aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (mIconContainer.getOverlayIcon() != null) { + Tessellator.instance.setColorOpaque(255, 255, 255); + aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + } + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + aRenderer.enableAO = enableAO; + } + + @Override + public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + if (aRenderer.useInventoryTint) return; // TODO: Remove this once all addons have migrated to the new Texture API + if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; + aRenderer.field_152631_f = true; + final boolean enableAO = aRenderer.enableAO; + aRenderer.enableAO = false; + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 1.0f, 0.0f, 0.0f); + Tessellator.instance.setBrightness(MAX_BRIGHTNESS); + Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]); + aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (mIconContainer.getOverlayIcon() != null) { + Tessellator.instance.setColorOpaque(255, 255, 255); + aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + } + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + aRenderer.field_152631_f = false; + aRenderer.enableAO = enableAO; + } + + @Override + public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + if (aRenderer.useInventoryTint) return; // TODO: Remove this once all addons have migrated to the new Texture API + if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; + final boolean enableAO = aRenderer.enableAO; + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f); + final Tessellator tessellator = Tessellator.instance; + IIcon aIcon = mIconContainer.getIcon(); + + float minU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMaxX) * 16.0D); + float maxU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMinX) * 16.0D); + float minV = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D); + float maxV = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D); + + if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { + minU = 16.0F - aIcon.getMaxU(); + maxU = 16.0F - aIcon.getMinU(); + } + + if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { + minV = aIcon.getMinV(); + maxV = aIcon.getMaxV(); + } + + double minX = aX + aRenderer.renderMinX; + double maxX = aX + aRenderer.renderMaxX; + double minY = aY + aRenderer.renderMinY; + double minZ = aZ + aRenderer.renderMinZ; + double maxZ = aZ + aRenderer.renderMaxZ; + + Tessellator.instance.setBrightness(MAX_BRIGHTNESS); + Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]); + + tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV); + tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV); + tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV); + tessellator.addVertexWithUV(maxX, minY, maxZ, minU, maxV); + + if (mIconContainer.getOverlayIcon() != null) { + minU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMaxX) * 16.0D); + maxU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMinX) * 16.0D); + minV = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D); + maxV = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D); + + if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { + minU = 16.0F - aIcon.getMaxU(); + maxU = 16.0F - aIcon.getMinU(); + } + + if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { + minV = aIcon.getMinV(); + maxV = aIcon.getMaxV(); + } + + minX = aX + (float) aRenderer.renderMinX; + maxX = aX + (float) aRenderer.renderMaxX; + minY = aY + (float) aRenderer.renderMinY; + minZ = aZ + (float) aRenderer.renderMinZ; + maxZ = aZ + (float) aRenderer.renderMaxZ; + + Tessellator.instance.setColorOpaque(255, 255, 255); + tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV); + tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV); + tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV); + tessellator.addVertexWithUV(maxX, minY, maxZ, minU, maxV); + } + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + aRenderer.enableAO = enableAO; + } + + @Override + public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + if (aRenderer.useInventoryTint) return; // TODO: Remove this once all addons have migrated to the new Texture API + if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; + final boolean enableAO = aRenderer.enableAO; + aRenderer.enableAO = false; + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 0.0f, 1.0f, 0.0f); + Tessellator.instance.setBrightness(MAX_BRIGHTNESS); + Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]); + aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (mIconContainer.getOverlayIcon() != null) { + Tessellator.instance.setColorOpaque(255, 255, 255); + aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + } + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + aRenderer.enableAO = enableAO; + } + + @Override + public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + if (aRenderer.useInventoryTint) return; // TODO: Remove this once all addons have migrated to the new Texture API + if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; + final boolean enableAO = aRenderer.enableAO; + aRenderer.enableAO = false; + aRenderer.field_152631_f = true; + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 0.0f, 0.0f, -1.0f); + Tessellator.instance.setBrightness(MAX_BRIGHTNESS); + Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]); + aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (mIconContainer.getOverlayIcon() != null) { + Tessellator.instance.setColorOpaque(255, 255, 255); + aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + } + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + aRenderer.field_152631_f = false; + aRenderer.enableAO = enableAO; + } + + @Override + public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + if (aRenderer.useInventoryTint) return; // TODO: Remove this once all addons have migrated to the new Texture API + if (!GT_Mod.gregtechproxy.mRenderGlowTextures) return; + final boolean enableAO = aRenderer.enableAO; + aRenderer.enableAO = false; + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 0.0f, 0.0f, 1.0f); + Tessellator.instance.setBrightness(MAX_BRIGHTNESS); + Tessellator.instance.setColorOpaque(mRGBa[0], mRGBa[1], mRGBa[2]); + aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (mIconContainer.getOverlayIcon() != null) { + aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + } + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + aRenderer.enableAO = enableAO; + } + + @Override + public boolean isValidTexture() { + return mIconContainer != null; + } +} diff --git a/src/main/java/gregtech/common/render/GT_RenderedTexture.java b/src/main/java/gregtech/common/render/GT_RenderedTexture.java new file mode 100644 index 0000000000..9e76634385 --- /dev/null +++ b/src/main/java/gregtech/common/render/GT_RenderedTexture.java @@ -0,0 +1,214 @@ +package gregtech.common.render; + +import gregtech.api.interfaces.IColorModulationContainer; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.util.LightingHelper; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.util.IIcon; +import net.minecraftforge.common.util.ForgeDirection; + +class GT_RenderedTexture implements ITexture, IColorModulationContainer { + protected final IIconContainer mIconContainer; + private final short[] mRGBa; + + GT_RenderedTexture(IIconContainer aIcon, short[] aRGBa, boolean allowAlpha) { + if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GT_RenderedTexture"); + mIconContainer = aIcon; + mRGBa = aRGBa; + } + + @Override + public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + aRenderer.field_152631_f = true; + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 1.0f, 0.0f, 0.0f); + LightingHelper lighting = new LightingHelper(aRenderer); + lighting.setupLightingXPos(aBlock, aX, aY, aZ) + .setupColor(ForgeDirection.EAST.ordinal(), mRGBa); + aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (mIconContainer.getOverlayIcon() != null) { + lighting.setupColor(ForgeDirection.EAST.ordinal(), 0xffffff); + aRenderer.renderFaceXPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + } + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + aRenderer.field_152631_f = false; + } + + @Override + public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, -1.0f, 0.0f, 0.0f); + LightingHelper lighting = new LightingHelper(aRenderer); + lighting.setupLightingXNeg(aBlock, aX, aY, aZ) + .setupColor(ForgeDirection.WEST.ordinal(), mRGBa); + aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (mIconContainer.getOverlayIcon() != null) { + lighting.setupColor(ForgeDirection.WEST.ordinal(), 0xffffff); + aRenderer.renderFaceXNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + } + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + } + + @Override + public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 0.0f, 1.0f, 0.0f); + LightingHelper lighting = new LightingHelper(aRenderer); + lighting.setupLightingYPos(aBlock, aX, aY, aZ) + .setupColor(ForgeDirection.UP.ordinal(), mRGBa); + aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (mIconContainer.getOverlayIcon() != null) { + lighting.setupColor(ForgeDirection.UP.ordinal(), 0xffffff); + aRenderer.renderFaceYPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + } + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + } + + @Override + public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f); + final Tessellator tessellator = Tessellator.instance; + IIcon aIcon = mIconContainer.getIcon(); + + float minU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMaxX) * 16.0D); + float maxU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMinX) * 16.0D); + float minV = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D); + float maxV = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D); + + if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { + minU = 16.0F - aIcon.getMaxU(); + maxU = 16.0F - aIcon.getMinU(); + } + + if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { + minV = aIcon.getMinV(); + maxV = aIcon.getMaxV(); + } + + double minX = aX + aRenderer.renderMinX; + double maxX = aX + aRenderer.renderMaxX; + double minY = aY + aRenderer.renderMinY; + double minZ = aZ + aRenderer.renderMinZ; + double maxZ = aZ + aRenderer.renderMaxZ; + + LightingHelper lighting = new LightingHelper(aRenderer); + lighting.setupLightingYNeg(aBlock, aX, aY, aZ) + .setupColor(ForgeDirection.DOWN.ordinal(), mRGBa); + + if (aRenderer.enableAO) { + tessellator.setColorOpaque_F(aRenderer.colorRedTopLeft, aRenderer.colorGreenTopLeft, aRenderer.colorBlueTopLeft); + tessellator.setBrightness(aRenderer.brightnessTopLeft); + tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV); + tessellator.setColorOpaque_F(aRenderer.colorRedBottomLeft, aRenderer.colorGreenBottomLeft, aRenderer.colorBlueBottomLeft); + tessellator.setBrightness(aRenderer.brightnessBottomLeft); + tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV); + tessellator.setColorOpaque_F(aRenderer.colorRedBottomRight, aRenderer.colorGreenBottomRight, aRenderer.colorBlueBottomRight); + tessellator.setBrightness(aRenderer.brightnessBottomRight); + tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV); + tessellator.setColorOpaque_F(aRenderer.colorRedTopRight, aRenderer.colorGreenTopRight, aRenderer.colorBlueTopRight); + tessellator.setBrightness(aRenderer.brightnessTopRight); + } else { + tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV); + tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV); + tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV); + } + tessellator.addVertexWithUV(maxX, minY, maxZ, minU, maxV); + + if (mIconContainer.getOverlayIcon() != null) { + minU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMaxX) * 16.0D); + maxU = aIcon.getInterpolatedU((1.0D - aRenderer.renderMinX) * 16.0D); + minV = aIcon.getInterpolatedV(aRenderer.renderMinZ * 16.0D); + maxV = aIcon.getInterpolatedV(aRenderer.renderMaxZ * 16.0D); + + if (aRenderer.renderMinX < 0.0D || aRenderer.renderMaxX > 1.0D) { + minU = 16.0F - aIcon.getMaxU(); + maxU = 16.0F - aIcon.getMinU(); + } + + if (aRenderer.renderMinZ < 0.0D || aRenderer.renderMaxZ > 1.0D) { + minV = aIcon.getMinV(); + maxV = aIcon.getMaxV(); + } + + minX = aX + (float)aRenderer.renderMinX; + maxX = aX + (float)aRenderer.renderMaxX; + minY = aY + (float)aRenderer.renderMinY; + minZ = aZ + (float)aRenderer.renderMinZ; + maxZ = aZ + (float)aRenderer.renderMaxZ; + + lighting.setupColor(ForgeDirection.DOWN.ordinal(), 0xffffff); + + if (aRenderer.enableAO) { + tessellator.setColorOpaque_F(aRenderer.colorRedTopLeft, aRenderer.colorGreenTopLeft, aRenderer.colorBlueTopLeft); + tessellator.setBrightness(aRenderer.brightnessTopLeft); + tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV); + tessellator.setColorOpaque_F(aRenderer.colorRedBottomLeft, aRenderer.colorGreenBottomLeft, aRenderer.colorBlueBottomLeft); + tessellator.setBrightness(aRenderer.brightnessBottomLeft); + tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV); + tessellator.setColorOpaque_F(aRenderer.colorRedBottomRight, aRenderer.colorGreenBottomRight, aRenderer.colorBlueBottomRight); + tessellator.setBrightness(aRenderer.brightnessBottomRight); + tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV); + tessellator.setColorOpaque_F(aRenderer.colorRedTopRight, aRenderer.colorGreenTopRight, aRenderer.colorBlueTopRight); + tessellator.setBrightness(aRenderer.brightnessTopRight); + } else { + tessellator.addVertexWithUV(minX, minY, maxZ, maxU, maxV); + tessellator.addVertexWithUV(minX, minY, minZ, maxU, minV); + tessellator.addVertexWithUV(maxX, minY, minZ, minU, minV); + } + tessellator.addVertexWithUV(maxX, minY, maxZ, minU, maxV); + } + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + } + + @Override + public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 0.0f, 0.0f, 1.0f); + LightingHelper lighting = new LightingHelper(aRenderer); + lighting.setupLightingZPos(aBlock, aX, aY, aZ) + .setupColor(ForgeDirection.SOUTH.ordinal(), mRGBa); + aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (mIconContainer.getOverlayIcon() != null) { + lighting.setupColor(ForgeDirection.SOUTH.ordinal(), 0xffffff); + aRenderer.renderFaceZPos(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + } + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + } + + @Override + public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 0.0f, 0.0f, -1.0f); + aRenderer.field_152631_f = true; + LightingHelper lighting = new LightingHelper(aRenderer); + lighting.setupLightingZNeg(aBlock, aX, aY, aZ) + .setupColor(ForgeDirection.NORTH.ordinal(), mRGBa); + aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (mIconContainer.getOverlayIcon() != null) { + lighting.setupColor(ForgeDirection.NORTH.ordinal(), 0xffffff); + aRenderer.renderFaceZNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + } + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + aRenderer.field_152631_f = false; + } + + @Override + public short[] getRGBA() { + return mRGBa; + } + + @Override + public boolean isValidTexture() { + return mIconContainer != null; + } +} diff --git a/src/main/java/gregtech/common/render/GT_Renderer_Block.java b/src/main/java/gregtech/common/render/GT_Renderer_Block.java index 5ee32f8dc6..a9eafd7854 100644 --- a/src/main/java/gregtech/common/render/GT_Renderer_Block.java +++ b/src/main/java/gregtech/common/render/GT_Renderer_Block.java @@ -2,6 +2,7 @@ package gregtech.common.render; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry; +import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -12,14 +13,36 @@ import gregtech.common.blocks.GT_Block_Machines; import gregtech.common.blocks.GT_Block_Ores_Abstract; import gregtech.common.blocks.GT_TileEntity_Ores; import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; import org.lwjgl.opengl.GL11; -public class GT_Renderer_Block - implements ISimpleBlockRenderingHandler { +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_FRESHFOAM; +import static gregtech.api.interfaces.metatileentity.IConnectable.HAS_HARDENEDFOAM; +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.VALID_DIRECTIONS; +import static net.minecraftforge.common.util.ForgeDirection.WEST; + +public class GT_Renderer_Block implements ISimpleBlockRenderingHandler { + public static final float blockMin = 0.0F; + public static final float blockMax = 1.0F; + private static final float coverThickness = blockMax / 8.0F; + private static final float coverInnerMin = blockMin + coverThickness; + private static final float coverInnerMax = blockMax - coverThickness; public static GT_Renderer_Block INSTANCE; public final int mRenderID; @@ -29,559 +52,638 @@ public class GT_Renderer_Block RenderingRegistry.registerBlockHandler(this); } - private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, RenderBlocks aRenderer) { - if ((aMeta <= 0) || (aMeta >= GregTech_API.METATILEENTITIES.length)) { - return; - } - IMetaTileEntity tMetaTileEntity = GregTech_API.METATILEENTITIES[aMeta]; - if (tMetaTileEntity == null) { - return; - } - 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)) { - float tThickness = ((IPipeRenderedTileEntity) tMetaTileEntity.getBaseMetaTileEntity()).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, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 0, (byte) 9, (byte) -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, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 1, (byte) 9, (byte) -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, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 2, (byte) 9, (byte) -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, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 3, (byte) 9, (byte) -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, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 4, (byte) 9, (byte) -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, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 5, (byte) 9, (byte) -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, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 0, (byte) 4, (byte) -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, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 1, (byte) 4, (byte) -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, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 2, (byte) 4, (byte) -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, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 3, (byte) 4, (byte) -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, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 4, (byte) 4, (byte) -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, tMetaTileEntity.getTexture(tMetaTileEntity.getBaseMetaTileEntity(), (byte) 5, (byte) 4, (byte) -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 static boolean renderStandardBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, RenderBlocks aRenderer) { TileEntity tTileEntity = aWorld.getTileEntity(aX, aY, aZ); + if ((tTileEntity instanceof IPipeRenderedTileEntity)) { + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, new ITexture[][]{ + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) DOWN.ordinal()), + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) UP.ordinal()), + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) NORTH.ordinal()), + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) SOUTH.ordinal()), + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) WEST.ordinal()), + ((IPipeRenderedTileEntity) tTileEntity).getTextureCovered((byte) EAST.ordinal())}); + } if ((tTileEntity instanceof ITexturedTileEntity)) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, new ITexture[][]{((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 0), ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 1), ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 2), ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 3), ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 4), ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) 5)}); + return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer, new ITexture[][]{ + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) DOWN.ordinal()), + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) UP.ordinal()), + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) NORTH.ordinal()), + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) SOUTH.ordinal()), + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) WEST.ordinal()), + ((ITexturedTileEntity) tTileEntity).getTexture(aBlock, (byte) EAST.ordinal())}); } return false; } public static 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); + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[0], true); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[1], true); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[2], true); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[3], true); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[4], true); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[5], true); + 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[NORTH.ordinal()], true); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[SOUTH.ordinal()], true); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[WEST.ordinal()], true); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, aTextures[EAST.ordinal()], true); return true; } public static boolean renderPipeBlock(IBlockAccess aWorld, int aX, int aY, int aZ, Block aBlock, IPipeRenderedTileEntity aTileEntity, RenderBlocks aRenderer) { - byte aConnections = aTileEntity.getConnections(); - if ((aConnections & 0xC0) != 0) { + final byte aConnections = aTileEntity.getConnections(); + if ((aConnections & (HAS_FRESHFOAM | HAS_HARDENEDFOAM)) != 0) { return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); } - float tThickness = aTileEntity.getThickNess(); - if (tThickness >= 0.99F) { + final float thickness = aTileEntity.getThickNess(); + if (thickness >= 0.99F) { return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); } - float sp = (1.0F - tThickness) / 2.0F; - - byte tConnections = 0; - for (byte i = 0; i < 6; i = (byte) (i + 1)) { - if ((aConnections & 1 << i) != 0) { - tConnections = (byte) (tConnections | 1 << (i + 2) % 6); - } + // Range of block occupied by pipe + final float pipeMin = (blockMax - thickness) / 2.0F; + final float pipeMax = blockMax - pipeMin; + final boolean[] tIsCovered = new boolean[VALID_DIRECTIONS.length]; + for (int i = 0; i < VALID_DIRECTIONS.length; i++) { + tIsCovered[i] = (aTileEntity.getCoverIDAtSide((byte) i) != 0); } - boolean[] tIsCovered = new boolean[6]; - for (byte i = 0; i < 6; i = (byte) (i + 1)) { - tIsCovered[i] = (aTileEntity.getCoverIDAtSide(i) != 0); - } - if ((tIsCovered[0]) && (tIsCovered[1]) && (tIsCovered[2]) && (tIsCovered[3]) && (tIsCovered[4]) && (tIsCovered[5])) { - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); - } - ITexture[][] tIcons = new ITexture[6][]; - ITexture[][] tCovers = new ITexture[6][]; - for (byte i = 0; i < 6; i = (byte) (i + 1)) { - tCovers[i] = aTileEntity.getTexture(aBlock, i); - tIcons[i] = aTileEntity.getTextureUncovered(i); + + final ITexture[][] tIcons = new ITexture[VALID_DIRECTIONS.length][]; + final ITexture[][] tCovers = new ITexture[VALID_DIRECTIONS.length][]; + for (int i = 0; i < VALID_DIRECTIONS.length; i++) { + tCovers[i] = aTileEntity.getTexture(aBlock, (byte) i); + tIcons[i] = aTileEntity.getTextureUncovered((byte) i); } - if (tConnections == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - } else if (tConnections == 3) { - aBlock.setBlockBounds(0.0F, sp, sp, 1.0F, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - if (!tIsCovered[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - } - if (!tIsCovered[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - } - } else if (tConnections == 12) { - aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, 1.0F, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - if (!tIsCovered[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - } - if (!tIsCovered[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - } - } else if (tConnections == 48) { - aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - if (!tIsCovered[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - } - if (!tIsCovered[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - } - } else { - if ((tConnections & 0x1) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + + switch (aConnections) { + case NO_CONNECTION: + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - } else { - aBlock.setBlockBounds(0.0F, sp, sp, sp, sp + tThickness, sp + tThickness); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + break; + case CONNECTED_EAST | CONNECTED_WEST: + // EAST - WEST Pipe Sides + aBlock.setBlockBounds(blockMin, pipeMin, pipeMin, blockMax, pipeMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - if (!tIsCovered[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - } - } - if ((tConnections & 0x2) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + + // EAST - WEST Pipe Ends + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + break; + case CONNECTED_DOWN | CONNECTED_UP: + // UP - DOWN Pipe Sides + aBlock.setBlockBounds(pipeMin, blockMin, pipeMin, pipeMax, blockMax, pipeMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - } else { - aBlock.setBlockBounds(sp + tThickness, sp, sp, 1.0F, sp + tThickness, sp + tThickness); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + + // UP - DOWN Pipe Ends + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + break; + case CONNECTED_NORTH | CONNECTED_SOUTH: + // NORTH - SOUTH Pipe Sides + aBlock.setBlockBounds(pipeMin, pipeMin, blockMin, pipeMax, pipeMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - if (!tIsCovered[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + + // NORTH - SOUTH Pipe Ends + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + break; + default: + if ((aConnections & CONNECTED_WEST) == 0) { + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + } else { + aBlock.setBlockBounds(blockMin, pipeMin, pipeMin, pipeMin, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); } - } - if ((tConnections & 0x4) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - } else { - aBlock.setBlockBounds(sp, 0.0F, sp, sp + tThickness, sp, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - if (!tIsCovered[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + + if ((aConnections & CONNECTED_EAST) == 0) { + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + } else { + aBlock.setBlockBounds(pipeMax, pipeMin, pipeMin, blockMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); } - } - if ((tConnections & 0x8) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - } else { - aBlock.setBlockBounds(sp, sp + tThickness, sp, sp + tThickness, 1.0F, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - if (!tIsCovered[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + + if ((aConnections & CONNECTED_DOWN) == 0) { + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + } else { + aBlock.setBlockBounds(pipeMin, blockMin, pipeMin, pipeMax, pipeMin, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); } - } - if ((tConnections & 0x10) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); - } else { - aBlock.setBlockBounds(sp, sp, 0.0F, sp + tThickness, sp + tThickness, sp); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - if (!tIsCovered[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[2], false); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + + if ((aConnections & CONNECTED_UP) == 0) { + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + } else { + aBlock.setBlockBounds(pipeMin, pipeMax, pipeMin, pipeMax, blockMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); } - } - if ((tConnections & 0x20) == 0) { - aBlock.setBlockBounds(sp, sp, sp, sp + tThickness, sp + tThickness, sp + tThickness); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); - } else { - aBlock.setBlockBounds(sp, sp, sp + tThickness, sp + tThickness, sp + tThickness, 1.0F); - aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[1], false); - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[5], false); - if (!tIsCovered[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[3], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + + if ((aConnections & CONNECTED_NORTH) == 0) { + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + } else { + aBlock.setBlockBounds(pipeMin, pipeMin, blockMin, pipeMax, pipeMax, pipeMin); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); } - } + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[NORTH.ordinal()], false); + + if ((aConnections & CONNECTED_SOUTH) == 0) { + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMin, pipeMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + } else { + aBlock.setBlockBounds(pipeMin, pipeMin, pipeMax, pipeMax, pipeMax, blockMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[DOWN.ordinal()], false); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[UP.ordinal()], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[WEST.ordinal()], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[EAST.ordinal()], false); + } + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tIcons[SOUTH.ordinal()], false); + break; } - if (tIsCovered[0]) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F); + + // Render covers on pipes + if (tIsCovered[DOWN.ordinal()]) { + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, coverInnerMin, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - if (!tIsCovered[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - } - if (!tIsCovered[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - } - if (!tIsCovered[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - } - if (!tIsCovered[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[0], false); - } - } - if (tIsCovered[1]) { - aBlock.setBlockBounds(0.0F, 0.875F, 0.0F, 1.0F, 1.0F, 1.0F); + if (!tIsCovered[NORTH.ordinal()]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + } + if (!tIsCovered[SOUTH.ordinal()]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + } + if (!tIsCovered[WEST.ordinal()]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + } + if (!tIsCovered[EAST.ordinal()]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + } + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + if ((aConnections & CONNECTED_DOWN) != 0) { + // Split outer face to leave hole for pipe + // Lower panel + aRenderer.setRenderBounds(blockMin, blockMin, blockMin, blockMax, blockMin, pipeMin); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + // Upper panel + aRenderer.setRenderBounds(blockMin, blockMin, pipeMax, blockMax, blockMin, blockMax); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + // Middle left panel + aRenderer.setRenderBounds(blockMin, blockMin, pipeMin, pipeMin, blockMin, pipeMax); + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + // Middle right panel + aRenderer.setRenderBounds(pipeMax, blockMin, pipeMin, blockMax, blockMin, pipeMax); + } + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[DOWN.ordinal()], false); + } + + if (tIsCovered[UP.ordinal()]) { + aBlock.setBlockBounds(blockMin, coverInnerMax, blockMin, blockMax, blockMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - if (!tIsCovered[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - } - if (!tIsCovered[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - } - if (!tIsCovered[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - } - if (!tIsCovered[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[1], false); - } - } - if (tIsCovered[2]) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.125F); + if (!tIsCovered[NORTH.ordinal()]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + } + if (!tIsCovered[SOUTH.ordinal()]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + } + if (!tIsCovered[WEST.ordinal()]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + } + if (!tIsCovered[EAST.ordinal()]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + } + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + if ((aConnections & CONNECTED_UP) != 0) { + // Split outer face to leave hole for pipe + // Lower panel + aRenderer.setRenderBounds(blockMin, blockMax, blockMin, blockMax, blockMax, pipeMin); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + // Upper panel + aRenderer.setRenderBounds(blockMin, blockMax, pipeMax, blockMax, blockMax, blockMax); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + // Middle left panel + aRenderer.setRenderBounds(blockMin, blockMax, pipeMin, pipeMin, blockMax, pipeMax); + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + // Middle right panel + aRenderer.setRenderBounds(pipeMax, blockMax, pipeMin, blockMax, blockMax, pipeMax); + } + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[UP.ordinal()], false); + } + + if (tIsCovered[NORTH.ordinal()]) { + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, coverInnerMin); aRenderer.setRenderBoundsFromBlock(aBlock); - if (!tIsCovered[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - } - if (!tIsCovered[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - } - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - if (!tIsCovered[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - } - if (!tIsCovered[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[2], false); - } - } - if (tIsCovered[3]) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.875F, 1.0F, 1.0F, 1.0F); + if (!tIsCovered[DOWN.ordinal()]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + } + if (!tIsCovered[UP.ordinal()]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + } + if (!tIsCovered[WEST.ordinal()]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + } + if (!tIsCovered[EAST.ordinal()]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + } + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + if ((aConnections & CONNECTED_NORTH) != 0) { + // Split outer face to leave hole for pipe + // Lower panel + aRenderer.setRenderBounds(blockMin, blockMin, blockMin, blockMax, pipeMin, blockMin); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + // Upper panel + aRenderer.setRenderBounds(blockMin, pipeMax, blockMin, blockMax, blockMax, blockMin); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + // Middle left panel + aRenderer.setRenderBounds(blockMin, pipeMin, blockMin, pipeMin, pipeMax, blockMin); + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + // Middle right panel + aRenderer.setRenderBounds(pipeMax, pipeMin, blockMin, blockMax, pipeMax, blockMin); + } + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[NORTH.ordinal()], false); + } + + if (tIsCovered[SOUTH.ordinal()]) { + aBlock.setBlockBounds(blockMin, blockMin, coverInnerMax, blockMax, blockMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); - if (!tIsCovered[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - } - if (!tIsCovered[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - } - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - if (!tIsCovered[4]) { - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - } - if (!tIsCovered[5]) { - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[3], false); - } - } - if (tIsCovered[4]) { - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 0.125F, 1.0F, 1.0F); + if (!tIsCovered[DOWN.ordinal()]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + } + if (!tIsCovered[UP.ordinal()]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + } + if (!tIsCovered[WEST.ordinal()]) { + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + } + if (!tIsCovered[EAST.ordinal()]) { + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + } + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + if ((aConnections & CONNECTED_SOUTH) != 0) { + // Split outer face to leave hole for pipe + // Lower panel + aRenderer.setRenderBounds(blockMin, blockMin, blockMax, blockMax, pipeMin, blockMax); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + // Upper panel + aRenderer.setRenderBounds(blockMin, pipeMax, blockMax, blockMax, blockMax, blockMax); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + // Middle left panel + aRenderer.setRenderBounds(blockMin, pipeMin, blockMax, pipeMin, pipeMax, blockMax); + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + // Middle right panel + aRenderer.setRenderBounds(pipeMax, pipeMin, blockMax, blockMax, pipeMax, blockMax); + } + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[SOUTH.ordinal()], false); + } + + if (tIsCovered[WEST.ordinal()]) { + aBlock.setBlockBounds(blockMin, blockMin, blockMin, coverInnerMin, blockMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); - if (!tIsCovered[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - } - if (!tIsCovered[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - } - if (!tIsCovered[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - } - if (!tIsCovered[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - } - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[4], false); - } - if (tIsCovered[5]) { - aBlock.setBlockBounds(0.875F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + if (!tIsCovered[DOWN.ordinal()]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + } + if (!tIsCovered[UP.ordinal()]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + } + if (!tIsCovered[NORTH.ordinal()]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + } + if (!tIsCovered[SOUTH.ordinal()]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + } + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + if ((aConnections & CONNECTED_WEST) != 0) { + // Split outer face to leave hole for pipe + // Lower panel + aRenderer.setRenderBounds(blockMin, blockMin, blockMin, blockMin, pipeMin, blockMax); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + // Upper panel + aRenderer.setRenderBounds(blockMin, pipeMax, blockMin, blockMin, blockMax, blockMax); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + // Middle left panel + aRenderer.setRenderBounds(blockMin, pipeMin, blockMin, blockMin, pipeMax, pipeMin); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + // Middle right panel + aRenderer.setRenderBounds(blockMin, pipeMin, pipeMax, blockMin, pipeMax, blockMax); + } + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[WEST.ordinal()], false); + } + + if (tIsCovered[EAST.ordinal()]) { + aBlock.setBlockBounds(coverInnerMax, blockMin, blockMin, blockMax, blockMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); - if (!tIsCovered[0]) { - renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + if (!tIsCovered[DOWN.ordinal()]) { + renderNegativeYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + } + if (!tIsCovered[UP.ordinal()]) { + renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); } - if (!tIsCovered[1]) { - renderPositiveYFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + if (!tIsCovered[NORTH.ordinal()]) { + renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); } - if (!tIsCovered[2]) { - renderNegativeZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + if (!tIsCovered[SOUTH.ordinal()]) { + renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); } - if (!tIsCovered[3]) { - renderPositiveZFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + + if ((aConnections & CONNECTED_EAST) != 0) { + // Split outer face to leave hole for pipe + // Lower panel + aRenderer.setRenderBounds(blockMax, blockMin, blockMin, blockMax, pipeMin, blockMax); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + // Upper panel + aRenderer.setRenderBounds(blockMax, pipeMax, blockMin, blockMax, blockMax, blockMax); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + // Middle left panel + aRenderer.setRenderBounds(blockMax, pipeMin, blockMin, blockMax, pipeMax, pipeMin); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); + // Middle right panel + aRenderer.setRenderBounds(blockMax, pipeMin, pipeMax, blockMax, pipeMax, blockMax); } - renderNegativeXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); - renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[5], false); + renderPositiveXFacing(aWorld, aRenderer, aBlock, aX, aY, aZ, tCovers[EAST.ordinal()], false); } - aBlock.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); aRenderer.setRenderBoundsFromBlock(aBlock); return true; } + @Override + public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { + aRenderer.enableAO = false; + aRenderer.useInventoryTint = true; + + GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + + if (aBlock instanceof GT_Block_Ores_Abstract) { + GT_TileEntity_Ores tTileEntity = new GT_TileEntity_Ores(); + tTileEntity.mMetaData = ((short) aMeta); + + aBlock.setBlockBoundsForItemRender(); + aRenderer.setRenderBoundsFromBlock(aBlock); + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(0, -1, 0); // TODO: Remove this once all addons have migrated to the new Texture API + renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) DOWN.ordinal()), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(0, 1, 0); // TODO: Remove this once all addons have migrated to the new Texture API + renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) UP.ordinal()), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(0, 0, -1); // TODO: Remove this once all addons have migrated to the new Texture API + renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) NORTH.ordinal()), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(0, 0, 1); // TODO: Remove this once all addons have migrated to the new Texture API + renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) SOUTH.ordinal()), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(-1, 0, 0); // TODO: Remove this once all addons have migrated to the new Texture API + renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) WEST.ordinal()), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(1, 0, 0); // TODO: Remove this once all addons have migrated to the new Texture API + renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) EAST.ordinal()), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + + } else if (aMeta > 0 + && (aMeta < GregTech_API.METATILEENTITIES.length) + && aBlock instanceof GT_Block_Machines + && (GregTech_API.METATILEENTITIES[aMeta] != null) + && (!GregTech_API.METATILEENTITIES[aMeta].renderInInventory(aBlock, aMeta, aRenderer))) { + renderNormalInventoryMetaTileEntity(aBlock, aMeta, aRenderer); + } + + aBlock.setBlockBounds(blockMin, blockMin, blockMin, blockMax, blockMax, blockMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + aRenderer.useInventoryTint = false; + } + + private static void renderNormalInventoryMetaTileEntity(Block aBlock, int aMeta, RenderBlocks aRenderer) { + if ((aMeta <= 0) || (aMeta >= GregTech_API.METATILEENTITIES.length)) { + return; + } + IMetaTileEntity tMetaTileEntity = GregTech_API.METATILEENTITIES[aMeta]; + if (tMetaTileEntity == null) { + return; + } + aBlock.setBlockBoundsForItemRender(); + aRenderer.setRenderBoundsFromBlock(aBlock); + + final IGregTechTileEntity iGregTechTileEntity = tMetaTileEntity.getBaseMetaTileEntity(); + + if ((iGregTechTileEntity instanceof IPipeRenderedTileEntity)) { + final float tThickness = ((IPipeRenderedTileEntity) iGregTechTileEntity).getThickNess(); + final float pipeMin = (blockMax - tThickness) / 2.0F; + final float pipeMax = blockMax - pipeMin; + + aBlock.setBlockBounds(blockMin, pipeMin, pipeMin, blockMax, pipeMax, pipeMax); + aRenderer.setRenderBoundsFromBlock(aBlock); + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(0, -1, 0); // TODO: Remove this once all addons have migrated to the new Texture API + renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) DOWN.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, false, false), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(0, 1, 0); // TODO: Remove this once all addons have migrated to the new Texture API + renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) UP.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, false, false), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(0, 0, -1); // TODO: Remove this once all addons have migrated to the new Texture API + renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) NORTH.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, false, false), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(0, 0, 1); // TODO: Remove this once all addons have migrated to the new Texture API + renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) SOUTH.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, false, false), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(-1, 0, 0); // TODO: Remove this once all addons have migrated to the new Texture API + renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) WEST.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, true, false), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(1, 0, 0); // TODO: Remove this once all addons have migrated to the new Texture API + renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) EAST.ordinal(), (byte) (CONNECTED_WEST | CONNECTED_EAST), (byte) -1, true, false), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + } else { + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(0, -1, 0); // TODO: Remove this once all addons have migrated to the new Texture API + renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) DOWN.ordinal(), (byte) WEST.ordinal(), (byte) -1, true, false), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(0, 1, 0); // TODO: Remove this once all addons have migrated to the new Texture API + renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) UP.ordinal(), (byte) WEST.ordinal(), (byte) -1, true, false), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(0, 0, -1); // TODO: Remove this once all addons have migrated to the new Texture API + renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) NORTH.ordinal(), (byte) WEST.ordinal(), (byte) -1, true, false), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(0, 0, 1); // TODO: Remove this once all addons have migrated to the new Texture API + renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) SOUTH.ordinal(), (byte) WEST.ordinal(), (byte) -1, true, false), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(-1, 0, 0); // TODO: Remove this once all addons have migrated to the new Texture API + renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) WEST.ordinal(), (byte) WEST.ordinal(), (byte) -1, true, false), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.startDrawingQuads(); // TODO: Remove this once all addons have migrated to the new Texture API + Tessellator.instance.setNormal(1, 0, 0); // TODO: Remove this once all addons have migrated to the new Texture API + renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tMetaTileEntity.getTexture(iGregTechTileEntity, (byte) EAST.ordinal(), (byte) WEST.ordinal(), (byte) -1, true, false), true); + Tessellator.instance.draw(); // TODO: Remove this once all addons have migrated to the new Texture API + } + } + public static void renderNegativeYFacing(IBlockAccess aWorld, RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ, ITexture[] aIcon, boolean aFullBlock) { - if (aWorld == null) return; - 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); - } + 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) return; + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderYNeg(aRenderer, aBlock, aX, aY, aZ); } } } 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; - } + 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); - } + if (aIcon == null) return; + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderYPos(aRenderer, aBlock, aX, aY, aZ); } } } 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; - } + if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX, aY, aZ - 1, 2))) return; Tessellator.instance.setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aX, aY, aFullBlock ? aZ - 1 : aZ)); } - if (aIcon != null) { - for (ITexture iTexture : aIcon) { - if (iTexture != null) { - iTexture.renderZNeg(aRenderer, aBlock, aX, aY, aZ); - } + if (aIcon == null) return; + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderZNeg(aRenderer, aBlock, aX, aY, aZ); } } } 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; - } + 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); - } + if (aIcon == null) return; + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderZPos(aRenderer, aBlock, aX, aY, aZ); } } } 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; - } + 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); - } + if (aIcon == null) return; + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderXNeg(aRenderer, aBlock, aX, aY, aZ); } } } 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; - } + if ((aFullBlock) && (!aBlock.shouldSideBeRendered(aWorld, aX + 1, aY, aZ, 5))) return; Tessellator.instance.setBrightness(aBlock.getMixedBrightnessForBlock(aWorld, aFullBlock ? aX + 1 : aX, aY, aZ)); } - if (aIcon != null) { - for (ITexture iTexture : aIcon) { - if (iTexture != null) { - iTexture.renderXPos(aRenderer, aBlock, aX, aY, aZ); - } + if (aIcon == null) return; + for (ITexture iTexture : aIcon) { + if (iTexture != null) { + iTexture.renderXPos(aRenderer, aBlock, aX, aY, aZ); } } } - public void renderInventoryBlock(Block aBlock, int aMeta, int aModelID, RenderBlocks aRenderer) { - 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); - } - } else if ((aBlock instanceof GT_Block_Ores_Abstract)) { - GT_TileEntity_Ores tTileEntity = new GT_TileEntity_Ores(); - tTileEntity.mMetaData = ((short) aMeta); - - aBlock.setBlockBoundsForItemRender(); - aRenderer.setRenderBoundsFromBlock(aBlock); - - GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, -1.0F, 0.0F); - renderNegativeYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 0), true); - Tessellator.instance.draw(); - - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 1.0F, 0.0F); - renderPositiveYFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 1), true); - Tessellator.instance.draw(); - - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, -1.0F); - renderNegativeZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 2), true); - Tessellator.instance.draw(); - - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(0.0F, 0.0F, 1.0F); - renderPositiveZFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 3), true); - Tessellator.instance.draw(); - - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(-1.0F, 0.0F, 0.0F); - renderNegativeXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 4), true); - Tessellator.instance.draw(); - - Tessellator.instance.startDrawingQuads(); - Tessellator.instance.setNormal(1.0F, 0.0F, 0.0F); - renderPositiveXFacing(null, aRenderer, aBlock, 0, 0, 0, tTileEntity.getTexture(aBlock, (byte) 5), 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); - } - + @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); - if (aTileEntity == null) { - return false; - } - if (aTileEntity instanceof IGregTechTileEntity && (((IGregTechTileEntity) aTileEntity).getMetaTileEntity() != null) && (((IGregTechTileEntity) aTileEntity).getMetaTileEntity().renderInWorld(aWorld, aX, aY, aZ, aBlock, aRenderer))) { + aRenderer.enableAO = Minecraft.isAmbientOcclusionEnabled() && GT_Mod.gregtechproxy.mRenderTileAmbientOcclusion; + aRenderer.useInventoryTint = false; + TileEntity tileEntity = aWorld.getTileEntity(aX, aY, aZ); + if (tileEntity == null) return false; + if (tileEntity instanceof IGregTechTileEntity) { + IMetaTileEntity metaTileEntity; + if ((metaTileEntity = ((IGregTechTileEntity) tileEntity).getMetaTileEntity()) != null && + metaTileEntity.renderInWorld(aWorld, aX, aY, aZ, aBlock, aRenderer)) { + aRenderer.enableAO = false; + return true; + } + } + if (tileEntity instanceof IPipeRenderedTileEntity && + renderPipeBlock(aWorld, aX, aY, aZ, aBlock, (IPipeRenderedTileEntity) tileEntity, aRenderer)) { + aRenderer.enableAO = false; return true; } - if ((aTileEntity instanceof IPipeRenderedTileEntity)) { - return renderPipeBlock(aWorld, aX, aY, aZ, aBlock, (IPipeRenderedTileEntity) aTileEntity, aRenderer); + if (renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer)) { + aRenderer.enableAO = false; + return true; } - return renderStandardBlock(aWorld, aX, aY, aZ, aBlock, aRenderer); + return false; } + @Override public boolean shouldRender3DInInventory(int aModel) { return true; } + @Override public int getRenderId() { return this.mRenderID; } diff --git a/src/main/java/gregtech/common/render/GT_Renderer_Entity_Arrow.java b/src/main/java/gregtech/common/render/GT_Renderer_Entity_Arrow.java index bbd791ec10..7feb8ce1b8 100644 --- a/src/main/java/gregtech/common/render/GT_Renderer_Entity_Arrow.java +++ b/src/main/java/gregtech/common/render/GT_Renderer_Entity_Arrow.java @@ -5,8 +5,7 @@ import net.minecraft.client.renderer.entity.RenderArrow; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -public class GT_Renderer_Entity_Arrow - extends RenderArrow { +public class GT_Renderer_Entity_Arrow extends RenderArrow { private final ResourceLocation mTexture; public GT_Renderer_Entity_Arrow(Class aArrowClass, String aTextureName) { @@ -14,6 +13,7 @@ public class GT_Renderer_Entity_Arrow RenderingRegistry.registerEntityRenderingHandler(aArrowClass, this); } + @Override protected ResourceLocation getEntityTexture(Entity p_110775_1_) { return this.mTexture; } diff --git a/src/main/java/gregtech/common/render/GT_SidedTexture.java b/src/main/java/gregtech/common/render/GT_SidedTexture.java new file mode 100644 index 0000000000..9bdee73eb0 --- /dev/null +++ b/src/main/java/gregtech/common/render/GT_SidedTexture.java @@ -0,0 +1,75 @@ +package gregtech.common.render; + +import gregtech.api.interfaces.IColorModulationContainer; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.render.TextureFactory; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; + +class GT_SidedTexture implements ITexture, IColorModulationContainer { + protected final ITexture[] mTextures; + /** + * DO NOT MANIPULATE THE VALUES INSIDE THIS ARRAY!!! + * <p/> + * Just set this variable to another different Array instead. + * Otherwise some colored things will get Problems. + */ + private final short[] mRGBa; + + GT_SidedTexture(IIconContainer aIcon0, IIconContainer aIcon1, IIconContainer aIcon2, IIconContainer aIcon3, IIconContainer aIcon4, IIconContainer aIcon5, short[] aRGBa, boolean aAllowAlpha) { + if (aRGBa.length != 4) throw new IllegalArgumentException("RGBa doesn't have 4 Values @ GT_RenderedTexture"); + mTextures = new ITexture[]{ + TextureFactory.of(aIcon0, aRGBa, aAllowAlpha), + TextureFactory.of(aIcon1, aRGBa, aAllowAlpha), + TextureFactory.of(aIcon2, aRGBa, aAllowAlpha), + TextureFactory.of(aIcon3, aRGBa, aAllowAlpha), + TextureFactory.of(aIcon4, aRGBa, aAllowAlpha), + TextureFactory.of(aIcon5, aRGBa, aAllowAlpha) + }; + mRGBa = aRGBa; + } + + @Override + public void renderXPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + mTextures[5].renderXPos(aRenderer, aBlock, aX ,aY, aZ); + } + + @Override + public void renderXNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + mTextures[4].renderXNeg(aRenderer, aBlock, aX ,aY, aZ); + } + + @Override + public void renderYPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + mTextures[1].renderYPos(aRenderer, aBlock, aX ,aY, aZ); + } + + @Override + public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + mTextures[0].renderYNeg(aRenderer, aBlock, aX ,aY, aZ); + } + + @Override + public void renderZPos(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + mTextures[3].renderZPos(aRenderer, aBlock, aX ,aY, aZ); + } + + @Override + public void renderZNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + mTextures[2].renderZNeg(aRenderer, aBlock, aX ,aY, aZ); + } + + @Override + public short[] getRGBA() { + return mRGBa; + } + + @Override + public boolean isValidTexture() { + for (ITexture renderedTexture : mTextures) { + if (!renderedTexture.isValidTexture()) return false; + } + return true; + } +} diff --git a/src/main/java/gregtech/common/render/GT_StdRenderedTexture.java b/src/main/java/gregtech/common/render/GT_StdRenderedTexture.java new file mode 100644 index 0000000000..ba0f9d3a91 --- /dev/null +++ b/src/main/java/gregtech/common/render/GT_StdRenderedTexture.java @@ -0,0 +1,36 @@ +package gregtech.common.render; + +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.util.LightingHelper; +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * This ITexture implementation extends the GT_RenderedTexture class + * to render with bottom side flipped as with dumb blocks rendering. + * It is used in Ore blocks rendering so they better blends with dumb block ores + * from vanilla or other mods, when seen from bottom. + */ +class GT_StdRenderedTexture extends GT_RenderedTexture{ + + GT_StdRenderedTexture(IIconContainer aIcon, short[] aRGBa, boolean allowAlpha) { + super(aIcon, aRGBa, allowAlpha); + } + + @Override + public void renderYNeg(RenderBlocks aRenderer, Block aBlock, int aX, int aY, int aZ) { + // TODO: Uncomment this once all addons have migrated to the new Texture API + //startDrawingQuads(aRenderer, 0.0f, -1.0f, 0.0f); + LightingHelper lighting = new LightingHelper(aRenderer); + lighting.setupLightingYNeg(aBlock, aX, aY, aZ) + .setupColor(ForgeDirection.DOWN.ordinal(), getRGBA()); + aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getIcon()); + if (mIconContainer.getOverlayIcon() != null) { + lighting.setupColor(ForgeDirection.DOWN.ordinal(), 0xffffff); + aRenderer.renderFaceYNeg(aBlock, aX, aY, aZ, mIconContainer.getOverlayIcon()); + } + // TODO: Uncomment this once all addons have migrated to the new Texture API + //draw(aRenderer); + } +} diff --git a/src/main/java/gregtech/common/render/GT_TextureBuilder.java b/src/main/java/gregtech/common/render/GT_TextureBuilder.java new file mode 100644 index 0000000000..22446f99a5 --- /dev/null +++ b/src/main/java/gregtech/common/render/GT_TextureBuilder.java @@ -0,0 +1,107 @@ +package gregtech.common.render; + +import gregtech.api.enums.Dyes; +import gregtech.api.interfaces.IIconContainer; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.ITextureBuilder; +import net.minecraft.block.Block; +import net.minecraftforge.common.util.ForgeDirection; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +@SuppressWarnings("unused") +public class GT_TextureBuilder implements ITextureBuilder { + private final List<IIconContainer> iconContainerList; + private final List<ITexture> textureLayers; + private Block fromBlock; + private int fromMeta; + private ForgeDirection fromSide; + private short[] rgba; + private boolean allowAlpha; + private boolean stdOrient; + private boolean glow; + + public GT_TextureBuilder() { + textureLayers = new ArrayList<>(); + iconContainerList = new ArrayList<>(); + rgba = Dyes._NULL.mRGBa; + allowAlpha = true; + stdOrient = false; + glow = false; + } + + @Override + public ITextureBuilder setFromBlock(final Block block, final int meta) { + this.fromBlock = block; + this.fromMeta = meta; + this.fromSide = ForgeDirection.UNKNOWN; + return this; + } + + @Override + public ITextureBuilder setFromSide(final ForgeDirection side) { + this.fromSide = side; + return this; + } + + @Override + public ITextureBuilder addIcon(final IIconContainer... iconContainers) { + this.iconContainerList.addAll(Arrays.asList(iconContainers)); + return this; + } + + @Override + public ITextureBuilder setRGBA(final short[] rgba) { + this.rgba = rgba; + return this; + } + + @Override + public ITextureBuilder addLayer(final ITexture... iTextures) { + this.textureLayers.addAll(Arrays.asList(iTextures)); + return this; + } + + @Override + public ITextureBuilder setAllowAlpha(final boolean allowAlpha) { + this.allowAlpha = allowAlpha; + return this; + } + + @Override + public ITextureBuilder stdOrient() { + this.stdOrient = true; + return this; + } + + @Override + public ITextureBuilder glow() { + glow = true; + return this; + } + + @Override + public ITexture build() { + if (fromBlock != null) return new GT_CopiedBlockTexture(fromBlock, fromSide.ordinal(), fromMeta, rgba, allowAlpha); + if (!textureLayers.isEmpty()) return new GT_MultiTexture(textureLayers.toArray(new ITexture[0])); + switch (iconContainerList.size()) { + case 1: + if (stdOrient) return new GT_StdRenderedTexture(iconContainerList.get(0), rgba, allowAlpha); + if (glow) return new GT_RenderedGlowTexture(iconContainerList.get(0), rgba, allowAlpha); + return new GT_RenderedTexture(iconContainerList.get(0), rgba, allowAlpha); + case 6: + return new GT_SidedTexture( + iconContainerList.get(ForgeDirection.DOWN.ordinal()), + iconContainerList.get(ForgeDirection.UP.ordinal()), + iconContainerList.get(ForgeDirection.NORTH.ordinal()), + iconContainerList.get(ForgeDirection.SOUTH.ordinal()), + iconContainerList.get(ForgeDirection.WEST.ordinal()), + iconContainerList.get(ForgeDirection.EAST.ordinal()), + rgba, allowAlpha); + default: + throw new IllegalStateException("Invalid sideIconContainer count"); + } + } +} |