fix: still update pose for players who had their entity type switched

This commit is contained in:
mworzala 2024-01-29 15:59:44 -05:00
parent 9fc4137995
commit da46d07699
No known key found for this signature in database
GPG Key ID: B148F922E64797C7
2 changed files with 4 additions and 6 deletions

View File

@ -1237,7 +1237,7 @@ public class Entity implements Viewable, Tickable, Schedulable, Snapshotable, Ev
setPose(Pose.FALL_FLYING);
} else if (entityMeta.isSwimming()) {
setPose(Pose.SWIMMING);
} else if (this instanceof LivingEntity && ((LivingEntityMeta) entityMeta).isInRiptideSpinAttack()) {
} else if (entityMeta instanceof LivingEntityMeta livingMeta && livingMeta.isInRiptideSpinAttack()) {
setPose(Pose.SPIN_ATTACK);
} else if (entityMeta.isSneaking()) {
setPose(Pose.SNEAKING);

View File

@ -33,6 +33,7 @@ import net.minestom.server.coordinate.Vec;
import net.minestom.server.effects.Effects;
import net.minestom.server.entity.damage.DamageType;
import net.minestom.server.entity.fakeplayer.FakePlayer;
import net.minestom.server.entity.metadata.LivingEntityMeta;
import net.minestom.server.entity.metadata.PlayerMeta;
import net.minestom.server.entity.vehicle.PlayerVehicleInformation;
import net.minestom.server.event.EventDispatcher;
@ -820,18 +821,15 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
Pose oldPose = getPose();
Pose newPose;
// If they are not a player, do nothing
if (!getEntityType().equals(EntityType.PLAYER)) return;
// Figure out their expected state
var meta = Objects.requireNonNull(getLivingEntityMeta());
var meta = getEntityMeta();
if (meta.isFlyingWithElytra()) {
newPose = Pose.FALL_FLYING;
} else if (false) { // When should they be sleeping? We don't have any in-bed state...
newPose = Pose.SLEEPING;
} else if (meta.isSwimming()) {
newPose = Pose.SWIMMING;
} else if (meta.isInRiptideSpinAttack()) {
} else if (meta instanceof LivingEntityMeta livingMeta && livingMeta.isInRiptideSpinAttack()) {
newPose = Pose.SPIN_ATTACK;
} else if (isSneaking() && !isFlying()) {
newPose = Pose.SNEAKING;