This commit is contained in:
fullwall 2012-05-08 21:38:28 +08:00
parent 1eb3041b3b
commit 406dfea4d1
3 changed files with 14 additions and 9 deletions

View File

@ -1,9 +1,10 @@
package net.citizensnpcs.npc.ai;
import net.citizensnpcs.npc.CitizensNPC;
import net.minecraft.server.EntityHuman;
import net.minecraft.server.EntityLiving;
import net.minecraft.server.EntityMonster;
import net.minecraft.server.EntityPlayer;
import net.minecraft.server.Packet18ArmAnimation;
import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.entity.LivingEntity;
@ -36,9 +37,12 @@ public class MCTargetStrategy implements PathStrategy {
handle.getControllerLook().a(target, 10.0F, handle.D());
if (aggro && canAttack()) {
if (handle instanceof EntityMonster) {
((EntityMonster) handle).a(target);
} else if (handle instanceof EntityHuman) {
((EntityHuman) handle).attack(target);
((EntityMonster) handle).a((net.minecraft.server.Entity) target);
// the cast is necessary to resolve overloaded method a
} else if (handle instanceof EntityPlayer) {
EntityPlayer humanHandle = (EntityPlayer) handle;
humanHandle.attack(target);
humanHandle.netServerHandler.sendPacket(new Packet18ArmAnimation(humanHandle, 1));
}
}

View File

@ -52,10 +52,8 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHandle {
getControllerLook().a();
getControllerJump().b();
if (this.aZ) {
if (aT()) {
this.motY += 0.03999999910593033D;
} else if (aU()) {
this.motY += 0.03999999910593033D;
if (aT() || aU()) {
this.motY += 0.04;
} else if (this.onGround && this.q == 0) {
this.motY = 0.5;
this.q = 10;

View File

@ -33,8 +33,11 @@ public class Behaviour extends Trait {
};
private final NPC npc;
private final File rootFolder = new File(CitizensAPI.getScriptFolder(), "behaviours");
private final List<File> scripts = Lists.newArrayList();
{
if (!rootFolder.exists())
rootFolder.mkdirs();
}
public Behaviour(NPC npc) {
this.npc = npc;