Skip to content

Commit

Permalink
Improve Invalid Setup Detection
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Dec 27, 2024
1 parent feb89b5 commit ab98f58
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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<InfoWrapper> 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<InfoWrapper> 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());
Expand Down

0 comments on commit ab98f58

Please sign in to comment.