Remove the generic from PonyPosture

This commit is contained in:
Sollace 2023-03-27 17:02:05 +01:00
parent 70797a1883
commit ef33d648e6
5 changed files with 16 additions and 21 deletions

View file

@ -103,17 +103,14 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
}
}
@SuppressWarnings("unchecked")
public void applyPostureTransform(T player, MatrixStack stack, float yaw, float ticks) {
((PonyPosture<T>) PonyPosture.getPosture(getModel().getAttributes(), player)).apply(player, getModel(), stack, yaw, ticks, 1);
public void setupTransforms(T entity, MatrixStack stack, float yaw, float tickDelta) {
PonyPosture.of(getModel().getAttributes()).apply(entity, getModel(), stack, yaw, tickDelta, 1);
}
@SuppressWarnings("unchecked")
public void applyPostureRiding(T player, MatrixStack stack, float yaw, float ticks) {
((PonyPosture<T>) PonyPosture.getPosture(getModel().getAttributes(), player)).apply(player, getModel(), stack, yaw, ticks, -1);
public void applyPostureRiding(T entity, MatrixStack stack, float yaw, float tickDelta) {
PonyPosture.of(getModel().getAttributes()).apply(entity, getModel(), stack, yaw, tickDelta, -1);
}
public M getModel() {
return playerModel.body();
}

View file

@ -81,8 +81,7 @@ public abstract class AbstractPonyRenderer<T extends MobEntity, M extends Entity
rotationYaw = manager.getRenderYaw(entity, rotationYaw, partialTicks);
super.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
manager.applyPostureTransform(entity, stack, rotationYaw, partialTicks);
manager.setupTransforms(entity, stack, rotationYaw, partialTicks);
}
@Override

View file

@ -102,8 +102,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements IPonyRen
manager.preRenderCallback(entity, stack, partialTicks);
rotationYaw = manager.getRenderYaw(entity, rotationYaw, partialTicks);
super.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
manager.applyPostureTransform(entity, stack, rotationYaw, partialTicks);
manager.setupTransforms(entity, stack, rotationYaw, partialTicks);
}
@Override

View file

@ -10,21 +10,21 @@ import org.jetbrains.annotations.NotNull;
import com.minelittlepony.api.model.*;
public interface PonyPosture<T extends LivingEntity> {
PonyPosture<LivingEntity> STANDING = (IModel model, LivingEntity entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float tickDelta) -> {
public interface PonyPosture {
PonyPosture STANDING = (IModel model, LivingEntity entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float tickDelta) -> {
model.getAttributes().motionPitch /= 10;
model.getAttributes().motionLerp /= 10;
model.getAttributes().motionRoll /= 10;
};
PonyPosture<LivingEntity> ELYTRA = (IModel model, LivingEntity entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float tickDelta) -> {
PonyPosture ELYTRA = (IModel model, LivingEntity entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float tickDelta) -> {
stack.translate(0, entity.isInSneakingPose() ? -0.825F : -1, 0);
};
PonyPosture<LivingEntity> FLYING = new PostureFlight(1, 0);
PonyPosture<LivingEntity> SWIMMING = new PostureFlight(2, -0.9F);
PonyPosture<LivingEntity> FALLING = STANDING;
PonyPosture FLYING = new PostureFlight(1, 0);
PonyPosture SWIMMING = new PostureFlight(2, -0.9F);
PonyPosture FALLING = STANDING;
@NotNull
static PonyPosture<?> getPosture(ModelAttributes attributes, LivingEntity entity) {
static PonyPosture of(ModelAttributes attributes) {
if (attributes.isGliding) {
return ELYTRA;
}
@ -44,7 +44,7 @@ public interface PonyPosture<T extends LivingEntity> {
return FALLING;
}
default void apply(T player, IModel model, MatrixStack stack, float yaw, float tickDelta, int invert) {
default void apply(LivingEntity player, IModel model, MatrixStack stack, float yaw, float tickDelta, int invert) {
if (RenderPass.getCurrent() == RenderPass.GUI || RenderPass.getCurrent() == RenderPass.WORLD) {
// this reverts the rotations done in PlayerEntityRenderer#setupTransforms
@ -91,5 +91,5 @@ public interface PonyPosture<T extends LivingEntity> {
transform(model, player, stack, motionX, invert * motionY, motionZ, yaw, tickDelta);
}
void transform(IModel model, T entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float tickDelta);
void transform(IModel model, LivingEntity entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float tickDelta);
}

View file

@ -7,7 +7,7 @@ import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.math.RotationAxis;
import net.minecraft.entity.LivingEntity;
public class PostureFlight extends MotionCompositor implements PonyPosture<LivingEntity> {
public class PostureFlight extends MotionCompositor implements PonyPosture {
private final float xScale;
private final float yOffset;