diff --git a/build.gradle.kts b/build.gradle.kts index bcfd1f4..9e253aa 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -40,6 +40,7 @@ dependencies { modApi(libs.cloth.config) modApi(libs.modmenu) + modApi(libs.night.auto.config) } java { @@ -86,15 +87,15 @@ publisher { versionType.set("release") projectVersion.set(project.version.toString()) - gameVersions.set(listOf("1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4")) + gameVersions.set(listOf("1.21")) loaders.set(listOf("fabric", "quilt")) curseEnvironment.set("both") - modrinthDepends.required("fabric-api") + modrinthDepends.required("fabric-api", "night-auto-config") modrinthDepends.optional() modrinthDepends.embedded() - curseDepends.required("fabric-api") + curseDepends.required("fabric-api", "night-auto-config") curseDepends.optional() curseDepends.embedded() diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cd7286a..192c5d6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,15 +4,16 @@ archives-name = "ivespoken" mod = "2.1.0" loader = "fabric" -minecraft = "1.20" -yarn = "1.20+build.1" +minecraft = "1.21" +yarn = "1.21+build.9" fabric-loader = "0.16.0" -fabric-api = "0.83.0+1.20" +fabric-api = "0.100.6+1.21" fabric-loom = "1.6-SNAPSHOT" modpublisher = "2.1.0" -cloth-config = "11.1.118" -modmenu = "7.0.1" +cloth-config = "15.0.127" +modmenu = "11.0.1" +night-auto-config = "1.0.3-fabric1.21" # id id-modrinth = "OidSa416" @@ -31,6 +32,7 @@ fabric-api = { group = "net.fabricmc.fabric-api", name = "fabric-api", version.r cloth-config = { group = "me.shedaniel.cloth", name = "cloth-config-fabric", version.ref = "cloth-config" } modmenu = { group = "com.terraformersmc", name = "modmenu", version.ref = "modmenu" } +night-auto-config = { group = "com.github.KessokuTeaTime", name = "Night-Auto-Config", version.ref = "night-auto-config" } [plugins] fabric-loom = { id = "fabric-loom", version.ref = "fabric-loom" } diff --git a/src/main/java/band/kessokuteatime/ivespoken/IveSpoken.java b/src/main/java/band/kessokuteatime/ivespoken/IveSpoken.java index 4ed578b..89c3eb3 100644 --- a/src/main/java/band/kessokuteatime/ivespoken/IveSpoken.java +++ b/src/main/java/band/kessokuteatime/ivespoken/IveSpoken.java @@ -11,9 +11,11 @@ import net.minecraft.client.network.AbstractClientPlayerEntity; import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.entity.EntityAttachmentType; import net.minecraft.text.MutableText; import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import net.minecraft.util.math.Vec3d; import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; import org.slf4j.Logger; @@ -94,36 +96,39 @@ public static long timestamp(UUID uuid) { .setStyle(content.getStyle().withColor(Formatting.GRAY)); } - public static void renderDialog(AbstractClientPlayerEntity player, MatrixStack matrixStack, VertexConsumerProvider vertexConsumers, int light) { + public static void renderDialog(AbstractClientPlayerEntity player, MatrixStack matrixStack, VertexConsumerProvider vertexConsumers, int light, float tickDelta) { @Nullable Text dialog = dialog(player.getUuid()); if (dialog == null) return; boolean sneaky = !player.isSneaky(); - int y = (player.getName().getString().equals("deadmau5") ? -10 : 0) - 10; + Vec3d pos = player.getAttachments().getPointNullable(EntityAttachmentType.NAME_TAG, 0, player.getYaw(tickDelta)); + if (pos != null) { + int y = (player.getName().getString().equals("deadmau5") ? -10 : 0) - 10; - matrixStack.push(); - matrixStack.translate(0, player.getNameLabelHeight(), 0); - matrixStack.multiply(MinecraftClient.getInstance().getEntityRenderDispatcher().getRotation()); - matrixStack.scale(-0.025F, -0.025F, 0.025F); - Matrix4f matrix4f = matrixStack.peek().getPositionMatrix(); + matrixStack.push(); + matrixStack.translate(0, pos.getY() + 0.5, 0); + matrixStack.multiply(MinecraftClient.getInstance().getEntityRenderDispatcher().getRotation()); + matrixStack.scale(-0.025F, -0.025F, 0.025F); + Matrix4f matrix4f = matrixStack.peek().getPositionMatrix(); - int backgroundColor = (int) (MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F) * 255.0F) << 24; - float x = (float) -MinecraftClient.getInstance().textRenderer.getWidth(dialog) / 2; + int backgroundColor = (int) (MinecraftClient.getInstance().options.getTextBackgroundOpacity(0.25F) * 255.0F) << 24; + float x = (float) -MinecraftClient.getInstance().textRenderer.getWidth(dialog) / 2; - MinecraftClient.getInstance().textRenderer.draw( - dialog, x, y, 0x20FFFFFF, false, matrix4f, vertexConsumers, - sneaky ? TextRenderer.TextLayerType.SEE_THROUGH : TextRenderer.TextLayerType.NORMAL, - backgroundColor, light - ); - - if (sneaky) { MinecraftClient.getInstance().textRenderer.draw( - dialog, x, y, 0xFFFFFFFF, false, matrix4f, vertexConsumers, - TextRenderer.TextLayerType.NORMAL, - 0, light + dialog, x, y, 0x20FFFFFF, false, matrix4f, vertexConsumers, + sneaky ? TextRenderer.TextLayerType.SEE_THROUGH : TextRenderer.TextLayerType.NORMAL, + backgroundColor, light ); - } - matrixStack.pop(); + if (sneaky) { + MinecraftClient.getInstance().textRenderer.draw( + dialog, x, y, 0xFFFFFFFF, false, matrix4f, vertexConsumers, + TextRenderer.TextLayerType.NORMAL, + 0, light + ); + } + + matrixStack.pop(); + } } } diff --git a/src/main/java/band/kessokuteatime/ivespoken/mixin/DialogRenderer.java b/src/main/java/band/kessokuteatime/ivespoken/mixin/DialogRenderer.java index ee34e11..caa0eb2 100644 --- a/src/main/java/band/kessokuteatime/ivespoken/mixin/DialogRenderer.java +++ b/src/main/java/band/kessokuteatime/ivespoken/mixin/DialogRenderer.java @@ -20,13 +20,19 @@ protected DialogRenderer(EntityRendererFactory.Context ctx) { super(ctx); } - @Inject(method = "renderLabelIfPresent*", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/math/MatrixStack;pop()V")) - private void renderDialog(AbstractClientPlayerEntity player, Text text, MatrixStack matrixStack, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) { + @Inject( + method = "renderLabelIfPresent*", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/util/math/MatrixStack;pop()V" + ) + ) + private void renderDialog(AbstractClientPlayerEntity player, Text text, MatrixStack matrixStack, VertexConsumerProvider vertexConsumers, int light, float tickDelta, CallbackInfo ci) { if (!IveSpoken.CONFIG.get().enabled) return; double distance = this.dispatcher.getSquaredDistanceToCamera(player); if (distance > 4096) return; - IveSpoken.renderDialog(player, matrixStack, vertexConsumers, light); + IveSpoken.renderDialog(player, matrixStack, vertexConsumers, light, tickDelta); } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index da9e4a8..bb57634 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -34,7 +34,7 @@ "depends": { "fabricloader": "*", "fabric-api": "*", - "minecraft": "1.20.x" + "minecraft": "1.21.x" }, "suggests": { }