Skip to content

Commit

Permalink
Added better soulsand rims
Browse files Browse the repository at this point in the history
As a finisher called SoulsandRims
  • Loading branch information
NiLSPACE committed Dec 1, 2014
1 parent 36500f8 commit fa4a85c
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 12 deletions.
12 changes: 1 addition & 11 deletions src/Generating/CompoGen.cpp
Expand Up @@ -290,17 +290,7 @@ void cCompoGenNether::ComposeTerrain(cChunkDesc & a_ChunkDesc, const cChunkDesc:
BLOCKTYPE Block = E_BLOCK_AIR;
if (Val < m_Threshold) // Don't calculate if the block should be Netherrack or Soulsand when it's already decided that it's air.
{
NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(BaseX + x)) / 8;
NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(BaseZ + z)) / 8;
NOISE_DATATYPE CompBlock = m_Noise1.CubicNoise3D(NoiseX, (float) (y + Segment) / 2, NoiseY);
if (CompBlock < -0.5)
{
Block = E_BLOCK_SOULSAND;
}
else
{
Block = E_BLOCK_NETHERRACK;
}
Block = E_BLOCK_NETHERRACK;
}
a_ChunkDesc.SetBlockType(x, y + Segment, z, Block);
}
Expand Down
4 changes: 4 additions & 0 deletions src/Generating/ComposableGenerator.cpp
Expand Up @@ -570,6 +570,10 @@ void cComposableGenerator::InitFinishGens(cIniFile & a_IniFile)
GridSize, MaxOffset
)));
}
else if (NoCaseCompare(*itr, "SoulsandRims") == 0)
{
m_FinishGens.push_back(cFinishGenPtr(new cFinishGenSoulsandRims(Seed)));
}
else if (NoCaseCompare(*itr, "Snow") == 0)
{
m_FinishGens.push_back(cFinishGenPtr(new cFinishGenSnow));
Expand Down
82 changes: 82 additions & 0 deletions src/Generating/FinishGen.cpp
Expand Up @@ -391,6 +391,88 @@ void cFinishGenSprinkleFoliage::GenFinish(cChunkDesc & a_ChunkDesc)



////////////////////////////////////////////////////////////////////////////////
// cFinishGenSoulsandRims

void cFinishGenSoulsandRims::GenFinish(cChunkDesc & a_ChunkDesc)
{
int ChunkX = a_ChunkDesc.GetChunkX() * cChunkDef::Width;
int ChunkZ = a_ChunkDesc.GetChunkZ() * cChunkDef::Width;
HEIGHTTYPE MaxHeight = a_ChunkDesc.GetMaxHeight();

for (int x = 0; x < 16; x++)
{
int xx = ChunkX + x;
for (int z = 0; z < 16; z++)
{
int zz = ChunkZ + z;

// Place soulsand rims when netherrack gets thin
for (int y = 2; y < MaxHeight - 2; y++)
{
// The current block is air. Let's bail ut.
BLOCKTYPE Block = a_ChunkDesc.GetBlockType(x, y, z);
if (Block == E_BLOCK_AIR)
{
continue;
}

// Check how many blocks there are above the current block. Don't go higher than 2 blocks, because we already bail out if that's the case.
int NumBlocksAbove = 0;
for (int I = y + 1; I <= y + 2; I++)
{
if (a_ChunkDesc.GetBlockType(x, I, z) != E_BLOCK_AIR)
{
NumBlocksAbove++;
}
else
{
break;
}
}

// There are too many blocks above the current block.
if (NumBlocksAbove == 2)
{
continue;
}

// Check how many blocks there below the current block. Don't go lower than 2 blocks, because we already bail out if that's the case.
int NumBlocksBelow = 0;
for (int I = y - 1; I >= y - 2; I--)
{
if (a_ChunkDesc.GetBlockType(x, I, z) != E_BLOCK_AIR)
{
NumBlocksBelow++;
}
else
{
break;
}
}

// There are too many blocks below the current block
if (NumBlocksBelow == 2)
{
continue;
}

NOISE_DATATYPE NoiseX = ((NOISE_DATATYPE)(xx)) / 32;
NOISE_DATATYPE NoiseY = ((NOISE_DATATYPE)(zz)) / 32;
NOISE_DATATYPE CompBlock = m_Noise.CubicNoise3D(NoiseX, (float) (y) / 4, NoiseY);
if (CompBlock < 0)
{
a_ChunkDesc.SetBlockType(x, y, z, E_BLOCK_SOULSAND);
}
}
}
}
}





////////////////////////////////////////////////////////////////////////////////
// cFinishGenSnow:

Expand Down
19 changes: 19 additions & 0 deletions src/Generating/FinishGen.h
Expand Up @@ -117,6 +117,25 @@ class cFinishGenTallGrass :



class cFinishGenSoulsandRims :
public cFinishGen
{
public:
cFinishGenSoulsandRims(int a_Seed) :
m_Noise(a_Seed)
{
}

protected:
cNoise m_Noise;

virtual void GenFinish(cChunkDesc & a_ChunkDesc) override;
} ;





class cFinishGenSprinkleFoliage :
public cFinishGen
{
Expand Down
2 changes: 1 addition & 1 deletion src/World.cpp
Expand Up @@ -759,7 +759,7 @@ void cWorld::InitialiseGeneratorDefaults(cIniFile & a_IniFile)
a_IniFile.GetValueSet("Generator", "HeightGen", "Flat");
a_IniFile.GetValueSet("Generator", "FlatHeight", "128");
a_IniFile.GetValueSet("Generator", "CompositionGen", "Nether");
a_IniFile.GetValueSet("Generator", "Finishers", "WormNestCaves, BottomLava, LavaSprings, NetherClumpFoliage, NetherForts, PreSimulator");
a_IniFile.GetValueSet("Generator", "Finishers", "SoulsandRims, WormNestCaves, BottomLava, LavaSprings, NetherClumpFoliage, NetherForts, PreSimulator");
a_IniFile.GetValueSet("Generator", "BottomLavaHeight", "30");
break;
}
Expand Down

4 comments on commit fa4a85c

@NiLSPACE
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noooo! I forgot to put it in a branch!

@madmaxoft
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's okay, the code was more or less reviewed already in the PR.

Still, I think you should change your I loop into two if statements.

@NiLSPACE
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a single if work as well?

if (
   ((a_ChunkDesc.GetBlockType(x, y + 1, z) != E_BLOCK_AIR) &&
   ( a_ChunkDesc.GetBlockType(x, y + 2, z) != E_BLOCK_AIR)) ||
   ((a_ChunkDesc.GetBlockType(x, y - 1, z) != E_BLOCK_AIR) &&
   ( a_ChunkDesc.GetBlockType(x, y - 2, z) != E_BLOCK_AIR))
)
{
   continue;
}

@madmaxoft
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually a single if with a single condition would do it - simply iterate through the entire Y range, and remember the last change from air to netherrack and from netherrack to air. If such the netherrack -> air change is less than 4 blocks from the air -> netherrack change, you've hit your point. Or am I reading the code wrong and it does something different than replacing netherrack less than 4 blocks thick with a pattern of soulsand?

Please sign in to comment.