1
0

Adding more customize options to mob spawners and improving the way to look for surrounding entities (#4955)

* added nearly any customize option

* fixed unnecessary diff
added comments

* removed unnecessary const qualifier

* fixed build

* changed to ForEachEntityInBox

* added docs

* updated lua api description

* checkstyle

* added changes suggested by @peterbell10
And now the player may break the server by setting ridiculous ranges

* updated docs
changed cast to static cast

* fixed clang

* fixed clang on WSSAnvil.cpp

Co-authored-by: 12xx12 <12xx12100@gmail.com>
This commit is contained in:
12xx12
2020-10-10 21:31:44 +02:00
committed by GitHub
parent b0b1ccddd1
commit c0711407e9
5 changed files with 241 additions and 87 deletions

View File

@@ -1349,13 +1349,55 @@ OwnedBlockEntity cWSSAnvil::LoadMobSpawnerFromNBT(const cParsedNBT & a_NBT, int
}
}
// Load delay:
int Delay = a_NBT.FindChildByName(a_TagIdx, "Delay");
if ((Delay >= 0) && (a_NBT.GetType(Delay) == TAG_Short))
// Load spawn count:
int CurrentLine = a_NBT.FindChildByName(a_TagIdx, "SpawnCount");
if ((CurrentLine >= 0) && (a_NBT.GetType(CurrentLine) == TAG_Short))
{
MobSpawner->SetSpawnDelay(a_NBT.GetShort(Delay));
MobSpawner->SetSpawnCount(a_NBT.GetShort(CurrentLine));
}
// Load spawn range:
CurrentLine = a_NBT.FindChildByName(a_TagIdx, "SpawnRange");
if ((CurrentLine >= 0) && (a_NBT.GetType(CurrentLine) == TAG_Short))
{
MobSpawner->SetSpawnRange(a_NBT.GetShort(CurrentLine));
}
// Load delay:
CurrentLine = a_NBT.FindChildByName(a_TagIdx, "Delay");
if ((CurrentLine >= 0) && (a_NBT.GetType(CurrentLine) == TAG_Short))
{
MobSpawner->SetSpawnDelay(a_NBT.GetShort(CurrentLine));
}
// Load delay range:
CurrentLine = a_NBT.FindChildByName(a_TagIdx, "MinSpawnDelay");
if ((CurrentLine >= 0) && (a_NBT.GetType(CurrentLine) == TAG_Short))
{
MobSpawner->SetMinSpawnDelay(a_NBT.GetShort(CurrentLine));
}
CurrentLine = a_NBT.FindChildByName(a_TagIdx, "MaxSpawnDelay");
if ((CurrentLine >= 0) && (a_NBT.GetType(CurrentLine) == TAG_Short))
{
MobSpawner->SetMaxSpawnDelay(a_NBT.GetShort(CurrentLine));
}
// Load MaxNearbyEntities:
CurrentLine = a_NBT.FindChildByName(a_TagIdx, "MaxNearbyEntities");
if ((CurrentLine >= 0) && (a_NBT.GetType(CurrentLine) == TAG_Short))
{
MobSpawner->SetMaxNearbyEntities(a_NBT.GetShort(CurrentLine));
}
// Load RequiredPlayerRange:
CurrentLine = a_NBT.FindChildByName(a_TagIdx, "RequiredPlayerRange");
if ((CurrentLine >= 0) && (a_NBT.GetType(CurrentLine) == TAG_Short))
{
MobSpawner->SetRequiredPlayerRange(a_NBT.GetShort(CurrentLine));
}
return MobSpawner;
}