Search in sources :

Example 91 with Vector3d

use of org.joml.Vector3d in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class MixinTileEntity method getDistanceSq.

/**
 * This is easier to have as an overwrite because there's less laggy hackery to be done then :P
 *
 * @author DaPorkchop_
 */
@Overwrite
public double getDistanceSq(double x, double y, double z) {
    World tileWorld = this.world;
    double d0 = (double) this.pos.getX() + 0.5D - x;
    double d1 = (double) this.pos.getY() + 0.5D - y;
    double d2 = (double) this.pos.getZ() + 0.5D - z;
    double toReturn = d0 * d0 + d1 * d1 + d2 * d2;
    if (tileWorld != null) {
        // Assume on Ship
        if (tileWorld.isRemote && toReturn > 9999999D) {
            BlockPos pos = this.pos;
            Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(world, pos);
            if (physicsObject.isPresent()) {
                Vector3d tilePos = new Vector3d(pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5);
                physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(tilePos, TransformType.SUBSPACE_TO_GLOBAL);
                tilePos.x -= x;
                tilePos.y -= y;
                tilePos.z -= z;
                return tilePos.lengthSquared();
            }
        }
    }
    return toReturn;
}
Also used : Vector3d(org.joml.Vector3d) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) PhysicsObject(org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 92 with Vector3d

use of org.joml.Vector3d in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class MixinChunkPos method getDistanceSq.

/**
 * This is easier to have as an overwrite because there's less laggy hackery to be done then :P
 *
 * @author DaPorkchop_
 */
@Overwrite
public double getDistanceSq(Entity entityIn) {
    double d0 = this.x * 16 + 8;
    double d1 = this.z * 16 + 8;
    double d2 = d0 - entityIn.posX;
    double d3 = d1 - entityIn.posZ;
    double vanilla = d2 * d2 + d3 * d3;
    // A big number
    if (vanilla < TOO_MUCH_DISTANCE) {
        return vanilla;
    }
    try {
        Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(entityIn.world, new BlockPos(d0, 127, d1));
        if (physicsObject.isPresent()) {
            Vector3d entityPosInLocal = new Vector3d(entityIn.posX, entityIn.posY, entityIn.posZ);
            // RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.wToLTransform,
            // entityPosInLocal);
            physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(entityPosInLocal, TransformType.GLOBAL_TO_SUBSPACE);
            entityPosInLocal.sub(d0, entityPosInLocal.y, d1);
            return entityPosInLocal.lengthSquared();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return vanilla;
}
Also used : Vector3d(org.joml.Vector3d) BlockPos(net.minecraft.util.math.BlockPos) PhysicsObject(org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 93 with Vector3d

use of org.joml.Vector3d in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class MixinEntity method getDistanceSq.

/**
 * This is easier to have as an overwrite because there's less laggy hackery to be done then :P
 *
 * @author DaPorkchop_
 */
@Overwrite
public double getDistanceSq(BlockPos pos) {
    double vanilla = pos.getDistance((int) posX, (int) posY, (int) posZ);
    if (vanilla < 64.0D) {
        return vanilla;
    } else {
        Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(world, pos);
        if (physicsObject.isPresent()) {
            Vector3d posVec = new Vector3d(pos.getX() + .5D, pos.getY() + .5D, pos.getZ() + .5D);
            physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(posVec, TransformType.SUBSPACE_TO_GLOBAL);
            posVec.x -= this.posX;
            posVec.y -= this.posY;
            posVec.z -= this.posZ;
            if (vanilla > posVec.lengthSquared()) {
                return posVec.lengthSquared();
            }
        }
    }
    return vanilla;
}
Also used : Vector3d(org.joml.Vector3d) PhysicsObject(org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 94 with Vector3d

use of org.joml.Vector3d in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class MixinEntity method runningParticlesFirstFloor.

@Redirect(method = "createRunningParticles", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/math/MathHelper;floor(D)I", ordinal = 0))
private int runningParticlesFirstFloor(double d) {
    final ShipData lastTouchedShip = ValkyrienUtils.getLastShipTouchedByEntity(thisAsEntity);
    if (lastTouchedShip == null) {
        searchVector = null;
        return MathHelper.floor(d);
    } else {
        searchVector = new Vector3d(this.posX, this.posY - 0.20000000298023224D, this.posZ);
        lastTouchedShip.getShipTransform().transformPosition(searchVector, TransformType.GLOBAL_TO_SUBSPACE);
        return MathHelper.floor(searchVector.x);
    }
}
Also used : Vector3d(org.joml.Vector3d) ShipData(org.valkyrienskies.mod.common.ships.ShipData) Redirect(org.spongepowered.asm.mixin.injection.Redirect)

Example 95 with Vector3d

use of org.joml.Vector3d in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class MixinEntity method getDistanceSq.

/**
 * This is easier to have as an overwrite because there's less laggy hackery to be done then :P
 *
 * @author DaPorkchop_
 */
@Overwrite
public double getDistanceSq(double x, double y, double z) {
    double d0 = this.posX - x;
    double d1 = this.posY - y;
    double d2 = this.posZ - z;
    double vanilla = d0 * d0 + d1 * d1 + d2 * d2;
    if (vanilla < 64.0D) {
        return vanilla;
    } else {
        Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(world, new BlockPos(x, y, z));
        if (physicsObject.isPresent()) {
            Vector3d posVec = new Vector3d(x, y, z);
            physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(posVec, TransformType.SUBSPACE_TO_GLOBAL);
            posVec.x -= this.posX;
            posVec.y -= this.posY;
            posVec.z -= this.posZ;
            if (vanilla > posVec.lengthSquared()) {
                return posVec.lengthSquared();
            }
        }
    }
    return vanilla;
}
Also used : Vector3d(org.joml.Vector3d) BlockPos(net.minecraft.util.math.BlockPos) PhysicsObject(org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Aggregations

Vector3d (org.joml.Vector3d)117 Vector3dc (org.joml.Vector3dc)33 PhysicsObject (org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject)20 BlockPos (net.minecraft.util.math.BlockPos)19 ShipTransform (org.valkyrienskies.mod.common.ships.ship_transform.ShipTransform)18 Location (io.xol.chunkstories.api.Location)12 Entity (io.xol.chunkstories.api.entity.Entity)11 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)9 World (net.minecraft.world.World)9 ShipData (org.valkyrienskies.mod.common.ships.ShipData)9 WorldClient (io.xol.chunkstories.api.world.WorldClient)8 WorldMaster (io.xol.chunkstories.api.world.WorldMaster)8 EntityPlayer (net.minecraft.entity.player.EntityPlayer)8 EntityShipMovementData (org.valkyrienskies.mod.common.entity.EntityShipMovementData)7 EntityControllable (io.xol.chunkstories.api.entity.interfaces.EntityControllable)6 IBlockState (net.minecraft.block.state.IBlockState)6 Vec3d (net.minecraft.util.math.Vec3d)6 Vector3f (org.joml.Vector3f)6 EntityLiving (io.xol.chunkstories.api.entity.EntityLiving)5 CellData (io.xol.chunkstories.api.world.cell.CellData)5