mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-28 15:08:00 +01:00
Remove the generic from PonyPosture
This commit is contained in:
parent
70797a1883
commit
ef33d648e6
5 changed files with 16 additions and 21 deletions
|
@ -103,17 +103,14 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
public void setupTransforms(T entity, MatrixStack stack, float yaw, float tickDelta) {
|
||||||
public void applyPostureTransform(T player, MatrixStack stack, float yaw, float ticks) {
|
PonyPosture.of(getModel().getAttributes()).apply(entity, getModel(), stack, yaw, tickDelta, 1);
|
||||||
((PonyPosture<T>) PonyPosture.getPosture(getModel().getAttributes(), player)).apply(player, getModel(), stack, yaw, ticks, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
public void applyPostureRiding(T entity, MatrixStack stack, float yaw, float tickDelta) {
|
||||||
public void applyPostureRiding(T player, MatrixStack stack, float yaw, float ticks) {
|
PonyPosture.of(getModel().getAttributes()).apply(entity, getModel(), stack, yaw, tickDelta, -1);
|
||||||
((PonyPosture<T>) PonyPosture.getPosture(getModel().getAttributes(), player)).apply(player, getModel(), stack, yaw, ticks, -1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public M getModel() {
|
public M getModel() {
|
||||||
return playerModel.body();
|
return playerModel.body();
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,8 +81,7 @@ public abstract class AbstractPonyRenderer<T extends MobEntity, M extends Entity
|
||||||
|
|
||||||
rotationYaw = manager.getRenderYaw(entity, rotationYaw, partialTicks);
|
rotationYaw = manager.getRenderYaw(entity, rotationYaw, partialTicks);
|
||||||
super.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
|
super.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
|
||||||
|
manager.setupTransforms(entity, stack, rotationYaw, partialTicks);
|
||||||
manager.applyPostureTransform(entity, stack, rotationYaw, partialTicks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -102,8 +102,7 @@ public class PlayerPonyRenderer extends PlayerEntityRenderer implements IPonyRen
|
||||||
manager.preRenderCallback(entity, stack, partialTicks);
|
manager.preRenderCallback(entity, stack, partialTicks);
|
||||||
rotationYaw = manager.getRenderYaw(entity, rotationYaw, partialTicks);
|
rotationYaw = manager.getRenderYaw(entity, rotationYaw, partialTicks);
|
||||||
super.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
|
super.setupTransforms(entity, stack, ageInTicks, rotationYaw, partialTicks);
|
||||||
|
manager.setupTransforms(entity, stack, rotationYaw, partialTicks);
|
||||||
manager.applyPostureTransform(entity, stack, rotationYaw, partialTicks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,21 +10,21 @@ import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import com.minelittlepony.api.model.*;
|
import com.minelittlepony.api.model.*;
|
||||||
|
|
||||||
public interface PonyPosture<T extends LivingEntity> {
|
public interface PonyPosture {
|
||||||
PonyPosture<LivingEntity> STANDING = (IModel model, LivingEntity entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float tickDelta) -> {
|
PonyPosture STANDING = (IModel model, LivingEntity entity, MatrixStack stack, double motionX, double motionY, double motionZ, float yaw, float tickDelta) -> {
|
||||||
model.getAttributes().motionPitch /= 10;
|
model.getAttributes().motionPitch /= 10;
|
||||||
model.getAttributes().motionLerp /= 10;
|
model.getAttributes().motionLerp /= 10;
|
||||||
model.getAttributes().motionRoll /= 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);
|
stack.translate(0, entity.isInSneakingPose() ? -0.825F : -1, 0);
|
||||||
};
|
};
|
||||||
PonyPosture<LivingEntity> FLYING = new PostureFlight(1, 0);
|
PonyPosture FLYING = new PostureFlight(1, 0);
|
||||||
PonyPosture<LivingEntity> SWIMMING = new PostureFlight(2, -0.9F);
|
PonyPosture SWIMMING = new PostureFlight(2, -0.9F);
|
||||||
PonyPosture<LivingEntity> FALLING = STANDING;
|
PonyPosture FALLING = STANDING;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
static PonyPosture<?> getPosture(ModelAttributes attributes, LivingEntity entity) {
|
static PonyPosture of(ModelAttributes attributes) {
|
||||||
if (attributes.isGliding) {
|
if (attributes.isGliding) {
|
||||||
return ELYTRA;
|
return ELYTRA;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public interface PonyPosture<T extends LivingEntity> {
|
||||||
return FALLING;
|
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) {
|
if (RenderPass.getCurrent() == RenderPass.GUI || RenderPass.getCurrent() == RenderPass.WORLD) {
|
||||||
// this reverts the rotations done in PlayerEntityRenderer#setupTransforms
|
// 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);
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import net.minecraft.client.util.math.MatrixStack;
|
||||||
import net.minecraft.util.math.RotationAxis;
|
import net.minecraft.util.math.RotationAxis;
|
||||||
import net.minecraft.entity.LivingEntity;
|
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 xScale;
|
||||||
private final float yOffset;
|
private final float yOffset;
|
||||||
|
|
Loading…
Reference in a new issue