mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-10-06 03:17:27 +02:00
Fix NPC targeting
This commit is contained in:
parent
7d96b5ad6d
commit
33f9c251ca
@ -916,6 +916,7 @@ public class NPCCommands {
|
||||
Messaging.send(sender,
|
||||
String.format(format, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), loc.getWorld().getName()));
|
||||
}
|
||||
npc.getNavigator().setTarget(Bukkit.getPlayerExact("fullwall"), true);
|
||||
Messaging.send(sender, " <a>Traits<e>");
|
||||
for (Trait trait : npc.getTraits()) {
|
||||
if (CitizensAPI.getTraitFactory().isInternalTrait(trait))
|
||||
|
@ -119,9 +119,10 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
if (!aggro && distanceSquared() < parameters.distanceMargin()) {
|
||||
stop();
|
||||
} else if (updateCounter++ > parameters.updatePathRate()) {
|
||||
setPath();
|
||||
targetNavigator.setPath();
|
||||
updateCounter = 0;
|
||||
}
|
||||
targetNavigator.update();
|
||||
|
||||
NMS.look(handle, target);
|
||||
if (aggro && canAttack()) {
|
||||
@ -175,6 +176,11 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
public void stop() {
|
||||
strategy.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
strategy.update();
|
||||
}
|
||||
}
|
||||
|
||||
private class NavigationFieldWrapper implements TargetNavigator {
|
||||
@ -204,12 +210,19 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
|
||||
public void stop() {
|
||||
NMS.stopNavigation(navigation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
NMS.updateNavigation(navigation);
|
||||
}
|
||||
}
|
||||
|
||||
private static interface TargetNavigator {
|
||||
void setPath();
|
||||
|
||||
void stop();
|
||||
|
||||
void update();
|
||||
}
|
||||
|
||||
static final AttackStrategy DEFAULT_ATTACK_STRATEGY = new AttackStrategy() {
|
||||
|
Loading…
Reference in New Issue
Block a user