use of net.tropicraft.core.common.entity.SeaTurtleEntity in project Tropicraft by Tropicraft.
the class PlayerRotationHandler method onRenderPlayerPost.
@SubscribeEvent
public static void onRenderPlayerPost(RenderPlayerEvent.Post event) {
Player p = event.getPlayer();
if (p.getVehicle() instanceof BeachFloatEntity || p.getVehicle() instanceof SeaTurtleEntity) {
event.getMatrixStack().popPose();
p.setXRot(rotationPitch);
p.xRotO = prevRotationPitch;
}
if (p.getVehicle() instanceof BeachFloatEntity) {
p.yHeadRot = rotationYawHead;
p.yHeadRotO = prevRotationYawHead;
}
}
use of net.tropicraft.core.common.entity.SeaTurtleEntity in project Tropicraft by Tropicraft.
the class PlayerRotationHandler method onRenderPlayer.
@SubscribeEvent
public static void onRenderPlayer(RenderPlayerEvent.Pre event) {
PoseStack stack = event.getMatrixStack();
MultiBufferSource buffers = event.getBuffers();
Player p = event.getPlayer();
Entity riding = p.getVehicle();
if (riding instanceof BeachFloatEntity) {
FurnitureEntity floaty = (FurnitureEntity) riding;
stack.pushPose();
stack.mulPose(Vector3f.YP.rotationDegrees(-(floaty.yRotO + (event.getPartialRenderTick() * (floaty.getYRot() - floaty.yRotO)))));
stack.translate(0, 1.55, 1.55);
stack.mulPose(Vector3f.XN.rotationDegrees(90));
// Cancel out player camera rotation
float f = interpolateAndWrap(p.yBodyRot, p.yBodyRotO, event.getPartialRenderTick());
stack.mulPose(Vector3f.YP.rotationDegrees(f));
// Lock in head
rotationYawHead = p.yHeadRot;
prevRotationYawHead = p.yHeadRotO;
p.yHeadRot = p.yBodyRot;
p.yHeadRotO = p.yBodyRotO;
rotationPitch = p.getXRot();
prevRotationPitch = p.xRotO;
p.setXRot(10f);
p.xRotO = 10f;
// Cancel limb swing
p.animationPosition = 0;
p.animationSpeed = 0;
p.animationSpeedOld = 0;
}
if (riding instanceof SeaTurtleEntity) {
SeaTurtleEntity turtle = (SeaTurtleEntity) riding;
stack.pushPose();
// Cancel out player camera rotation
float pitch = interpolateAndWrap(turtle.getXRot(), turtle.xRotO, event.getPartialRenderTick());
float yaw = interpolateAndWrap(turtle.yHeadRot, turtle.yHeadRotO, event.getPartialRenderTick());
stack.translate(0, turtle.getPassengersRidingOffset() - p.getMyRidingOffset(), 0);
stack.mulPose(Vector3f.YN.rotationDegrees(yaw));
// TODO figure out why this budging is needed
stack.translate(0, -0.1, 0);
stack.mulPose(Vector3f.XP.rotationDegrees(pitch));
stack.translate(0, 0.1, 0);
stack.mulPose(Vector3f.YP.rotationDegrees(yaw));
stack.translate(0, -turtle.getPassengersRidingOffset() + p.getMyRidingOffset(), 0);
Vec3 passengerOffset = (new Vec3(-0.25f, 0.0D, 0.0D)).yRot((float) (-Math.toRadians(yaw) - (Math.PI / 2)));
stack.translate(passengerOffset.x(), 0, passengerOffset.z());
// Lock in head
rotationPitch = p.getXRot();
prevRotationPitch = p.xRotO;
p.setXRot(10f);
p.xRotO = 10f;
}
}
Aggregations