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) if (npc == null)
return; return;
Navigation navigation = getNavigation(); Navigation navigation = getNavigation();
if (Math.abs(motX) < EPSILON && Math.abs(motY) < EPSILON && Math.abs(motZ) < EPSILON)
motX = motY = motZ = 0;
if (!navigation.f()) { if (!navigation.f()) {
navigation.e(); navigation.e();
moveOnCurrentHeading(); 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 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) if (noDamageTicks > 0)
--noDamageTicks; --noDamageTicks;
npc.update(); npc.update();
} }
private static final float EPSILON = 0.005F;
private void initialise(MinecraftServer minecraftServer) { private void initialise(MinecraftServer minecraftServer) {
Socket socket = new EmptySocket(); Socket socket = new EmptySocket();
NetworkManager netMgr = null; NetworkManager netMgr = null;

View File

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