Skip to content

Commit

Permalink
1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
RacoonDog committed Aug 7, 2023
1 parent 01fb32c commit 9be5fea
Show file tree
Hide file tree
Showing 20 changed files with 157 additions and 506 deletions.
29 changes: 10 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'fabric-loom' version '1.3-SNAPSHOT'
}

sourceCompatibility = targetCompatibility = JavaVersion.VERSION_17

archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group

base {
archivesName = project.archives_base_name
}

loom {
accessWidenerPath = file("src/main/resources/tokyo-client.accesswidener")
}
Expand All @@ -16,9 +19,10 @@ repositories {
maven {
name = "meteor-maven"
url = "https://maven.meteordev.org/releases"
//content {
// includeGroup "meteordevelopment"
//}
content {
includeGroup "meteordevelopment"
includeGroup "com.github.LlamaLad7.MixinExtras"
}
}
maven {
name = "meteor-maven-snapshots"
Expand All @@ -28,20 +32,7 @@ repositories {
includeGroup "baritone"
}
}
maven {
name = "msau-repsy"
url = "https://repo.repsy.io/mvn/ggcrosby/meteorsharedaddonutils"
content {
includeGroup "io.github.racoondog"
}
}
maven {
name = "launch-args-api-repsy"
url = "https://repo.repsy.io/mvn/ggcrosby/launchargsapi"
content {
includeGroup "io.github.racoondog"
}
}
mavenLocal()
}

dependencies {
Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
org.gradle.jvmargs=-Xmx2G

# Fabric Properties (https://fabricmc.net/versions.html)
minecraft_version=1.19.4
yarn_mappings=1.19.4+build.1
loader_version=0.14.19
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
loader_version=0.14.22

# Mod Properties
mod_version=1.0.3
mod_version=1.1.0
maven_group=io.github.racoondog
archives_base_name=tokyo

# Dependencies

# Meteor (https://maven.meteordev.org/)
meteor_version=0.5.3-SNAPSHOT
msau_version=1.3.1
fapi_version=0.77.0+1.19.4
meteor_version=0.5.4-SNAPSHOT
msau_version=1.3.3
fapi_version=0.86.1+1.20.1
launchargsapi_version=1.1.2

# JDA (https://mvnrepository.com/artifact/net.dv8tion/JDA)
Expand Down
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-8.0.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

This file was deleted.

109 changes: 0 additions & 109 deletions src/main/java/io/github/racoondog/tokyo/mixin/CraftingScreenMixin.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package io.github.racoondog.tokyo.mixin;

import io.github.racoondog.tokyo.systems.modules.ChatEmojis;
import io.github.racoondog.tokyo.utils.TextUtils;
import it.unimi.dsi.fastutil.Pair;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.OrderedText;
import net.minecraft.text.Style;
import org.spongepowered.asm.mixin.Final;
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.CallbackInfoReturnable;

import java.util.List;
import java.util.regex.Matcher;

@Environment(EnvType.CLIENT)
@Mixin(DrawContext.class)
public abstract class DrawContextMixin {
@Shadow @Final private MatrixStack matrices;

@Shadow public abstract int drawText(TextRenderer textRenderer, OrderedText text, int x, int y, int color, boolean shadow);

@Inject(method = "drawTextWithShadow(Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/OrderedText;III)I", at = @At("HEAD"), cancellable = true)
private void injectDrawWithShadow(TextRenderer renderer, OrderedText text, int x, int y, int color, CallbackInfoReturnable<Integer> cir) {
if (!ChatEmojis.shouldRender()) return;

List<Pair<String, Style>> dissected = TextUtils.dissect(text);

x = drawWithEmoji(renderer, dissected, matrices, x, y, color, true);
cir.setReturnValue(x + 1);
}

@Unique
private int drawWithEmoji(TextRenderer renderer, List<Pair<String, Style>> dissected, MatrixStack matrices, int x, int y, int color, boolean shadow) {
for (var textEntry : dissected) {
x = drawWithEmoji(renderer, textEntry.left(), textEntry.right(), matrices, x, y, color, shadow);
}

return x;
}

@Unique
private int drawWithEmoji(TextRenderer renderer, String content, Style style, MatrixStack matrices, int x, int y, int color, boolean shadow) {
Matcher matcher = ChatEmojis.EMOJI_REGEX.matcher(content);

if (matcher.find()) {
do {
ChatEmojis.Emoji emoji = ChatEmojis.get(matcher.group());

if (emoji == null) {
if (matcher.end() == content.length())
return drawShadowFix(renderer, TextUtils.toOrderedText(content, style), x, y, color, shadow);
else {
x = drawShadowFix(renderer, TextUtils.toOrderedText(content.substring(0, matcher.end()), style), x, y, color, shadow);
content = content.substring(matcher.end());
matcher.reset(content);
continue;
}
}

if (matcher.start() > 0) {
x = drawShadowFix(renderer, TextUtils.toOrderedText(content.substring(0, matcher.start()), style), x, y, color, shadow);
}

emoji.render((DrawContext) (Object) this, x, y, renderer.fontHeight);
x += renderer.fontHeight;

content = content.substring(matcher.end());
matcher.reset(content);
} while (matcher.find());
if (content.isEmpty()) return x;
}
return drawShadowFix(renderer, TextUtils.toOrderedText(content, style), x, y, color, shadow);
}

@Unique
private int drawShadowFix(TextRenderer renderer, OrderedText text, int x, int y, int color, boolean shadow) {
x = drawText(renderer, text, x, y, color, shadow);
return x - (shadow ? 1 : 0);
}
}
Loading

0 comments on commit 9be5fea

Please sign in to comment.