From a4200717498580eaa4fab80e6f9b04eef35daea5 Mon Sep 17 00:00:00 2001 From: Goodlyay Date: Wed, 4 Mar 2020 04:20:53 -0800 Subject: [PATCH] Make CalcEyeHeight take Y scale int account Make LevelInfo.Check public, so it can be used in plugins --- MCGalaxy/Bots/Instructions/HunterInstructions.cs | 4 ++-- MCGalaxy/Entity/ModelInfo.cs | 6 +++--- MCGalaxy/Levels/LevelInfo.cs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/MCGalaxy/Bots/Instructions/HunterInstructions.cs b/MCGalaxy/Bots/Instructions/HunterInstructions.cs index 75da722a4..e307d050f 100644 --- a/MCGalaxy/Bots/Instructions/HunterInstructions.cs +++ b/MCGalaxy/Bots/Instructions/HunterInstructions.cs @@ -155,8 +155,8 @@ namespace MCGalaxy.Bots { } static void FaceTowards(PlayerBot bot, Player p) { - int srcHeight = ModelInfo.CalcEyeHeight(p.Model); - int dstHeight = ModelInfo.CalcEyeHeight(bot.Model); + int srcHeight = ModelInfo.CalcEyeHeight(p); + int dstHeight = ModelInfo.CalcEyeHeight(bot); int dx = p.Pos.X - bot.Pos.X, dy = (p.Pos.Y + srcHeight) - (bot.Pos.Y + dstHeight), dz = p.Pos.Z - bot.Pos.Z; Vec3F32 dir = new Vec3F32(dx, dy, dz); diff --git a/MCGalaxy/Entity/ModelInfo.cs b/MCGalaxy/Entity/ModelInfo.cs index ac1f512ed..1c1e3c939 100644 --- a/MCGalaxy/Entity/ModelInfo.cs +++ b/MCGalaxy/Entity/ModelInfo.cs @@ -121,9 +121,9 @@ namespace MCGalaxy { } /// Gives distance (in half-pixel world units) from feet to camera height - public static int CalcEyeHeight(string model) { - float scale = GetRawScale(model); - model = GetRawModel(model); + public static int CalcEyeHeight(Entity entity) { + float scale = (entity.ScaleY == 0) ? GetRawScale(entity.Model) : entity.ScaleY; + string model = GetRawModel(entity.Model); BlockID raw; if (BlockID.TryParse(model, out raw) && raw <= Block.MaxRaw) return 16; //lazily return middle of full block if it thinks it's a block ID. diff --git a/MCGalaxy/Levels/LevelInfo.cs b/MCGalaxy/Levels/LevelInfo.cs index 2c54e622a..ceddb0d55 100644 --- a/MCGalaxy/Levels/LevelInfo.cs +++ b/MCGalaxy/Levels/LevelInfo.cs @@ -134,7 +134,7 @@ namespace MCGalaxy { return true; } - internal static bool Check(Player p, LevelPermission plRank, Level lvl, string action) { + public static bool Check(Player p, LevelPermission plRank, Level lvl, string action) { if (p.IsConsole) return true; if (!lvl.VisitAccess.CheckDetailed(p, plRank) || !lvl.BuildAccess.CheckDetailed(p, plRank)) { p.Message("Hence, you cannot {0}.", action); return false;