/// <summary> /// Used to render a player's name above their head /// </summary> protected virtual void RenderName(EntityPlayer par1EntityPlayer, double par2, double par4, double par6) { if (Minecraft.IsGuiEnabled() && par1EntityPlayer != RenderManager.LivingPlayer) { float f = 1.6F; float f1 = 0.01666667F * f; float f2 = par1EntityPlayer.GetDistanceToEntity(RenderManager.LivingPlayer); float f3 = par1EntityPlayer.IsSneaking() ? 32F : 64F; if (f2 < f3) { string s = par1EntityPlayer.Username; if (!par1EntityPlayer.IsSneaking()) { if (par1EntityPlayer.IsPlayerSleeping()) { RenderLivingLabel(par1EntityPlayer, s, par2, par4 - 1.5D, par6, 64); } else { RenderLivingLabel(par1EntityPlayer, s, par2, par4, par6, 64); } } else { FontRenderer fontrenderer = GetFontRendererFromRenderManager(); //GL.PushMatrix(); //GL.Translate((float)par2 + 0.0F, (float)par4 + 2.3F, (float)par6); //GL.Normal3(0.0F, 1.0F, 0.0F); //GL.Rotate(-RenderManager.PlayerViewY, 0.0F, 1.0F, 0.0F); //GL.Rotate(RenderManager.PlayerViewX, 1.0F, 0.0F, 0.0F); //GL.Scale(-f1, -f1, f1); //GL.Disable(EnableCap.Lighting); //GL.Translate(0.0F, 0.25F / f1, 0.0F); //GL.DepthMask(false); //GL.Enable(EnableCap.Blend); //GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); Tessellator tessellator = Tessellator.Instance; //GL.Disable(EnableCap.Texture2D); tessellator.StartDrawingQuads(); int i = fontrenderer.GetStringWidth(s) / 2; tessellator.SetColorRGBA_F(0.0F, 0.0F, 0.0F, 0.25F); tessellator.AddVertex(-i - 1, -1D, 0.0F); tessellator.AddVertex(-i - 1, 8D, 0.0F); tessellator.AddVertex(i + 1, 8D, 0.0F); tessellator.AddVertex(i + 1, -1D, 0.0F); tessellator.Draw(); //GL.Enable(EnableCap.Texture2D); //GL.DepthMask(true); fontrenderer.DrawString(s, -fontrenderer.GetStringWidth(s) / 2, 0, 0x20ffffff); //GL.Enable(EnableCap.Lighting); //GL.Disable(EnableCap.Blend); //GL.Color4(1.0F, 1.0F, 1.0F, 1.0F); //GL.PopMatrix(); } } } }
/// <summary> /// Renders player with sleeping offset if sleeping /// </summary> protected virtual void RenderPlayerSleep(EntityPlayer par1EntityPlayer, double par2, double par4, double par6) { if (par1EntityPlayer.IsEntityAlive() && par1EntityPlayer.IsPlayerSleeping()) { base.RenderLivingAt(par1EntityPlayer, par2 + (double)par1EntityPlayer.Field_22063_x, par4 + (double)par1EntityPlayer.Field_22062_y, par6 + (double)par1EntityPlayer.Field_22061_z); } else { base.RenderLivingAt(par1EntityPlayer, par2, par4, par6); } }
/// <summary> /// Rotates the player if the player is sleeping. This method is called in rotateCorpse. /// </summary> protected virtual void RotatePlayer(EntityPlayer par1EntityPlayer, float par2, float par3, float par4) { if (par1EntityPlayer.IsEntityAlive() && par1EntityPlayer.IsPlayerSleeping()) { //GL.Rotate(par1EntityPlayer.GetBedOrientationInDegrees(), 0.0F, 1.0F, 0.0F); //GL.Rotate(GetDeathMaxRotation(par1EntityPlayer), 0.0F, 0.0F, 1.0F); //GL.Rotate(270F, 0.0F, 1.0F, 0.0F); } else { base.RotateCorpse(par1EntityPlayer, par2, par3, par4); } }
/// <summary> /// Called upon block activation (left or right click on the block.). The three integers represent x,y,z of the /// block. /// </summary> public override bool BlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) { if (par1World.IsRemote) { return(true); } int i = par1World.GetBlockMetadata(par2, par3, par4); if (!IsBlockFootOfBed(i)) { int j = GetDirection(i); par2 += HeadBlockToFootBlockMap[j][0]; par4 += HeadBlockToFootBlockMap[j][1]; if (par1World.GetBlockId(par2, par3, par4) != BlockID) { return(true); } i = par1World.GetBlockMetadata(par2, par3, par4); } if (!par1World.WorldProvider.CanRespawnHere()) { double d = (double)par2 + 0.5D; double d1 = (double)par3 + 0.5D; double d2 = (double)par4 + 0.5D; par1World.SetBlockWithNotify(par2, par3, par4, 0); int k = GetDirection(i); par2 += HeadBlockToFootBlockMap[k][0]; par4 += HeadBlockToFootBlockMap[k][1]; if (par1World.GetBlockId(par2, par3, par4) == BlockID) { par1World.SetBlockWithNotify(par2, par3, par4, 0); d = (d + (double)par2 + 0.5D) / 2D; d1 = (d1 + (double)par3 + 0.5D) / 2D; d2 = (d2 + (double)par4 + 0.5D) / 2D; } par1World.NewExplosion(null, (float)par2 + 0.5F, (float)par3 + 0.5F, (float)par4 + 0.5F, 5F, true); return(true); } if (IsBedOccupied(i)) { EntityPlayer entityplayer = null; IEnumerator <EntityPlayer> iterator = par1World.PlayerEntities.GetEnumerator(); do { if (!iterator.MoveNext()) { break; } EntityPlayer entityplayer1 = iterator.Current; if (entityplayer1.IsPlayerSleeping()) { ChunkCoordinates chunkcoordinates = entityplayer1.PlayerLocation; if (chunkcoordinates.PosX == par2 && chunkcoordinates.PosY == par3 && chunkcoordinates.PosZ == par4) { entityplayer = entityplayer1; } } }while (true); if (entityplayer == null) { SetBedOccupied(par1World, par2, par3, par4, false); } else { par5EntityPlayer.AddChatMessage("tile.bed.occupied"); return(true); } } EnumStatus enumstatus = par5EntityPlayer.SleepInBedAt(par2, par3, par4); if (enumstatus == EnumStatus.OK) { SetBedOccupied(par1World, par2, par3, par4, true); return(true); } if (enumstatus == EnumStatus.NOT_POSSIBLE_NOW) { par5EntityPlayer.AddChatMessage("tile.bed.noSleep"); } else if (enumstatus == EnumStatus.NOT_SAFE) { par5EntityPlayer.AddChatMessage("tile.bed.notSafe"); } return(true); }