From 5530ab352b769f3893e766a69c63d340e9c7d04e Mon Sep 17 00:00:00 2001 From: Calclavia Date: Mon, 5 Aug 2013 11:59:14 -0400 Subject: [PATCH 1/3] Added model for multimeter --- .../textures/models/multimeter.png | Bin 0 -> 1848 bytes .../model/ModelMultimeter.java | 75 ++++++++++++++++++ .../multimeter/BlockMultimeter.java | 15 ++++ .../multimeter/ItemBlockMultimeter.java | 6 +- .../render/BlockRenderingHandler.java | 12 +++ .../render/RenderMultimeter.java | 43 ++++++++++ 6 files changed, 148 insertions(+), 3 deletions(-) create mode 100644 resources/assets/resonantinduction/textures/models/multimeter.png create mode 100644 src/resonantinduction/model/ModelMultimeter.java diff --git a/resources/assets/resonantinduction/textures/models/multimeter.png b/resources/assets/resonantinduction/textures/models/multimeter.png new file mode 100644 index 0000000000000000000000000000000000000000..869357fc22c85642c79771cb092c9aaa7c9d81b0 GIT binary patch literal 1848 zcmds2`#0MO7XLC)kI`xC)kTe%9fBIvjA~^ORimEcS;iw_l$y3=sr4vQlD5WrZA*p{ zn`m{ad5}syW2DM78%0dg&}hT9M57{_2SJdLGy7NU5BK@G=iGDe{hV_v!ova%8dw+r z0B|ty+}X%|TdEPg1N(Z!JLSc`0bTSB^#y>(wV&>!=ACqSIcY$6%8yyO&SC!1;JmM$-JMUkx+-#70pP%sz_Y&51@KiI3uzKy zQeGlFR0-1E^vGe^4nKc2?9{`A)!Vad{`rOQu;JWrDN|KdZQ>9KzVTo8S4S$Ow~m6e z9mXEZP%(n^^v2s>+{C6WC$EXz7)D3zd;*b}+21;hlFY5<thci8XkL}(O^zGVbJ+J+e*!ID z@WuK;Ai9Hf@+}(=C{+CR!?j$+0OR5nGIMB!HiNc(lR(O9EtH-r_aa5Ak31a96zWw~ zuWvcw8%6T4mL>}s7RJZE5V+|o{rNu0O2f@HzWCs$H!O!b&kN2ZyvtUQTUvB_dwWIy z_Q4l1Yl2eW@DCSvs~pa7 z=o5O}%H}u7F|-54MMi=%GA=g-S6v;@v%#jXuQSbn;PW~^SBl#&K;R)T82wsW?-;cU zfrV)i$avh~a{g|sc>ZI6-)RK?t$iFlOZqvu>aXwD#7+a<-Q{MW+ABWP@CyO9P~#A5 zUOZbSEgbw=32?p=fW~SB0;&p;^efVraEThOaK6WhD>$K5wi)+ue8z&52FA%p0>L&N9Uo!^sO@=!*CcLs-_N8}+hm%k(gQ9ssLNlEjOnkiyd#n`mj-Q%i%P(tz3i<_^G zGSEDWzj@CsVElq%ng#ANjUVyI+Qkk`P^ui&QkT?sa?~-(cGROgCA9p!9ruSx2t*7?|98+P*z(--an2L)l%G5X5+&>$99Y83ANy@_Vnwp&l(ei&$>Y_#>kUX37sXEUIDuA!+SH3Lk&HVPD+1B&BpXz8CN zo!H_n9<77eRoXqEz3J((s$+z<$>}U)nnXnvy&S$Wa)fEm+OjC za!wlw5V}8kiyb7*#tornA@xGy0lr(!E_?RLcYPP{)Jk4|32>~B%{Ln}D%?~n?MB~V zv&H$-zihBWnnL44y&?N3p#Ihrwz5}Jhrcg&Zn^6?5)$ojQXHl90c${?CgX11so4&9 z_)1a#cvkPm@d!k7Nl#;> zZscyy{eUNeC>stAzun`aH}pP0Em@E>3F#_sxq0tV6eO`#lu76azL@h;#R&i^Z8RJK zwAX_P3jEhRmkLi@VZVCfp_(0AZr|wkCxrm*!=?XY)Bl_M(xXhRh3 Date: Mon, 5 Aug 2013 12:10:43 -0400 Subject: [PATCH 2/3] Fixed multimeter item render --- .../textures/blocks/multimeter.png | Bin 2138 -> 0 bytes .../multimeter/BlockMultimeter.java | 37 ++---------------- .../render/BlockRenderingHandler.java | 6 +-- .../render/RenderMultimeter.java | 6 ++- 4 files changed, 10 insertions(+), 39 deletions(-) delete mode 100644 resources/assets/resonantinduction/textures/blocks/multimeter.png diff --git a/resources/assets/resonantinduction/textures/blocks/multimeter.png b/resources/assets/resonantinduction/textures/blocks/multimeter.png deleted file mode 100644 index 36cd83f3d48f4bc3d9e9cae541fb0fc09e00ead8..0000000000000000000000000000000000000000 GIT binary patch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d?X{T`aeQrAh8G|jZIZDSda#xsE%=NzFkp2(%WWUiW$JEr6>v(7W!TLP6{gdR3gG$uS%E>q+0Nv-~(sQJkOy+2LM=Exto_? zKFiwr8d;W+=XonMrVh0>D6LUiquZY`hO#Iy+VJ9wf1GNJUPWEkiHMroc7kO4P1^x@ z;f3FD*IjoqYWK`J$KKob@Yd=Dn!28Jve{J=Z@5mF*IF|_->0mKZdlJ0IkS2mfL|WDpkVpuT7y`9(7_I5``cq{cWd=cNBA2~S+-$Aw zc)O~~i-_PuplRyvUFXt#QptiE45sv}b>e4hEe8%B z;OyB~7!0S+UwiF!R#xumRE>3xrY$C8Qo1LNN|YkRh;xqNaI52&bRLL|$4%0N6UGA2 zMw1r>&N?!!x&Qvp^U_N%bNSL`wALKD_aH>jMxm8vb8|ol9@?G|5hSF{Of*8ltA6u^im{`&T%S#nUSGgeg< zN=ot@(e+`_d9NoBt(m%= Date: Mon, 5 Aug 2013 12:33:09 -0400 Subject: [PATCH 3/3] 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