Update to 1.2

This commit is contained in:
fullwall 2012-03-01 23:12:47 +08:00
parent 70136caa8e
commit d2e7064d44
26 changed files with 55 additions and 35 deletions

View File

@ -11,8 +11,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bukkit.version>1.1-R5-SNAPSHOT</bukkit.version>
<craftbukkit.version>1.1-R5-SNAPSHOT</craftbukkit.version>
<bukkit.version>1.2.2-R0-SNAPSHOT</bukkit.version>
<craftbukkit.version>1.2.2-R0-SNAPSHOT</craftbukkit.version>
<citizensapi.version>2.0-SNAPSHOT</citizensapi.version>
<build.number>Unknown</build.number>
</properties>

View File

@ -1,5 +1,6 @@
package net.citizensnpcs.npc.ai;
import java.lang.reflect.Field;
import java.util.Random;
import net.citizensnpcs.npc.CitizensNPC;
@ -14,6 +15,7 @@ import org.bukkit.entity.Player;
public class MoveStrategy implements PathStrategy {
private static final double JUMP_VELOCITY = 0.49D;
private Float cachedMotion;
private final EntityLiving handle;
private final PathEntity path;
private final Random random = new Random();
@ -21,7 +23,7 @@ public class MoveStrategy implements PathStrategy {
public MoveStrategy(CitizensNPC handle, Location destination) {
this.handle = handle.getHandle();
this.path = this.handle.world.a(this.handle, destination.getBlockX(), destination.getBlockY(),
destination.getBlockZ(), 16F);
destination.getBlockZ(), 16F, true, false, false, true);
}
MoveStrategy(EntityLiving handle, PathEntity path) {
@ -59,8 +61,16 @@ public class MoveStrategy implements PathStrategy {
handle.yaw += getYawDifference(diffZ, diffX);
if (vector.b - yHeight > 0.0D)
jump();
handle.d(handle.ar());
handle.d();
if (cachedMotion == null) {
try {
cachedMotion = MOTION_FIELD.getFloat(handle);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
handle.e(cachedMotion);
// handle.walk();
if (handle.positionChanged)
@ -80,4 +90,15 @@ public class MoveStrategy implements PathStrategy {
if (handle.onGround)
handle.motY = JUMP_VELOCITY;
}
private static Field MOTION_FIELD;
static {
try {
MOTION_FIELD = EntityLiving.class.getDeclaredField("bb");
} catch (SecurityException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
}

View File

@ -14,7 +14,7 @@ public class TargetStrategy implements PathStrategy {
private PathStrategy current = null;
public TargetStrategy(CitizensNPC handle, LivingEntity target, boolean aggro) {
this.handle = (EntityLiving) handle.getHandle();
this.handle = handle.getHandle();
this.target = ((CraftLivingEntity) target).getHandle();
this.aggro = aggro;
}
@ -23,10 +23,10 @@ public class TargetStrategy implements PathStrategy {
public boolean update() {
if (target == null || target.dead)
return true;
current = new MoveStrategy(handle, handle.world.findPath(handle, target, 16F));
current = new MoveStrategy(handle, handle.world.findPath(handle, target, 16F, true, false, false, true));
if (aggro && canAttack()) {
if (handle instanceof EntityMonster) {
((EntityMonster) handle).d(target);
((EntityMonster) handle).a(target);
} else if (handle instanceof EntityHuman) {
((EntityHuman) handle).attack(target);
}
@ -39,7 +39,7 @@ public class TargetStrategy implements PathStrategy {
private boolean canAttack() {
return handle.attackTicks == 0
&& (handle.boundingBox.e > target.boundingBox.b && handle.boundingBox.b < target.boundingBox.e)
&& distanceSquared() <= ATTACK_DISTANCE && handle.g(target);
&& distanceSquared() <= ATTACK_DISTANCE && handle.h(target);
}
private static final double ATTACK_DISTANCE = 1.75 * 1.75;

View File

@ -2,7 +2,6 @@ package net.citizensnpcs.npc.entity;
import net.citizensnpcs.npc.CitizensMobNPC;
import net.citizensnpcs.npc.CitizensNPCManager;
import net.minecraft.server.EntityBlaze;
import net.minecraft.server.World;
@ -26,7 +25,7 @@ public class CitizensBlazeNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensCaveSpiderNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensChickenNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensCowNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensCreeperNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,11 +25,11 @@ public class CitizensEnderDragonNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
@Override
public void d() {
public void e() {
}
}
}

View File

@ -25,11 +25,11 @@ public class CitizensEndermanNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
@Override
public void d() {
public void e() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensGhastNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensGiantNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -26,7 +26,7 @@ public class CitizensMagmaCubeNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensMushroomCowNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensPigNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensPigZombieNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensSheepNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensSilverfishNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensSkeletonNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -26,7 +26,7 @@ public class CitizensSlimeNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensSnowmanNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensSpiderNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensSquidNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensVillagerNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensWolfNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}

View File

@ -25,7 +25,7 @@ public class CitizensZombieNPC extends CitizensMobNPC {
}
@Override
public void m_() {
public void d_() {
}
}
}