Fixed some issues with animations not continuing when they should

This commit is contained in:
luisc committed 2025-02-12 13:16:39 -06:00
1 parent 3b9c38124e
commit 0418aa11e4
5 files changed
+33 -16

No files matched your search

@@ -13,12 +13,10 @@ import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.entity.RendererLivingEntity;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.MouseEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.client.event.RenderPlayerEvent;
import net.minecraftforge.client.event.*;
import net.minecraftforge.event.entity.living.LivingEvent;
import noppes.npcs.client.gui.customoverlay.OverlayCustom;
import noppes.npcs.client.renderer.MarkRenderer;
@@ -107,8 +105,17 @@ public class ClientEventHandler {
ClientEventHandler.renderer = event.renderer;
ClientEventHandler.partialRenderTick = Minecraft.getMinecraft().timer.renderPartialTicks;
if (event.entity instanceof EntityClientPlayerMP) {
Render render = RenderManager.instance.getEntityClassRenderObject(event.entity.getClass());
this.setOriginalPlayerParts(event.entity);
}
@SubscribeEvent
public void renderHand(RenderHandEvent event) {
this.setOriginalPlayerParts(Minecraft.getMinecraft().thePlayer);
}
private void setOriginalPlayerParts(Entity entity) {
if (entity instanceof EntityClientPlayerMP) {
Render render = RenderManager.instance.getEntityClassRenderObject(entity.getClass());
if (!processedPlayerRenderers.contains(render)) {
processedPlayerRenderers.add(render);
Collection<ModelRenderer> modelRenderers = getAllModelRenderers(render);
@@ -39,7 +39,9 @@ public class ClientTickHandler{
public void onClientTick(TickEvent.ClientTickEvent event){
Minecraft mc = Minecraft.getMinecraft();
if ((this.prevWorld == null || mc.theWorld == null) && this.prevWorld != mc.theWorld) {
ClientCacheHandler.clearCache();
if (mc.theWorld == null) {
ClientCacheHandler.clearCache();
}
this.prevWorld = mc.theWorld;
}
if(event.phase == Phase.END) {
@@ -46,6 +46,9 @@ public class AnimationData implements IAnimationData {
}
public static AnimationData getData(Entity entity) {
if (entity == null) {
return null;
}
if (entity.worldObj.isRemote) {
return CustomNpcs.proxy.getClientAnimationData(entity);
}
@@ -69,7 +69,15 @@ public class PlayerData implements IExtendedEntityProperties, IPlayerData {
public ScreenSize screenSize = new ScreenSize(-1,-1);
public void onLogin() {
}
//Continue playing animation for self when re-logging
AnimationData animationData = this.animationData;
if (animationData != null && animationData.isClientAnimating()) {
Animation currentAnimation = animationData.currentClientAnimation;
NBTTagCompound compound = currentAnimation.writeToNBT();
animationData.viewAnimation(currentAnimation, animationData, compound,
animationData.isClientAnimating(), currentAnimation.currentFrame, currentAnimation.currentFrameTime);
}
}
public void onLogout() {
this.partyInvites.clear();
@@ -3,7 +3,6 @@ package noppes.npcs.mixin;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityClientPlayerMP;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.*;
@@ -39,7 +38,6 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -73,9 +71,9 @@ public abstract class MixinItemRenderer {
}
private boolean mixin_renderFirstPersonAnimation(float partialRenderTick, EntityPlayer player, ModelBiped model) {
AnimationData animData = ClientCacheHandler.playerAnimations.get(player.getUniqueID());
if (animData != null && animData.isActive()) {
Frame frame = (Frame) animData.animation.currentFrame();
AnimationData animationData = ClientCacheHandler.playerAnimations.get(player.getUniqueID());
if (animationData != null && animationData.isActive()) {
Frame frame = (Frame) animationData.animation.currentFrame();
if (frame.frameParts.containsKey(EnumAnimationPart.FULL_MODEL)) {
FramePart part = frame.frameParts.get(EnumAnimationPart.FULL_MODEL);
part.interpolateOffset();
@@ -87,8 +85,7 @@ public abstract class MixinItemRenderer {
EnumAnimationPart[] enumParts = new EnumAnimationPart[]{EnumAnimationPart.RIGHT_ARM, EnumAnimationPart.LEFT_ARM, EnumAnimationPart.RIGHT_LEG, EnumAnimationPart.LEFT_LEG};
Frame frame;
AnimationData animationData = ClientCacheHandler.playerAnimations.get(player.getUniqueID());
if (animationData != null && animationData.isActive() && animationData.getAnimation() != null && animationData.getAnimation().currentFrame() != null) {
if (animationData != null && animationData.isActive()) {
Animation animation = (Animation) animationData.getAnimation();
frame = (Frame) animation.currentFrame();
for (int i = 0; i < parts.length; i++) {
@@ -109,7 +106,7 @@ public abstract class MixinItemRenderer {
return false;
}
if (animData != null && animData.isActive()) {
if (animationData != null && animationData.isActive()) {
if (frame.frameParts.containsKey(EnumAnimationPart.FULL_MODEL)) {
FramePart part = frame.frameParts.get(EnumAnimationPart.FULL_MODEL);
float pi = 180 / (float) Math.PI;