Search in sources :

Example 1 with IBlockForceProvider

use of ValkyrienWarfareBase.API.IBlockForceProvider in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class PhysicsCalculations method calculateForces.

public void calculateForces() {
    double modifiedDrag = Math.pow(drag, physTickSpeed / .05D);
    linearMomentum.multiply(modifiedDrag);
    angularVelocity.multiply(modifiedDrag);
    if (PhysicsSettings.doGravity) {
        addForceAtPoint(new Vector(0, 0, 0), ValkyrienWarfareMod.gravity.getProduct(mass * physTickSpeed));
    }
    addQueuedForces();
    Collections.shuffle(activeForcePositions);
    Vector blockForce = new Vector();
    Vector inBodyWO = new Vector();
    Vector crossVector = new Vector();
    if (PhysicsSettings.doPhysicsBlocks) {
        for (BlockPos pos : activeForcePositions) {
            IBlockState state = parent.VKChunkCache.getBlockState(pos);
            Block blockAt = state.getBlock();
            BigBastardMath.getBodyPosWithOrientation(pos, centerOfMass, parent.coordTransform.lToWRotation, inBodyWO);
            BlockForce.basicForces.getForceFromState(state, pos, worldObj, physTickSpeed, parent, blockForce);
            if (blockForce != null) {
                if (blockAt instanceof IBlockForceProvider) {
                    Vector otherPosition = ((IBlockForceProvider) blockAt).getBlockForcePosition(worldObj, pos, state, parent.wrapper, physTickSpeed);
                    if (otherPosition != null) {
                        BigBastardMath.getBodyPosWithOrientation(otherPosition, centerOfMass, parent.coordTransform.lToWRotation, inBodyWO);
                    }
                }
                addForceAtPoint(inBodyWO, blockForce, crossVector);
            } else {
            }
        }
    }
    if (PhysicsSettings.doBalloons) {
        for (BalloonProcessor balloon : parent.balloonManager.balloonProcessors) {
            balloon.tickBalloonTemperatures(physTickSpeed, this);
            Vector balloonForce = balloon.getBalloonForce(physTickSpeed, this);
            Vector balloonCenterInBody = balloon.getForceCenter();
            BigBastardMath.getBodyPosWithOrientation(balloonCenterInBody, centerOfMass, parent.coordTransform.lToWRotation, inBodyWO);
            addForceAtPoint(inBodyWO, balloonForce, crossVector);
        }
    }
    convertTorqueToVelocity();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BalloonProcessor(ValkyrienWarfareControl.Balloon.BalloonProcessor) IBlockForceProvider(ValkyrienWarfareBase.API.IBlockForceProvider) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) Vector(ValkyrienWarfareBase.API.Vector)

Example 2 with IBlockForceProvider

use of ValkyrienWarfareBase.API.IBlockForceProvider in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class BlockForce method getForceFromState.

public void getForceFromState(IBlockState state, BlockPos pos, World world, double secondsToApply, PhysicsObject obj, Vector toSet) {
    Block block = state.getBlock();
    if (block instanceof IBlockForceProvider) {
        Vector forceVector = ((IBlockForceProvider) block).getBlockForce(world, pos, state, obj.wrapper, secondsToApply);
        if (forceVector == null) {
            toSet.zero();
            return;
        }
        boolean isInLocal = ((IBlockForceProvider) block).isForceLocalCoords(world, pos, state, secondsToApply);
        if (isInLocal) {
            RotationMatrices.applyTransform(obj.coordTransform.lToWRotation, forceVector);
        }
        toSet.X = forceVector.X;
        toSet.Y = forceVector.Y;
        toSet.Z = forceVector.Z;
        return;
    }
    Force force = basicForces.blocksToForces.get(block);
    if (force != null) {
        toSet.X = force.X * secondsToApply;
        toSet.Y = force.Y * secondsToApply;
        toSet.Z = force.Z * secondsToApply;
    } else {
        toSet.zero();
    }
}
Also used : IBlockForceProvider(ValkyrienWarfareBase.API.IBlockForceProvider) Block(net.minecraft.block.Block) Vector(ValkyrienWarfareBase.API.Vector)

Example 3 with IBlockForceProvider

use of ValkyrienWarfareBase.API.IBlockForceProvider in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class BlockForce method getForceFromState.

public Vector getForceFromState(IBlockState state, BlockPos pos, World world, double secondsToApply, PhysicsObject obj) {
    Block block = state.getBlock();
    if (block instanceof IBlockForceProvider) {
        Vector forceVector = ((IBlockForceProvider) block).getBlockForce(world, pos, state, obj.wrapper, secondsToApply);
        if (forceVector == null) {
            return null;
        }
        boolean isInLocal = ((IBlockForceProvider) block).isForceLocalCoords(world, pos, state, secondsToApply);
        if (isInLocal) {
            RotationMatrices.applyTransform(obj.coordTransform.lToWRotation, forceVector);
        }
        return forceVector;
    }
    Force force = basicForces.blocksToForces.get(block);
    if (force != null) {
        return force.getProduct(secondsToApply);
    } else {
        return null;
    }
}
Also used : IBlockForceProvider(ValkyrienWarfareBase.API.IBlockForceProvider) Block(net.minecraft.block.Block) Vector(ValkyrienWarfareBase.API.Vector)

Aggregations

IBlockForceProvider (ValkyrienWarfareBase.API.IBlockForceProvider)3 Vector (ValkyrienWarfareBase.API.Vector)3 Block (net.minecraft.block.Block)3 BalloonProcessor (ValkyrienWarfareControl.Balloon.BalloonProcessor)1 IBlockState (net.minecraft.block.state.IBlockState)1 BlockPos (net.minecraft.util.math.BlockPos)1