| 1 | /* |
| 2 | * Decompiled with CFR 0.151. |
| 3 | * |
| 4 | * Could not load the following classes: |
| 5 | * com.wurmonline.client.game.PlayerPosition |
| 6 | * com.wurmonline.client.renderer.Color |
| 7 | * com.wurmonline.client.renderer.HitNamesData |
| 8 | * com.wurmonline.client.renderer.backend.RenderState |
| 9 | * com.wurmonline.client.renderer.cave.CaveRender |
| 10 | * com.wurmonline.mesh.Tiles$Tile |
| 11 | */ |
| 12 | package net.encode.wurmesp.feature; |
| 13 | |
| 14 | import com.wurmonline.client.game.PlayerPosition; |
| 15 | import com.wurmonline.mesh.Tiles; |
| 16 | import java.awt.Color; |
| 17 | import java.util.logging.Level; |
| 18 | import java.util.logging.Logger; |
| 19 | import net.encode.wurmesp.WurmEspMod; |
| 20 | import net.encode.wurmesp.util.RenderUtils; |
| 21 | import net.encode.wurmesp.util.XrayColors; |
| 22 | |
| 23 | public class FeatureXRay |
| 24 | extends Feature { |
| 25 | @Override |
| 26 | public void refresh() { |
| 27 | if (!this.world.isOwnBodyAdded()) { |
| 28 | return; |
| 29 | } |
| 30 | WurmEspMod._terrain.clear(); |
| 31 | WurmEspMod._caveBuffer = this.world.getCaveBuffer(); |
| 32 | PlayerPosition pos = this.world.getPlayer().getPos(); |
| 33 | int px = pos.getTileX(); |
| 34 | int py = pos.getTileY(); |
| 35 | int size = WurmEspMod.xraydiameter; |
| 36 | int sx = px - size / 2; |
| 37 | int sy = py - size / 2; |
| 38 | float ox = this.world.getRenderOriginX(); |
| 39 | float oy = this.world.getRenderOriginY(); |
| 40 | for (int x = 0; x < size; ++x) { |
| 41 | for (int y = size - 1; y >= 0; --y) { |
| 42 | try { |
| 43 | int tileX = x + sx; |
| 44 | int tileY = y + sy; |
| 45 | Tiles.Tile tile = WurmEspMod._caveBuffer.getTileType(tileX, tileY); |
| 46 | if (tile == null || !tile.isOreCave()) continue; |
| 47 | Color color = XrayColors.getColorFor(tile); |
| 48 | float[] colorF = new float[]{(float)color.getRed() / 255.0f, (float)color.getGreen() / 255.0f, (float)color.getBlue() / 255.0f}; |
| 49 | float curX = (float)(tileX * 4) - ox; |
| 50 | float curY = (float)(tileY * 4) - oy; |
| 51 | float nextX = (float)((tileX + 1) * 4) - ox; |
| 52 | float nextY = (float)((tileY + 1) * 4) - oy; |
| 53 | float x0 = curX + 0.2f; |
| 54 | float y0 = curY + 0.2f; |
| 55 | float x1 = nextX - 0.2f; |
| 56 | float y1 = nextY - 0.2f; |
| 57 | WurmEspMod._terrain.add(new float[]{x0, y0, x1, y1, colorF[0], colorF[1], colorF[2]}); |
| 58 | continue; |
| 59 | } |
| 60 | catch (IllegalArgumentException | SecurityException ex) { |
| 61 | Logger.getLogger(FeatureXRay.class.getName()).log(Level.SEVERE, null, ex); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public void queue() { |
| 69 | if (WurmEspMod._terrain == null) { |
| 70 | return; |
| 71 | } |
| 72 | WurmEspMod._terrain.stream().forEach(t -> { |
| 73 | float x0 = t[0]; |
| 74 | float y0 = t[1]; |
| 75 | float x1 = t[2]; |
| 76 | float y1 = t[3]; |
| 77 | |
| 78 | float[] color = new float[]{t[4],t[5],t[6], 1.0F}; |
| 79 | PlayerPosition pos = this.world.getPlayer().getPos(); |
| 80 | |
| 81 | float z0 = pos.getH(); |
| 82 | float z1 = z0 + 3; |
| 83 | |
| 84 | float[] vertexdata = new float[] { |
| 85 | x1, z0, y0, |
| 86 | x1, z1, y0, |
| 87 | x0, z1, y0, |
| 88 | x0, z0, y0, |
| 89 | x1, z0, y1, |
| 90 | x1, z1, y1, |
| 91 | x0, z1, y1, |
| 92 | x0, z0, y1 }; |
| 93 | |
| 94 | 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 }; |
| 95 | RenderUtils.renderPrimitiveLines(8, vertexdata, indexdata, this.queuePick, color); |
| 96 | }); |
| 97 | /* |
| 98 | if (!this.world.isOwnBodyAdded()) { |
| 99 | return; |
| 100 | } |
| 101 | WurmEspMod._terrain.clear(); |
| 102 | WurmEspMod._caveBuffer = this.world.getCaveBuffer(); |
| 103 | PlayerPosition pos = this.world.getPlayer().getPos(); |
| 104 | int px = pos.getTileX(); |
| 105 | int py = pos.getTileY(); |
| 106 | int size = WurmEspMod.xraydiameter; |
| 107 | int sx = px - size / 2; |
| 108 | int sy = py - size / 2; |
| 109 | WorldRender worldRenderer = (WorldRender)ReUtils.getField(this.world, "worldRenderer"); |
| 110 | CaveRender caveRenderer = (CaveRender)ReUtils.getField(worldRenderer, "caveRenderer"); |
| 111 | for (int x = 0; x < size; ++x) { |
| 112 | for (int y = size - 1; y >= 0; --y) { |
| 113 | try { |
| 114 | int tileX = x + sx; |
| 115 | int tileY = y + sy; |
| 116 | for (int side = 0; side < 7; ++side) { |
| 117 | IntBuffer intBuffer = IntBuffer.allocate(3); |
| 118 | intBuffer.put(tileX); |
| 119 | intBuffer.put(tileY); |
| 120 | intBuffer.put(side); |
| 121 | Class<HitNamesData> cls = HitNamesData.class; |
| 122 | Constructor<HitNamesData> constructor = cls.getDeclaredConstructor(IntBuffer.class, Integer.TYPE); |
| 123 | constructor.setAccessible(true); |
| 124 | HitNamesData hitNames = (HitNamesData)constructor.newInstance(intBuffer, 3); |
| 125 | caveRenderer.getPickedWall(hitNames).renderPicked(this.queuePick, RenderState.RENDERSTATE_DEFAULT, com.wurmonline.client.renderer.Color.GREEN); |
| 126 | } |
| 127 | continue; |
| 128 | } |
| 129 | catch (IllegalAccessException | IllegalArgumentException | InstantiationException | NoSuchMethodException | SecurityException | InvocationTargetException ex) { |
| 130 | Logger.getLogger(FeatureXRay.class.getName()).log(Level.SEVERE, null, ex); |
| 131 | } |
| 132 | } |
| 133 | }*/ |
| 134 | } |
| 135 | } |
| 136 | |