1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
|
import { m } from "../../mappings/mappings"
import { numberWithCommas } from "./numberUtils"
let SoopyV2Forge = Java.type("me.soopyboo32.soopyv2forge.SoopyV2Forge").INSTANCE
let LASTEST_SOOPYFORGE_VER = "1.0"
let canUseForgeRendering = net.minecraftforge.fml.common.Loader.isModLoaded("soopyv2forge") && SoopyV2Forge.getVersion() === LASTEST_SOOPYFORGE_VER
let ArrayList = Java.type("java.util.ArrayList")
let Vec3 = Java.type("net.minecraft.util.Vec3")
let Vector2f = Java.type("javax.vecmath.Vector2f")
let RenderPointsC = Java.type("me.soopyboo32.soopyv2forge.RenderTypes.Points")
let RenderWorldTextC = Java.type("me.soopyboo32.soopyv2forge.RenderTypes.WorldText")
let RenderBeaconC = Java.type("me.soopyboo32.soopyv2forge.RenderTypes.Beacon")
let HudPointsC = Java.type("me.soopyboo32.soopyv2forge.RenderTypes.HudPoints")
let HudTextC = Java.type("me.soopyboo32.soopyv2forge.RenderTypes.HudText")
if (!global.soopyv2RenderWorldThings) global.soopyv2RenderWorldThings = new Set()
if (!global.soopyv2RenderHudThings) global.soopyv2RenderHudThings = new Set()
register("gameUnload", () => {
global.soopyv2RenderWorldThings.clear()
SoopyV2Forge.setRenderWorldList(new ArrayList([]))
global.soopyv2RenderHudThings.clear()
SoopyV2Forge.setRenderHudList(new ArrayList([]))
})
let currentlyRendering = true
export function setRendering(rendering) {
if (!rendering) {
setRenderWorldList(new ArrayList([]))
setRenderHudList(new ArrayList([]))
}
currentlyRendering = rendering
if (rendering) {
setRenderWorldList(new ArrayList([...global.soopyv2RenderWorldThings]))
setRenderHudList(new ArrayList([...global.soopyv2RenderHudThings]))
}
}
function setRenderWorldList(data) {
if (currentlyRendering) SoopyV2Forge.setRenderWorldList(data)
}
function setRenderHudList(data) {
if (currentlyRendering) SoopyV2Forge.setRenderHudList(data)
}
class RenderWorldAble {
startRender(isBatched) {
if (!canUseForgeRendering) return
if (global.soopyv2RenderWorldThings.has(this.javaObj)) return this
global.soopyv2RenderWorldThings.add(this.javaObj)
if (!isBatched) setRenderWorldList(new ArrayList([...global.soopyv2RenderWorldThings]))
return this
}
stopRender(isBatched) {
if (!canUseForgeRendering) return
if (!global.soopyv2RenderWorldThings.has(this.javaObj)) return this
global.soopyv2RenderWorldThings.delete(this.javaObj)
if (!isBatched) setRenderWorldList(new ArrayList([...global.soopyv2RenderWorldThings]))
return this
}
}
class RenderHudAble {
startRender() {
if (!canUseForgeRendering) return
if (global.soopyv2RenderHudThings.has(this.javaObj)) return this
global.soopyv2RenderHudThings.add(this.javaObj)
setRenderHudList(new ArrayList([...global.soopyv2RenderHudThings]))
return this
}
stopRender() {
if (!canUseForgeRendering) return
if (!global.soopyv2RenderHudThings.has(this.javaObj)) return this
global.soopyv2RenderHudThings.delete(this.javaObj)
setRenderHudList(new ArrayList([...global.soopyv2RenderHudThings]))
return this
}
}
export class Points extends RenderWorldAble {
constructor(points, r, g, b, a, thickness, depth) {
this.javaObj = new RenderPointsC(new ArrayList(points.map(a => new Vec3(...a))), r, g, b, a, thickness, depth)
}
setPoints(points) {
this.javaObj.points = new ArrayList(points.map(a => new Vec3(...a)))
return this
}
setRGBA(r, g, b, a) {
this.javaObj.red = r
this.javaObj.green = g
this.javaObj.blue = b
this.javaObj.alpha = a
return this
}
setThickness(thickness) {
this.javaObj.thickness = thickness
return this
}
setDepth(depth) {
this.javaObj.depthtest = depth
return this
}
setDisableCullFace(disable) {
this.javaObj.disableCullFace = disable
return this
}
setGLMode(glMode) {
this.javaObj.glmode = glMode
return this
}
}
export class FilledPoints extends Points {
constructor(points, r, g, b, a, thickness, depth) {
super(points, r, g, b, a, thickness, depth)
this.setGLMode(GL11.GL_QUADS)
this.setDisableCullFace(true)
}
}
export class Box extends Points {
constructor(location, size, r, g, b, a, thickness, depth) {
super(Box.getPointsFromLocationSize(location, size), r, g, b, a, thickness, depth)
}
setLocationSize(location, size) {
this.setPoints(Box.getPointsFromLocationSize(location, size))
return this
}
static getPointsFromLocationSize(location, size) {
let [x, y, z] = location
let [width, height, width2] = size
return [[x + width, y + height, z + width2],
[x + width, y + height, z],
[x, y + height, z],
[x, y + height, z + width2],
[x + width, y + height, z + width2],
[x + width, y, z + width2],
[x + width, y, z],
[x, y, z],
[x, y, z + width2],
[x, y, z],
[x, y + height, z],
[x, y, z],
[x + width, y, z],
[x + width, y + height, z],
[x + width, y, z],
[x + width, y, z + width2],
[x, y, z + width2],
[x, y + height, z + width2],
[x + width, y + height, z + width2]]
}
}
export class FilledBox extends FilledPoints {
constructor(location, size, r, g, b, a, thickness, depth) {
super(FilledBox.getPointsFromLocationSize(location, size), r, g, b, a, thickness, depth)
}
setLocationSize(location, size) {
this.setPoints(FilledBox.getPointsFromLocationSize(location, size))
return this
}
static getPointsFromLocationSize(location, size) {
let [x, y, z] = location
let [w, h, w2] = size
return [
[x + w, y + 0, z + w2],
[x + w, y + 0, z],
[x, y + 0, z],
[x, y + 0, z + w2],
[x + w, y + h, z + w2],
[x + w, y + h, z],
[x, y + h, z],
[x, y + h, z + w2],
[x, y + h, z + w2],
[x, y + h, z],
[x, y + 0, z],
[x, y + 0, z + w2],
[x + w, y + h, z + w2],
[x + w, y + h, z],
[x + w, y + 0, z],
[x + w, y + 0, z + w2],
[x + w, y + h, z],
[x, y + h, z],
[x, y + 0, z],
[x + w, y + 0, z],
[x, y + h, z + w2],
[x + w, y + h, z + w2],
[x + w, y + 0, z + w2],
[x, y + 0, z + w2]
]
}
}
export class WorldText extends RenderWorldAble {
constructor(location, text, depth, scale) {
this.javaObj = new RenderWorldTextC(new Vec3(...location), text, depth, scale)
}
setLocation(location) {
this.javaObj.location = new Vec3(...location)
return this
}
setText(text) {
this.javaObj.text = text
return this
}
setDepthtest(depthtest) {
this.javaObj.depthtest = depthtest
return this
}
setScale(scale) {
this.javaObj.scale = scale
return this
}
setShadow(shadow) {
this.javaObj.shadow = shadow
return this
}
}
export class Beacon extends RenderWorldAble {
constructor(location, r, g, b, a, depth) {
this.javaObj = new RenderBeaconC(new Vec3(...location), r, g, b, a, depth)
}
setLocation(location) {
this.javaObj.location = new Vec3(...location)
return this
}
setRGBA(r, g, b, a) {
this.javaObj.red = r
this.javaObj.green = g
this.javaObj.blue = b
this.javaObj.alpha = a
return this
}
setDepthtest(depthtest) {
this.javaObj.depthtest = depthtest
return this
}
}
export class HudPoints extends RenderHudAble {
constructor(points, r, g, b, a, thickness) {
this.javaObj = new HudPointsC(new ArrayList(points.map(a => new Vector2f(...a))), r, g, b, a, thickness)
}
setPoints(points) {
this.javaObj.points = new ArrayList(points.map(a => new Vec3(...a)))
return this
}
setRGBA(r, g, b, a) {
this.javaObj.colorR = r
this.javaObj.colorG = g
this.javaObj.colorB = b
this.javaObj.colorA = a
return this
}
setThickness(thickness) {
this.javaObj.thickness = thickness
return this
}
setGlmode(glmode) {
this.javaObj.glmode = glmode
return this
}
}
export class HudText extends RenderHudAble {
constructor(text, x, y, shadow) {
this.javaObj = new HudTextC(text, x, y, shadow)
}
setText(text) {
this.javaObj.textLines = text
return this
}
setX(x) {
this.javaObj.x = x
return this
}
setY(y) {
this.javaObj.y = y
return this
}
setScale(scale) {
this.javaObj.scale = scale
return this
}
setShadow(shadow) {
this.javaObj.shadow = shadow
return this
}
}
export class Waypoint extends FilledBox {
constructor(x, y, z, r, g, b, { name = "", showDist = !!name, phase = false }) {
this.rendering = false
let distToPlayerSq = (x - Player.getRenderX()) ** 2 + (y - (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]())) ** 2 + (z - Player.getRenderZ()) ** 2
let alpha = Math.min(1, Math.max(0, 1 - (distToPlayerSq - 10000) / 12500))
super([x - 0.001, y - 0.001, z - 0.001], [1.002, 1.002, 1.002], r, g, b, 0.25 * alpha, 1, !phase)
this.params = { x, y, z, r, g, b, name, showDist, phase }
this.outLine = new Box([x - 0.002, y - 0.002, z - 0.002], [1.004, 1.004, 1.004], r, g, b, alpha, 3, !phase)
this.beam = new Beacon([x, y + 1, z], r, g, b, Math.min(1, Math.max(0, (distToPlayerSq - 25) / 100)) * alpha, true)
let distToPlayer = Math.sqrt(distToPlayerSq)
let distRender = Math.min(distToPlayer, 50)
let loc5 = [Player.getRenderX() + (x + 0.5 - Player.getRenderX()) / (distToPlayer / distRender), (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]()) + (y + 2 + 20 * distToPlayer / 300 - (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]())) / (distToPlayer / distRender), Player.getRenderZ() + (z + 0.5 - Player.getRenderZ()) / (distToPlayer / distRender)]
let loc6 = [Player.getRenderX() + (x + 0.5 - Player.getRenderX()) / (distToPlayer / distRender), (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]()) + (y + 2 + 20 * distToPlayer / 300 - 10 * distToPlayer / 300 - (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]())) / (distToPlayer / distRender), Player.getRenderZ() + (z + 0.5 - Player.getRenderZ()) / (distToPlayer / distRender)]
this.textLine1 = new WorldText([loc5[0], loc5[1], loc5[2]], "§a" + name, false, distRender / 12)
this.textLine2 = new WorldText([(name ? loc6[0] : loc5[0]), (name ? loc6[1] : loc5[1]), (name ? loc6[2] : loc5[2])], "§b(" + numberWithCommas(Math.round(distToPlayer)) + "m)", false, distRender / 12)
}
update() {
let { x, y, z, r, g, b, name, showDist } = this.params
let distToPlayerSq = (x - Player.getRenderX()) ** 2 + (y - (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]())) ** 2 + (z - Player.getRenderZ()) ** 2
let alpha = Math.min(1, Math.max(0, 1 - (distToPlayerSq - 10000) / 12500))
this.setRGBA(r, g, b, 0.25 * alpha)
this.outLine.setRGBA(r, g, b, alpha)
this.beam.setRGBA(r, g, b, Math.min(1, Math.max(0, (distToPlayerSq - 25) / 100)) * alpha)
if (name || showDist) {
let distToPlayer = Math.sqrt(distToPlayerSq)
let distRender = Math.min(distToPlayer, 100)
let loc5 = [Player.getRenderX() + (x + 0.5 - Player.getRenderX()) / (distToPlayer / distRender), (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]()) + (y + 2 + 20 * distToPlayer / 300 - (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]())) / (distToPlayer / distRender), Player.getRenderZ() + (z + 0.5 - Player.getRenderZ()) / (distToPlayer / distRender)]
let loc6 = [Player.getRenderX() + (x + 0.5 - Player.getRenderX()) / (distToPlayer / distRender), (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]()) + (y + 2 + 20 * distToPlayer / 300 - 10 * distToPlayer / 300 - (Player.getRenderY() + Player.getPlayer()[m.getEyeHeight]())) / (distToPlayer / distRender), Player.getRenderZ() + (z + 0.5 - Player.getRenderZ()) / (distToPlayer / distRender)]
this.textLine1.setLocation([loc5[0], loc5[1], loc5[2]]).setScale(distRender / 12)
this.textLine2.setLocation([(name ? loc6[0] : loc5[0]), (name ? loc6[1] : loc5[1]), (name ? loc6[2] : loc5[2])]).setScale(distRender / 12).setText("§b(" + numberWithCommas(Math.round(distToPlayer)) + "m)")
}
}
startRender(isBatched) {
if (this.rendering) return this
this.rendering = true
super.startRender(true)
this.outLine.startRender(true)
this.beam.startRender(true)
if (this.params.name) this.textLine1.startRender(true)
if (this.params.showDist) this.textLine2.startRender(true)
if (!isBatched) setRenderWorldList(new ArrayList([...global.soopyv2RenderWorldThings]))
return this
}
stopRender(isBatched) {
if (!this.rendering) return this
this.rendering = false
super.stopRender(true)
this.outLine.stopRender(true)
this.beam.stopRender(true)
this.textLine1.stopRender(true)
this.textLine2.stopRender(true)
if (!isBatched) setRenderWorldList(new ArrayList([...global.soopyv2RenderWorldThings]))
return this
}
}
register("worldLoad", () => {
if (!net.minecraftforge.fml.common.Loader.isModLoaded("soopyv2forge")) {
ChatLib.chat("&1" + ChatLib.getChatBreak("-").trim())
ChatLib.chat("§cWARNING: You dont have the forge mod for soopyv2 installed")
ChatLib.chat("§cWARNING: -> almost nothing can be rendered")
new TextComponent(" &e[CLICK] &7- Download").setHover("show_text", "&2Download").setClick("open_url", "https://github.com/Soopyboo32/SoopyV2Forge/releases").chat()
ChatLib.chat("Or if u want to remove soopyv2 run /ct delete soopyv2")
ChatLib.chat("&1" + ChatLib.getChatBreak("-").trim())
}
if (SoopyV2Forge.getVersion() !== LASTEST_SOOPYFORGE_VER) {
ChatLib.chat("&1" + ChatLib.getChatBreak("-").trim())
ChatLib.chat("§cWARNING: Your forge version of soopyv2 is outdated")
ChatLib.chat("§cWARNING: -> almost nothing can be rendered")
new TextComponent(" &e[CLICK] &7- Download").setHover("show_text", "&2Download update").setClick("open_url", "https://github.com/Soopyboo32/SoopyV2Forge/releases").chat()
ChatLib.chat("&1" + ChatLib.getChatBreak("-").trim())
}
})
|