Skip to content

Commit 9b36732

Browse files
committed
Fix #1863
1 parent e0f7553 commit 9b36732

File tree

6 files changed

+35
-23
lines changed

6 files changed

+35
-23
lines changed

default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -275,14 +275,16 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
275275

276276
@Override
277277
public boolean mouseClicked(double mouseX, double mouseY, int button) {
278+
Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getGamemodeCommand().replaceAll("\\{gamemode}", gameMode.name().toLowerCase(Locale.ROOT)), "/"));
279+
minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
280+
closeMenu();
281+
return true;
282+
}
283+
284+
@Override
285+
public boolean containsMouse(double mouseX, double mouseY) {
278286
boolean disabled = this.minecraft.gameMode.getPlayerMode() == gameMode;
279-
if (!disabled && rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12) {
280-
Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getGamemodeCommand().replaceAll("\\{gamemode}", gameMode.name().toLowerCase(Locale.ROOT)), "/"));
281-
minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
282-
closeMenu();
283-
return true;
284-
}
285-
return super.mouseClicked(mouseX, mouseY, button);
287+
return rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12 && !disabled;
286288
}
287289
}
288290
}

default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -300,13 +300,15 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
300300

301301
@Override
302302
public boolean mouseClicked(double mouseX, double mouseY, int button) {
303-
if (rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12) {
304-
Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getTimeCommand().replaceAll("\\{time}", time.getPart().toLowerCase(Locale.ROOT)), "/"));
305-
minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
306-
closeMenu();
307-
return true;
308-
}
309-
return super.mouseClicked(mouseX, mouseY, button);
303+
Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getTimeCommand().replaceAll("\\{time}", time.getPart().toLowerCase(Locale.ROOT)), "/"));
304+
minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
305+
closeMenu();
306+
return true;
307+
}
308+
309+
@Override
310+
public boolean containsMouse(double mouseX, double mouseY) {
311+
return rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12;
310312
}
311313
}
312314
}

default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -309,13 +309,15 @@ public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
309309

310310
@Override
311311
public boolean mouseClicked(double mouseX, double mouseY, int button) {
312-
if (rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12) {
313-
Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT)), "/"));
314-
minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
315-
closeMenu();
316-
return true;
317-
}
318-
return super.mouseClicked(mouseX, mouseY, button);
312+
Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT)), "/"));
313+
minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
314+
closeMenu();
315+
return true;
316+
}
317+
318+
@Override
319+
public boolean containsMouse(double mouseX, double mouseY) {
320+
return rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12;
319321
}
320322
}
321323
}

runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/EntryWidget.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,11 @@ public void tooltipProcessor(UnaryOperator<Tooltip> operator) {
561561

562562
@Override
563563
public boolean mouseClicked(double mouseX, double mouseY, int button) {
564-
if (containsMouse(mouseX, mouseY))
564+
if (containsMouse(mouseX, mouseY)) {
565565
this.wasClicked = true;
566+
return true;
567+
}
568+
566569
return super.mouseClicked(mouseX, mouseY, button);
567570
}
568571

runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/history/DisplayEntry.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,11 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
234234
return true;
235235
}
236236
}
237+
238+
return true;
237239
}
238240

239-
return super.mouseClicked(mouseX, mouseY, button);
241+
return false;
240242
}
241243

242244
@Override

runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/favorites/panel/FadingFavoritesPanelButton.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public List<? extends GuiEventListener> children() {
105105
public boolean mouseClicked(double mouseX, double mouseY, int button) {
106106
if (isVisible() && containsMouse(mouseX, mouseY)) {
107107
this.wasClicked = true;
108+
return true;
108109
}
109110
return false;
110111
}

0 commit comments

Comments
 (0)