Untitled
unknown
java
a year ago
2.5 kB
5
Indexable
public class GoraniEntity extends Monster { public GoraniEntity(EntityType<? extends Monster> pEntityType, Level pLevel) { super(pEntityType, pLevel); } public final AnimationState thunderAnimationState = new AnimationState(); private int thunderAnimationTimeout = 0; public final AnimationState shieldAnimationState = new AnimationState(); private int shieldAnimationTimeout = 0; public final AnimationState vanishmentAnimationState = new AnimationState(); @Override public void tick() { super.tick(); if (this.level().isClientSide()) { boolean hasThunderTag = this.getTags().contains("thunder"); boolean hasShieldTag = this.getTags().contains("shield"); setupAnimationStates(hasThunderTag, hasShieldTag); } } private void setupAnimationStates(boolean hasThunderTag, boolean hasShieldTag) { if (hasThunderTag && this.thunderAnimationTimeout <= 0) { this.thunderAnimationTimeout = 15; this.thunderAnimationState.start(this.tickCount); } else { this.thunderAnimationTimeout --; } if (hasShieldTag && this.shieldAnimationTimeout <= 0) { this.shieldAnimationTimeout = 20; this.shieldAnimationState.start(this.tickCount); } else { this.shieldAnimationTimeout --; } if (!hasThunderTag) { thunderAnimationState.stop(); } if (!hasShieldTag) { //shieldAnimationState.stop(); } } @Override protected void updateWalkAnimation(float pPartialTick) { float f; if (this.getPose() == Pose.STANDING) { f = Math.min(pPartialTick * 6f, 1f); } else { f = 0f; } this.walkAnimation.update(f, 0.2f); } @Override protected void registerGoals() { this.goalSelector.addGoal(0, new FloatGoal(this)); } public static AttributeSupplier.Builder createAttributes() { return Monster.createLivingAttributes() .add(Attributes.MAX_HEALTH, 20) .add(Attributes.MOVEMENT_SPEED, 1) .add(Attributes.ARMOR_TOUGHNESS, 1) .add(Attributes.ATTACK_KNOCKBACK, 1) .add(Attributes.ATTACK_DAMAGE, 0) .add(Attributes.FOLLOW_RANGE, 1000); } }
Editor is loading...
Leave a Comment