This commit is contained in:
fullwall 2012-10-10 14:26:41 +08:00
parent f6d0db7bdf
commit 08d2001d37
2 changed files with 14 additions and 7 deletions

View File

@ -112,18 +112,23 @@ public class EntityHumanNPC extends EntityPlayer implements NPCHolder {
if (npc == null)
return;
Navigation navigation = getNavigation();
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON)
motX = motY = motZ = 0;
if (!navigation.f()) {
navigation.e();
moveOnCurrentHeading();
} else if (!npc.getNavigator().isNavigating() && (motX != 0 || motZ != 0 || motY != 0)) {
} else if (motX != 0 || motZ != 0 || motY != 0)
e(0, 0); // is this necessary? it does gravity/controllable but
// sometimes players sink into the ground
}
// sometimes players sink into the ground
if (noDamageTicks > 0)
--noDamageTicks;
npc.update();
}
private static final float EPSILON = 0.005F;
private void initialise(MinecraftServer minecraftServer) {
Socket socket = new EmptySocket();
NetworkManager netMgr = null;

View File

@ -104,6 +104,7 @@ public class Controllable extends Trait implements Toggleable {
} else
controller = innerConstructor.newInstance(this);
} catch (Exception e) {
e.printStackTrace();
controller = new GroundController();
}
}
@ -148,11 +149,12 @@ public class Controllable extends Trait implements Toggleable {
@Override
public void run(Player rider) {
if (paused)
if (paused) {
getHandle().motY = 0;
return;
}
Vector dir = rider.getEyeLocation().getDirection();
double y = dir.getY();
dir.multiply(npc.getNavigator().getDefaultParameters().speedModifier()).setY(y);
dir.multiply(npc.getNavigator().getDefaultParameters().speedModifier());
EntityLiving handle = getHandle();
handle.motX += dir.getX();
handle.motY += dir.getY();
@ -160,7 +162,7 @@ public class Controllable extends Trait implements Toggleable {
}
}
private static interface Controller {
private interface Controller {
void leftClick(PlayerInteractEvent event);
void rightClick(PlayerInteractEvent event);