From ab98f587ce98479dd6c0c4008b35dbb9d192d0a4 Mon Sep 17 00:00:00 2001 From: Integer Limit <103940576+IntegerLimit@users.noreply.github.com> Date: Fri, 27 Dec 2024 22:00:22 +1100 Subject: [PATCH] Improve Invalid Setup Detection --- .../mixin/betterp2p/WidgetP2PColumnMixin.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/betterp2p/WidgetP2PColumnMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/betterp2p/WidgetP2PColumnMixin.java index 4bc33274..aa86dc12 100644 --- a/src/main/java/com/nomiceu/nomilabs/mixin/betterp2p/WidgetP2PColumnMixin.java +++ b/src/main/java/com/nomiceu/nomilabs/mixin/betterp2p/WidgetP2PColumnMixin.java @@ -6,6 +6,7 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import com.nomiceu.nomilabs.integration.betterp2p.LabsBetterMemoryCardModes; import com.nomiceu.nomilabs.network.LabsNetworkHandler; @@ -20,7 +21,8 @@ import kotlin.jvm.functions.Function0; /** - * Trims text before renaming, handles add as input/output, properly refreshes renames in gui. + * Trims text before renaming, handles add as input/output, properly refreshes renames in gui, + * properly searches for inputs/outputs. */ @Mixin(value = WidgetP2PColumn.class, remap = false) public class WidgetP2PColumnMixin { @@ -37,6 +39,28 @@ public class WidgetP2PColumnMixin { @Final private IGuiTextField renameBar; + @Inject(method = "findInput", at = @At("HEAD"), cancellable = true) + private void findInputInAll(Short frequency, CallbackInfoReturnable cir) { + for (InfoWrapper info : infos.getSorted()) { + if (info.getFrequency() == frequency && !info.getOutput()) { + cir.setReturnValue(info); + return; + } + } + cir.setReturnValue(null); + } + + @Inject(method = "findOutput", at = @At("HEAD"), cancellable = true) + private void findOutputInAll(Short frequency, CallbackInfoReturnable cir) { + for (InfoWrapper info : infos.getSorted()) { + if (info.getFrequency() == frequency && info.getOutput()) { + cir.setReturnValue(info); + return; + } + } + cir.setReturnValue(null); + } + @Inject(method = "finishRename", at = @At("HEAD")) private void trimText(CallbackInfo ci) { renameBar.setText(renameBar.getText().trim());