Search in sources :

Example 1 with IWorldVS

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;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) IWorldVS(org.valkyrienskies.mod.common.ships.ship_world.IWorldVS) Vector3d(org.joml.Vector3d) RayTraceResult(net.minecraft.util.math.RayTraceResult) BlockPos(net.minecraft.util.math.BlockPos) PhysicsObject(org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1 RayTraceResult (net.minecraft.util.math.RayTraceResult)1 Vec3d (net.minecraft.util.math.Vec3d)1 Vector3d (org.joml.Vector3d)1 IWorldVS (org.valkyrienskies.mod.common.ships.ship_world.IWorldVS)1 PhysicsObject (org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject)1