Search in sources :

Example 26 with PhysicsWrapperEntity

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

the class BlockShipPassengerChair 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 27 with PhysicsWrapperEntity

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

the class CallRunnerClient method renderTileEntity.

public static void renderTileEntity(TileEntityRendererDispatcher dispatch, TileEntity tileentityIn, float partialTicks, int destroyStage) {
    BlockPos pos = tileentityIn.getPos();
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(tileentityIn.getWorld(), pos);
    if (wrapper != null && wrapper.wrapping != null && wrapper.wrapping.renderer != null) {
        try {
            boolean drawingBatchOrig = drawingBatchName.getBoolean(dispatch);
            if (drawingBatchOrig) {
                dispatch.drawBatch(MinecraftForgeClient.getRenderPass());
                dispatch.preDrawBatch();
            }
            wrapper.wrapping.renderer.setupTranslation(partialTicks);
            double playerX = TileEntityRendererDispatcher.instance.staticPlayerX;
            double playerY = TileEntityRendererDispatcher.instance.staticPlayerY;
            double playerZ = TileEntityRendererDispatcher.instance.staticPlayerZ;
            TileEntityRendererDispatcher.instance.staticPlayerX = wrapper.wrapping.renderer.offsetPos.getX();
            TileEntityRendererDispatcher.instance.staticPlayerY = wrapper.wrapping.renderer.offsetPos.getY();
            TileEntityRendererDispatcher.instance.staticPlayerZ = wrapper.wrapping.renderer.offsetPos.getZ();
            if (drawingBatchOrig) {
                dispatch.renderTileEntity(tileentityIn, partialTicks, destroyStage);
                dispatch.drawBatch(MinecraftForgeClient.getRenderPass());
                dispatch.preDrawBatch();
            } else {
                dispatch.renderTileEntity(tileentityIn, partialTicks, destroyStage);
            }
            TileEntityRendererDispatcher.instance.staticPlayerX = playerX;
            TileEntityRendererDispatcher.instance.staticPlayerY = playerY;
            TileEntityRendererDispatcher.instance.staticPlayerZ = playerZ;
            wrapper.wrapping.renderer.inverseTransform(partialTicks);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } else {
        dispatch.renderTileEntity(tileentityIn, partialTicks, destroyStage);
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos) IOException(java.io.IOException)

Example 28 with PhysicsWrapperEntity

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

the class CallRunnerClient method onGetPositionEyes.

public static Vec3d onGetPositionEyes(Entity entityFor, float partialTicks) {
    Vec3d defaultOutput = entityFor.getPositionEyes(partialTicks);
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getShipFixedOnto(entityFor);
    if (wrapper != null) {
        Vector playerPosition = new Vector(wrapper.wrapping.getLocalPositionForEntity(entityFor));
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.RlToWTransform, playerPosition);
        Vector playerEyes = new Vector(0, entityFor.getEyeHeight(), 0);
        //Remove the original position added for the player's eyes
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWRotation, playerEyes);
        //Add the new rotate player eyes to the position
        playerPosition.add(playerEyes);
        //			System.out.println("test");
        return playerPosition.toVec3d();
    }
    return defaultOutput;
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) Vector(ValkyrienWarfareBase.API.Vector) Vec3d(net.minecraft.util.math.Vec3d)

Example 29 with PhysicsWrapperEntity

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

the class EventsClient method onDrawBlockHighlightEventFirst.

@SubscribeEvent(priority = EventPriority.HIGHEST, receiveCanceled = true)
public void onDrawBlockHighlightEventFirst(DrawBlockHighlightEvent event) {
    BlockPos pos = Minecraft.getMinecraft().objectMouseOver.getBlockPos();
    if (pos != null) {
        PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(Minecraft.getMinecraft().theWorld, pos);
        if (wrapper != null && wrapper.wrapping != null && wrapper.wrapping.renderer != null && wrapper.wrapping.centerCoord != null) {
            //				GL11.glPushMatrix();
            float partialTicks = event.getPartialTicks();
            Entity player = Minecraft.getMinecraft().thePlayer;
            wrapper.wrapping.renderer.setupTranslation(partialTicks);
            Tessellator tessellator = Tessellator.getInstance();
            VertexBuffer vertexbuffer = tessellator.getBuffer();
            double xOff = (player.lastTickPosX + (player.posX - player.lastTickPosX) * (double) partialTicks) - wrapper.wrapping.renderer.offsetPos.getX();
            double yOff = (player.lastTickPosY + (player.posY - player.lastTickPosY) * (double) partialTicks) - wrapper.wrapping.renderer.offsetPos.getY();
            double zOff = (player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * (double) partialTicks) - wrapper.wrapping.renderer.offsetPos.getZ();
            vertexbuffer.xOffset += xOff;
            vertexbuffer.yOffset += yOff;
            vertexbuffer.zOffset += zOff;
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) BlockPos(net.minecraft.util.math.BlockPos) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 30 with PhysicsWrapperEntity

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

the class EventsCommon method onRightClick.

@SubscribeEvent
public void onRightClick(PlayerInteractEvent.RightClickBlock event) {
    if (!event.getWorld().isRemote) {
        PhysicsWrapperEntity physObj = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(event.getWorld(), event.getPos());
        if (physObj != null) {
            //Bucket fix, probably not that important
            if (event.getEntityPlayer().getHeldItem(event.getHand()) != null && event.getEntityPlayer().getHeldItem(event.getHand()).getItem() instanceof ItemBucket) {
                event.setResult(Result.ALLOW);
                event.setCanceled(false);
            }
            if (ValkyrienWarfareMod.runAirshipPermissions && !(physObj.wrapping.creator.equals(event.getEntityPlayer().entityUniqueID.toString()) || physObj.wrapping.allowedUsers.contains(event.getEntityPlayer().entityUniqueID.toString()))) {
                event.getEntityPlayer().addChatMessage(new TextComponentString("You need to be added to the airship to do that!" + (physObj.wrapping.creator == null || physObj.wrapping.creator.trim().isEmpty() ? " Try using \"/airshipSettings claim\"!" : "")));
                event.setCanceled(true);
                return;
            }
        }
    }
}
Also used : PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) ItemBucket(net.minecraft.item.ItemBucket) TextComponentString(net.minecraft.util.text.TextComponentString) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

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