Make CalcEyeHeight take Y scale int account

Make LevelInfo.Check public, so it can be used in plugins
This commit is contained in:
Goodlyay 2020-03-04 04:20:53 -08:00
parent d8b8fce737
commit a420071749
3 changed files with 6 additions and 6 deletions

View File

@ -155,8 +155,8 @@ namespace MCGalaxy.Bots {
} }
static void FaceTowards(PlayerBot bot, Player p) { static void FaceTowards(PlayerBot bot, Player p) {
int srcHeight = ModelInfo.CalcEyeHeight(p.Model); int srcHeight = ModelInfo.CalcEyeHeight(p);
int dstHeight = ModelInfo.CalcEyeHeight(bot.Model); 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; 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); Vec3F32 dir = new Vec3F32(dx, dy, dz);

View File

@ -121,9 +121,9 @@ namespace MCGalaxy {
} }
/// <summary> Gives distance (in half-pixel world units) from feet to camera height </summary> /// <summary> Gives distance (in half-pixel world units) from feet to camera height </summary>
public static int CalcEyeHeight(string model) { public static int CalcEyeHeight(Entity entity) {
float scale = GetRawScale(model); float scale = (entity.ScaleY == 0) ? GetRawScale(entity.Model) : entity.ScaleY;
model = GetRawModel(model); string model = GetRawModel(entity.Model);
BlockID raw; 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. 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.

View File

@ -134,7 +134,7 @@ namespace MCGalaxy {
return true; 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 (p.IsConsole) return true;
if (!lvl.VisitAccess.CheckDetailed(p, plRank) || !lvl.BuildAccess.CheckDetailed(p, plRank)) { if (!lvl.VisitAccess.CheckDetailed(p, plRank) || !lvl.BuildAccess.CheckDetailed(p, plRank)) {
p.Message("Hence, you cannot {0}.", action); return false; p.Message("Hence, you cannot {0}.", action); return false;