Permalink
Browse files

Catch crazy velocity errors.

  • Loading branch information...
me4502 committed Jul 23, 2017
1 parent 2ff610c commit d93785deb337a0b8c8746111aad116ea37950796
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/main/java/com/sk89q/craftbook/mechanics/boat/RemoveEntities.java
@@ -14,6 +14,8 @@
public class RemoveEntities extends AbstractCraftBookMechanic {
private static final Vector HALF_BLOCK_UP = new Vector(0, 0.5, 0);
@EventHandler(priority = EventPriority.HIGH)
public void onVehicleEntityCollision(VehicleEntityCollisionEvent event) {
@@ -31,7 +33,11 @@ public void onVehicleEntityCollision(VehicleEntityCollisionEvent event) {
if(event.getEntity().isInsideVehicle())
return;
((LivingEntity) event.getEntity()).damage(10);
event.getEntity().setVelocity(event.getVehicle().getVelocity().normalize().multiply(1.8).add(new Vector(0,0.5,0)));
try {
event.getEntity().setVelocity(event.getVehicle().getVelocity().normalize().multiply(1.8).add(HALF_BLOCK_UP));
} catch(IllegalArgumentException e) {
event.getEntity().setVelocity(HALF_BLOCK_UP);
}
} else if (event.getEntity() instanceof Vehicle) {
if(!event.getEntity().isEmpty())

0 comments on commit d93785d

Please sign in to comment.