mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 12:37:59 +01:00
WIP Updating to 1.21.3
This commit is contained in:
parent
1464b3318a
commit
f72fdaaebe
36 changed files with 262 additions and 295 deletions
|
@ -12,4 +12,9 @@ public interface HornedPonyModel<T extends EntityRenderState & PonyModel.Attribu
|
|||
return state instanceof PlayerEntityRenderState s
|
||||
&& (getArmPoseForSide(s, Arm.LEFT) != ArmPose.EMPTY || getArmPoseForSide(s, Arm.RIGHT) != ArmPose.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
default float getWobbleAmplitude(T state) {
|
||||
return isCasting(state) ? 0 : 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -111,6 +111,11 @@ public class ModelAttributes {
|
|||
*/
|
||||
public float wingAngle;
|
||||
|
||||
/**
|
||||
* Flag to indicate whether the wings are open or shut
|
||||
*/
|
||||
public boolean wingsSpread;
|
||||
|
||||
/**
|
||||
* Contains a list of additional skins available for rendering.
|
||||
*/
|
||||
|
@ -141,6 +146,7 @@ public class ModelAttributes {
|
|||
motionLerp = MathUtil.clampLimit(zMotion * 30, 1);
|
||||
|
||||
wingAngle = calcWingRotationFactor(ticks);
|
||||
wingsSpread = (isSwimming || isFlying || isCrouching) && (PonyConfig.getInstance().flappyElytras.get() || !isGliding);
|
||||
}
|
||||
|
||||
private float calcWingRotationFactor(float ticks) {
|
||||
|
|
|
@ -17,6 +17,10 @@ public interface PonyModel<T extends EntityRenderState & PonyModel.AttributedHol
|
|||
*/
|
||||
void transform(T state, BodyPart part, MatrixStack stack);
|
||||
|
||||
default float getWobbleAmplitude(T state) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public interface AttributedHolder {
|
||||
ModelAttributes getAttributes();
|
||||
|
||||
|
|
|
@ -1,22 +1,21 @@
|
|||
package com.minelittlepony.api.model;
|
||||
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.render.entity.state.BipedEntityRenderState;
|
||||
import net.minecraft.client.render.entity.state.EntityRenderState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
public interface SubModel<T extends BipedEntityRenderState & PonyModel.AttributedHolder> {
|
||||
/**
|
||||
* Sets the model's various rotation angles.
|
||||
*/
|
||||
default void setPartAngles(T state, float limbAngle, float limbSpeed, float bodySwing, float animationProgress) {
|
||||
|
||||
}
|
||||
|
||||
public interface SubModel<T extends EntityRenderState> {
|
||||
/**
|
||||
* Renders this model component.
|
||||
*/
|
||||
void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color);
|
||||
|
||||
/**
|
||||
* Sets the model's various rotation angles.
|
||||
*/
|
||||
default void setPartAngles(T state, float wobbleAmount) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether this part should be rendered.
|
||||
*/
|
||||
|
|
|
@ -2,8 +2,6 @@ package com.minelittlepony.api.model;
|
|||
|
||||
import net.minecraft.client.render.entity.state.BipedEntityRenderState;
|
||||
|
||||
import com.minelittlepony.api.config.PonyConfig;
|
||||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.util.MathUtil;
|
||||
|
||||
public interface WingedPonyModel<T extends BipedEntityRenderState & PonyModel.AttributedHolder> extends PonyModel<T> {
|
||||
|
@ -20,14 +18,7 @@ public interface WingedPonyModel<T extends BipedEntityRenderState & PonyModel.At
|
|||
* Returns true if the wings are spread.
|
||||
*/
|
||||
default boolean wingsAreOpen(T state) {
|
||||
return (state.getAttributes().isSwimming || state.getAttributes().isFlying || state.getAttributes().isCrouching)
|
||||
&& (PonyConfig.getInstance().flappyElytras.get() || !state.getAttributes().isGliding);
|
||||
}
|
||||
|
||||
default boolean isBurdened(T state) {
|
||||
return state.getAttributes().isWearing(Wearable.SADDLE_BAGS_BOTH)
|
||||
|| state.getAttributes().isWearing(Wearable.SADDLE_BAGS_LEFT)
|
||||
|| state.getAttributes().isWearing(Wearable.SADDLE_BAGS_RIGHT);
|
||||
return state.getAttributes().wingsSpread;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,8 +26,7 @@ public interface WingedPonyModel<T extends BipedEntityRenderState & PonyModel.At
|
|||
*
|
||||
* @param ticks Partial render ticks
|
||||
*/
|
||||
default float getWingRotationFactor(T state, float ticks) {
|
||||
default float getWingRotationFactor(T state) {
|
||||
return state.getAttributes().wingAngle;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package com.minelittlepony.api.pony.meta;
|
||||
|
||||
import net.minecraft.util.math.ColorHelper;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.minelittlepony.common.util.Color;
|
||||
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
@ -31,7 +32,7 @@ public interface Mats {
|
|||
return 0;
|
||||
}
|
||||
int[] color = raster.getPixel(x, y, new int[] {0, 0, 0, 0});
|
||||
return Color.argbToHex(color[3], color[0], color[1], color[2]);
|
||||
return ColorHelper.getArgb(color[3], color[0], color[1], color[2]);
|
||||
};
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IOException("Could not create mat from image", e);
|
||||
|
|
|
@ -5,8 +5,6 @@ import net.minecraft.util.math.ColorHelper;
|
|||
|
||||
import org.joml.Vector2i;
|
||||
|
||||
import com.minelittlepony.common.util.Color;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
|
@ -41,7 +39,7 @@ public interface TriggerPixel<T> {
|
|||
static TriggerPixel<Integer> ofColor(int x, int y) {
|
||||
MAX_COORDS.x = Math.max(MAX_COORDS.x, x);
|
||||
MAX_COORDS.y = Math.max(MAX_COORDS.y, y);
|
||||
return image -> Color.abgrToArgb(image.getColor(x, y));
|
||||
return image -> image.getColor(x, y);
|
||||
}
|
||||
|
||||
static <T extends Enum<T> & TValue<T>> TriggerPixel<Flags<T>> ofFlags(int x, int y, Flags<T> def, T[] options) {
|
||||
|
|
|
@ -127,23 +127,18 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
}
|
||||
|
||||
protected void setModelAngles(T entity) {
|
||||
setModelAngles((T)entity, entity.limbAmplitudeInverse, entity.limbAmplitudeMultiplier, entity.age, entity.yawDegrees, entity.pitch);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
protected final void setModelAngles(T entity, float limbAngle, float limbSpeed, float animationProgress, float headYaw, float headPitch) {
|
||||
float pitch = entity.attributes.motionPitch * MathHelper.RADIANS_PER_DEGREE;
|
||||
head.setAngles(
|
||||
MathHelper.clamp(entity.attributes.isSleeping ? 0.1f : headPitch / 57.29578F, -1.25f - pitch, 0.5f - pitch),
|
||||
entity.attributes.isSleeping ? (Math.signum(MathHelper.wrapDegrees(headYaw)) * 1.3F) : headYaw * MathHelper.RADIANS_PER_DEGREE,
|
||||
MathHelper.clamp(entity.attributes.isSleeping ? 0.1f : entity.pitch / 57.29578F, -1.25f - pitch, 0.5f - pitch),
|
||||
entity.attributes.isSleeping ? (Math.signum(MathHelper.wrapDegrees(entity.yawDegrees)) * 1.3F) : entity.yawDegrees * MathHelper.RADIANS_PER_DEGREE,
|
||||
0
|
||||
);
|
||||
|
||||
float wobbleAmount = entity.getWobbleAmount();
|
||||
float wobbleAmount = entity.wobbleAmount * getWobbleAmplitude(entity);
|
||||
body.yaw = wobbleAmount;
|
||||
neck.yaw = wobbleAmount;
|
||||
|
||||
rotateLegs(entity, limbAngle, limbSpeed, animationProgress);
|
||||
rotateLegs(entity);
|
||||
|
||||
ArmPose left = getArmPose(entity, Arm.LEFT);
|
||||
ArmPose right = getArmPose(entity, Arm.RIGHT);
|
||||
|
@ -153,7 +148,8 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
}
|
||||
|
||||
if (!entity.attributes.isSwimming && !entity.attributes.isGoingFast) {
|
||||
holdItem(entity, limbSpeed, left, right);
|
||||
alignArmForAction(entity, getArm(Arm.LEFT), left, right, 1);
|
||||
alignArmForAction(entity, getArm(Arm.RIGHT), right, left, -1);
|
||||
}
|
||||
swingItem(entity);
|
||||
|
||||
|
@ -165,7 +161,7 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
adjustBody(entity, 0, ORIGIN);
|
||||
|
||||
if (!entity.attributes.isLyingDown) {
|
||||
animateBreathing(entity, animationProgress, left, right);
|
||||
animateBreathing(entity, left, right);
|
||||
}
|
||||
|
||||
if (entity.attributes.isSwimmingRotated) {
|
||||
|
@ -184,7 +180,7 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
head.pitch = 0.5F;
|
||||
}
|
||||
|
||||
parts.forEach(part -> part.setPartAngles(entity, limbAngle, limbSpeed, wobbleAmount, animationProgress));
|
||||
parts.forEach(part -> part.setPartAngles(entity, wobbleAmount));
|
||||
}
|
||||
|
||||
public void setHeadRotation(float animationProgress, float yaw, float pitch) {
|
||||
|
@ -249,11 +245,11 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
* Takes the same parameters as {@link AbstractPonyModel.setRotationAndAngles}
|
||||
*
|
||||
*/
|
||||
protected void rotateLegs(T state, float move, float swing, float ticks) {
|
||||
protected void rotateLegs(T state) {
|
||||
if (state.attributes.isSwimming) {
|
||||
rotateLegsSwimming(state, move, swing, ticks);
|
||||
rotateLegsSwimming(state, state.limbAmplitudeInverse, state.limbAmplitudeMultiplier, state.age);
|
||||
} else {
|
||||
rotateLegsOnGround(state, move, swing, ticks);
|
||||
rotateLegsOnGround(state, state.limbAmplitudeInverse, state.limbAmplitudeMultiplier, state.age);
|
||||
}
|
||||
|
||||
float sin = MathHelper.sin(body.yaw) * 5;
|
||||
|
@ -327,14 +323,6 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
rightLeg.setAngles(MathHelper.lerp(rainboomLegLotation, MathHelper.cos(baseRotation + angle / 5) * scale, MathUtil.Angles._90_DEG * rainboomLegLotation), -yAngle, rightLeg.roll);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts legs as if holding an item. Delegates to the correct arm/leg/limb as necessary.
|
||||
*/
|
||||
protected void holdItem(T state, float limbSpeed, ArmPose left, ArmPose right) {
|
||||
alignArmForAction(state, getArm(Arm.LEFT), left, right, limbSpeed, 1);
|
||||
alignArmForAction(state, getArm(Arm.RIGHT), right, left, limbSpeed, -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModelPart getBodyPart(BodyPart part) {
|
||||
switch (part) {
|
||||
|
@ -355,7 +343,7 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
* @param pose The post to align to
|
||||
* @param limbSpeed Degree to which each 'limb' swings.
|
||||
*/
|
||||
protected void alignArmForAction(T state, ModelPart arm, ArmPose pose, ArmPose complement, float limbSpeed, float sigma) {
|
||||
protected void alignArmForAction(T state, ModelPart arm, ArmPose pose, ArmPose complement, float sigma) {
|
||||
switch (pose) {
|
||||
case ITEM:
|
||||
arm.yaw = 0;
|
||||
|
@ -365,13 +353,13 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
if (state.attributes.shouldLiftArm(pose, complement, sigma)) {
|
||||
float swag = 1;
|
||||
if (!state.attributes.isFlying && both) {
|
||||
swag -= (float)Math.pow(limbSpeed, 2);
|
||||
swag -= (float)Math.pow(state.limbAmplitudeMultiplier, 2);
|
||||
}
|
||||
|
||||
float mult = 1 - swag/2;
|
||||
arm.pitch = arm.pitch * mult - (MathHelper.PI / 10) * swag;
|
||||
arm.roll = -sigma * (MathHelper.PI / 15);
|
||||
arm.roll += 0.3F * -limbSpeed * sigma;
|
||||
arm.roll += 0.3F * -state.limbAmplitudeMultiplier * sigma;
|
||||
|
||||
if (state.attributes.isCrouching) {
|
||||
arm.pivotX -= sigma * 2;
|
||||
|
@ -385,7 +373,7 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
case BLOCK:
|
||||
arm.pitch = (arm.pitch / 2 - 0.9424779F) - 0.3F;
|
||||
arm.yaw = sigma * MathHelper.PI / 9;
|
||||
arm.roll += 0.3F * -limbSpeed * sigma;
|
||||
arm.roll += 0.3F * -state.limbAmplitudeMultiplier * sigma;
|
||||
if (complement == pose) {
|
||||
arm.yaw -= sigma * MathHelper.PI / 18;
|
||||
}
|
||||
|
@ -396,24 +384,24 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
}
|
||||
break;
|
||||
case BOW_AND_ARROW:
|
||||
aimBow(state, arm, limbSpeed);
|
||||
aimBow(state, arm);
|
||||
break;
|
||||
case CROSSBOW_HOLD:
|
||||
aimBow(state, arm, limbSpeed);
|
||||
aimBow(state, arm);
|
||||
|
||||
arm.pitch = head.pitch - MathUtil.Angles._90_DEG;
|
||||
arm.yaw = head.yaw + 0.06F;
|
||||
break;
|
||||
case CROSSBOW_CHARGE:
|
||||
aimBow(state, arm, limbSpeed);
|
||||
aimBow(state, arm);
|
||||
|
||||
arm.pitch = -0.8F;
|
||||
arm.yaw = head.yaw + 0.06F;
|
||||
arm.roll += 0.3F * -limbSpeed * sigma;
|
||||
arm.roll += 0.3F * -state.limbAmplitudeMultiplier * sigma;
|
||||
break;
|
||||
case THROW_SPEAR:
|
||||
arm.pitch = MathUtil.Angles._90_DEG * 2;
|
||||
arm.roll += (0.3F * -limbSpeed + 0.6F) * sigma;
|
||||
arm.roll += (0.3F * -state.limbAmplitudeMultiplier + 0.6F) * sigma;
|
||||
arm.pivotY ++;
|
||||
break;
|
||||
case SPYGLASS:
|
||||
|
@ -427,10 +415,10 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
arm.pivotX -= 6 * sigma;
|
||||
arm.pivotZ -= 2;
|
||||
}
|
||||
if (state.getSize() == SizePreset.TALL) {
|
||||
if (state.size == SizePreset.TALL) {
|
||||
arm.pivotY += 1;
|
||||
}
|
||||
if (state.getSize() == SizePreset.FOAL) {
|
||||
if (state.size == SizePreset.FOAL) {
|
||||
arm.pivotY -= 2;
|
||||
}
|
||||
|
||||
|
@ -439,22 +427,22 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
arm.pitch = MathHelper.clamp(head.pitch, -0.55f, 1.2f) - 1.7835298f;
|
||||
arm.yaw = head.yaw - 0.1235988f * sigma;
|
||||
arm.pivotY += 3;
|
||||
arm.roll += 0.3F * -limbSpeed * sigma;
|
||||
arm.roll += 0.3F * -state.limbAmplitudeMultiplier * sigma;
|
||||
break;
|
||||
case BRUSH:
|
||||
arm.pitch = arm.pitch * 0.5f - 0.62831855f;
|
||||
arm.yaw = 0;
|
||||
arm.roll += 0.3F * -limbSpeed * sigma;
|
||||
arm.roll += 0.3F * -state.limbAmplitudeMultiplier * sigma;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected void aimBow(T state, ModelPart arm, float limbSpeed) {
|
||||
arm.pitch = MathUtil.Angles._270_DEG + head.pitch + (MathHelper.sin(limbSpeed * 0.067F) * 0.05F);
|
||||
protected final void aimBow(T state, ModelPart arm) {
|
||||
arm.pitch = MathUtil.Angles._270_DEG + head.pitch + (MathHelper.sin(state.limbAmplitudeMultiplier * 0.067F) * 0.05F);
|
||||
arm.yaw = head.yaw - 0.06F;
|
||||
arm.roll = MathHelper.cos(limbSpeed * 0.09F) * 0.05F + 0.05F;
|
||||
arm.roll = MathHelper.cos(state.limbAmplitudeMultiplier * 0.09F) * 0.05F + 0.05F;
|
||||
|
||||
if (state.isInSneakingPose) {
|
||||
arm.pivotY += 4;
|
||||
|
@ -466,7 +454,7 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
*
|
||||
* @param entity The entity we are being called for.
|
||||
*/
|
||||
protected void swingItem(T state) {
|
||||
protected final void swingItem(T state) {
|
||||
if (state.getSwingAmount() > 0 && !state.attributes.isLyingDown) {
|
||||
swingArm(state, getArm(state.preferredArm));
|
||||
}
|
||||
|
@ -477,7 +465,7 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
*
|
||||
* @param arm The arm to swing
|
||||
*/
|
||||
protected void swingArm(T state, ModelPart arm) {
|
||||
protected final void swingArm(T state, ModelPart arm) {
|
||||
float swing = 1 - (float)Math.pow(1 - state.getSwingAmount(), 3);
|
||||
|
||||
float deltaX = MathHelper.sin(swing * MathHelper.PI);
|
||||
|
@ -496,9 +484,9 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
* @param animationProgress Total whole and partial ticks since the entity's existence.
|
||||
* Used in animations together with {@code swing} and {@code move}.
|
||||
*/
|
||||
protected void animateBreathing(T state, float animationProgress, ArmPose left, ArmPose right) {
|
||||
float cos = MathHelper.cos(animationProgress * 0.09F) * 0.05F + 0.05F;
|
||||
float sin = MathHelper.sin(animationProgress * 0.067F) * 0.05F;
|
||||
protected void animateBreathing(T state, ArmPose left, ArmPose right) {
|
||||
float cos = MathHelper.cos(state.age * 0.09F) * 0.05F + 0.05F;
|
||||
float sin = MathHelper.sin(state.age * 0.067F) * 0.05F;
|
||||
|
||||
if (state.attributes.shouldLiftArm(right, left, -1)) {
|
||||
ModelPart arm = getArm(Arm.RIGHT);
|
||||
|
@ -596,6 +584,6 @@ public abstract class AbstractPonyModel<T extends PonyRenderState> extends Clien
|
|||
neck.hidden = !head.visible;
|
||||
}
|
||||
|
||||
PonyTransformation.forSize(state.getSize()).transform(state.attributes, part, stack);
|
||||
PonyTransformation.forSize(state.size).transform(state.attributes, part, stack);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.jetbrains.annotations.Nullable;
|
|||
|
||||
import com.minelittlepony.api.model.*;
|
||||
import com.minelittlepony.client.render.entity.state.PonyRenderState;
|
||||
import com.minelittlepony.mson.api.MsonModel;
|
||||
|
||||
/**
|
||||
* The raw pony model without any implementations.
|
||||
|
@ -17,7 +16,7 @@ import com.minelittlepony.mson.api.MsonModel;
|
|||
*
|
||||
* Modders can extend this class to make their own pony models if they wish.
|
||||
*/
|
||||
public abstract class ClientPonyModel<T extends PonyRenderState> extends PlayerEntityModel implements MsonModel, PonyModel<T> {
|
||||
public abstract class ClientPonyModel<T extends PonyRenderState> extends PlayerEntityModel implements PonyModel<T> {
|
||||
@Nullable
|
||||
protected PosingCallback<T> onSetModelAngles;
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.minelittlepony.client.model.entity;
|
|||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import com.minelittlepony.client.render.entity.EnderStallionRenderer;
|
||||
|
||||
|
@ -54,14 +53,4 @@ public class EnderStallionModel extends SkeleponyModel<EnderStallionRenderer.Sta
|
|||
leftPants.visible = false;
|
||||
rightPants.visible = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean wingsAreOpen(EnderStallionRenderer.State state) {
|
||||
return state.isAttacking;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWingRotationFactor(EnderStallionRenderer.State state, float ticks) {
|
||||
return MathHelper.sin(ticks) + WINGS_HALF_SPREAD_ANGLE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class IllagerPonyModel<S extends IllagerPonyRenderer.State> extends Alico
|
|||
arm.roll = mult * MathHelper.cos(state.age * 0.6662F) / 4;
|
||||
arm.yaw = mult * 1.1F;
|
||||
} else if (pose == IllagerEntity.State.BOW_AND_ARROW) {
|
||||
aimBow(state, arm, state.age);
|
||||
aimBow(state, arm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,8 +56,8 @@ public class PiglinPonyModel extends ZomponyModel<PonyPiglinRenderer.State> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void rotateLegs(PonyPiglinRenderer.State state, float move, float swing, float ticks) {
|
||||
super.rotateLegs(state, move, swing, ticks);
|
||||
protected void rotateLegs(PonyPiglinRenderer.State state) {
|
||||
super.rotateLegs(state);
|
||||
|
||||
if (state.activity == PiglinActivity.ADMIRING_ITEM) {
|
||||
leftArm.yaw = 0.5F;
|
||||
|
@ -65,13 +65,13 @@ public class PiglinPonyModel extends ZomponyModel<PonyPiglinRenderer.State> {
|
|||
leftArm.pivotY += 4;
|
||||
leftArm.pivotZ += 3;
|
||||
leftArm.pivotX += 2;
|
||||
head.pitch = MathHelper.sin(ticks / 12) / 6 + 0.5F;
|
||||
head.pitch = MathHelper.sin(state.age / 12) / 6 + 0.5F;
|
||||
head.yaw = 0;
|
||||
|
||||
head.roll = MathHelper.sin(ticks / 10) / 3F;
|
||||
head.roll = MathHelper.sin(state.age / 10) / 3F;
|
||||
} else if (state.activity == PiglinActivity.DANCING) {
|
||||
|
||||
float speed = ticks / 60;
|
||||
float speed = state.age / 60;
|
||||
|
||||
head.pivotX = MathHelper.sin(speed * 10);
|
||||
head.pivotY = MathHelper.sin(speed * 40) + 0.4F;
|
||||
|
|
|
@ -12,8 +12,8 @@ public class ZomponyModel<T extends ZomponyRenderer.State> extends AlicornModel<
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void rotateLegs(T state, float move, float swing, float ticks) {
|
||||
super.rotateLegs(state, move, swing, ticks);
|
||||
protected void rotateLegs(T state) {
|
||||
super.rotateLegs(state);
|
||||
if (shouldLiftBothArms(state)) {
|
||||
MobPosingHelper.rotateUndeadArms(state, this, state.limbFrequency, state.age);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class ChangelingModel<T extends PonyRenderState> extends AlicornModel<T>
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getWingRotationFactor(T state, float ticks) {
|
||||
return state.attributes.isFlying ? MathHelper.sin(ticks * 3) + WINGS_HALF_SPREAD_ANGLE : WINGS_RAISED_ANGLE;
|
||||
public float getWingRotationFactor(T state) {
|
||||
return state.attributes.isFlying ? MathHelper.sin(state.age * 3) + WINGS_HALF_SPREAD_ANGLE : WINGS_RAISED_ANGLE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -71,8 +71,8 @@ public class SeaponyModel<T extends PonyRenderState> extends UnicornModel<T> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void rotateLegs(T state, float move, float swing, float ticks) {
|
||||
super.rotateLegs(state, move, swing, ticks);
|
||||
protected void rotateLegs(T state) {
|
||||
super.rotateLegs(state);
|
||||
leftArm.pitch -= 1.4F;
|
||||
leftArm.yaw -= 0.3F;
|
||||
rightArm.pitch -= 1.4F;
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.minelittlepony.client.model.entity.race;
|
|||
|
||||
import com.minelittlepony.api.config.PonyConfig;
|
||||
import com.minelittlepony.api.model.*;
|
||||
import com.minelittlepony.api.pony.meta.Size;
|
||||
import com.minelittlepony.api.pony.meta.SizePreset;
|
||||
import com.minelittlepony.client.model.part.UnicornHorn;
|
||||
import com.minelittlepony.client.render.entity.state.PonyRenderState;
|
||||
|
@ -11,7 +10,6 @@ import com.minelittlepony.mson.util.RenderList;
|
|||
|
||||
import net.minecraft.client.model.ModelPart;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.consume.UseAction;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.util.*;
|
||||
|
@ -43,13 +41,8 @@ public class UnicornModel<T extends PonyRenderState> extends EarthPonyModel<T> i
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getWobbleAmount() {
|
||||
return isCasting(currentState) ? 0 : super.getWobbleAmount();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rotateLegs(T state, float move, float swing, float ticks) {
|
||||
super.rotateLegs(state, move, swing, ticks);
|
||||
protected void rotateLegs(T state) {
|
||||
super.rotateLegs(state);
|
||||
|
||||
unicornArmRight.setAngles(0, 0, 0);
|
||||
unicornArmRight.setPivot(-7, 12, -2);
|
||||
|
@ -97,13 +90,12 @@ public class UnicornModel<T extends PonyRenderState> extends EarthPonyModel<T> i
|
|||
}
|
||||
if (main == arm) {
|
||||
if (action == UseAction.SPYGLASS) {
|
||||
Size size = state.getSize();
|
||||
float x = 0.3F;
|
||||
float z = -0.4F;
|
||||
|
||||
if (size == SizePreset.TALL || size == SizePreset.YEARLING) {
|
||||
if (state.size == SizePreset.TALL || state.size == SizePreset.YEARLING) {
|
||||
z += 0.05F;
|
||||
} else if (size == SizePreset.FOAL) {
|
||||
} else if (state.size == SizePreset.FOAL) {
|
||||
x -= 0.1F;
|
||||
z -= 0.1F;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class SaddleBags extends WearableGear {
|
|||
rightBag.pitch = bodySwing;
|
||||
|
||||
if (model instanceof WingedPonyModel pegasus && state.getAttributes().isFlying) {
|
||||
bodySwing = pegasus.getWingRotationFactor(state, ticks) - MathUtil.Angles._270_DEG;
|
||||
bodySwing = pegasus.getWingRotationFactor(state) - MathUtil.Angles._270_DEG;
|
||||
bodySwing /= 10;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,18 +18,18 @@ public class LionTail implements SubModel<PonyRenderState> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setPartAngles(PonyRenderState state, float limbAngle, float limbSpeed, float bodySwing, float animationProgress) {
|
||||
public void setPartAngles(PonyRenderState state, float bodySwing) {
|
||||
tail.resetTransform();
|
||||
|
||||
bodySwing *= 5;
|
||||
|
||||
float baseSail = 1F;
|
||||
|
||||
float speed = limbSpeed > 0.01F ? 6 : 90;
|
||||
float speed = state.limbAmplitudeMultiplier > 0.01F ? 6 : 90;
|
||||
Interpolator interpolator = state.attributes.getMainInterpolator();
|
||||
|
||||
float straightness = 1.6F * (1 + (float)Math.sin(animationProgress / speed) / 8F);
|
||||
float twist = (float)Math.sin(Math.PI/2F + 2 * animationProgress / speed) / 16F;
|
||||
float straightness = 1.6F * (1 + (float)Math.sin(state.age / speed) / 8F);
|
||||
float twist = (float)Math.sin(Math.PI/2F + 2 * state.age / speed) / 16F;
|
||||
float bend = state.attributes.motionRoll / 80F;
|
||||
|
||||
if (state.attributes.isCrouching) {
|
||||
|
@ -46,11 +46,11 @@ public class LionTail implements SubModel<PonyRenderState> {
|
|||
bend = interpolator.interpolate("kirin_tail_bendiness", bend, 10);
|
||||
|
||||
tail.pitch = baseSail;
|
||||
tail.pitch += limbSpeed / 2;
|
||||
tail.pitch += state.limbAmplitudeMultiplier / 2;
|
||||
tail.yaw = twist;
|
||||
tail.roll = bodySwing * 2;
|
||||
|
||||
float sinTickFactor = MathHelper.sin(animationProgress * 0.067f) * 0.05f;
|
||||
float sinTickFactor = MathHelper.sin(state.age * 0.067f) * 0.05f;
|
||||
tail.pitch += sinTickFactor;
|
||||
tail.yaw += sinTickFactor;
|
||||
|
||||
|
|
|
@ -27,11 +27,11 @@ public class PonyEars implements SubModel<PonyRenderState>, MsonModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setPartAngles(PonyRenderState state, float limbAngle, float limbSpeed, float bodySwing, float animationProgress) {
|
||||
public void setPartAngles(PonyRenderState state, float bodySwing) {
|
||||
right.resetTransform();
|
||||
left.resetTransform();
|
||||
|
||||
limbSpeed = MathHelper.clamp(limbSpeed, 0, 1);
|
||||
float limbSpeed = MathHelper.clamp(state.limbAmplitudeMultiplier, 0, 1);
|
||||
|
||||
float forwardFold = 0.14F * limbSpeed;
|
||||
float sidewaysFlop = 0.11F * limbSpeed;
|
||||
|
@ -42,12 +42,12 @@ public class PonyEars implements SubModel<PonyRenderState>, MsonModel {
|
|||
right.roll -= sidewaysFlop;
|
||||
left.roll += sidewaysFlop;
|
||||
|
||||
float floppyness = Math.abs(MathHelper.sin(animationProgress / 99F));
|
||||
float floppyness = Math.abs(MathHelper.sin(state.age / 99F));
|
||||
if (floppyness > 0.99F) {
|
||||
boolean leftFlop = MathHelper.sin(animationProgress / 5F) > 0.5F;
|
||||
boolean leftFlop = MathHelper.sin(state.age / 5F) > 0.5F;
|
||||
(leftFlop ? left : right).roll +=
|
||||
0.01F * MathHelper.sin(animationProgress / 2F)
|
||||
+ 0.015F * MathHelper.cos(animationProgress / 3F);
|
||||
0.01F * MathHelper.sin(state.age / 2F)
|
||||
+ 0.015F * MathHelper.cos(state.age / 3F);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,9 +44,9 @@ public class PonyTail implements SubModel<PonyRenderState>, MsonModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setPartAngles(PonyRenderState state, float limbAngle, float limbSpeed, float bodySwing, float animationProgress) {
|
||||
public void setPartAngles(PonyRenderState state, float bodySwing) {
|
||||
boolean rainboom = state.attributes.isSwimming || state.attributes.isGoingFast;
|
||||
tail.roll = rainboom ? 0 : MathHelper.cos(limbAngle * 0.8F) * 0.2f * limbSpeed;
|
||||
tail.roll = rainboom ? 0 : MathHelper.cos(state.limbAmplitudeInverse * 0.8F) * 0.2f * state.limbAmplitudeMultiplier;
|
||||
tail.yaw = bodySwing * 5;
|
||||
|
||||
if (state.attributes.isCrouching && !rainboom) {
|
||||
|
@ -59,11 +59,11 @@ public class PonyTail implements SubModel<PonyRenderState>, MsonModel {
|
|||
} else {
|
||||
tail.setPivot(0, 0, TAIL_Z);
|
||||
if (rainboom) {
|
||||
tail.pitch = MathUtil.Angles._90_DEG + MathHelper.sin(limbAngle) / 10;
|
||||
tail.pitch = MathUtil.Angles._90_DEG + MathHelper.sin(state.limbAmplitudeInverse) / 10;
|
||||
} else {
|
||||
tail.pitch = limbSpeed / 2;
|
||||
tail.pitch = state.limbAmplitudeMultiplier / 2;
|
||||
|
||||
swingX(animationProgress);
|
||||
swingX(state.age);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,17 +57,17 @@ public class PonyWings<S extends PonyRenderState> implements SubModel<S>, MsonMo
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setPartAngles(S state, float move, float swing, float bodySwing, float ticks) {
|
||||
public void setPartAngles(S state, float bodySwing) {
|
||||
float flap = 0;
|
||||
float progress = state.getSwingAmount();
|
||||
|
||||
if (progress > 0) {
|
||||
flap = MathHelper.sin(MathHelper.sqrt(progress) * MathHelper.TAU);
|
||||
} else {
|
||||
float pi = MathHelper.PI * (float) Math.pow(swing, 16);
|
||||
float pi = MathHelper.PI * (float) Math.pow(state.limbAmplitudeMultiplier, 16);
|
||||
|
||||
float mve = move * 0.6662f; // magic number ahoy (actually 2/3)
|
||||
float srt = swing / 4;
|
||||
float mve = state.limbAmplitudeInverse * 0.6662f; // magic number ahoy (actually 2/3)
|
||||
float srt = state.limbAmplitudeMultiplier * 0.25F;
|
||||
|
||||
flap = MathHelper.cos(mve + pi) * srt;
|
||||
}
|
||||
|
@ -75,12 +75,12 @@ public class PonyWings<S extends PonyRenderState> implements SubModel<S>, MsonMo
|
|||
float flapAngle = MathUtil.Angles._270_DEG;
|
||||
|
||||
if (pegasus.wingsAreOpen(state)) {
|
||||
flapAngle = pegasus.getWingRotationFactor(state, ticks);
|
||||
if (!state.attributes.isCrouching && pegasus.isBurdened(state)) {
|
||||
flapAngle = pegasus.getWingRotationFactor(state);
|
||||
if (!state.attributes.isCrouching && isBurdened(state)) {
|
||||
flapAngle -= 1F;
|
||||
}
|
||||
} else {
|
||||
flapAngle = MathUtil.Angles._270_DEG - 0.9F + (float)Math.sin(ticks / 10) / 15F;
|
||||
flapAngle = MathUtil.Angles._270_DEG - 0.9F + (float)Math.sin(state.age * 0.1F) / 15F;
|
||||
}
|
||||
|
||||
if (!state.attributes.isFlying) {
|
||||
|
@ -114,6 +114,13 @@ public class PonyWings<S extends PonyRenderState> implements SubModel<S>, MsonMo
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isBurdened(S state) {
|
||||
return state.getAttributes().isWearing(Wearable.SADDLE_BAGS_BOTH)
|
||||
|| state.getAttributes().isWearing(Wearable.SADDLE_BAGS_LEFT)
|
||||
|| state.getAttributes().isWearing(Wearable.SADDLE_BAGS_RIGHT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderPart(MatrixStack stack, VertexConsumer vertices, int overlay, int light, int color) {
|
||||
leftWing.render(stack, vertices, overlay, light, color);
|
||||
|
|
|
@ -22,8 +22,8 @@ public class SeaponyTail implements SubModel<PonyRenderState>, MsonModel {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setPartAngles(PonyRenderState state, float limbAngle, float limbSpeed, float bodySwing, float animationProgress) {
|
||||
float rotation = state.attributes.isLyingDown ? 0 : MathHelper.sin(animationProgress * 0.536f) / 4;
|
||||
public void setPartAngles(PonyRenderState state, float bodySwing) {
|
||||
float rotation = state.attributes.isLyingDown ? 0 : MathHelper.sin(state.age * 0.536f) / 4;
|
||||
|
||||
tailBase.pitch = MathHelper.HALF_PI + rotation;
|
||||
tailTip.pitch = rotation;
|
||||
|
|
|
@ -37,7 +37,7 @@ public final class DebugBoundingBoxRenderer {
|
|||
}
|
||||
|
||||
public static Box getBoundingBox(PonyRenderState state) {
|
||||
final float scale = state.getScaleFactor();
|
||||
final float scale = state.size.scaleFactor();
|
||||
final float width = state.width * scale;
|
||||
final float height = state.height * scale;
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public class EquineRenderManager<
|
|||
}
|
||||
|
||||
public void setupTransforms(S state, MatrixStack stack, float animationProgress, float bodyYaw) {
|
||||
float s = state.getScaleFactor();
|
||||
float s = state.size.scaleFactor();
|
||||
stack.scale(s, s, s);
|
||||
|
||||
if (state instanceof PlayerEntityRenderState && state.attributes.isSitting) {
|
||||
|
|
|
@ -6,7 +6,6 @@ import com.minelittlepony.client.model.ModelType;
|
|||
import com.minelittlepony.client.model.armour.ArmourRendererPlugin;
|
||||
import com.minelittlepony.client.render.MobRenderers;
|
||||
import com.minelittlepony.client.render.entity.*;
|
||||
import com.minelittlepony.common.util.Color;
|
||||
|
||||
import net.minecraft.block.AbstractSkullBlock;
|
||||
import net.minecraft.block.SkullBlock;
|
||||
|
@ -18,16 +17,17 @@ import net.minecraft.client.render.VertexConsumer;
|
|||
import net.minecraft.client.render.VertexConsumerProvider;
|
||||
import net.minecraft.client.render.block.entity.SkullBlockEntityModel;
|
||||
import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer;
|
||||
import net.minecraft.client.render.entity.state.LivingEntityRenderState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.ProfileComponent;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.equipment.EquipmentModel.LayerType;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Util;
|
||||
import net.minecraft.util.math.ColorHelper;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -60,13 +60,13 @@ public class PonySkullRenderer {
|
|||
headModels = SkullBlockEntityRenderer.getModels(MinecraftClient.getInstance().getEntityModelLoader());
|
||||
}
|
||||
|
||||
public void renderSkull(MatrixStack matrices, VertexConsumerProvider provider, ItemStack stack, LivingEntity entity, float tickDelta, int light, boolean isPony) {
|
||||
public void renderSkull(MatrixStack matrices, VertexConsumerProvider provider, ItemStack stack, LivingEntityRenderState entity, float tickDelta, int light, boolean isPony) {
|
||||
isBeingWorn = true;
|
||||
this.isPony = isPony;
|
||||
SkullType type = ((AbstractSkullBlock) ((BlockItem) stack.getItem()).getBlock()).getSkullType();
|
||||
SkullBlockEntityModel skullBlockEntityModel = headModels.get(type);
|
||||
RenderLayer renderLayer = SkullBlockEntityRenderer.getRenderLayer(type, stack.get(DataComponentTypes.PROFILE));
|
||||
SkullBlockEntityRenderer.renderSkull(null, 180, (entity.getVehicle() instanceof LivingEntity l ? l : entity).limbAnimator.getPos(tickDelta), matrices, provider, light, skullBlockEntityModel, renderLayer);
|
||||
SkullBlockEntityRenderer.renderSkull(null, 180, entity.headItemAnimationProgress, matrices, provider, light, skullBlockEntityModel, renderLayer);
|
||||
isBeingWorn = false;
|
||||
this.isPony = false;
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class PonySkullRenderer {
|
|||
VertexConsumer vertices = renderContext.getBuffer(layer);
|
||||
|
||||
selectedSkull.setAngles(yaw, animationProgress);
|
||||
selectedSkull.render(stack, vertices, light, OverlayTexture.DEFAULT_UV, Color.argbToHex(ArmourRendererPlugin.INSTANCE.get().getArmourAlpha(EquipmentSlot.HEAD, LayerType.HUMANOID), 1, 1, 1));
|
||||
selectedSkull.render(stack, vertices, light, OverlayTexture.DEFAULT_UV, ColorHelper.fromFloats(ArmourRendererPlugin.INSTANCE.get().getArmourAlpha(EquipmentSlot.HEAD, LayerType.HUMANOID), 1, 1, 1));
|
||||
|
||||
stack.pop();
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import net.minecraft.client.render.VertexConsumerProvider;
|
|||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.render.entity.MobEntityRenderer;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
||||
import net.minecraft.client.render.entity.feature.HeadFeatureRenderer;
|
||||
import net.minecraft.client.render.entity.state.PlayerEntityRenderState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
|
@ -58,7 +59,7 @@ public abstract class AbstractPonyRenderer<
|
|||
protected void addFeatures(EntityRendererFactory.Context context) {
|
||||
addFeature(new ArmourFeature<>(this, context.getEquipmentModelLoader()));
|
||||
addPonyFeature(createHeldItemFeature(context));
|
||||
addFeature(new SkullFeature<>(this, context.getModelLoader(), context.getItemRenderer()));
|
||||
addFeature(createSkullFeature(context));
|
||||
addPonyFeature(new ElytraFeature<>(this, context.getEquipmentRenderer()));
|
||||
addFeature(new GearFeature<>(this));
|
||||
}
|
||||
|
@ -71,6 +72,10 @@ public abstract class AbstractPonyRenderer<
|
|||
return ((List)features).add(feature);
|
||||
}
|
||||
|
||||
protected SkullFeature<S, M> createSkullFeature(EntityRendererFactory.Context context) {
|
||||
return new SkullFeature<>(this, context.getModelLoader(), context.getItemRenderer(), HeadFeatureRenderer.HeadTransformation.DEFAULT, true);
|
||||
}
|
||||
|
||||
protected HeldItemFeature<S, M> createHeldItemFeature(EntityRendererFactory.Context context) {
|
||||
return new HeldItemFeature<>(this, context.getItemRenderer());
|
||||
}
|
||||
|
@ -92,13 +97,13 @@ public abstract class AbstractPonyRenderer<
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender(T state, Frustum visibleRegion, double camX, double camY, double camZ) {
|
||||
return super.shouldRender(state, manager.getFrustrum(state, visibleRegion), camX, camY, camZ);
|
||||
public boolean shouldRender(T entity, Frustum visibleRegion, double camX, double camY, double camZ) {
|
||||
return super.shouldRender(entity, manager.getFrustrum(entity, visibleRegion), camX, camY, camZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scale(S state, MatrixStack stack) {
|
||||
shadowRadius = state.getShadowSize();
|
||||
shadowRadius = state.size.shadowSize();
|
||||
|
||||
if (state.baby) {
|
||||
shadowRadius *= 3; // undo vanilla shadow scaling
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.minelittlepony.client.render.entity;
|
||||
|
||||
import com.minelittlepony.api.model.ModelAttributes;
|
||||
import com.minelittlepony.api.model.PonyModel;
|
||||
import com.minelittlepony.api.model.*;
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
import com.minelittlepony.api.pony.meta.Race;
|
||||
import com.minelittlepony.client.MineLittlePony;
|
||||
|
@ -21,6 +20,7 @@ import net.minecraft.entity.LivingEntity;
|
|||
import net.minecraft.entity.mob.EndermanEntity;
|
||||
import net.minecraft.util.Arm;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -92,6 +92,9 @@ public class EnderStallionRenderer extends PonyRenderer<EndermanEntity, EnderSta
|
|||
leftHandStack = carriedBlock.getBlock().asItem().getDefaultStack();
|
||||
}
|
||||
}
|
||||
|
||||
attributes.wingsSpread = isAttacking;
|
||||
attributes.wingAngle = MathHelper.sin(age) + WingedPonyModel.WINGS_HALF_SPREAD_ANGLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -52,6 +52,7 @@ public class PlayerPonyRenderer
|
|||
addPonyFeatures(context);
|
||||
}
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
protected void addPonyFeatures(EntityRendererFactory.Context context) {
|
||||
// remove vanilla features (keep modded ones)
|
||||
features.removeIf(feature -> {
|
||||
|
@ -67,8 +68,8 @@ public class PlayerPonyRenderer
|
|||
addPonyFeature(new HeldItemFeature<>(this, context.getItemRenderer()));
|
||||
addPonyFeature(new DJPon3Feature<>(this));
|
||||
addFeature(new CapeFeature(this, context.getModelLoader(), context.getEquipmentModelLoader()));
|
||||
addPonyFeature(new SkullFeature<>(this, context.getModelLoader(), context.getItemRenderer()));
|
||||
addPonyFeature(new ElytraFeature<>(this, context.getEquipmentRenderer()));
|
||||
addPonyFeature(new SkullFeature<>(this, context.getModelLoader(), context.getItemRenderer(), HeadFeatureRenderer.HeadTransformation.DEFAULT, true));
|
||||
addPonyFeature(new ElytraFeature(this, context.getEquipmentRenderer()));
|
||||
addPonyFeature(new PassengerFeature<>(this, context));
|
||||
addPonyFeature(new GearFeature<>(this));
|
||||
}
|
||||
|
@ -83,7 +84,7 @@ public class PlayerPonyRenderer
|
|||
|
||||
public Vec3d getPositionOffset(PlayerEntityRenderState state) {
|
||||
Vec3d offset = super.getPositionOffset(state);
|
||||
return offset.add(state.baseScale * ((PlayerPonyRenderState)state).yOffset).multiply(((PonyRenderState)state).getScaleFactor());
|
||||
return offset.add(state.baseScale * ((PlayerPonyRenderState)state).yOffset).multiply(((PonyRenderState)state).size.scaleFactor());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -112,7 +113,7 @@ public class PlayerPonyRenderer
|
|||
@Override
|
||||
public void render(PlayerEntityRenderState state, MatrixStack stack, VertexConsumerProvider vertices, int light) {
|
||||
// EntityModelFeatures: We have to force it to use our models otherwise EMF overrides it and breaks pony rendering
|
||||
shadowRadius = ((PlayerPonyRenderState)state).getShadowSize();
|
||||
shadowRadius = ((PlayerPonyRenderState)state).size.shadowSize();
|
||||
super.render(state, stack, vertices, light);
|
||||
DebugBoundingBoxRenderer.render((PlayerPonyRenderState)state, stack, vertices);
|
||||
|
||||
|
|
|
@ -7,36 +7,86 @@ import net.minecraft.client.render.entity.model.ArmorStandArmorEntityModel;
|
|||
import net.minecraft.client.render.entity.state.ArmorStandEntityRenderState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.decoration.ArmorStandEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import com.minelittlepony.api.model.ModelAttributes.Mode;
|
||||
import com.minelittlepony.api.model.Models;
|
||||
import com.minelittlepony.api.pony.Pony;
|
||||
import com.minelittlepony.api.pony.PonyData;
|
||||
import com.minelittlepony.api.pony.meta.Wearable;
|
||||
import com.minelittlepony.client.model.ModelType;
|
||||
import com.minelittlepony.client.model.armour.PonifiedEquipmentRenderer;
|
||||
import com.minelittlepony.client.model.entity.PonyArmourStandModel;
|
||||
import com.minelittlepony.client.model.entity.race.EarthPonyModel;
|
||||
import com.minelittlepony.client.render.EquineRenderManager;
|
||||
import com.minelittlepony.client.render.PonyRenderContext;
|
||||
import com.minelittlepony.client.render.entity.feature.*;
|
||||
import com.minelittlepony.client.render.entity.state.PonyRenderState;
|
||||
|
||||
public class PonyStandRenderer extends ArmorStandEntityRenderer {
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public class PonyStandRenderer extends ArmorStandEntityRenderer implements PonyRenderContext<ArmorStandEntity, PonyRenderState, EarthPonyModel<PonyRenderState>> {
|
||||
static final Pony PONY = new Pony(Identifier.ofVanilla("null"), () -> Optional.of(PonyData.NULL));
|
||||
private final PonyArmourStandModel pony = ModelType.ARMOUR_STAND.createModel();
|
||||
private final Models<EarthPonyModel<PonyRenderState>> models = ModelType.EARTH_PONY.create(false);
|
||||
|
||||
private final ArmorStandArmorEntityModel human;
|
||||
|
||||
private final EquineRenderManager<ArmorStandEntity, PonyRenderState, EarthPonyModel<PonyRenderState>> manager;
|
||||
|
||||
public PonyStandRenderer(EntityRendererFactory.Context context) {
|
||||
super(context);
|
||||
human = model;
|
||||
this.manager = new EquineRenderManager<>(this, (state, stack, progress, yaw) -> {}, models);
|
||||
|
||||
Predicate<ArmorStandEntityRenderState> swapPredicate = state -> ((State)state).hasPonyForm;
|
||||
Function<ArmorStandEntityRenderState, PonyRenderState> converter = state -> ((State)state).ponyState;
|
||||
|
||||
for (int i = 0; i < features.size(); i++) {
|
||||
var feature = features.get(i);
|
||||
if (feature instanceof ArmorFeatureRenderer) {
|
||||
features.set(i, new SwappableFeature<>(this, feature, new Armour(this, context), state -> ((State)state).hasPonyForm));
|
||||
features.set(i, new SwappableFeature<>(this, feature, new Armour(context), swapPredicate, converter));
|
||||
}
|
||||
if (feature instanceof ElytraFeatureRenderer) {
|
||||
features.set(i, new SwappableFeature<>(this, feature, new ElytraFeature<>(this, context.getEquipmentRenderer()), state -> ((State)state).hasPonyForm));
|
||||
features.set(i, new SwappableFeature<>(this,
|
||||
feature,
|
||||
new ElytraFeature<>(() -> models.body(), context.getEquipmentRenderer()), swapPredicate, converter));
|
||||
}
|
||||
if (feature instanceof HeadFeatureRenderer) {
|
||||
features.set(i, new SwappableFeature<>(this,
|
||||
feature,
|
||||
new SkullFeature<PonyRenderState, EarthPonyModel<PonyRenderState>>(
|
||||
this,
|
||||
context.getModelLoader(),
|
||||
context.getItemRenderer(),
|
||||
HeadFeatureRenderer.HeadTransformation.DEFAULT,
|
||||
false
|
||||
), swapPredicate, converter));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//addFeature(new HeadFeatureRenderer<>(this, context.getModelLoader(), context.getItemRenderer()));
|
||||
|
||||
@Override
|
||||
public Identifier getDefaultTexture(PonyRenderState entity, Wearable wearable) {
|
||||
return wearable.getDefaultTexture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Pony getEntityPony(ArmorStandEntity entity) {
|
||||
return PONY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EquineRenderManager<ArmorStandEntity, PonyRenderState, EarthPonyModel<PonyRenderState>> getInternalRenderer() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setModel(EarthPonyModel<PonyRenderState> model) { }
|
||||
|
||||
@Override
|
||||
public ArmorStandEntityRenderState createRenderState() {
|
||||
return new State();
|
||||
|
@ -48,6 +98,8 @@ public class PonyStandRenderer extends ArmorStandEntityRenderer {
|
|||
super.updateRenderState(entity, state, tickDelta);
|
||||
((State)state).hasPonyForm = ponified;
|
||||
if (ponified) {
|
||||
BipedEntityRenderer.updateBipedRenderState(entity, ((State)state).ponyState, tickDelta);
|
||||
manager.updateState(entity, ((State)state).ponyState, Mode.OTHER);
|
||||
state.pitch = 0.017453292F * entity.getHeadRotation().getPitch();
|
||||
state.yawDegrees = 0.017453292F * entity.getHeadRotation().getYaw();
|
||||
}
|
||||
|
@ -64,20 +116,18 @@ public class PonyStandRenderer extends ArmorStandEntityRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
class Armour extends FeatureRenderer<ArmorStandEntityRenderState, ArmorStandArmorEntityModel> {
|
||||
private final Models<EarthPonyModel<PonyRenderState>> pony = ModelType.EARTH_PONY.create(false);
|
||||
|
||||
class Armour extends FeatureRenderer<PonyRenderState, EarthPonyModel<PonyRenderState>> {
|
||||
private final PonifiedEquipmentRenderer equipmentRenderer;
|
||||
|
||||
public Armour(FeatureRendererContext<ArmorStandEntityRenderState, ArmorStandArmorEntityModel> renderer, EntityRendererFactory.Context context) {
|
||||
super(renderer);
|
||||
public Armour(EntityRendererFactory.Context context) {
|
||||
super(() -> models.body());
|
||||
equipmentRenderer = new PonifiedEquipmentRenderer(context.getEquipmentModelLoader());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider vertices, int light, ArmorStandEntityRenderState state, float limbAngle, float limbDistance) {
|
||||
pony.body().setAngles(((State)state).ponyState);
|
||||
ArmourFeature.renderArmor(pony, matrices, vertices, light, ((State)state).ponyState, limbDistance, limbAngle, equipmentRenderer);
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider vertices, int light, PonyRenderState state, float limbAngle, float limbDistance) {
|
||||
getContextModel().setAngles(state);
|
||||
ArmourFeature.renderArmor(models, matrices, vertices, light, state, limbDistance, limbAngle, equipmentRenderer);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@ import com.minelittlepony.client.model.entity.race.SeaponyModel;
|
|||
import com.minelittlepony.client.render.entity.npc.textures.TextureSupplier;
|
||||
import com.minelittlepony.client.render.entity.state.PonyRenderState;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.render.entity.EntityRendererFactory;
|
||||
import net.minecraft.client.render.entity.GuardianEntityRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
@ -50,8 +50,8 @@ public class SeaponyRenderer extends PonyRenderer<GuardianEntity, SeaponyRendere
|
|||
super.updateRenderState(entity, state, tickDelta);
|
||||
state.spikesExtension = entity.getSpikesExtension(tickDelta);
|
||||
state.tailAngle = entity.getTailAngle(tickDelta);
|
||||
state.cameraPosVec = getScaledCameraPosVec(entity, tickDelta, state.getScaleFactor());
|
||||
Entity cameraBeamTarget = getBeamTarget(entity);
|
||||
state.cameraPosVec = getScaledCameraPosVec(entity, tickDelta, state.size.scaleFactor());
|
||||
Entity cameraBeamTarget = GuardianEntityRenderer.getBeamTarget(entity);
|
||||
state.rotationVec = cameraBeamTarget != null ? entity.getRotationVec(tickDelta) : null;
|
||||
state.lookAtPos = cameraBeamTarget != null ? cameraBeamTarget.getCameraPosVec(tickDelta) : null;
|
||||
|
||||
|
@ -73,7 +73,7 @@ public class SeaponyRenderer extends PonyRenderer<GuardianEntity, SeaponyRendere
|
|||
float f = state.beamTicks * 0.5F % 1.0F;
|
||||
matrices.push();
|
||||
matrices.translate(0.0F, state.standingEyeHeight, 0.0F);
|
||||
renderBeam(
|
||||
GuardianEntityRenderer.renderBeam(
|
||||
matrices,
|
||||
vertices.getBuffer(LAYER),
|
||||
vec3d.subtract(state.cameraPosVec),
|
||||
|
@ -85,71 +85,6 @@ public class SeaponyRenderer extends PonyRenderer<GuardianEntity, SeaponyRendere
|
|||
}
|
||||
}
|
||||
|
||||
private static void renderBeam(MatrixStack matrices, VertexConsumer vertexConsumer, Vec3d vec3d, float beamTicks, float f, float g) {
|
||||
float h = (float)(vec3d.length() + 1.0);
|
||||
vec3d = vec3d.normalize();
|
||||
float i = (float)Math.acos(vec3d.y);
|
||||
float j = (float) (Math.PI / 2) - (float)Math.atan2(vec3d.z, vec3d.x);
|
||||
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(j * (180.0F / (float)Math.PI)));
|
||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(i * (180.0F / (float)Math.PI)));
|
||||
float k = beamTicks * 0.05F * -1.5F;
|
||||
float l = f * f;
|
||||
int m = 64 + (int)(l * 191.0F);
|
||||
int n = 32 + (int)(l * 191.0F);
|
||||
int o = 128 - (int)(l * 64.0F);
|
||||
float p = 0.2F;
|
||||
float q = 0.282F;
|
||||
float r = MathHelper.cos(k + (float) (Math.PI * 3.0 / 4.0)) * 0.282F;
|
||||
float s = MathHelper.sin(k + (float) (Math.PI * 3.0 / 4.0)) * 0.282F;
|
||||
float t = MathHelper.cos(k + (float) (Math.PI / 4)) * 0.282F;
|
||||
float u = MathHelper.sin(k + (float) (Math.PI / 4)) * 0.282F;
|
||||
float v = MathHelper.cos(k + ((float) Math.PI * 5.0F / 4.0F)) * 0.282F;
|
||||
float w = MathHelper.sin(k + ((float) Math.PI * 5.0F / 4.0F)) * 0.282F;
|
||||
float x = MathHelper.cos(k + ((float) Math.PI * 7.0F / 4.0F)) * 0.282F;
|
||||
float y = MathHelper.sin(k + ((float) Math.PI * 7.0F / 4.0F)) * 0.282F;
|
||||
float z = MathHelper.cos(k + (float) Math.PI) * 0.2F;
|
||||
float aa = MathHelper.sin(k + (float) Math.PI) * 0.2F;
|
||||
float ab = MathHelper.cos(k + 0.0F) * 0.2F;
|
||||
float ac = MathHelper.sin(k + 0.0F) * 0.2F;
|
||||
float ad = MathHelper.cos(k + (float) (Math.PI / 2)) * 0.2F;
|
||||
float ae = MathHelper.sin(k + (float) (Math.PI / 2)) * 0.2F;
|
||||
float af = MathHelper.cos(k + (float) (Math.PI * 3.0 / 2.0)) * 0.2F;
|
||||
float ag = MathHelper.sin(k + (float) (Math.PI * 3.0 / 2.0)) * 0.2F;
|
||||
float ai = 0.0F;
|
||||
float aj = 0.4999F;
|
||||
float ak = -1.0F + g;
|
||||
float al = ak + h * 2.5F;
|
||||
MatrixStack.Entry entry = matrices.peek();
|
||||
vertex(vertexConsumer, entry, z, h, aa, m, n, o, 0.4999F, al);
|
||||
vertex(vertexConsumer, entry, z, 0.0F, aa, m, n, o, 0.4999F, ak);
|
||||
vertex(vertexConsumer, entry, ab, 0.0F, ac, m, n, o, 0.0F, ak);
|
||||
vertex(vertexConsumer, entry, ab, h, ac, m, n, o, 0.0F, al);
|
||||
vertex(vertexConsumer, entry, ad, h, ae, m, n, o, 0.4999F, al);
|
||||
vertex(vertexConsumer, entry, ad, 0.0F, ae, m, n, o, 0.4999F, ak);
|
||||
vertex(vertexConsumer, entry, af, 0.0F, ag, m, n, o, 0.0F, ak);
|
||||
vertex(vertexConsumer, entry, af, h, ag, m, n, o, 0.0F, al);
|
||||
float am = MathHelper.floor(beamTicks) % 2 == 0 ? 0.5F : 0.0F;
|
||||
vertex(vertexConsumer, entry, r, h, s, m, n, o, 0.5F, am + 0.5F);
|
||||
vertex(vertexConsumer, entry, t, h, u, m, n, o, 1.0F, am + 0.5F);
|
||||
vertex(vertexConsumer, entry, x, h, y, m, n, o, 1.0F, am);
|
||||
vertex(vertexConsumer, entry, v, h, w, m, n, o, 0.5F, am);
|
||||
}
|
||||
|
||||
private static void vertex(VertexConsumer vertexConsumer, MatrixStack.Entry matrix, float x, float y, float z, int red, int green, int blue, float u, float v) {
|
||||
vertexConsumer.vertex(matrix, x, y, z)
|
||||
.color(red, green, blue, 255)
|
||||
.texture(u, v)
|
||||
.overlay(OverlayTexture.DEFAULT_UV)
|
||||
.light(LightmapTextureManager.MAX_LIGHT_COORDINATE)
|
||||
.normal(matrix, 0.0F, 1.0F, 0.0F);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Entity getBeamTarget(GuardianEntity guardian) {
|
||||
Entity entity = MinecraftClient.getInstance().getCameraEntity();
|
||||
return guardian.hasBeamTarget() ? guardian.getBeamTarget() : entity;
|
||||
}
|
||||
|
||||
private Vec3d fromLerpedPosition(LivingEntity entity, double yOffset, float delta) {
|
||||
double d = MathHelper.lerp((double)delta, entity.lastRenderX, entity.getX());
|
||||
double e = MathHelper.lerp((double)delta, entity.lastRenderY, entity.getY()) + yOffset;
|
||||
|
|
|
@ -11,8 +11,6 @@ import net.minecraft.client.render.VertexConsumerProvider;
|
|||
import net.minecraft.client.render.entity.equipment.EquipmentRenderer;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRenderer;
|
||||
import net.minecraft.client.render.entity.feature.FeatureRendererContext;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.render.entity.state.BipedEntityRenderState;
|
||||
import net.minecraft.client.render.entity.state.PlayerEntityRenderState;
|
||||
import net.minecraft.client.util.SkinTextures;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
@ -24,8 +22,8 @@ import net.minecraft.item.equipment.EquipmentModel;
|
|||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class ElytraFeature<
|
||||
S extends BipedEntityRenderState,
|
||||
M extends EntityModel<S>
|
||||
S extends PonyRenderState,
|
||||
M extends ClientPonyModel<S>
|
||||
> extends FeatureRenderer<S, M> {
|
||||
private static final Identifier TEXTURE = Identifier.ofVanilla("textures/entity/elytra.png");
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ public class GearFeature<
|
|||
}
|
||||
|
||||
private void renderGear(M model, S entity, Gear gear, MatrixStack stack, VertexConsumerProvider renderContext, int lightUv, float limbDistance, float limbAngle, float tickDelta) {
|
||||
gear.pose(model, entity, entity.attributes.isGoingFast, entity.attributes.getEntityId(), limbDistance, limbAngle, entity.getWobbleAmount(), tickDelta);
|
||||
gear.pose(model, entity, entity.attributes.isGoingFast, entity.attributes.getEntityId(), limbDistance, limbAngle, entity.wobbleAmount * model.getWobbleAmplitude(entity), tickDelta);
|
||||
gear.render(stack, renderContext.getBuffer(gear.getLayer(entity, getContext())), lightUv, OverlayTexture.DEFAULT_UV, Colors.WHITE, entity.attributes.getEntityId());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.minelittlepony.client.render.entity.feature;
|
||||
|
||||
import com.minelittlepony.api.model.BodyPart;
|
||||
import com.minelittlepony.api.model.PonyModel;
|
||||
import com.minelittlepony.client.model.ClientPonyModel;
|
||||
import com.minelittlepony.client.model.armour.ArmourLayer;
|
||||
import com.minelittlepony.client.model.armour.ArmourRendererPlugin;
|
||||
|
@ -12,27 +11,31 @@ import com.minelittlepony.client.render.entity.state.PonyRenderState;
|
|||
import net.minecraft.block.AbstractSkullBlock;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.render.entity.feature.HeadFeatureRenderer;
|
||||
import net.minecraft.client.render.entity.model.EntityModel;
|
||||
import net.minecraft.client.render.entity.model.EntityModelLoader;
|
||||
import net.minecraft.client.render.entity.state.BipedEntityRenderState;
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.component.DataComponentTypes;
|
||||
import net.minecraft.component.type.EquippableComponent;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.mob.ZombieVillagerEntity;
|
||||
import net.minecraft.entity.passive.VillagerEntity;
|
||||
import net.minecraft.item.*;
|
||||
|
||||
public class SkullFeature<
|
||||
T extends LivingEntity,
|
||||
S extends PonyRenderState,
|
||||
M extends ClientPonyModel<S>
|
||||
> extends AbstractPonyFeature<S, M> {
|
||||
private final ItemRenderer itemRenderer;
|
||||
|
||||
public SkullFeature(PonyRenderContext<T, S, M> renderPony, EntityModelLoader entityModelLoader, ItemRenderer itemRenderer) {
|
||||
super(renderPony);
|
||||
private final HeadFeatureRenderer.HeadTransformation headTransformation;
|
||||
|
||||
private final boolean scaleForChild;
|
||||
|
||||
public SkullFeature(PonyRenderContext<?, S, M> context, EntityModelLoader entityModelLoader, ItemRenderer itemRenderer,
|
||||
HeadFeatureRenderer.HeadTransformation headTransformation, boolean scaleForChild) {
|
||||
super(context);
|
||||
this.itemRenderer = itemRenderer;
|
||||
this.headTransformation = headTransformation;
|
||||
this.scaleForChild = scaleForChild;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,16 +43,20 @@ public class SkullFeature<
|
|||
ArmourRendererPlugin plugin = ArmourRendererPlugin.INSTANCE.get();
|
||||
|
||||
for (ItemStack stack : plugin.getArmorStacks(state, EquipmentSlot.HEAD, ArmourLayer.OUTER, ArmourRendererPlugin.ArmourType.SKULL)) {
|
||||
if (stack.isEmpty()) {
|
||||
|
||||
BakedModel headModel = state.equippedHeadItemModel;
|
||||
|
||||
if (stack.isEmpty() || headModel == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
M model = getModelWrapper().body();
|
||||
Item item = stack.getItem();
|
||||
EquippableComponent equipable = stack.get(DataComponentTypes.EQUIPPABLE);
|
||||
|
||||
matrices.push();
|
||||
|
||||
if (state.baby && !(state instanceof VillagerEntity)) {
|
||||
if (state.baby && scaleForChild) {
|
||||
matrices.translate(0, 0.03125F, 0);
|
||||
matrices.scale(0.7F, 0.7F, 0.7F);
|
||||
matrices.translate(0, 1, 0);
|
||||
|
@ -58,8 +65,6 @@ public class SkullFeature<
|
|||
model.transform(state, BodyPart.HEAD, matrices);
|
||||
model.getHead().rotate(matrices);
|
||||
|
||||
boolean isVillager = state instanceof VillagerEntity || state instanceof ZombieVillagerEntity;
|
||||
|
||||
float f = 1.1F;
|
||||
matrices.scale(f, f, f);
|
||||
|
||||
|
@ -69,10 +74,10 @@ public class SkullFeature<
|
|||
matrices.translate(0, -0.1F, 0.1F);
|
||||
matrices.translate(-0.5, 0, -0.5);
|
||||
PonySkullRenderer.INSTANCE.renderSkull(matrices, provider, stack, state, state.age, light, true);
|
||||
} else if (!(item instanceof ArmorItem a) || a.getSlotType() != EquipmentSlot.HEAD) {
|
||||
} else if (equipable != null && equipable.slot() != EquipmentSlot.HEAD) {
|
||||
matrices.translate(0, 0.1F, -0.1F);
|
||||
HeadFeatureRenderer.translate(matrices, isVillager);
|
||||
itemRenderer.renderItem(state, stack, ModelTransformationMode.HEAD, false, matrices, provider, entity.getWorld(), light, OverlayTexture.DEFAULT_UV, entity.getId() + ModelTransformationMode.HEAD.ordinal());
|
||||
HeadFeatureRenderer.translate(matrices, headTransformation);
|
||||
itemRenderer.renderItem(stack, ModelTransformationMode.HEAD, false, matrices, provider, light, OverlayTexture.DEFAULT_UV, headModel);
|
||||
}
|
||||
|
||||
matrices.pop();
|
||||
|
|
|
@ -7,29 +7,42 @@ import net.minecraft.client.render.entity.model.EntityModel;
|
|||
import net.minecraft.client.render.entity.state.EntityRenderState;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
public final class SwappableFeature<S extends EntityRenderState, M extends EntityModel<? super S>> extends FeatureRenderer<S, M> {
|
||||
public final class SwappableFeature<
|
||||
S extends EntityRenderState,
|
||||
M extends EntityModel<? super S>,
|
||||
P extends EntityRenderState,
|
||||
N extends EntityModel<? super P>
|
||||
> extends FeatureRenderer<S, M> {
|
||||
|
||||
private final FeatureRenderer<S, M> normal;
|
||||
private final FeatureRenderer<S, M> swapped;
|
||||
private final FeatureRenderer<P, N> swapped;
|
||||
|
||||
private final Predicate<S> swapCondition;
|
||||
private final Function<S, P> stateConverter;
|
||||
|
||||
public SwappableFeature(
|
||||
FeatureRendererContext<S, M> context,
|
||||
FeatureRenderer<S, M> normal,
|
||||
FeatureRenderer<S, M> swapped,
|
||||
Predicate<S> swapCondition
|
||||
FeatureRenderer<P, N> swapped,
|
||||
Predicate<S> swapCondition,
|
||||
Function<S, P> stateConverter
|
||||
) {
|
||||
super(context);
|
||||
this.normal = normal;
|
||||
this.swapped = swapped;
|
||||
this.swapCondition = swapCondition;
|
||||
this.stateConverter = stateConverter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(MatrixStack matrices, VertexConsumerProvider vertices, int light, S state, float limbAngle, float limbDistance) {
|
||||
(swapCondition.test(state) ? swapped : normal).render(matrices, vertices, light, state, limbAngle, limbDistance);
|
||||
if (swapCondition.test(state)) {
|
||||
swapped.render(matrices, vertices, light, stateConverter.apply(state), limbAngle, limbDistance);
|
||||
} else {
|
||||
normal.render(matrices, vertices, light, state, limbAngle, limbDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ public class PonyRenderState extends PlayerEntityRenderState implements PonyMode
|
|||
public float riderOffset;
|
||||
public float nameplateYOffset;
|
||||
public float legOutset;
|
||||
public float wobbleAmount;
|
||||
public boolean smallArms;
|
||||
public boolean sleepingInBed;
|
||||
public boolean submergedInWater;
|
||||
|
@ -31,6 +32,7 @@ public class PonyRenderState extends PlayerEntityRenderState implements PonyMode
|
|||
public boolean isTechnoblade;
|
||||
|
||||
public Pony pony;
|
||||
public Size size;
|
||||
|
||||
public void updateState(LivingEntity entity, PonyModel<?> model, Pony pony, ModelAttributes.Mode mode) {
|
||||
this.pony = pony;
|
||||
|
@ -43,6 +45,7 @@ public class PonyRenderState extends PlayerEntityRenderState implements PonyMode
|
|||
isInSneakingPose = attributes.isCrouching && !attributes.isLyingDown;
|
||||
sleepingInBed = entity.getSleepingPosition().isPresent() && entity.getEntityWorld().getBlockState(entity.getSleepingPosition().get()).getBlock() instanceof BedBlock;
|
||||
submergedInWater = entity.isSubmergedInWater();
|
||||
wobbleAmount = handSwingProgress <= 0 ? 0 : MathHelper.sin(MathHelper.sqrt(getSwingAmount()) * MathHelper.PI * 2) * 0.04F;
|
||||
if (attributes.isSitting) {
|
||||
pose = EntityPose.SITTING;
|
||||
}
|
||||
|
@ -53,18 +56,13 @@ public class PonyRenderState extends PlayerEntityRenderState implements PonyMode
|
|||
|| entity instanceof ZombifiedPiglinEntity
|
||||
) && entity.hasCustomName() && entity.getCustomName().getString().equalsIgnoreCase("technoblade")
|
||||
);
|
||||
size = baby ? SizePreset.FOAL : PonyConfig.getEffectiveSize(attributes.metadata.size());
|
||||
|
||||
PonyPosture.of(attributes).updateState(entity, this);
|
||||
PonyModelPrepareCallback.EVENT.invoker().onPonyModelPrepared(attributes, model, ModelAttributes.Mode.OTHER);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the active scaling profile used to lay out this model's parts.
|
||||
*/
|
||||
public Size getSize() {
|
||||
return baby ? SizePreset.FOAL : PonyConfig.getEffectiveSize(attributes.metadata.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Race getRace() {
|
||||
return PonyConfig.getEffectiveRace(attributes.metadata.race());
|
||||
}
|
||||
|
@ -73,14 +71,6 @@ public class PonyRenderState extends PlayerEntityRenderState implements PonyMode
|
|||
return getRace().hasHorn() && attributes.metadata.glowColor() != 0;
|
||||
}
|
||||
|
||||
public final float getScaleFactor() {
|
||||
return getSize().scaleFactor();
|
||||
}
|
||||
|
||||
public final float getShadowSize() {
|
||||
return getSize().shadowSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current leg swing amount.
|
||||
*/
|
||||
|
@ -88,17 +78,6 @@ public class PonyRenderState extends PlayerEntityRenderState implements PonyMode
|
|||
return this.handSwingProgress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the step wobble used for various hair bits and animations.
|
||||
*/
|
||||
public float getWobbleAmount() {
|
||||
if (getSwingAmount() <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return MathHelper.sin(MathHelper.sqrt(getSwingAmount()) * MathHelper.PI * 2) * 0.04F;
|
||||
}
|
||||
|
||||
protected float getLegOutset() {
|
||||
float outset = attributes.isLyingDown ? 3.6F : attributes.isCrouching ? 1 : 5;
|
||||
|
||||
|
@ -112,13 +91,10 @@ public class PonyRenderState extends PlayerEntityRenderState implements PonyMode
|
|||
* Gets the y-offset applied to entities riding this one.
|
||||
*/
|
||||
protected float getRiderYOffset() {
|
||||
switch ((SizePreset)getSize()) {
|
||||
case NORMAL: return 0.4F;
|
||||
case FOAL:
|
||||
case TALL:
|
||||
case BULKY:
|
||||
default: return 0.25F;
|
||||
}
|
||||
return switch ((SizePreset)size) {
|
||||
case NORMAL -> 0.4F;
|
||||
default -> 0.25F;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -141,7 +117,7 @@ public class PonyRenderState extends PlayerEntityRenderState implements PonyMode
|
|||
float y = -(height + 0.5F);
|
||||
|
||||
// Then we add our own offsets.
|
||||
y += attributes.visualHeight * getScaleFactor() + 0.25F;
|
||||
y += attributes.visualHeight * size.scaleFactor() + 0.25F;
|
||||
y += vehicleOffset;
|
||||
|
||||
if (isInSneakingPose) {
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
accessWidener v1 named
|
||||
accessible class net/minecraft/client/render/VertexConsumers$Union
|
||||
|
||||
accessible method net/minecraft/client/render/entity/GuardianEntityRenderer renderBeam (Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;Lnet/minecraft/util/math/Vec3d;FFF)V
|
||||
accessible method net/minecraft/client/render/entity/GuardianEntityRenderer getBeamTarget (Lnet/minecraft/entity/mob/GuardianEntity;)Lnet/minecraft/entity/Entity;
|
||||
|
||||
extendable method net/minecraft/client/model/Model render (Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;III)V
|
||||
|
|
Loading…
Reference in a new issue