Skip to content

Commit 28f5428

Browse files
committed
Update entity model sizes
/ent and /model now have specific min/max models sizes based on player rank and if it is being applied to an entity/bot or not.
1 parent 77362c7 commit 28f5428

2 files changed

Lines changed: 23 additions & 9 deletions

File tree

fCraft/Commands/CpeCommands.cs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ private static void EntityHandler(Player player, CommandReader cmd) {
138138
string requestedModel = "humanoid";
139139
if (cmd.HasNext) {
140140
requestedModel = cmd.Next().ToLower();
141-
requestedModel = ParseModel(player, requestedModel);
141+
requestedModel = ParseModel(player, requestedModel, true);
142142
if (requestedModel == null) {
143143
player.Message(
144144
"That wasn't a valid entity model! Valid models are chibi, chicken, creeper, giant, human, pig, sheep, skeleton, spider, zombie, or any block ID/Name.");
@@ -174,7 +174,7 @@ private static void EntityHandler(Player player, CommandReader cmd) {
174174
player.Message("Usage is /Ent model <bot> <model>. " + validModels);
175175
break;
176176
}
177-
model = ParseModel(player, model);
177+
model = ParseModel(player, model, true);
178178
if (model == null) {
179179
player.Message("That wasn't a valid entity model! " + validModels);
180180
break;
@@ -332,7 +332,7 @@ static void SetModel(Player player, CommandReader cmd, string prefix,
332332
return;
333333
}
334334

335-
model = ParseModel(player, model);
335+
model = ParseModel(player, model, false);
336336
if (model == null) {
337337
player.Message("Model not valid, see &H/Help {0}Model&S.", prefix.TrimEnd());
338338
return;
@@ -354,19 +354,33 @@ static void SetModel(Player player, CommandReader cmd, string prefix,
354354
setter(target, model);
355355
}
356356

357-
internal static string ParseModel(Player player, string model) {
357+
internal static string ParseModel(Player player, string model, bool isBot) {
358358
model = model ?? "humanoid";
359-
float scale = 0.0f;
360359
string scalestr = "";
361360
int sepIndex = model.IndexOf('|');
362361

363362
if (sepIndex >= 0) {
364363
scalestr = model.Substring(sepIndex + 1);
365364
model = model.Substring(0, sepIndex);
366365
}
367-
if (float.TryParse(scalestr, out scale)) {
368-
if (scale < 0.25f) scale = 0.25f;
369-
if (scale > 3f) scale = 3f;
366+
if (float.TryParse(scalestr, out float scale)) {
367+
if (player.Info.Rank == RankManager.HighestRank) {
368+
if (isBot) { //Owner Bot scale between 0.01 and 128
369+
if (scale < 0.01f) scale = 0.01f;
370+
if (scale > 128f) scale = 128f;
371+
} else {//Owner Self scale between 0.1 and 10
372+
if (scale < 0.1f) scale = 0.1f;
373+
if (scale > 10f) scale = 10f;
374+
}
375+
} else {
376+
if (isBot) {//Player Bot scale between 0.1 and 10
377+
if (scale < 0.1f) scale = 0.1f;
378+
if (scale > 10f) scale = 10f;
379+
} else {//Player Self scale between 0.25 and 2
380+
if (scale < 0.25f) scale = 0.25f;
381+
if (scale > 2f) scale = 2f;
382+
}
383+
}
370384
}
371385

372386
byte blockId;

fCraft/World/Entity.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public static void OldLoad() {
226226
if (Path.GetExtension(filename) != ".txt") continue;
227227

228228
string[] entityData = File.ReadAllLines(filename);
229-
entity.Model = CpeCommands.ParseModel(Player.Console, entityData[2]) ?? "humanoid";
229+
entity.Model = CpeCommands.ParseModel(Player.Console, entityData[2], true) ?? "humanoid";
230230
entity.World = entityData[4];
231231

232232
sbyte id;

0 commit comments

Comments
 (0)