Don't restrict model bot axis scaling in /model, fix giant model scaling

This commit is contained in:
UnknownShadow200 2019-10-19 11:14:37 +11:00
parent 4784fe297b
commit 6070e77865
10 changed files with 16 additions and 11 deletions

View File

@ -45,7 +45,7 @@ namespace MCGalaxy.Bots {
PlayerBot bot = new PlayerBot(data.Name, lvl);
data.ApplyTo(bot);
bot.SetModel(bot.Model, lvl);
bot.SetModel(bot.Model);
LoadAi(data, bot);
PlayerBot.Add(bot, false);
}

View File

@ -52,7 +52,7 @@ namespace MCGalaxy {
name = n; DisplayName = n; SkinName = n;
color = "&1";
level = lvl;
SetModel(Model, lvl);
SetModel(Model);
hasExtPositions = true;
BotsScheduler.Activate();
}
@ -60,6 +60,7 @@ namespace MCGalaxy {
public override bool CanSeeEntity(Entity other) { return true; }
public override byte EntityID { get { return id; } }
public override Level Level { get { return level; } }
public override float MaxScale { get { return float.MaxValue; } }
public bool EditableBy(Player p, string attemptedAction = "modify") {
if (CanEditAny(p)) { return true; }

View File

@ -194,7 +194,7 @@ namespace MCGalaxy.Commands.Bots {
props.FromBot(bot);
props.ApplyTo(clone);
clone.Owner = p.name;
clone.SetModel(clone.Model, p.level);
clone.SetModel(clone.Model);
BotsFile.LoadAi(props, clone);
// Preserve custom name tag
if (bot.DisplayName == bot.name) clone.DisplayName = newName;

View File

@ -103,7 +103,7 @@ namespace MCGalaxy.Commands.CPE {
static string ParseModelScale(Player dst, Entity entity, string model, string argName, ref float value) {
string[] bits = model.SplitSpaces();
CommandParser.GetReal(dst, bits[1], argName, ref value, 0, 3);
CommandParser.GetReal(dst, bits[1], argName, ref value, 0, entity.MaxScale);
return entity.Model;
}

View File

@ -45,7 +45,7 @@ namespace MCGalaxy.Core {
p.prevMsg = "";
p.showMBs = false;
p.showPortals = false;
p.SetModel(p.Model, level); // in case had been using a level-only custom block for their model
p.SetModel(p.Model); // in case had been using a level-only custom block for their model
p.ZoneIn = null;
OnChangedZoneEvent.Call(p);

View File

@ -182,7 +182,7 @@ namespace MCGalaxy {
public static void UpdateModel(Entity entity, string model) {
Player[] players = PlayerInfo.Online.Items;
Level lvl = entity.Level;
entity.SetModel(model, lvl);
entity.SetModel(model);
foreach (Player pl in players) {
if (pl.level != lvl || !pl.Supports(CpeExt.ChangeModel)) continue;

View File

@ -50,9 +50,9 @@ namespace MCGalaxy {
Pos = pos; lastPos = pos;
}
public void SetModel(string model, Level lvl) {
Model = model;
ModelBB = AABB.ModelAABB(this, lvl);
public void SetModel(string model) {
Model = model;
ModelBB = AABB.ModelAABB(this, Level);
}
public void SetYawPitch(byte yaw, byte pitch) {
@ -64,6 +64,7 @@ namespace MCGalaxy {
public abstract bool CanSeeEntity(Entity other);
public abstract byte EntityID { get; }
public abstract Level Level { get; }
public abstract float MaxScale { get; }
protected virtual void OnSetPos() { }

View File

@ -211,7 +211,7 @@ namespace MCGalaxy {
byte.TryParse(bits[1], out rot.RotZ);
Rot = rot;
}
SetModel(Model, level);
SetModel(Model);
}
void GetPlayerStats() {

View File

@ -71,6 +71,7 @@ namespace MCGalaxy {
public override byte EntityID { get { return id; } }
public override Level Level { get { return level; } }
public override float MaxScale { get { return 3; } }
public override bool CanSeeEntity(Entity other) {
Player target = other as Player;

View File

@ -121,7 +121,6 @@ namespace MCGalaxy.Maths {
}
internal static float GetScaleFrom(ref string model, bool unlimitedScaleAllowed = false) {
if (model.CaselessEq("giant")) { return 2; }
int sep = model.IndexOf('|');
string scaleStr = sep == -1 ? null : model.Substring(sep + 1);
model = sep == -1 ? model : model.Substring(0, sep);
@ -130,6 +129,9 @@ namespace MCGalaxy.Maths {
if (!Utils.TryParseSingle(scaleStr, out scale)) scale = 1.0f;
if (scale < 0.01f) scale = 0.01f;
// backwards compatibility
if (model.CaselessEq("giant")) scale *= 2;
float max = unlimitedScaleAllowed ? int.MaxValue : (model.CaselessEq("chibi") ? 3 : 2);
return Math.Min(scale, max);
}