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