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) {
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);

View File

@ -121,9 +121,9 @@ namespace MCGalaxy {
}
/// <summary> Gives distance (in half-pixel world units) from feet to camera height </summary>
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.

View File

@ -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;