Анимации при помощи GeckoLib

Версия Minecraft
1.12.2
API
Forge
36
0
Сделал моба при помощи Геколиб, все работает, модель, текстура, но вот анимация не совсем, анимация афк работает, анимация ходьбы тоже, а вот удара нет, делал по примеру самого геколиба, если есть хоть какие то догадки, прошу поделиться ими

Класс моба:
package com.lunya.hm.entity.EntityGiant;

import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackMelee;
import net.minecraft.entity.ai.EntityAIAvoidEntity;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import software.bernie.geckolib3.core.IAnimatable;
import software.bernie.geckolib3.core.IAnimationTickable;
import software.bernie.geckolib3.core.PlayState;
import software.bernie.geckolib3.core.builder.AnimationBuilder;
import software.bernie.geckolib3.core.controller.AnimationController;
import software.bernie.geckolib3.core.event.predicate.AnimationEvent;
import software.bernie.geckolib3.core.manager.AnimationData;
import software.bernie.geckolib3.core.manager.AnimationFactory;

public class GeoExampleEntity extends EntityCreature implements IAnimatable, IAnimationTickable {
    private AnimationFactory factory = new AnimationFactory(this);
    private boolean swingingArms;
    
    private <E extends IAnimatable> PlayState idlePredicate(AnimationEvent<E> event) {
        event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.bat.idle", true));
        return PlayState.CONTINUE;
    }

    private int attackTime = 0;
    private int attackCooldown = 20; // 20 ticks = 1 second

    private <E extends IAnimatable> PlayState attackPredicate(AnimationEvent<E> event) {
        if ((this.swingProgress > -0.4F || this.swingProgress <= 0.0F && this.attackTime > 0) && this.attackTime <= 20) {
            this.attackTime = this.attackCooldown;
            event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.bat.attack", false));
        } else if (this.attackTime > 0) {
            --this.attackTime;
            event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.bat.attack", false));
        } else if (event.isMoving()) {
            event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.bat.walk", true));
        } else {
            event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.bat.idle", true));
        }
        return PlayState.CONTINUE;
    }

    public GeoExampleEntity(World worldIn) {
        super(worldIn);
        this.ignoreFrustumCheck = true;
        this.setSize(0.7F, 1.3F);
    }
    @Override
    public void swingArm(EnumHand hand) {
        super.swingArm(hand);
        this.swingingArms = true;
    }

    @Override
    public boolean isAIDisabled() {
        return false;
    }

    public int getUpdateInterval() {
        return 1; // Устанавливаем частоту обновления моба в 1 тик
    }

    @Override
    public void registerControllers(AnimationData data) {
        data.addAnimationController(new AnimationController<GeoExampleEntity>(this, "idleController", 1, this::idlePredicate));
        data.addAnimationController(new AnimationController<GeoExampleEntity>(this, "attackController", 1, this::attackPredicate));
    }

    @Override
    protected void initEntityAI() {
        this.tasks.addTask(2, new EntityAISwimming(this));
        this.tasks.addTask(1, new EntityAIWander(this, 0.5D)); // increase speed parameter
        this.tasks.addTask(2, new EntityAIAttackMelee(this, 0.5D, true));
        this.tasks.addTask(3, new EntityAIAvoidEntity(this, EntityMob.class, 4.0F, 2.2D, 2.2D));
        this.tasks.addTask(4, new EntityAIWatchClosest(this, EntityPlayer.class, 1.0F));

        this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false));
        this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true, canDropLoot(), null));
    }
    
    @Override
    protected void applyEntityAttributes() {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(5.0D);
        this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.3D); // increase movement speed
        this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(10.0D);
    }

    @Override
    public boolean attackEntityAsMob(Entity entityIn) {
        if (entityIn instanceof EntityPlayer) {
            EntityPlayer player = (EntityPlayer) entityIn;
            player.attackEntityFrom(DamageSource.GENERIC, 5.0F);
        }
        this.swingProgress = -0.4F; // Add this line
        this.attackTime = this.attackCooldown; // Reset the attackTime here
        return super.attackEntityAsMob(entityIn);
    }

    @Override
    public AnimationFactory getFactory() {
        return this.factory;
    }

    @Override
    public int tickTimer() {
        return ticksExisted;
    }

    @Override
    public void tick() {
        super.onUpdate();
    }
}
класс модели:
package com.lunya.hm.client.model;

import com.lunya.hm.entity.EntityGiant.GeoExampleEntity;
import com.lunya.hm.reference.Reference;

import net.minecraft.util.ResourceLocation;
import software.bernie.geckolib3.model.AnimatedTickingGeoModel;

public class ExampleEntityModel extends AnimatedTickingGeoModel<GeoExampleEntity> {
    @Override
    public ResourceLocation getAnimationFileLocation(GeoExampleEntity entity) {
        return new ResourceLocation(Reference.MODID, "animations/bat.animation.json");
    }

    @Override
    public ResourceLocation getModelLocation(GeoExampleEntity entity) {
        return new ResourceLocation(Reference.MODID, "geo/bat.geo.json");
    }

    @Override
    public ResourceLocation getTextureLocation(GeoExampleEntity entity) {
        return new ResourceLocation(Reference.MODID, "textures/models/entity/bat.png");
    }
}
рендер:
package com.lunya.hm.client.renderer;

import com.lunya.hm.client.model.ExampleEntityModel;
import com.lunya.hm.entity.EntityGiant.GeoExampleEntity;

import net.minecraft.client.renderer.entity.RenderManager;
import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer;

public class ExampleGeoRenderer extends GeoEntityRenderer<GeoExampleEntity> {

    public ExampleGeoRenderer(RenderManager renderManager) {
        super(renderManager, new ExampleEntityModel());
    }
}
 
Сверху