-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
72 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
common/src/main/java/moe/caramel/chat/mixin/emi/MixinPluginEmiPort.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package moe.caramel.chat.mixin.emi; | ||
|
||
import dev.emi.emi.EmiPort; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.util.FormattedCharSequence; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
/** | ||
* (EMI Mixin) Fix crash in PREVIEW mode. | ||
*/ | ||
@Mixin(EmiPort.class) | ||
public final class MixinPluginEmiPort { | ||
|
||
@Inject(method = "ordered", at = @At("HEAD"), cancellable = true) | ||
private static void fixCrashInPreviewMode(final Component text, final CallbackInfoReturnable<FormattedCharSequence> cir) { | ||
if (text == null) { | ||
cir.setReturnValue(FormattedCharSequence.EMPTY); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
common/src/main/java/moe/caramel/chat/mixin/emi/MixinPluginEmiSearchWidget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package moe.caramel.chat.mixin.emi; | ||
|
||
import dev.emi.emi.screen.widget.EmiSearchWidget; | ||
import moe.caramel.chat.controller.EditBoxController; | ||
import net.minecraft.client.gui.components.EditBox; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
/** | ||
* (EMI Mixin) Refresh the search results immediately. | ||
*/ | ||
@Mixin(EmiSearchWidget.class) | ||
public final class MixinPluginEmiSearchWidget { | ||
|
||
@Inject(method = "<init>", at = @At("TAIL")) | ||
private void init(final CallbackInfo ci) { | ||
final EditBox editBox = ((EditBox) (Object) this); | ||
EditBoxController.getWrapper(editBox) | ||
.setInsertCallback(() -> { | ||
if (editBox.responder != null) { | ||
editBox.responder.accept(editBox.value); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters