Search in sources :

Example 41 with PhysicsWrapperEntity

use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class BlockShipPilotsChair method onBlockActivated.

@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (!worldIn.isRemote) {
        PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldIn, pos);
        if (wrapper != null) {
            if (playerIn.getLowestRidingEntity() != wrapper.getLowestRidingEntity()) {
                Vector playerPos = new Vector(playerIn);
                wrapper.wrapping.coordTransform.fromLocalToGlobal(playerPos);
                playerIn.posX = playerPos.X;
                playerIn.posY = playerPos.Y;
                playerIn.posZ = playerPos.Z;
                playerIn.startRiding(wrapper);
                Vector localMountPos = getPlayerMountOffset(state, pos);
                wrapper.wrapping.fixEntity(playerIn, localMountPos);
                wrapper.wrapping.pilotingController.setPilotEntity((EntityPlayerMP) playerIn, false);
                wrapper.wrapping.coordTransform.fromGlobalToLocal(playerPos);
                playerIn.posX = playerPos.X;
                playerIn.posY = playerPos.Y;
                playerIn.posZ = playerPos.Z;
                return true;
            }
        }
    }
    return false;
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) Vector(ValkyrienWarfareBase.API.Vector)

Example 42 with PhysicsWrapperEntity

use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class RealMethods method getPositionInShipFromReal.

@Override
public Vector getPositionInShipFromReal(World worldObj, Entity shipEnt, Vector positionInWorld) {
    PhysicsWrapperEntity wrapper = (PhysicsWrapperEntity) shipEnt;
    Vector inLocal = new Vector(positionInWorld);
    wrapper.wrapping.coordTransform.fromLocalToGlobal(inLocal);
    return inLocal;
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) Vector(ValkyrienWarfareBase.API.Vector)

Example 43 with PhysicsWrapperEntity

use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class RealMethods method getVelocityAtPoint.

// Note, do not call this from World coordinates; first subtract the world coords from the shipEntity xyz and then call!
@Override
public Vector getVelocityAtPoint(Entity shipEnt, Vector inBody, double secondsToApply) {
    PhysicsWrapperEntity wrapper = (PhysicsWrapperEntity) shipEnt;
    Vector toReturn = wrapper.wrapping.physicsProcessor.getVelocityAtPoint(inBody);
    toReturn.multiply(secondsToApply);
    return toReturn;
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) Vector(ValkyrienWarfareBase.API.Vector)

Example 44 with PhysicsWrapperEntity

use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CallRunner method onSetBlockState.

public static void onSetBlockState(IBlockState newState, int flags, World world, BlockPos pos) {
    IBlockState oldState = world.getBlockState(pos);
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(world, pos);
    if (wrapper != null) {
        wrapper.wrapping.onSetBlockState(oldState, newState, pos);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)

Example 45 with PhysicsWrapperEntity

use of ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class CallRunnerClient method onRenderBlockLayer.

public static int onRenderBlockLayer(RenderGlobal renderer, BlockRenderLayer blockLayerIn, double partialTicks, int pass, Entity entityIn) {
    for (PhysicsWrapperEntity wrapper : ValkyrienWarfareMod.physicsManager.getManagerForWorld(renderer.theWorld).physicsEntities) {
        GL11.glPushMatrix();
        if (wrapper.wrapping.renderer != null && wrapper.wrapping.renderer.shouldRender()) {
            wrapper.wrapping.renderer.renderBlockLayer(blockLayerIn, partialTicks, pass);
        }
        GL11.glPopMatrix();
    }
    GlStateManager.resetColor();
    return renderer.renderBlockLayer(blockLayerIn, partialTicks, pass, entityIn);
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)

Aggregations

PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)69 BlockPos (net.minecraft.util.math.BlockPos)29 Vector (ValkyrienWarfareBase.API.Vector)28 EntityPlayer (net.minecraft.entity.player.EntityPlayer)10 IBlockState (net.minecraft.block.state.IBlockState)9 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)9 TextComponentString (net.minecraft.util.text.TextComponentString)9 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)8 Vec3d (net.minecraft.util.math.Vec3d)7 WorldPhysObjectManager (ValkyrienWarfareBase.PhysicsManagement.WorldPhysObjectManager)6 Block (net.minecraft.block.Block)6 Entity (net.minecraft.entity.Entity)6 TileEntity (net.minecraft.tileentity.TileEntity)6 IThreadListener (net.minecraft.util.IThreadListener)5 World (net.minecraft.world.World)5 Quaternion (ValkyrienWarfareBase.Math.Quaternion)4 ArrayList (java.util.ArrayList)4 RayTraceResult (net.minecraft.util.math.RayTraceResult)4 EntityPolygon (ValkyrienWarfareBase.Collision.EntityPolygon)3 Polygon (ValkyrienWarfareBase.Collision.Polygon)3