Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
1.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MicrocontrollersDev committed May 26, 2024
1 parent bb48f67 commit 0f33620
Show file tree
Hide file tree
Showing 16 changed files with 240 additions and 130 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: Artifacts
path: build/libs/
path: versions/**/build/libs/
64 changes: 0 additions & 64 deletions build.gradle

This file was deleted.

80 changes: 80 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import org.polyfrost.gradle.util.noServerRunConfigs

plugins {
id(libs.plugins.pgt.main.get().pluginId)
id(libs.plugins.pgt.defaults.repo.get().pluginId)
id(libs.plugins.pgt.defaults.loom.get().pluginId)
id(libs.plugins.pgt.defaults.java.get().pluginId)
alias(libs.plugins.blossom)
id(libs.plugins.shadow.get().pluginId)
alias(libs.plugins.kotlin) apply false
}

version = project.properties["mod_version"] as String
group = project.properties["maven_group"] as String

repositories {
mavenCentral()
maven("https://repo.polyfrost.org/releases")
maven("https://maven.isxander.dev/releases")
maven("https://maven.terraformersmc.com/releases")
}

java {
toolchain {
when(platform.mcVersion) {
in 12001..12004 -> {
languageVersion.set(JavaLanguageVersion.of(17))
}
else -> {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
}
}

loom {
noServerRunConfigs()
}

dependencies {
// Mixin Extras because PGT doesn't include it
implementation(annotationProcessor(libs.mixinextras.get())!!)

val modMenuVersion = when(platform.mcVersion) {
12001 -> "7.2.2"
12004 -> "9.2.0-beta.2"
else -> "10.0.0-beta.1"
}

val fabricApiVersion = when(platform.mcVersion) {
12001 -> "0.92.1"
12004 -> "0.97.0"
else -> "0.98.0"
}

val yaclVersion = when(platform.mcVersion) {
12001 -> "3.4.2+1.20.1-fabric"
12004 -> "3.4.2+1.20.4-fabric"
else -> "3.4.2+1.20.5-fabric"
}

modImplementation("com.terraformersmc:modmenu:${modMenuVersion}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${fabricApiVersion}+${platform.mcVersionStr}")
modImplementation("dev.isxander:yet-another-config-lib:${yaclVersion}")

// DevAuth. Lets us log in with our own Minecraft account. Useful for testing tab features.
modRuntimeOnly("me.djtheredstoner:DevAuth-${platform.loaderStr}:1.2.0")
}

tasks.processResources {
filesMatching("fabric.mod.json") {
expand(mapOf("version" to project.version))
}
}

tasks.jar {
from("LICENSE") {
rename { "${it}_${project.base.archivesName.get()}" }
}
}
15 changes: 3 additions & 12 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,10 @@
org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.5
yarn_mappings=1.20.5+build.1
loader_version=0.15.10
# PGT
polyfrost.defaults.loom=2

# Mod Properties
mod_version=1.3.1
mod_version=1.3.2
maven_group=dev.microcontrollers.nametagtweaks
archives_base_name=nametagtweaks

# Dependencies
fabric_version=0.97.5+1.20.5
modMenuVersion=10.0.0-beta.1
yaclVersion=3.4.0+1.20.5
devauthVersion=1.2.0
25 changes: 25 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[versions]
kotlin = "1.9.23"

pgt = "0.5.1"
shadow = "8.1.1"
blossom = "1.3.2"

mixinextras = "0.3.5"

[libraries]
mixinextras = { module = "io.github.llamalad7:mixinextras-fabric", version.ref = "mixinextras" }


[plugins]
kotlin = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }

pgt-main = { id = "org.polyfrost.multi-version", version.ref = "pgt" }
pgt-root = { id = "org.polyfrost.multi-version.root", version.ref = "pgt" }
pgt-default = { id = "org.polyfrost.defaults", version.ref = "pgt" }
pgt-defaults-repo = { id = "org.polyfrost.defaults.repo", version.ref = "pgt" }
pgt-defaults-loom = { id = "org.polyfrost.defaults.loom", version.ref = "pgt" }
pgt-defaults-java = { id = "org.polyfrost.defaults.java", version.ref = "pgt" }

shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadow" }
blossom = { id = "net.kyori.blossom", version.ref = "blossom" }
11 changes: 11 additions & 0 deletions root.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
alias(libs.plugins.pgt.root)
alias(libs.plugins.kotlin) apply false
}

