Skip to content

Commit

Permalink
Improve compatibility with Xaero's Minimap mod
Browse files Browse the repository at this point in the history
closes #5
  • Loading branch information
LemonCaramel committed Jan 28, 2024
1 parent 9f32074 commit f98bcf7
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
2 changes: 2 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
repositories {
maven { url "https://maven.terraformersmc.com/" }
maven { url = "https://api.modrinth.com/maven" }
}

dependencies {
Expand All @@ -9,6 +10,7 @@ dependencies {

// Other mods
modCompileOnly "dev.emi:emi-xplat-intermediary:${emi_version}"
modCompileOnly "maven.modrinth:xaeros-minimap:${xaeros_minimap_version}"
}

architectury {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package moe.caramel.chat.mixin.xaeromap;

import moe.caramel.chat.controller.EditBoxController;
import moe.caramel.chat.wrapper.AbstractIMEWrapper;
import moe.caramel.chat.wrapper.WrapperEditBox;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.events.GuiEventListener;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import xaero.common.gui.GuiAddWaypoint;

/**
* (Xaero's Minimap Mixin) ???.
*/
@Mixin(GuiAddWaypoint.class)
public abstract class MixinPluginXaeroMapWayPoint {

@Shadow private EditBox nameTextField;
@Shadow private EditBox initialTextField;
@Shadow(remap = false) private boolean ignoreEditBoxChanges;
@Shadow(remap = false) protected abstract void postType(GuiEventListener focused);

@Inject(method = "init", at = @At("TAIL"))
private void init(final CallbackInfo ci) {
this.caramelChat$fixIme(this.nameTextField);
this.caramelChat$fixIme(this.initialTextField);
}

@Unique
private void caramelChat$fixIme(final EditBox box) {
final WrapperEditBox wrapper = EditBoxController.getWrapper(box);
wrapper.setInsertCallback(() -> {
if (wrapper.getStatus() == AbstractIMEWrapper.InputStatus.PREVIEW) {
this.ignoreEditBoxChanges = false;
this.postType(box);
}
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ public final class Compatibilities {
)
);

public static final Data XAERO_MINIMAP = register(
"Xaero's Minimap", "xaero.common.gui.GuiAddWaypoint",
Set.of("moe.caramel.chat.mixin.xaeromap.MixinPluginXaeroMapWayPoint")
);

// ================================

/**
Expand Down
3 changes: 2 additions & 1 deletion common/src/main/resources/caramelchat.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"MixinSelectWorldScreen",
"MixinSignEditScreen",
"emi.MixinPluginEmiPort",
"emi.MixinPluginEmiSearchWidget"
"emi.MixinPluginEmiSearchWidget",
"xaeromap.MixinPluginXaeroMapWayPoint"
]
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ forge_version=1.20.1-47.1.44

# Other mods
emi_version=1.1.0+1.20.1
xaeros_minimap_version=23.9.7_Fabric_1.20

0 comments on commit f98bcf7

Please sign in to comment.