Now devs have to explicitly instantiate EntityAIGroupBuilder

This commit is contained in:
Konstantin Shandurenko 2021-02-28 20:07:34 +03:00
parent 57e2bdb5d6
commit 2b6a081c0d
3 changed files with 4 additions and 11 deletions

View File

@ -44,15 +44,6 @@ public interface EntityAI {
addAIGroup(group);
}
/**
* Creates new {@link EntityAIGroup} builder.
*
* @return a builder to create and add an {@link EntityAIGroup}.
*/
default EntityAIGroupBuilder newAIGroupBuilder() {
return new EntityAIGroupBuilder();
}
default void aiTick(long time) {
getAIGroups().forEach(group -> group.tick(time));
}

View File

@ -3,6 +3,7 @@ package demo.entity;
import com.google.common.collect.ImmutableList;
import net.minestom.server.attribute.Attributes;
import net.minestom.server.entity.LivingEntity;
import net.minestom.server.entity.ai.EntityAIGroupBuilder;
import net.minestom.server.entity.ai.goal.DoNothingGoal;
import net.minestom.server.entity.ai.goal.MeleeAttackGoal;
import net.minestom.server.entity.ai.goal.RandomStrollGoal;
@ -34,7 +35,7 @@ public class ChickenCreature extends EntityChicken {
// Another way to register previously added EntityAIGroup, using specialized builder:
// addAIGroup(
// newAIGroupBuilder()
// new EntityAIGroupBuilder()
// .addGoalSelector(new DoNothingGoal(this, 500, .1F))
// .addGoalSelector(new MeleeAttackGoal(this, 500, 2, TimeUnit.MILLISECOND))
// .addGoalSelector(new RandomStrollGoal(this, 2))

View File

@ -1,5 +1,6 @@
package demo.entity;
import net.minestom.server.entity.ai.EntityAIGroupBuilder;
import net.minestom.server.entity.ai.goal.RandomLookAroundGoal;
import net.minestom.server.entity.type.monster.EntityZombie;
import net.minestom.server.utils.Position;
@ -9,7 +10,7 @@ public class ZombieCreature extends EntityZombie {
public ZombieCreature(Position spawnPosition) {
super(spawnPosition);
addAIGroup(
newAIGroupBuilder()
new EntityAIGroupBuilder()
.addGoalSelector(new RandomLookAroundGoal(this, 20))
.build()
);