From 8dbef429f5ac34a2e34f4bb8b1288efc982f4693 Mon Sep 17 00:00:00 2001 From: Calclavia Date: Mon, 5 Aug 2013 12:33:09 -0400 Subject: [PATCH] Finished multimeter model render --- src/resonantinduction/ResonantInduction.java | 4 +- .../multimeter/BlockMultimeter.java | 2 +- .../render/RenderMultimeter.java | 200 +++++++++--------- 3 files changed, 98 insertions(+), 108 deletions(-) diff --git a/src/resonantinduction/ResonantInduction.java b/src/resonantinduction/ResonantInduction.java index 414371fd..50a6e902 100644 --- a/src/resonantinduction/ResonantInduction.java +++ b/src/resonantinduction/ResonantInduction.java @@ -183,11 +183,11 @@ public class ResonantInduction metadata.modId = ID; metadata.name = NAME; metadata.description = "Resonant Induction is a Minecraft mod focusing on the manipulation of electricity and wireless technology. Ever wanted blazing electrical shocks flying off your evil lairs? You've came to the right place!"; - metadata.url = "http://universalelectricity.com"; + metadata.url = "http://universalelectricity.com/resonant-induction"; metadata.version = VERSION + BUILD_VERSION; metadata.authorList = Arrays.asList(new String[] { "Calclavia", "Aidancbrady" }); metadata.logoFile = "/"; - metadata.credits = "Thanks to Archadia for the assets."; + metadata.credits = "Thanks to Archadia for the awesome assets!"; metadata.autogenerated = true; } diff --git a/src/resonantinduction/multimeter/BlockMultimeter.java b/src/resonantinduction/multimeter/BlockMultimeter.java index 003bbda1..a0927087 100644 --- a/src/resonantinduction/multimeter/BlockMultimeter.java +++ b/src/resonantinduction/multimeter/BlockMultimeter.java @@ -35,7 +35,7 @@ public class BlockMultimeter extends BlockBase implements ITileEntityProvider */ public int onBlockPlaced(World par1World, int par2, int par3, int par4, int side, float hitX, float hitY, float hitZ, int metadata) { - return ForgeDirection.getOrientation(side).ordinal(); + return ForgeDirection.getOrientation(side).getOpposite().ordinal(); } @Override diff --git a/src/resonantinduction/render/RenderMultimeter.java b/src/resonantinduction/render/RenderMultimeter.java index f80a2229..ebb1ec8d 100644 --- a/src/resonantinduction/render/RenderMultimeter.java +++ b/src/resonantinduction/render/RenderMultimeter.java @@ -34,27 +34,24 @@ public class RenderMultimeter extends TileEntitySpecialRenderer ForgeDirection direction = ForgeDirection.getOrientation(tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord)); GL11.glPushMatrix(); - / GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); - GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5); - //GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90F, 0, 0, 1); - GL11.glTranslated(x + 0.5, y + 1.5, z + 0.5); -/* + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + GL11.glRotatef(90, 0, 0, 1); + GL11.glTranslated(0, -1, 0); + switch (direction) { + case UP: + GL11.glRotatef(90, 0, 1, 0); + break; case DOWN: + GL11.glRotatef(-90, 0, 1, 0); + break; + case NORTH: + GL11.glRotatef(180, 0, 1, 0); GL11.glRotatef(180, 0, 0, 1); GL11.glTranslatef(0, -2, 0); break; - case UP: - break; - case NORTH: - GL11.glTranslatef(1, 1, 0); - GL11.glRotatef(90, 0, 0, 1); - break; case SOUTH: - GL11.glTranslatef(-1, 1, 0); - GL11.glRotatef(-90, 0, 0, 1); break; case WEST: GL11.glTranslatef(0, 1, 1); @@ -65,103 +62,96 @@ public class RenderMultimeter extends TileEntitySpecialRenderer GL11.glRotatef(90, 1, 0, 0); break; } -*/ + this.func_110628_a(TEXTURE); MODEL.render(0.0625f); GL11.glPopMatrix(); - /** - * Render from side 2 to 6. This means render all sides excluding top and bottom. - */ - for (int side = 0; side < 6; side++) + GL11.glPushMatrix(); + GL11.glPolygonOffset(-10, -10); + GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); + + float dx = 1F / 16; + float dz = 1F / 16; + float displayWidth = 1 - 2F / 16; + float displayHeight = 1 - 2F / 16; + GL11.glTranslatef((float) x, (float) y, (float) z); + + switch (direction) { - if (direction.ordinal() != side) - { - GL11.glPushMatrix(); - GL11.glPolygonOffset(-10, -10); - GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); - - float dx = 1F / 16; - float dz = 1F / 16; - float displayWidth = 1 - 2F / 16; - float displayHeight = 1 - 2F / 16; - GL11.glTranslatef((float) x, (float) y, (float) z); - - switch (side) - { - case 1: - break; - case 0: - GL11.glTranslatef(1, 1, 0); - GL11.glRotatef(180, 1, 0, 0); - GL11.glRotatef(180, 0, 1, 0); - - break; - case 3: - GL11.glTranslatef(0, 1, 0); - GL11.glRotatef(0, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - - break; - case 2: - GL11.glTranslatef(1, 1, 1); - GL11.glRotatef(180, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - - break; - case 5: - GL11.glTranslatef(0, 1, 1); - GL11.glRotatef(90, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - - break; - case 4: - GL11.glTranslatef(1, 1, 0); - GL11.glRotatef(-90, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - - break; - } - - GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2); - GL11.glRotatef(-90, 1, 0, 0); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - - FontRenderer fontRenderer = this.getFontRenderer(); - - String joules = Math.round(tileEntity.getDetectedEnergy()) + " J"; - - int stringWidth = Math.max(fontRenderer.getStringWidth(joules), 0); - // maxWidth += 8; - int lineHeight = fontRenderer.FONT_HEIGHT + 2; - int requiredHeight = lineHeight * 1; - - /** - * Create an average scale. - */ - float scaleX = displayWidth / stringWidth; - float scaleY = displayHeight / requiredHeight; - float scale = (float) (Math.min(scaleX, scaleY) * 0.8); - GL11.glScalef(scale, -scale, scale); - GL11.glDepthMask(false); - - int realHeight = (int) Math.floor(displayHeight / scale); - int realWidth = (int) Math.floor(displayWidth / scale); - - int offsetY = (realHeight - requiredHeight) / 2; - int offsetX = (realWidth - stringWidth) / 2; - - GL11.glDisable(GL11.GL_LIGHTING); - fontRenderer.drawString(joules, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 0 * lineHeight, 1); - - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDepthMask(true); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); - GL11.glPopMatrix(); - } + case UP: + GL11.glTranslatef(1, 1, 0); + GL11.glRotatef(180, 1, 0, 0); + GL11.glRotatef(180, 0, 1, 0); + GL11.glTranslatef(0, -0.9f, -0.1f); + break; + case DOWN: + GL11.glRotatef(180, 0, 1, 0); + GL11.glTranslatef(-1, -0.9f, -1.1f); + break; + case SOUTH: + GL11.glTranslatef(1, 1, 1); + GL11.glRotatef(180, 0, 1, 0); + GL11.glRotatef(90, 1, 0, 0); + GL11.glTranslatef(0, -0.9f, -0.1f); + break; + case NORTH: + GL11.glTranslatef(0, 1, 0); + GL11.glRotatef(0, 0, 1, 0); + GL11.glRotatef(90, 1, 0, 0); + GL11.glTranslatef(0, -0.9f, -0.1f); + break; + case EAST: + GL11.glTranslatef(1, 1, 0); + GL11.glRotatef(-90, 0, 1, 0); + GL11.glRotatef(90, 1, 0, 0); + GL11.glTranslatef(0, -0.9f, -0.1f); + break; + case WEST: + GL11.glTranslatef(0, 1, 1); + GL11.glRotatef(90, 0, 1, 0); + GL11.glRotatef(90, 1, 0, 0); + GL11.glTranslatef(0, -0.9f, -0.1f); + break; } + + GL11.glTranslatef(dx + displayWidth / 2, 1F, dz + displayHeight / 2); + GL11.glRotatef(-90, 1, 0, 0); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + FontRenderer fontRenderer = this.getFontRenderer(); + + String joules = Math.round(tileEntity.getDetectedEnergy()) + " J"; + + int stringWidth = Math.max(fontRenderer.getStringWidth(joules), 0); + // maxWidth += 8; + int lineHeight = fontRenderer.FONT_HEIGHT + 2; + int requiredHeight = lineHeight * 1; + + /** + * Create an average scale. + */ + float scaleX = displayWidth / stringWidth; + float scaleY = displayHeight / requiredHeight; + float scale = (float) (Math.min(scaleX, scaleY) * 0.8); + GL11.glScalef(scale, -scale, scale); + GL11.glDepthMask(false); + + int realHeight = (int) Math.floor(displayHeight / scale); + int realWidth = (int) Math.floor(displayWidth / scale); + + int offsetY = (realHeight - requiredHeight) / 2; + int offsetX = (realWidth - stringWidth) / 2; + + GL11.glDisable(GL11.GL_LIGHTING); + fontRenderer.drawString(joules, offsetX - realWidth / 2, 1 + offsetY - realHeight / 2 + 0 * lineHeight, 1); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDepthMask(true); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); + GL11.glPopMatrix(); } } \ No newline at end of file