Fix NPC targeting

This commit is contained in:
fullwall 2014-12-21 23:34:54 +08:00
parent 954a3bd27b
commit 516035fc70
3 changed files with 9 additions and 6 deletions

View File

@ -268,7 +268,7 @@ public class NPCCommands {
} }
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, copy) CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, copy)
: new CommandSenderCreateNPCEvent(sender, copy); : new CommandSenderCreateNPCEvent(sender, copy);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
event.getNPC().destroy(); event.getNPC().destroy();
@ -344,7 +344,7 @@ public class NPCCommands {
spawnLoc = args.getSenderLocation(); spawnLoc = args.getSenderLocation();
} }
CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, npc) CommandSenderCreateNPCEvent event = sender instanceof Player ? new PlayerCreateNPCEvent((Player) sender, npc)
: new CommandSenderCreateNPCEvent(sender, npc); : new CommandSenderCreateNPCEvent(sender, npc);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
npc.destroy(); npc.destroy();
@ -842,6 +842,8 @@ public class NPCCommands {
String message = " <e>- <a>" + trait.getName(); String message = " <e>- <a>" + trait.getName();
Messaging.send(sender, message); Messaging.send(sender, message);
} }
npc.getNavigator().setTarget((Entity) sender, true);
} }
@Command( @Command(
@ -1021,7 +1023,7 @@ public class NPCCommands {
@Requirements(selected = true, ownership = true, types = { EntityType.CREEPER }) @Requirements(selected = true, ownership = true, types = { EntityType.CREEPER })
public void power(CommandContext args, CommandSender sender, NPC npc) { public void power(CommandContext args, CommandSender sender, NPC npc) {
Messaging 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( @Command(
@ -1044,7 +1046,7 @@ public class NPCCommands {
} }
@Command(aliases = { "npc" }, usage = "remove|rem (all|id|name)", desc = "Remove a NPC", modifiers = { "remove", @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 @Requirements
public void remove(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException { public void remove(final CommandContext args, final CommandSender sender, NPC npc) throws CommandException {
if (args.argsLength() == 2) { if (args.argsLength() == 2) {

View File

@ -177,7 +177,7 @@ public class MCTargetStrategy implements PathStrategy, EntityTarget {
@Override @Override
public void setPath() { public void setPath() {
navigation.a(target, parameters.speed()); navigation.a(target, 1f);
} }
@Override @Override

View File

@ -79,7 +79,8 @@ public class NMS {
} }
public static void attack(EntityLiving handle, Entity target) { 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; int i = 0;
if (target instanceof EntityLiving) { if (target instanceof EntityLiving) {