mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 16:28:00 +01:00
Change flight physics a little and fix interaction with the heavy enchantment
This commit is contained in:
parent
955c4d4afe
commit
e92f1ddbe1
1 changed files with 35 additions and 31 deletions
|
@ -54,6 +54,8 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
private int prevStrafe;
|
private int prevStrafe;
|
||||||
private float strafe;
|
private float strafe;
|
||||||
|
|
||||||
|
private float descentRate;
|
||||||
|
|
||||||
private FlightType lastFlightType = FlightType.NONE;
|
private FlightType lastFlightType = FlightType.NONE;
|
||||||
|
|
||||||
public boolean isFlyingEither = false;
|
public boolean isFlyingEither = false;
|
||||||
|
@ -290,24 +292,21 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
ticksInAir = 0;
|
ticksInAir = 0;
|
||||||
wallHitCooldown = MAX_WALL_HIT_CALLDOWN;
|
wallHitCooldown = MAX_WALL_HIT_CALLDOWN;
|
||||||
soundPlaying = false;
|
soundPlaying = false;
|
||||||
if (pony.getJumpingHeuristic().hasChanged(Heuristic.TWICE)) {
|
descentRate = 0;
|
||||||
System.out.println("DOUBLE JUMP!!!!");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!creative && type.isAvian()) {
|
if (!creative && type.isAvian()) {
|
||||||
checkAvianTakeoffConditions(velocity);
|
checkAvianTakeoffConditions(velocity);
|
||||||
} else {
|
|
||||||
System.out.println("WRONG TYPE");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
descentRate = 0;
|
||||||
soundPlaying = false;
|
soundPlaying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entity.isOnGround()) {
|
if (!entity.isOnGround()) {
|
||||||
float heavyness = 1 - EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, entity) * 0.015F;
|
float heavyness = 1 - EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, entity) * 0.015F;
|
||||||
velocity.x *= heavyness;
|
velocity.x /= heavyness;
|
||||||
velocity.z *= heavyness;
|
velocity.z /= heavyness;
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.setVelocity(velocity.toImmutable());
|
entity.setVelocity(velocity.toImmutable());
|
||||||
|
@ -350,12 +349,6 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
|
|
||||||
moveFlying(velocity);
|
moveFlying(velocity);
|
||||||
|
|
||||||
if (entity.world.hasRain(entity.getBlockPos())) {
|
|
||||||
applyTurbulance(velocity);
|
|
||||||
} else {
|
|
||||||
velocity.y += WeatherConditions.getUpdraft(new BlockPos.Mutable().set(entity.getBlockPos()), entity.world);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type.isAvian()) {
|
if (type.isAvian()) {
|
||||||
if (entity.world.isClient && ticksInAir % IDLE_FLAP_INTERVAL == 0 && entity.getVelocity().length() < 0.29) {
|
if (entity.world.isClient && ticksInAir % IDLE_FLAP_INTERVAL == 0 && entity.getVelocity().length() < 0.29) {
|
||||||
flapping = true;
|
flapping = true;
|
||||||
|
@ -475,6 +468,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
entity.getAbilities().flying = true;
|
entity.getAbilities().flying = true;
|
||||||
isFlyingEither = true;
|
isFlyingEither = true;
|
||||||
isFlyingSurvival = true;
|
isFlyingSurvival = true;
|
||||||
|
thrustScale = 0;
|
||||||
entity.calculateDimensions();
|
entity.calculateDimensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,8 +516,21 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
forward += 0.005F;
|
forward += 0.005F;
|
||||||
|
|
||||||
velocity.x += - forward * MathHelper.sin(entity.getYaw() * 0.017453292F);
|
velocity.x += - forward * MathHelper.sin(entity.getYaw() * 0.017453292F);
|
||||||
velocity.y -= (0.01F / Math.max(motion * 100, 1)) * getGravityModifier();
|
|
||||||
velocity.z += forward * MathHelper.cos(entity.getYaw() * 0.017453292F);
|
velocity.z += forward * MathHelper.cos(entity.getYaw() * 0.017453292F);
|
||||||
|
|
||||||
|
|
||||||
|
if (entity.world.hasRain(entity.getBlockPos())) {
|
||||||
|
applyTurbulance(velocity);
|
||||||
|
} else {
|
||||||
|
descentRate -= WeatherConditions.getUpdraft(new BlockPos.Mutable().set(entity.getBlockPos()), entity.world) / 3F;
|
||||||
|
}
|
||||||
|
|
||||||
|
descentRate += 0.001F;
|
||||||
|
descentRate = Math.min(1.5F, descentRate);
|
||||||
|
if (descentRate < 0) {
|
||||||
|
descentRate *= 0.8F;
|
||||||
|
}
|
||||||
|
velocity.y -= descentRate * getGravityModifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyThrust(MutableVector velocity) {
|
private void applyThrust(MutableVector velocity) {
|
||||||
|
@ -534,41 +541,36 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
|
|
||||||
thrustScale *= 0.2889F;
|
thrustScale *= 0.2889F;
|
||||||
|
|
||||||
|
boolean hovering = entity.getVelocity().horizontalLength() < 0.1;
|
||||||
|
|
||||||
if (thrustScale <= 0.000001F & flapping) {
|
if (thrustScale <= 0.000001F & flapping) {
|
||||||
flapping = false;
|
flapping = false;
|
||||||
if (!SpellPredicate.IS_DISGUISE.isOn(pony)) {
|
if (!SpellPredicate.IS_DISGUISE.isOn(pony)) {
|
||||||
entity.playSound(getFlightType().getWingFlapSound(), 0.5F, 1);
|
entity.playSound(getFlightType().getWingFlapSound(), 0.5F, 1);
|
||||||
entity.world.emitGameEvent(entity, GameEvent.ELYTRA_GLIDE, entity.getPos());
|
entity.world.emitGameEvent(entity, GameEvent.ELYTRA_GLIDE, entity.getPos());
|
||||||
}
|
}
|
||||||
|
if (!hovering) {
|
||||||
thrustScale = 1;
|
thrustScale = 1;
|
||||||
|
descentRate -= 0.5F;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float heavyness = EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, entity) / 6F;
|
float heavyness = EnchantmentHelper.getEquipmentLevel(UEnchantments.HEAVY, entity);
|
||||||
float thrustStrength = 0.135F * thrustScale;
|
float thrustStrength = 0.135F * thrustScale;
|
||||||
|
|
||||||
if (heavyness > 0) {
|
if (heavyness > 0) {
|
||||||
thrustStrength /= heavyness;
|
thrustStrength /= 1 + heavyness;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3d direction = entity.getRotationVec(1).normalize().multiply(thrustStrength);
|
Vec3d direction = entity.getRotationVec(1).normalize().multiply(thrustStrength);
|
||||||
|
|
||||||
if (entity.getVelocity().horizontalLength() > 0.1) {
|
if (!hovering) {
|
||||||
velocity.x += direction.x;
|
velocity.x += direction.x;
|
||||||
velocity.z += direction.z;
|
velocity.z += direction.z;
|
||||||
velocity.y += (direction.y * 2.45 + Math.abs(direction.y) * 10) * getGravitySignum() - heavyness / 5F;
|
velocity.y += ((direction.y * 2.45 + Math.abs(direction.y) * 10)) * getGravitySignum();// - heavyness / 5F
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.isSneaking()) {
|
if (velocity.y < 0 && hovering) {
|
||||||
if (!isGravityNegative()) {
|
|
||||||
velocity.y += 0.4 - 0.25;
|
|
||||||
}
|
|
||||||
if (pony.sneakingChanged()) {
|
|
||||||
velocity.y += 0.75 * getGravitySignum();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
velocity.y -= 0.1 * getGravitySignum();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (velocity.y < 0 && entity.getVelocity().horizontalLength() < 0.1) {
|
|
||||||
velocity.y *= 0.01;
|
velocity.y *= 0.01;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -648,6 +650,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
compound.putBoolean("isCancelled", isCancelled);
|
compound.putBoolean("isCancelled", isCancelled);
|
||||||
compound.putBoolean("isFlyingEither", isFlyingEither);
|
compound.putBoolean("isFlyingEither", isFlyingEither);
|
||||||
compound.putInt("ticksInAir", ticksInAir);
|
compound.putInt("ticksInAir", ticksInAir);
|
||||||
|
compound.putFloat("descentRate", descentRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -657,6 +660,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
isCancelled = compound.getBoolean("isCancelled");
|
isCancelled = compound.getBoolean("isCancelled");
|
||||||
isFlyingEither = compound.getBoolean("isFlyingEither");
|
isFlyingEither = compound.getBoolean("isFlyingEither");
|
||||||
ticksInAir = compound.getInt("ticksInAir");
|
ticksInAir = compound.getInt("ticksInAir");
|
||||||
|
descentRate = compound.getFloat("descentRate");
|
||||||
|
|
||||||
entity.calculateDimensions();
|
entity.calculateDimensions();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue