From 9592d7f024b8b4a9ebf032e914e887fe0189c21b Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Sun, 13 Jul 2014 23:27:23 -0400 Subject: [PATCH] Flamethrower fixes! --- src/main/java/mekanism/api/Pos3D.java | 35 ++++++++++++++++++- .../client/render/RenderTickHandler.java | 8 ++--- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/main/java/mekanism/api/Pos3D.java b/src/main/java/mekanism/api/Pos3D.java index 6117a14e1..a4505ade5 100644 --- a/src/main/java/mekanism/api/Pos3D.java +++ b/src/main/java/mekanism/api/Pos3D.java @@ -3,6 +3,7 @@ package mekanism.api; import net.minecraft.entity.Entity; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; +import net.minecraft.util.Vec3; /** * Pos3D - a way of performing operations on objects in a three dimensional environment. @@ -19,6 +20,13 @@ public class Pos3D { this(0, 0, 0); } + + public Pos3D(Vec3 vec) + { + xPos = vec.xCoord; + yPos = vec.yCoord; + zPos = vec.zCoord; + } public Pos3D(double x, double y, double z) { @@ -126,7 +134,7 @@ public class Pos3D if(yaw != 0) { xPos = x * Math.cos(yawRadians) - z * Math.sin(yawRadians); - zPos = x * Math.sin(yawRadians) + z * Math.cos(yawRadians); + zPos = z * Math.cos(yawRadians) + x * Math.sin(yawRadians); } return this; @@ -147,6 +155,31 @@ public class Pos3D return this; } + + public Pos3D rotate(double yaw, double pitch) + { + double yawRadians = Math.toRadians(yaw); + double pitchRadians = Math.toRadians(pitch); + + double x = xPos; + double y = yPos; + double z = zPos; + + xPos = x * Math.cos(yawRadians) - z * Math.sin(yawRadians); + yPos = y * Math.cos(pitchRadians) - z * Math.sin(pitchRadians); + zPos = (z * Math.cos(yawRadians) + x * Math.sin(yawRadians)) * (z * Math.cos(pitchRadians) + y * Math.sin(pitchRadians)); + + return this; + } + + public Pos3D multiply(Pos3D pos) + { + xPos *= pos.xPos; + yPos *= pos.yPos; + zPos *= pos.zPos; + + return this; + } /** * Scales this Pos3D by the defined x, y, an z values. diff --git a/src/main/java/mekanism/client/render/RenderTickHandler.java b/src/main/java/mekanism/client/render/RenderTickHandler.java index f35e9e6f9..09506f538 100644 --- a/src/main/java/mekanism/client/render/RenderTickHandler.java +++ b/src/main/java/mekanism/client/render/RenderTickHandler.java @@ -188,12 +188,10 @@ public class RenderTickHandler if(player == p && mc.gameSettings.thirdPersonView == 0) { - flameVec.xPos -= 0.25F; - flameVec.yPos -= 0.5F; - flameVec.zPos += 1.15F; + flameVec = new Pos3D(0.8, 0.8, 0.8); - flameVec.rotateYaw(p.rotationYaw); - flameVec.rotatePitch(p.rotationPitch); + flameVec.multiply(new Pos3D(p.getLook(90))); + flameVec.rotateYaw(15); } else { flameVec.xPos -= 0.45F;