From 340165d4f45c0595de7a2b9eb8467402d2e5804b Mon Sep 17 00:00:00 2001 From: ZigyTheBird <105124180+ZigyTheBird@users.noreply.github.com> Date: Sat, 18 Jan 2025 21:04:27 +0330 Subject: [PATCH] Fixed incompatibility with playerAnimator --- build.gradle | 2 ++ .../compat/PlayerAnimatorCompat.java | 31 +++++++++++++++++++ .../yesman/epicfight/main/EpicFightMod.java | 15 +++------ .../entitypatch/player/PlayerPatch.java | 7 +++++ src/main/resources/mixins.epicfight.json | 2 +- 5 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 src/main/java/yesman/epicfight/compat/PlayerAnimatorCompat.java diff --git a/build.gradle b/build.gradle index dae9eec5..032e31b3 100644 --- a/build.gradle +++ b/build.gradle @@ -131,6 +131,8 @@ dependencies { implementation fg.deobf("curse.maven:ice-and-fire-dragons-264231:5633453") implementation fg.deobf("curse.maven:citadel-331936:5559513") + + implementation fg.deobf("curse.maven:playeranimator-658587:4587214") // These mods don't allow 3rd party distribution compileOnly fg.deobf("local:skinlayers3d:1.6.6") diff --git a/src/main/java/yesman/epicfight/compat/PlayerAnimatorCompat.java b/src/main/java/yesman/epicfight/compat/PlayerAnimatorCompat.java new file mode 100644 index 00000000..4178f637 --- /dev/null +++ b/src/main/java/yesman/epicfight/compat/PlayerAnimatorCompat.java @@ -0,0 +1,31 @@ +package yesman.epicfight.compat; + +import dev.kosmx.playerAnim.impl.IAnimatedPlayer; +import dev.kosmx.playerAnim.impl.animation.AnimationApplier; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.eventbus.api.IEventBus; +import yesman.epicfight.api.client.forgeevent.RenderEpicFightPlayerEvent; + +public class PlayerAnimatorCompat implements ICompatModule { + @Override + public void onModEventBus(IEventBus eventBus) {} + + @Override + public void onForgeEventBus(IEventBus eventBus) {} + + @Override + public void onModEventBusClient(IEventBus eventBus) {} + + @Override + @OnlyIn(Dist.CLIENT) + public void onForgeEventBusClient(IEventBus eventBus) { + eventBus.addListener(this::renderEvent); + } + + @OnlyIn(Dist.CLIENT) + private void renderEvent(RenderEpicFightPlayerEvent event) { + AnimationApplier emote = ((IAnimatedPlayer) event.getPlayerPatch().getPlayer()).playerAnimator_getAnimation(); + if (emote.isActive()) event.setShouldRender(false); + } +} diff --git a/src/main/java/yesman/epicfight/main/EpicFightMod.java b/src/main/java/yesman/epicfight/main/EpicFightMod.java index 48faf436..11328cdb 100644 --- a/src/main/java/yesman/epicfight/main/EpicFightMod.java +++ b/src/main/java/yesman/epicfight/main/EpicFightMod.java @@ -50,16 +50,7 @@ import yesman.epicfight.client.gui.screen.SkillBookScreen; import yesman.epicfight.client.gui.screen.config.IngameConfigurationScreen; import yesman.epicfight.client.renderer.patched.item.EpicFightItemProperties; -import yesman.epicfight.compat.AzureLibArmorCompat; -import yesman.epicfight.compat.AzureLibCompat; -import yesman.epicfight.compat.FirstPersonCompat; -import yesman.epicfight.compat.GeckolibCompat; -import yesman.epicfight.compat.ICompatModule; -import yesman.epicfight.compat.IRISCompat; -import yesman.epicfight.compat.IceAndFireCompat; -import yesman.epicfight.compat.SkinLayer3DCompat; -import yesman.epicfight.compat.VampirismCompat; -import yesman.epicfight.compat.WerewolvesCompat; +import yesman.epicfight.compat.*; import yesman.epicfight.config.ConfigManager; import yesman.epicfight.config.EpicFightOptions; import yesman.epicfight.data.conditions.EpicFightConditions; @@ -237,6 +228,10 @@ public EpicFightMod() { if (ModList.get().isLoaded("iceandfire")) { ICompatModule.loadCompatModule(IceAndFireCompat.class); } + + if (ModList.get().isLoaded("playeranimator")) { + ICompatModule.loadCompatModule(PlayerAnimatorCompat.class); + } } /** diff --git a/src/main/java/yesman/epicfight/world/capabilities/entitypatch/player/PlayerPatch.java b/src/main/java/yesman/epicfight/world/capabilities/entitypatch/player/PlayerPatch.java index 4f46443e..be527038 100644 --- a/src/main/java/yesman/epicfight/world/capabilities/entitypatch/player/PlayerPatch.java +++ b/src/main/java/yesman/epicfight/world/capabilities/entitypatch/player/PlayerPatch.java @@ -80,6 +80,8 @@ public static void createSyncedEntityData(LivingEntity livingentity) { protected int lastChargingTick; protected int chargingAmount; protected ChargeableSkill chargingSkill; + + protected Player player; // Manage the previous position here because playerpatch#tick called before entity#travel method. protected double xo; @@ -220,6 +222,7 @@ public void serverTick(LivingEvent.LivingTickEvent event) { @Override public void tick(LivingEvent.LivingTickEvent event) { + this.player = (Player) event.getEntity(); if (this.playerMode == PlayerMode.BATTLE || this.battleModeRestricted) { BattleModeSustainableEvent battleModeSustainableEvent = new BattleModeSustainableEvent(this); MinecraftForge.EVENT_BUS.post(battleModeSustainableEvent); @@ -662,6 +665,10 @@ public StaticAnimation getHitAnimation(StunType stunType) { }; } } + + public Player getPlayer() { + return this.player; + } public enum PlayerMode { MINING, BATTLE diff --git a/src/main/resources/mixins.epicfight.json b/src/main/resources/mixins.epicfight.json index 5f8c7910..7e732151 100644 --- a/src/main/resources/mixins.epicfight.json +++ b/src/main/resources/mixins.epicfight.json @@ -32,7 +32,7 @@ "MixinThrownTrident", "MixinServerGamePacketListenerImpl" ], - "injector": { + "injectors": { "defaultRequire": 1 }, "refmap": "mixins.epicfight.refmap.json"