Skip to content

Commit

Permalink
Catch crazy velocity errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Jul 23, 2017
1 parent 2ff610c commit d93785d
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -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) {

Expand All @@ -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())
Expand Down

0 comments on commit d93785d

Please sign in to comment.