From 8ba15348eaea96afaed1e0025d8d5da10727cdd3 Mon Sep 17 00:00:00 2001 From: LostInLinearPast <1283411677@qq.com> Date: Fri, 2 Jan 2026 19:50:36 +0800 Subject: [PATCH 1/2] version 0.1.8 --- build.gradle | 5 ++ gradle.properties | 2 +- .../sccore/animation/data/util/AnimJson.java | 47 ++++++++++--------- .../animation/data/util/RawAnimJson.java | 45 ++++++++++-------- .../toclient/AnimationClearPacket.java | 20 +++++--- .../sccore/mixin/SCCoreMixinPlugin.java | 11 +++-- 6 files changed, 78 insertions(+), 52 deletions(-) diff --git a/build.gradle b/build.gradle index c3eb257..f9ef6dc 100644 --- a/build.gradle +++ b/build.gradle @@ -173,6 +173,7 @@ tasks.named('jar', Jar).configure { ]) } + archiveFileName = "${mod_id}-${mod_version}-origin.jar" finalizedBy 'reobfJar' } @@ -251,8 +252,12 @@ publishing { gradle.buildFinished { def javadocJar = file("build/libs/${mod_id}-${mod_version}-javadoc.jar") def sourcesJar = file("build/libs/${mod_id}-${mod_version}-sources.jar") + def allJarsJar = file("build/libs/${mod_id}-${mod_version}-all.jar") if (javadocJar.exists()) ant.delete(file: javadocJar) if (sourcesJar.exists()) ant.delete(file: sourcesJar) + if (allJarsJar.exists()) { + ant.move(file: allJarsJar, tofile: file("build/libs/${mod_id}-${mod_version}.jar")) + } } tasks.withType(JavaCompile).configureEach { diff --git a/gradle.properties b/gradle.properties index 30e5f1f..1d5ad81 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ mapping_version=2023.09.03-1.20.1 mod_id=sccore mod_name=SnowyCrescentCore mod_license=GNU AGPL 3.0 -mod_version=1.20.1-0.1.7.1 +mod_version=1.20.1-0.1.8 mod_group_id=com.linearpast mod_authors=LostInLinearPast mod_description=A lib about capability and player animator. diff --git a/src/main/java/com/linearpast/sccore/animation/data/util/AnimJson.java b/src/main/java/com/linearpast/sccore/animation/data/util/AnimJson.java index 8d5c0bb..bc9f70d 100644 --- a/src/main/java/com/linearpast/sccore/animation/data/util/AnimJson.java +++ b/src/main/java/com/linearpast/sccore/animation/data/util/AnimJson.java @@ -66,22 +66,35 @@ public class AnimJson { GenericAnimationData animation = GenericAnimationData.create(new ResourceLocation(json.get(Key).getAsString())); if(json.has(Name)) animation.withName(json.get(Name).getAsString()); if(json.has(LyingType)) animation.withLyingType(AnimationData.LyingType.valueOf(json.get(LyingType).getAsString())); - JsonObject camOffset = json.get(CamPosOffset).getAsJsonObject(); - animation.withHeightModifier(json.get(HeightModifier).getAsFloat()) - .withCamComputePriority(json.get(Priority).getAsInt()) - .setCamPosOffset(new Vec3( - camOffset.get("x").getAsDouble(), - camOffset.get("y").getAsDouble(), - camOffset.get("z").getAsDouble() - )) - .withCamPosOffsetRelative(camOffset.get(Relative).getAsBoolean()) - .withCamPitch(json.get(CamPitch).getAsFloat()) - .withCamRoll(json.get(CamRoll).getAsFloat()) - .withCamYaw(json.get(CamYaw).getAsFloat()); + if(json.has(HeightModifier)) animation.withHeightModifier(json.get(HeightModifier).getAsFloat()); + if(json.has(Priority)) animation.withCamComputePriority(json.get(Priority).getAsInt()); + if(json.has(CamPitch)) animation.withCamPitch(json.get(CamPitch).getAsFloat()); + if(json.has(CamRoll)) animation.withCamRoll(json.get(CamRoll).getAsFloat()); + if(json.has(CamYaw)) animation.withCamYaw(json.get(CamYaw).getAsFloat()); + if(json.has(CamPosOffset)) { + JsonObject camOffset = json.get(CamPosOffset).getAsJsonObject(); + Vec3 vec3 = Vec3.ZERO; + if(camOffset.has("x")) vec3 = vec3.add(camOffset.get("x").getAsDouble(), 0, 0); + if(camOffset.has("y")) vec3 = vec3.add(0, camOffset.get("y").getAsDouble(), 0); + if(camOffset.has("z")) vec3 = vec3.add(0, 0, camOffset.get("z").getAsDouble()); + if(!vec3.equals(Vec3.ZERO)) animation.setCamPosOffset(vec3); + if(camOffset.has(Relative)) animation.withCamPosOffsetRelative(camOffset.get(Relative).getAsBoolean()); + } if(json.has(WithRide)){ Ride ride = Ride.create(); JsonObject withRide = json.get(WithRide).getAsJsonObject(); - JsonObject offsetJson = withRide.get(Offset).getAsJsonObject(); + if(withRide.has(ExistTick)) ride.setExistTick(withRide.get(ExistTick).getAsInt()); + if(withRide.has(XRot)) ride.setXRot(withRide.get(XRot).getAsFloat()); + if(withRide.has(YRot)) ride.setYRot(withRide.get(YRot).getAsFloat()); + if(withRide.has(Offset)) { + JsonObject offsetJson = withRide.get(Offset).getAsJsonObject(); + Vec3 offset = new Vec3( + offsetJson.get("x").getAsDouble(), + offsetJson.get("y").getAsDouble(), + offsetJson.get("z").getAsDouble() + ); + ride.withOffset(offset); + } if(withRide.has(ComponentsAnimation)){ JsonArray elements = withRide.get(ComponentsAnimation).getAsJsonArray(); for (JsonElement element : elements) { @@ -90,14 +103,6 @@ public class AnimJson { ride.addComponentAnimation(componentKey); } } - Vec3 offset = new Vec3( - offsetJson.get("x").getAsDouble(), - offsetJson.get("y").getAsDouble(), - offsetJson.get("z").getAsDouble() - ); - ride.withOffset(offset).withExistTick(withRide.get(ExistTick).getAsInt()) - .withXRot(withRide.get(XRot).getAsFloat()) - .withYRot(withRide.get(YRot).getAsFloat()); animation.withRide(ride); } return animation; diff --git a/src/main/java/com/linearpast/sccore/animation/data/util/RawAnimJson.java b/src/main/java/com/linearpast/sccore/animation/data/util/RawAnimJson.java index a0514e0..68825f5 100644 --- a/src/main/java/com/linearpast/sccore/animation/data/util/RawAnimJson.java +++ b/src/main/java/com/linearpast/sccore/animation/data/util/RawAnimJson.java @@ -59,21 +59,34 @@ public class RawAnimJson { JsonObject json = originElement.getAsJsonObject(); RawAnimationData animation = RawAnimationData.create(new ResourceLocation(json.get(Key).getAsString())); if(json.has(LyingType)) animation.withLyingType(AnimationData.LyingType.valueOf(json.get(LyingType).getAsString())); - JsonObject camOffset = json.get(CamPosOffset).getAsJsonObject(); - animation.withCamComputePriority(json.get(Priority).getAsInt()) - .setCamPosOffset(new Vec3( - camOffset.get("x").getAsDouble(), - camOffset.get("y").getAsDouble(), - camOffset.get("z").getAsDouble() - )) - .withCamPosOffsetRelative(camOffset.get(Relative).getAsBoolean()) - .withCamPitch(json.get(CamPitch).getAsFloat()) - .withCamRoll(json.get(CamRoll).getAsFloat()) - .withCamYaw(json.get(CamYaw).getAsFloat()); + if(json.has(Priority)) animation.withCamComputePriority(json.get(Priority).getAsInt()); + if(json.has(CamPitch)) animation.withCamPitch(json.get(CamPitch).getAsFloat()); + if(json.has(CamRoll)) animation.withCamRoll(json.get(CamRoll).getAsFloat()); + if(json.has(CamYaw)) animation.withCamYaw(json.get(CamYaw).getAsFloat()); + if(json.has(CamPosOffset)) { + JsonObject camOffset = json.get(CamPosOffset).getAsJsonObject(); + Vec3 vec3 = Vec3.ZERO; + if(camOffset.has("x")) vec3 = vec3.add(camOffset.get("x").getAsDouble(), 0, 0); + if(camOffset.has("y")) vec3 = vec3.add(0, camOffset.get("y").getAsDouble(), 0); + if(camOffset.has("z")) vec3 = vec3.add(0, 0, camOffset.get("z").getAsDouble()); + if(!vec3.equals(Vec3.ZERO)) animation.setCamPosOffset(vec3); + if(camOffset.has(Relative)) animation.withCamPosOffsetRelative(camOffset.get(Relative).getAsBoolean()); + } if(json.has(WithRide)){ Ride ride = Ride.create(); JsonObject withRide = json.get(WithRide).getAsJsonObject(); - JsonObject offsetJson = withRide.get(Offset).getAsJsonObject(); + if(withRide.has(ExistTick)) ride.setExistTick(withRide.get(ExistTick).getAsInt()); + if(withRide.has(XRot)) ride.setXRot(withRide.get(XRot).getAsFloat()); + if(withRide.has(YRot)) ride.setYRot(withRide.get(YRot).getAsFloat()); + if(withRide.has(Offset)) { + JsonObject offsetJson = withRide.get(Offset).getAsJsonObject(); + Vec3 offset = new Vec3( + offsetJson.get("x").getAsDouble(), + offsetJson.get("y").getAsDouble(), + offsetJson.get("z").getAsDouble() + ); + ride.withOffset(offset); + } if(withRide.has(ComponentsAnimation)){ JsonArray elements = withRide.get(ComponentsAnimation).getAsJsonArray(); for (JsonElement element : elements) { @@ -82,14 +95,6 @@ public class RawAnimJson { ride.addComponentAnimation(componentKey); } } - Vec3 offset = new Vec3( - offsetJson.get("x").getAsDouble(), - offsetJson.get("y").getAsDouble(), - offsetJson.get("z").getAsDouble() - ); - ride.withOffset(offset).withExistTick(withRide.get(ExistTick).getAsInt()) - .withXRot(withRide.get(XRot).getAsFloat()) - .withYRot(withRide.get(YRot).getAsFloat()); animation.withRide(ride); } return animation; diff --git a/src/main/java/com/linearpast/sccore/animation/network/toclient/AnimationClearPacket.java b/src/main/java/com/linearpast/sccore/animation/network/toclient/AnimationClearPacket.java index e2deeec..f3f03d7 100644 --- a/src/main/java/com/linearpast/sccore/animation/network/toclient/AnimationClearPacket.java +++ b/src/main/java/com/linearpast/sccore/animation/network/toclient/AnimationClearPacket.java @@ -6,6 +6,9 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.fml.DistExecutor; import net.minecraftforge.network.NetworkEvent; import org.jetbrains.annotations.Nullable; @@ -26,12 +29,17 @@ public record AnimationClearPacket(@Nullable ResourceLocation layer) { NetworkEvent.Context context = supplier.get(); context.enqueueWork(() -> { context.setPacketHandled(true); - LocalPlayer player = Minecraft.getInstance().player; - if(player == null) return; - List layers = new ArrayList<>(); - if(layer != null) layers.add(layer); - else layers.addAll(AnimationRegistry.getLayers().keySet()); - layers.forEach(layer -> AnimationUtils.playAnimation(player, layer, null)); + DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> this::handle); }); } + + @OnlyIn(Dist.CLIENT) + public void handle(){ + LocalPlayer player = Minecraft.getInstance().player; + if(player == null) return; + List layers = new ArrayList<>(); + if(layer != null) layers.add(layer); + else layers.addAll(AnimationRegistry.getLayers().keySet()); + layers.forEach(layer -> AnimationUtils.playAnimation(player, layer, null)); + } } diff --git a/src/main/java/com/linearpast/sccore/mixin/SCCoreMixinPlugin.java b/src/main/java/com/linearpast/sccore/mixin/SCCoreMixinPlugin.java index 3b84bc0..11ca04f 100644 --- a/src/main/java/com/linearpast/sccore/mixin/SCCoreMixinPlugin.java +++ b/src/main/java/com/linearpast/sccore/mixin/SCCoreMixinPlugin.java @@ -2,7 +2,8 @@ package com.linearpast.sccore.mixin; import com.linearpast.sccore.SnowyCrescentCore; import com.linearpast.sccore.animation.service.AnimationService; -import net.minecraftforge.fml.ModList; +import net.minecraftforge.fml.loading.LoadingModList; +import net.minecraftforge.fml.loading.moddiscovery.ModInfo; import org.objectweb.asm.tree.ClassNode; import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; import org.spongepowered.asm.mixin.extensibility.IMixinInfo; @@ -23,11 +24,13 @@ public class SCCoreMixinPlugin implements IMixinConfigPlugin { @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { - if (targetClassName.startsWith("runData\\.")) { + if (targetClassName.startsWith("runData.")) { return "runData".equals(System.getProperty("gradle.task")); } - if (mixinClassName.startsWith("com\\.linearpast\\." + SnowyCrescentCore.MODID + "\\.mixin\\.animation")) { - return ModList.get().isLoaded(AnimationService.AnimModId); + if (mixinClassName.startsWith("com.linearpast." + SnowyCrescentCore.MODID + ".mixin.animation.")) { + return LoadingModList.get().getMods().stream().map(ModInfo::getModId).anyMatch( + s -> s.equals(AnimationService.AnimModId) + ); } return true; } From deda6a2e7571a88c917b319fff190ac03e560c85 Mon Sep 17 00:00:00 2001 From: LostInLinearPast <1283411677@qq.com> Date: Thu, 8 Jan 2026 04:50:00 +0800 Subject: [PATCH 2/2] version 0.1.9 --- gradle.properties | 2 +- .../animation/entity/AnimationRideEntity.java | 14 +++++++-- .../event/client/ClientPlayerEvent.java | 4 +-- .../animation/helper/AnimationHelper.java | 13 ++++++++ .../network/toserver/StopAnimationPacket.java | 30 +++++++++++++++++++ .../animation/register/AnimationChannels.java | 5 ++++ .../animation/service/IAnimationService.java | 16 ++++++++-- .../animation/utils/AnimationUtils.java | 6 ++-- 8 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/linearpast/sccore/animation/network/toserver/StopAnimationPacket.java diff --git a/gradle.properties b/gradle.properties index 1d5ad81..a54dbb9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -12,7 +12,7 @@ mapping_version=2023.09.03-1.20.1 mod_id=sccore mod_name=SnowyCrescentCore mod_license=GNU AGPL 3.0 -mod_version=1.20.1-0.1.8 +mod_version=1.20.1-0.1.9 mod_group_id=com.linearpast mod_authors=LostInLinearPast mod_description=A lib about capability and player animator. diff --git a/src/main/java/com/linearpast/sccore/animation/entity/AnimationRideEntity.java b/src/main/java/com/linearpast/sccore/animation/entity/AnimationRideEntity.java index 67073c2..7068a7a 100644 --- a/src/main/java/com/linearpast/sccore/animation/entity/AnimationRideEntity.java +++ b/src/main/java/com/linearpast/sccore/animation/entity/AnimationRideEntity.java @@ -6,6 +6,7 @@ import com.linearpast.sccore.animation.data.AnimationData; import com.linearpast.sccore.animation.data.Ride; import com.linearpast.sccore.animation.register.AnimationEntities; import com.linearpast.sccore.animation.service.AnimationService; +import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; @@ -103,7 +104,7 @@ public class AnimationRideEntity extends Entity { } @Nullable - public static AnimationRideEntity create(ServerPlayer pPlayer, ResourceLocation layer, AnimationData anim, boolean force) { + public static AnimationRideEntity create(ServerPlayer pPlayer, ResourceLocation layer, AnimationData anim, boolean force, Vec3 pos) { if(anim == null) return null; if(anim.getRide() == null) return null; IAnimationCapability data = AnimationDataCapability.getCapability(pPlayer).orElse(null); @@ -114,7 +115,6 @@ public class AnimationRideEntity extends Entity { float yRot = anim.getRide().getYRot(); if(xRot == 0 && yRot == 0) seat.setRot(pPlayer.getXRot(), pPlayer.getYRot()); else seat.setRot(yRot, xRot); - Vec3 pos = pPlayer.position(); pos.add(anim.getRide().getOffset()); seat.setPos(pos.x, pos.y + 0.35f, pos.z); pPlayer.level().addFreshEntity(seat); @@ -122,6 +122,16 @@ public class AnimationRideEntity extends Entity { return seat; } + @Nullable + public static AnimationRideEntity create(ServerPlayer pPlayer, ResourceLocation layer, AnimationData anim, boolean force) { + return create(pPlayer, layer, anim, force, pPlayer.position()); + } + + @Nullable + public static AnimationRideEntity create(ServerPlayer pPlayer, ResourceLocation layer, AnimationData anim, boolean force, BlockPos pos) { + return create(pPlayer, layer, anim, force, pos.getCenter()); + } + @Override protected void positionRider(@NotNull Entity pPassenger, @NotNull MoveFunction pCallback) { super.positionRider(pPassenger, pCallback); diff --git a/src/main/java/com/linearpast/sccore/animation/event/client/ClientPlayerEvent.java b/src/main/java/com/linearpast/sccore/animation/event/client/ClientPlayerEvent.java index 38341b0..3aaeff8 100644 --- a/src/main/java/com/linearpast/sccore/animation/event/client/ClientPlayerEvent.java +++ b/src/main/java/com/linearpast/sccore/animation/event/client/ClientPlayerEvent.java @@ -1,6 +1,6 @@ package com.linearpast.sccore.animation.event.client; -import com.linearpast.sccore.animation.service.AnimationService; +import com.linearpast.sccore.animation.AnimationApi; import net.minecraft.client.player.AbstractClientPlayer; import net.minecraft.world.entity.player.Player; import net.minecraftforge.api.distmarker.Dist; @@ -19,7 +19,7 @@ public class ClientPlayerEvent { Player player = event.player; if(player.tickCount % 10 != 0) return; if (!(player instanceof AbstractClientPlayer clientPlayer)) return; - AnimationService.INSTANCE.refreshAnimation(clientPlayer); + AnimationApi.getHelper(clientPlayer).refreshAnimation(); } } diff --git a/src/main/java/com/linearpast/sccore/animation/helper/AnimationHelper.java b/src/main/java/com/linearpast/sccore/animation/helper/AnimationHelper.java index 581ecba..8737066 100644 --- a/src/main/java/com/linearpast/sccore/animation/helper/AnimationHelper.java +++ b/src/main/java/com/linearpast/sccore/animation/helper/AnimationHelper.java @@ -8,9 +8,11 @@ import com.linearpast.sccore.core.IModLazyRun; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.core.BlockPos; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.jetbrains.annotations.Nullable; @@ -51,6 +53,17 @@ public class AnimationHelper { () -> service.playAnimationWithRide(lazyRun.getClientPlayer(), layer, animation.getKey(), isForce) ); } + public ApiBack playAnimationWithRide(ResourceLocation layer, AnimationData animation, boolean isForce, Vec3 pos) { + IAnimationService service = AnimationApi.getServiceGetterHelper(animation.getKey()).getService(); + if(service == null) return ApiBack.FAIL; + return lazyRun.testLoadedAndCall( + () -> service.playAnimationWithRide(lazyRun.getServerPlayer(), layer, animation, isForce, pos), + () -> ApiBack.UNSUPPORTED + ); + } + public ApiBack playAnimationWithRide(ResourceLocation layer, AnimationData animation, boolean isForce, BlockPos pos) { + return playAnimationWithRide(layer, animation, isForce, pos.getCenter()); + } public void clearAnimation() { for (IAnimationService service : AnimationApi.getServiceGetterHelper().getAllServices()) { diff --git a/src/main/java/com/linearpast/sccore/animation/network/toserver/StopAnimationPacket.java b/src/main/java/com/linearpast/sccore/animation/network/toserver/StopAnimationPacket.java new file mode 100644 index 0000000..335116e --- /dev/null +++ b/src/main/java/com/linearpast/sccore/animation/network/toserver/StopAnimationPacket.java @@ -0,0 +1,30 @@ +package com.linearpast.sccore.animation.network.toserver; + +import com.linearpast.sccore.animation.AnimationApi; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import net.minecraftforge.network.NetworkEvent; + +import java.util.function.Supplier; + +public record StopAnimationPacket(ResourceLocation layer) { + public StopAnimationPacket(FriendlyByteBuf buf) { + this(buf.readResourceLocation()); + } + + public void encode(FriendlyByteBuf buf) { + buf.writeResourceLocation(layer); + } + + public void handle(Supplier supplier) { + NetworkEvent.Context context = supplier.get(); + context.enqueueWork(() -> { + context.setPacketHandled(true); + ServerPlayer sender = context.getSender(); + if(sender == null) return; + AnimationApi.getHelper(sender).removeAnimation(layer); + }); + } + +} diff --git a/src/main/java/com/linearpast/sccore/animation/register/AnimationChannels.java b/src/main/java/com/linearpast/sccore/animation/register/AnimationChannels.java index c0c6186..5f8c979 100644 --- a/src/main/java/com/linearpast/sccore/animation/register/AnimationChannels.java +++ b/src/main/java/com/linearpast/sccore/animation/register/AnimationChannels.java @@ -57,6 +57,11 @@ public class AnimationChannels { .encoder(RequestAnimationPacket::encode) .consumerMainThread(RequestAnimationPacket::handle) .add(); + ModChannel.INSTANCE.messageBuilder(StopAnimationPacket.class, cid(), NetworkDirection.PLAY_TO_SERVER) + .decoder(StopAnimationPacket::new) + .encoder(StopAnimationPacket::encode) + .consumerMainThread(StopAnimationPacket::handle) + .add(); } private static int cid() { diff --git a/src/main/java/com/linearpast/sccore/animation/service/IAnimationService.java b/src/main/java/com/linearpast/sccore/animation/service/IAnimationService.java index c609004..ee58632 100644 --- a/src/main/java/com/linearpast/sccore/animation/service/IAnimationService.java +++ b/src/main/java/com/linearpast/sccore/animation/service/IAnimationService.java @@ -21,12 +21,15 @@ import com.linearpast.sccore.core.ModCompatRun; import com.linearpast.sccore.core.configs.ModConfigs; import dev.kosmx.playerAnim.core.data.KeyframeAnimation; import dev.kosmx.playerAnim.minecraftApi.PlayerAnimationRegistry; +import net.minecraft.client.Minecraft; import net.minecraft.client.player.AbstractClientPlayer; +import net.minecraft.client.player.LocalPlayer; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.phys.Vec3; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; @@ -251,6 +254,10 @@ public interface IAnimationService { AnimationUtils.removeAnimation(player, layer); + LocalPlayer self = Minecraft.getInstance().player; + if(self != null && player != null && Objects.equals(self.getUUID(), player.getUUID())) { + ModChannel.INSTANCE.sendToServer(new StopAnimationPacket(layer)); + } return ApiBack.SUCCESS; }); } @@ -280,7 +287,7 @@ public interface IAnimationService { ResourceLocation key = animation.getKey(); if(!isAnimationLayerPresent(layer) || !isAnimationPresent(key)) @@ -292,10 +299,13 @@ public interface IAnimationService diff --git a/src/main/java/com/linearpast/sccore/animation/utils/AnimationUtils.java b/src/main/java/com/linearpast/sccore/animation/utils/AnimationUtils.java index 749f0d7..8ee7f33 100644 --- a/src/main/java/com/linearpast/sccore/animation/utils/AnimationUtils.java +++ b/src/main/java/com/linearpast/sccore/animation/utils/AnimationUtils.java @@ -81,16 +81,18 @@ public class AnimationUtils { Set resourceLocations = new HashSet<>(); if(layer == null) resourceLocations.addAll(AnimationRegistry.getLayers().keySet()); else resourceLocations.add(layer); + boolean isNoneAnimation = true; for (ResourceLocation location : resourceLocations) { ModifierLayer animationModifierLayer = (ModifierLayer) PlayerAnimationAccess .getPlayerAssociatedData(player).get(location); if(animationModifierLayer == null) continue; KeyframeAnimationPlayer animation = (KeyframeAnimationPlayer) animationModifierLayer.getAnimation(); - if(animation == null) return false; + if(animation == null) continue; int currentTick = animation.getCurrentTick(); int stopTick = animation.getStopTick(); - return currentTick > stopTick; + if(currentTick < stopTick) isNoneAnimation = false; } + return isNoneAnimation; } catch (Exception ignored) {} return true; });