I'm working on a Cars plugin for Minecraft (Spigot 1.8.8).
You can already drive around with it, but:
How can I do that the Minecart (So the car) on Slabs can go up?
@EventHandler
public void onVehicleUpdate (VehicleUpdateEvent event) {
if (! (event.getVehicle (). GetPassenger () instanceof Player)) {
return;
}
if (! (event.getVehicle () instanceof Minecart)) {
return;
}
Player player = (Player) event.getVehicle (). GetPassenger ();
Vector playerVelocity = event.getVehicle (). GetVelocity ();
double carSpeed = Double.valueOf (50.0D) .doubleValue ();
playerVelocity.setX (player.getEyeLocation (). GetDirection (). GetX () / 140.0D * carSpeed);
playerVelocity.setZ (player.getEyeLocation (). GetDirection (). GetZ () / 140.0D * carSpeed);
Minecart minecart = (Minecart) event.getVehicle ();
Material materialBelow = minecart.getLocation (). Subtract (0.0D, 1.0D, 0.0D) .getBlock (). GetType ();
if (materialBelow.toString (). Equals ("STEP")) {
playerVelocity.setY (playerVelocity.getY () + Double.valueOf (0.05D) .doubleValue ());
}
event.getVehicle () SetVelocity (player velocity).
}
Does anyone have an idea? I'm at a loss: /
To go up you would have to query the block before the Minecart. Then you can try pushing it with Velocity or you could teleport the Minecraft to the block.