Search in sources :

Example 1 with BlockShipPilotsChair

use of ValkyrienWarfareControl.Block.BlockShipPilotsChair in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ShipPilotingController method handlePilotControlMessage.

private void handlePilotControlMessage(PilotControlsMessage message, EntityPlayerMP whoSentIt) {
    //Set to whatever the player was pointing at in Ship space
    //These vectors can be re-arranged depending on the direction the chair was placed
    IBlockState state = controlledShip.worldObj.getBlockState(chairPosition);
    if (state.getBlock() instanceof BlockShipPilotsChair) {
        double pilotPitch = 0D;
        double pilotYaw = ((BlockShipPilotsChair) state.getBlock()).getChairYaw(state, chairPosition);
        double pilotRoll = 0D;
        double[] pilotRotationMatrix = RotationMatrices.getRotationMatrix(pilotPitch, pilotYaw, pilotRoll);
        Vector playerDirection = new Vector(1, 0, 0);
        Vector rightDirection = new Vector(0, 0, 1);
        Vector leftDirection = new Vector(0, 0, -1);
        RotationMatrices.applyTransform(pilotRotationMatrix, playerDirection);
        RotationMatrices.applyTransform(pilotRotationMatrix, rightDirection);
        RotationMatrices.applyTransform(pilotRotationMatrix, leftDirection);
        Vector upDirection = new Vector(0, 1, 0);
        Vector downDirection = new Vector(0, -1, 0);
        Vector idealAngularDirection = new Vector();
        Vector idealLinearVelocity = new Vector();
        Vector shipUp = new Vector(0, 1, 0);
        Vector shipUpPos = new Vector(0, 1, 0);
        if (message.airshipForward) {
            idealLinearVelocity.add(playerDirection);
        }
        if (message.airshipBackward) {
            idealLinearVelocity.subtract(playerDirection);
        }
        RotationMatrices.applyTransform(controlledShip.coordTransform.lToWRotation, idealLinearVelocity);
        RotationMatrices.applyTransform(controlledShip.coordTransform.lToWRotation, shipUp);
        if (message.airshipUp) {
            idealLinearVelocity.add(upDirection);
        }
        if (message.airshipDown) {
            idealLinearVelocity.add(downDirection);
        }
        if (message.airshipRight) {
            idealAngularDirection.add(rightDirection);
        }
        if (message.airshipLeft) {
            idealAngularDirection.add(leftDirection);
        }
        //Upside down if you want it
        //			Vector shipUpOffset = shipUpPos.getSubtraction(shipUp);
        Vector shipUpOffset = shipUp.getSubtraction(shipUpPos);
        double mass = controlledShip.physicsProcessor.mass;
        //			idealAngularDirection.multiply(mass/2.5D);
        idealLinearVelocity.multiply(mass / 5D);
        //			shipUpOffset.multiply(mass/2.5D);
        idealAngularDirection.multiply(1D / 6D);
        shipUpOffset.multiply(1D / 3D);
        Vector velocityCompenstationLinear = controlledShip.physicsProcessor.linearMomentum;
        Vector velocityCompensationAngular = controlledShip.physicsProcessor.angularVelocity.cross(playerDirection);
        Vector velocityCompensationAlignment = controlledShip.physicsProcessor.angularVelocity.cross(shipUpPos);
        velocityCompensationAlignment.multiply(controlledShip.physicsProcessor.physRawSpeed);
        velocityCompensationAngular.multiply(2D * controlledShip.physicsProcessor.physRawSpeed);
        shipUpOffset.subtract(velocityCompensationAlignment);
        velocityCompensationAngular.subtract(velocityCompensationAngular);
        RotationMatrices.applyTransform3by3(controlledShip.physicsProcessor.framedMOI, idealAngularDirection);
        RotationMatrices.applyTransform3by3(controlledShip.physicsProcessor.framedMOI, shipUpOffset);
        if (message.airshipSprinting) {
            idealLinearVelocity.multiply(2D);
        }
        idealLinearVelocity.subtract(idealAngularDirection);
        idealLinearVelocity.subtract(shipUpOffset);
        //TEMPORARY CODE!!!
        controlledShip.physicsProcessor.addForceAtPoint(playerDirection, idealAngularDirection);
        controlledShip.physicsProcessor.addForceAtPoint(shipUpPos, shipUpOffset);
        controlledShip.physicsProcessor.addForceAtPoint(new Vector(), idealLinearVelocity);
        controlledShip.physicsProcessor.convertTorqueToVelocity();
    //			RotationMatrices.applyTransform(controlledShip.coordTransform.lToWRotation, idealAngularDirection);
    //			System.out.println(idealAngularDirection);
    }
}
Also used : BlockShipPilotsChair(ValkyrienWarfareControl.Block.BlockShipPilotsChair) IBlockState(net.minecraft.block.state.IBlockState) Vector(ValkyrienWarfareBase.API.Vector)

