This repository has been archived by the owner on Sep 15, 2024. It is now read-only.
generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb48f67
commit 0f33620
Showing
16 changed files
with
240 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,4 +34,4 @@ jobs: | |
uses: actions/upload-artifact@v4 | ||
with: | ||
name: Artifacts | ||
path: build/libs/ | ||
path: versions/**/build/libs/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()}" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
10 changes: 10 additions & 0 deletions
10
src/main/java/dev/microcontrollers/nametagtweaks/NametagShadowFix.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 27 additions & 9 deletions
36
src/main/java/dev/microcontrollers/nametagtweaks/mixin/EntityRendererMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
|
||
} |
Oops, something went wrong.