Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Commit

Permalink
fix: still update pose for players who had their entity type switched
Browse files Browse the repository at this point in the history
  • Loading branch information
mworzala committed Jan 29, 2024
1 parent 9fc4137 commit da46d07
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/minestom/server/entity/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,7 @@ protected void updatePose() {
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);
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/net/minestom/server/entity/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
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;
Expand Down Expand Up @@ -820,18 +821,15 @@ protected void updatePose() {
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;
Expand Down

0 comments on commit da46d07

Please sign in to comment.