From acb2d9a4418512382c86c4edeadd32f22fafaf38 Mon Sep 17 00:00:00 2001 From: jktham-pc Date: Sat, 15 Feb 2025 22:43:13 +0100 Subject: [PATCH 1/5] Make ore prospector place waypoints at vein height --- .../widget/WidgetProspectingMap.java | 27 +++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java b/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java index f203e1af020..5735d38cc14 100644 --- a/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java +++ b/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java @@ -64,6 +64,7 @@ public class WidgetProspectingMap extends Widget { private long lastClicked; private final List hoveredNames = new ArrayList<>(); + private float hoveredOreHeight = 0.0f; private int color; public WidgetProspectingMap(int xPosition, int yPosition, int chunkRadius, WidgetOreList widgetOreList, @@ -242,6 +243,7 @@ public void drawInForeground(int mouseX, int mouseY) { // draw tooltips if (this.isMouseOverElement(mouseX, mouseY) && texture != null) { this.hoveredNames.clear(); + this.hoveredOreHeight = 0.0f; List tooltips = new ArrayList<>(); int cX = (mouseX - this.getPosition().x) / 16; int cZ = (mouseY - this.getPosition().y) / 16; @@ -260,14 +262,16 @@ public void drawInForeground(int mouseX, int mouseY) { if (this.mode == ProspectorMode.ORE) { // draw ore tooltips.add(I18n.format("terminal.prospector.ore")); HashMap oreInfo = new HashMap<>(); + HashMap oreHeight = new HashMap<>(); for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { if (texture.map[cX * 16 + i][cZ * 16 + j] != null) { - texture.map[cX * 16 + i][cZ * 16 + j].values().forEach(dict -> { + texture.map[cX * 16 + i][cZ * 16 + j].forEach((height, dict) -> { String name = OreDictUnifier.get(dict).getDisplayName(); if (ProspectingTexture.SELECTED_ALL.equals(texture.getSelected()) || texture.getSelected().equals(dict)) { oreInfo.put(name, oreInfo.getOrDefault(name, 0) + 1); + oreHeight.put(name, oreHeight.getOrDefault(name, 0.0f) + height.intValue()); if (oreInfo.get(name) > maxAmount[0]) { maxAmount[0] = oreInfo.get(name); MaterialStack m = OreDictUnifier.getMaterial(OreDictUnifier.get(dict)); @@ -280,8 +284,19 @@ public void drawInForeground(int mouseX, int mouseY) { } } } + oreHeight.forEach((name, height) -> { + int count = oreInfo.getOrDefault(name, 0); + float avgHeight = height / (count != 0 ? count : 1); + oreHeight.put(name, avgHeight); + hoveredOreHeight += avgHeight * count; + }); + int totalCount = oreInfo.values().stream().reduce(0, Integer::sum); + if (totalCount != 0) { + hoveredOreHeight /= totalCount; + } oreInfo.forEach((name, count) -> { - tooltips.add(name + " --- " + count); + float height = oreHeight.getOrDefault(name, 0.0f); + tooltips.add(name + " --- " + count + " at y: " + Math.round(height)); hoveredNames.add(name); }); } else if (this.mode == ProspectorMode.FLUID) { @@ -327,8 +342,10 @@ public boolean mouseClicked(int mouseX, int mouseY, int button) { int xPos = ((Minecraft.getMinecraft().player.chunkCoordX + xDiff) << 4) + 8; int zPos = ((Minecraft.getMinecraft().player.chunkCoordZ + zDiff) << 4) + 8; + int yPos = hoveredOreHeight != 0.0f ? Math.round(hoveredOreHeight) : + Minecraft.getMinecraft().world.getHeight(xPos, zPos); - BlockPos b = new BlockPos(xPos, Minecraft.getMinecraft().world.getHeight(xPos, zPos), zPos); + BlockPos b = new BlockPos(xPos, yPos, zPos); if (System.currentTimeMillis() - lastClicked < 400 && !hoveredNames.isEmpty()) { boolean added = false; trimHoveredNames(); @@ -405,7 +422,7 @@ private boolean addVoxelMapWaypoint(@NotNull BlockPos b) { createVeinName(), b.getX(), b.getZ(), - Minecraft.getMinecraft().world.getHeight(b.getX(), b.getZ()), + b.getY(), true, c.getRed() / 255F, c.getGreen() / 255F, @@ -451,7 +468,7 @@ private boolean addXaeroMapWaypoint(@NotNull BlockPos b) { xaero.common.minimap.waypoints.WaypointWorld ww = minimapSession.getWaypointsManager().getCurrentWorld(); xaero.common.minimap.waypoints.Waypoint xaeroWaypoint = new xaero.common.minimap.waypoints.Waypoint( b.getX(), - Minecraft.getMinecraft().world.getHeight(b.getX(), b.getZ()), + b.getY(), b.getZ(), createVeinName(), hoveredNames.get(0).substring(0, 1), bestColorIndex); From e43f37fd7d233a9044cfb4469f350a8521b59ba1 Mon Sep 17 00:00:00 2001 From: jktham-pc Date: Sat, 1 Mar 2025 16:49:43 +0100 Subject: [PATCH 2/5] store ore prospector hovered height as int --- .../prospector/widget/WidgetProspectingMap.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java b/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java index 5735d38cc14..93e545ddd7a 100644 --- a/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java +++ b/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java @@ -64,7 +64,7 @@ public class WidgetProspectingMap extends Widget { private long lastClicked; private final List hoveredNames = new ArrayList<>(); - private float hoveredOreHeight = 0.0f; + private int hoveredOreHeight = 0; private int color; public WidgetProspectingMap(int xPosition, int yPosition, int chunkRadius, WidgetOreList widgetOreList, @@ -243,7 +243,7 @@ public void drawInForeground(int mouseX, int mouseY) { // draw tooltips if (this.isMouseOverElement(mouseX, mouseY) && texture != null) { this.hoveredNames.clear(); - this.hoveredOreHeight = 0.0f; + this.hoveredOreHeight = 0; List tooltips = new ArrayList<>(); int cX = (mouseX - this.getPosition().x) / 16; int cZ = (mouseY - this.getPosition().y) / 16; @@ -285,18 +285,18 @@ public void drawInForeground(int mouseX, int mouseY) { } } oreHeight.forEach((name, height) -> { + hoveredOreHeight += height; int count = oreInfo.getOrDefault(name, 0); - float avgHeight = height / (count != 0 ? count : 1); + float avgHeight = count != 0 ? height / count : 0.0f; oreHeight.put(name, avgHeight); - hoveredOreHeight += avgHeight * count; }); int totalCount = oreInfo.values().stream().reduce(0, Integer::sum); if (totalCount != 0) { - hoveredOreHeight /= totalCount; + hoveredOreHeight = Math.round(hoveredOreHeight / (float) totalCount); } oreInfo.forEach((name, count) -> { float height = oreHeight.getOrDefault(name, 0.0f); - tooltips.add(name + " --- " + count + " at y: " + Math.round(height)); + tooltips.add(name + ", y" + Math.round(height) + " --- " + count); hoveredNames.add(name); }); } else if (this.mode == ProspectorMode.FLUID) { @@ -342,7 +342,7 @@ public boolean mouseClicked(int mouseX, int mouseY, int button) { int xPos = ((Minecraft.getMinecraft().player.chunkCoordX + xDiff) << 4) + 8; int zPos = ((Minecraft.getMinecraft().player.chunkCoordZ + zDiff) << 4) + 8; - int yPos = hoveredOreHeight != 0.0f ? Math.round(hoveredOreHeight) : + int yPos = hoveredOreHeight != 0 ? hoveredOreHeight : Minecraft.getMinecraft().world.getHeight(xPos, zPos); BlockPos b = new BlockPos(xPos, yPos, zPos); From 9c8e0e1734fe3039db0b62bc24cad2843caaef3f Mon Sep 17 00:00:00 2001 From: jktham-pc Date: Tue, 4 Mar 2025 14:06:43 +0100 Subject: [PATCH 3/5] change stuff to int --- .../prospector/widget/WidgetProspectingMap.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java b/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java index 93e545ddd7a..5b0dba95c78 100644 --- a/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java +++ b/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java @@ -262,7 +262,7 @@ public void drawInForeground(int mouseX, int mouseY) { if (this.mode == ProspectorMode.ORE) { // draw ore tooltips.add(I18n.format("terminal.prospector.ore")); HashMap oreInfo = new HashMap<>(); - HashMap oreHeight = new HashMap<>(); + HashMap oreHeight = new HashMap<>(); for (int i = 0; i < 16; i++) { for (int j = 0; j < 16; j++) { if (texture.map[cX * 16 + i][cZ * 16 + j] != null) { @@ -271,7 +271,7 @@ public void drawInForeground(int mouseX, int mouseY) { if (ProspectingTexture.SELECTED_ALL.equals(texture.getSelected()) || texture.getSelected().equals(dict)) { oreInfo.put(name, oreInfo.getOrDefault(name, 0) + 1); - oreHeight.put(name, oreHeight.getOrDefault(name, 0.0f) + height.intValue()); + oreHeight.put(name, oreHeight.getOrDefault(name, 0) + height.intValue()); if (oreInfo.get(name) > maxAmount[0]) { maxAmount[0] = oreInfo.get(name); MaterialStack m = OreDictUnifier.getMaterial(OreDictUnifier.get(dict)); @@ -287,16 +287,16 @@ public void drawInForeground(int mouseX, int mouseY) { oreHeight.forEach((name, height) -> { hoveredOreHeight += height; int count = oreInfo.getOrDefault(name, 0); - float avgHeight = count != 0 ? height / count : 0.0f; + int avgHeight = count != 0 ? height / count : 0; oreHeight.put(name, avgHeight); }); int totalCount = oreInfo.values().stream().reduce(0, Integer::sum); if (totalCount != 0) { - hoveredOreHeight = Math.round(hoveredOreHeight / (float) totalCount); + hoveredOreHeight /= totalCount; } oreInfo.forEach((name, count) -> { - float height = oreHeight.getOrDefault(name, 0.0f); - tooltips.add(name + ", y" + Math.round(height) + " --- " + count); + int height = oreHeight.getOrDefault(name, 0); + tooltips.add(name + ", y" + height + " --- " + count); hoveredNames.add(name); }); } else if (this.mode == ProspectorMode.FLUID) { From e20d71905ac2dde34d7f9664f2e32095af97de95 Mon Sep 17 00:00:00 2001 From: jktham-pc Date: Tue, 4 Mar 2025 20:45:07 +0100 Subject: [PATCH 4/5] try different tooltip format --- .../gui/widget/prospector/widget/WidgetProspectingMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java b/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java index 5b0dba95c78..dd4b9f2eaa7 100644 --- a/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java +++ b/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java @@ -296,7 +296,7 @@ public void drawInForeground(int mouseX, int mouseY) { } oreInfo.forEach((name, count) -> { int height = oreHeight.getOrDefault(name, 0); - tooltips.add(name + ", y" + height + " --- " + count); + tooltips.add(name + " --- §e" + count + "§r§7, y" + height + "§r"); hoveredNames.add(name); }); } else if (this.mode == ProspectorMode.FLUID) { From bdec0981b2839f2c4c602d9e9e03a1a8d2384b78 Mon Sep 17 00:00:00 2001 From: jktham-pc Date: Thu, 6 Mar 2025 02:14:56 +0100 Subject: [PATCH 5/5] adjust height color --- .../gui/widget/prospector/widget/WidgetProspectingMap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java b/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java index dd4b9f2eaa7..74acc2292ff 100644 --- a/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java +++ b/src/main/java/gregtech/common/gui/widget/prospector/widget/WidgetProspectingMap.java @@ -296,7 +296,7 @@ public void drawInForeground(int mouseX, int mouseY) { } oreInfo.forEach((name, count) -> { int height = oreHeight.getOrDefault(name, 0); - tooltips.add(name + " --- §e" + count + "§r§7, y" + height + "§r"); + tooltips.add(name + " --- §e" + count + "§r, §cy" + height + "§r"); hoveredNames.add(name); }); } else if (this.mode == ProspectorMode.FLUID) {