diff options
author | Julienraptor01 <julienraptor01@gmail.com> | 2023-01-11 23:22:08 +0100 |
---|---|---|
committer | Julienraptor01 <julienraptor01@gmail.com> | 2023-01-11 23:22:08 +0100 |
commit | 954f2040a7b0a8429dfdcde07fc44c84648d3814 (patch) | |
tree | 1e69831b6a3a0c28b1033ad489620fb084be27fa /src/main/java | |
parent | c9c7bce2fa710b94db8bec7a2979d244ed41625c (diff) | |
download | Skyblocker-954f2040a7b0a8429dfdcde07fc44c84648d3814.tar.gz Skyblocker-954f2040a7b0a8429dfdcde07fc44c84648d3814.tar.bz2 Skyblocker-954f2040a7b0a8429dfdcde07fc44c84648d3814.zip |
Maybe fix the math stuff but IDK
Diffstat (limited to 'src/main/java')
3 files changed, 45 insertions, 22 deletions
diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtils.java b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtils.java index 5ac11d57..c659f4f9 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtils.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtils.java @@ -17,7 +17,8 @@ import net.minecraft.util.math.Box; import net.minecraft.util.math.Direction; import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.Vec3d; -import net.minecraft.util.math.Vec3f; +//import net.minecraft.util.math.Vec3f; +import net.minecraft.util.math.RotationAxis; public class RenderUtils { @@ -59,8 +60,10 @@ public class RenderUtils { MatrixStack matrices = new MatrixStack(); Camera camera = MinecraftClient.getInstance().gameRenderer.getCamera(); - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch())); - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(camera.getYaw() + 180.0F)); + // matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch())); + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch())); + // matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(camera.getYaw() + 180.0F)); + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(camera.getYaw() + 180.0F)); matrices.translate(x - camera.getPos().x, y - camera.getPos().y, z - camera.getPos().z); diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtilsLiving.java b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtilsLiving.java index c1111b36..651ef2bd 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtilsLiving.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/RenderUtilsLiving.java @@ -35,7 +35,9 @@ import net.minecraft.client.render.model.json.ModelTransformation; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.item.ItemStack; import net.minecraft.text.Text; -import net.minecraft.util.math.Vec3f; +//import net.minecraft.util.math.Vec3f; +import net.minecraft.util.math.RotationAxis; +import org.joml.Vector3f; public class RenderUtilsLiving { @@ -52,8 +54,10 @@ public class RenderUtilsLiving { MatrixStack matrices = matrixFrom(x, y, z); Camera camera = mc.gameRenderer.getCamera(); - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-camera.getYaw())); - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch())); + // matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-camera.getYaw())); + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-camera.getYaw())); + // matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch())); + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch())); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); @@ -92,20 +96,24 @@ public class RenderUtilsLiving { MatrixStack matrices = matrixFrom(x, y, z); Camera camera = mc.gameRenderer.getCamera(); - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-camera.getYaw())); - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch())); + // matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(-camera.getYaw())); + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-camera.getYaw())); + // matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch())); + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch())); matrices.translate(offX, offY, 0); matrices.scale((float) scale, (float) scale, 0.001f); - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180f)); + // matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(180f)); + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180f)); //mc.getBufferBuilders().getEntityVertexConsumers().draw(); RenderSystem.enableBlend(); RenderSystem.defaultBlendFunc(); - Vec3f[] currentLight = getCurrentLight(); + // Vec3f[] currentLight = getCurrentLight(); + Vector3f[] currentLight = getCurrentLight(); DiffuseLighting.disableGuiDepthLighting(); mc.getBufferBuilders().getEntityVertexConsumers().draw(); @@ -123,21 +131,25 @@ public class RenderUtilsLiving { MatrixStack matrices = new MatrixStack(); Camera camera = mc.gameRenderer.getCamera(); - matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch())); - matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(camera.getYaw() + 180.0F)); + // matrices.multiply(Vec3f.POSITIVE_X.getDegreesQuaternion(camera.getPitch())); + matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(camera.getPitch())); + // matrices.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(camera.getYaw() + 180.0F)); + matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(camera.getYaw() + 180.0F)); matrices.translate(x - camera.getPos().x, y - camera.getPos().y, z - camera.getPos().z); return matrices; } - public static Vec3f[] getCurrentLight() { + // public static Vec3f[] getCurrentLight() { + public static Vector3f[] getCurrentLight() { if (shaderLightField == null) { shaderLightField = FieldUtils.getField(RenderSystem.class, "shaderLightDirections", true); } try { - return (Vec3f[]) shaderLightField.get(null); + // return (Vec3f[]) shaderLightField.get(null); + return (Vector3f[]) shaderLightField.get(null); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/src/main/java/me/xmrvizzy/skyblocker/utils/Vertexer.java b/src/main/java/me/xmrvizzy/skyblocker/utils/Vertexer.java index 12f4b0fd..cf6d90b6 100644 --- a/src/main/java/me/xmrvizzy/skyblocker/utils/Vertexer.java +++ b/src/main/java/me/xmrvizzy/skyblocker/utils/Vertexer.java @@ -7,9 +7,12 @@ import net.minecraft.client.util.math.MatrixStack; import net.minecraft.util.math.Box; import net.minecraft.util.math.Direction; import net.minecraft.util.math.MathHelper; -import net.minecraft.util.math.Matrix3f; -import net.minecraft.util.math.Matrix4f; -import net.minecraft.util.math.Vec3f; +// import net.minecraft.util.math.Matrix3f; +// import net.minecraft.util.math.Matrix4f; +// import net.minecraft.util.math.Vec3f; +import org.joml.Matrix3f; +import org.joml.Matrix4f; +import org.joml.Vector3f; import org.apache.commons.lang3.ArrayUtils; public class Vertexer { @@ -135,22 +138,27 @@ public class Vertexer { Matrix4f model = matrices.peek().getPositionMatrix(); Matrix3f normal = matrices.peek().getNormalMatrix(); - Vec3f normalVec = getNormal(normal, x1, y1, z1, x2, y2, z2); + // Vec3f normalVec = getNormal(normal, x1, y1, z1, x2, y2, z2); + Vector3f normalVec = getNormal(normal, x1, y1, z1, x2, y2, z2); int[] color1 = lineColor.getColor(x1, y1, z1, 0); int[] color2 = lineColor.getColor(x2, y2, z2, 1); - vertexConsumer.vertex(model, x1, y1, z1).color(color1[0], color1[1], color1[2], color1[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next(); - vertexConsumer.vertex(model, x2, y2, z2).color(color2[0], color2[1], color2[2], color2[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next(); + // vertexConsumer.vertex(model, x1, y1, z1).color(color1[0], color1[1], color1[2], color1[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next(); + vertexConsumer.vertex(model, x1, y1, z1).color(color1[0], color1[1], color1[2], color1[3]).normal(normal, normalVec.x(), normalVec.y(), normalVec.z()).next(); + // vertexConsumer.vertex(model, x2, y2, z2).color(color2[0], color2[1], color2[2], color2[3]).normal(normal, normalVec.getX(), normalVec.getY(), normalVec.getZ()).next(); + vertexConsumer.vertex(model, x2, y2, z2).color(color2[0], color2[1], color2[2], color2[3]).normal(normal, normalVec.x(), normalVec.y(), normalVec.z()).next(); } - public static Vec3f getNormal(Matrix3f normal, float x1, float y1, float z1, float x2, float y2, float z2) { + // public static Vec3f getNormal(Matrix3f normal, float x1, float y1, float z1, float x2, float y2, float z2) { + public static Vector3f getNormal(Matrix3f normal, float x1, float y1, float z1, float x2, float y2, float z2) { float xNormal = x2 - x1; float yNormal = y2 - y1; float zNormal = z2 - z1; float normalSqrt = MathHelper.sqrt(xNormal * xNormal + yNormal * yNormal + zNormal * zNormal); - return new Vec3f(xNormal / normalSqrt, yNormal / normalSqrt, zNormal / normalSqrt); + // return new Vec3f(xNormal / normalSqrt, yNormal / normalSqrt, zNormal / normalSqrt); + return new Vector3f(xNormal / normalSqrt, yNormal / normalSqrt, zNormal / normalSqrt); } }
\ No newline at end of file |