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..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 @@ -64,6 +64,7 @@ public class WidgetProspectingMap extends Widget { private long lastClicked; private final List hoveredNames = new ArrayList<>(); + private int hoveredOreHeight = 0; 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; 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) + 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) -> { + hoveredOreHeight += height; + int count = oreInfo.getOrDefault(name, 0); + int avgHeight = count != 0 ? height / count : 0; + oreHeight.put(name, avgHeight); + }); + int totalCount = oreInfo.values().stream().reduce(0, Integer::sum); + if (totalCount != 0) { + hoveredOreHeight /= totalCount; + } oreInfo.forEach((name, count) -> { - tooltips.add(name + " --- " + count); + int height = oreHeight.getOrDefault(name, 0); + tooltips.add(name + " --- §e" + count + "§r, §cy" + height + "§r"); 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 ? 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);