preprocess {
val fabric12004 = createNode("1.20.4-fabric", 12004, "yarn")
val fabric12006 = createNode("1.20.6-fabric", 12006, "yarn")

fabric12006.link(fabric12004)
}
10 changes: 0 additions & 10 deletions settings.gradle

This file was deleted.

20 changes: 20 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
pluginManagement {
repositories {
maven("https://repo.polyfrost.org/releases")
mavenCentral()
gradlePluginPortal()
}
}

listOf(
"1.20.4-fabric",
"1.20.6-fabric"
).forEach { version ->
include(":$version")
project(":$version").apply {
projectDir = file("versions/$version")
buildFileName = "../../build.gradle.kts"
}
}

rootProject.buildFileName = "root.gradle.kts"
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package dev.microcontrollers.nametagtweaks;

import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.text.OrderedText;
import org.joml.Matrix4f;

public interface NametagShadowFix {
void nametagTweaks$drawNametagShadow(OrderedText text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, TextRenderer.TextLayerType layerType, int backgroundColor, int light);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import dev.isxander.yacl3.api.controller.FloatSliderControllerBuilder;
import dev.isxander.yacl3.api.controller.IntegerSliderControllerBuilder;
import dev.isxander.yacl3.api.controller.TickBoxControllerBuilder;
import dev.isxander.yacl3.config.ConfigEntry;
import dev.isxander.yacl3.config.ConfigInstance;
import dev.isxander.yacl3.config.GsonConfigInstance;
import dev.isxander.yacl3.config.v2.api.ConfigClassHandler;
import dev.isxander.yacl3.config.v2.api.SerialEntry;
import dev.isxander.yacl3.config.v2.api.serializer.GsonConfigSerializerBuilder;
import dev.isxander.yacl3.gui.controllers.ColorController;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.gui.screen.Screen;
Expand All @@ -18,21 +18,22 @@
import java.awt.*;

public class NametagTweaksConfig {
public static final ConfigInstance<NametagTweaksConfig> CONFIG = GsonConfigInstance.createBuilder(NametagTweaksConfig.class)
.setPath(FabricLoader.getInstance().getConfigDir().resolve("nametagtweaks.json"))
public static final ConfigClassHandler<NametagTweaksConfig> CONFIG = ConfigClassHandler.createBuilder(NametagTweaksConfig.class)
.serializer(config -> GsonConfigSerializerBuilder.create(config)
.setPath(FabricLoader.getInstance().getConfigDir().resolve("nametagtweaks.json"))
.build())
.build();

@ConfigEntry public boolean removeNametags = false;
@ConfigEntry public boolean showOwnNametags = false;
@ConfigEntry public boolean hideEntityNametagsInHiddenHud = true;
@ConfigEntry public boolean hidePlayerNametagsInHiddenHud = false;
@ConfigEntry public boolean hideArmorStandNametagsInHiddenHud = false;
@ConfigEntry public int nametagOffset = 0;
@ConfigEntry public Color nametagColor = new Color(0, 0, 0, 63);
@ConfigEntry public boolean nametagTextShadow = false;
@ConfigEntry public float nametagScale = 1F;
@SerialEntry public boolean removeNametags = false;
@SerialEntry public boolean showOwnNametags = false;
@SerialEntry public boolean hideEntityNametagsInHiddenHud = true;
@SerialEntry public boolean hidePlayerNametagsInHiddenHud = false;
@SerialEntry public boolean hideArmorStandNametagsInHiddenHud = false;
@SerialEntry public int nametagOffset = 0;
@SerialEntry public Color nametagColor = new Color(0, 0, 0, 63);
@SerialEntry public boolean nametagTextShadow = false;
@SerialEntry public float nametagScale = 1F;

@SuppressWarnings("deprecation")
public static Screen configScreen(Screen parent) {
return YetAnotherConfigLib.create(CONFIG, ((defaults, config, builder) -> builder
.title(Text.literal("Nametag Tweaks"))
Expand Down Expand Up @@ -84,7 +85,7 @@ public static Screen configScreen(Screen parent) {
.build())
.option(Option.createBuilder(boolean.class)
.name(Text.literal("Nametag Text Shadow"))
.description(OptionDescription.of(Text.of("Adds a textshadow to nametags. The shadow renders in front of the regular text, which seems to be a vanilla Minecraft bug.")))
.description(OptionDescription.of(Text.of("Adds text shadow to nametags.")))
.binding(defaults.nametagTextShadow, () -> config.nametagTextShadow, newVal -> config.nametagTextShadow = newVal)
.controller(TickBoxControllerBuilder::create)
.build())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,66 @@
package dev.microcontrollers.nametagtweaks.mixin;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import dev.microcontrollers.nametagtweaks.NametagShadowFix;
import dev.microcontrollers.nametagtweaks.config.NametagTweaksConfig;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.Entity;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.text.Text;
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.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(EntityRenderer.class)
public class EntityRendererMixin<T extends Entity> {
@Shadow @Final private TextRenderer textRenderer;

@Inject(method = "renderLabelIfPresent", at = @At("HEAD"), cancellable = true)
//#if MC >= 1.20.6
public void hideNametags(T entity, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, float tickDelta, CallbackInfo ci) {
if (NametagTweaksConfig.CONFIG.getConfig().removeNametags ||
(NametagTweaksConfig.CONFIG.getConfig().hideEntityNametagsInHiddenHud && !MinecraftClient.isHudEnabled() && !entity.isPlayer()) ||
(NametagTweaksConfig.CONFIG.getConfig().hideArmorStandNametagsInHiddenHud && !MinecraftClient.isHudEnabled() && entity instanceof ArmorStandEntity))
//#else
//$$ public void hideNametags(T entity, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
//#endif
if (NametagTweaksConfig.CONFIG.instance().removeNametags ||
(NametagTweaksConfig.CONFIG.instance().hideEntityNametagsInHiddenHud && !MinecraftClient.isHudEnabled() && !entity.isPlayer()) ||
(NametagTweaksConfig.CONFIG.instance().hideArmorStandNametagsInHiddenHud && !MinecraftClient.isHudEnabled() && entity instanceof ArmorStandEntity))
ci.cancel();
}

@Inject(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Lnet/minecraft/text/Text;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;II)I", shift = At.Shift.BEFORE, ordinal = 0))
//#if MC >= 1.20.6
public void nametagScale(T entity, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, float tickDelta, CallbackInfo ci) {
float scale = NametagTweaksConfig.CONFIG.getConfig().nametagScale;
//#else
//$$ public void nametagScale(T entity, Text text, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, CallbackInfo ci) {
//#endif
float scale = NametagTweaksConfig.CONFIG.instance().nametagScale;
matrices.scale(scale, scale, scale);
}

@ModifyArg(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Lnet/minecraft/text/Text;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;II)I"), index = 2)
public float changeNametagHeight(float y) {
return y - NametagTweaksConfig.CONFIG.getConfig().nametagOffset;
return y - NametagTweaksConfig.CONFIG.instance().nametagOffset;
}

@ModifyArg(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Lnet/minecraft/text/Text;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;II)I"), index = 4)
public boolean addNametagShadow(boolean shadow) {
return NametagTweaksConfig.CONFIG.getConfig().nametagTextShadow;
@WrapOperation(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Lnet/minecraft/text/Text;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;II)I"))
private int addNametagShadow(TextRenderer instance, Text text, float x, float y, int color, boolean shadow, Matrix4f matrix, VertexConsumerProvider vertexConsumers, TextRenderer.TextLayerType layerType, int backgroundColor, int light, Operation<Integer> original) {
if (NametagTweaksConfig.CONFIG.instance().nametagTextShadow) ((NametagShadowFix) textRenderer).nametagTweaks$drawNametagShadow(text.asOrderedText(), x, y, color, true, matrix, vertexConsumers, layerType, backgroundColor, light);
return original.call(instance, text, x, y, color, shadow, matrix, vertexConsumers, layerType, backgroundColor, light);
}

@ModifyArg(method = "renderLabelIfPresent", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/font/TextRenderer;draw(Lnet/minecraft/text/Text;FFIZLorg/joml/Matrix4f;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/client/font/TextRenderer$TextLayerType;II)I", ordinal = 0), index = 8)
public int changeNametagBackground(int color) {
return NametagTweaksConfig.CONFIG.getConfig().nametagColor.getRGB();
return NametagTweaksConfig.CONFIG.instance().nametagColor.getRGB();
}

}
Loading

0 comments on commit 0f33620

Please sign in to comment.