mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 16:28:00 +01:00
Fixed other players appearing "stuck" in flight mode when playing in multiplayer
This commit is contained in:
parent
f8f415f255
commit
0d06f13ee5
1 changed files with 22 additions and 11 deletions
|
@ -23,7 +23,6 @@ import com.minelittlepony.unicopia.util.MutableVector;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.entity.EntityPose;
|
import net.minecraft.entity.EntityPose;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
|
@ -109,7 +108,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
spreadAmount += MathHelper.clamp(-entity.getVelocity().y, 0, 2);
|
spreadAmount += MathHelper.clamp(-getVerticalMotion(), 0, 2);
|
||||||
spreadAmount += Math.sin(entity.age / 9F) / 9F;
|
spreadAmount += Math.sin(entity.age / 9F) / 9F;
|
||||||
|
|
||||||
if (entity.isSneaking()) {
|
if (entity.isSneaking()) {
|
||||||
|
@ -138,10 +137,18 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
entity.getAbilities().flying = false;
|
entity.getAbilities().flying = false;
|
||||||
isFlyingEither = false;
|
isFlyingEither = false;
|
||||||
isFlyingSurvival = false;
|
isFlyingSurvival = false;
|
||||||
|
strafe = 0;
|
||||||
|
thrustScale = 0;
|
||||||
|
entity.calculateDimensions();
|
||||||
|
pony.sendCapabilities(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double getHorizontalMotion(Entity e) {
|
private double getHorizontalMotion() {
|
||||||
return e.getPos().subtract(lastPos).horizontalLengthSquared();
|
return entity.getPos().subtract(lastPos).horizontalLengthSquared();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double getVerticalMotion() {
|
||||||
|
return entity.getPos().y - lastPos.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -178,6 +185,10 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
boolean creative = entity.getAbilities().creativeMode || entity.isSpectator();
|
boolean creative = entity.getAbilities().creativeMode || entity.isSpectator();
|
||||||
|
|
||||||
if (!creative) {
|
if (!creative) {
|
||||||
|
if (entity.world.isClient && entity.isOnGround()) {
|
||||||
|
cancelFlight();
|
||||||
|
}
|
||||||
|
|
||||||
entity.getAbilities().flying |= (type.canFly() || entity.getAbilities().allowFlying) && isFlyingEither;
|
entity.getAbilities().flying |= (type.canFly() || entity.getAbilities().allowFlying) && isFlyingEither;
|
||||||
if (!type.canFly() && (type != lastFlightType)) {
|
if (!type.canFly() && (type != lastFlightType)) {
|
||||||
entity.getAbilities().flying = false;
|
entity.getAbilities().flying = false;
|
||||||
|
@ -249,7 +260,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
soundPlaying = false;
|
soundPlaying = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
lastPos = new Vec3d(entity.getX(), 0, entity.getZ());
|
lastPos = entity.getPos();
|
||||||
|
|
||||||
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;
|
||||||
|
@ -326,7 +337,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
int damageInterval = 20;
|
int damageInterval = 20;
|
||||||
int minDamage = 1;
|
int minDamage = 1;
|
||||||
|
|
||||||
float energyConsumed = 2 + (float)getHorizontalMotion(entity) / 10F;
|
float energyConsumed = 2 + (float)getHorizontalMotion() / 10F;
|
||||||
if (entity.world.hasRain(entity.getBlockPos())) {
|
if (entity.world.hasRain(entity.getBlockPos())) {
|
||||||
energyConsumed *= 3;
|
energyConsumed *= 3;
|
||||||
}
|
}
|
||||||
|
@ -359,7 +370,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
if (ticksInAir > (level * 100)) {
|
if (ticksInAir > (level * 100)) {
|
||||||
Bar mana = pony.getMagicalReserves().getMana();
|
Bar mana = pony.getMagicalReserves().getMana();
|
||||||
|
|
||||||
float cost = (float)-getHorizontalMotion(entity) * 20F / level;
|
float cost = (float)-getHorizontalMotion() * 20F / level;
|
||||||
if (entity.isSneaking()) {
|
if (entity.isSneaking()) {
|
||||||
cost /= 10;
|
cost /= 10;
|
||||||
}
|
}
|
||||||
|
@ -368,7 +379,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
|
|
||||||
if (mana.getPercentFill() < 0.2) {
|
if (mana.getPercentFill() < 0.2) {
|
||||||
pony.getMagicalReserves().getExertion().add(2);
|
pony.getMagicalReserves().getExertion().add(2);
|
||||||
pony.getMagicalReserves().getExhaustion().add(2 + (int)(getHorizontalMotion(entity) * 50));
|
pony.getMagicalReserves().getExhaustion().add(2 + (int)(getHorizontalMotion() * 50));
|
||||||
|
|
||||||
if (mana.getPercentFill() < 0.1 && ticksInAir % 10 == 0) {
|
if (mana.getPercentFill() < 0.1 && ticksInAir % 10 == 0) {
|
||||||
float exhaustion = (0.3F * ticksInAir) / 70;
|
float exhaustion = (0.3F * ticksInAir) / 70;
|
||||||
|
@ -383,7 +394,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAvianTakeoffConditions(MutableVector velocity) {
|
private void checkAvianTakeoffConditions(MutableVector velocity) {
|
||||||
double horMotion = getHorizontalMotion(entity);
|
double horMotion = getHorizontalMotion();
|
||||||
double motion = entity.getPos().subtract(lastPos).lengthSquared();
|
double motion = entity.getPos().subtract(lastPos).lengthSquared();
|
||||||
|
|
||||||
boolean takeOffCondition = velocity.y > 0
|
boolean takeOffCondition = velocity.y > 0
|
||||||
|
@ -415,7 +426,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
BlockState state = entity.world.getBlockState(pos);
|
BlockState state = entity.world.getBlockState(pos);
|
||||||
|
|
||||||
if (!entity.world.isAir(pos) && Block.isFaceFullSquare(state.getCollisionShape(entity.world, pos), entity.getHorizontalFacing().getOpposite())) {
|
if (!entity.world.isAir(pos) && Block.isFaceFullSquare(state.getCollisionShape(entity.world, pos), entity.getHorizontalFacing().getOpposite())) {
|
||||||
double motion = Math.sqrt(getHorizontalMotion(entity));
|
double motion = Math.sqrt(getHorizontalMotion());
|
||||||
|
|
||||||
float distance = (float)(motion * 20 - 3);
|
float distance = (float)(motion * 20 - 3);
|
||||||
|
|
||||||
|
@ -441,7 +452,7 @@ public class PlayerPhysics extends EntityPhysics<PlayerEntity> implements Tickab
|
||||||
}
|
}
|
||||||
|
|
||||||
private void moveFlying(MutableVector velocity) {
|
private void moveFlying(MutableVector velocity) {
|
||||||
double motion = getHorizontalMotion(entity);
|
double motion = getHorizontalMotion();
|
||||||
|
|
||||||
float forward = 0.000015F * (1 + (pony.getLevel().get() / 10F)) * (float)Math.sqrt(motion);
|
float forward = 0.000015F * (1 + (pony.getLevel().get() / 10F)) * (float)Math.sqrt(motion);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue