|
8 | 8 | package net.wurstclient.hacks; |
9 | 9 |
|
10 | 10 | import com.mojang.blaze3d.vertex.PoseStack; |
| 11 | +import java.util.ArrayList; |
11 | 12 | import java.util.List; |
12 | 13 | import net.minecraft.world.entity.Entity; |
13 | 14 | import net.minecraft.world.phys.AABB; |
@@ -152,85 +153,147 @@ public void onRender(PoseStack matrixStack, float partialTicks) |
152 | 153 |
|
153 | 154 | private void renderBoxes(PoseStack matrixStack) |
154 | 155 | { |
| 156 | + ChestSearchHack csh = null; |
| 157 | + boolean canMarkOpened = false; |
| 158 | + ChestSearchHack.OpenedChestMarker markerMode = |
| 159 | + ChestSearchHack.OpenedChestMarker.LINE; |
| 160 | + if(!openedChests.isEmpty()) |
| 161 | + { |
| 162 | + try |
| 163 | + { |
| 164 | + csh = net.wurstclient.WurstClient.INSTANCE |
| 165 | + .getHax().chestSearchHack; |
| 166 | + if(csh != null && csh.isMarkOpenedChest()) |
| 167 | + { |
| 168 | + canMarkOpened = true; |
| 169 | + ChestSearchHack.OpenedChestMarker selected = |
| 170 | + csh.getOpenedChestMarker(); |
| 171 | + if(selected != null) |
| 172 | + markerMode = selected; |
| 173 | + } |
| 174 | + }catch(Throwable ignored) |
| 175 | + { |
| 176 | + csh = null; |
| 177 | + canMarkOpened = false; |
| 178 | + } |
| 179 | + } |
| 180 | + |
| 181 | + String curDimFull = MC.level == null ? "overworld" |
| 182 | + : MC.level.dimension().identifier().toString(); |
| 183 | + String curDim = MC.level == null ? "overworld" |
| 184 | + : MC.level.dimension().identifier().getPath(); |
| 185 | + |
155 | 186 | for(ChestEspGroup group : groups.allGroups) |
156 | 187 | { |
157 | 188 | if(!group.isEnabled()) |
158 | 189 | continue; |
159 | 190 |
|
160 | 191 | List<AABB> boxes = group.getBoxes(); |
| 192 | + if(boxes.isEmpty()) |
| 193 | + continue; |
| 194 | + |
161 | 195 | int quadsColor = group.getColorI(0x40); |
162 | 196 | int linesColor = group.getColorI(0x80); |
163 | 197 |
|
164 | | - RenderUtils.drawSolidBoxes(matrixStack, boxes, quadsColor, false); |
165 | | - RenderUtils.drawOutlinedBoxes(matrixStack, boxes, linesColor, |
166 | | - false); |
| 198 | + List<AABB> openedBoxes = java.util.Collections.emptyList(); |
| 199 | + List<AABB> closedBoxes = boxes; |
| 200 | + if(canMarkOpened) |
| 201 | + { |
| 202 | + List<AABB> opened = new ArrayList<>(); |
| 203 | + List<AABB> closed = new ArrayList<>(); |
| 204 | + for(AABB box : boxes) |
| 205 | + { |
| 206 | + if(isRecordedChest(box, curDimFull, curDim)) |
| 207 | + opened.add(box); |
| 208 | + else |
| 209 | + closed.add(box); |
| 210 | + } |
| 211 | + openedBoxes = opened; |
| 212 | + closedBoxes = closed; |
| 213 | + } |
167 | 214 |
|
168 | | - // If ChestSearch marking is enabled, draw an X through opened |
169 | | - // chests that match entries in the ChestSearch DB |
170 | | - try |
| 215 | + boolean useRecolor = canMarkOpened |
| 216 | + && markerMode == ChestSearchHack.OpenedChestMarker.RECOLOR |
| 217 | + && !openedBoxes.isEmpty(); |
| 218 | + |
| 219 | + if(useRecolor && csh != null) |
171 | 220 | { |
172 | | - var csh = net.wurstclient.WurstClient.INSTANCE |
173 | | - .getHax().chestSearchHack; |
174 | | - if(csh != null && csh.isMarkOpenedChest() |
175 | | - && !openedChests.isEmpty()) |
| 221 | + if(!closedBoxes.isEmpty()) |
| 222 | + { |
| 223 | + RenderUtils.drawSolidBoxes(matrixStack, closedBoxes, |
| 224 | + quadsColor, false); |
| 225 | + RenderUtils.drawOutlinedBoxes(matrixStack, closedBoxes, |
| 226 | + linesColor, false); |
| 227 | + } |
| 228 | + |
| 229 | + int markColor = csh.getMarkXColorARGB(); |
| 230 | + int openedFillColor = (markColor & 0x00FFFFFF) | (0x40 << 24); |
| 231 | + int openedLineColor = markColor; |
| 232 | + RenderUtils.drawSolidBoxes(matrixStack, openedBoxes, |
| 233 | + openedFillColor, false); |
| 234 | + RenderUtils.drawOutlinedBoxes(matrixStack, openedBoxes, |
| 235 | + openedLineColor, false); |
| 236 | + }else |
| 237 | + { |
| 238 | + RenderUtils.drawSolidBoxes(matrixStack, boxes, quadsColor, |
| 239 | + false); |
| 240 | + RenderUtils.drawOutlinedBoxes(matrixStack, boxes, linesColor, |
| 241 | + false); |
| 242 | + |
| 243 | + if(canMarkOpened |
| 244 | + && markerMode == ChestSearchHack.OpenedChestMarker.LINE |
| 245 | + && csh != null && !openedBoxes.isEmpty()) |
176 | 246 | { |
177 | | - // base esp line color retained if needed |
178 | | - String curDimFull = MC.level == null ? "overworld" |
179 | | - : MC.level.dimension().location().toString(); |
180 | | - String curDim = MC.level == null ? "overworld" |
181 | | - : MC.level.dimension().location().getPath(); |
182 | | - for(AABB box : boxes) |
| 247 | + for(AABB box : openedBoxes) |
183 | 248 | { |
184 | | - int boxMinX = (int)Math.floor(box.minX + 1e-6); |
185 | | - int boxMaxX = (int)Math.floor(box.maxX - 1e-6); |
186 | | - int boxMinY = (int)Math.floor(box.minY + 1e-6); |
187 | | - int boxMaxY = (int)Math.floor(box.maxY - 1e-6); |
188 | | - int boxMinZ = (int)Math.floor(box.minZ + 1e-6); |
189 | | - int boxMaxZ = (int)Math.floor(box.maxZ - 1e-6); |
190 | | - boolean matched = false; |
191 | | - for(ChestEntry e : openedChests) |
192 | | - { |
193 | | - if(e == null || e.dimension == null) |
194 | | - continue; |
195 | | - // Accept either namespaced ("minecraft:the_nether") |
196 | | - // or |
197 | | - // plain path ("the_nether") dimension identifiers. |
198 | | - String ed = e.dimension; |
199 | | - if(!(ed.equals(curDimFull) || ed.equals(curDim) |
200 | | - || ed.endsWith(":" + curDim))) |
201 | | - continue; |
202 | | - int minX = Math.min(e.x, e.maxX); |
203 | | - int maxX = Math.max(e.x, e.maxX); |
204 | | - int minY = Math.min(e.y, e.maxY); |
205 | | - int maxY = Math.max(e.y, e.maxY); |
206 | | - int minZ = Math.min(e.z, e.maxZ); |
207 | | - int maxZ = Math.max(e.z, e.maxZ); |
208 | | - // check range overlap between the ESP box and |
209 | | - // recorded chest bounds |
210 | | - boolean overlap = boxMinX <= maxX && boxMaxX >= minX |
211 | | - && boxMinY <= maxY && boxMaxY >= minY |
212 | | - && boxMinZ <= maxZ && boxMaxZ >= minZ; |
213 | | - if(overlap) |
214 | | - { |
215 | | - matched = true; |
216 | | - break; |
217 | | - } |
218 | | - } |
219 | | - if(matched) |
220 | | - { |
221 | | - ChestSearchMarkerRenderer.drawMarker(matrixStack, |
222 | | - box, csh.getMarkXColorARGB(), |
223 | | - csh.getMarkXThickness(), false); |
224 | | - } |
| 249 | + ChestSearchMarkerRenderer.drawMarker(matrixStack, box, |
| 250 | + csh.getMarkXColorARGB(), csh.getMarkXThickness(), |
| 251 | + false); |
225 | 252 | } |
226 | 253 | } |
227 | | - }catch(Throwable ignored) |
228 | | - { |
229 | | - // don't fail rendering if chestsearch isn't available |
230 | 254 | } |
231 | 255 | } |
232 | 256 | } |
233 | 257 |
|
| 258 | + private boolean isRecordedChest(AABB box, String curDimFull, String curDim) |
| 259 | + { |
| 260 | + if(openedChests.isEmpty()) |
| 261 | + return false; |
| 262 | + |
| 263 | + int boxMinX = (int)Math.floor(box.minX + 1e-6); |
| 264 | + int boxMaxX = (int)Math.floor(box.maxX - 1e-6); |
| 265 | + int boxMinY = (int)Math.floor(box.minY + 1e-6); |
| 266 | + int boxMaxY = (int)Math.floor(box.maxY - 1e-6); |
| 267 | + int boxMinZ = (int)Math.floor(box.minZ + 1e-6); |
| 268 | + int boxMaxZ = (int)Math.floor(box.maxZ - 1e-6); |
| 269 | + |
| 270 | + for(ChestEntry e : openedChests) |
| 271 | + { |
| 272 | + if(e == null || e.dimension == null) |
| 273 | + continue; |
| 274 | + |
| 275 | + String ed = e.dimension; |
| 276 | + boolean sameDimension = ed.equals(curDimFull) || ed.equals(curDim) |
| 277 | + || ed.endsWith(":" + curDim); |
| 278 | + if(!sameDimension) |
| 279 | + continue; |
| 280 | + |
| 281 | + int minX = Math.min(e.x, e.maxX); |
| 282 | + int maxX = Math.max(e.x, e.maxX); |
| 283 | + int minY = Math.min(e.y, e.maxY); |
| 284 | + int maxY = Math.max(e.y, e.maxY); |
| 285 | + int minZ = Math.min(e.z, e.maxZ); |
| 286 | + int maxZ = Math.max(e.z, e.maxZ); |
| 287 | + boolean overlap = |
| 288 | + boxMinX <= maxX && boxMaxX >= minX && boxMinY <= maxY |
| 289 | + && boxMaxY >= minY && boxMinZ <= maxZ && boxMaxZ >= minZ; |
| 290 | + if(overlap) |
| 291 | + return true; |
| 292 | + } |
| 293 | + |
| 294 | + return false; |
| 295 | + } |
| 296 | + |
234 | 297 | private void renderTracers(PoseStack matrixStack, float partialTicks) |
235 | 298 | { |
236 | 299 | for(ChestEspGroup group : groups.allGroups) |
|
0 commit comments