Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
plugins {
id 'fabric-loom' version "${loom_version}"
id 'net.fabricmc.fabric-loom' version "${loom_version}"
id 'maven-publish'
id 'io.freefair.lombok' version '8.10'
id 'io.freefair.lombok' version '9.5.0'
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
languageVersion = JavaLanguageVersion.of(25)
}
}
base {
archivesName = project.archives_base_name
}

lombok {
version = project.lombok_version
}

version = "${project.minecraft_version}-${project.mod_version}"
group = project.maven_group

repositories {
mavenLocal()
mavenCentral()
maven { url 'https://api.modrinth.com/maven' }
mavenLocal() // only used to build the mod locally
maven { url 'https://masa.dy.fi/maven' }
maven { url 'https://jitpack.io' }
Expand All @@ -36,11 +42,10 @@ repositories {

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
modImplementation files("../malilib-fabric-1.21.11-0.27.8.jar")
modImplementation files("../AdvancedChatCore-1.21.11-1.5.17-alpha.1.jar")
implementation "net.fabricmc:fabric-loader:${project.loader_version}"
implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
implementation "maven.modrinth:malilib:${project.malilib_version}"
implementation "com.arematics:advancedchatcore:${project.advancedchat_version}"

implementation "org.mariuszgromada.math:MathParser.org-mXparser:${project.mxparser_version}"
include "org.mariuszgromada.math:MathParser.org-mXparser:${project.mxparser_version}"
Expand Down Expand Up @@ -80,7 +85,8 @@ processResources {

tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
it.options.release = 21
it.options.release = 25
it.options.compilerArgs << "-Xmaxerrs" << "10000"
}

java {
Expand All @@ -94,11 +100,11 @@ jar {
publishing {
publications {
mavenJava(MavenPublication) {
artifact(remapJar) {
builtBy remapJar
artifact(jar) {
builtBy jar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
builtBy sourcesJar
}
}
}
Expand Down
19 changes: 11 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
org.gradle.jvmargs=-Xmx3g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# https://fabricmc.net/develop
minecraft_version=1.21.11
yarn_mappings=1.21.11+build.4
loader_version=0.17.3
loom_version=1.15.5
fabric_api_version=0.136.0+1.21.11
minecraft_version=26.2
loader_version=0.19.3
loom_version=1.17.+
fabric_api_version=0.156.0+26.2

mod_version=1.6.1
mod_version=1.7.2-alpha.1
maven_group=com.arematics
archives_base_name=AdvancedChatBox

advancedchat_version=1.21.11-1.6.1
advancedchat_version=26.2-1.7.2-alpha.1
# https://jitpack.io/#sakura-ryoko/malilib
malilib_version=0.27.8
malilib_version=0.29.3
# https://repo.maven.apache.org/maven2/org/mariuszgromada/math/MathParser.org-mXparser
mxparser_version=4.4.2

Expand All @@ -29,3 +28,7 @@ project_color=0x4480ad
changelog_hide_unimportant_commits=true
changelog_max_commit_search=200
discord_webhook_changelog_line_limit=10

# 1.18.42+ is required for JDK 25
lombok_version=1.18.46
modmenu_version=20.0.1
3 changes: 3 additions & 0 deletions gradle/gradle-daemon-jvm.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#This file is generated by updateDaemonJvm
#Minecraft 26.2 requires the Gradle daemon itself to run on Java 25.
toolchainVersion=25
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 6 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ pluginManagement {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
gradlePluginPortal()
mavenCentral()
}
}

// Lets Gradle download a JDK 25 toolchain automatically, so no system JDK 25 is required.
plugins {
id 'org.gradle.toolchains.foojay-resolver-convention' version '1.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@
import lombok.Getter;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import net.minecraft.network.chat.Style;
import net.minecraft.network.chat.Component;

/** Suggestion that contains render text, suggested text, suggested start/stop, and tooltip. */
@Environment(EnvType.CLIENT)
public class AdvancedSuggestion extends Suggestion {
@Nonnull
@Getter
private final Text render;
private final Component render;

/**
* @param range Range from the original string where it is recommending
* @param text Suggested text to use
* @param render How the suggestion will render
* @param tooltip Message to show up on hover
*/
public AdvancedSuggestion(StringRange range, String text, Text render, Message tooltip) {
public AdvancedSuggestion(StringRange range, String text, Component render, Message tooltip) {
super(range, text, tooltip);
if (render == null) {
this.render = new RawText(text, Style.EMPTY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import io.github.darkkronicle.advancedchatcore.interfaces.AdvancedChatScreenSection;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Click;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.input.KeyInput;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.input.MouseButtonEvent;
import net.minecraft.client.gui.GuiGraphicsExtractor;
import net.minecraft.client.input.KeyEvent;
import com.mojang.blaze3d.vertex.PoseStack;

@Environment(EnvType.CLIENT)
public class ChatBoxSection extends AdvancedChatScreenSection {
Expand All @@ -33,12 +33,12 @@ public void onChatFieldUpdate(String chatText, String text) {
}

@Override
public boolean keyPressed(KeyInput input) {
public boolean keyPressed(KeyEvent input) {
return this.suggestor.keyPressed(input);
}

@Override
public void render(DrawContext context, int mouseX, int mouseY, float partialTicks) {
public void extractRenderState(GuiGraphicsExtractor context, int mouseX, int mouseY, float partialTicks) {
this.suggestor.render(context, mouseX, mouseY);
}

Expand All @@ -53,7 +53,7 @@ public boolean mouseScrolled(double mouseX, double mouseY, double amount) {
}

@Override
public boolean mouseClicked(Click click, boolean doubled) {
public boolean mouseClicked(MouseButtonEvent click, boolean doubled) {
return this.suggestor.mouseClicked(click, doubled);
}

Expand All @@ -64,9 +64,9 @@ public void resize(int width, int height) {

@Override
public void initGui() {
MinecraftClient client = MinecraftClient.getInstance();
Minecraft client = Minecraft.getInstance();
AdvancedChatScreen screen = getScreen();
this.suggestor = new ChatSuggestorGui(client, screen, screen.getChatField(), client.textRenderer, false, false,
this.suggestor = new ChatSuggestorGui(client, screen, screen.getChatField(), client.font, false, false,
1, ChatBoxConfigStorage.General.SUGGESTION_SIZE.config.getIntegerValue(), true);
this.suggestor.refresh();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
import io.github.darkkronicle.advancedchatcore.util.TextUtil;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.text.*;
import net.minecraft.util.Formatting;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.network.chat.*;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.ChatFormatting;

/**
* A class to format the chat box on the
Expand All @@ -32,12 +33,12 @@ public class ChatFormatter {
private String current = null;

/** The formatted current */
private Text last = null;
private Component last = null;

private final TextFieldWidget widget;
private final EditBox widget;
private final ChatSuggestor suggestor;

public ChatFormatter(TextFieldWidget widget, ChatSuggestor suggestor) {
public ChatFormatter(EditBox widget, ChatSuggestor suggestor) {
this.widget = widget;
this.suggestor = suggestor;
}
Expand All @@ -48,8 +49,8 @@ public ChatFormatter(TextFieldWidget widget, ChatSuggestor suggestor) {
* @param string Contents
* @return Formatted FluidText. If nothing is changed it will be the contents with Style.EMPTY
*/
public Text format(String string) {
Text text = Text.literal(string);
public Component format(String string) {
Component text = Component.literal(string);
if (string.length() == 0) {
return text;
}
Expand Down Expand Up @@ -82,11 +83,11 @@ public Text format(String string) {
String matchString = string.subSequence(start, end).toString();
format.put(new StringMatch(matchString, start, end), (current, match) -> {
Style style = Style.EMPTY;
style = style.withFormatting(Formatting.UNDERLINE);
style = style.applyFormat(ChatFormatting.UNDERLINE);
TextColor textColor = TextColor
.fromRgb(ChatBoxConfigStorage.General.AVAILABLE_SUGGESTION_COLOR.config.getIntegerValue());
style = style.withColor(textColor);
return Text.literal(matchString).fillStyle(style);
return Component.literal(matchString).withStyle(style);
});
}
text = TextUtil.replaceStrings(text, format);
Expand All @@ -95,33 +96,33 @@ public Text format(String string) {
if (!option.isActive()) {
continue;
}
Optional<Text> otext = option.getOption().format(text, suggestor.getParse());
Optional<Component> otext = option.getOption().format(text, suggestor.getParse());
if (otext.isPresent()) {
text = otext.get();
}
}
return text;
}

private OrderedText set(String s, Integer integer) {
private FormattedCharSequence set(String s, Integer integer) {
int length = s.length();
if (length == 0) {
return OrderedText.EMPTY;
return FormattedCharSequence.EMPTY;
}
if (last.getString().length() == 0) {
return OrderedText.EMPTY;
return FormattedCharSequence.EMPTY;
}
int start = integer;
int end = integer + length;
int fluidLength = last.getString().length();
if (end > fluidLength) {
end = fluidLength;
}
return TextUtil.truncate(last, new StringMatch(s, start, end)).asOrderedText();
return TextUtil.truncate(last, new StringMatch(s, start, end)).getVisualOrderText();
}

public OrderedText apply(String s, Integer integer) {
String text = widget.getText();
public FormattedCharSequence apply(String s, Integer integer) {
String text = widget.getValue();
if (text.equals(current)) {
// If the content hasn't changed, use the previous one.
return set(s, integer);
Expand Down
Loading