aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2021-11-30 23:28:02 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2021-11-30 23:28:02 +0800
commit71ae701c364f586c34ae2d1e5f82e4df89e1d851 (patch)
tree8ed41d1b9fbdf72bbf256cb60d83a82adf8446b6 /utils
parent5f481b984dfeb8ec6d6eb1762928726d728e775d (diff)
downloadSoopyV2-71ae701c364f586c34ae2d1e5f82e4df89e1d851.tar.gz
SoopyV2-71ae701c364f586c34ae2d1e5f82e4df89e1d851.tar.bz2
SoopyV2-71ae701c364f586c34ae2d1e5f82e4df89e1d851.zip
Allow for dynamic updating of module code in the fly
Diffstat (limited to 'utils')
-rw-r--r--utils/renderLib2d.js22
1 files changed, 21 insertions, 1 deletions
diff --git a/utils/renderLib2d.js b/utils/renderLib2d.js
index e9769b7..22dbca7 100644
--- a/utils/renderLib2d.js
+++ b/utils/renderLib2d.js
@@ -3,9 +3,10 @@
// CODE BY DJtheRedstoner
// IM COPYING THIS BECAUSE THE UPLOADED VERSION IS FOR
// CT 2.0.0 ONLY
+//
+// Edit: iv added some features to this so might keep as is
//--------------------------------------------------------------------------
-//TODO: just require the module when ct 2.0 comes out
const GL11 = Java.type("org.lwjgl.opengl.GL11");
@@ -20,6 +21,8 @@ const viewportDims = BufferUtils.createIntBuffer(16);
const ScaledResolution = net.minecraft.client.gui.ScaledResolution;
+const AxisAlignedBB = Java.type("net.minecraft.util.AxisAlignedBB")
+
register('renderWorld', () => {
GlStateManager.func_179094_E();
@@ -66,6 +69,19 @@ export default class RenderLib2D {
return { x, y, z };
}
+ static drawLine(x1, y1, z1, x2, y2, z2, color, thickness=1) {
+ let pos1 = RenderLib2D.projectPoint(x1, y1, z1);
+ let pos2 = RenderLib2D.projectPoint(x2, y2, z2);
+
+ if(!pos1 || !pos2) return;
+
+ let {x, y} = pos1
+ let {x:ox, y:oy} = pos2
+
+ console.log(x, y, ox, oy, thickness)
+ Renderer.drawLine(color, x, y, ox, oy, thickness);
+ }
+
// Original made by DJtheRedstoner
static calculateBoundingBox = (box) => {
let vertices = RenderLib2D.getVertices(box);
@@ -146,4 +162,8 @@ export default class RenderLib2D {
if (projected[4] && projected[7]) Renderer.drawLine(color, projected[4].x, projected[4].y, projected[7].x, projected[7].y, thickness);
if (projected[5] && projected[6]) Renderer.drawLine(color, projected[5].x, projected[5].y, projected[6].x, projected[6].y, thickness);
}
+
+ static getBlockAABB = (x, y, z) => {
+ return new AxisAlignedBB(x, y, z, x + 1, y + 1, z + 1);
+ }
}