Assuming this works

This commit is contained in:
fullwall 2012-10-26 17:52:01 +08:00
parent cd55c42ec0
commit 4ce0843315
2 changed files with 9 additions and 3 deletions

View File

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

View File

@ -208,7 +208,7 @@ public class NMS {
}
public static void trySwim(EntityLiving handle, float power) {
if ((handle.I() || handle.J()) && Math.random() < 0.8F) {
if (inWater(handle) && Math.random() < 0.8F) {
handle.motY += power;
}
}
@ -276,4 +276,8 @@ public class NMS {
Messaging.logTr(Messages.ERROR_GETTING_ID_MAPPING, e.getMessage());
}
}
public static boolean inWater(EntityLiving mcEntity) {
return mcEntity.I() || mcEntity.J();
}
}