33 lines
677 B
Java
33 lines
677 B
Java
package net.minecraft.world.phys;
|
|
|
|
import net.minecraft.world.entity.Entity;
|
|
|
|
public abstract class HitResult {
|
|
protected final Vec3 location;
|
|
|
|
protected HitResult(Vec3 location) {
|
|
this.location = location;
|
|
}
|
|
|
|
public double distanceTo(Entity entity) {
|
|
double d = this.location.x - entity.getX();
|
|
double e = this.location.y - entity.getY();
|
|
double f = this.location.z - entity.getZ();
|
|
return d * d + e * e + f * f;
|
|
}
|
|
|
|
public abstract HitResult.Type getType();
|
|
|
|
/**
|
|
* Returns the hit position of the raycast, in absolute world coordinates
|
|
*/
|
|
public Vec3 getLocation() {
|
|
return this.location;
|
|
}
|
|
|
|
public static enum Type {
|
|
MISS,
|
|
BLOCK,
|
|
ENTITY;
|
|
}
|
|
}
|