mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-30 16:28:00 +01:00
Prevent registering custom AI to our own entities. Closes #185
This commit is contained in:
parent
94d7ff1419
commit
b7487e9901
2 changed files with 13 additions and 17 deletions
|
@ -17,7 +17,6 @@ import com.minelittlepony.unicopia.entity.ai.BreakHeartGoal;
|
||||||
import com.minelittlepony.unicopia.entity.ai.DynamicTargetGoal;
|
import com.minelittlepony.unicopia.entity.ai.DynamicTargetGoal;
|
||||||
import com.minelittlepony.unicopia.entity.ai.EatMuffinGoal;
|
import com.minelittlepony.unicopia.entity.ai.EatMuffinGoal;
|
||||||
import com.minelittlepony.unicopia.entity.ai.WantItTakeItGoal;
|
import com.minelittlepony.unicopia.entity.ai.WantItTakeItGoal;
|
||||||
import com.minelittlepony.unicopia.entity.mob.SombraEntity;
|
|
||||||
import com.minelittlepony.unicopia.entity.mob.UEntityAttributes;
|
import com.minelittlepony.unicopia.entity.mob.UEntityAttributes;
|
||||||
|
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
|
@ -122,14 +121,13 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned.Mutabl
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initAi(GoalSelector goals, GoalSelector targets) {
|
public void initAi(GoalSelector goals, GoalSelector targets) {
|
||||||
|
|
||||||
if (entity instanceof SombraEntity) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.goals = Optional.of(goals);
|
this.goals = Optional.of(goals);
|
||||||
this.targets = Optional.of(targets);
|
this.targets = Optional.of(targets);
|
||||||
|
|
||||||
|
if (entity instanceof MagicImmune) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DynamicTargetGoal targetter = new DynamicTargetGoal((MobEntity)entity);
|
DynamicTargetGoal targetter = new DynamicTargetGoal((MobEntity)entity);
|
||||||
targets.add(1, targetter);
|
targets.add(1, targetter);
|
||||||
if (!Unicopia.getConfig().wantItNeedItEntityExcludelist.get().contains(EntityType.getId(entity.getType()).toString())) {
|
if (!Unicopia.getConfig().wantItNeedItEntityExcludelist.get().contains(EntityType.getId(entity.getType()).toString())) {
|
||||||
|
@ -143,13 +141,8 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned.Mutabl
|
||||||
goals.add(3, eatMuffinGoal);
|
goals.add(3, eatMuffinGoal);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getMasterReference().isSet()) {
|
initMinionAi(targets);
|
||||||
initMinionAi(targets);
|
initDiscordedAi();
|
||||||
}
|
|
||||||
|
|
||||||
if (isDiscorded()) {
|
|
||||||
initDiscordedAi();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity instanceof CreeperEntity mob) {
|
if (entity instanceof CreeperEntity mob) {
|
||||||
goals.add(1, new FleeEntityGoal<>(mob, LivingEntity.class, 10, 1.5, 1.9, AmuletSelectors.ALICORN_AMULET));
|
goals.add(1, new FleeEntityGoal<>(mob, LivingEntity.class, 10, 1.5, 1.9, AmuletSelectors.ALICORN_AMULET));
|
||||||
|
@ -160,6 +153,10 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned.Mutabl
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initMinionAi(GoalSelector targets) {
|
private void initMinionAi(GoalSelector targets) {
|
||||||
|
if (entity instanceof MagicImmune || !getMasterReference().isSet()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
clearGoals(targets);
|
clearGoals(targets);
|
||||||
targets.add(2, new ActiveEnemyGoal<>(PlayerEntity.class));
|
targets.add(2, new ActiveEnemyGoal<>(PlayerEntity.class));
|
||||||
targets.add(2, new ActiveEnemyGoal<>(HostileEntity.class));
|
targets.add(2, new ActiveEnemyGoal<>(HostileEntity.class));
|
||||||
|
@ -167,7 +164,7 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned.Mutabl
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initDiscordedAi() {
|
private void initDiscordedAi() {
|
||||||
if (getMasterReference().isSet()) {
|
if (entity instanceof MagicImmune || getMasterReference().isSet() || !isDiscorded()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
targets.ifPresent(this::clearGoals);
|
targets.ifPresent(this::clearGoals);
|
||||||
|
@ -197,7 +194,7 @@ public class Creature extends Living<LivingEntity> implements WeaklyOwned.Mutabl
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean beforeUpdate() {
|
public boolean beforeUpdate() {
|
||||||
if (isDiscorded() && discordedChanged) {
|
if (discordedChanged) {
|
||||||
discordedChanged = false;
|
discordedChanged = false;
|
||||||
initDiscordedAi();
|
initDiscordedAi();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import java.util.stream.StreamSupport;
|
||||||
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
|
||||||
import com.minelittlepony.unicopia.USounds;
|
import com.minelittlepony.unicopia.USounds;
|
||||||
import com.minelittlepony.unicopia.UTags;
|
import com.minelittlepony.unicopia.UTags;
|
||||||
import com.minelittlepony.unicopia.Unicopia;
|
import com.minelittlepony.unicopia.Unicopia;
|
||||||
|
@ -113,7 +112,7 @@ public abstract class Living<T extends LivingEntity> implements Equine<T>, Caste
|
||||||
}
|
}
|
||||||
|
|
||||||
public <Q extends Tickable> Q addTicker(Q tickable) {
|
public <Q extends Tickable> Q addTicker(Q tickable) {
|
||||||
tickers.add(Preconditions.checkNotNull(tickable, "tickable"));
|
tickers.add(Objects.requireNonNull(tickable, "tickable cannot be null"));
|
||||||
return tickable;
|
return tickable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue