Search in sources :

Example 1 with IntermediateMovementVariableStorage

use of org.valkyrienskies.mod.common.ships.entity_interaction.EntityCollisionInjector.IntermediateMovementVariableStorage in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class EntityMoveInjectionMethods method handleMove.

public static IntermediateMovementVariableStorage handleMove(MoverType type, double dx, double dy, double dz, Entity this_) {
    if (this_ instanceof EntityPlayer && ((EntityPlayer) this_).isSpectator()) {
        return null;
    }
    double movDistSq = (dx * dx) + (dy * dy) + (dz * dz);
    if (movDistSq > 10000) {
        // Assume this_ will take us to Ship coordinates
        double newX = this_.posX + dx;
        double newY = this_.posY + dy;
        double newZ = this_.posZ + dz;
        BlockPos newPosInBlock = new BlockPos(newX, newY, newZ);
        Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(this_.world, newPosInBlock);
        if (!physicsObject.isPresent()) {
            return null;
        }
        Vector3d endPos = new Vector3d(newX, newY, newZ);
        physicsObject.get().getShipTransformationManager().getCurrentTickTransform().transformPosition(endPos, TransformType.GLOBAL_TO_SUBSPACE);
        dx = endPos.x - this_.posX;
        dy = endPos.y - this_.posY;
        dz = endPos.z - this_.posZ;
    }
    IntermediateMovementVariableStorage alteredMovement = EntityCollisionInjector.alterEntityMovement(this_, type, dx, dy, dz);
    return alteredMovement;
}
Also used : Vector3d(org.joml.Vector3d) EntityPlayer(net.minecraft.entity.player.EntityPlayer) BlockPos(net.minecraft.util.math.BlockPos) IntermediateMovementVariableStorage(org.valkyrienskies.mod.common.ships.entity_interaction.EntityCollisionInjector.IntermediateMovementVariableStorage) PhysicsObject(org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject)

Aggregations

EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 BlockPos (net.minecraft.util.math.BlockPos)1 Vector3d (org.joml.Vector3d)1 IntermediateMovementVariableStorage (org.valkyrienskies.mod.common.ships.entity_interaction.EntityCollisionInjector.IntermediateMovementVariableStorage)1 PhysicsObject (org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject)1