Skip to content

Commit

Permalink
fix: Don't change focus with up/down keys, remove a debug print (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucyydotp committed Oct 23, 2023
1 parent a9f9614 commit 75cce00
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
15 changes: 15 additions & 0 deletions api/src/main/java/com/noxcrew/sheeplib/mixin/ChatScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
import net.minecraft.client.gui.screens.ChatScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import org.lwjgl.glfw.GLFW;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

Expand Down Expand Up @@ -121,6 +123,19 @@ public void keyPressed(int i, int j, int k, CallbackInfoReturnable<Boolean> cir)
}
}

@Redirect(
method = "keyPressed",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/screens/Screen;keyPressed(III)Z"
)
)
public boolean redirectSuper(Screen instance, int i, int j, int k) {
return i != GLFW.GLFW_KEY_UP &&
i != GLFW.GLFW_KEY_DOWN &&
super.keyPressed(i, j, k);
}

/**
* Clear the dialog container's focus when the screen is closed.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ public object DialogContainer : Renderable, ContainerEventHandler, NarratableEnt
"New focused element is not in the container"
}
focused = dialog
logger.info("Focused $dialog")
minecraft.screen?.focused = this
}

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
allprojects {
group = "com.noxcrew.sheeplib"
version = "1.0.1"
version = "1.0.2"
}

0 comments on commit 75cce00

Please sign in to comment.