Skip to content

Commit 3be7d97

Browse files
committed
fix: make the mouseIn method more consistent
Show the tooltip/highlighting when the mouse is over the border of the capacitors/tanks to match slots Remove unused copy of the mouseIn method from TankImpl
1 parent 9ce9ae0 commit 3be7d97

3 files changed

Lines changed: 5 additions & 9 deletions

File tree

src/main/java/dev/galacticraft/machinelib/client/api/screen/MachineScreen.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ private static Item getOptionalItem(ResourceLocation id, Item fallback) {
229229
}
230230

231231
protected static boolean mouseIn(double mouseX, double mouseY, int x, int y, int width, int height) {
232-
return mouseX >= x && mouseY >= y && mouseX <= x + width && mouseY <= y + height;
232+
return mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
233233
}
234234

235235
@Override
@@ -820,7 +820,7 @@ protected void drawCapacitor(GuiGraphics graphics, int mouseX, int mouseY) {
820820
long amount = this.menu.energyStorage.getAmount();
821821
GraphicsUtil.drawCapacitor(graphics, x, y, capacity, amount, false);
822822

823-
if (mouseIn(mouseX, mouseY, x, y, 16, this.capacitorHeight)) {
823+
if (mouseIn(mouseX, mouseY, x - 1, y - 1, OVERLAY_WIDTH + 2, this.capacitorHeight + 2)) {
824824
List<Component> lines = new ArrayList<>();
825825
this.appendEnergyTooltip(lines);
826826
this.setTooltipForNextRenderPass(Lists.transform(lines, Component::getVisualOrderText));
@@ -865,7 +865,7 @@ protected void drawTanks(GuiGraphics graphics, int mouseX, int mouseY) {
865865
}
866866
}
867867

868-
if (this.hoveredTank == null && mouseIn(mouseX, mouseY, this.leftPos + tank.getX(), this.topPos + tank.getY(), tank.getWidth(), tank.getHeight())) {
868+
if (this.hoveredTank == null && mouseIn(mouseX, mouseY, this.leftPos + tank.getX() - 1, this.topPos + tank.getY() - 1, tank.getWidth() + 2, tank.getHeight() + 2)) {
869869
this.hoveredTank = tank;
870870
RenderSystem.disableDepthTest();
871871
graphics.fill(tank.getX(), tank.getY(), tank.getX() + tank.getWidth(), tank.getY() + tank.getHeight(), 0x80ffffff);
@@ -876,7 +876,7 @@ protected void drawTanks(GuiGraphics graphics, int mouseX, int mouseY) {
876876
graphics.pose().popPose();
877877

878878
for (Tank tank : this.menu.tanks) {
879-
if (mouseIn(mouseX, mouseY, this.leftPos + tank.getX(), this.topPos + tank.getY(), tank.getWidth(), tank.getHeight())) {
879+
if (mouseIn(mouseX, mouseY, this.leftPos + tank.getX() - 1, this.topPos + tank.getY() - 1, tank.getWidth() + 2, tank.getHeight() + 2)) {
880880
this.setTooltipForNextRenderPass(Lists.transform(tank.getTooltip(), Component::getVisualOrderText));
881881
break;
882882
}

src/main/java/dev/galacticraft/machinelib/impl/Constant.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ interface TextureCoordinate {
111111
/**
112112
* The height of a configuration tab.
113113
*/
114-
115114
int TAB_HEIGHT = 22;
115+
116116
int BUTTON_U = 0;
117117
int BUTTON_V = 196;
118118
int BUTTON_HOVERED_V = 216;

src/main/java/dev/galacticraft/machinelib/impl/menu/TankImpl.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ public TankImpl(ResourceSlot<Fluid> slot, TransferType transferType, int index,
6767
this.marked = marked;
6868
}
6969

70-
private static boolean mouseIn(double mouseX, double mouseY, int x, int y, int width, int height) {
71-
return mouseX >= x && mouseY >= y && mouseX <= x + width && mouseY <= y + height;
72-
}
73-
7470
@Override
7571
public @Nullable Fluid getFluid() {
7672
return this.slot.getResource();

0 commit comments

Comments
 (0)