fix forge event action performed not triggered (#1312)

Co-authored-by: Martin Robertz <dream-master@gmx.net>
Co-authored-by: UltraProdigy <187078471+UltraProdigy@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-05-23 04:21:35 +00:00
1 parent 4cf1e48645
commit f7c32abde6
5 files changed
+18 -4

No files matched your search

@@ -40,6 +40,7 @@ import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StringUtils;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.common.MinecraftForge;
import org.jetbrains.annotations.NotNull;
@@ -1171,4 +1172,17 @@ public abstract class AEBaseGui extends GuiContainer implements IGuiTooltipHandl
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
return false;
}
public void triggerActionPerformed(final GuiButton btn) {
GuiScreenEvent.ActionPerformedEvent.Pre event = new GuiScreenEvent.ActionPerformedEvent.Pre(
this,
btn,
this.buttonList);
if (MinecraftForge.EVENT_BUS.post(event)) return;
event.button.func_146113_a(this.mc.getSoundHandler());
this.actionPerformed(event.button);
if (this.equals(this.mc.currentScreen)) MinecraftForge.EVENT_BUS
.post(new GuiScreenEvent.ActionPerformedEvent.Post(this, event.button, this.buttonList));
}
}
@@ -182,7 +182,7 @@ public abstract class GuiAmount extends GuiSub {
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
this.actionPerformed(this.nextBtn);
this.triggerActionPerformed(this.nextBtn);
} else if (!this.amountTextField.textboxKeyTyped(character, key)) super.keyTyped(character, key);
}
}
@@ -939,7 +939,7 @@ public class GuiCraftConfirm extends GuiSub implements ICraftingCPUTableHolder,
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
this.actionPerformed(this.start);
this.triggerActionPerformed(this.start);
}
if (!(this.searchField.textboxKeyTyped(character, key))) {
super.keyTyped(character, key);
@@ -384,7 +384,7 @@ public class GuiLevelEmitter extends GuiUpgradeable {
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
this.actionPerformed(this.setButton);
this.triggerActionPerformed(this.setButton);
} else {
boolean typedTextbox = this.amountTextField.textboxKeyTyped(character, key);
if (typedTextbox) {
@@ -333,7 +333,7 @@ public class GuiOptimizePatterns extends GuiSub implements IGuiTooltipHandler {
protected void keyTyped(final char character, final int key) {
if (!this.checkHotbarKeys(key)) {
if (key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER) {
this.actionPerformed(this.optimize);
this.triggerActionPerformed(this.optimize);
}
this.amountToCraft.textboxKeyTyped(character, key);
super.keyTyped(character, key);