diff --git a/build.gradle b/build.gradle index 8459609..4d5575f 100644 --- a/build.gradle +++ b/build.gradle @@ -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") } @@ -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" @@ -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 { diff --git a/gradle.properties b/gradle.properties index 4ed7e2b..ba0e3c7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f72df95..fae0804 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/src/main/java/io/github/racoondog/tokyo/gui/overlays/CraftingScreenOverlay.java b/src/main/java/io/github/racoondog/tokyo/gui/overlays/CraftingScreenOverlay.java deleted file mode 100644 index e41e6d5..0000000 --- a/src/main/java/io/github/racoondog/tokyo/gui/overlays/CraftingScreenOverlay.java +++ /dev/null @@ -1,66 +0,0 @@ -package io.github.racoondog.tokyo.gui.overlays; - -import io.github.racoondog.meteorsharedaddonutils.features.ScreenContainer; -import it.unimi.dsi.fastutil.objects.Object2IntMap; -import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap; -import meteordevelopment.meteorclient.gui.GuiThemes; -import meteordevelopment.meteorclient.gui.widgets.containers.WTable; -import meteordevelopment.meteorclient.gui.widgets.containers.WWindow; -import meteordevelopment.meteorclient.utils.player.SlotUtils; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.resource.language.I18n; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.item.Items; - -import static meteordevelopment.meteorclient.MeteorClient.mc; - -@Environment(EnvType.CLIENT) -public class CraftingScreenOverlay extends ScreenContainer { - private WTable itemCountTable; - - public CraftingScreenOverlay() { - super(GuiThemes.get()); - } - - @Override - public void initWidgets() { - WWindow window = this.add(theme.window(null, "Crafting Overlay")).widget(); - window.view.scrollOnlyWhenMouseOver = false; - - window.add(theme.label("Inventory Item Counts:")).expandX(); - window.add(theme.horizontalSeparator()).expandX(); - - itemCountTable = window.add(theme.table()).expandX().widget(); - } - - public void onTick() { - itemCountTable.clear(); - - Object2IntMap inventoryItems = new Object2IntOpenHashMap<>(); - - handleStack(inventoryItems, mc.player.getInventory().offHand.get(0)); - for (int i = SlotUtils.HOTBAR_START; i < SlotUtils.MAIN_END; i++) { - ItemStack stack = mc.player.getInventory().getStack(i); - handleStack(inventoryItems, stack); - } - - if (inventoryItems.isEmpty()) itemCountTable.add(theme.label("Empty")); - else { - for (var entry : inventoryItems.object2IntEntrySet()) { - itemCountTable.add(theme.label(I18n.translate(entry.getKey().getTranslationKey()))); - itemCountTable.add(theme.label(": ")); - itemCountTable.add(theme.label(String.valueOf(entry.getIntValue()))); - itemCountTable.row(); - } - } - } - - private static void handleStack(Object2IntMap map, ItemStack stack) { - Item item = stack.getItem(); - if (item == Items.AIR) return; - if (map.containsKey(item)) map.put(item, map.getInt(item) + stack.getCount()); - else map.put(item, stack.getCount()); - } -} diff --git a/src/main/java/io/github/racoondog/tokyo/mixin/CraftingScreenMixin.java b/src/main/java/io/github/racoondog/tokyo/mixin/CraftingScreenMixin.java deleted file mode 100644 index 6bfb4d2..0000000 --- a/src/main/java/io/github/racoondog/tokyo/mixin/CraftingScreenMixin.java +++ /dev/null @@ -1,109 +0,0 @@ -package io.github.racoondog.tokyo.mixin; - -import io.github.racoondog.tokyo.gui.overlays.CraftingScreenOverlay; -import io.github.racoondog.tokyo.systems.config.TokyoConfig; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.screen.ingame.CraftingScreen; -import net.minecraft.client.gui.screen.ingame.HandledScreen; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.entity.player.PlayerInventory; -import net.minecraft.screen.CraftingScreenHandler; -import net.minecraft.text.Text; -import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Mixin; -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 org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Environment(EnvType.CLIENT) -@Mixin(CraftingScreen.class) -public abstract class CraftingScreenMixin extends HandledScreen { - @Nullable - @Unique - private CraftingScreenOverlay container; - - private CraftingScreenMixin(CraftingScreenHandler handler, PlayerInventory inventory, Text title) { - super(handler, inventory, title); - } - - @Inject(method = "", at = @At("TAIL")) - private void injectConstructor(CraftingScreenHandler handler, PlayerInventory inventory, Text title, CallbackInfo ci) { - if (TokyoConfig.INSTANCE.screenOverlays.get()) container = new CraftingScreenOverlay(); - } - - @Inject(method = "handledScreenTick", at = @At("TAIL")) - private void injectTick(CallbackInfo ci) { - if (container != null) container.onTick(); - } - - @Inject(method = "init()V", at = @At("TAIL")) - private void injectInit(CallbackInfo ci) { - if (container != null) container.init(); - } - - @Inject(method = "mouseClicked", at = @At("HEAD"), cancellable = true) - private void injectMouseClicked(double mouseX, double mouseY, int button, CallbackInfoReturnable cir) { - if (container != null && container.mouseClicked(mouseX, mouseY, button)) { - cir.setReturnValue(true); - cir.cancel(); - } - } - - @Override - public boolean mouseReleased(double mouseX, double mouseY, int button) { - if (container != null && container.mouseReleased(mouseX, mouseY, button)) return true; - return super.mouseReleased(mouseX, mouseY, button); - } - - @Override - public void mouseMoved(double mouseX, double mouseY) { - if (container != null) container.mouseMoved(mouseX, mouseY); - super.mouseMoved(mouseX, mouseY); - } - - @Override - public boolean mouseScrolled(double mouseX, double mouseY, double amount) { - if (container != null && container.mouseScrolled(mouseX, mouseY, amount)) return true; - return super.mouseScrolled(mouseX, mouseY, amount); - } - - @Override - public boolean keyReleased(int keyCode, int scanCode, int modifiers) { - if (container != null && container.keyReleased(keyCode, scanCode, modifiers)) return true; - return super.keyReleased(keyCode, scanCode, modifiers); - } - - - @Override - public boolean keyPressed(int keyCode, int scanCode, int modifiers) { - if (container != null && container.keyPressed(keyCode, scanCode, modifiers)) return true; - return super.keyPressed(keyCode, scanCode, modifiers); - } - - @Override - public boolean charTyped(char chr, int modifiers) { - if (container != null && container.charTyped(chr, modifiers)) return true; - return super.charTyped(chr, modifiers); - } - - @Inject(method = "render", at = @At("TAIL")) - private void injectRender(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) { - if (container != null) container.render(matrices, mouseX, mouseY, delta); - } - - @Override - public void resize(MinecraftClient client, int width, int height) { - if (container != null) container.resize(client, width, height); - super.resize(client, width, height); - } - - @Override - public void removed() { - if (container != null) container.removed(); - super.removed(); - } -} diff --git a/src/main/java/io/github/racoondog/tokyo/mixin/DrawContextMixin.java b/src/main/java/io/github/racoondog/tokyo/mixin/DrawContextMixin.java new file mode 100644 index 0000000..f230903 --- /dev/null +++ b/src/main/java/io/github/racoondog/tokyo/mixin/DrawContextMixin.java @@ -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 cir) { + if (!ChatEmojis.shouldRender()) return; + + List> dissected = TextUtils.dissect(text); + + x = drawWithEmoji(renderer, dissected, matrices, x, y, color, true); + cir.setReturnValue(x + 1); + } + + @Unique + private int drawWithEmoji(TextRenderer renderer, List> 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); + } +} diff --git a/src/main/java/io/github/racoondog/tokyo/mixin/TextRendererMixin.java b/src/main/java/io/github/racoondog/tokyo/mixin/TextRendererMixin.java deleted file mode 100644 index 904e31f..0000000 --- a/src/main/java/io/github/racoondog/tokyo/mixin/TextRendererMixin.java +++ /dev/null @@ -1,91 +0,0 @@ -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.util.math.MatrixStack; -import net.minecraft.text.OrderedText; -import net.minecraft.text.Style; -import org.joml.Matrix4f; -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(TextRenderer.class) -public abstract class TextRendererMixin { - @Shadow protected abstract int draw(OrderedText text, float x, float y, int color, Matrix4f matrix4f, boolean shadow); - - @Shadow @Final public int fontHeight; - - @Inject(method = "drawWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/text/OrderedText;FFI)I", at = @At("HEAD"), cancellable = true) - private void injectDrawWithShadow(MatrixStack matrices, OrderedText text, float x, float y, int color, CallbackInfoReturnable cir) { - if (!ChatEmojis.shouldRender()) return; - - List> dissected = TextUtils.dissect(text); - - x = drawWithEmoji(dissected, matrices, x, y, color, true); - cir.setReturnValue((int) x + 1); - } - - @Unique - private float drawWithEmoji(List> dissected, MatrixStack matrices, float x, float y, int color, boolean shadow) { - for (var textEntry : dissected) { - x = drawWithEmoji(textEntry.left(), textEntry.right(), matrices, x, y, color, shadow); - } - - return x; - } - - @Unique - private float drawWithEmoji(String content, Style style, MatrixStack matrices, float x, float y, int color, boolean shadow) { - Matrix4f positionMatrix = matrices.peek().getPositionMatrix(); - - 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(TextUtils.toOrderedText(content, style), x, y, color, positionMatrix, shadow); - else { - x = drawShadowFix(TextUtils.toOrderedText(content.substring(0, matcher.end()), style), x, y, color, positionMatrix, shadow); - content = content.substring(matcher.end()); - matcher.reset(content); - continue; - } - } - - if (matcher.start() > 0) { - x = drawShadowFix(TextUtils.toOrderedText(content.substring(0, matcher.start()), style), x, y, color, positionMatrix, shadow); - } - - emoji.render(matrices, (int) x, (int) y, fontHeight); - x += fontHeight; - - content = content.substring(matcher.end()); - matcher.reset(content); - } while (matcher.find()); - if (content.isEmpty()) return x; - } - return drawShadowFix(TextUtils.toOrderedText(content, style), x, y, color, positionMatrix, shadow); - } - - @Unique - private int drawShadowFix(OrderedText text, float x, float y, int color, Matrix4f matrix4f, boolean shadow) { - x = draw(text, x, y, color, matrix4f, shadow); - return (int) x - (shadow ? 1 : 0); - } -} diff --git a/src/main/java/io/github/racoondog/tokyo/mixin/meteor/ConfigMixin.java b/src/main/java/io/github/racoondog/tokyo/mixin/meteor/ConfigMixin.java deleted file mode 100644 index 40b231c..0000000 --- a/src/main/java/io/github/racoondog/tokyo/mixin/meteor/ConfigMixin.java +++ /dev/null @@ -1,67 +0,0 @@ -package io.github.racoondog.tokyo.mixin.meteor; - -import io.github.racoondog.tokyo.mixininterface.IConfig; -import io.github.racoondog.tokyo.utils.settings.MinecraftFont; -import meteordevelopment.meteorclient.gui.WidgetScreen; -import meteordevelopment.meteorclient.settings.BoolSetting; -import meteordevelopment.meteorclient.settings.GenericSetting; -import meteordevelopment.meteorclient.settings.Setting; -import meteordevelopment.meteorclient.settings.SettingGroup; -import meteordevelopment.meteorclient.systems.config.Config; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -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.CallbackInfo; - -import static meteordevelopment.meteorclient.MeteorClient.mc; - -@Environment(EnvType.CLIENT) -@Mixin(value = Config.class, remap = false) -public abstract class ConfigMixin implements IConfig { - @Shadow @Final private SettingGroup sgVisual; - @Shadow @Final public Setting customFont; - - @Unique private Setting shadows; - @Unique private Setting minecraftFont; - - @Inject(method = "", at = @At(value = "INVOKE", target = "Lmeteordevelopment/meteorclient/settings/SettingGroup;add(Lmeteordevelopment/meteorclient/settings/Setting;)Lmeteordevelopment/meteorclient/settings/Setting;", ordinal = 1)) - private void inject(CallbackInfo ci) { - shadows = sgVisual.add(new BoolSetting.Builder() - .name("shadows") - .visible(() -> !customFont.get()) - .defaultValue(true) - .onChanged(o -> invalidate()) - .build() - ); - - minecraftFont = sgVisual.add(new GenericSetting.Builder() - .name("font") - .visible(() -> !customFont.get()) - .defaultValue(new MinecraftFont()) - .onChanged(o -> invalidate()) - .build() - ); - } - - @Unique - private void invalidate() { - if (mc.currentScreen instanceof WidgetScreen w) { - w.invalidate(); - } - } - - @Override - public boolean tokyo$getShadows() { - return shadows.get(); - } - - @Override - public MinecraftFont tokyo$getMinecraftFont() { - return minecraftFont.get(); - } -} diff --git a/src/main/java/io/github/racoondog/tokyo/mixin/meteor/GuiRendererMixin.java b/src/main/java/io/github/racoondog/tokyo/mixin/meteor/GuiRendererMixin.java deleted file mode 100644 index 7108577..0000000 --- a/src/main/java/io/github/racoondog/tokyo/mixin/meteor/GuiRendererMixin.java +++ /dev/null @@ -1,19 +0,0 @@ -package io.github.racoondog.tokyo.mixin.meteor; - -import meteordevelopment.meteorclient.gui.renderer.GuiRenderer; -import meteordevelopment.meteorclient.systems.config.Config; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyArg; - -@Environment(EnvType.CLIENT) -@Mixin(value = GuiRenderer.class, remap = false) -public abstract class GuiRendererMixin { - @ModifyArg(method = "endRender", at = @At(value = "INVOKE", target = "Lmeteordevelopment/meteorclient/gui/GuiTheme;scale(D)D", ordinal = 1)) - private double resetScale(double value) { - if (!Config.get().customFont.get()) return 1; - return value; - } -} diff --git a/src/main/java/io/github/racoondog/tokyo/mixin/meteor/TextOperationMixin.java b/src/main/java/io/github/racoondog/tokyo/mixin/meteor/TextOperationMixin.java deleted file mode 100644 index 49a1171..0000000 --- a/src/main/java/io/github/racoondog/tokyo/mixin/meteor/TextOperationMixin.java +++ /dev/null @@ -1,41 +0,0 @@ -package io.github.racoondog.tokyo.mixin.meteor; - -import io.github.racoondog.tokyo.mixininterface.IConfig; -import meteordevelopment.meteorclient.gui.renderer.GuiRenderOperation; -import meteordevelopment.meteorclient.gui.renderer.operations.TextOperation; -import meteordevelopment.meteorclient.systems.config.Config; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.util.math.MatrixStack; -import net.minecraft.text.Style; -import net.minecraft.text.Text; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import static meteordevelopment.meteorclient.MeteorClient.mc; - -@Environment(EnvType.CLIENT) -@Mixin(value = TextOperation.class, remap = false) -public abstract class TextOperationMixin extends GuiRenderOperation { - @Shadow public boolean title; - @Shadow private String text; - - @Inject(method = "onRun", at = @At("HEAD"), cancellable = true) - private void injectHead(CallbackInfo ci) { - if (!Config.get().customFont.get()) { - MatrixStack stack = new MatrixStack(); - stack.scale(2, 2, 1); - - Style style = Style.EMPTY.withFont(IConfig.getMinecraftFont().get()); - if (title) style = style.withBold(true); - - if (IConfig.getShadows()) mc.textRenderer.drawWithShadow(stack, Text.literal(text).setStyle(style), (float) (x + 1) / 2, title ? (float) (y + 4) / 2 : (float) (y + 2) / 2, color.getPacked()); - else mc.textRenderer.draw(stack, Text.literal(text).setStyle(style), (float) (x + 1) / 2, title ? (float) (y + 4) / 2 : (float) (y + 2) / 2, color.getPacked()); - - ci.cancel(); - } - } -} diff --git a/src/main/java/io/github/racoondog/tokyo/mixin/meteor/VanillaTextRendererMixin.java b/src/main/java/io/github/racoondog/tokyo/mixin/meteor/VanillaTextRendererMixin.java deleted file mode 100644 index e972e1a..0000000 --- a/src/main/java/io/github/racoondog/tokyo/mixin/meteor/VanillaTextRendererMixin.java +++ /dev/null @@ -1,37 +0,0 @@ -package io.github.racoondog.tokyo.mixin.meteor; - -import io.github.racoondog.tokyo.mixininterface.IConfig; -import meteordevelopment.meteorclient.renderer.text.VanillaTextRenderer; -import meteordevelopment.meteorclient.systems.config.Config; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; -import net.minecraft.client.font.TextRenderer; -import net.minecraft.client.render.VertexConsumerProvider; -import org.joml.Matrix4f; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Environment(EnvType.CLIENT) -@Mixin(VanillaTextRenderer.class) -public abstract class VanillaTextRendererMixin { - @Shadow(remap = false) public double scale; - - @Inject(method = "getWidth", at = @At("RETURN"), cancellable = true, remap = false) - private void shadowsWidth(String text, int length, boolean shadow, CallbackInfoReturnable cir) { - if (!shadow && IConfig.getShadows() && !Config.get().customFont.get()) cir.setReturnValue(cir.getReturnValue() + 1); - } - - @Inject(method = "getHeight", at = @At("RETURN"), cancellable = true, remap = false) - private void shadowsHeight(boolean shadow, CallbackInfoReturnable cir) { - if (!shadow && IConfig.getShadows() && !Config.get().customFont.get()) cir.setReturnValue(cir.getReturnValue() + 1 * scale); - } - - @Redirect(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Ljava/lang/String;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;II)I")) - private int useShadows(TextRenderer instance, String text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, TextRenderer.TextLayerType layerType, int backgroundColor, int light) { - return instance.draw(text, x, y, color, IConfig.getShadows(), matrix, vertexConsumers, layerType, backgroundColor, light); - } -} diff --git a/src/main/java/io/github/racoondog/tokyo/mixininterface/IConfig.java b/src/main/java/io/github/racoondog/tokyo/mixininterface/IConfig.java deleted file mode 100644 index 27a248b..0000000 --- a/src/main/java/io/github/racoondog/tokyo/mixininterface/IConfig.java +++ /dev/null @@ -1,20 +0,0 @@ -package io.github.racoondog.tokyo.mixininterface; - -import io.github.racoondog.tokyo.utils.settings.MinecraftFont; -import meteordevelopment.meteorclient.systems.config.Config; -import net.fabricmc.api.EnvType; -import net.fabricmc.api.Environment; - -@Environment(EnvType.CLIENT) -public interface IConfig { - boolean tokyo$getShadows(); - MinecraftFont tokyo$getMinecraftFont(); - - static boolean getShadows() { - return ((IConfig) Config.get()).tokyo$getShadows(); - } - - static MinecraftFont getMinecraftFont() { - return ((IConfig) Config.get()).tokyo$getMinecraftFont(); - } -} diff --git a/src/main/java/io/github/racoondog/tokyo/systems/TokyoSystems.java b/src/main/java/io/github/racoondog/tokyo/systems/TokyoSystems.java index a7ef9c1..657240f 100644 --- a/src/main/java/io/github/racoondog/tokyo/systems/TokyoSystems.java +++ b/src/main/java/io/github/racoondog/tokyo/systems/TokyoSystems.java @@ -30,10 +30,10 @@ public static void initialize() { MODULES.add(AutoUnfriend.INSTANCE); MODULES.add(DiscordSRV.INSTANCE); MODULES.add(TokyoBetterChat.INSTANCE); - MODULES.add(ChatEmojis.INSTANCE); - MODULES.add(Sprint.INSTANCE); - MODULES.add(NewChunks.INSTANCE); - MODULES.add(StrafeSpeed.INSTANCE); + //MODULES.add(ChatEmojis.INSTANCE); + //MODULES.add(Sprint.INSTANCE); + //MODULES.add(NewChunks.INSTANCE); + //MODULES.add(StrafeSpeed.INSTANCE); HUD.register(ImageHud.INFO); diff --git a/src/main/java/io/github/racoondog/tokyo/systems/commands/QuickLaunchCommand.java b/src/main/java/io/github/racoondog/tokyo/systems/commands/QuickLaunchCommand.java index b0933e1..cf4dc0f 100644 --- a/src/main/java/io/github/racoondog/tokyo/systems/commands/QuickLaunchCommand.java +++ b/src/main/java/io/github/racoondog/tokyo/systems/commands/QuickLaunchCommand.java @@ -1,5 +1,6 @@ package io.github.racoondog.tokyo.systems.commands; +import com.google.common.collect.Lists; import com.mojang.brigadier.builder.LiteralArgumentBuilder; import com.mojang.brigadier.context.CommandContext; import com.mojang.brigadier.tree.LiteralCommandNode; @@ -20,6 +21,7 @@ import net.minecraft.client.network.ClientCommandSource; import net.minecraft.client.network.ServerInfo; import net.minecraft.command.CommandSource; +import org.apache.commons.collections.ListUtils; import org.jetbrains.annotations.Nullable; import java.util.Locale; @@ -39,7 +41,7 @@ private QuickLaunchCommand() { public void build(LiteralArgumentBuilder builder) { LiteralCommandNode root = Commands.DISPATCHER.register(builder); - builder.executes(this::execute); + builder.then(literal("run").executes(this::execute)); builder.then(literal("-join") .redirect(root, ctx -> modifySource(ctx, "join", true))); @@ -104,11 +106,8 @@ private void configureJoin(InstanceBuilder builder) { warning("Could not obtain server information."); return; } - - String[] address = serverInfo.address.split(":"); - - builder.modifyArg("--server", address[0]) - .modifyArg("--port", address.length > 1 ? address[1] : "25565"); + + builder.modifyArg("--quickPlayMultiplayer", serverInfo.address); } } diff --git a/src/main/java/io/github/racoondog/tokyo/systems/modules/AutoTpa.java b/src/main/java/io/github/racoondog/tokyo/systems/modules/AutoTpa.java index 11c841e..9f12598 100644 --- a/src/main/java/io/github/racoondog/tokyo/systems/modules/AutoTpa.java +++ b/src/main/java/io/github/racoondog/tokyo/systems/modules/AutoTpa.java @@ -61,6 +61,7 @@ public class AutoTpa extends Module { .description("Regex used to detect a TPA request, with \"username\" as the named capture group to find the username.") .defaultValue("(^|\\s)(?[a-zA-Z0-9_.]*?) has requested to teleport to you\\.") .onChanged(o -> recompileRegex()) + .wide() .build() ); diff --git a/src/main/java/io/github/racoondog/tokyo/systems/modules/ChatEmojis.java b/src/main/java/io/github/racoondog/tokyo/systems/modules/ChatEmojis.java index 413ffb0..49dd6bf 100644 --- a/src/main/java/io/github/racoondog/tokyo/systems/modules/ChatEmojis.java +++ b/src/main/java/io/github/racoondog/tokyo/systems/modules/ChatEmojis.java @@ -16,9 +16,8 @@ import net.fabricmc.fabric.api.resource.ResourceManagerHelper; import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; import net.minecraft.client.MinecraftClient; -import net.minecraft.client.gui.DrawableHelper; +import net.minecraft.client.gui.DrawContext; import net.minecraft.client.texture.*; -import net.minecraft.client.util.math.MatrixStack; import net.minecraft.resource.Resource; import net.minecraft.resource.ResourceManager; import net.minecraft.resource.ResourceType; @@ -144,7 +143,7 @@ public Emoji(AbstractTexture texture, int texWidth, int texHeight) { this(texture, texWidth, texHeight, 0, 0, texWidth, texHeight); } - public void render(MatrixStack matrices, int x, int y, int fontHeight) { + public void render(DrawContext context, int x, int y, int fontHeight) { if (texture instanceof NativeImageBackedTexture nativeImageBackedTexture) nativeImageBackedTexture.upload(); else texture.bindTexture(); @@ -155,7 +154,8 @@ public void render(MatrixStack matrices, int x, int y, int fontHeight) { int width = texWidth / ratio; int height = texHeight / ratio; - DrawableHelper.drawTexture(matrices, x, y, width, height, u, v, regWidth, regHeight, texWidth, texHeight); + //todo fix + context.drawTexture(new Identifier("asd"), x, y, width, height, u, v, regWidth, regHeight, texWidth, texHeight); } public static Emoji fromAtlas(Identifier atlasId, int width, int height, int u, int v) { @@ -276,7 +276,7 @@ public static AnimatedEmoji fromResource(Identifier textureId, Resource texture, } @Override - public void render(MatrixStack matrices, int x, int y, int fontHeight) { + public void render(DrawContext context, int x, int y, int fontHeight) { if (texture instanceof NativeImageBackedTexture nativeImageBackedTexture) nativeImageBackedTexture.upload(); else texture.bindTexture(); @@ -291,7 +291,7 @@ public void render(MatrixStack matrices, int x, int y, int fontHeight) { int u = frameIndex / regionsHeight * regWidth; int v = frameIndex % regionsHeight * regHeight; - DrawableHelper.drawTexture(matrices, x, y, width, height, u, v, regWidth, regHeight, texWidth, texHeight); + context.drawTexture(new Identifier("asd"), x, y, width, height, u, v, regWidth, regHeight, texWidth, texHeight); } public void tick() { diff --git a/src/main/java/io/github/racoondog/tokyo/systems/modules/UwUChat.java b/src/main/java/io/github/racoondog/tokyo/systems/modules/UwUChat.java index c4b7d43..0d3b997 100644 --- a/src/main/java/io/github/racoondog/tokyo/systems/modules/UwUChat.java +++ b/src/main/java/io/github/racoondog/tokyo/systems/modules/UwUChat.java @@ -40,8 +40,16 @@ public class UwUChat extends Module { .build() ); - private final Setting skipPercentage = sgGeneral.add(new DoubleSetting.Builder() - .name("skip-percentage") + private final Setting> emoticons = sgGeneral.add(new StringListSetting.Builder() + .name("emoticons") + .description("Ecomitons") + .defaultValue(" :3", " >:3", " :>", " :D") + .visible(() -> emoticonChance.get() > 0.0d) + .build() + ); + + private final Setting integrity = sgGeneral.add(new DoubleSetting.Builder() + .name("integrity") .description("Skip a word if a certain percentage of it would be modified.") .defaultValue(0.6d) .range(0.0d, 1.0d) @@ -66,7 +74,7 @@ public void onMessageSend(SendMessageEvent event) { String originalMessage = event.message; StringBuilder sb = new StringBuilder(); - if (skipPercentage.get() >= 1.0d || replacementChance.get() <= 0.0d) sb.append(originalMessage); + if (integrity.get() >= 1.0d || replacementChance.get() <= 0.0d) sb.append(originalMessage); else { String[] tokens = originalMessage.split(" "); @@ -80,7 +88,7 @@ public void onMessageSend(SendMessageEvent event) { continue; } - if ((float) StringUtils.countChars(token, 'r', 'l') / token.length() <= skipPercentage.get()) { + if ((float) StringUtils.countChars(token, 'r', 'l') / token.length() <= integrity.get()) { StringBuilder tsb = new StringBuilder(token); StringUtils.randomChanceKeepCaseReplace(tsb, "ove", "uv", replacementChance.get()); StringUtils.randomChanceKeepCaseReplace(tsb, "the", "da", replacementChance.get()); @@ -94,7 +102,7 @@ public void onMessageSend(SendMessageEvent event) { } if (emoticonChance.get() > 0.0d && StringUtils.isLastCharAlphabetic(sb)) { - StringUtils.uniformChanceAppend(sb, new String[]{" :3", " >:3"}, emoticonChance.get()); + StringUtils.uniformChanceAppend(sb, emoticons.get(), emoticonChance.get()); } event.message = sb.toString(); diff --git a/src/main/java/io/github/racoondog/tokyo/systems/seedresolver/SeedResolver.java b/src/main/java/io/github/racoondog/tokyo/systems/seedresolver/SeedResolver.java index fa5f904..085f7f0 100644 --- a/src/main/java/io/github/racoondog/tokyo/systems/seedresolver/SeedResolver.java +++ b/src/main/java/io/github/racoondog/tokyo/systems/seedresolver/SeedResolver.java @@ -36,6 +36,7 @@ public SeedResolver() { Http.Request request = Http.get("https://script.google.com/macros/s/AKfycbxvJa3GPh2B_atqbxFdlpInPw4XGKk1jR7lHqALx1durf0X-VXi6bG4zi7Jg-FCU3DfFg/exec"); ((IHttpRequest) request).tokyo$getBuilder().timeout(Duration.ofSeconds(30)); JsonArray databaseSeedArray = request.sendJson(JsonArray.class); + if (databaseSeedArray == null) return; for (var databaseEntry : databaseSeedArray) { JsonArray seedEntry = databaseEntry.getAsJsonArray(); String address = seedEntry.get(0).getAsString(); diff --git a/src/main/java/io/github/racoondog/tokyo/utils/misc/StringUtils.java b/src/main/java/io/github/racoondog/tokyo/utils/misc/StringUtils.java index 6b4075f..6bfc8e5 100644 --- a/src/main/java/io/github/racoondog/tokyo/utils/misc/StringUtils.java +++ b/src/main/java/io/github/racoondog/tokyo/utils/misc/StringUtils.java @@ -89,6 +89,23 @@ public static void uniformChanceAppend(StringBuilder text, CharSequence[] append if (rng < append.length) text.append(append[rng]); } + public static String uniformChanceAppend(CharSequence text, List append, double totalChance) { + if (totalChance <= 0.0d) return text.toString(); + totalChance = Math.max(totalChance, 1.0d); + + double localChance = totalChance / append.size(); + int rng = (int) (RANDOM.nextFloat() / localChance); + + return rng >= append.size() ? text.toString() : text.toString().concat(append.get(rng).toString()); + } + + public static void uniformChanceAppend(StringBuilder text, List append, double totalChance) { + double localChance = totalChance / append.size(); + int rng = (int) (RANDOM.nextFloat() / localChance); + + if (rng < append.size()) text.append(append.get(rng)); + } + public static boolean isLastCharAlphabetic(CharSequence seq) { return Character.isAlphabetic(seq.charAt(seq.length() - 1)); } @@ -110,7 +127,7 @@ public static void randomChanceKeepCaseReplace(StringBuilder text, CharSequence int lenDiff = replacementString.length() - targetString.length(); int index = org.apache.commons.lang3.StringUtils.indexOfIgnoreCase(text, targetString); while (index != -1) { - if (RANDOM.nextDouble() > chance) { + if (chance >= RANDOM.nextDouble()) { boolean upper = isMostlyUppercase(text, index, targetString.length()); int endIdx = index + replacementString.length(); @@ -139,7 +156,7 @@ public static void randomChanceReplace(StringBuilder text, CharSequence target, int lenDiff = replacementString.length() - targetString.length(); int index = text.indexOf(targetString); while (index != -1) { - if (RANDOM.nextDouble() > chance) { + if (chance >= RANDOM.nextDouble()) { int endIdx = index + replacementString.length(); text.replace(index, endIdx + push, replacementString); push += lenDiff; diff --git a/src/main/resources/tokyo-client.mixins.json b/src/main/resources/tokyo-client.mixins.json index d43588d..39f5516 100644 --- a/src/main/resources/tokyo-client.mixins.json +++ b/src/main/resources/tokyo-client.mixins.json @@ -7,7 +7,6 @@ "ChatInputSuggestorMixin", "ChatScreenMixin", "ClientCommandSourceMixin", - "CraftingScreenMixin", "IArrayPalette", "IBiMapPalette", "IClientChunkManager", @@ -21,18 +20,14 @@ "IStyle", "MusicTrackerMixin", "RunnableClickEventMixin", - "TextRendererMixin", + "DrawContextMixin", "meteor.ChatUtilsMixin", - "meteor.ConfigMixin", - "meteor.GuiRendererMixin", "meteor.ILogoutSpotsEntry", "meteor.LogoutSpotsMixin", "meteor.Renderer2DMixin", "meteor.SpamMixin", "meteor.StarscriptMixin", "meteor.SystemsMixin", - "meteor.TextOperationMixin", - "meteor.VanillaTextRendererMixin", "meteor.WAccountMixin" ], "injectors": {