Skip to content

Commit

Permalink
Release 1.1.0-beta.1 for Minecraft 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonCaramel committed Sep 22, 2023
1 parent 8fe20ae commit 30db6f5
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 52 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/caramelchat-build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: Build caramelChat

on: [ push, pull_request ]
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,5 @@ private void rewriteDrawPage(final GuiGraphics helper, final int mouseX, final i
// Run cancelled task
this.renderHighlight(helper, cache.selection);
this.renderCursor(helper, cache.cursor, cache.cursorAtEnd);
super.render(helper, mouseX, mouseY, delta);
}
}
50 changes: 7 additions & 43 deletions common/src/main/java/moe/caramel/chat/mixin/MixinEditBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
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.ModifyArg;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.ArrayList;
Expand All @@ -31,6 +30,8 @@ public abstract class MixinEditBox implements EditBoxController {
@Unique private int caramelChat$cacheCursorPos, caramelChat$cacheHighlightPos;
@Shadow private BiFunction<String, Integer, FormattedCharSequence> formatter;
@Shadow private boolean canLoseFocus;
@Shadow public int highlightPos;
@Shadow public int cursorPos;
@Shadow public String value;

@Inject(
Expand Down Expand Up @@ -102,7 +103,7 @@ else if (caramelChat$wrapper.blockTyping()) {
@Inject(method = "setValue", at = @At("HEAD"))
private void setValueHead(final String text, final CallbackInfo ci) {
// setStatusToNone -> forceUpdateOrigin -> onValueChange
if (caramelChat$wrapper.valueChanged) {
if (this.caramelChat$wrapper != null && this.caramelChat$wrapper.valueChanged) {
this.caramelChat$cacheCursorPos = 0;
this.caramelChat$cacheHighlightPos = 0;
} else {
Expand All @@ -118,7 +119,7 @@ private void setValueHead(final String text, final CallbackInfo ci) {
)
)
private boolean setValuePredicateTest(final Predicate<String> predicate, final Object value) {
if (caramelChat$wrapper.valueChanged) {
if (this.caramelChat$wrapper != null && this.caramelChat$wrapper.valueChanged) {
this.caramelChat$cacheCursorPos = this.cursorPos;
this.caramelChat$cacheHighlightPos = this.highlightPos;
return true;
Expand All @@ -131,11 +132,11 @@ private boolean setValuePredicateTest(final Predicate<String> predicate, final O
method = "setValue",
at = @At(
value = "INVOKE", shift = At.Shift.BEFORE,
target = "Lnet/minecraft/client/gui/components/EditBox;moveCursorToEnd()V"
target = "Lnet/minecraft/client/gui/components/EditBox;moveCursorToEnd(Z)V"
), cancellable = true
)
private void setValueInvoke(final String text, final CallbackInfo ci) {
if (caramelChat$wrapper.valueChanged) {
if (this.caramelChat$wrapper != null && this.caramelChat$wrapper.valueChanged) {
ci.cancel();
// caxton Compatibility
this.cursorPos = this.caramelChat$cacheCursorPos;
Expand Down Expand Up @@ -175,7 +176,7 @@ private void onValueChange(final String text, final CallbackInfo ci) {
method = "deleteChars",
at = @At(
value = "INVOKE", shift = At.Shift.BEFORE,
target = "Lnet/minecraft/client/gui/components/EditBox;moveCursorTo(I)V"
target = "Lnet/minecraft/client/gui/components/EditBox;moveCursorTo(IZ)V"
)
)
private void deleteChars(final int pos, final CallbackInfo ci) {
Expand Down Expand Up @@ -209,41 +210,4 @@ private void setCanLoseFocus(final boolean canLoseFocus, final CallbackInfo ci)
this.caramelChat$wrapper.setOrigin(value);
}
}

// ================================ (Fix MC-140646)

@Shadow private boolean shiftPressed;
@Shadow public int cursorPos;
@Shadow public int highlightPos;
@Shadow public abstract void setHighlightPos(int i);

@Inject(
method = "moveCursorTo",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/components/EditBox;setCursorPosition(I)V"
)
)
private void moveCursorTo(final int cursor, final CallbackInfo ci) {
if (this.shiftPressed) {
final int previous = highlightPos;
this.setHighlightPos(cursor);
this.highlightPos = previous;
}

// Set Status to None
this.caramelChat$setStatusToNone();
}

@ModifyArg(
method = "renderWidget",
at = @At(
value = "INVOKE",
target = "Ljava/lang/String;substring(II)Ljava/lang/String;",
ordinal = 1
), index = 1
)
private int renderWidget(final int selectionEnd) {
return Math.max(0, selectionEnd);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

/**
* SelectWorldScreen Mixin (Fix Editbox Focus)
* SelectWorldScreen Mixin (Fix MC-265273)
* I don't have a good idea right now...
*/
@Mixin(SelectWorldScreen.class)
Expand Down
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"mixins": [ "caramelchat.mixins.json" ],
"depends": {
"fabricloader": ">=0.14.0",
"minecraft": ">=1.20.0 <=1.20.1"
"minecraft": ">=1.20.2"
},
"breaks": {
"lunar": "*",
Expand Down
4 changes: 2 additions & 2 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ Provides an enhanced IME input experience in Minecraft.
[[dependencies.caramelchat]]
modId = "forge"
mandatory = true
versionRange = "[47,)"
versionRange = "[48,)"
side = "CLIENT"

[[dependencies.caramelchat]]
modId="minecraft"
mandatory=true
versionRange = "[1.20,)"
versionRange = "[1.20.2,)"
side = "CLIENT"
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
org.gradle.jvmargs=-Xmx2G

archives_base_name=caramelChat
mod_version=1.0.0-beta.3
mod_version=1.1.0-beta.1
maven_group=moe.caramel

minecraft_version=1.20.1
minecraft_version=1.20.2
fabric_loader_version=0.14.22
forge_version=1.20.1-47.1.44
forge_version=1.20.2-48.0.0

0 comments on commit 30db6f5

Please sign in to comment.