protected virtual MovingObjectPosition GetMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, bool par3) { float f = 1.0F; float f1 = par2EntityPlayer.PrevRotationPitch + (par2EntityPlayer.RotationPitch - par2EntityPlayer.PrevRotationPitch) * f; float f2 = par2EntityPlayer.PrevRotationYaw + (par2EntityPlayer.RotationYaw - par2EntityPlayer.PrevRotationYaw) * f; double d = par2EntityPlayer.PrevPosX + (par2EntityPlayer.PosX - par2EntityPlayer.PrevPosX) * (double)f; double d1 = (par2EntityPlayer.PrevPosY + (par2EntityPlayer.PosY - par2EntityPlayer.PrevPosY) * (double)f + 1.6200000000000001D) - (double)par2EntityPlayer.YOffset; double d2 = par2EntityPlayer.PrevPosZ + (par2EntityPlayer.PosZ - par2EntityPlayer.PrevPosZ) * (double)f; Vec3D vec3d = Vec3D.CreateVector(d, d1, d2); float f3 = MathHelper2.Cos(-f2 * 0.01745329F - (float)Math.PI); float f4 = MathHelper2.Sin(-f2 * 0.01745329F - (float)Math.PI); float f5 = -MathHelper2.Cos(-f1 * 0.01745329F); float f6 = MathHelper2.Sin(-f1 * 0.01745329F); float f7 = f4 * f5; float f8 = f6; float f9 = f3 * f5; double d3 = 5D; Vec3D vec3d1 = vec3d.AddVector((double)f7 * d3, (double)f8 * d3, (double)f9 * d3); MovingObjectPosition movingobjectposition = par1World.RayTraceBlocks_do_do(vec3d, vec3d1, par3, !par3); return(movingobjectposition); }
/// <summary> /// Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer /// </summary> public override ItemStack OnItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { float f = 1.0F; float f1 = par3EntityPlayer.PrevRotationPitch + (par3EntityPlayer.RotationPitch - par3EntityPlayer.PrevRotationPitch) * f; float f2 = par3EntityPlayer.PrevRotationYaw + (par3EntityPlayer.RotationYaw - par3EntityPlayer.PrevRotationYaw) * f; double d = par3EntityPlayer.PrevPosX + (par3EntityPlayer.PosX - par3EntityPlayer.PrevPosX) * (double)f; double d1 = (par3EntityPlayer.PrevPosY + (par3EntityPlayer.PosY - par3EntityPlayer.PrevPosY) * (double)f + 1.6200000000000001D) - (double)par3EntityPlayer.YOffset; double d2 = par3EntityPlayer.PrevPosZ + (par3EntityPlayer.PosZ - par3EntityPlayer.PrevPosZ) * (double)f; Vec3D vec3d = Vec3D.CreateVector(d, d1, d2); float f3 = MathHelper2.Cos(-f2 * 0.01745329F - (float)Math.PI); float f4 = MathHelper2.Sin(-f2 * 0.01745329F - (float)Math.PI); float f5 = -MathHelper2.Cos(-f1 * 0.01745329F); float f6 = MathHelper2.Sin(-f1 * 0.01745329F); float f7 = f4 * f5; float f8 = f6; float f9 = f3 * f5; float d3 = 5; Vec3D vec3d1 = vec3d.AddVector((double)f7 * d3, (double)f8 * d3, (double)f9 * d3); MovingObjectPosition movingobjectposition = par2World.RayTraceBlocks_do(vec3d, vec3d1, true); if (movingobjectposition == null) { return(par1ItemStack); } Vec3D vec3d2 = par3EntityPlayer.GetLook(f); bool flag = false; float f10 = 1.0F; List <Entity> list = par2World.GetEntitiesWithinAABBExcludingEntity(par3EntityPlayer, par3EntityPlayer.BoundingBox.AddCoord((float)vec3d2.XCoord * d3, (float)vec3d2.YCoord * d3, (float)vec3d2.ZCoord * d3).Expand(f10, f10, f10)); for (int l = 0; l < list.Count; l++) { Entity entity = list[l]; if (!entity.CanBeCollidedWith()) { continue; } float f11 = entity.GetCollisionBorderSize(); AxisAlignedBB axisalignedbb = entity.BoundingBox.Expand(f11, f11, f11); if (axisalignedbb.IsVecInside(vec3d)) { flag = true; } } if (flag) { return(par1ItemStack); } if (movingobjectposition.TypeOfHit == EnumMovingObjectType.TILE) { int i = movingobjectposition.BlockX; int j = movingobjectposition.BlockY; int k = movingobjectposition.BlockZ; if (!par2World.IsRemote) { if (par2World.GetBlockId(i, j, k) == Block.Snow.BlockID) { j--; } par2World.SpawnEntityInWorld(new EntityBoat(par2World, (float)i + 0.5F, (float)j + 1.0F, (float)k + 0.5F)); } if (!par3EntityPlayer.Capabilities.IsCreativeMode) { par1ItemStack.StackSize--; } } return(par1ItemStack); }
/// <summary> /// Returns a vector indicating the direction and intensity of fluid flow. /// </summary> private Vec3D GetFlowVector(IBlockAccess par1IBlockAccess, int par2, int par3, int par4) { Vec3D vec3d = Vec3D.CreateVector(0.0F, 0.0F, 0.0F); int i = GetEffectiveFlowDecay(par1IBlockAccess, par2, par3, par4); for (int j = 0; j < 4; j++) { int k = par2; int l = par3; int i1 = par4; if (j == 0) { k--; } if (j == 1) { i1--; } if (j == 2) { k++; } if (j == 3) { i1++; } int j1 = GetEffectiveFlowDecay(par1IBlockAccess, k, l, i1); if (j1 < 0) { if (par1IBlockAccess.GetBlockMaterial(k, l, i1).BlocksMovement()) { continue; } j1 = GetEffectiveFlowDecay(par1IBlockAccess, k, l - 1, i1); if (j1 >= 0) { int k1 = j1 - (i - 8); vec3d = vec3d.AddVector((k - par2) * k1, (l - par3) * k1, (i1 - par4) * k1); } continue; } if (j1 >= 0) { int l1 = j1 - i; vec3d = vec3d.AddVector((k - par2) * l1, (l - par3) * l1, (i1 - par4) * l1); } } if (par1IBlockAccess.GetBlockMetadata(par2, par3, par4) >= 8) { bool flag = false; if (flag || IsBlockSolid(par1IBlockAccess, par2, par3, par4 - 1, 2)) { flag = true; } if (flag || IsBlockSolid(par1IBlockAccess, par2, par3, par4 + 1, 3)) { flag = true; } if (flag || IsBlockSolid(par1IBlockAccess, par2 - 1, par3, par4, 4)) { flag = true; } if (flag || IsBlockSolid(par1IBlockAccess, par2 + 1, par3, par4, 5)) { flag = true; } if (flag || IsBlockSolid(par1IBlockAccess, par2, par3 + 1, par4 - 1, 2)) { flag = true; } if (flag || IsBlockSolid(par1IBlockAccess, par2, par3 + 1, par4 + 1, 3)) { flag = true; } if (flag || IsBlockSolid(par1IBlockAccess, par2 - 1, par3 + 1, par4, 4)) { flag = true; } if (flag || IsBlockSolid(par1IBlockAccess, par2 + 1, par3 + 1, par4, 5)) { flag = true; } if (flag) { vec3d = vec3d.Normalize().AddVector(0.0F, -6D, 0.0F); } } vec3d = vec3d.Normalize(); return(vec3d); }
public virtual void Func_152_a(EntityMinecart par1EntityMinecart, double par2, double par4, double par6, float par8, float par9) { //GL.PushMatrix(); long l = (long)par1EntityMinecart.EntityId * 0x1d66f537L; l = l * l * 0x105cb26d1L + l * 0x181c9L; float f = (((float)(l >> 16 & 7L) + 0.5F) / 8F - 0.5F) * 0.004F; float f1 = (((float)(l >> 20 & 7L) + 0.5F) / 8F - 0.5F) * 0.004F; float f2 = (((float)(l >> 24 & 7L) + 0.5F) / 8F - 0.5F) * 0.004F; //GL.Translate(f, f1, f2); double d = par1EntityMinecart.LastTickPosX + (par1EntityMinecart.PosX - par1EntityMinecart.LastTickPosX) * (double)par9; double d1 = par1EntityMinecart.LastTickPosY + (par1EntityMinecart.PosY - par1EntityMinecart.LastTickPosY) * (double)par9; double d2 = par1EntityMinecart.LastTickPosZ + (par1EntityMinecart.PosZ - par1EntityMinecart.LastTickPosZ) * (double)par9; double d3 = 0.30000001192092896D; Vec3D vec3d = par1EntityMinecart.Func_514_g(d, d1, d2); float f3 = par1EntityMinecart.PrevRotationPitch + (par1EntityMinecart.RotationPitch - par1EntityMinecart.PrevRotationPitch) * par9; if (vec3d != null) { Vec3D vec3d1 = par1EntityMinecart.Func_515_a(d, d1, d2, d3); Vec3D vec3d2 = par1EntityMinecart.Func_515_a(d, d1, d2, -d3); if (vec3d1 == null) { vec3d1 = vec3d; } if (vec3d2 == null) { vec3d2 = vec3d; } par2 += vec3d.XCoord - d; par4 += (vec3d1.YCoord + vec3d2.YCoord) / 2D - d1; par6 += vec3d.ZCoord - d2; Vec3D vec3d3 = vec3d2.AddVector(-vec3d1.XCoord, -vec3d1.YCoord, -vec3d1.ZCoord); if (vec3d3.LengthVector() != 0.0F) { vec3d3 = vec3d3.Normalize(); par8 = (float)((Math.Atan2(vec3d3.ZCoord, vec3d3.XCoord) * 180D) / Math.PI); f3 = (float)(Math.Atan(vec3d3.YCoord) * 73D); } } //GL.Translate((float)par2, (float)par4, (float)par6); //GL.Rotate(180F - par8, 0.0F, 1.0F, 0.0F); //GL.Rotate(-f3, 0.0F, 0.0F, 1.0F); float f4 = (float)par1EntityMinecart.Func_41023_l() - par9; float f5 = (float)par1EntityMinecart.Func_41025_i() - par9; if (f5 < 0.0F) { f5 = 0.0F; } if (f4 > 0.0F) { //GL.Rotate(((MathHelper.Sin(f4) * f4 * f5) / 10F) * (float)par1EntityMinecart.Func_41030_m(), 1.0F, 0.0F, 0.0F); } if (par1EntityMinecart.MinecartType != 0) { LoadTexture("/terrain.png"); float f6 = 0.75F; //GL.Scale(f6, f6, f6); if (par1EntityMinecart.MinecartType == 1) { //GL.Translate(-0.5F, 0.0F, 0.5F); //GL.Rotate(90F, 0.0F, 1.0F, 0.0F); (new RenderBlocks()).RenderBlockAsItem(Block.Chest, 0, par1EntityMinecart.GetBrightness(par9)); //GL.Rotate(-90F, 0.0F, 1.0F, 0.0F); //GL.Translate(0.5F, 0.0F, -0.5F); //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F); } else if (par1EntityMinecart.MinecartType == 2) { //GL.Translate(0.0F, 0.3125F, 0.0F); //GL.Rotate(90F, 0.0F, 1.0F, 0.0F); (new RenderBlocks()).RenderBlockAsItem(Block.StoneOvenIdle, 0, par1EntityMinecart.GetBrightness(par9)); //GL.Rotate(-90F, 0.0F, 1.0F, 0.0F); //GL.Translate(0.0F, -0.3125F, 0.0F); //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F); } //GL.Scale(1.0F / f6, 1.0F / f6, 1.0F / f6); } LoadTexture("/item/cart.png"); //GL.Scale(-1F, -1F, 1.0F); ModelMinecart.Render(par1EntityMinecart, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); //GL.PopMatrix(); }