mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-16 09:34:46 +00:00
If the animation data is disabled for players, their last frame of animation will gradually interpolate back to the player's vanilla animations.
This commit is contained in:
1 parent
a67604e22d
commit
bc089a4e14
4 files changed
+69
-17
No files matched your search
@@ -14,6 +14,7 @@ import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.controllers.PlayerDataController;
|
||||
import noppes.npcs.entity.EntityNPCInterface;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -27,11 +28,25 @@ public class AnimationData implements IAnimationData {
|
||||
|
||||
private final HashSet<Integer> cachedAnimationIDs = new HashSet<>();
|
||||
|
||||
//Client-side values
|
||||
public EntityLivingBase animationEntity;
|
||||
public int finishedTime = -1;
|
||||
public int finishedFrame = -1;
|
||||
|
||||
public AnimationData(Object parent){
|
||||
this.parent = parent;
|
||||
if (parent instanceof DataDisplay) {
|
||||
this.animationEntity = ((DataDisplay) parent).npc;
|
||||
} else if (parent instanceof EntityPlayer) {
|
||||
this.animationEntity = (EntityLivingBase) parent;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateClient() {
|
||||
this.updateClient(new EntityPlayer[0]);
|
||||
}
|
||||
|
||||
public void updateClient(EntityPlayer... excludedPlayers) {
|
||||
EntityLivingBase sendingEntity = parent instanceof PlayerData ? ((PlayerData) parent).player : parent instanceof DataDisplay ? ((DataDisplay) parent).npc : null;
|
||||
float range = parent instanceof PlayerData ? 160 : 60;
|
||||
if (sendingEntity != null) {
|
||||
@@ -40,6 +55,8 @@ public class AnimationData implements IAnimationData {
|
||||
sendingEntity.posX - range, sendingEntity.posY - range, sendingEntity.posZ - range,
|
||||
sendingEntity.posX + range, sendingEntity.posY + range, sendingEntity.posZ + range));
|
||||
|
||||
entities.removeIf(player -> Arrays.stream(excludedPlayers).anyMatch(exp -> player == exp));
|
||||
|
||||
NBTTagCompound animationNBT = null;
|
||||
for (EntityPlayer player : entities) {
|
||||
AnimationData animationData = PlayerDataController.Instance.getPlayerData(player).animationData;
|
||||
@@ -110,11 +127,16 @@ public class AnimationData implements IAnimationData {
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound compound) {
|
||||
this.allowAnimation = compound.getBoolean("AllowAnimation");
|
||||
this.setEnabled(compound.getBoolean("AllowAnimation"));
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.allowAnimation = enabled;
|
||||
if (this.allowAnimation != enabled) {
|
||||
this.allowAnimation = enabled;
|
||||
if (this.parent instanceof EntityPlayer) {
|
||||
this.finishedTime = enabled ? -1 : ((EntityPlayer) this.parent).getAge();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean enabled() {
|
||||
|
||||
Reference in new issue
Block a user