Remove outdated code/enum and add "setSleeping" and "setSwimming" while fixing "setSneaking"

This commit is contained in:
libraryaddict 2019-12-22 21:11:47 +13:00
parent fc957c76e9
commit 4835b6de0b
3 changed files with 44 additions and 37 deletions

View File

@ -9,6 +9,6 @@ public enum EntityPose {
SLEEPING,
SWIMMING,
SPIN_ATTACK,
SNEAKING,
CROUCHING,
DYING
}

View File

@ -38,6 +38,8 @@ public class FlagWatcher {
private boolean hasDied;
private boolean[] modifiedEntityAnimations = new boolean[8];
private transient List<WrappedWatchableObject> watchableObjects;
private boolean sleeping;
private boolean swimming;
public FlagWatcher(Disguise disguise) {
this.disguise = (TargetedDisguise) disguise;
@ -542,9 +544,50 @@ public class FlagWatcher {
public void setSneaking(boolean setSneaking) {
setEntityFlag(1, setSneaking);
updatePose();
sendData(MetaIndex.ENTITY_META);
}
public boolean isSleeping() {
return sleeping;
}
public void setSleeping(boolean sleeping) {
if (isSleeping() == sleeping) {
return;
}
this.sleeping = sleeping;
updatePose();
}
public boolean isSwimming() {
return swimming;
}
public void setSwimming(boolean swimming) {
if (isSwimming() == swimming) {
return;
}
this.swimming = swimming;
updatePose();
}
protected void updatePose() {
if (isSleeping()) {
setEntityPose(EntityPose.SLEEPING);
} else if (isSwimming()) {
setEntityPose(EntityPose.SWIMMING);
} else if (isSneaking()) {
setEntityPose(EntityPose.CROUCHING);
} else {
setEntityPose(EntityPose.STANDING);
}
}
public void setSprinting(boolean setSprinting) {
setEntityFlag(3, setSprinting);
sendData(MetaIndex.ENTITY_META);

View File

@ -54,11 +54,6 @@ public class PlayerWatcher extends LivingWatcher {
return MainHand.values()[getData(MetaIndex.PLAYER_HAND)];
}
@Deprecated
public BlockFace getSleepingDirection() {
return BlockFace.SELF;
}
// Bit 0 (0x01): Cape enabled
// Bit 1 (0x02): Jacket enabled
// Bit 2 (0x04): Left Sleeve enabled
@ -141,11 +136,6 @@ public class PlayerWatcher extends LivingWatcher {
sendData(MetaIndex.PLAYER_SKIN);
}
@Deprecated
public boolean isSleeping() {
return getEntityPose() == EntityPose.SLEEPING;
}
public void setSkin(String playerName) {
((PlayerDisguise) getDisguise()).setSkin(playerName);
}
@ -154,32 +144,6 @@ public class PlayerWatcher extends LivingWatcher {
((PlayerDisguise) getDisguise()).setSkin(profile);
}
@Deprecated
public void setSleeping(BlockFace sleepingDirection) {
setSleeping(true, sleepingDirection);
}
@Deprecated
public void setSleeping(boolean sleep) {
setSleeping(sleep, null);
}
/**
* If no BlockFace is supplied. It grabs it from the entities facing direction if applicable.
*
* @param sleeping
* @param sleepingDirection
*/
@Deprecated
public void setSleeping(boolean sleeping, BlockFace sleepingDirection) {
if (sleeping == isSleeping()) {
return;
}
setEntityPose(sleeping ? EntityPose.SLEEPING : EntityPose.STANDING);
}
private void setSkinFlags(int i, boolean flag) {
byte b0 = getData(MetaIndex.PLAYER_SKIN);