diff --git a/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/animation/animator/ModelAnimator.java b/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/animation/animator/ModelAnimator.java index 666a23455..6bd5c300a 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/animation/animator/ModelAnimator.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/animation/animator/ModelAnimator.java @@ -64,10 +64,10 @@ public static void animateKeyframe( float f = getRunningSeconds(animation, runningTime); Iterator var7 = animation.boneAnimations().entrySet().iterator(); - while(var7.hasNext()) { - Map.Entry> entry = (Map.Entry)var7.next(); - Optional optional = model.getChild((String)entry.getKey()); - List list = (List)entry.getValue(); + while (var7.hasNext()) { + Map.Entry> entry = (Map.Entry) var7.next(); + Optional optional = model.getChild((String) entry.getKey()); + List list = (List) entry.getValue(); optional.ifPresent((part) -> { list.forEach((transformation) -> { Keyframe[] keyframes = transformation.keyframes(); diff --git a/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/AnimatedEntityModel.java b/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/AnimatedEntityModel.java index a6987c5ba..77b96e73b 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/AnimatedEntityModel.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/AnimatedEntityModel.java @@ -1,7 +1,5 @@ package com.faboslav.friendsandfoes.client.render.entity.model; -import com.faboslav.friendsandfoes.FriendsAndFoes; -import com.faboslav.friendsandfoes.client.render.entity.animation.KeyframeAnimation; import com.faboslav.friendsandfoes.client.render.entity.animation.animator.ModelAnimator; import com.faboslav.friendsandfoes.entity.animation.AnimatedEntity; import com.faboslav.friendsandfoes.mixin.ModelPartAccessor; diff --git a/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/TuffGolemEntityModel.java b/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/TuffGolemEntityModel.java index 4246bec29..16d7f6865 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/TuffGolemEntityModel.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/client/render/entity/model/TuffGolemEntityModel.java @@ -1,11 +1,9 @@ package com.faboslav.friendsandfoes.client.render.entity.model; -import com.faboslav.friendsandfoes.FriendsAndFoes; import com.faboslav.friendsandfoes.entity.TuffGolemEntity; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.model.*; -import net.minecraft.util.math.MathHelper; @Environment(EnvType.CLIENT) public final class TuffGolemEntityModel extends AnimatedEntityModel @@ -72,15 +70,6 @@ public void setAngles( float headYaw, float headPitch ) { - /* - if(tuffGolem.isHoldingItem() && tuffGolem.hurtTime != 0) { - limbDistance = 1.0F; - limbAngle = 1.0F; - } - - FriendsAndFoes.getLogger().info(String.valueOf(limbDistance)); - FriendsAndFoes.getLogger().info(String.valueOf(limbAngle));*/ - this.getPart().traverse().forEach(ModelPart::resetTransform); this.updateMovementKeyframeAnimations(tuffGolem, limbAngle, limbDistance, 4.0F, 4F); this.updateKeyframeAnimations(tuffGolem, animationProgress); diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/RascalEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/RascalEntity.java index f6b32b80c..0ab20d78c 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/RascalEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/RascalEntity.java @@ -117,7 +117,7 @@ public AnimationContextTracker getAnimationContextTracker() { this.animationContextTracker.add(keyframeAnimation); } - this.animationContextTracker.add(RascalAnimations.WALK); + this.animationContextTracker.add(this.getMovementAnimation()); } return this.animationContextTracker; @@ -197,21 +197,14 @@ public void tick() { this.playReappearSound(); } - if (this.getWorld().isClient() == false && this.isAnyKeyframeAnimationRunning()) { - this.setKeyframeAnimationTicks(this.getKeyframeAnimationTicks() - 1); + if (this.getWorld().isClient() == false) { + this.updateKeyframeAnimationTicks(); } KeyframeAnimation keyframeAnimationToStart = this.getKeyframeAnimationByPose(); - if ( - keyframeAnimationToStart != null - && this.isKeyframeAnimationRunning(keyframeAnimationToStart) == false - ) { - if (this.getWorld().isClient() == false) { - this.setKeyframeAnimationTicks(keyframeAnimationToStart.getAnimationLengthInTicks()); - } - - this.startKeyframeAnimation(keyframeAnimationToStart); + if (keyframeAnimationToStart != null) { + this.tryToStartKeyframeAnimation(keyframeAnimationToStart); } super.tick(); @@ -221,7 +214,7 @@ public void tick() { private KeyframeAnimation getKeyframeAnimationByPose() { KeyframeAnimation keyframeAnimation = null; - if (this.isInPose(RascalEntityPose.IDLE)) { + if (this.isInPose(RascalEntityPose.IDLE) && this.isMoving() == false) { keyframeAnimation = RascalAnimations.IDLE; } else if (this.isInPose(RascalEntityPose.NOD)) { keyframeAnimation = RascalAnimations.NOD; @@ -232,6 +225,18 @@ private KeyframeAnimation getKeyframeAnimationByPose() { return keyframeAnimation; } + private void tryToStartKeyframeAnimation(KeyframeAnimation keyframeAnimationToStart) { + if (this.isKeyframeAnimationRunning(keyframeAnimationToStart)) { + return; + } + + if (this.getWorld().isClient() == false) { + this.setKeyframeAnimationTicks(keyframeAnimationToStart.getAnimationLengthInTicks()); + } + + this.startKeyframeAnimation(keyframeAnimationToStart); + } + private void startKeyframeAnimation(KeyframeAnimation keyframeAnimationToStart) { for (KeyframeAnimation keyframeAnimation : this.getAnimations()) { if (keyframeAnimation == keyframeAnimationToStart) { @@ -393,6 +398,10 @@ public boolean isHidden() { return this.getBrain().getOptionalMemory(MemoryModuleType.AVOID_TARGET).orElse(null) instanceof PlayerEntity; } + public boolean isMoving() { + return this.isOnGround() && this.getVelocity().lengthSquared() >= 0.0001; + } + public int getCaughtCount() { return this.dataTracker.get(CAUGHT_COUNT); } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java index 9c27b4933..523dc49d8 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/TuffGolemEntity.java @@ -2,7 +2,6 @@ import com.faboslav.friendsandfoes.FriendsAndFoes; import com.faboslav.friendsandfoes.client.render.entity.animation.KeyframeAnimation; -import com.faboslav.friendsandfoes.client.render.entity.animation.RascalAnimations; import com.faboslav.friendsandfoes.client.render.entity.animation.TuffGolemAnimations; import com.faboslav.friendsandfoes.client.render.entity.animation.animator.context.AnimationContextTracker; import com.faboslav.friendsandfoes.entity.ai.brain.TuffGolemBrain; @@ -28,7 +27,6 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.*; import net.minecraft.nbt.NbtCompound; -import net.minecraft.particle.ParticleEffect; import net.minecraft.particle.ParticleTypes; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.BlockSoundGroup; @@ -103,7 +101,7 @@ public ArrayList getAnimations() { @Override public KeyframeAnimation getMovementAnimation() { - if(this.isHoldingItem()) { + if (this.isHoldingItem()) { return TuffGolemAnimations.WALK_WITH_ITEM; } @@ -833,10 +831,6 @@ public void stopMovement() { this.upwardSpeed = 0.0F; } - public boolean isMoving() { - return this.isOnGround() && this.getVelocity().lengthSquared() >= 0.0001; - } - public enum Color { RED("red"), diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/TuffGolemBrain.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/TuffGolemBrain.java index b2fafd7a5..aec73d08e 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/TuffGolemBrain.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/TuffGolemBrain.java @@ -150,6 +150,6 @@ public static void setSleepCooldown(TuffGolemEntity tuffGolem) { MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, FriendsAndFoesMemoryModuleTypes.TUFF_GOLEM_SLEEP_COOLDOWN.get() ); - SLEEP_COOLDOWN_PROVIDER = UniformIntProvider.create(2400, 7200); + SLEEP_COOLDOWN_PROVIDER = UniformIntProvider.create(6000, 8000); } } diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/tuffgolem/TuffGolemSleepTask.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/tuffgolem/TuffGolemSleepTask.java index 6ac7e5c99..ee0f1ccc0 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/tuffgolem/TuffGolemSleepTask.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/ai/brain/task/tuffgolem/TuffGolemSleepTask.java @@ -11,8 +11,8 @@ public final class TuffGolemSleepTask extends Task { - private final static int MIN_TICKS_TO_SLEEP = 2400; - private final static int MAX_TICKS_TO_SLEEP = 4800; + private final static int MIN_TICKS_TO_SLEEP = 6000; + private final static int MAX_TICKS_TO_SLEEP = 12000; public TuffGolemSleepTask() { super(ImmutableMap.of( diff --git a/common/src/main/java/com/faboslav/friendsandfoes/entity/animation/AnimatedEntity.java b/common/src/main/java/com/faboslav/friendsandfoes/entity/animation/AnimatedEntity.java index 78ea3366b..ef64f85c3 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/entity/animation/AnimatedEntity.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/entity/animation/AnimatedEntity.java @@ -1,6 +1,5 @@ package com.faboslav.friendsandfoes.entity.animation; -import com.faboslav.friendsandfoes.FriendsAndFoes; import com.faboslav.friendsandfoes.client.render.entity.animation.KeyframeAnimation; import com.faboslav.friendsandfoes.client.render.entity.animation.animator.context.AnimationContextTracker; import com.faboslav.friendsandfoes.client.render.entity.animation.animator.context.KeyframeAnimationContext; diff --git a/common/src/main/java/com/faboslav/friendsandfoes/mixin/AddCustomEntityPoseMixin.java b/common/src/main/java/com/faboslav/friendsandfoes/mixin/AddCustomEntityPoseMixin.java index 50853160b..5e357c7d8 100644 --- a/common/src/main/java/com/faboslav/friendsandfoes/mixin/AddCustomEntityPoseMixin.java +++ b/common/src/main/java/com/faboslav/friendsandfoes/mixin/AddCustomEntityPoseMixin.java @@ -1,6 +1,5 @@ package com.faboslav.friendsandfoes.mixin; -import com.faboslav.friendsandfoes.FriendsAndFoes; import com.faboslav.friendsandfoes.entity.pose.RascalEntityPose; import com.faboslav.friendsandfoes.entity.pose.TuffGolemEntityPose; import net.minecraft.entity.EntityPose;