feat: remove bonus chests
This commit is contained in:
1 parent
7272b62d38
commit
ca003f1afa
30 files changed
+8
-246
No files matched your search
@@ -119,13 +119,6 @@ ServerLevel::ServerLevel(MinecraftServer *server, shared_ptr<LevelStorage>levelS
|
||||
initializeLevel(levelSettings);
|
||||
levelData->setInitialized(true);
|
||||
}
|
||||
else if ( (dimension==0) && levelData->getSpawnBonusChest() ) // 4J-JEV, still would like bonus chests to respawn.
|
||||
{
|
||||
// 4J - added isFindingSpawn as we want any chunks we are looking in here for suitable locations for the bonus chest to actually create those chunks rather than just get emptychunks if they aren't loaded
|
||||
isFindingSpawn = true;
|
||||
generateBonusItemsNearSpawn();
|
||||
isFindingSpawn = false;
|
||||
}
|
||||
|
||||
// 4J - added initialisers
|
||||
// 4J Stu - Allowing spawn edit for our game, and consider a better solution for the possible griefing
|
||||
@@ -788,58 +781,9 @@ void ServerLevel::setInitialSpawn(LevelSettings *levelSettings)
|
||||
}
|
||||
|
||||
levelData->setSpawn(xSpawn, ySpawn, zSpawn);
|
||||
if (levelSettings->hasStartingBonusItems())
|
||||
{
|
||||
generateBonusItemsNearSpawn();
|
||||
}
|
||||
isFindingSpawn = false;
|
||||
}
|
||||
|
||||
// 4J - brought forward from 1.3.2
|
||||
void ServerLevel::generateBonusItemsNearSpawn()
|
||||
{
|
||||
// once we've found the initial spawn, try to find a location for the
|
||||
// starting bonus chest
|
||||
// 4J - added - scan the spawn area first to see if there's already a chest near here
|
||||
|
||||
static const int r = 20;
|
||||
int xs = levelData->getXSpawn();
|
||||
int zs = levelData->getZSpawn();
|
||||
for( int xx = -r; xx <= r; xx++ )
|
||||
for( int zz = -r; zz <= r; zz++ )
|
||||
{
|
||||
int x = xx + xs;
|
||||
int z = zz + zs;
|
||||
int y = getTopSolidBlock( x, z ) - 1;
|
||||
|
||||
if( getTile( x, y, z ) == Tile::chest_Id )
|
||||
{
|
||||
shared_ptr<ChestTileEntity> chest = dynamic_pointer_cast<ChestTileEntity>(getTileEntity(x, y, z));
|
||||
if (chest != NULL)
|
||||
{
|
||||
if( chest->isBonusChest )
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BonusChestFeature *feature = new BonusChestFeature(RANDOM_BONUS_ITEMS, 16);
|
||||
for (int attempt = 0; attempt < 16; attempt++)
|
||||
{
|
||||
int x = levelData->getXSpawn() + random->nextInt(6) - random->nextInt(6);
|
||||
int z = levelData->getZSpawn() + random->nextInt(6) - random->nextInt(6);
|
||||
int y = getTopSolidBlock(x, z) + 1;
|
||||
|
||||
if (feature->place(this, random, x, y, z, (attempt == 15) ))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete feature;
|
||||
}
|
||||
|
||||
Pos *ServerLevel::getDimensionSpecificSpawn()
|
||||
{
|
||||
return dimension->getSpawnPos();
|
||||
|
||||
Reference in new issue
Block a user