Fixed transitions playing when first joining the world, fixed pegasus flight under inverted gravity

This commit is contained in:
Sollace 2019-03-02 18:03:59 +02:00
parent 10545adb66
commit 0800865661
3 changed files with 26 additions and 11 deletions

View file

@ -52,7 +52,7 @@ public class MovementControl extends MovementInputFromOptions {
moveStrafe = -moveStrafe;
if (player.getOwner().capabilities.isCreativeMode && player.getOwner().capabilities.isFlying) {
if (player.getOwner().capabilities.isFlying) {
tmp = jump;
jump = sneak;
sneak = tmp;

View file

@ -121,25 +121,33 @@ class PlayerGravityDelegate implements IUpdatable, IGravity, InbtSerialisable, I
isFlying = entity.capabilities.isFlying && !entity.capabilities.isCreativeMode;
if (!entity.capabilities.isFlying || !entity.capabilities.isCreativeMode) {
if (gravity != 0) {
if (gravity != 0) {
if (!entity.capabilities.isFlying) {
entity.motionY += 0.08;
entity.motionY -= gravity;
}
entity.onGround = !entity.world.isAirBlock(new BlockPos(entity.posX, entity.posY + entity.height + 0.5F, entity.posZ));
entity.onGround = !entity.world.isAirBlock(new BlockPos(entity.posX, entity.posY + entity.height + 0.5F, entity.posZ));
if (entity.onGround) {
entity.capabilities.isFlying = isFlying = false;
}
}
float bodyHeight = getTargetBodyHeight(player);
MixinEntity.setSize(entity, entity.width, player.getInterpolator().interpolate("standingHeight", bodyHeight, 10));
float eyeHeight = getTargetEyeHeight(player);
if (gravity < 0) {
eyeHeight = bodyHeight - eyeHeight;
}
entity.eyeHeight = player.getInterpolator().interpolate("eyeHeight", eyeHeight, 10);
if (entity.ticksExisted > 10) {
bodyHeight = player.getInterpolator().interpolate("standingHeight", bodyHeight, 10);
eyeHeight = player.getInterpolator().interpolate("eyeHeight", eyeHeight, 10);
}
MixinEntity.setSize(entity, entity.width, bodyHeight);
entity.eyeHeight = eyeHeight;
if (gravity < 0) {
if (entity.isSneaking()) {
@ -192,13 +200,15 @@ class PlayerGravityDelegate implements IUpdatable, IGravity, InbtSerialisable, I
protected void moveFlying(EntityPlayer player) {
float forward = 0.00015F * flightExperience * player.moveForward;
int factor = gravity < 0 ? -1 : 1;
boolean sneak = !player.isSneaking();
// vertical drop due to gravity
if (!player.isSneaking()) {
player.motionY -= 0.05F - getHorizontalMotion(player) / 100;
if (sneak) {
player.motionY -= (0.05F - getHorizontalMotion(player) / 100) * factor;
} else {
forward += 0.005F;
player.motionY -= 0.0005F;
player.motionY -= 0.0005F * factor;
}
player.motionX += - forward * MathHelper.sin(player.rotationYaw * 0.017453292F);

View file

@ -22,10 +22,15 @@ class PlayerView extends MotionCompositor implements IView {
}
if (player.getGravity().getGravitationConstant() < 0) {
roll = -roll;
roll += 180;
}
return (float)player.getInterpolator().interpolate("roll", (float)roll, 100);
if (player.getEntity().ticksExisted > 10) {
roll = player.getInterpolator().interpolate("roll", (float)roll, 250);
}
return (float)roll;
}
@Override