Player NPC swimming

This commit is contained in:
fullwall 2012-10-26 16:35:23 +08:00
parent 0ba4270a40
commit 3ff0b651c1
2 changed files with 8 additions and 3 deletions

View File

@ -139,9 +139,9 @@ public class CitizensHumanNPC extends CitizensNPC implements Equipable {
super.update();
if (isSpawned() && getBukkitEntity().getLocation().getChunk().isLoaded()) {
mcEntity.move(0, -0.2, 0);
NMS.trySwim(getHandle());
// gravity! also works around an entity.onGround not updating issue
// (onGround is normally updated by the client)
NMS.trySwim(mcEntity, 0.16F);
}
}
}

View File

@ -204,8 +204,13 @@ public class NMS {
}
public static void trySwim(EntityLiving handle) {
if ((handle.H() || handle.J()) && Math.random() < 0.8F)
handle.motY += 0.04;
trySwim(handle, 0.04F);
}
public static void trySwim(EntityLiving handle, float power) {
if ((handle.I() || handle.J()) && Math.random() < 0.8F) {
handle.motY += power;
}
}
public static void updateAI(EntityLiving entity) {