Skip to content

Commit

Permalink
Make Spawn's Target argument also work on creatures with old AI.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcernat committed Jun 10, 2013
1 parent bbda273 commit 127c663
Showing 1 changed file with 9 additions and 3 deletions.
Expand Up @@ -13,6 +13,7 @@

import org.bukkit.craftbukkit.v1_5_R3.entity.CraftCreature;
import org.bukkit.craftbukkit.v1_5_R3.entity.CraftLivingEntity;
import org.bukkit.entity.Creature;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
Expand Down Expand Up @@ -49,6 +50,11 @@ else if (aH.matchesLocation(arg)) {
}
else if (aH.matchesValueArg("TARGET", arg, ArgumentType.Custom)) {
target = dEntity.valueOf(aH.getStringFrom(arg)).getBukkitEntity();
dB.echoDebug("...target set to '%s' at " +
target.getLocation().getBlockX() + "," +
target.getLocation().getBlockY() + "," +
target.getLocation().getBlockZ() + "," +
target.getLocation().getWorld().getName(), arg);
}
else throw new InvalidArgumentsException(Messages.ERROR_UNKNOWN_ARGUMENT, arg);
}
Expand Down Expand Up @@ -77,11 +83,11 @@ public void execute(final ScriptEntry scriptEntry) throws CommandExecutionExcept

// If target is not null and entity is a Creature, make entity go after the target
if (target != null && entity instanceof CraftCreature) {

dB.echoApproval("SETTING TARGET! " + target.getType().toString());


((CraftCreature) entity).getHandle().
setGoalTarget(((CraftLivingEntity) target).getHandle());

((CraftCreature) entity).setTarget(target);
}

// If entity is a Skeleton, give it a bow
Expand Down

0 comments on commit 127c663

Please sign in to comment.