Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed incompatibility with playerAnimator #1901

Open
wants to merge 1 commit into
base: 1.20.1
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/yesman/epicfight/compat/PlayerAnimatorCompat.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
15 changes: 5 additions & 10 deletions src/main/java/yesman/epicfight/main/EpicFightMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -237,6 +228,10 @@ public EpicFightMod() {
if (ModList.get().isLoaded("iceandfire")) {
ICompatModule.loadCompatModule(IceAndFireCompat.class);
}

if (ModList.get().isLoaded("playeranimator")) {
ICompatModule.loadCompatModule(PlayerAnimatorCompat.class);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -662,6 +665,10 @@ public StaticAnimation getHitAnimation(StunType stunType) {
};
}
}

public Player getPlayer() {
return this.player;
}

public enum PlayerMode {
MINING, BATTLE
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/mixins.epicfight.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"MixinThrownTrident",
"MixinServerGamePacketListenerImpl"
],
"injector": {
"injectors": {
"defaultRequire": 1
},
"refmap": "mixins.epicfight.refmap.json"
Expand Down