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
10 changes: 4 additions & 6 deletions src/main/java/cc/aabss/eventutils/manager/KeybindManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import cc.aabss.eventutils.EventUtils;
import cc.aabss.eventutils.config.Group;
import cc.aabss.eventutils.mixin.KeyBindingAccessor;
import cc.aabss.eventutils.screen.EventInfoScreen;
import cc.aabss.eventutils.sdk.EventWrapper;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
Expand Down Expand Up @@ -36,7 +35,6 @@ public class KeybindManager {
@NotNull private static final String CATEGORY = "key.category.eventutils";
//?}

@Nullable private Long windowHandle;
@NotNull public KeyBinding eventInfoKey;
@NotNull private final Map<String, Long> lastKeyPresses = new HashMap<>();
@Nullable public EventWrapper lastEventForInfoScreen;
Expand All @@ -63,12 +61,12 @@ public KeybindManager(@NotNull EventUtils mod) {
// Only allow if no screen or TitleScreen
if (client.currentScreen != null && (!(client.currentScreen instanceof TitleScreen))) return;

// Store Minecraft's window
if (windowHandle == null) windowHandle = client.getWindow().getHandle();
// Vanilla does not update ordinary keybinding states while the title screen is open
if (client.currentScreen instanceof TitleScreen) KeyBinding.updatePressedStates();

// Event info key
if (!eventInfoKey.isUnbound()) {
if (GLFW.glfwGetKey(windowHandle, ((KeyBindingAccessor) eventInfoKey).getBoundKey().getCode()) == GLFW.GLFW_PRESS) {
if (eventInfoKey.isPressed()) {
if (canNotPress(eventInfoKey, DEFAULT_COOLDOWN_TIME_MS)) return;
EventUtils.LOGGER.debug("Event info key pressed");

Expand All @@ -91,7 +89,7 @@ public KeybindManager(@NotNull EventUtils mod) {

// Developer Mode: simulate test event
if (!testEventKey.isUnbound() && mod.config.developer_mode) {
if (GLFW.glfwGetKey(windowHandle, ((KeyBindingAccessor) testEventKey).getBoundKey().getCode()) == GLFW.GLFW_PRESS) {
if (testEventKey.isPressed()) {
if (canNotPress(testEventKey, DEFAULT_COOLDOWN_TIME_MS)) return;
EventUtils.LOGGER.debug("Test event key pressed");

Expand Down
13 changes: 0 additions & 13 deletions src/main/java/cc/aabss/eventutils/mixin/KeyBindingAccessor.java

This file was deleted.

19 changes: 19 additions & 0 deletions src/main/java/cc/aabss/eventutils/mixin/PlayerListHudMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,16 @@
import cc.aabss.eventutils.plustag.IconRenderer;
import cc.aabss.eventutils.plustag.PlusTag;
import cc.aabss.eventutils.versioning.VersionedGameProfile;
//? if >=1.21.11
//import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.hud.PlayerListHud;
import net.minecraft.client.network.PlayerListEntry;
//? if >=1.21.11 {
/*import net.minecraft.scoreboard.Scoreboard;
import net.minecraft.scoreboard.ScoreboardObjective;
*///?}
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -17,13 +23,25 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

//? if >=1.21.11
//import java.util.List;
import java.util.UUID;


@Mixin(PlayerListHud.class)
public abstract class PlayerListHudMixin {
@Shadow @Final private MinecraftClient client;

//? if >=1.21.11 {
/*@Inject(method = "render", at = @At(value = "INVOKE", target = "Ljava/util/List;get(I)Ljava/lang/Object;", ordinal = 0))
private void eventutils$drawPlusTagNextToName(DrawContext context, int scaledWindowWidth, Scoreboard scoreboard, ScoreboardObjective objective, CallbackInfo ci,
@Local(index = 5) List<PlayerListEntry> entries,
@Local(index = 22) int entryIndex,
@Local(index = 25) int x,
@Local(index = 26) int y) {
drawPlusTagNextToName(context, x, y, entries.get(entryIndex));
}
*///?} else {
@Inject(method = "renderLatencyIcon", at = @At("TAIL"), require = 0)
private void eventutils$drawPlusTagNextToName(DrawContext context, int width, int x, int y, PlayerListEntry entry, CallbackInfo ci) {
drawPlusTagNextToName(context, x, y, entry);
Expand All @@ -35,6 +53,7 @@ public abstract class PlayerListHudMixin {
private void eventutils$drawPlusTagNextToNameLunar(DrawContext context, int width, int x, int y, PlayerListEntry entry, CallbackInfo lunarCi, CallbackInfo ci) {
drawPlusTagNextToName(context, x, y, entry);
}
//?}

@Unique
private void drawPlusTagNextToName(DrawContext context, int x, int y, PlayerListEntry entry) {
Expand Down
8 changes: 7 additions & 1 deletion src/main/resources/eventutils.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@
"compatibilityLevel": "JAVA_17",
"injectors": {
"defaultRequire": 1
}
},
"client": [
"ClientMixin",
"EntryListWidgetAccessor",
"ServerListAccessor",
"ServerListMixin"
]
}