Animation fixes, temporarily removed caching.

This commit is contained in:
Luis C.M. committed 2025-01-23 00:35:25 -06:00
1 parent 572077b7e5
commit 34d002191e
3 files changed
+28 -24

No files matched your search

@@ -491,12 +491,28 @@ public class ServerEventsHandler {
@SubscribeEvent
public void playerTracking(PlayerEvent.StartTracking event){
if(!(event.target instanceof EntityNPCInterface) || event.target.worldObj.isRemote)
if(!(event.target instanceof EntityPlayerMP || event.target instanceof EntityNPCInterface) || event.target.worldObj.isRemote)
return;
MarkData data = MarkData.get((EntityNPCInterface) event.target);
if(data.marks.isEmpty())
return;
Server.sendData((EntityPlayerMP)event.entityPlayer, EnumPacketClient.MARK_DATA, event.target.getEntityId(), data.getNBT());
AnimationData animationData = AnimationData.getData(event.target);
if (animationData.isClientAnimating()) {
AnimationData playerAnimData = AnimationData.getData(event.entityPlayer);
Animation currentAnimation = animationData.currentClientAnimation;
NBTTagCompound compound = currentAnimation.writeToNBT();
if (playerAnimData.viewAnimation(currentAnimation, animationData, compound,
animationData.isClientAnimating(), currentAnimation.currentFrame, currentAnimation.currentFrameTime)) {
synchronized (CommonProxy.serverPlayingAnimations) {
CommonProxy.serverPlayingAnimations.add(animationData);
}
}
}
if (event.target instanceof EntityNPCInterface) {
MarkData data = MarkData.get((EntityNPCInterface) event.target);
if (data.marks.isEmpty())
return;
Server.sendData((EntityPlayerMP) event.entityPlayer, EnumPacketClient.MARK_DATA, event.target.getEntityId(), data.getNBT());
}
}
}
@@ -368,19 +368,14 @@ public class PacketHandlerClient extends PacketHandlerServer{
}
if (animationData != null) {
int animationId;
if (compound.hasKey("AnimationID")) {
animationId = compound.getInteger("AnimationID");
} else {
if (compound.hasKey("Animation")) {
Animation animation = new Animation();
animation.readFromNBT(compound.getCompoundTag("Animation"));
ClientCacheHandler.animationCache.put(animation.getID(), animation);
animationId = animation.getID();
animationData.setAnimation(animation);
} else {
animationData.setAnimation(null);
}
animationData.setAnimation(ClientCacheHandler.animationCache.get(animationId));
animationData.readFromNBT(compound);
Client.sendData(EnumPacketServer.CacheAnimation, animationId);
}
}
else if(type == EnumPacketClient.DISABLE_MOUSE_INPUT) {
@@ -120,12 +120,9 @@ public class AnimationData implements IAnimationData {
entities.removeIf(player -> Arrays.stream(excludedPlayers).anyMatch(exp -> player == exp));
NBTTagCompound animationNBT = null;
for (EntityPlayer player : entities) {
AnimationData animationData = PlayerDataController.Instance.getPlayerData(player).animationData;
if (animationNBT == null && this.animation != null && !animationData.isCached(this.animation.getID())) {
animationNBT = this.animation.writeToNBT();
}
NBTTagCompound animationNBT = this.animation != null ? this.animation.writeToNBT() : null;
animationData.viewAnimation(this.animation, this, animationNBT);
}
}
@@ -221,12 +218,8 @@ public class AnimationData implements IAnimationData {
data.setInteger("Time", time);
}
if (animation != null) {
if (this.cachedAnimationIDs.contains(animation.getID()) && !data.hasKey("Frame")) {
data.setInteger("AnimationID", animation.getID());
} else {
data.setTag("Animation", animationNBT);
}
if (animationNBT != null) {
data.setTag("Animation", animationNBT);
}
IAnimatable animatable = animationData.getEntity();