Compare commits
15
Commits
18b74212ca
...
0.1.4-beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37db94649f | ||
|
|
896f4cccc0 | ||
|
|
de3c554e63 | ||
|
|
8417427059 | ||
|
|
ba5a32fb34 | ||
|
|
8b1c94151a | ||
|
|
3623024cce | ||
|
|
2dcbe0302e | ||
|
|
502bddd720 | ||
|
|
0c22fee8c0 | ||
|
|
f69f6eb883 | ||
|
|
cebd9aec96 | ||
|
|
2554a84950 | ||
|
|
49bbdff418 | ||
|
|
8995de9067 |
+1
-1
Submodule common updated: 7d0bfd26c9...b0d75af8c4
+2
-2
@@ -6,10 +6,10 @@ org.gradle.caching=true
|
||||
# IntelliJ IDEA is not yet fully compatible with configuration cache, see: https://github.com/FabricMC/fabric-loom/issues/1349
|
||||
org.gradle.configuration-cache=false
|
||||
|
||||
mod_version=0.1.2-beta
|
||||
mod_version=0.1.4-beta
|
||||
|
||||
# Saturn's emote library (git.selimaj.dev/saturnclientmc/emotes)
|
||||
emotes_version=0.1.0
|
||||
emotes_version=0.1.1
|
||||
|
||||
# Loom, for every Minecraft version (read in settings.gradle.kts).
|
||||
loom_version=1.17.21
|
||||
|
||||
@@ -1,18 +1,28 @@
|
||||
package org.saturnclient.impl.cosmetics;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import org.joml.Matrix3f;
|
||||
import org.joml.Matrix4f;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.joml.Vector4f;
|
||||
import org.saturnclient.client.player.SaturnPlayer;
|
||||
import org.saturnclient.common.ref.asset.IdentifierRef;
|
||||
import org.saturnclient.config.Config;
|
||||
import org.saturnclient.cosmetics.Cloaks;
|
||||
import org.saturnclient.emotes.core.Animation;
|
||||
import org.saturnclient.emotes.core.Bone;
|
||||
import org.saturnclient.emotes.core.bend.LimbBend;
|
||||
import org.saturnclient.emotes.core.bend.Vec3;
|
||||
import org.saturnclient.emotes.fabric.access.BendablePart;
|
||||
import org.saturnclient.impl.cosmetics.utils.ShaderUtils;
|
||||
import org.saturnclient.saturnclient.SaturnRenderState;
|
||||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.OverlayTexture;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
//? if >=1.21.9 {
|
||||
@@ -33,7 +43,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.equipment.EquipmentAsset;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.RotationAxis;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
/**
|
||||
@@ -383,6 +392,50 @@ public class CloakFeatureRenderer extends FeatureRenderer<PlayerEntityRenderStat
|
||||
}
|
||||
}
|
||||
|
||||
/** A torso bend past this curves the back more than a flat cloak can follow. */
|
||||
private static final float MAX_CLOAK_BEND = (float) Math.toRadians(10);
|
||||
/** Whether each animation bends the torso past that at any point. */
|
||||
private static final Map<Animation, Boolean> BENDS_TORSO = Collections.synchronizedMap(new WeakHashMap<>());
|
||||
|
||||
/**
|
||||
* Whether the player is playing an emote that curves the torso (a twerk, the griddy). The cloak
|
||||
* would cut through the arched back, so it's hidden for the whole emote rather than only while
|
||||
* the back is curved, which would flicker.
|
||||
*/
|
||||
private static boolean playingTorsoBend(SaturnPlayer player) {
|
||||
return org.saturnclient.emotes.fabric.Emotes.playing(player.uuid)
|
||||
.map(playing -> BENDS_TORSO.computeIfAbsent(playing.animation(), CloakFeatureRenderer::bendsTorso))
|
||||
.orElse(false);
|
||||
}
|
||||
|
||||
private static boolean bendsTorso(Animation animation) {
|
||||
for (float tick = 0; tick <= animation.length(); tick += 0.5f) {
|
||||
if (animation.sample(tick).get(Bone.BODY).filter(body -> Math.abs(body.bend()) > MAX_CLOAK_BEND).isPresent()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* An emote that bends the torso a little leans the chest from the hips, so the cloak hangs from
|
||||
* where the top of the back ends up, turned as much as the torso is there.
|
||||
*/
|
||||
private static void followBend(MatrixStack matrices, ModelPart body) {
|
||||
LimbBend bend = ((BendablePart) (Object) body).saturnEmotes$getBend();
|
||||
if (bend == null || bend.isStraight()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The top of the torso, in the body's own pixels
|
||||
float[] top = new float[3];
|
||||
bend.bendPoint(0, 0, 0, top);
|
||||
matrices.translate(top[0] / 16.0f, top[1] / 16.0f, top[2] / 16.0f);
|
||||
|
||||
Vec3 axis = bend.axis();
|
||||
matrices.multiply(new Quaternionf().rotationAxis(bend.angleAt(0), axis.x(), axis.y(), axis.z()));
|
||||
}
|
||||
|
||||
// Shift array left and insert new value at the start
|
||||
private void updateSegmentValues(float value) {
|
||||
// Shift all elements one position to the right (from end to start)
|
||||
@@ -416,7 +469,7 @@ public class CloakFeatureRenderer extends FeatureRenderer<PlayerEntityRenderStat
|
||||
//?} else
|
||||
//SaturnPlayer player = SaturnPlayer.get(state.name);
|
||||
|
||||
if (player == null) {
|
||||
if (player == null || playingTorsoBend(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -436,17 +489,24 @@ public class CloakFeatureRenderer extends FeatureRenderer<PlayerEntityRenderStat
|
||||
|
||||
matrices.push();
|
||||
|
||||
// On the back: the whole player (which emotes like the backflip turn), then the body's position
|
||||
// and turn (which crouching and emotes move), then the chest's lean when an emote bends the torso
|
||||
PlayerEntityModel model = this.getContextModel();
|
||||
//? if >=1.21.5 {
|
||||
model.getRootPart().applyTransform(matrices);
|
||||
model.body.applyTransform(matrices);
|
||||
//?} else {
|
||||
/*model.getRootPart().rotate(matrices);
|
||||
model.body.rotate(matrices);
|
||||
*///?}
|
||||
followBend(matrices, model.body);
|
||||
|
||||
matrices.translate(0.0f, 0.0f, 0.12f);
|
||||
|
||||
if (this.hasCustomModelForLayer(state.equippedChestStack, LayerType.HUMANOID)) {
|
||||
matrices.translate(0.0F, -0.053125F, 0.06875F);
|
||||
}
|
||||
|
||||
if (state.isInSneakingPose) {
|
||||
matrices.translate(0, 0.16f, 0.0f);
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(29.0f));
|
||||
}
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
if (now - lastUpdate >= 20) {
|
||||
float velX = Math.min(0.8f, state.field_53537 / 108.0f);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.saturnclient.impl.cosmetics;
|
||||
|
||||
import org.joml.Quaternionf;
|
||||
import org.saturnclient.client.player.SaturnPlayer;
|
||||
import org.saturnclient.impl.cosmetics.obj.MtlLoader;
|
||||
import org.saturnclient.impl.cosmetics.obj.ObjModel;
|
||||
@@ -16,7 +15,6 @@ import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
||||
import net.minecraft.client.render.entity.model.PlayerEntityModel;
|
||||
import net.minecraft.client.render.entity.state.PlayerEntityRenderState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
|
||||
public class HatFeatureRenderer extends FeatureRenderer<PlayerEntityRenderState, PlayerEntityModel> {
|
||||
public HatFeatureRenderer(FeatureRendererContext<PlayerEntityRenderState, PlayerEntityModel> context) {
|
||||
@@ -41,11 +39,16 @@ public class HatFeatureRenderer extends FeatureRenderer<PlayerEntityRenderState,
|
||||
|
||||
matrices.push();
|
||||
|
||||
// On the head, as vanilla places head items: the whole player (which emotes like the backflip
|
||||
// turn), then the head's position, turn and scale (which crouching and emotes move)
|
||||
PlayerEntityModel model = this.getContextModel();
|
||||
//? if >=1.21.5 {
|
||||
ModelPart head = this.getContextModel().head;
|
||||
matrices.multiply(new Quaternionf().rotationZYX(head.roll, head.yaw, head.pitch));
|
||||
//?} else
|
||||
//this.getContextModel().head.rotate(matrices);
|
||||
model.getRootPart().applyTransform(matrices);
|
||||
model.head.applyTransform(matrices);
|
||||
//?} else {
|
||||
/*model.getRootPart().rotate(matrices);
|
||||
model.head.rotate(matrices);
|
||||
*///?}
|
||||
|
||||
ObjModel.cosmetic("hat", player.hat).render(MtlLoader.cosmetic(player.hat),
|
||||
matrices, output, light,
|
||||
|
||||
@@ -48,6 +48,9 @@ public final class GlassRenderer {
|
||||
.withLocation(Identifier.of("saturnclient", "pipeline/glass"))
|
||||
.withFragmentShader(Identifier.of("saturnclient", "core/glass"))
|
||||
.withSampler("Sampler1")
|
||||
// The transforms block ends with LineWidth before 1.21.11 (see glass.fsh).
|
||||
//? if <1.21.11
|
||||
//.withShaderDefine("HAS_LINE_WIDTH")
|
||||
.build();
|
||||
|
||||
private static final Identifier BLUR = Identifier.ofVanilla("post_effect/blur.json");
|
||||
|
||||
@@ -3,8 +3,18 @@
|
||||
// Saturn's glass: the blurred game behind the screen, cut to a panel's shape. For 1.21.6 and
|
||||
// later; glass_pre_1_21_6.fsh (with glass.json, the program 1.21.4 loads) is for older versions.
|
||||
|
||||
// Vanilla's own, since its layout changes between versions (1.21.11 dropped LineWidth)
|
||||
#moj_import <minecraft:dynamictransforms.glsl>
|
||||
// Vanilla's transforms, laid out as the version has them: 1.21.6 to 1.21.10 end with LineWidth, which
|
||||
// 1.21.11 dropped (GlassRenderer defines HAS_LINE_WIDTH there). Not imported: the include only exists
|
||||
// from 1.21.6, and 1.21.4 and 1.21.5 still read every shader's imports while loading resources.
|
||||
layout(std140) uniform DynamicTransforms {
|
||||
mat4 ModelViewMat;
|
||||
vec4 ColorModulator;
|
||||
vec3 ModelOffset;
|
||||
mat4 TextureMat;
|
||||
#ifdef HAS_LINE_WIDTH
|
||||
float LineWidth;
|
||||
#endif
|
||||
};
|
||||
|
||||
// The panel's rounded rectangle, the same texture its background is drawn with
|
||||
uniform sampler2D Sampler0;
|
||||
|
||||
Reference in New Issue
Block a user