From d9283448262253326286b6b1efee3ffc987c1a92 Mon Sep 17 00:00:00 2001 From: Draylar Date: Wed, 24 Jun 2020 18:11:19 -0500 Subject: [PATCH] 1.16 update --- build.gradle | 63 +++++++++++++++---- gradle.properties | 13 +++- .../cu/client/gui/ColorButtonWidget.java | 31 ++++----- .../cu/client/gui/ColorToggleWidget.java | 25 ++++---- .../draylar/cu/mixin/AnvilScreenMixin.java | 19 +++--- .../draylar/cu/mixin/BookEditScreenMixin.java | 47 +++++++------- .../draylar/cu/mixin/ChatScreenMixin.java | 17 ++--- .../draylar/cu/mixin/FormattingAccessor.java | 11 ++++ .../draylar/cu/mixin/FormattingMixin.java | 2 +- .../mixin/ServerPlayNetworkHandlerMixin.java | 8 +-- .../cu/mixin/SharedConstantsMixin.java | 2 +- .../draylar/cu/mixin/SignEditScreenMixin.java | 17 ++--- src/main/resources/colorunchained.mixins.json | 13 ++-- src/main/resources/fabric.mod.json | 2 +- 14 files changed, 170 insertions(+), 100 deletions(-) rename src/main/java/{com/github => }/draylar/cu/client/gui/ColorButtonWidget.java (63%) rename src/main/java/{com/github => }/draylar/cu/client/gui/ColorToggleWidget.java (66%) rename src/main/java/{com/github => }/draylar/cu/mixin/AnvilScreenMixin.java (73%) rename src/main/java/{com/github => }/draylar/cu/mixin/BookEditScreenMixin.java (68%) rename src/main/java/{com/github => }/draylar/cu/mixin/ChatScreenMixin.java (74%) create mode 100644 src/main/java/draylar/cu/mixin/FormattingAccessor.java rename src/main/java/{com/github => }/draylar/cu/mixin/FormattingMixin.java (93%) rename src/main/java/{com/github => }/draylar/cu/mixin/ServerPlayNetworkHandlerMixin.java (75%) rename src/main/java/{com/github => }/draylar/cu/mixin/SharedConstantsMixin.java (94%) rename src/main/java/{com/github => }/draylar/cu/mixin/SignEditScreenMixin.java (75%) diff --git a/build.gradle b/build.gradle index b76712f..536cbac 100644 --- a/build.gradle +++ b/build.gradle @@ -1,12 +1,13 @@ plugins { - id 'fabric-loom' version '0.2.7-SNAPSHOT' + id 'fabric-loom' version '0.4-SNAPSHOT' + id 'maven-publish' } sourceCompatibility = 1.8 targetCompatibility = 1.8 archivesBaseName = "colorunchained" -version = "1.0.2" +version = project.mod_version + "-" + project.minecraft_version minecraft { } @@ -15,26 +16,64 @@ repositories { maven { url = "https://maven.fabricmc.net/" } } - dependencies { - minecraft "com.mojang:minecraft:1.15.2" - mappings "net.fabricmc:yarn:1.15.2+build.14:v2" - modCompile "net.fabricmc:fabric-loader:0.7.8+build.184" - modCompile "net.fabricmc.fabric-api:fabric-api:0.4.32+build.292-1.15" + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings "net.fabricmc:yarn:${project.yarn_version}:v2" + modCompile "net.fabricmc:fabric-loader:${project.loader_version}" + modCompile "net.fabricmc.fabric-api:fabric-api:${project.api_version}" + + modCompile "io.github.prospector:modmenu:${project.modmenu_version}" +} + +processResources { + inputs.property "version", project.version - modApi ("io.github.prospector:modmenu:1.8.5+build.23"){ - transitive = false + from(sourceSets.main.resources.srcDirs) { + include "fabric.mod.json" + expand "version": project.version } + + from(sourceSets.main.resources.srcDirs) { + exclude "fabric.mod.json" + } +} + +// ensure that the encoding is set to UTF-8, no matter what the system default is +// this fixes some edge cases with special characters not displaying correctly +// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" } // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task // if it is present. // If you remove this task, sources will not be generated. task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' + classifier = "sources" from sourceSets.main.allSource } -tasks.withType(JavaCompile) { - options.encoding = "UTF-8" +jar { + from "LICENSE" } + +// configure the maven publication +publishing { + publications { + mavenJava(MavenPublication) { + // add all the jars that should be included when publishing to maven + artifact(remapJar) { + builtBy remapJar + } + artifact(sourcesJar) { + builtBy remapSourcesJar + } + } + } + + // select the repositories you want to publish to + repositories { + // uncomment to publish to the local maven + // mavenLocal() + } +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index d8e54c1..67bce58 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,13 @@ #Done to increase the memory available to gradle. -org.gradle.jvmargs=-Xmx1G \ No newline at end of file +org.gradle.jvmargs=-Xmx1G + +mod_version = 1.1.0 + +## Game / Fabric deps +minecraft_version = 1.16.1 +yarn_version=1.16.1+build.4 +loader_version=0.8.8+build.202 +api_version=0.13.1+build.370-1.16 + +## Dev Deps +modmenu_version=1.12+ \ No newline at end of file diff --git a/src/main/java/com/github/draylar/cu/client/gui/ColorButtonWidget.java b/src/main/java/draylar/cu/client/gui/ColorButtonWidget.java similarity index 63% rename from src/main/java/com/github/draylar/cu/client/gui/ColorButtonWidget.java rename to src/main/java/draylar/cu/client/gui/ColorButtonWidget.java index 49c80a5..a95e6dd 100644 --- a/src/main/java/com/github/draylar/cu/client/gui/ColorButtonWidget.java +++ b/src/main/java/draylar/cu/client/gui/ColorButtonWidget.java @@ -1,31 +1,32 @@ -package com.github.draylar.cu.client.gui; +package draylar.cu.client.gui; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.widget.ButtonWidget; -import net.minecraft.client.util.TextFormat; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.text.Text; import net.minecraft.util.Formatting; import net.minecraft.util.math.MathHelper; public class ColorButtonWidget extends ButtonWidget { - private int x; - private int y; - private Formatting formatting; + private final int x; + private final int y; + private final Formatting formatting; + + public ColorButtonWidget(Formatting formatting, int x, int y, int width, int height, Text message, PressAction onPress) { + super(x, y, width, height, message, onPress); - public ColorButtonWidget(TextFormat format, int x, int y, int width, int height, String text, PressAction pressAction) { - super(x, y, width, height, text, pressAction); this.x = x; this.y = y; - - formatting = Formatting.byCode(format.getChar()); - visible = false; + this.formatting = formatting; + this.visible = false; } @Override - public void renderButton(int mouseX, int mouseY, float float_1) { + public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float float_1) { MinecraftClient client = MinecraftClient.getInstance(); client.getTextureManager().bindTexture(WIDGETS_LOCATION); @@ -35,8 +36,8 @@ public void renderButton(int mouseX, int mouseY, float float_1) { RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO); RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); - this.blit(this.x, this.y, 0, 46 + int_3 * 20, this.width / 2, this.height + 4); - this.blit(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + int_3 * 20, this.width / 2, this.height + 4); + this.drawTexture(matrices, this.x, this.y, 0, 46 + int_3 * 20, this.width / 2, this.height + 4); + this.drawTexture(matrices, this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + int_3 * 20, this.width / 2, this.height + 4); int int_4 = 14737632; if (!this.active) { @@ -46,7 +47,7 @@ public void renderButton(int mouseX, int mouseY, float float_1) { } if(formatting.getColorValue() != null) { - DrawableHelper.fill(x + 5, y + 6, x + 11, y + 12, formatting.getColorValue() | 0xFF000000); + DrawableHelper.fill(matrices,x + 5, y + 6, x + 11, y + 12, formatting.getColorValue() | 0xFF000000); } else { String icon = ""; switch(formatting) { @@ -68,7 +69,7 @@ public void renderButton(int mouseX, int mouseY, float float_1) { case RESET: icon = "R"; } - this.drawCenteredString(MinecraftClient.getInstance().textRenderer, icon, this.x + this.width / 2, this.y + (this.height - 8) / 2, int_4 | MathHelper.ceil(this.alpha * 255.0F) << 24); + this.drawCenteredString(matrices, MinecraftClient.getInstance().textRenderer, icon, this.x + this.width / 2, this.y + (this.height - 8) / 2, int_4 | MathHelper.ceil(this.alpha * 255.0F) << 24); } } diff --git a/src/main/java/com/github/draylar/cu/client/gui/ColorToggleWidget.java b/src/main/java/draylar/cu/client/gui/ColorToggleWidget.java similarity index 66% rename from src/main/java/com/github/draylar/cu/client/gui/ColorToggleWidget.java rename to src/main/java/draylar/cu/client/gui/ColorToggleWidget.java index 9a0a67b..a512edb 100644 --- a/src/main/java/com/github/draylar/cu/client/gui/ColorToggleWidget.java +++ b/src/main/java/draylar/cu/client/gui/ColorToggleWidget.java @@ -1,32 +1,35 @@ -package com.github.draylar.cu.client.gui; +package draylar.cu.client.gui; import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawableHelper; import net.minecraft.client.gui.widget.ButtonWidget; +import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.text.Text; import java.awt.*; public class ColorToggleWidget extends ButtonWidget { - private int x; - private int y; + private final int x; + private final int y; int index = 0; - private PressAction pressAction; + private final PressAction pressAction; - public ColorToggleWidget(int x, int y, int width, int height, String text, PressAction pressAction) { + public ColorToggleWidget(int x, int y, int width, int height, Text text, PressAction pressAction) { super(x, y, width, height, text, pressAction); + this.x = x; this.y = y; this.pressAction = pressAction; } @Override - public void onClick(double double_1, double double_2) { - super.onClick(double_1, double_2); + public void onClick(double x, double y) { + super.onClick(x, y); } public void onPress() { @@ -34,7 +37,7 @@ public void onPress() { } @Override - public void render(int mouseX, int mouseY, float float_1) { + public void render(MatrixStack stack, int mouseX, int mouseY, float float_1) { MinecraftClient client = MinecraftClient.getInstance(); client.getTextureManager().bindTexture(WIDGETS_LOCATION); @@ -44,15 +47,15 @@ public void render(int mouseX, int mouseY, float float_1) { RenderSystem.blendFuncSeparate(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SrcFactor.ONE, GlStateManager.DstFactor.ZERO); RenderSystem.blendFunc(GlStateManager.SrcFactor.SRC_ALPHA, GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA); - this.blit(this.x, this.y, 0, 46 + int_3 * 20, this.width / 2, this.height + 4); - this.blit(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + int_3 * 20, this.width / 2, this.height + 4); + this.drawTexture(stack, this.x, this.y, 0, 46 + int_3 * 20, this.width / 2, this.height + 4); + this.drawTexture(stack, this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + int_3 * 20, this.width / 2, this.height + 4); double red = Math.sin(.03 * index + 0) * 127 + 128; double green = Math.sin(.03 * index + 2) * 127 + 128; double blue = Math.sin(.03 * index + 4) * 127 + 128; - DrawableHelper.fill(x + 5, y + 5, x + 11, y + 14, new Color((int) red, (int) green, (int) blue).getRGB()); + DrawableHelper.fill(stack,x + 5, y + 5, x + 11, y + 14, new Color((int) red, (int) green, (int) blue).getRGB()); index++; diff --git a/src/main/java/com/github/draylar/cu/mixin/AnvilScreenMixin.java b/src/main/java/draylar/cu/mixin/AnvilScreenMixin.java similarity index 73% rename from src/main/java/com/github/draylar/cu/mixin/AnvilScreenMixin.java rename to src/main/java/draylar/cu/mixin/AnvilScreenMixin.java index 1228ca2..2e410cd 100644 --- a/src/main/java/com/github/draylar/cu/mixin/AnvilScreenMixin.java +++ b/src/main/java/draylar/cu/mixin/AnvilScreenMixin.java @@ -1,12 +1,13 @@ -package com.github.draylar.cu.mixin; +package draylar.cu.mixin; -import com.github.draylar.cu.client.gui.ColorButtonWidget; -import com.github.draylar.cu.client.gui.ColorToggleWidget; +import draylar.cu.client.gui.ColorButtonWidget; +import draylar.cu.client.gui.ColorToggleWidget; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ingame.AnvilScreen; import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.client.util.TextFormat; +import net.minecraft.text.LiteralText; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -25,7 +26,7 @@ public abstract class AnvilScreenMixin extends Screen { @Shadow private TextFieldWidget nameField; boolean showColors = false; - ColorToggleWidget colorButton = new ColorToggleWidget(2, 2, 16, 16, "Color", (widget) -> { + ColorToggleWidget colorButton = new ColorToggleWidget(2, 2, 16, 16, new LiteralText("Color"), (widget) -> { toggleVisible(); }); @@ -42,14 +43,14 @@ private void toggleVisible() { } - @Inject(at = @At("HEAD"), method = "init") + @Inject(at = @At("HEAD"), method = "setup") private void init(CallbackInfo ci) { int index = 0; - for(TextFormat color : TextFormat.values()) { + for(Formatting color : Formatting.values()) { index++; - ColorButtonWidget red = new ColorButtonWidget(color,18 * index + 3, 2, 16, 16, color.getName(), (widget) -> { - nameField.setText(nameField.getText() + "§" + color.getChar()); + ColorButtonWidget red = new ColorButtonWidget(color,18 * index + 3, 2, 16, 16, new LiteralText(color.getName()), (widget) -> { + nameField.setText(nameField.getText() + "§" + ((FormattingAccessor) (Object) color).getCode()); this.setFocused(nameField); }); diff --git a/src/main/java/com/github/draylar/cu/mixin/BookEditScreenMixin.java b/src/main/java/draylar/cu/mixin/BookEditScreenMixin.java similarity index 68% rename from src/main/java/com/github/draylar/cu/mixin/BookEditScreenMixin.java rename to src/main/java/draylar/cu/mixin/BookEditScreenMixin.java index 27f1e5d..4494a6c 100644 --- a/src/main/java/com/github/draylar/cu/mixin/BookEditScreenMixin.java +++ b/src/main/java/draylar/cu/mixin/BookEditScreenMixin.java @@ -1,11 +1,12 @@ -package com.github.draylar.cu.mixin; +package draylar.cu.mixin; -import com.github.draylar.cu.client.gui.ColorButtonWidget; -import com.github.draylar.cu.client.gui.ColorToggleWidget; +import draylar.cu.client.gui.ColorButtonWidget; +import draylar.cu.client.gui.ColorToggleWidget; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ingame.BookEditScreen; -import net.minecraft.client.util.TextFormat; +import net.minecraft.text.LiteralText; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -26,26 +27,26 @@ public abstract class BookEditScreenMixin extends Screen { @Shadow public abstract boolean charTyped(char char_1, int int_1); - @Inject(at = @At("HEAD"), method = "stripFromatting", cancellable = true) - private void stripFromatting(String string_1, CallbackInfoReturnable info) { - StringBuilder stringBuilder_1 = new StringBuilder(); - char[] var3 = string_1.toCharArray(); - int var4 = var3.length; - - for(int var5 = 0; var5 < var4; ++var5) { - char char_1 = var3[var5]; - if (char_1 != 127) { - stringBuilder_1.append(char_1); - } - } - - info.setReturnValue(stringBuilder_1.toString()); - } +// @Inject(at = @At("HEAD"), method = "stripFromatting", cancellable = true) +// private void stripFromatting(String string_1, CallbackInfoReturnable info) { +// StringBuilder stringBuilder_1 = new StringBuilder(); +// char[] var3 = string_1.toCharArray(); +// int var4 = var3.length; +// +// for(int var5 = 0; var5 < var4; ++var5) { +// char char_1 = var3[var5]; +// if (char_1 != 127) { +// stringBuilder_1.append(char_1); +// } +// } +// +// info.setReturnValue(stringBuilder_1.toString()); +// } boolean showColors = false; - ColorToggleWidget colorButton = new ColorToggleWidget(2, 2, 16, 16, "Color", (widget) -> { + ColorToggleWidget colorButton = new ColorToggleWidget(2, 2, 16, 16, new LiteralText("Color"), (widget) -> { toggleVisible(); }); @@ -79,10 +80,10 @@ private void init(CallbackInfo ci) { int x = 0; int y = 0; - for(TextFormat color : TextFormat.values()) { - ColorButtonWidget red = new ColorButtonWidget(color, 2 + x * 20, 2 + y * 20, 16, 16, color.getName(), (widget) -> { + for(Formatting color : Formatting.values()) { + ColorButtonWidget red = new ColorButtonWidget(color, 2 + x * 20, 2 + y * 20, 16, 16, new LiteralText(color.getName()), (widget) -> { this.charTyped('§', 1); - this.charTyped(color.getChar(), 0); + this.charTyped(((FormattingAccessor) (Object) color).getCode(), 0); }); if(y < 8) { diff --git a/src/main/java/com/github/draylar/cu/mixin/ChatScreenMixin.java b/src/main/java/draylar/cu/mixin/ChatScreenMixin.java similarity index 74% rename from src/main/java/com/github/draylar/cu/mixin/ChatScreenMixin.java rename to src/main/java/draylar/cu/mixin/ChatScreenMixin.java index 1c97961..8de7969 100644 --- a/src/main/java/com/github/draylar/cu/mixin/ChatScreenMixin.java +++ b/src/main/java/draylar/cu/mixin/ChatScreenMixin.java @@ -1,12 +1,13 @@ -package com.github.draylar.cu.mixin; +package draylar.cu.mixin; -import com.github.draylar.cu.client.gui.ColorButtonWidget; -import com.github.draylar.cu.client.gui.ColorToggleWidget; +import draylar.cu.client.gui.ColorButtonWidget; +import draylar.cu.client.gui.ColorToggleWidget; import net.minecraft.client.gui.screen.ChatScreen; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.widget.TextFieldWidget; -import net.minecraft.client.util.TextFormat; +import net.minecraft.text.LiteralText; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -24,7 +25,7 @@ public abstract class ChatScreenMixin extends Screen { @Shadow protected TextFieldWidget chatField; boolean showColors = false; - ColorToggleWidget colorButton = new ColorToggleWidget(2, 2, 16, 16, "Color", (widget) -> { + ColorToggleWidget colorButton = new ColorToggleWidget(2, 2, 16, 16, new LiteralText("Color"), (widget) -> { toggleVisible(); }); @@ -45,10 +46,10 @@ private void toggleVisible() { private void init(CallbackInfo ci) { int index = 0; - for(TextFormat color : TextFormat.values()) { + for(Formatting color : Formatting.values()) { index++; - ColorButtonWidget red = new ColorButtonWidget(color,18 * index + 3, 2, 16, 16, color.getName(), (widget) -> { - chatField.setText(chatField.getText() + "§" + color.getChar()); + ColorButtonWidget red = new ColorButtonWidget(color,18 * index + 3, 2, 16, 16, new LiteralText(color.getName()), (widget) -> { + chatField.setText(chatField.getText() + "§" + ((FormattingAccessor) (Object) color).getCode()); }); colors.add(red); diff --git a/src/main/java/draylar/cu/mixin/FormattingAccessor.java b/src/main/java/draylar/cu/mixin/FormattingAccessor.java new file mode 100644 index 0000000..da1da5a --- /dev/null +++ b/src/main/java/draylar/cu/mixin/FormattingAccessor.java @@ -0,0 +1,11 @@ +package draylar.cu.mixin; + +import net.minecraft.util.Formatting; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(Formatting.class) +public interface FormattingAccessor { + @Accessor + char getCode(); +} diff --git a/src/main/java/com/github/draylar/cu/mixin/FormattingMixin.java b/src/main/java/draylar/cu/mixin/FormattingMixin.java similarity index 93% rename from src/main/java/com/github/draylar/cu/mixin/FormattingMixin.java rename to src/main/java/draylar/cu/mixin/FormattingMixin.java index 36c90fb..9860743 100644 --- a/src/main/java/com/github/draylar/cu/mixin/FormattingMixin.java +++ b/src/main/java/draylar/cu/mixin/FormattingMixin.java @@ -1,4 +1,4 @@ -package com.github.draylar.cu.mixin; +package draylar.cu.mixin; import net.minecraft.util.Formatting; import org.spongepowered.asm.mixin.Final; diff --git a/src/main/java/com/github/draylar/cu/mixin/ServerPlayNetworkHandlerMixin.java b/src/main/java/draylar/cu/mixin/ServerPlayNetworkHandlerMixin.java similarity index 75% rename from src/main/java/com/github/draylar/cu/mixin/ServerPlayNetworkHandlerMixin.java rename to src/main/java/draylar/cu/mixin/ServerPlayNetworkHandlerMixin.java index a02c138..80e0b49 100644 --- a/src/main/java/com/github/draylar/cu/mixin/ServerPlayNetworkHandlerMixin.java +++ b/src/main/java/draylar/cu/mixin/ServerPlayNetworkHandlerMixin.java @@ -1,4 +1,4 @@ -package com.github.draylar.cu.mixin; +package draylar.cu.mixin; import net.minecraft.server.network.ServerPlayNetworkHandler; import org.spongepowered.asm.mixin.Mixin; @@ -15,8 +15,8 @@ public class ServerPlayNetworkHandlerMixin { value = "INVOKE", target = "Ljava/lang/String;startsWith(Ljava/lang/String;)Z", shift = At.Shift.BEFORE - ), method = "onChatMessage", ordinal = 0) - private String onChatMessage(String string_1) { - return string_1.replace("%%", "§"); + ), method = "onGameMessage", ordinal = 0) + private String onGameMessage(String message) { + return message.replace("%%", "§"); } } diff --git a/src/main/java/com/github/draylar/cu/mixin/SharedConstantsMixin.java b/src/main/java/draylar/cu/mixin/SharedConstantsMixin.java similarity index 94% rename from src/main/java/com/github/draylar/cu/mixin/SharedConstantsMixin.java rename to src/main/java/draylar/cu/mixin/SharedConstantsMixin.java index cb92cf4..162955c 100644 --- a/src/main/java/com/github/draylar/cu/mixin/SharedConstantsMixin.java +++ b/src/main/java/draylar/cu/mixin/SharedConstantsMixin.java @@ -1,4 +1,4 @@ -package com.github.draylar.cu.mixin; +package draylar.cu.mixin; import net.minecraft.SharedConstants; import org.spongepowered.asm.mixin.Mixin; diff --git a/src/main/java/com/github/draylar/cu/mixin/SignEditScreenMixin.java b/src/main/java/draylar/cu/mixin/SignEditScreenMixin.java similarity index 75% rename from src/main/java/com/github/draylar/cu/mixin/SignEditScreenMixin.java rename to src/main/java/draylar/cu/mixin/SignEditScreenMixin.java index 6ff4c3d..fe379f9 100644 --- a/src/main/java/com/github/draylar/cu/mixin/SignEditScreenMixin.java +++ b/src/main/java/draylar/cu/mixin/SignEditScreenMixin.java @@ -1,12 +1,13 @@ -package com.github.draylar.cu.mixin; +package draylar.cu.mixin; -import com.github.draylar.cu.client.gui.ColorButtonWidget; -import com.github.draylar.cu.client.gui.ColorToggleWidget; +import draylar.cu.client.gui.ColorButtonWidget; +import draylar.cu.client.gui.ColorToggleWidget; import net.minecraft.client.gui.screen.Screen; import net.minecraft.client.gui.screen.ingame.SignEditScreen; import net.minecraft.client.util.SelectionManager; -import net.minecraft.client.util.TextFormat; +import net.minecraft.text.LiteralText; import net.minecraft.text.Text; +import net.minecraft.util.Formatting; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -24,7 +25,7 @@ public abstract class SignEditScreenMixin extends Screen { @Shadow private SelectionManager selectionManager; boolean showColors = false; - ColorToggleWidget colorButton = new ColorToggleWidget(2, 2, 16, 16, "Color", (widget) -> { + ColorToggleWidget colorButton = new ColorToggleWidget(2, 2, 16, 16, new LiteralText("Color"), (widget) -> { toggleVisible(); }); @@ -45,11 +46,11 @@ private void toggleVisible() { private void init(CallbackInfo ci) { int index = 0; - for(TextFormat color : TextFormat.values()) { + for(Formatting color : Formatting.values()) { index++; - ColorButtonWidget red = new ColorButtonWidget(color,18 * index + 3, 2, 16, 16, color.getName(), (widget) -> { + ColorButtonWidget red = new ColorButtonWidget(color,18 * index + 3, 2, 16, 16, new LiteralText(color.getName()), (widget) -> { selectionManager.insert('§'); - selectionManager.insert(color.getChar()); + selectionManager.insert(((FormattingAccessor) (Object) color).getCode()); }); colors.add(red); diff --git a/src/main/resources/colorunchained.mixins.json b/src/main/resources/colorunchained.mixins.json index 5e4ef6f..2d02fc9 100644 --- a/src/main/resources/colorunchained.mixins.json +++ b/src/main/resources/colorunchained.mixins.json @@ -1,17 +1,18 @@ { "required": true, - "package": "com.github.draylar.cu.mixin", + "package": "draylar.cu.mixin", "compatibilityLevel": "JAVA_8", "mixins": [ - "SharedConstantsMixin", + "FormattingAccessor", + "FormattingMixin", "ServerPlayNetworkHandlerMixin", - "FormattingMixin" + "SharedConstantsMixin" ], "client": [ - "BookEditScreenMixin", - "SignEditScreenMixin", "AnvilScreenMixin", - "ChatScreenMixin" + "BookEditScreenMixin", + "ChatScreenMixin", + "SignEditScreenMixin" ], "injectors": { "defaultRequire": 1 diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 9b60746..7396dc3 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -2,7 +2,7 @@ { "schemaVersion": 1, "id": "colorunchained", - "version": "1.0.2", + "version": "${version}", "name": "Color Unchained", "description": "Color Unchained brings color back to your life.",