Search in sources :

Example 1 with BalloonProcessor

use of ValkyrienWarfareControl.Balloon.BalloonProcessor 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 BalloonProcessor

use of ValkyrienWarfareControl.Balloon.BalloonProcessor in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class BlockBalloonBurner method onBlockPlaced.

@Override
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) {
    PhysicsWrapperEntity wrapperEntity = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, pos);
    // Balloons can only be made on an active Ship
    if (wrapperEntity != null) {
        BlockPos balloonStart = pos.up(2);
        if (!worldIn.isRemote) {
            BalloonProcessor existingProcessor = wrapperEntity.wrapping.balloonManager.getProcessorAbovePos(pos);
            if (existingProcessor == null) {
                BalloonDetector detector = new BalloonDetector(balloonStart, worldIn, 25000);
                int balloonSize = detector.foundSet.size();
                if (balloonSize == 0) {
                    placer.addChatMessage(new TextComponentString("No balloon above"));
                } else {
                    placer.addChatMessage(new TextComponentString("Created a new Balloon"));
                    BalloonProcessor processor = BalloonProcessor.makeProcessorForDetector(wrapperEntity, detector);
                    wrapperEntity.wrapping.balloonManager.addBalloonProcessor(processor);
                // System.out.println("Balloon Walls Are " + detector.balloonWalls.size());
                }
            } else {
                placer.addChatMessage(new TextComponentString("Hooked onto Exisiting Balloon"));
            }
        }
    }
    return super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer);
}
Also used : BalloonProcessor(ValkyrienWarfareControl.Balloon.BalloonProcessor) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BalloonDetector(ValkyrienWarfareControl.Balloon.BalloonDetector) BlockPos(net.minecraft.util.math.BlockPos) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

BalloonProcessor (ValkyrienWarfareControl.Balloon.BalloonProcessor)2 BlockPos (net.minecraft.util.math.BlockPos)2 IBlockForceProvider (ValkyrienWarfareBase.API.IBlockForceProvider)1 Vector (ValkyrienWarfareBase.API.Vector)1 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)1 BalloonDetector (ValkyrienWarfareControl.Balloon.BalloonDetector)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 TextComponentString (net.minecraft.util.text.TextComponentString)1