1 package net
.encode
.wurmesp
.feature
;
3 import com
.wurmonline
.client
.game
.PlayerPosition
;
4 import com
.wurmonline
.mesh
.Tiles
;
6 import java
.util
.logging
.Level
;
7 import java
.util
.logging
.Logger
;
8 import net
.encode
.wurmesp
.WurmEspMod
;
9 import net
.encode
.wurmesp
.util
.RenderUtils
;
10 import net
.encode
.wurmesp
.util
.XrayColors
;
12 public class FeatureXRay
15 public void refresh() {
16 if (!this.world
.isOwnBodyAdded()) {
19 WurmEspMod
._terrain
.clear();
20 WurmEspMod
._caveBuffer
= this.world
.getCaveBuffer();
21 PlayerPosition pos
= this.world
.getPlayer().getPos();
22 int px
= pos
.getTileX();
23 int py
= pos
.getTileY();
24 int size
= WurmEspMod
.xraydiameter
;
25 int sx
= px
- size
/ 2;
26 int sy
= py
- size
/ 2;
27 float ox
= this.world
.getRenderOriginX();
28 float oy
= this.world
.getRenderOriginY();
29 for (int x
= 0; x
< size
; ++x
) {
30 for (int y
= size
- 1; y
>= 0; --y
) {
34 Tiles
.Tile tile
= WurmEspMod
._caveBuffer
.getTileType(tileX
, tileY
);
35 if (tile
== null || !tile
.isOreCave()) continue;
36 Color color
= XrayColors
.getColorFor(tile
);
37 float[] colorF
= new float[]{(float)color
.getRed() / 255.0f, (float)color
.getGreen() / 255.0f, (float)color
.getBlue() / 255.0f};
38 float curX
= (float)(tileX
* 4) - ox
;
39 float curY
= (float)(tileY
* 4) - oy
;
40 float nextX
= (float)((tileX
+ 1) * 4) - ox
;
41 float nextY
= (float)((tileY
+ 1) * 4) - oy
;
42 float x0
= curX
+ 0.2f;
43 float y0
= curY
+ 0.2f;
44 float x1
= nextX
- 0.2f;
45 float y1
= nextY
- 0.2f;
46 WurmEspMod
._terrain
.add(new float[]{x0
, y0
, x1
, y1
, colorF
[0], colorF
[1], colorF
[2]});
49 catch (IllegalArgumentException
| SecurityException ex
) {
50 Logger
.getLogger(FeatureXRay
.class.getName()).log(Level
.SEVERE
, null, ex
);
58 if (WurmEspMod
._terrain
== null) {
61 WurmEspMod
._terrain
.stream().forEach(t
-> {
67 float[] color
= new float[]{t
[4],t
[5],t
[6], 1.0F};
68 PlayerPosition pos
= this.world
.getPlayer().getPos();
70 float z0
= pos
.getH();
73 float[] vertexdata
= new float[] {
83 int[] indexdata
= new int[] { 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7 };
84 RenderUtils
.renderPrimitiveLines(8, vertexdata
, indexdata
, this.queuePick
, color
);
87 if (!this.world.isOwnBodyAdded()) {
90 WurmEspMod._terrain.clear();
91 WurmEspMod._caveBuffer = this.world.getCaveBuffer();
92 PlayerPosition pos = this.world.getPlayer().getPos();
93 int px = pos.getTileX();
94 int py = pos.getTileY();
95 int size = WurmEspMod.xraydiameter;
96 int sx = px - size / 2;
97 int sy = py - size / 2;
98 WorldRender worldRenderer = (WorldRender)ReUtils.getField(this.world, "worldRenderer");
99 CaveRender caveRenderer = (CaveRender)ReUtils.getField(worldRenderer, "caveRenderer");
100 for (int x = 0; x < size; ++x) {
101 for (int y = size - 1; y >= 0; --y) {
105 for (int side = 0; side < 7; ++side) {
106 IntBuffer intBuffer = IntBuffer.allocate(3);
107 intBuffer.put(tileX);
108 intBuffer.put(tileY);
110 Class<HitNamesData> cls = HitNamesData.class;
111 Constructor<HitNamesData> constructor = cls.getDeclaredConstructor(IntBuffer.class, Integer.TYPE);
112 constructor.setAccessible(true);
113 HitNamesData hitNames = (HitNamesData)constructor.newInstance(intBuffer, 3);
114 caveRenderer.getPickedWall(hitNames).renderPicked(this.queuePick, RenderState.RENDERSTATE_DEFAULT, com.wurmonline.client.renderer.Color.GREEN);
118 catch (IllegalAccessException | IllegalArgumentException | InstantiationException | NoSuchMethodException | SecurityException | InvocationTargetException ex) {
119 Logger.getLogger(FeatureXRay.class.getName()).log(Level.SEVERE, null, ex);