SteamWar/BauSystem2.0
Archiviert
12
0

Remove unused RayTraceUtils
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2023-02-23 18:13:53 +01:00
Ursprung 81df1e02be
Commit cc2668a49b

Datei anzeigen

@ -39,44 +39,6 @@ import java.util.List;
@UtilityClass @UtilityClass
public class RayTraceUtils { public class RayTraceUtils {
public static RayTraceResult trace(Player player, Location to, List<Entity> entityList) {
if (player.getGameMode() == GameMode.SPECTATOR) {
return null;
}
Location startPos = to.clone().add(0.0, player.getEyeHeight(), 0.0);
Vector direction = to.getDirection();
RayTraceResult blocks = player.getWorld().rayTraceBlocks(startPos, direction, 10.0, FluidCollisionMode.NEVER, true);
Entity nearestHitEntity = null;
RayTraceResult nearestHitResult = null;
double nearestDistanceSq = Double.MAX_VALUE;
for (Entity entity : entityList) {
BoundingBox boundingBox = entity.getBoundingBox();
RayTraceResult hitResult = boundingBox.rayTrace(startPos.toVector(), direction, 10.0);
if (hitResult != null) {
double distanceSq = startPos.toVector().distanceSquared(hitResult.getHitPosition());
if (distanceSq < nearestDistanceSq) {
nearestHitEntity = entity;
nearestHitResult = hitResult;
nearestDistanceSq = distanceSq;
}
}
}
RayTraceResult entities = nearestHitEntity == null ? null : new RayTraceResult(nearestHitResult.getHitPosition(), nearestHitEntity, nearestHitResult.getHitBlockFace());
if (blocks == null) {
return entities;
} else if (entities == null) {
return blocks;
} else {
Vector startVec = startPos.toVector();
double blockHitDistance = startVec.distance(blocks.getHitPosition());
double entityHitDistanceSquared = startVec.distanceSquared(entities.getHitPosition());
return entityHitDistanceSquared < blockHitDistance * blockHitDistance ? entities : blocks;
}
}
public static RRayTraceResult traceREntity(Player player, Location to, List<RFallingBlockEntity> entityList) { public static RRayTraceResult traceREntity(Player player, Location to, List<RFallingBlockEntity> entityList) {
if (player.getGameMode() == GameMode.SPECTATOR) { if (player.getGameMode() == GameMode.SPECTATOR) {
return null; return null;