From ff1025d1ba0cd8fb2d1063c9b83872df61ed7ed9 Mon Sep 17 00:00:00 2001 From: UselessBullets <80850784+UselessBullets@users.noreply.github.com> Date: Thu, 18 Apr 2024 04:41:15 -0500 Subject: [PATCH] fixed controller input crash --- gradle.properties | 2 +- .../Gui/GuiScreens/GuiLegacyCrafting.java | 2 +- .../Gui/GuiScreens/GuiLegacyCreative.java | 2 +- .../Gui/GuiScreens/GuiLegacyFlag.java | 2 +- .../Gui/GuiScreens/GuiLegacyInventory.java | 2 +- .../useless/legacyui/Gui/IGuiController.java | 1 - .../legacyui/Mixins/ControllerInputMixin.java | 144 +++++++++--------- 7 files changed, 77 insertions(+), 78 deletions(-) diff --git a/gradle.properties b/gradle.properties index 2d26377..7dc11f5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,6 +11,6 @@ halplibe_version=3.5.3 prismatic_version=3.1.1-7.1 # Mod -mod_version=1.2.0-7.1 +mod_version=1.2.1-7.1 mod_group=useless mod_name=legacyui diff --git a/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyCrafting.java b/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyCrafting.java index 7816980..6ca42c1 100644 --- a/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyCrafting.java +++ b/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyCrafting.java @@ -420,7 +420,7 @@ public void renderCraftingDisplay(int mouseX, int mouseY) { } @Override - public void GuiControls(ControllerInput controllerInput) { + public void guiSpecificControllerInput(ControllerInput controllerInput) { if (controllerInput.buttonR.pressedThisFrame() || controllerInput.buttonR.isPressed() && RepeatInputHandler.doRepeatInput(-2, UtilGui.tabScrollRepeatDelay) && controllerInput.buttonR.getHoldTime() > 3){ RepeatInputHandler.manualSuccess(-2); scrollTab(1); diff --git a/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyCreative.java b/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyCreative.java index 6c42fbe..e87309e 100644 --- a/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyCreative.java +++ b/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyCreative.java @@ -273,7 +273,7 @@ protected void drawGuiContainerBackgroundLayer(float renderPartialTick) { } @Override - public void GuiControls(ControllerInput controllerInput) { + public void guiSpecificControllerInput(ControllerInput controllerInput) { if (controllerInput.buttonR.pressedThisFrame() || controllerInput.buttonR.isPressed() && RepeatInputHandler.doRepeatInput(-2, UtilGui.tabScrollRepeatDelay) && controllerInput.buttonR.getHoldTime() > 3){ RepeatInputHandler.manualSuccess(-2); scrollTab(1); diff --git a/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyFlag.java b/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyFlag.java index 6da3072..1677f4f 100644 --- a/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyFlag.java +++ b/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyFlag.java @@ -517,7 +517,7 @@ public void onClosed() { } @Override - public void GuiControls(ControllerInput controllerInput) { + public void guiSpecificControllerInput(ControllerInput controllerInput) { int dpadDelay = 1000/15; int dyeSelectDelay = 1000/7; int toolDelay = UtilGui.tabScrollRepeatDelay; diff --git a/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyInventory.java b/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyInventory.java index f15e45e..af913f4 100644 --- a/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyInventory.java +++ b/src/main/java/useless/legacyui/Gui/GuiScreens/GuiLegacyInventory.java @@ -135,7 +135,7 @@ private void renderPlayerDoll(){ } @Override - public void GuiControls(ControllerInput controllerInput) { + public void guiSpecificControllerInput(ControllerInput controllerInput) { if (controllerInput.buttonZL.pressedThisFrame() && player.getGamemode() == Gamemode.creative){ openCreative(); } diff --git a/src/main/java/useless/legacyui/Gui/IGuiController.java b/src/main/java/useless/legacyui/Gui/IGuiController.java index de3e972..cc47023 100644 --- a/src/main/java/useless/legacyui/Gui/IGuiController.java +++ b/src/main/java/useless/legacyui/Gui/IGuiController.java @@ -3,7 +3,6 @@ import net.minecraft.client.input.controller.ControllerInput; public interface IGuiController { - void GuiControls(ControllerInput controllerInput); boolean playDefaultPressSound(); boolean enableDefaultSnapping(); } diff --git a/src/main/java/useless/legacyui/Mixins/ControllerInputMixin.java b/src/main/java/useless/legacyui/Mixins/ControllerInputMixin.java index 1b08300..095cc4c 100644 --- a/src/main/java/useless/legacyui/Mixins/ControllerInputMixin.java +++ b/src/main/java/useless/legacyui/Mixins/ControllerInputMixin.java @@ -48,83 +48,83 @@ public class ControllerInputMixin { @Final @Shadow public final Minecraft minecraft = Minecraft.getMinecraft(this); - /** - * @author Useless - * @reason I need to fundamentally restructure the inventory controls system to work with how I want to setup controller support - */ - @Overwrite - public void inventoryControls(GuiContainer guiContainer){ - thisAsController = (ControllerInput)(Object)(this); - boolean hasDoneGuiSpecificControls = false; - boolean playDefaultSound = true; - boolean doDefaultSlotSnap = true; - if (guiContainer instanceof IGuiController){ - IGuiController iGuiController = ((IGuiController) guiContainer); - iGuiController.GuiControls(thisAsController); - playDefaultSound = iGuiController.playDefaultPressSound(); - doDefaultSlotSnap = iGuiController.enableDefaultSnapping(); - hasDoneGuiSpecificControls = true; - } - Slot currentSlot = this.getSlotAt((int)this.cursorX, (int)this.cursorY, guiContainer); - if (doDefaultSlotSnap){ - if (currentSlot != null) { - Slot slot3; - if (this.digitalPad.right.pressedThisFrame()) { - snapRight(guiContainer, currentSlot); - } - if (this.digitalPad.left.pressedThisFrame()) { - snapLeft(guiContainer, currentSlot); - } - if (this.digitalPad.up.pressedThisFrame()) { - snapUp(guiContainer, currentSlot); - } - if (this.digitalPad.down.pressedThisFrame()) { - snapDown(guiContainer, currentSlot); - } - } - } - if (this.buttonR.pressedThisFrame() && (currentSlot = this.getSlotAtCursor(guiContainer)) != null) { - System.out.println("SLOT: " + currentSlot.id); - } - if (!hasDoneGuiSpecificControls) { - if (guiContainer instanceof GuiInventoryCreative) { - GuiInventoryCreative inventoryCreative = (GuiInventoryCreative) guiContainer; - if (this.buttonL.pressedThisFrame()) { - inventoryCreative.scroll(1); - } - if (this.buttonR.pressedThisFrame()) { - inventoryCreative.scroll(-1); - } - } -// if (guiContainer instanceof GuiGuidebook) { TODO add controller support to new guidebook -// GuiGuidebook guidebook = (GuiGuidebook) guiContainer; +// /** +// * @author Useless +// * @reason I need to fundamentally restructure the inventory controls system to work with how I want to setup controller support +// */ +// @Overwrite +// public void inventoryControls(GuiContainer guiContainer){ +// thisAsController = (ControllerInput)(Object)(this); +// boolean hasDoneGuiSpecificControls = false; +// boolean playDefaultSound = true; +// boolean doDefaultSlotSnap = true; +// if (guiContainer instanceof IGuiController){ +// IGuiController iGuiController = ((IGuiController) guiContainer); +// iGuiController.GuiControls(thisAsController); +// playDefaultSound = iGuiController.playDefaultPressSound(); +// doDefaultSlotSnap = iGuiController.enableDefaultSnapping(); +// hasDoneGuiSpecificControls = true; +// } +// Slot currentSlot = this.getSlotAt((int)this.cursorX, (int)this.cursorY, guiContainer); +// if (doDefaultSlotSnap){ +// if (currentSlot != null) { +// Slot slot3; +// if (this.digitalPad.right.pressedThisFrame()) { +// snapRight(guiContainer, currentSlot); +// } +// if (this.digitalPad.left.pressedThisFrame()) { +// snapLeft(guiContainer, currentSlot); +// } +// if (this.digitalPad.up.pressedThisFrame()) { +// snapUp(guiContainer, currentSlot); +// } +// if (this.digitalPad.down.pressedThisFrame()) { +// snapDown(guiContainer, currentSlot); +// } +// } +// } +// if (this.buttonR.pressedThisFrame() && (currentSlot = this.getSlotAtCursor(guiContainer)) != null) { +// System.out.println("SLOT: " + currentSlot.id); +// } +// if (!hasDoneGuiSpecificControls) { +// if (guiContainer instanceof GuiInventoryCreative) { +// GuiInventoryCreative inventoryCreative = (GuiInventoryCreative) guiContainer; // if (this.buttonL.pressedThisFrame()) { -// guidebook.scroll(1); +// inventoryCreative.scroll(1); // } // if (this.buttonR.pressedThisFrame()) { -// guidebook.scroll(-1); +// inventoryCreative.scroll(-1); // } // } - if (guiContainer instanceof GuiCrafting) { - this.craftingGuiHandler.handleCrafting((GuiCrafting) guiContainer); - } - if (guiContainer instanceof GuiInventory) { - this.craftingGuiHandler.handleInventory((GuiInventory) guiContainer); - } - if (guiContainer instanceof GuiFurnace) { - this.craftingGuiHandler.handleFurnace((GuiFurnace) guiContainer); - } - } - if (!playDefaultSound){ - return; - } - if (this.buttonA.pressedThisFrame() || this.buttonX.pressedThisFrame() || this.buttonY.pressedThisFrame()) { - LegacySoundManager.play.press(true); - } - if (this.buttonB.pressedThisFrame()) { - LegacySoundManager.play.back(true); - } - } +//// if (guiContainer instanceof GuiGuidebook) { TODO add controller support to new guidebook +//// GuiGuidebook guidebook = (GuiGuidebook) guiContainer; +//// if (this.buttonL.pressedThisFrame()) { +//// guidebook.scroll(1); +//// } +//// if (this.buttonR.pressedThisFrame()) { +//// guidebook.scroll(-1); +//// } +//// } +// if (guiContainer instanceof GuiCrafting) { +// this.craftingGuiHandler.handleCrafting((GuiCrafting) guiContainer); +// } +// if (guiContainer instanceof GuiInventory) { +// this.craftingGuiHandler.handleInventory((GuiInventory) guiContainer); +// } +// if (guiContainer instanceof GuiFurnace) { +// this.craftingGuiHandler.handleFurnace((GuiFurnace) guiContainer); +// } +// } +// if (!playDefaultSound){ +// return; +// } +// if (this.buttonA.pressedThisFrame() || this.buttonX.pressedThisFrame() || this.buttonY.pressedThisFrame()) { +// LegacySoundManager.play.press(true); +// } +// if (this.buttonB.pressedThisFrame()) { +// LegacySoundManager.play.back(true); +// } +// } @Shadow public Slot getSlotAtCursor(GuiContainer guiContainer) { return null;