Skip to content

Commit 152fc98

Browse files
committed
Fix slugger animation
1 parent 88f0a7e commit 152fc98

File tree

3 files changed

+306
-111
lines changed

3 files changed

+306
-111
lines changed

common/src/main/java/org/infernalstudios/enemyexp/client/entity/model/SluggerModel.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import net.minecraft.resources.ResourceLocation;
44
import org.infernalstudios.enemyexp.EEMod;
55
import org.infernalstudios.enemyexp.content.entity.SluggerEntity;
6+
import software.bernie.geckolib.core.animation.AnimationState;
67
import software.bernie.geckolib.model.DefaultedEntityGeoModel;
78

89
public class SluggerModel extends DefaultedEntityGeoModel<SluggerEntity> {
@@ -14,4 +15,11 @@ public SluggerModel() {
1415
public ResourceLocation getTextureResource(SluggerEntity animatable) {
1516
return EEMod.location("textures/entity/" + animatable.getTexture() + ".png");
1617
}
17-
}
18+
19+
@Override
20+
public void setCustomAnimations(SluggerEntity animatable, long instanceId, AnimationState<SluggerEntity> animationState) {
21+
if (!animatable.isCharging()) {
22+
super.setCustomAnimations(animatable, instanceId, animationState);
23+
}
24+
}
25+
}

common/src/main/java/org/infernalstudios/enemyexp/content/entity/SluggerEntity.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import net.minecraft.network.syncher.EntityDataAccessor;
44
import net.minecraft.network.syncher.EntityDataSerializers;
55
import net.minecraft.network.syncher.SynchedEntityData;
6-
import net.minecraft.world.entity.*;
6+
import net.minecraft.world.damagesource.DamageSource;
7+
import net.minecraft.world.entity.EntityType;
8+
import net.minecraft.world.entity.LivingEntity;
79
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
810
import net.minecraft.world.entity.ai.attributes.Attributes;
911
import net.minecraft.world.entity.ai.goal.*;
@@ -16,7 +18,6 @@
1618
import net.minecraft.world.entity.player.Player;
1719
import net.minecraft.world.level.Level;
1820
import net.minecraft.world.phys.Vec3;
19-
import net.minecraft.world.damagesource.DamageSource;
2021
import org.infernalstudios.enemyexp.core.mixin.RandomLookAroundGoalAccessor;
2122
import org.infernalstudios.enemyexp.core.util.AnimUtils;
2223
import org.jetbrains.annotations.NotNull;
@@ -33,26 +34,32 @@
3334
import java.util.List;
3435

3536
public class SluggerEntity extends Zombie implements GeoEntity {
36-
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
3737
private static final EntityDataAccessor<Integer> CHARGE_TIME = SynchedEntityData.defineId(SluggerEntity.class, EntityDataSerializers.INT);
3838
private static final EntityDataAccessor<Float> CHARGE_DIR_X = SynchedEntityData.defineId(SluggerEntity.class, EntityDataSerializers.FLOAT);
3939
private static final EntityDataAccessor<Float> CHARGE_DIR_Z = SynchedEntityData.defineId(SluggerEntity.class, EntityDataSerializers.FLOAT);
4040
private static final EntityDataAccessor<String> TEXTURE = SynchedEntityData.defineId(SluggerEntity.class, EntityDataSerializers.STRING);
41-
4241
private static final String NORMAL_TEXTURE = "slugger";
4342
private static final String STAGGERED_CHARGE = "slugger_charge";
4443
private static final String DASHING_TEXTURE = "slugger_dashing";
45-
4644
private static final int CHARGE_DURATION = 17;
4745
private static final int CHARGE_WINDUP = 10;
4846
private static final float CHARGE_SPEED = 0.7F;
4947
private static final float CHARGE_DAMAGE = 6.0F;
5048
private static final float CHARGE_KNOCKBACK = 1.5F;
49+
private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this);
5150

5251
public SluggerEntity(EntityType<? extends Zombie> entityType, Level level) {
5352
super(entityType, level);
5453
}
5554

55+
public static AttributeSupplier.@NotNull Builder createAttributes() {
56+
return Zombie.createAttributes()
57+
.add(Attributes.MOVEMENT_SPEED, 0.2D).add(Attributes.FOLLOW_RANGE, 32.0D)
58+
.add(Attributes.ATTACK_DAMAGE, 4.0D).add(Attributes.MAX_HEALTH, 8.0D)
59+
.add(Attributes.ARMOR, 16.0D).add(Attributes.KNOCKBACK_RESISTANCE, 3.0D)
60+
.add(Attributes.ATTACK_KNOCKBACK, 0.3D);
61+
}
62+
5663
@Override
5764
protected void registerGoals() {
5865
this.goalSelector.addGoal(1, new SluggerChargeGoal(this));
@@ -68,14 +75,6 @@ protected void registerGoals() {
6875
this.targetSelector.addGoal(3, new NearestAttackableTargetGoal<>(this, IronGolem.class, true));
6976
}
7077

71-
public static AttributeSupplier.@NotNull Builder createAttributes() {
72-
return Zombie.createAttributes()
73-
.add(Attributes.MOVEMENT_SPEED, 0.2D).add(Attributes.FOLLOW_RANGE, 32.0D)
74-
.add(Attributes.ATTACK_DAMAGE, 4.0D).add(Attributes.MAX_HEALTH, 8.0D)
75-
.add(Attributes.ARMOR, 16.0D).add(Attributes.KNOCKBACK_RESISTANCE, 3.0D)
76-
.add(Attributes.ATTACK_KNOCKBACK, 0.3D);
77-
}
78-
7978
@Override
8079
protected void defineSynchedData() {
8180
super.defineSynchedData();
@@ -89,6 +88,7 @@ private void lockRotationDuringCharge() {
8988
this.setYRot(this.yRotO);
9089
this.yHeadRot = this.yRotO;
9190
this.yBodyRot = this.yRotO;
91+
this.setXRot(this.xRotO);
9292
}
9393

9494
@Override
@@ -152,12 +152,12 @@ public void setTexture(String texture) {
152152
}
153153

154154
@Override
155-
public void setBaby(boolean childZombie) {
155+
public boolean isBaby() {
156+
return false;
156157
}
157158

158159
@Override
159-
public boolean isBaby() {
160-
return false;
160+
public void setBaby(boolean childZombie) {
161161
}
162162

163163
@Override

0 commit comments

Comments
 (0)