Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ plugins {
id "org.sonarqube" version "4.4.1.3373"
id "com.hypherionmc.modutils.modpublisher" version "2.1.4" apply false
// https://projects.neoforged.net/neoforged/moddevgradle
id "net.neoforged.moddev" version "2.0.126" apply false
id "net.neoforged.moddev" version "2.0.141" apply false
// https://fabricmc.net/develop/
id "fabric-loom" version "1.13-SNAPSHOT" apply false
id "net.fabricmc.fabric-loom" version "${fabric_loom_version}" apply false
}

sonar {
Expand All @@ -17,6 +17,11 @@ sonar {
}
}

tasks.named("updateDaemonJvm") {
languageVersion = JavaLanguageVersion.of(java_version as Integer)
toolchainPlatforms = []
}

tasks.register("publishAll") {
group = "publishing"
description = "Publish all loader specific versions to all platforms"
Expand Down
8 changes: 6 additions & 2 deletions buildSrc/src/main/groovy/multiloader-common.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
plugins {
id "idea"
id "java-library"
id "maven-publish"
id "com.hypherionmc.modutils.modpublisher"
Expand Down Expand Up @@ -116,7 +117,10 @@ processResources {
"fabric_loader_version" : fabric_loader_version,
"neoforge_version" : neoforge_version,
"neoforge_loader_version_range": neoforge_loader_version_range,
"prometheus_version" : prometheus_version
"prometheus_version" : prometheus_version,
"prometheus_minecraft_version" : prometheus_minecraft_version,
"cobweb_version" : cobweb_version,
"cobweb_minecraft_version" : cobweb_minecraft_version
]
filesMatching(["pack.mcmeta", "fabric.mod.json", "META-INF/neoforge.mods.toml", "META-INF/mods.toml", "*.mixins.json"]) {
expand expandProps
Expand Down Expand Up @@ -201,7 +205,7 @@ publisher {
}
setGameVersions(minecraft_version)
setDisplayName("[$loader - $minecraft_version] $mod_title v$mod_version")
setJavaVersions([JavaVersion.VERSION_21]) // Remember to update this to match java_version gradle property.
setJavaVersions([JavaVersion.VERSION_25]) // Remember to update this to match java_version gradle property.
setCurseEnvironment("client") // "server", "client" or "both".
github {
repo = "$github_user/$mod_id_kebab"
Expand Down
29 changes: 6 additions & 23 deletions buildSrc/src/main/groovy/multiloader-loader.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,27 @@ plugins {
id "multiloader-common"
}

configurations {
commonJava{
canBeResolved = true
}
commonResources{
canBeResolved = true
}
}

dependencies {
compileOnly(project(":common")) {
capabilities {
requireCapability "$group:$mod_id"
}
}
commonJava project(path: ":common", configuration: "commonJava")
commonResources project(path: ":common", configuration: "commonResources")
}

tasks.named('compileJava', JavaCompile) {
dependsOn(configurations.commonJava)
source(configurations.commonJava)
tasks.named("compileJava", JavaCompile) {
source(project(":common").sourceSets.main.allSource)
}

processResources {
dependsOn(configurations.commonResources)
from(configurations.commonResources)
from(project(":common").sourceSets.main.resources)
}

tasks.named("javadoc", Javadoc).configure {
dependsOn(configurations.commonJava)
source(configurations.commonJava)
tasks.named("javadoc", Javadoc) {
source(project(":common").sourceSets.main.allJava)
}

tasks.named("sourcesJar", Jar) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
dependsOn(configurations.commonJava)
from(configurations.commonJava)
dependsOn(configurations.commonResources)
from(configurations.commonResources)
from(project(":common").sourceSets.main.allSource)
}
39 changes: 13 additions & 26 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,44 +1,31 @@
plugins {
id "multiloader-common"
id "net.neoforged.moddev"
id "net.fabricmc.fabric-loom"
}

neoForge {
neoFormVersion = neo_form_version
def at = file("src/main/resources/META-INF/accesstransformer.cfg")
if (at.exists()) {
accessTransformers.from(at.absolutePath)
}
parchment {
minecraftVersion = parchment_minecraft
mappingsVersion = parchment_version
}
}
def minecraftClientJar = files(new File(gradle.gradleUserHomeDir, "caches/fabric-loom/${minecraft_version}/minecraft-client.jar"))

dependencies {
minecraft "com.mojang:minecraft:$minecraft_version"
compileOnly group: "org.spongepowered", name: "mixin", version: "0.8.5"
compileOnly group: "io.github.llamalad7", name: "mixinextras-common", version: "$mixin_extras_version"
annotationProcessor group: "io.github.llamalad7", name: "mixinextras-common", version: "$mixin_extras_version"
compileOnly "it.crystalnest:prometheus-$name:$minecraft_version-$prometheus_version"
compileOnly "it.crystalnest:prometheus-$name:$prometheus_minecraft_version-$prometheus_version"
compileOnly "it.crystalnest:cobweb-common:$cobweb_minecraft_version-$cobweb_version"
}

configurations {
commonJava {
canBeResolved = false
canBeConsumed = true
}
commonResources {
canBeResolved = false
canBeConsumed = true
}
}

artifacts {
commonJava sourceSets.main.java.sourceDirectories.singleFile
commonResources sourceSets.main.resources.sourceDirectories.singleFile
}

// Disable publishing tasks where common is not published
tasks.named("publishModrinth").get().setEnabled(false)
tasks.named("publishCurseforge").get().setEnabled(false)
tasks.named("publishGitHub").get().setEnabled(false)

tasks.named("compileJava", JavaCompile) {
classpath += minecraftClientJar + configurations.minecraftLibraries
}

tasks.named("javadoc", Javadoc) {
classpath += minecraftClientJar + configurations.minecraftLibraries
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@
import net.minecraft.client.gui.Font;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.renderer.LightTexture;
import net.minecraft.client.renderer.SubmitNodeCollector;
import net.minecraft.client.renderer.entity.ArmorModelSet;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.layers.CapeLayer;
import net.minecraft.client.renderer.entity.layers.HumanoidArmorLayer;
import net.minecraft.client.renderer.entity.player.AvatarRenderer;
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
import net.minecraft.client.renderer.state.CameraRenderState;
import net.minecraft.network.chat.Component;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.util.LightCoordsUtil;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Avatar;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Pose;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.phys.Vec3;
import net.minecraft.client.renderer.state.level.CameraRenderState;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.joml.Quaternionf;
Expand All @@ -34,6 +34,10 @@
* Custom player renderer.
*/
public class FancyPlayerRenderer extends AvatarRenderer<@NotNull AbstractClientPlayer> {
private static final float SLEEPING_EYE_HEIGHT = 0.2F;
private static final float CROUCHING_EYE_HEIGHT = 1.27F;
private static final float PRONE_EYE_HEIGHT = 0.4F;

/**
* Adult player model.
*/
Expand Down Expand Up @@ -78,11 +82,12 @@ public FancyPlayerRenderer(EntityRendererProvider.Context context, boolean isSli
* @param camera camera state.
*/
@Override
protected void submitNameTag(@NotNull AvatarRenderState renderState, @NotNull PoseStack poseStack, @NotNull SubmitNodeCollector submitNodeCollector, @NotNull CameraRenderState camera) {
protected void submitNameDisplay(@NotNull AvatarRenderState renderState, @NotNull PoseStack poseStack, @NotNull SubmitNodeCollector submitNodeCollector, @NotNull CameraRenderState camera) {
if (renderState instanceof FancyPlayerRenderState state && state.nameTag != null && state.nameTagAttachment != null) {
FormattedCharSequence text = state.nameTag.getVisualOrderText();
Minecraft minecraft = Minecraft.getInstance();
poseStack.pushPose();
int offset = state.showExtraEars ? -10 : 0;
float scale = state.scale * NAMETAG_SCALE;
float height = state.isBaby && state.pose != Pose.SPIN_ATTACK ? state.boundingBoxHeight * LivingEntity.DEFAULT_BABY_SCALE : state.boundingBoxHeight;
float offsetY = (state.pose == Pose.SLEEPING || state.pose == Pose.SWIMMING ? state.boundingBoxWidth : height) / scale + (float) state.nameTagAttachment.y;
Expand All @@ -95,9 +100,11 @@ protected void submitNameTag(@NotNull AvatarRenderState renderState, @NotNull Po
poseStack.rotateAround(Axis.ZP.rotationDegrees(Math.min(Mth.sqrt((state.deathTime - 1) / 20F * 1.6F), 1) * 90), 0, offsetY, 0);
}
float x = -minecraft.font.width(text) / 2F;
submitNodeCollector.submitText(poseStack, x, 0, text, false, Font.DisplayMode.SEE_THROUGH, state.lightCoords, -2130706433, (int) (minecraft.options.getBackgroundOpacity(0.25F) * 255F) << 24, 0);
submitNodeCollector.submitText(poseStack, x, 0, text, false, Font.DisplayMode.NORMAL, LightTexture.lightCoordsWithEmission(state.lightCoords, 2), state.isDiscrete ? -2130706433 : -1, 0, 0);
submitNodeCollector.submitText(poseStack, x, offset, text, false, Font.DisplayMode.SEE_THROUGH, state.lightCoords, -2130706433, (int) (minecraft.options.getBackgroundOpacity(0.25F) * 255F) << 24, 0);
submitNodeCollector.submitText(poseStack, x, offset, text, false, Font.DisplayMode.NORMAL, LightCoordsUtil.lightCoordsWithEmission(state.lightCoords, 2), state.isDiscrete ? -2130706433 : -1, 0, 0);
poseStack.popPose();
} else {
super.submitNameDisplay(renderState, poseStack, submitNodeCollector, camera);
}
}

Expand Down Expand Up @@ -202,7 +209,7 @@ protected void mimicRenderState(@NotNull FancyPlayerRenderState state, float hei
* @param state render state.
*/
protected void updateRenderState(@NotNull FancyPlayerRenderState state) {
state.eyeHeight = Avatar.POSES.get(state.pose).eyeHeight();
state.eyeHeight = getEyeHeight(state.pose);
state.isDiscrete = state.isCrouching || state.isInvisible;
if (state.isMoving && state.pose != Pose.DYING) {
float step = state.speedValue * 0.33F;
Expand All @@ -220,7 +227,7 @@ protected void updateRenderState(@NotNull FancyPlayerRenderState state) {
}
state.nameTag = state.showPlayerName && !state.isInvisibleToPlayer ? Component.literal(state.name) : null;
if (state.pose == Pose.SLEEPING) {
state.nameTagAttachment = new Vec3(Avatar.POSES.get(state.pose).eyeHeight() * state.scale - state.boundingBoxHeight / 1.35F, 0, 0);
state.nameTagAttachment = new Vec3(getEyeHeight(state.pose) * state.scale - state.boundingBoxHeight / 1.35F, 0, 0);
} else {
state.nameTagAttachment = new Vec3(0, 0.25F * state.scale, 0);
}
Expand All @@ -233,4 +240,13 @@ protected void updateRenderState(@NotNull FancyPlayerRenderState state) {
state.elytraRotX = (float) (Math.PI / 16);
state.elytraRotZ = (float) (Math.PI / 10);
}

private static float getEyeHeight(Pose pose) {
return switch (pose) {
case SLEEPING -> SLEEPING_EYE_HEIGHT;
case FALL_FLYING, SWIMMING, SPIN_ATTACK -> PRONE_EYE_HEIGHT;
case CROUCHING -> CROUCHING_EYE_HEIGHT;
default -> Avatar.DEFAULT_EYE_HEIGHT;
};
}
}
Loading
Loading