Skip to content

Commit

Permalink
Fix NPC targeting
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Dec 21, 2014
1 parent 64935ef commit 866a381
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/main/java/net/citizensnpcs/commands/NPCCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public void copy(CommandContext args, CommandSender sender, NPC npc) throws Comm
}

CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, copy)
: new CommandSenderCreateNPCEvent(sender, copy);
: new CommandSenderCreateNPCEvent(sender, copy);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
event.getNPC().destroy();
Expand Down Expand Up @@ -344,7 +344,7 @@ public void create(CommandContext args, CommandSender sender, NPC npc) throws Co
spawnLoc = args.getSenderLocation();
}
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, npc)
: new CommandSenderCreateNPCEvent(sender, npc);
: new CommandSenderCreateNPCEvent(sender, npc);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
npc.destroy();
Expand Down Expand Up @@ -842,6 +842,8 @@ public void npc(CommandContext args, CommandSender sender, NPC npc) {
String message = " <e>- <a>" + trait.getName();
Messaging.send(sender, message);
}

npc.getNavigator().setTarget((Entity) sender, true);
}

@Command(
Expand Down Expand Up @@ -1021,7 +1023,7 @@ public void pose(CommandContext args, CommandSender sender, NPC npc) throws Comm
@Requirements(selected = true, ownership = true, types = { EntityType.CREEPER })
public void power(CommandContext args, CommandSender sender, NPC npc) {
Messaging
.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
.sendTr(sender, npc.getTrait(Powered.class).toggle() ? Messages.POWERED_SET : Messages.POWERED_STOPPED);
}

@Command(
Expand All @@ -1044,7 +1046,7 @@ public void profession(CommandContext args, CommandSender sender, NPC npc) throw
}

@Command(aliases = { "npc" }, usage = "remove|rem (all|id|name)", desc = "Remove a NPC", modifiers = { "remove",
"rem" }, min = 1, max = 2)
"rem" }, min = 1, max = 2)
@Requirements
public void remove(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException {
if (args.argsLength() == 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private NavigationFieldWrapper(NavigationAbstract navigation) {

@Override
public void setPath() {
navigation.a(target, parameters.speed());
navigation.a(target, 1f);
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/citizensnpcs/util/NMS.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public static void addOrRemoveFromPlayerList(org.bukkit.entity.Entity entity, bo
}

public static void attack(EntityLiving handle, Entity target) {
float f = (float) handle.getAttributeInstance(GenericAttributes.e).getValue();
AttributeInstance attackDamage = handle.getAttributeInstance(GenericAttributes.e);
float f = (float) (attackDamage == null ? 1 : attackDamage.getValue());
int i = 0;

if (target instanceof EntityLiving) {
Expand Down

0 comments on commit 866a381

Please sign in to comment.