Example 2 with BlockShipPilotsChair

use of ValkyrienWarfareControl.Block.BlockShipPilotsChair in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ValkyrienWarfareControlMod method registerBlocks.

private void registerBlocks(FMLStateEvent event) {
    double basicEnginePower = config.get(Configuration.CATEGORY_GENERAL, "basicEnginePower", 4000D, "Engine power for the basic Engine").getDouble();
    double advancedEnginePower = config.get(Configuration.CATEGORY_GENERAL, "advancedEnginePower", 6000D, "Engine power for the advanced Engine").getDouble();
    double eliteEnginePower = config.get(Configuration.CATEGORY_GENERAL, "eliteEnginePower", 8000D, "Engine power for the elite Engine").getDouble();
    double ultimateEnginePower = config.get(Configuration.CATEGORY_GENERAL, "ultimateEnginePower", 16000D, "Engine power for the ultimate Engine").getDouble();
    double redstoneEnginePower = config.get(Configuration.CATEGORY_GENERAL, "redstoneEnginePower", 500D, "Multiplied by the redstone power (0-15) to the Redstone Engine").getDouble();
    double basicEtherCompressorPower = config.get(Configuration.CATEGORY_GENERAL, "basicEtherCompressorPower", 25000D, "Engine power for the basic Ether Compressor").getDouble();
    double advancedEtherCompressorPower = config.get(Configuration.CATEGORY_GENERAL, "advancedEtherCompressorPower", 45000D, "Engine power for the advanced Ether Compressor").getDouble();
    double eliteEtherCompressorPower = config.get(Configuration.CATEGORY_GENERAL, "eliteEtherCompressorPower", 80000D, "Engine power for the elite Ether Compressor").getDouble();
    double ultimateEtherCompressorPower = config.get(Configuration.CATEGORY_GENERAL, "ultimateEtherCompressorPower", 100000D, "Engine power for the ultimate Ether Compressor").getDouble();
    basicEngine = new BlockNormalEngine(Material.WOOD, basicEnginePower).setHardness(5f).setUnlocalizedName("basicEngine").setRegistryName(MODID, "basicEngine").setCreativeTab(CreativeTabs.TRANSPORTATION);
    advancedEngine = new BlockNormalEngine(Material.ROCK, advancedEnginePower).setHardness(6f).setUnlocalizedName("advancedEngine").setRegistryName(MODID, "advancedEngine").setCreativeTab(CreativeTabs.TRANSPORTATION);
    eliteEngine = new BlockNormalEngine(Material.IRON, eliteEnginePower).setHardness(8f).setUnlocalizedName("eliteEngine").setRegistryName(MODID, "eliteEngine").setCreativeTab(CreativeTabs.TRANSPORTATION);
    ultimateEngine = new BlockNormalEngine(Material.GROUND, ultimateEnginePower).setHardness(10f).setUnlocalizedName("ultimateEngine").setRegistryName(MODID, "ultimateEngine").setCreativeTab(CreativeTabs.TRANSPORTATION);
    redstoneEngine = new BlockRedstoneEngine(Material.REDSTONE_LIGHT, redstoneEnginePower).setHardness(7.0f).setUnlocalizedName("redstoneEngine").setRegistryName(MODID, "redstoneEngine").setCreativeTab(CreativeTabs.TRANSPORTATION);
    antigravityEngine = new BlockNormalEtherCompressor(Material.WOOD, basicEtherCompressorPower).setHardness(8f).setUnlocalizedName("antigravengine").setRegistryName(MODID, "antigravengine").setCreativeTab(CreativeTabs.TRANSPORTATION);
    advancedEtherCompressor = new BlockNormalEtherCompressor(Material.ROCK, advancedEtherCompressorPower).setHardness(8f).setUnlocalizedName("advancedEtherCompressor").setRegistryName(MODID, "advancedEtherCompressor").setCreativeTab(CreativeTabs.TRANSPORTATION);
    eliteEtherCompressor = new BlockNormalEtherCompressor(Material.IRON, eliteEtherCompressorPower).setHardness(8f).setUnlocalizedName("eliteEtherCompressor").setRegistryName(MODID, "eliteEtherCompressor").setCreativeTab(CreativeTabs.TRANSPORTATION);
    ultimateEtherCompressor = new BlockNormalEtherCompressor(Material.GROUND, ultimateEtherCompressorPower).setHardness(8f).setUnlocalizedName("ultimateEtherCompressor").setRegistryName(MODID, "ultimateEtherCompressor").setCreativeTab(CreativeTabs.TRANSPORTATION);
    creativeEtherCompressor = new BlockCreativeEtherCompressor(Material.BARRIER, Double.MAX_VALUE / 4).setHardness(0.0f).setUnlocalizedName("creativeEtherCompressor").setRegistryName(MODID, "creativeEtherCompressor").setCreativeTab(CreativeTabs.TRANSPORTATION);
    basicHoverController = new BlockHovercraftController(Material.IRON).setHardness(10f).setUnlocalizedName("basichovercraftcontroller").setRegistryName(MODID, "basichovercraftcontroller").setCreativeTab(CreativeTabs.TRANSPORTATION);
    dopedEtherium = new BlockDopedEtherium(Material.GLASS).setHardness(4f).setUnlocalizedName("dopedetherium").setRegistryName(MODID, "dopedetherium").setCreativeTab(CreativeTabs.TRANSPORTATION);
    balloonBurner = new BlockBalloonBurner(Material.IRON).setHardness(4f).setUnlocalizedName("balloonburner").setRegistryName(MODID, "balloonburner").setCreativeTab(CreativeTabs.TRANSPORTATION);
    pilotsChair = new BlockShipPilotsChair(Material.IRON).setHardness(4f).setUnlocalizedName("shippilotschair").setRegistryName(MODID, "shippilotschair").setCreativeTab(CreativeTabs.TRANSPORTATION);
    passengerChair = new BlockShipPassengerChair(Material.IRON).setHardness(4f).setUnlocalizedName("shippassengerchair").setRegistryName(MODID, "shippassengerchair").setCreativeTab(CreativeTabs.TRANSPORTATION);
    thrustRelay = new BlockThrustRelay(Material.IRON).setHardness(5f).setUnlocalizedName("thrustrelay").setRegistryName(MODID, "thrustrelay").setCreativeTab(CreativeTabs.TRANSPORTATION);
    thrustModulator = new BlockThrustModulator(Material.IRON).setHardness(8f).setUnlocalizedName("thrustmodulator").setRegistryName(MODID, "thrustmodulator").setCreativeTab(CreativeTabs.TRANSPORTATION);
    registerBlock(basicEngine);
    registerBlock(advancedEngine);
    registerBlock(eliteEngine);
    registerBlock(ultimateEngine);
    registerBlock(redstoneEngine);
    registerBlock(antigravityEngine);
    registerBlock(advancedEtherCompressor);
    registerBlock(eliteEtherCompressor);
    registerBlock(ultimateEtherCompressor);
    registerBlock(creativeEtherCompressor);
    registerBlock(basicHoverController);
    registerBlock(dopedEtherium);
    registerBlock(balloonBurner);
    registerBlock(pilotsChair);
    registerBlock(passengerChair);
    registerBlock(thrustRelay);
    registerBlock(thrustModulator);
}
Also used : BlockShipPilotsChair(ValkyrienWarfareControl.Block.BlockShipPilotsChair) BlockRedstoneEngine(ValkyrienWarfareControl.Block.Engine.BlockRedstoneEngine) BlockHovercraftController(ValkyrienWarfareControl.Block.BlockHovercraftController) BlockNormalEngine(ValkyrienWarfareControl.Block.Engine.BlockNormalEngine) BlockDopedEtherium(ValkyrienWarfareControl.Block.BlockDopedEtherium) BlockCreativeEtherCompressor(ValkyrienWarfareControl.Block.EtherCompressor.BlockCreativeEtherCompressor) BlockThrustRelay(ValkyrienWarfareControl.Block.BlockThrustRelay) BlockNormalEtherCompressor(ValkyrienWarfareControl.Block.EtherCompressor.BlockNormalEtherCompressor) BlockBalloonBurner(ValkyrienWarfareControl.Block.BlockBalloonBurner) BlockThrustModulator(ValkyrienWarfareControl.Block.BlockThrustModulator) BlockShipPassengerChair(ValkyrienWarfareControl.Block.BlockShipPassengerChair)

