Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.7
yarn_mappings=1.21.7+build.6
loader_version=0.16.14
minecraft_version=1.21.10
yarn_mappings=1.21.10+build.3
loader_version=0.18.3

# Fabric API
fabric_version=0.128.2+1.21.7
fabric_version=0.138.4+1.21.10
# Mod Properties
mod_version = 2.4.0

Expand Down
9 changes: 6 additions & 3 deletions src/main/java/com/ui_utils/MainClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.input.SystemKeycodes;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import net.minecraft.network.packet.Packet;
Expand All @@ -24,6 +25,7 @@
import net.minecraft.screen.sync.ItemStackHash;
import net.minecraft.text.Text;
import net.minecraft.text.TextCodecs;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.NotNull;
import org.lwjgl.glfw.GLFW;
import org.slf4j.Logger;
Expand All @@ -49,7 +51,8 @@ public void onInitializeClient() {
UpdateUtils.checkForUpdates();

// register "restore screen" key
restoreScreenKey = KeyBindingHelper.registerKeyBinding(new KeyBinding("Restore Screen", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_V, "UI Utils"));
restoreScreenKey = KeyBindingHelper.registerKeyBinding(new KeyBinding("Restore Screen", InputUtil.Type.KEYSYM, GLFW.GLFW_KEY_V,
KeyBinding.Category.create(Identifier.of("ui_utils", "ui-utils"))));

// register event for END_CLIENT_TICK
ClientTickEvents.END_CLIENT_TICK.register((client) -> {
Expand All @@ -63,7 +66,7 @@ public void onInitializeClient() {
});

// set java.awt.headless to false if os is not mac (allows for JFrame guis to be used)
if (!MinecraftClient.IS_SYSTEM_MAC) {
if (!SystemKeycodes.IS_MAC_OS) {
System.setProperty("java.awt.headless", "false");
monospace = new Font(Font.MONOSPACED, Font.PLAIN, 10);
darkWhite = new Color(220, 220, 220);
Expand Down Expand Up @@ -441,7 +444,7 @@ public static void createWidgets(MinecraftClient mc, Screen screen) {
frame.add(buttonClickButton);
frame.setVisible(true);
}).width(115).position(5, 185).build();
fabricatePacketButton.active = !MinecraftClient.IS_SYSTEM_MAC;
fabricatePacketButton.active = !SystemKeycodes.IS_MAC_OS;
screen.addDrawableChild(fabricatePacketButton);

screen.addDrawableChild(ButtonWidget.builder(Text.of("Copy GUI Title JSON"), (button) -> {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/ui_utils/mixin/BookEditScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.BookEditScreen;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.input.KeyInput;
import net.minecraft.text.Text;
import org.lwjgl.glfw.GLFW;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -32,8 +33,8 @@ public void init(CallbackInfo ci) {
// create chat box
TextFieldWidget addressField = new TextFieldWidget(textRenderer, 5, 245, 160, 20, Text.of("Chat ...")) {
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if (keyCode == GLFW.GLFW_KEY_ENTER) {
public boolean keyPressed(KeyInput input) {
if (input.getKeycode() == GLFW.GLFW_KEY_ENTER) {
if (this.getText().equals("^toggleuiutils")) {
SharedVariables.enabled = !SharedVariables.enabled;
if (mc.player != null) {
Expand All @@ -54,7 +55,7 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {

this.setText("");
}
return super.keyPressed(keyCode, scanCode, modifiers);
return super.keyPressed(input);
}
};
addressField.setText("");
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/ui_utils/mixin/BookScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.BookScreen;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.input.KeyInput;
import net.minecraft.text.Text;
import org.lwjgl.glfw.GLFW;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -32,8 +33,8 @@ public void init(CallbackInfo ci) {
// create chat box
TextFieldWidget addressField = new TextFieldWidget(textRenderer, 5, 245, 160, 20, Text.of("Chat ...")) {
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if (keyCode == GLFW.GLFW_KEY_ENTER) {
public boolean keyPressed(KeyInput input) {
if (input.getKeycode() == GLFW.GLFW_KEY_ENTER) {
if (this.getText().equals("^toggleuiutils")) {
SharedVariables.enabled = !SharedVariables.enabled;
if (mc.player != null) {
Expand All @@ -54,7 +55,7 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {

this.setText("");
}
return super.keyPressed(keyCode, scanCode, modifiers);
return super.keyPressed(input);
}
};
addressField.setText("");
Expand Down
25 changes: 13 additions & 12 deletions src/main/java/com/ui_utils/mixin/HandledScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.HandledScreen;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.input.KeyInput;
import net.minecraft.screen.slot.Slot;
import net.minecraft.screen.slot.SlotActionType;
import net.minecraft.text.Text;
Expand All @@ -29,7 +30,7 @@ private HandledScreenMixin() {
}

@Shadow
protected abstract boolean handleHotbarKeyPressed(int keyCode, int scanCode);
protected abstract boolean handleHotbarKeyPressed(KeyInput input);
@Shadow
protected abstract void onMouseClick(Slot slot, int slotId, int button, SlotActionType actionType);
@Shadow
Expand All @@ -51,8 +52,8 @@ public void init(CallbackInfo ci) {
// create chat box
this.addressField = new TextFieldWidget(this.textRenderer, 5, 245, 160, 20, Text.of("Chat ...")) {
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if (keyCode == GLFW.GLFW_KEY_ENTER) {
public boolean keyPressed(KeyInput input) {
if (input.getKeycode() == GLFW.GLFW_KEY_ENTER) {
if (this.getText().equals("^toggleuiutils")) {
SharedVariables.enabled = !SharedVariables.enabled;
if (mc.player != null) {
Expand All @@ -68,13 +69,13 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
} else {
mc.getNetworkHandler().sendChatMessage(this.getText());
}
} else {
} else {
MainClient.LOGGER.warn("Minecraft network handler (mc.getNetworkHandler()) was null while trying to send chat message from UI Utils.");
}

this.setText("");
}
return super.keyPressed(keyCode, scanCode, modifiers);
return super.keyPressed(input);
}
};
this.addressField.setText("");
Expand All @@ -85,21 +86,21 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
}

@Inject(at = @At("HEAD"), method = "keyPressed", cancellable = true)
public void keyPressed(int keyCode, int scanCode, int modifiers, CallbackInfoReturnable<Boolean> cir) {
public void keyPressed(KeyInput input, CallbackInfoReturnable<Boolean> cir) {
cir.cancel();
if (super.keyPressed(keyCode, scanCode, modifiers)) {
if (super.keyPressed(input)) {
cir.setReturnValue(true);
} else if (MainClient.mc.options.inventoryKey.matchesKey(keyCode, scanCode) && (this.addressField == null || !this.addressField.isSelected())) {
} else if (MainClient.mc.options.inventoryKey.matchesKey(input) && (this.addressField == null || !this.addressField.isSelected())) {
// Crashes if address field does not exist (because of ui utils disabled, this is a temporary fix.)
this.close();
cir.setReturnValue(true);
} else {
this.handleHotbarKeyPressed(keyCode, scanCode);
this.handleHotbarKeyPressed(input);
if (this.focusedSlot != null && this.focusedSlot.hasStack()) {
if (mc.options.pickItemKey.matchesKey(keyCode, scanCode)) {
if (mc.options.pickItemKey.matchesKey(input)) {
this.onMouseClick(this.focusedSlot, this.focusedSlot.id, 0, SlotActionType.CLONE);
} else if (mc.options.dropKey.matchesKey(keyCode, scanCode)) {
this.onMouseClick(this.focusedSlot, this.focusedSlot.id, hasControlDown() ? 1 : 0, SlotActionType.THROW);
} else if (mc.options.dropKey.matchesKey(input)) {
this.onMouseClick(this.focusedSlot, this.focusedSlot.id, input.hasCtrl() ? 1 : 0, SlotActionType.THROW);
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/ui_utils/mixin/ScreenMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.ingame.LecternScreen;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.input.KeyInput;
import net.minecraft.text.Text;
import org.lwjgl.glfw.GLFW;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -51,8 +52,8 @@ public void init(MinecraftClient client, int width, int height, CallbackInfo ci)
// create chat box
this.addressField = new TextFieldWidget(textRenderer, 5, 245, 160, 20, Text.of("Chat ...")) {
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if (keyCode == GLFW.GLFW_KEY_ENTER) {
public boolean keyPressed(KeyInput input) {
if (input.getKeycode() == GLFW.GLFW_KEY_ENTER) {
if (this.getText().equals("^toggleuiutils")) {
SharedVariables.enabled = !SharedVariables.enabled;
if (mc.player != null) {
Expand All @@ -73,7 +74,7 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {

this.setText("");
}
return super.keyPressed(keyCode, scanCode, modifiers);
return super.keyPressed(input);
}
};
this.addressField.setText("");
Expand All @@ -92,4 +93,4 @@ public void render(DrawContext context, int mouseX, int mouseY, float delta, Cal
MainClient.createText(mc, context, ((ScreenAccessor) this).getTextRenderer());
}
}
}
}