mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-11 23:07:37 +00:00
Implemented animation caching
This commit is contained in:
1 parent
7820ad171b
commit
a67604e22d
7 files changed
+99
-24
No files matched your search
@@ -30,6 +30,7 @@ import noppes.npcs.client.gui.util.*;
|
||||
import noppes.npcs.config.ConfigClient;
|
||||
import noppes.npcs.constants.EnumGuiType;
|
||||
import noppes.npcs.constants.EnumPacketClient;
|
||||
import noppes.npcs.constants.EnumPacketServer;
|
||||
import noppes.npcs.controllers.RecipeController;
|
||||
import noppes.npcs.controllers.data.Animation;
|
||||
import noppes.npcs.controllers.data.AnimationData;
|
||||
@@ -299,24 +300,37 @@ public class PacketHandlerClient extends PacketHandlerServer{
|
||||
}
|
||||
else if(type == EnumPacketClient.UPDATE_ANIMATIONS) {
|
||||
NBTTagCompound compound = Server.readNBT(buffer);
|
||||
AnimationData animationData = null;
|
||||
if (compound.hasKey("EntityId")) {
|
||||
Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(compound.getInteger("EntityId"));
|
||||
if (entity instanceof EntityNPCInterface) {
|
||||
AnimationData data = ((EntityNPCInterface) entity).display.animationData;
|
||||
data.readFromNBT(compound);
|
||||
data.animation = new Animation();
|
||||
data.animation.readFromNBT(compound.getCompoundTag("Animation"));
|
||||
animationData = ((EntityNPCInterface) entity).display.animationData;
|
||||
}
|
||||
} else {
|
||||
EntityPlayer sendingPlayer = Minecraft.getMinecraft().theWorld.getPlayerEntityByName(Server.readString(buffer));
|
||||
if (sendingPlayer != null) {
|
||||
AnimationData data = new AnimationData(sendingPlayer);
|
||||
data.readFromNBT(compound);
|
||||
data.animation = new Animation();
|
||||
data.animation.readFromNBT(compound.getCompoundTag("Animation"));
|
||||
ClientCacheHandler.playerAnimations.put(sendingPlayer.getUniqueID(), data);
|
||||
ClientCacheHandler.playerAnimations.put(sendingPlayer.getUniqueID(), new AnimationData(sendingPlayer));
|
||||
animationData = ClientCacheHandler.playerAnimations.get(sendingPlayer.getUniqueID());
|
||||
}
|
||||
}
|
||||
|
||||
if (animationData != null) {
|
||||
animationData.readFromNBT(compound);
|
||||
int animationId;
|
||||
if (compound.hasKey("AnimationID")) {
|
||||
animationId = compound.getInteger("AnimationID");
|
||||
} else {
|
||||
Animation animation = new Animation();
|
||||
animation.readFromNBT(compound.getCompoundTag("Animation"));
|
||||
ClientCacheHandler.animationCache.put(animation.getID(), animation);
|
||||
animationId = animation.getID();
|
||||
}
|
||||
|
||||
Animation animation = new Animation();
|
||||
animation.readFromNBT(ClientCacheHandler.animationCache.get(animationId).writeToNBT());
|
||||
animationData.animation = animation;
|
||||
Client.sendData(EnumPacketServer.CacheAnimation, animationId);
|
||||
}
|
||||
}
|
||||
else if(type == EnumPacketClient.DISABLE_MOUSE_INPUT) {
|
||||
long length = buffer.readLong();
|
||||
|
||||
Reference in new issue
Block a user