From 7e30286c2cea42f60e6337862d674716bdd4eaa8 Mon Sep 17 00:00:00 2001 From: Louis_Quepierts Date: Tue, 20 Aug 2024 14:57:30 +0800 Subject: [PATCH] 1.2.3 Bug Fix: NullPointerException during ClientAnimator sync. --- .../api/event/common/CancelInteractEvent.java | 10 +++++++++- .../simpleanimator/core/client/ClientAnimator.java | 2 +- .../simpleanimator/core/mixin/PlayerMixin.java | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/net/quepierts/simpleanimator/api/event/common/CancelInteractEvent.java b/common/src/main/java/net/quepierts/simpleanimator/api/event/common/CancelInteractEvent.java index 2307776..ffa5500 100644 --- a/common/src/main/java/net/quepierts/simpleanimator/api/event/common/CancelInteractEvent.java +++ b/common/src/main/java/net/quepierts/simpleanimator/api/event/common/CancelInteractEvent.java @@ -4,13 +4,17 @@ import net.minecraft.world.entity.player.Player; import net.quepierts.simpleanimator.api.event.SAEvent; +import java.util.UUID; + @SuppressWarnings("unused") public class CancelInteractEvent extends SAEvent { private final Player player; + private final UUID target; private final ResourceLocation interactionID; - public CancelInteractEvent(Player player, ResourceLocation interactionID) { + public CancelInteractEvent(Player player, UUID other, ResourceLocation interactionID) { this.player = player; + this.target = other; this.interactionID = interactionID; } @@ -18,6 +22,10 @@ public Player getPlayer() { return player; } + public UUID getTarget() { + return target; + } + public ResourceLocation getInteractionID() { return interactionID; } diff --git a/common/src/main/java/net/quepierts/simpleanimator/core/client/ClientAnimator.java b/common/src/main/java/net/quepierts/simpleanimator/core/client/ClientAnimator.java index 4f8320b..3887611 100644 --- a/common/src/main/java/net/quepierts/simpleanimator/core/client/ClientAnimator.java +++ b/common/src/main/java/net/quepierts/simpleanimator/core/client/ClientAnimator.java @@ -76,7 +76,7 @@ public void update(AnimatorDataPacket packet) { public void sync(AnimatorDataPacket packet) { ResourceLocation location = this.animationLocation; super.sync(packet); - if (!location.equals(this.animationLocation)) { + if (!location.equals(this.animationLocation) || this.animation != null) { Set animationVariables = this.animation.getVariables(); for (String variable : animationVariables) { this.variables.computeIfAbsent(variable, VariableHolder::get); diff --git a/common/src/main/java/net/quepierts/simpleanimator/core/mixin/PlayerMixin.java b/common/src/main/java/net/quepierts/simpleanimator/core/mixin/PlayerMixin.java index 3887f2e..8e47a7a 100644 --- a/common/src/main/java/net/quepierts/simpleanimator/core/mixin/PlayerMixin.java +++ b/common/src/main/java/net/quepierts/simpleanimator/core/mixin/PlayerMixin.java @@ -134,7 +134,7 @@ public void createAnimator(Level level, BlockPos blockPos, float f, GameProfile if (!this.simpleanimator$request.hasRequest()) return; - SimpleAnimator.EVENT_BUS.post(new CancelInteractEvent((Player) (Object) this, this.simpleanimator$request.getInteraction())); + SimpleAnimator.EVENT_BUS.post(new CancelInteractEvent((Player) (Object) this, this.simpleanimator$request.getTarget(), this.simpleanimator$request.getInteraction())); this.simpleanimator$animator.stop(); this.simpleanimator$request.reset();