Skip to content

Commit

Permalink
Update to 1.20.6
Browse files Browse the repository at this point in the history
  • Loading branch information
BluSpring committed May 20, 2024
1 parent 645eaed commit cc12361
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
with:
submodules: true
token: ${{ secrets.PAT_TOKEN }}
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
# Taken from https://github.com/CaffeineMC/sodium-fabric/blob/1.19.3/dev/.github/workflows/gradle.yml
- name: Cache/Uncache
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/modrinth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
with:
submodules: true
token: ${{ secrets.PAT_TOKEN }}
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'
# Taken from https://github.com/CaffeineMC/sodium-fabric/blob/1.19.3/dev/.github/workflows/gradle.yml
- name: Cache/Uncache
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'fabric-loom' version '1.6-SNAPSHOT'
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '1.7.20'
id "com.modrinth.minotaur" version "2.+"
Expand Down Expand Up @@ -126,7 +126,7 @@ modrinth {
versionNumber = "${project.mod_version}+${project.minecraft_version}" // You don't need to set this manually. Will fail if Modrinth has this version already
versionType = "release" // This is the default -- can also be `beta` or `alpha`
uploadFile = remapJar // With Loom, this MUST be set to `remapJar` instead of `jar`!
gameVersions = ["1.20.3", "1.20.4"] // Must be an array, even with only one version
gameVersions = ["1.20.5", "1.20.6"] // Must be an array, even with only one version
loaders = ["fabric"] // Must also be an array - no need to specify this if you're using Loom or ForgeGradle
dependencies { // A special DSL for creating dependencies
// scope.type
Expand Down
12 changes: 6 additions & 6 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.14.9
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.2
loader_version=0.15.10
# Mod Properties
mod_version=1.1.3
maven_group=xyz.bluspring
archives_base_name=Nicknamer
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.93.1+1.20.4
fabric_version=0.99.0+1.20.6
fabric_kotlin_version=1.8.5+kotlin.1.7.20

modmenu_version=9.0.0
cloth_config_version=13.0.121
modmenu_version=10.0.0-beta.1
cloth_config_version=14.0.126
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-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,32 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
import xyz.bluspring.nicknamer.Nicknamer;
import xyz.bluspring.nicknamer.config.ConfigManager;
import xyz.bluspring.nicknamer.config.nickname.NicknameManager;
import xyz.bluspring.nicknamer.config.pronouns.PronounManager;
import xyz.bluspring.nicknamer.config.ConfigManager;

@Mixin(PlayerEntityRenderer.class)
public abstract class PlayerEntityRendererMixin extends LivingEntityRenderer<AbstractClientPlayerEntity, PlayerEntityModel<AbstractClientPlayerEntity>> {
public PlayerEntityRendererMixin(EntityRendererFactory.Context ctx, PlayerEntityModel<AbstractClientPlayerEntity> model, float shadowRadius) {
super(ctx, model, shadowRadius);
}

@Inject(at = @At("HEAD"), method = "renderLabelIfPresent(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V")
public void appendPronouns(AbstractClientPlayerEntity player, Text text, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, CallbackInfo ci) {
@Inject(at = @At("HEAD"), method = "renderLabelIfPresent(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IF)V")
public void appendPronouns(AbstractClientPlayerEntity player, Text text, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, float f, CallbackInfo ci) {
if (PronounManager.INSTANCE.getPronouns().containsKey(player.getUuid())) {
super.renderLabelIfPresent(
player,
PronounManager.INSTANCE.getPronounsText(player.getUuid()),
matrixStack,
vertexConsumerProvider,
i
i, f
);

matrixStack.translate(0.0, (9.0F * 1.15F * 0.025F), 0.0);
}
}

@ModifyArgs(method = "renderLabelIfPresent(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/LivingEntityRenderer;renderLabelIfPresent(Lnet/minecraft/entity/Entity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V"))
@ModifyArgs(method = "renderLabelIfPresent(Lnet/minecraft/client/network/AbstractClientPlayerEntity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IF)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/LivingEntityRenderer;renderLabelIfPresent(Lnet/minecraft/entity/Entity;Lnet/minecraft/text/Text;Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;IF)V"))
public void changeText(Args args) {
var player = (AbstractClientPlayerEntity) args.get(0);
Text text = args.get(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import net.fabricmc.api.ClientModInitializer
import net.fabricmc.fabric.api.client.command.v2.ClientCommandManager
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import net.minecraft.command.CommandRegistryAccess
import net.minecraft.command.argument.TextArgumentType
import xyz.bluspring.nicknamer.commands.nick.*
import xyz.bluspring.nicknamer.commands.pronouns.PronounsGetCommand
Expand All @@ -20,12 +21,12 @@ import xyz.bluspring.nicknamer.config.pronouns.PronounManager

class NicknamerClient : ClientModInitializer {
override fun onInitializeClient() {
ClientCommandRegistrationCallback.EVENT.register { it, _ ->
registerCommands(it)
ClientCommandRegistrationCallback.EVENT.register { it, registryAccess ->
registerCommands(it, registryAccess)
}
}

private fun registerCommands(dispatcher: CommandDispatcher<FabricClientCommandSource>) {
private fun registerCommands(dispatcher: CommandDispatcher<FabricClientCommandSource>, registryAccess: CommandRegistryAccess) {
dispatcher.register(
ClientCommandManager
.literal("nickc")
Expand Down Expand Up @@ -58,7 +59,7 @@ class NicknamerClient : ClientModInitializer {
.then(
ClientCommandManager.argument(
"nickname",
TextArgumentType.text()
TextArgumentType.text(registryAccess)
)
.executes(NickSetRawCommand())
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package xyz.bluspring.nicknamer.config.nickname

import com.google.gson.JsonArray
import com.google.gson.JsonObject
import com.google.gson.JsonParser
import com.google.gson.*
import com.mojang.serialization.JsonOps
import net.minecraft.text.Text
import net.minecraft.text.TextCodecs
import xyz.bluspring.nicknamer.Nicknamer
import xyz.bluspring.nicknamer.config.ConfigManager
import java.io.File
Expand All @@ -15,6 +15,10 @@ object NicknameManager/*(val pathName: String)*/ {
val nicknames = mutableMapOf<UUID, Text>()
val disabled = mutableSetOf<UUID>()

private val GSON = GsonBuilder()
.disableHtmlEscaping()
.create()

fun save() {
if (!file.exists()) {
if (!Nicknamer.configDir.exists())
Expand All @@ -27,7 +31,7 @@ object NicknameManager/*(val pathName: String)*/ {

json.add("nicknames", JsonObject().apply {
nicknames.forEach { (uuid, text) ->
addProperty(uuid.toString(), Text.Serialization.toJsonString(text))
addProperty(uuid.toString(), GSON.toJson(TextCodecs.CODEC.encodeStart(JsonOps.INSTANCE, text).getOrThrow(::JsonParseException)))
}
})

Expand All @@ -48,7 +52,10 @@ object NicknameManager/*(val pathName: String)*/ {

json.getAsJsonObject("nicknames").apply {
entrySet().forEach { (uuid, text) ->
nicknames[UUID.fromString(uuid)] = Text.Serialization.fromJson(text.asString) ?: Text.of("no load")
nicknames[UUID.fromString(uuid)] = TextCodecs.CODEC.parse(
JsonOps.INSTANCE,
JsonParser.parseString(text.asString)
).getOrThrow(::JsonParseException) ?: Text.of("no load")
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"depends": {
"fabricloader": ">=0.14.9",
"fabric": "*",
"minecraft": ">=1.20.3",
"minecraft": ">=1.20.5",
"fabric-language-kotlin": "*",
"cloth-config": ">=13"
"cloth-config": ">=14"
}
}

0 comments on commit cc12361

Please sign in to comment.