use of org.valkyrienskies.mod.common.ships.ship_world.IWorldVS in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class FixAccurateRain method getRainPosFromShips.
public static BlockPos getRainPosFromShips(final World world, final BlockPos originalHeight) {
if (VSConfig.accurateRain && Minecraft.getMinecraft().player != null) {
final AxisAlignedBB boundingBox = new AxisAlignedBB(originalHeight.getX() - .5, 0, originalHeight.getZ() - .5, originalHeight.getX() + .5, 255, originalHeight.getZ() + .5);
final List<PhysicsObject> physicsObjectList = ValkyrienUtils.getPhysObjWorld(world).getPhysObjectsInAABB(boundingBox);
final Vec3d traceStart = new Vec3d(originalHeight.getX() + .5, Minecraft.getMinecraft().player.posY + 50, originalHeight.getZ() + .5);
final Vec3d traceEnd = new Vec3d(originalHeight.getX() + .5, originalHeight.getY() + .5, originalHeight.getZ() + .5);
if (traceStart.y < traceEnd.y) {
return originalHeight;
}
for (final PhysicsObject physicsObject : physicsObjectList) {
final RayTraceResult result = ((IWorldVS) world).rayTraceBlocksInShip(traceStart, traceEnd, true, true, false, physicsObject);
// noinspection ConstantConditions
if (result != null && result.getBlockPos() != null && result.typeOfHit != RayTraceResult.Type.MISS) {
Vector3d blockPosVector = JOML.convertDouble(result.getBlockPos()).add(.5, .5, .5);
physicsObject.getShipTransformationManager().getCurrentTickTransform().getSubspaceToGlobal().transformPosition(blockPosVector);
return new BlockPos(originalHeight.getX(), blockPosVector.y(), originalHeight.getZ());
}
}
}
return originalHeight;
}
Aggregations