mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-22 21:20:04 +00:00
Add GeckoLib Support
This commit is contained in:
1 parent
6f8d99d94a
commit
c67a8e43cb
13 files changed
+565
-16
No files matched your search
@@ -0,0 +1,77 @@
|
||||
package noppes.npcs.entity;
|
||||
|
||||
import net.minecraft.entity.EntityCreature;
|
||||
import net.minecraft.entity.ai.EntityAIWatchClosest;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
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;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class EntityGeckoModel extends EntityCreature implements IAnimatable, IAnimationTickable {
|
||||
private AnimationFactory factory = new AnimationFactory(this);
|
||||
public ResourceLocation modelResLoc=new ResourceLocation("geckolib3", "geo/npc.geo.json");
|
||||
public ResourceLocation animResLoc=new ResourceLocation("custom", "geo_npc.animation.json");
|
||||
public ResourceLocation textureResLoc = new ResourceLocation("geckolib3", "textures/model/entity/geo_npc.png");
|
||||
public String idleAnim = "";
|
||||
public String walkAnim = "";
|
||||
public String hurtAnim = "";
|
||||
public String attackAnim = "";
|
||||
private <E extends IAnimatable> PlayState predicateMovement(AnimationEvent<E> event) {
|
||||
if(!event.isMoving()){
|
||||
if(!Objects.equals(idleAnim, "")) {
|
||||
event.getController().setAnimation(new AnimationBuilder().addAnimation(idleAnim, true));
|
||||
}
|
||||
}else{
|
||||
if(!Objects.equals(idleAnim, "")) {
|
||||
event.getController().setAnimation(new AnimationBuilder().addAnimation(walkAnim, true));
|
||||
}
|
||||
}
|
||||
//event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.bat.fly", true));
|
||||
return PlayState.CONTINUE;
|
||||
}
|
||||
private <E extends IAnimatable> PlayState predicateAttack(AnimationEvent<E> event) {
|
||||
//event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.bat.fly", true));
|
||||
return PlayState.CONTINUE;
|
||||
}
|
||||
private <E extends IAnimatable> PlayState predicateManual(AnimationEvent<E> event) {
|
||||
return PlayState.CONTINUE;
|
||||
}
|
||||
|
||||
public EntityGeckoModel(World worldIn) {
|
||||
super(worldIn);
|
||||
this.ignoreFrustumCheck = true;
|
||||
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
|
||||
this.setSize(0.7F, 2F);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerControllers(AnimationData data) {
|
||||
data.addAnimationController(new AnimationController<>(this, "movement", 10, this::predicateMovement));
|
||||
data.addAnimationController(new AnimationController<>(this, "attack", 10, this::predicateAttack));
|
||||
data.addAnimationController(new AnimationController<>(this, "manual", 10, this::predicateManual));
|
||||
}
|
||||
|
||||
@Override
|
||||
public AnimationFactory getFactory() {
|
||||
return this.factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int tickTimer() {
|
||||
return ticksExisted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.onUpdate();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user