Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Geckolib animation


Recommended Posts

Hi!

I have troubles understanding how Geckolib animation works. I've already created a model and an animation, and put them in game. Now my entity is contstantly playing this animation, and I don't know how to make that this animation would only play when entity is wolking/looking around/eating.

 

My entity class:

public class ExampleEntity extends CreatureEntity implements IAnimatable {

	private AnimationFactory factory = new AnimationFactory(this);
	public ExampleEntity(EntityType<? extends CreatureEntity> type, World worldIn)
    {
        super(type, worldIn);
        this.ignoreFrustumCheck = true;
		// TODO Auto-generated constructor stub
	}
	
	 public static AttributeModifierMap.MutableAttribute setAttributes() {
	      return MobEntity.func_233666_p_().createMutableAttribute(Attributes.MAX_HEALTH, 20.0f)
	    		  .createMutableAttribute(Attributes.ATTACK_DAMAGE, 5.0f)
	    		  .createMutableAttribute(Attributes.ATTACK_SPEED, 3.0f)
	    		  .createMutableAttribute(Attributes.MOVEMENT_SPEED, 1.5f);
	    		  }
	
	 @Override
	protected void registerGoals() {
		
		super.registerGoals();
		this.goalSelector.addGoal(0, new SwimGoal(this));
		this.goalSelector.addGoal(1, new LookRandomlyGoal(this));
		this.goalSelector.addGoal(2, new LookAtGoal(this, PlayerEntity.class, 8.0f)); 
		this.goalSelector.addGoal(1, new PanicGoal(this, 0.7d)); 
		this.goalSelector.addGoal(1, new WaterAvoidingRandomWalkingGoal(this, 0.5d, 100f));
		this.goalSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, PlayerEntity.class, true));
		
     
	}
	 
	 @Override
	protected int getExperiencePoints(PlayerEntity player) {
		// TODO Auto-generated method stub
		return 10;
	}
	 
	 @Override
	protected SoundEvent getDeathSound() {
		// TODO Auto-generated method stub
		return SoundEvents.ENTITY_HOGLIN_DEATH;
	}
	 
	  private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event)
	    {
	        event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.akirathedemon.walk", true));
	        
	        return PlayState.CONTINUE;
	    }

	@Override
	public void registerControllers(AnimationData data) {
		 data.addAnimationController(new AnimationController(this, "controller", 0, this::predicate));
		
	}

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

 

Edited by urabaros
Link to post
Share on other sites
33 minutes ago, urabaros said:

