mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-23 16:41:35 +01:00
Now devs have to explicitly instantiate EntityAIGroupBuilder
This commit is contained in:
parent
57e2bdb5d6
commit
2b6a081c0d
@ -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));
|
||||
}
|
||||
|
@ -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))
|
||||
|
@ -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()
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user