Better flyable NPCs

This commit is contained in:
fullwall 2012-10-10 21:45:34 +08:00
parent ab19a48d7f
commit 3b8cdae068

View File

@ -97,8 +97,14 @@ public class Controllable extends Trait implements Toggleable {
controller = new GroundController(); controller = new GroundController();
return; return;
} }
Constructor<? extends Controller> innerConstructor = null;
try {
innerConstructor = clazz.getConstructor(Controllable.class);
} catch (Exception e) {
e.printStackTrace();
}
try { try {
Constructor<? extends Controller> innerConstructor = clazz.getConstructor(Controllable.class);
if (innerConstructor == null) { if (innerConstructor == null) {
controller = clazz.newInstance(); controller = clazz.newInstance();
} else } else
@ -156,9 +162,9 @@ public class Controllable extends Trait implements Toggleable {
Vector dir = rider.getEyeLocation().getDirection(); Vector dir = rider.getEyeLocation().getDirection();
dir.multiply(npc.getNavigator().getDefaultParameters().speedModifier()); dir.multiply(npc.getNavigator().getDefaultParameters().speedModifier());
EntityLiving handle = getHandle(); EntityLiving handle = getHandle();
handle.motX += dir.getX(); handle.motX = dir.getX();
handle.motY += dir.getY(); handle.motY = dir.getY();
handle.motZ += dir.getZ(); handle.motZ = dir.getZ();
} }
} }