Skip to content

Commit fc1260c

Browse files
committed
🎨 feat -> added Spider like goals to Meature
1 parent dc4565a commit fc1260c

File tree

1 file changed

+44
-15
lines changed

1 file changed

+44
-15
lines changed

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

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
import net.minecraft.sounds.SoundEvents;
88
import net.minecraft.world.damagesource.DamageSource;
99
import net.minecraft.world.entity.EntityType;
10+
import net.minecraft.world.entity.LivingEntity;
1011
import net.minecraft.world.entity.MobType;
1112
import net.minecraft.world.entity.OwnableEntity;
1213
import net.minecraft.world.entity.ai.attributes.AttributeSupplier;
1314
import net.minecraft.world.entity.ai.attributes.Attributes;
14-
import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal;
15-
import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal;
16-
import net.minecraft.world.entity.ai.goal.ZombieAttackGoal;
15+
import net.minecraft.world.entity.ai.goal.*;
16+
import net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal;
1717
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
1818
import net.minecraft.world.entity.monster.Zombie;
1919
import net.minecraft.world.entity.player.Player;
@@ -25,8 +25,6 @@
2525
import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache;
2626
import software.bernie.geckolib.core.animation.AnimatableManager;
2727
import software.bernie.geckolib.core.animation.AnimationController;
28-
import software.bernie.geckolib.core.animation.AnimationState;
29-
import software.bernie.geckolib.core.object.PlayState;
3028
import software.bernie.geckolib.util.GeckoLibUtil;
3129

3230
import java.util.Optional;
@@ -53,11 +51,16 @@ public MeatureEntity(EntityType<? extends Zombie> entityType, Level level) {
5351

5452
@Override
5553
protected void registerGoals() {
56-
this.goalSelector.addGoal(8, new RandomLookAroundGoal(this));
57-
this.goalSelector.addGoal(2, new ZombieAttackGoal(this, 1.0F, false));
58-
this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0F));
59-
this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, true));
60-
this.targetSelector.addGoal(5, new NearestAttackableTargetGoal<>(this, Zombie.class, 10, true, false, e -> !(e instanceof MeatureEntity)));
54+
this.goalSelector.addGoal(1, new FloatGoal(this));
55+
this.goalSelector.addGoal(3, new LeapAtTargetGoal(this, 0.4F));
56+
this.goalSelector.addGoal(4, new MeatureAttackGoal(this));
57+
this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0F));
58+
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 8.0F));
59+
this.goalSelector.addGoal(6, new RandomLookAroundGoal(this));
60+
this.targetSelector.addGoal(1, new HurtByTargetGoal(this));
61+
62+
this.targetSelector.addGoal(2, new MeatureTargetGoal<>(this, Player.class));
63+
this.targetSelector.addGoal(5, new MeatureTargetGoal<>(this, Zombie.class));
6164
}
6265

6366
@Override
@@ -68,11 +71,7 @@ protected void defineSynchedData() {
6871

6972
@Override
7073
public void registerControllers(AnimatableManager.ControllerRegistrar data) {
71-
data.add(new AnimationController<>(this, "movement", 2, this::movementPredicate));
72-
}
73-
74-
private PlayState movementPredicate(AnimationState<?> event) {
75-
return AnimUtils.idleWalkAnimation(event, "idle", "walk");
74+
data.add(new AnimationController<>(this, "movement", 2, (event) -> AnimUtils.idleWalkAnimation(event, "idle", "walk")));
7675
}
7776

7877
@Override
@@ -127,4 +126,34 @@ public AnimatableInstanceCache getAnimatableInstanceCache() {
127126
public void setOwnerUUID(@Nullable UUID uuid) {
128127
this.entityData.set(OWNER_UUID, Optional.ofNullable(uuid));
129128
}
129+
130+
static class MeatureAttackGoal extends MeleeAttackGoal {
131+
public MeatureAttackGoal(MeatureEntity meature) {
132+
super(meature, 1.0F, true);
133+
}
134+
135+
public boolean canUse() {
136+
return super.canUse() && !this.mob.isVehicle();
137+
}
138+
139+
public boolean canContinueToUse() {
140+
float f = this.mob.getLightLevelDependentMagicValue();
141+
if (f >= 0.5F && this.mob.getRandom().nextInt(100) == 0) {
142+
this.mob.setTarget(null);
143+
return false;
144+
} else {
145+
return super.canContinueToUse();
146+
}
147+
}
148+
149+
protected double getAttackReachSqr(LivingEntity attackTarget) {
150+
return 4.0F + attackTarget.getBbWidth();
151+
}
152+
}
153+
154+
static class MeatureTargetGoal<T extends LivingEntity> extends NearestAttackableTargetGoal<T> {
155+
public MeatureTargetGoal(MeatureEntity spider, Class<T> entityTypeToTarget) {
156+
super(spider, entityTypeToTarget, true);
157+
}
158+
}
130159
}

0 commit comments

Comments
 (0)