Aggregations

BlockShipPilotsChair (ValkyrienWarfareControl.Block.BlockShipPilotsChair)2 Vector (ValkyrienWarfareBase.API.Vector)1 BlockBalloonBurner (ValkyrienWarfareControl.Block.BlockBalloonBurner)1 BlockDopedEtherium (ValkyrienWarfareControl.Block.BlockDopedEtherium)1 BlockHovercraftController (ValkyrienWarfareControl.Block.BlockHovercraftController)1 BlockShipPassengerChair (ValkyrienWarfareControl.Block.BlockShipPassengerChair)1 BlockThrustModulator (ValkyrienWarfareControl.Block.BlockThrustModulator)1 BlockThrustRelay (ValkyrienWarfareControl.Block.BlockThrustRelay)1 BlockNormalEngine (ValkyrienWarfareControl.Block.Engine.BlockNormalEngine)1 BlockRedstoneEngine (ValkyrienWarfareControl.Block.Engine.BlockRedstoneEngine)1 BlockCreativeEtherCompressor (ValkyrienWarfareControl.Block.EtherCompressor.BlockCreativeEtherCompressor)1 BlockNormalEtherCompressor (ValkyrienWarfareControl.Block.EtherCompressor.BlockNormalEtherCompressor)1 IBlockState (net.minecraft.block.state.IBlockState)1