From 9b367326a210dc6842c45341ddf4f3d599158736 Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sat, 12 Apr 2025 16:43:27 +0800 Subject: Fix #1863 --- .../plugin/client/favorites/GameModeFavoriteEntry.java | 16 +++++++++------- .../rei/plugin/client/favorites/TimeFavoriteEntry.java | 16 +++++++++------- .../plugin/client/favorites/WeatherFavoriteEntry.java | 16 +++++++++------- 3 files changed, 27 insertions(+), 21 deletions(-) (limited to 'default-plugin') diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java index bdf7456df..e78e10cc3 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java @@ -275,14 +275,16 @@ public class GameModeFavoriteEntry extends FavoriteEntry { @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { + Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getGamemodeCommand().replaceAll("\\{gamemode}", gameMode.name().toLowerCase(Locale.ROOT)), "/")); + minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + closeMenu(); + return true; + } + + @Override + public boolean containsMouse(double mouseX, double mouseY) { boolean disabled = this.minecraft.gameMode.getPlayerMode() == gameMode; - if (!disabled && rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12) { - Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getGamemodeCommand().replaceAll("\\{gamemode}", gameMode.name().toLowerCase(Locale.ROOT)), "/")); - minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); - closeMenu(); - return true; - } - return super.mouseClicked(mouseX, mouseY, button); + return rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12 && !disabled; } } } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java index c6c0d6bdc..dec965a60 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java @@ -300,13 +300,15 @@ public class TimeFavoriteEntry extends FavoriteEntry { @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12) { - Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getTimeCommand().replaceAll("\\{time}", time.getPart().toLowerCase(Locale.ROOT)), "/")); - minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); - closeMenu(); - return true; - } - return super.mouseClicked(mouseX, mouseY, button); + Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getTimeCommand().replaceAll("\\{time}", time.getPart().toLowerCase(Locale.ROOT)), "/")); + minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + closeMenu(); + return true; + } + + @Override + public boolean containsMouse(double mouseX, double mouseY) { + return rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12; } } } diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java index bfb0334cc..fde840d21 100644 --- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java +++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java @@ -309,13 +309,15 @@ public class WeatherFavoriteEntry extends FavoriteEntry { @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12) { - Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT)), "/")); - minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); - closeMenu(); - return true; - } - return super.mouseClicked(mouseX, mouseY, button); + Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT)), "/")); + minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F)); + closeMenu(); + return true; + } + + @Override + public boolean containsMouse(double mouseX, double mouseY) { + return rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12; } } } -- cgit