mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-22 04:27:59 +01:00
Disable pitch and yaw rotations when rendering in first person mode
This commit is contained in:
parent
9bc1a4502d
commit
5f62ba8e47
6 changed files with 62 additions and 10 deletions
17
src/main/java/com/minelittlepony/api/model/RenderPass.java
Normal file
17
src/main/java/com/minelittlepony/api/model/RenderPass.java
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
package com.minelittlepony.api.model;
|
||||||
|
|
||||||
|
public enum RenderPass {
|
||||||
|
GUI,
|
||||||
|
WORLD,
|
||||||
|
HUD;
|
||||||
|
|
||||||
|
private static RenderPass CURRENT = WORLD;
|
||||||
|
|
||||||
|
public static RenderPass getCurrent() {
|
||||||
|
return CURRENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void swap(RenderPass pass) {
|
||||||
|
CURRENT = pass == null ? WORLD : pass;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.minelittlepony.client.mixin;
|
||||||
|
|
||||||
|
import net.minecraft.client.render.*;
|
||||||
|
import net.minecraft.client.util.math.MatrixStack;
|
||||||
|
|
||||||
|
import org.joml.Matrix4f;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import com.minelittlepony.api.model.RenderPass;
|
||||||
|
|
||||||
|
@Mixin(GameRenderer.class)
|
||||||
|
abstract class MixinGameRenderer {
|
||||||
|
@Inject(method = "renderWorld", at = @At("HEAD"))
|
||||||
|
private void beforeRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
|
||||||
|
RenderPass.swap(RenderPass.WORLD);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Inject(method = "renderWorld", at = @At("RETURN"))
|
||||||
|
private void afterRenderWorld(float tickDelta, long limitTime, MatrixStack matrices, CallbackInfo info) {
|
||||||
|
RenderPass.swap(RenderPass.GUI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mixin(value = WorldRenderer.class, priority = 0)
|
||||||
|
abstract class MixinWorldRenderer {
|
||||||
|
@Inject(method = "render", at = @At(
|
||||||
|
value = "INVOKE",
|
||||||
|
target = "net.minecraft.client.render.VertexConsumerProvider$Immediate.drawCurrentLayer()V",
|
||||||
|
ordinal = 0
|
||||||
|
))
|
||||||
|
private void onRender(MatrixStack matrices, float tickDelta, long limitTime, boolean renderBlockOutline, Camera camera, GameRenderer gameRenderer, LightmapTextureManager lightmapTextureManager, Matrix4f positionMatrix, CallbackInfo info) {
|
||||||
|
RenderPass.swap(RenderPass.HUD);
|
||||||
|
}
|
||||||
|
}
|
|
@ -105,9 +105,7 @@ public abstract class AbstractPonyModel<T extends LivingEntity> extends ClientPo
|
||||||
PonyModelPrepareCallback.EVENT.invoker().onPonyModelPrepared(entity, this, ModelAttributes.Mode.OTHER);
|
PonyModelPrepareCallback.EVENT.invoker().onPonyModelPrepared(entity, this, ModelAttributes.Mode.OTHER);
|
||||||
super.setAngles(entity, move, swing, ticks, headYaw, headPitch);
|
super.setAngles(entity, move, swing, ticks, headYaw, headPitch);
|
||||||
|
|
||||||
head.pivotY = head.getDefaultTransform().pivotY;
|
head.setPivot(head.getDefaultTransform().pivotX, head.getDefaultTransform().pivotY, head.getDefaultTransform().pivotZ);
|
||||||
head.pivotX = head.getDefaultTransform().pivotX;
|
|
||||||
head.pivotZ = head.getDefaultTransform().pivotZ;
|
|
||||||
|
|
||||||
setModelAngles(entity, move, swing, ticks, headYaw, headPitch);
|
setModelAngles(entity, move, swing, ticks, headYaw, headPitch);
|
||||||
|
|
||||||
|
|
|
@ -162,12 +162,7 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
|
||||||
public void updateModel(T entity, ModelAttributes.Mode mode) {
|
public void updateModel(T entity, ModelAttributes.Mode mode) {
|
||||||
pony = renderer.getEntityPony(entity);
|
pony = renderer.getEntityPony(entity);
|
||||||
playerModel.applyMetadata(pony.metadata());
|
playerModel.applyMetadata(pony.metadata());
|
||||||
updateForEntity(pony, entity);
|
|
||||||
|
|
||||||
getModel().updateLivingState(entity, pony, mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateForEntity(IPony pony, Entity entity) {
|
|
||||||
if (pony.hasMetadata() && entity instanceof RegistrationHandler && ((RegistrationHandler)entity).shouldUpdateRegistration(pony)) {
|
if (pony.hasMetadata() && entity instanceof RegistrationHandler && ((RegistrationHandler)entity).shouldUpdateRegistration(pony)) {
|
||||||
entity.calculateDimensions();
|
entity.calculateDimensions();
|
||||||
|
|
||||||
|
@ -179,6 +174,8 @@ public class EquineRenderManager<T extends LivingEntity, M extends EntityModel<T
|
||||||
}
|
}
|
||||||
PonyDataCallback.EVENT.invoker().onPonyDataAvailable((PlayerEntity)entity, pony.metadata(), pony.defaulted(), EnvType.CLIENT);
|
PonyDataCallback.EVENT.invoker().onPonyDataAvailable((PlayerEntity)entity, pony.metadata(), pony.defaulted(), EnvType.CLIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getModel().updateLivingState(entity, pony, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPony getPony(T entity) {
|
public IPony getPony(T entity) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
|
||||||
import com.minelittlepony.api.model.IModel;
|
import com.minelittlepony.api.model.IModel;
|
||||||
|
import com.minelittlepony.api.model.RenderPass;
|
||||||
|
|
||||||
public interface PonyPosture<T extends LivingEntity> {
|
public interface PonyPosture<T extends LivingEntity> {
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ public interface PonyPosture<T extends LivingEntity> {
|
||||||
}
|
}
|
||||||
|
|
||||||
default void apply(T player, IModel model, MatrixStack stack, float yaw, float ticks, int invert) {
|
default void apply(T player, IModel model, MatrixStack stack, float yaw, float ticks, int invert) {
|
||||||
if (applies(player)) {
|
if (RenderPass.getCurrent() == RenderPass.WORLD && applies(player)) {
|
||||||
double motionX = player.getX() - player.prevX;
|
double motionX = player.getX() - player.prevX;
|
||||||
double motionY = player.isOnGround() ? 0 : player.getY() - player.prevY;
|
double motionY = player.isOnGround() ? 0 : player.getY() - player.prevY;
|
||||||
double motionZ = player.getZ() - player.prevZ;
|
double motionZ = player.getZ() - player.prevZ;
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
"MixinClientPlayerEntity",
|
"MixinClientPlayerEntity",
|
||||||
"MixinPlayerMoveC2SPacket",
|
"MixinPlayerMoveC2SPacket",
|
||||||
"MixinPlayerPositionLookS2CPacket",
|
"MixinPlayerPositionLookS2CPacket",
|
||||||
"MixinVertextConsumers"
|
"MixinVertextConsumers",
|
||||||
|
"MixinGameRenderer",
|
||||||
|
"MixinWorldRenderer"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue