event.getVehicle().setVelocity(event.getVehicle().getVelocity().normalize().multiply(4));
if (ladder)
if (event.getTo().getBlock().getType() == Material.LADDER) {
Attachable ladder = (Attachable) event.getTo().getBlock().getState().getData();
Vector velocity = new Vector(0,ladderVerticalVelocity,((Attachable) event.getTo().getBlock().getState().getData()).getAttachedFace().getModZ());
if(velocity.length() > ((Minecart) event.getVehicle()).getMaxSpeed()) {
double length = velocity.length()/((Minecart) event.getVehicle()).getMaxSpeed();
velocity.setX(velocity.getX() / length);
velocity.setY(velocity.getY() / length);
velocity.setZ(velocity.getZ() / length);
}
velocity.add(new Vector(ladder.getAttachedFace().getModX(), 0, ladder.getAttachedFace().getModZ()));
event.getVehicle().setVelocity(event.getVehicle().getVelocity().add(velocity));
} else if (event.getTo().getBlock().getType() == Material.VINE) {
BlockFace movementFace = BlockFace.SELF;
Vine vine = (Vine) event.getTo().getBlock().getState().getData();
for(BlockFace test : LocationUtil.getDirectFaces())
if(vine.isOnFace(test)) {
movementFace = test;
break;
}
if(movementFace == BlockFace.SELF)
return;
Vector velocity = new Vector(0,ladderVerticalVelocity,0);
if(velocity.length() > ((Minecart) event.getVehicle()).getMaxSpeed()) {
double length = velocity.length()/((Minecart) event.getVehicle()).getMaxSpeed();
velocity.setX(velocity.getX() / length);
velocity.setY(velocity.getY() / length);
velocity.setZ(velocity.getZ() / length);
}
velocity.add(new Vector(movementFace.getModX(), 0, movementFace.getModZ()));
event.getVehicle().setVelocity(event.getVehicle().getVelocity().add(velocity));
}
}