mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-11-26 05:28:33 +01:00
fixed the cancel crafting button not working correctly with JEI installed
This commit is contained in:
parent
42e91287a8
commit
82d56178f3
1 changed files with 16 additions and 7 deletions
|
@ -2,13 +2,11 @@ package de.ellpeck.prettypipes.terminal.containers;
|
||||||
|
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import de.ellpeck.prettypipes.PrettyPipes;
|
import de.ellpeck.prettypipes.PrettyPipes;
|
||||||
import de.ellpeck.prettypipes.misc.ItemOrder;
|
|
||||||
import de.ellpeck.prettypipes.misc.ItemTerminalWidget;
|
import de.ellpeck.prettypipes.misc.ItemTerminalWidget;
|
||||||
import de.ellpeck.prettypipes.misc.PlayerPrefs;
|
import de.ellpeck.prettypipes.misc.PlayerPrefs;
|
||||||
import de.ellpeck.prettypipes.packets.PacketButton;
|
import de.ellpeck.prettypipes.packets.PacketButton;
|
||||||
import de.ellpeck.prettypipes.packets.PacketHandler;
|
import de.ellpeck.prettypipes.packets.PacketHandler;
|
||||||
import de.ellpeck.prettypipes.packets.PacketRequest;
|
import de.ellpeck.prettypipes.packets.PacketRequest;
|
||||||
import de.ellpeck.prettypipes.pipe.containers.AbstractPipeGui;
|
|
||||||
import joptsimple.internal.Strings;
|
import joptsimple.internal.Strings;
|
||||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||||
|
@ -103,10 +101,7 @@ public class ItemTerminalGui extends ContainerScreen<ItemTerminalContainer> {
|
||||||
prefs.save();
|
prefs.save();
|
||||||
this.updateWidgets();
|
this.updateWidgets();
|
||||||
}));
|
}));
|
||||||
this.cancelCraftingButton = this.addButton(new Button(this.guiLeft + this.xSize + 4, this.guiTop + 4 + 64, 54, 20, new TranslationTextComponent("info." + PrettyPipes.ID + ".cancel_all"), button -> {
|
this.cancelCraftingButton = this.addButton(new Button(this.guiLeft + this.xSize + 4, this.guiTop + 4 + 64, 54, 20, new TranslationTextComponent("info." + PrettyPipes.ID + ".cancel_all"), b -> {
|
||||||
if (this.currentlyCrafting == null || this.currentlyCrafting.isEmpty())
|
|
||||||
return;
|
|
||||||
PacketHandler.sendToServer(new PacketButton(this.container.tile.getPos(), PacketButton.ButtonResult.CANCEL_CRAFTING));
|
|
||||||
}));
|
}));
|
||||||
this.cancelCraftingButton.visible = false;
|
this.cancelCraftingButton.visible = false;
|
||||||
for (int y = 0; y < 4; y++) {
|
for (int y = 0; y < 4; y++) {
|
||||||
|
@ -141,6 +136,20 @@ public class ItemTerminalGui extends ContainerScreen<ItemTerminalContainer> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseReleased(double mouseX, double mouseY, int button) {
|
||||||
|
// we have to do the click logic here because JEI is activated when letting go of the mouse button
|
||||||
|
// and vanilla buttons are activated when the click starts, so we'll always invoke jei accidentally by default
|
||||||
|
if (button == 0 && this.cancelCraftingButton.visible && this.cancelCraftingButton.isHovered()) {
|
||||||
|
if (this.currentlyCrafting != null && !this.currentlyCrafting.isEmpty()) {
|
||||||
|
PacketHandler.sendToServer(new PacketButton(this.container.tile.getPos(), PacketButton.ButtonResult.CANCEL_CRAFTING));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return super.mouseReleased(mouseX, mouseY, button);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(int x, int y, int z) {
|
public boolean keyPressed(int x, int y, int z) {
|
||||||
// for some reason we have to do this to make the text field allow the inventory key to be typed
|
// for some reason we have to do this to make the text field allow the inventory key to be typed
|
||||||
|
@ -231,7 +240,7 @@ public class ItemTerminalGui extends ContainerScreen<ItemTerminalContainer> {
|
||||||
if (this.ascendingButton.isHovered())
|
if (this.ascendingButton.isHovered())
|
||||||
this.renderTooltip(matrix, new TranslationTextComponent("info." + PrettyPipes.ID + "." + (prefs.terminalAscending ? "ascending" : "descending")), mouseX, mouseY);
|
this.renderTooltip(matrix, new TranslationTextComponent("info." + PrettyPipes.ID + "." + (prefs.terminalAscending ? "ascending" : "descending")), mouseX, mouseY);
|
||||||
}
|
}
|
||||||
if (this.cancelCraftingButton.isHovered()) {
|
if (this.cancelCraftingButton.visible && this.cancelCraftingButton.isHovered()) {
|
||||||
String[] tooltip = I18n.format("info." + PrettyPipes.ID + ".cancel_all.desc").split("\n");
|
String[] tooltip = I18n.format("info." + PrettyPipes.ID + ".cancel_all.desc").split("\n");
|
||||||
this.func_243308_b(matrix, Arrays.stream(tooltip).map(StringTextComponent::new).collect(Collectors.toList()), mouseX, mouseY);
|
this.func_243308_b(matrix, Arrays.stream(tooltip).map(StringTextComponent::new).collect(Collectors.toList()), mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue