Skip to content

Commit

Permalink
fixed controller input crash
Browse files Browse the repository at this point in the history
  • Loading branch information
UselessBullets committed Apr 18, 2024
1 parent 52c07f0 commit ff1025d
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 78 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
1 change: 0 additions & 1 deletion src/main/java/useless/legacyui/Gui/IGuiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.minecraft.client.input.controller.ControllerInput;

public interface IGuiController {
void GuiControls(ControllerInput controllerInput);
boolean playDefaultPressSound();
boolean enableDefaultSnapping();
}
144 changes: 72 additions & 72 deletions src/main/java/useless/legacyui/Mixins/ControllerInputMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ff1025d

Please sign in to comment.