private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event) { event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.akirathedemon.walk", true)); return PlayState.CONTINUE; }

You need some condition checking here, e.g. if walking add walk animation, and only add eating animation when eating... etc

Link to post
Share on other sites

Yea, I understand that, so I'm asking how exactly should I check.

 

Because animations doesn't really work when I do this:

if (event.isMoving()) {
		  event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.examplemode.walk", true));
		  return PlayState.CONTINUE;
}
		  	
return PlayState.STOP;

 

Link to post
Share on other sites

Thanks! It's perfectly working: 

if (this.prevPosX == this.getPosX() && this.prevPosY == this.getPosY() && this.prevPosZ == this.getPosZ()) {
			  return PlayState.STOP;
		  }
		  else {
			  event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.examplemod.walk", true));
		  		return PlayState.CONTINUE;
		  }

 

And do you know, how can I check if the specific goal is running? Should I just (GoalSelector.getRunningGoals == new SwimGoal) or something like that?

Link to post
Share on other sites

Hm...

 public boolean isPanic() {
			//LOGGER.info("The AttackingEntity will be: " + this.getAttackingEntity());
			return this.goalSelector.getRunningGoals().anyMatch(goal -> goal.getGoal().getClass() == PanicGoal.class);
		}
	 
	  private <E extends IAnimatable> PlayState predicate(AnimationEvent<E> event)
	    {
		  if(isPanic()) {
			  event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.akirathedemon.panic", true));
		  		return PlayState.CONTINUE;
		  }
		   
		  if (this.prevPosX == this.getPosX() && this.prevPosY == this.getPosY() && this.prevPosZ == this.getPosZ()) {
			  event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.akirathedemon.nod", true));
		  		return PlayState.CONTINUE;
		  }
		  else {
			  event.getController().setAnimation(new AnimationBuilder().addAnimation("animation.akirathedemon.walk", true));
		  	return PlayState.CONTINUE;
		  }
		  	

It looks completely right for me. Is there something that can prevent it from working?

Edited by urabaros
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • i am looking for a mod that shows all the chunks that have been loaded or a mod that shows all of the chunks that are currently loaded for 1.17.1
    • Heya. I have been trying to figure out why using /tp keeps crashing me when Im using forge 1.16.5. the crash report is below. please help me out. ---- Minecraft Crash Report ---- // Don't do that. Time: 7/25/21 5:11 PM Description: Exception generating new chunk java.lang.IllegalArgumentException: bound must be positive     at java.util.Random.nextInt(Random.java:388) ~[?:1.8.0_51] {}     at net.minecraft.world.gen.feature.structure.Structure.func_236392_a_(Structure.java:202) ~[?:?] {re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B}     at net.minecraft.world.gen.feature.structure.Structure.func_242785_a(Structure.java:221) ~[?:?] {re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B}     at net.minecraft.world.gen.feature.StructureFeature.func_242771_a(SourceFile:35) ~[?:?] {re:classloading}     at net.minecraft.world.gen.ChunkGenerator.func_242705_a(SourceFile:278) ~[?:?] {re:mixin,re:classloading,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorAccessor,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorMixin,pl:mixin:A}     at net.minecraft.world.gen.ChunkGenerator.func_242707_a(SourceFile:267) ~[?:?] {re:mixin,re:classloading,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorAccessor,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorMixin,pl:mixin:A}     at net.minecraft.world.chunk.ChunkStatus.lambda$static$2(ChunkStatus.java:41) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.world.chunk.ChunkStatus$$Lambda$2265/387194988.doWork(Unknown Source) ~[?:?] {}     at net.minecraft.world.chunk.ChunkStatus.func_223198_a(ChunkStatus.java:198) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.world.server.ChunkManager.lambda$null$18(ChunkManager.java:524) ~[?:?] {re:classloading}     at net.minecraft.world.server.ChunkManager$$Lambda$6523/918777125.apply(Unknown Source) ~[?:?] {}     at com.mojang.datafixers.util.Either$Left.map(Either.java:38) ~[datafixerupper-4.0.26.jar:?] {re:classloading,re:classloading}     at net.minecraft.world.server.ChunkManager.lambda$chunkGenerate$20(ChunkManager.java:522) ~[?:?] {re:classloading}     at net.minecraft.world.server.ChunkManager$$Lambda$6520/530773096.apply(Unknown Source) ~[?:?] {}     at java.util.concurrent.CompletableFuture.uniCompose(CompletableFuture.java:952) ~[?:1.8.0_51] {}     at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:926) ~[?:1.8.0_51] {}     at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:442) ~[?:1.8.0_51] {}     at net.minecraft.world.chunk.ChunkTaskPriorityQueueSorter.func_219083_b(SourceFile:58) ~[?:?] {re:classloading}     at net.minecraft.world.chunk.ChunkTaskPriorityQueueSorter$$Lambda$6464/1211192729.run(Unknown Source) ~[?:?] {}     at net.minecraft.util.concurrent.DelegatedTaskExecutor.func_213148_e(SourceFile:94) ~[?:?] {re:classloading}     at net.minecraft.util.concurrent.DelegatedTaskExecutor.func_213145_a(SourceFile:137) ~[?:?] {re:classloading}     at net.minecraft.util.concurrent.DelegatedTaskExecutor.run(SourceFile:105) ~[?:?] {re:classloading}     at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402) ~[?:1.8.0_51] {}     at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) ~[?:1.8.0_51] {}     at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) ~[?:1.8.0_51] {}     at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1689) ~[?:1.8.0_51] {}     at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) ~[?:1.8.0_51] {} A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Server thread Stacktrace:     at java.util.Random.nextInt(Random.java:388) ~[?:1.8.0_51] {}     at net.minecraft.world.gen.feature.structure.Structure.func_236392_a_(Structure.java:202) ~[?:?] {re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B}     at net.minecraft.world.gen.feature.structure.Structure.func_242785_a(Structure.java:221) ~[?:?] {re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B}     at net.minecraft.world.gen.feature.StructureFeature.func_242771_a(SourceFile:35) ~[?:?] {re:classloading}     at net.minecraft.world.gen.ChunkGenerator.func_242705_a(SourceFile:278) ~[?:?] {re:mixin,re:classloading,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorAccessor,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorMixin,pl:mixin:A}     at net.minecraft.world.gen.ChunkGenerator.func_242707_a(SourceFile:267) ~[?:?] {re:mixin,re:classloading,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorAccessor,pl:mixin:APP:repurposed_structures.mixins.json:ChunkGeneratorMixin,pl:mixin:A}     at net.minecraft.world.chunk.ChunkStatus.lambda$static$2(ChunkStatus.java:41) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.world.chunk.ChunkStatus$$Lambda$2265/387194988.doWork(Unknown Source) ~[?:?] {}     at net.minecraft.world.chunk.ChunkStatus.func_223198_a(ChunkStatus.java:198) ~[?:?] {re:classloading,pl:accesstransformer:B} -- Chunk to be generated -- Details:     Location: 170,-183     Position hash: -785979014998     Generator: net.minecraft.world.gen.NoiseChunkGenerator@68c16e02 Stacktrace:     at net.minecraft.world.server.ChunkManager.lambda$null$18(ChunkManager.java:524) ~[?:?] {re:classloading}     at net.minecraft.world.server.ChunkManager$$Lambda$6523/918777125.apply(Unknown Source) ~[?:?] {}     at com.mojang.datafixers.util.Either$Left.map(Either.java:38) ~[datafixerupper-4.0.26.jar:?] {re:classloading,re:classloading,re:classloading}     at net.minecraft.world.server.ChunkManager.lambda$chunkGenerate$20(ChunkManager.java:522) ~[?:?] {re:classloading}     at net.minecraft.world.server.ChunkManager$$Lambda$6520/530773096.apply(Unknown Source) ~[?:?] {}     at java.util.concurrent.CompletableFuture.uniCompose(CompletableFuture.java:952) ~[?:1.8.0_51] {}     at java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:926) ~[?:1.8.0_51] {}     at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:442) ~[?:1.8.0_51] {}     at net.minecraft.world.chunk.ChunkTaskPriorityQueueSorter.func_219083_b(SourceFile:58) ~[?:?] {re:classloading}     at net.minecraft.world.chunk.ChunkTaskPriorityQueueSorter$$Lambda$6464/1211192729.run(Unknown Source) ~[?:?] {}     at net.minecraft.util.concurrent.DelegatedTaskExecutor.func_213148_e(SourceFile:94) ~[?:?] {re:classloading} -- Affected level -- Details:     All players: 1 total; [ServerPlayerEntity['KrystalTheFox_'/132, l='ServerLevel[Modded Survival]', x=2748.50, y=77.00, z=-2911.50]]     Chunk stats: ServerChunkCache: 3347     Level dimension: minecraft:overworld     Level spawn location: World: (51,64,-90), Chunk: (at 3,4,6 in 3,-6; contains blocks 48,0,-96 to 63,255,-81), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1)     Level time: 42412 game time, 227 day time     Level name: Modded Survival     Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false     Level weather: Rain time: 120492 (now: false), thunder time: 52965 (now: false)     Known server brands: forge     Level was modded: true     Level storage version: 0x04ABD - Anvil Stacktrace:     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:854) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:787) ~[?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:78) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}     at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:642) [?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer.lambda$startServer$0(MinecraftServer.java:232) [?:?] {re:classloading,pl:accesstransformer:B}     at net.minecraft.server.MinecraftServer$$Lambda$6334/1896438195.run(Unknown Source) [?:?] {}     at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51] {} -- System Details -- Details:     Minecraft Version: 1.16.5     Minecraft Version ID: 1.16.5     Operating System: Windows 10 (amd64) version 10.0     Java Version: 1.8.0_51, Oracle Corporation     Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation     Memory: 1148904608 bytes (1095 MB) / 2147483648 bytes (2048 MB) up to 2147483648 bytes (2048 MB)     CPUs: 4     JVM Flags: 9 total; -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xss1M -Xmx2G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M     ModLauncher: 8.0.9+86+master.3cf110c     ModLauncher launch target: fmlclient     ModLauncher naming: srg     ModLauncher services:          /mixin-0.8.2.jar mixin PLUGINSERVICE          /eventbus-4.0.0.jar eventbus PLUGINSERVICE          /forge-1.16.5-36.0.45.jar object_holder_definalize PLUGINSERVICE          /forge-1.16.5-36.0.45.jar runtime_enum_extender PLUGINSERVICE          /accesstransformers-3.0.1.jar accesstransformer PLUGINSERVICE          /forge-1.16.5-36.0.45.jar capability_inject_definalize PLUGINSERVICE          /forge-1.16.5-36.0.45.jar runtimedistcleaner PLUGINSERVICE          /mixin-0.8.2.jar mixin TRANSFORMATIONSERVICE          /forge-1.16.5-36.0.45.jar fml TRANSFORMATIONSERVICE      FML: 36.0     Forge: net.minecraftforge:36.0.45     FML Language Providers:          javafml@36.0         minecraft@1     Mod List:          forge-1.16.5-36.0.45-client.jar                   |Minecraft                     |minecraft                     |1.16.5              |DONE      |NOSIGNATURE         dungeons_mobs-1.16.5-1.0.5.jar                    |Dungeons Mobs                 |dungeons_mobs                 |1.0.5               |DONE      |NOSIGNATURE         repurposed_structures-1.16.5-2.6.6-forge.jar      |Repurposed Structures         |repurposed_structures         |1.16.5-2.6.6-forge  |DONE      |NOSIGNATURE         illagers_plus-1.16.4v1.5.jar                      |Illagers+                     |illagers_plus                 |1.16.4v1.5          |DONE      |NOSIGNATURE         enchantwithmob-1.16.5-1.4.6.jar                   |Enchant With Mob              |enchantwithmob                |1.16.5-1.4.6        |DONE      |NOSIGNATURE         Ma-Enchants-1.16.5-3.6.0 (1).jar                  |Ma Enchants                   |ma-enchants                   |1.16.5-3.6.0        |DONE      |NOSIGNATURE         forge-1.16.5-36.0.45-universal.jar                |Forge                         |forge                         |36.0.45             |DONE      |22:af:21:d8:19:82:7f:93:94:fe:2b:ac:b7:e4:41:57:68:39:87:b1:a7:5c:c6:44:f9:25:74:21:14:f5:0d:90         torohealth-1.16.4-forge-4.jar                     |ToroHealth                    |torohealth                    |NONE                |DONE      |NOSIGNATURE         extragolems-11.3.0.jar                            |Extra Golems                  |golems                        |11.3.0              |DONE      |NOSIGNATURE         Deeper+in+The+Caves+Remake+1.1.jar                |Deeper In The Caves Remake    |stacked_dimensions_warden     |1.0.0               |DONE      |NOSIGNATURE         MobBattleMod-1.16.2-2.3.4 (2).jar                 |Mob Battle Mod                |mobbattle                     |1.16.2-2.3.4        |DONE      |NOSIGNATURE         supertools-1.16.5-4.5.jar                         |Vanilla+ Tools                |supertools                    |version             |DONE      |NOSIGNATURE     Crash Report UUID: 2888177d-2bf6-4908-99f1-1b7b6465ec05     Player Count: 1 / 8; [ServerPlayerEntity['KrystalTheFox_'/132, l='ServerLevel[Modded Survival]', x=2748.50, y=77.00, z=-2911.50]]     Data Packs: vanilla, mod:dungeons_mobs (incompatible), mod:repurposed_structures, mod:illagers_plus, mod:enchantwithmob, mod:ma-enchants (incompatible), mod:forge, mod:torohealth, mod:golems (incompatible), mod:stacked_dimensions_warden, mod:mobbattle (incompatible), mod:supertools (incompatible)     Type: Integrated Server (map_client.txt)     Is Modded: Definitely; Client brand changed to 'forge'
    • I installed a Forge server, ran the normal .jar file, accepted the EULA, tried to run the forge.jar file but it doesn't give me any folders (like the mods or config) folder. Already looked through the forum here but there weren't any help. I also updated to the newest Java version but it doesn't help.
    • I have a custom inventory that saves when i have the world running but when I rejoin the items are not there in the slots.
    • Hello, I have a weird issue with my server where I have to be on the multiplayer page on the same version as my friends for them to join the server. This has happened on all versions, no matter what mod, Forge and vanilla. It's not a LAN, and I've port forwarded, and I'm kinda new to this stuff anyways. Anybody have a reason to this?
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.