mirror of
https://github.com/GabsPuNs/Project-Zenith-Main.git
synced 2026-06-12 04:52:02 +00:00
Fix all the Cherry Pick Commits from TU24 to TU30
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
#include "Facing.h"
|
||||
#include "DoorItem.h"
|
||||
#include "EnchantedBookItem.h"
|
||||
#include "StringHelpers.h"
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -120,9 +121,7 @@ StructurePiece* StructurePiece::findCollisionPiece( list< StructurePiece* > *pie
|
||||
for (auto& piece : *pieces)
|
||||
{
|
||||
if ( piece && piece->getBoundingBox() && piece->getBoundingBox()->intersects( box ) )
|
||||
{
|
||||
return piece;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
@@ -149,14 +148,11 @@ bool StructurePiece::edgesLiquid( Level* level, BoundingBox* chunkBB )
|
||||
{
|
||||
int tile = level->getTile( x, y0, z );
|
||||
if ( tile > 0 && Tile::tiles[tile]->material->isLiquid() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
tile = level->getTile( x, y1, z );
|
||||
if ( tile > 0 && Tile::tiles[tile]->material->isLiquid() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// north and south
|
||||
@@ -166,14 +162,11 @@ bool StructurePiece::edgesLiquid( Level* level, BoundingBox* chunkBB )
|
||||
{
|
||||
int tile = level->getTile( x, y, z0 );
|
||||
if ( tile > 0 && Tile::tiles[tile]->material->isLiquid() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
tile = level->getTile( x, y, z1 );
|
||||
if ( tile > 0 && Tile::tiles[tile]->material->isLiquid() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// east and west
|
||||
@@ -183,14 +176,11 @@ bool StructurePiece::edgesLiquid( Level* level, BoundingBox* chunkBB )
|
||||
{
|
||||
int tile = level->getTile( x0, y, z );
|
||||
if ( tile > 0 && Tile::tiles[tile]->material->isLiquid() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
tile = level->getTile( x1, y, z );
|
||||
if ( tile > 0 && Tile::tiles[tile]->material->isLiquid() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -216,9 +206,8 @@ int StructurePiece::getWorldX( int x, int z )
|
||||
int StructurePiece::getWorldY( int y )
|
||||
{
|
||||
if ( orientation == Direction::UNDEFINED )
|
||||
{
|
||||
return y;
|
||||
}
|
||||
|
||||
return y + boundingBox->y0;
|
||||
}
|
||||
|
||||
@@ -245,13 +234,9 @@ int StructurePiece::getOrientationData( int tile, int data )
|
||||
if ( orientation == Direction::WEST || orientation == Direction::EAST )
|
||||
{
|
||||
if ( data == BaseRailTile::DIR_FLAT_X )
|
||||
{
|
||||
return BaseRailTile::DIR_FLAT_Z;
|
||||
}
|
||||
else
|
||||
{
|
||||
return BaseRailTile::DIR_FLAT_X;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( tile == Tile::door_wood_Id || tile == Tile::door_iron_Id )
|
||||
@@ -259,13 +244,9 @@ int StructurePiece::getOrientationData( int tile, int data )
|
||||
if ( orientation == Direction::SOUTH )
|
||||
{
|
||||
if ( data == 0 )
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if ( data == 2 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if ( orientation == Direction::WEST )
|
||||
{
|
||||
@@ -289,51 +270,31 @@ int StructurePiece::getOrientationData( int tile, int data )
|
||||
if ( orientation == Direction::SOUTH )
|
||||
{
|
||||
if ( data == 2 )
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if ( data == 3 )
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
else if ( orientation == Direction::WEST )
|
||||
{
|
||||
if ( data == 0 )
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if ( data == 1 )
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if ( data == 2 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if ( data == 3 )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if ( orientation == Direction::EAST )
|
||||
{
|
||||
if ( data == 0 )
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if ( data == 1 )
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if ( data == 2 )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if ( data == 3 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( tile == Tile::ladder->id )
|
||||
@@ -341,104 +302,63 @@ int StructurePiece::getOrientationData( int tile, int data )
|
||||
if ( orientation == Direction::SOUTH )
|
||||
{
|
||||
if ( data == Facing::NORTH )
|
||||
{
|
||||
return Facing::SOUTH;
|
||||
}
|
||||
if ( data == Facing::SOUTH )
|
||||
{
|
||||
return Facing::NORTH;
|
||||
}
|
||||
}
|
||||
else if ( orientation == Direction::WEST )
|
||||
{
|
||||
if ( data == Facing::NORTH )
|
||||
{
|
||||
return Facing::WEST;
|
||||
}
|
||||
if ( data == Facing::SOUTH )
|
||||
{
|
||||
return Facing::EAST;
|
||||
}
|
||||
if ( data == Facing::WEST )
|
||||
{
|
||||
return Facing::NORTH;
|
||||
}
|
||||
if ( data == Facing::EAST )
|
||||
{
|
||||
return Facing::SOUTH;
|
||||
}
|
||||
}
|
||||
else if ( orientation == Direction::EAST )
|
||||
{
|
||||
if ( data == Facing::NORTH )
|
||||
{
|
||||
return Facing::EAST;
|
||||
}
|
||||
if ( data == Facing::SOUTH )
|
||||
{
|
||||
return Facing::WEST;
|
||||
}
|
||||
if ( data == Facing::WEST )
|
||||
{
|
||||
return Facing::NORTH;
|
||||
}
|
||||
if ( data == Facing::EAST )
|
||||
{
|
||||
return Facing::SOUTH;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if ( tile == Tile::button->id )
|
||||
{
|
||||
if ( orientation == Direction::SOUTH )
|
||||
{
|
||||
if ( data == 3 )
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
if ( data == 4 )
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
else if ( orientation == Direction::WEST )
|
||||
{
|
||||
if ( data == 3 )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if ( data == 4 )
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if ( data == 2 )
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if ( data == 1 )
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
else if ( orientation == Direction::EAST )
|
||||
{
|
||||
if ( data == 3 )
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if ( data == 4 )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if ( data == 2 )
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if ( data == 1 )
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tile == Tile::tripWireSource_Id || (Tile::tiles[tile] != nullptr && dynamic_cast<DirectionalTile *>(Tile::tiles[tile])))
|
||||
@@ -446,47 +366,29 @@ int StructurePiece::getOrientationData( int tile, int data )
|
||||
if (orientation == Direction::SOUTH)
|
||||
{
|
||||
if (data == Direction::SOUTH || data == Direction::NORTH)
|
||||
{
|
||||
return Direction::DIRECTION_OPPOSITE[data];
|
||||
}
|
||||
}
|
||||
else if (orientation == Direction::WEST)
|
||||
{
|
||||
if (data == Direction::NORTH)
|
||||
{
|
||||
return Direction::WEST;
|
||||
}
|
||||
if (data == Direction::SOUTH)
|
||||
{
|
||||
return Direction::EAST;
|
||||
}
|
||||
if (data == Direction::WEST)
|
||||
{
|
||||
return Direction::NORTH;
|
||||
}
|
||||
if (data == Direction::EAST)
|
||||
{
|
||||
return Direction::SOUTH;
|
||||
}
|
||||
}
|
||||
else if (orientation == Direction::EAST)
|
||||
{
|
||||
if (data == Direction::NORTH)
|
||||
{
|
||||
return Direction::EAST;
|
||||
}
|
||||
if (data == Direction::SOUTH)
|
||||
{
|
||||
return Direction::WEST;
|
||||
}
|
||||
if (data == Direction::WEST)
|
||||
{
|
||||
return Direction::NORTH;
|
||||
}
|
||||
if (data == Direction::EAST)
|
||||
{
|
||||
return Direction::SOUTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (tile == Tile::pistonBase_Id || tile == Tile::pistonStickyBase_Id || tile == Tile::lever_Id || tile == Tile::dispenser_Id)
|
||||
@@ -494,46 +396,29 @@ int StructurePiece::getOrientationData( int tile, int data )
|
||||
if (orientation == Direction::SOUTH)
|
||||
{
|
||||
if (data == Facing::NORTH || data == Facing::SOUTH)
|
||||
{
|
||||
return Facing::OPPOSITE_FACING[data];
|
||||
}
|
||||
}
|
||||
else if (orientation == Direction::WEST)
|
||||
{
|
||||
if (data == Facing::NORTH)
|
||||
{
|
||||
return Facing::WEST;
|
||||
}
|
||||
if (data == Facing::SOUTH)
|
||||
{
|
||||
return Facing::EAST;
|
||||
}
|
||||
if (data == Facing::WEST)
|
||||
{
|
||||
return Facing::NORTH;
|
||||
}
|
||||
if (data == Facing::EAST)
|
||||
{
|
||||
return Facing::SOUTH;
|
||||
}
|
||||
} else if (orientation == Direction::EAST)
|
||||
}
|
||||
else if (orientation == Direction::EAST)
|
||||
{
|
||||
if (data == Facing::NORTH)
|
||||
{
|
||||
return Facing::EAST;
|
||||
}
|
||||
if (data == Facing::SOUTH)
|
||||
{
|
||||
return Facing::WEST;
|
||||
}
|
||||
if (data == Facing::WEST)
|
||||
{
|
||||
return Facing::NORTH;
|
||||
}
|
||||
if (data == Facing::EAST)
|
||||
{
|
||||
return Facing::SOUTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
return data;
|
||||
@@ -547,9 +432,7 @@ void StructurePiece::placeBlock( Level* level, int block, int data, int x, int y
|
||||
int worldZ = getWorldZ( x, z );
|
||||
|
||||
if ( !chunkBB->isInside( worldX, worldY, worldZ ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 4J Stu - We shouldn't be removing bedrock when generating things (eg in SuperFlat)
|
||||
if(worldY == 0) return;
|
||||
@@ -557,7 +440,6 @@ void StructurePiece::placeBlock( Level* level, int block, int data, int x, int y
|
||||
level->setTileAndData( worldX, worldY, worldZ, block, data, Tile::UPDATE_CLIENTS);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The purpose of this method is to wrap the getTile call on Level, in order
|
||||
* to prevent the level from generating chunks that shouldn't be loaded yet.
|
||||
@@ -577,9 +459,7 @@ int StructurePiece::getBlock( Level* level, int x, int y, int z, BoundingBox* ch
|
||||
int worldZ = getWorldZ( x, z );
|
||||
|
||||
if ( !chunkBB->isInside( worldX, worldY, worldZ ) )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return level->getTile( worldX, worldY, worldZ );
|
||||
}
|
||||
@@ -591,9 +471,7 @@ void StructurePiece::generateAirBox(Level *level, BoundingBox *chunkBB, int x0,
|
||||
for (int x = x0; x <= x1; x++)
|
||||
{
|
||||
for (int z = z0; z <= z1; z++)
|
||||
{
|
||||
placeBlock(level, 0, 0, x, y, z, chunkBB);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -607,20 +485,13 @@ void StructurePiece::generateBox( Level* level, BoundingBox* chunkBB, int x0, in
|
||||
{
|
||||
for ( int z = z0; z <= z1; z++ )
|
||||
{
|
||||
|
||||
if ( skipAir && getBlock( level, x, y, z, chunkBB ) == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( y == y0 || y == y1 || x == x0 || x == x1 || z == z0 || z == z1 )
|
||||
{
|
||||
placeBlock( level, edgeTile, 0, x, y, z, chunkBB );
|
||||
}
|
||||
else
|
||||
{
|
||||
placeBlock( level, fillTile, 0, x, y, z, chunkBB );
|
||||
}
|
||||
|
||||
if ( y == y0 || y == y1 || x == x0 || x == x1 || z == z0 || z == z1 )
|
||||
placeBlock( level, edgeTile, 0, x, y, z, chunkBB );
|
||||
else
|
||||
placeBlock( level, fillTile, 0, x, y, z, chunkBB );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -634,27 +505,19 @@ void StructurePiece::generateBox(Level *level, BoundingBox *chunkBB, int x0, int
|
||||
{
|
||||
for (int z = z0; z <= z1; z++)
|
||||
{
|
||||
|
||||
if (skipAir && getBlock(level, x, y, z, chunkBB) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (y == y0 || y == y1 || x == x0 || x == x1 || z == z0 || z == z1)
|
||||
{
|
||||
placeBlock(level, edgeTile, edgeData, x, y, z, chunkBB);
|
||||
}
|
||||
else
|
||||
{
|
||||
placeBlock(level, fillTile, fillData, x, y, z, chunkBB);
|
||||
}
|
||||
|
||||
if (y == y0 || y == y1 || x == x0 || x == x1 || z == z0 || z == z1)
|
||||
placeBlock(level, edgeTile, edgeData, x, y, z, chunkBB);
|
||||
else
|
||||
placeBlock(level, fillTile, fillData, x, y, z, chunkBB);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StructurePiece::generateBox( Level* level, BoundingBox* chunkBB, BoundingBox* boxBB, int edgeTile, int fillTile,
|
||||
bool skipAir )
|
||||
void StructurePiece::generateBox( Level* level, BoundingBox* chunkBB, BoundingBox* boxBB, int edgeTile, int fillTile, bool skipAir )
|
||||
{
|
||||
generateBox( level, chunkBB, boxBB->x0, boxBB->y0, boxBB->z0, boxBB->x1, boxBB->y1, boxBB->z1, edgeTile, fillTile,
|
||||
skipAir );
|
||||
@@ -669,21 +532,17 @@ void StructurePiece::generateBox( Level* level, BoundingBox* chunkBB, int x0, in
|
||||
{
|
||||
for ( int z = z0; z <= z1; z++ )
|
||||
{
|
||||
|
||||
if ( skipAir && getBlock( level, x, y, z, chunkBB ) == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
selector->next( random, x, y, z, y == y0 || y == y1 || x == x0 || x == x1 || z == z0 || z == z1 );
|
||||
placeBlock( level, selector->getNextId(), selector->getNextData(), x, y, z, chunkBB );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StructurePiece::generateBox( Level* level, BoundingBox* chunkBB, BoundingBox* boxBB, bool skipAir, Random* random,
|
||||
StructurePiece::BlockSelector* selector )
|
||||
void StructurePiece::generateBox( Level* level, BoundingBox* chunkBB, BoundingBox* boxBB, bool skipAir, Random* random, StructurePiece::BlockSelector* selector )
|
||||
{
|
||||
generateBox( level, chunkBB, boxBB->x0, boxBB->y0, boxBB->z0, boxBB->x1, boxBB->y1, boxBB->z1, skipAir, random,
|
||||
selector );
|
||||
@@ -699,31 +558,22 @@ void StructurePiece::generateMaybeBox( Level* level, BoundingBox* chunkBB, Rando
|
||||
{
|
||||
for ( int z = z0; z <= z1; z++ )
|
||||
{
|
||||
|
||||
if ( random->nextFloat() > probability )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( skipAir && getBlock( level, x, y, z, chunkBB ) == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ( y == y0 || y == y1 || x == x0 || x == x1 || z == z0 || z == z1 )
|
||||
{
|
||||
placeBlock( level, edgeTile, 0, x, y, z, chunkBB );
|
||||
}
|
||||
else
|
||||
{
|
||||
placeBlock( level, fillTile, 0, x, y, z, chunkBB );
|
||||
}
|
||||
|
||||
if ( skipAir && getBlock( level, x, y, z, chunkBB ) == 0 )
|
||||
continue;
|
||||
|
||||
if ( y == y0 || y == y1 || x == x0 || x == x1 || z == z0 || z == z1 )
|
||||
placeBlock( level, edgeTile, 0, x, y, z, chunkBB );
|
||||
else
|
||||
placeBlock( level, fillTile, 0, x, y, z, chunkBB );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void StructurePiece::maybeGenerateBlock( Level* level, BoundingBox* chunkBB, Random *random, float probability, int x,
|
||||
int y, int z, int tile, int data )
|
||||
void StructurePiece::maybeGenerateBlock( Level* level, BoundingBox* chunkBB, Random *random, float probability, int x, int y, int z, int tile, int data )
|
||||
{
|
||||
if ( random->nextFloat() < probability )
|
||||
{
|
||||
@@ -731,8 +581,7 @@ void StructurePiece::maybeGenerateBlock( Level* level, BoundingBox* chunkBB, Ran
|
||||
}
|
||||
}
|
||||
|
||||
void StructurePiece::generateUpperHalfSphere( Level* level, BoundingBox* chunkBB, int x0, int y0, int z0, int x1,
|
||||
int y1, int z1, int fillTile, bool skipAir )
|
||||
void StructurePiece::generateUpperHalfSphere( Level* level, BoundingBox* chunkBB, int x0, int y0, int z0, int x1, int y1, int z1, int fillTile, bool skipAir )
|
||||
{
|
||||
float diagX = static_cast<float>(x1 - x0 + 1);
|
||||
float diagY = static_cast<float>(y1 - y0 + 1);
|
||||
@@ -753,18 +602,13 @@ void StructurePiece::generateUpperHalfSphere( Level* level, BoundingBox* chunkBB
|
||||
float normalizedZDistance = ( float )( z - cz ) / ( diagZ * 0.5f );
|
||||
|
||||
if ( skipAir && getBlock( level, x, y, z, chunkBB ) == 0 )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
float dist = ( normalizedXDistance * normalizedXDistance ) + ( normalizedYDistance *
|
||||
normalizedYDistance ) + ( normalizedZDistance * normalizedZDistance );
|
||||
|
||||
if ( dist <= 1.05f )
|
||||
{
|
||||
placeBlock( level, fillTile, 0, x, y, z, chunkBB );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -792,9 +636,7 @@ void StructurePiece::generateFullSphere( Level* level, BoundingBox* chunkBB, int
|
||||
}
|
||||
|
||||
if ( ( float ) radius - dist > 0.5f )
|
||||
{
|
||||
placeBlock( level, fillTile, fillData, x, y, z, chunkBB );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -807,9 +649,7 @@ void StructurePiece::generateAirColumnUp( Level* level, int x, int startY, int z
|
||||
int worldZ = getWorldZ( x, z );
|
||||
|
||||
if ( !chunkBB->isInside( worldX, worldY, worldZ ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while ( !level->isEmptyTile( worldX, worldY, worldZ ) && worldY < Level::maxBuildHeight - 1 )
|
||||
{
|
||||
@@ -823,9 +663,7 @@ void StructurePiece::generateAirBoxUp( Level* level, int x0, int z0, int x1, int
|
||||
for ( int x = x0; x < x1; ++x )
|
||||
{
|
||||
for ( int z = z0; z < z1; ++z )
|
||||
{
|
||||
placeBlock( level, 0, 0, x, y, z, chunkBB );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -836,9 +674,7 @@ void StructurePiece::fillColumnDown( Level* level, int tile, int tileData, int x
|
||||
int worldZ = getWorldZ( x, z );
|
||||
|
||||
if ( !chunkBB->isInside( worldX, worldY, worldZ ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while ( ( level->isEmptyTile( worldX, worldY, worldZ ) || level->getMaterial( worldX, worldY, worldZ )->isLiquid() ) && worldY > 1 )
|
||||
{
|
||||
@@ -852,9 +688,7 @@ void StructurePiece::fillBoxDown( Level* level, int tileId, int tileData, int x0
|
||||
for ( int x = x0; x <= x1; x++ )
|
||||
{
|
||||
for ( int z = z0; z <= z1; z++ )
|
||||
{
|
||||
fillColumnDown( level, tileId, tileData, x, y0, z, chunkBB );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -914,9 +748,7 @@ void StructurePiece::createCrops( Level *level, BoundingBox *chunkBB, Random *ra
|
||||
for ( int x = x0; x <= x1; x++ )
|
||||
{
|
||||
for ( int z = z0; z <= z1; z++ )
|
||||
{
|
||||
placeBlock( level, tileId, Mth::nextInt( random, minData, maxData ), x, y, z, chunkBB );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -949,25 +781,19 @@ void StructurePiece::generateStructureFromData( Level *level, BoundingBox *chunk
|
||||
bool invert = s.v26[1] != 0;
|
||||
|
||||
if ( bitIndex >= (int)featureConditions.size() )
|
||||
{
|
||||
shouldGenerate = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
bool bit = featureConditions[bitIndex];
|
||||
if ( invert )
|
||||
{
|
||||
if ( bit )
|
||||
{
|
||||
shouldGenerate = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( !bit )
|
||||
{
|
||||
shouldGenerate = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1000,7 +826,8 @@ void StructurePiece::generateStructureFromData( Level *level, BoundingBox *chunk
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!shouldGenerate) break;
|
||||
if (!shouldGenerate)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1012,32 +839,41 @@ void StructurePiece::generateStructureFromData( Level *level, BoundingBox *chunk
|
||||
{
|
||||
int offsetValue = tileOptionRemap[remapIdx];
|
||||
// start
|
||||
if (s.startRemap0 == remapIdx) s.x0 += offsetValue;
|
||||
if (s.startRemap1 == remapIdx) s.x0 += offsetValue;
|
||||
if (s.startRemap2 == remapIdx) s.y0 += offsetValue;
|
||||
if (s.startRemap0 == remapIdx)
|
||||
s.x0 += offsetValue;
|
||||
if (s.startRemap1 == remapIdx)
|
||||
s.x0 += offsetValue;
|
||||
if (s.startRemap2 == remapIdx)
|
||||
s.y0 += offsetValue;
|
||||
|
||||
// end
|
||||
if (s.endRemap0 == remapIdx) s.x1 += offsetValue;
|
||||
if (s.endRemap1 == remapIdx) s.x1 += offsetValue;
|
||||
if (s.endRemap2 == remapIdx) s.y1 += offsetValue;
|
||||
if (s.endRemap0 == remapIdx)
|
||||
s.x1 += offsetValue;
|
||||
if (s.endRemap1 == remapIdx)
|
||||
s.x1 += offsetValue;
|
||||
if (s.endRemap2 == remapIdx)
|
||||
s.y1 += offsetValue;
|
||||
}
|
||||
|
||||
switch( s.id )
|
||||
{
|
||||
case eGenerateStructure_Block:
|
||||
{
|
||||
placeBlock( level, s.tileId, getBlockDataValue( (StructureTable::eBlockDataType)s.dataType, s.tileId, s.data ), s.x0, s.y0, s.z0, chunkBB );
|
||||
break;
|
||||
|
||||
}
|
||||
/*
|
||||
case eGenerateStructure_maybeGenerateBlock:
|
||||
{
|
||||
maybeGenerateBlock( level, chunkBB, random, s.probability, s.x0, s.y0, s.z0, s.tileId, s.data );
|
||||
break;
|
||||
|
||||
}
|
||||
case eGenerateStructure_AirBox:
|
||||
{
|
||||
generateAirBox( level, chunkBB, s.x0, s.y0, s.z0, s.x1, s.y1, s.z1 );
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
case eGenerateStructure_Box:
|
||||
{
|
||||
int data0 = getBlockDataValue( (StructureTable::eBlockDataType)s.dataType, s.tileId, s.data );
|
||||
@@ -1048,14 +884,16 @@ void StructurePiece::generateStructureFromData( Level *level, BoundingBox *chunk
|
||||
|
||||
/*
|
||||
case eGenerateStructure_MaybeBox:
|
||||
{
|
||||
generateMaybeBox( level, chunkBB, random, s.probability, s.x0, s.y0, s.z0, s.x1, s.y1, s.z1, s.tileId, s.data, false );
|
||||
break;
|
||||
|
||||
}
|
||||
case eGenerateStructure_UpperHalfSphere:
|
||||
{
|
||||
generateUpperHalfSphere( level, chunkBB, s.x0, s.y0, s.z0, s.x1, s.y1, s.z1, s.tileId, false );
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
case eGenerateStructure_FullSphere:
|
||||
{
|
||||
int data0 = getBlockDataValue( (StructureTable::eBlockDataType)s.dataType, s.tileId, s.data );
|
||||
@@ -1063,31 +901,30 @@ void StructurePiece::generateStructureFromData( Level *level, BoundingBox *chunk
|
||||
generateFullSphere( level, chunkBB, s.x0, s.y0, s.z0, s.v25[0], s.tileId, data0, s.secondTileId, data1, false );
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
case eGenerateStructure_AirColumnUp:
|
||||
{
|
||||
generateAirColumnUp( level, s.x0, s.y0, s.z0, chunkBB );
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
case eGenerateStructure_fillColumnDown:
|
||||
{
|
||||
int data0 = getBlockDataValue( (StructureTable::eBlockDataType)s.dataType, s.tileId, s.data );
|
||||
fillColumnDown( level, s.tileId, data0, s.x0, s.y0, s.z0, chunkBB );
|
||||
break;
|
||||
}
|
||||
|
||||
case eGenerateStructure_fillBoxDown:
|
||||
{
|
||||
int data0 = getBlockDataValue( (StructureTable::eBlockDataType)s.dataType, s.tileId, s.data );
|
||||
fillBoxDown( level, s.tileId, data0, s.x0, s.y0, s.z0, s.x1, s.z1, chunkBB );
|
||||
break;
|
||||
}
|
||||
|
||||
case eGenerateStructure_generateAirBoxUp:
|
||||
{
|
||||
generateAirBoxUp( level, s.x0, s.z0, s.x1, s.z1, s.y0, chunkBB );
|
||||
break;
|
||||
|
||||
}
|
||||
case eGenerateStructure_Crops:
|
||||
{
|
||||
if( tileOptionRemap.empty() )
|
||||
@@ -1109,7 +946,6 @@ void StructurePiece::generateStructureFromData( Level *level, BoundingBox *chunk
|
||||
createCrops( level, chunkBB, random, s.x0, s.z0, s.x1, s.z1, s.y0, cropTileId, minCropAge, maxCropAge);
|
||||
break;
|
||||
}
|
||||
|
||||
case eGenerateStructure_CreateDoor:
|
||||
{
|
||||
int worldX = getWorldX( s.x0, s.z0 );
|
||||
@@ -1119,38 +955,28 @@ void StructurePiece::generateStructureFromData( Level *level, BoundingBox *chunk
|
||||
{
|
||||
int doorData = getBlockDataValue( (StructureTable::eBlockDataType)s.dataType, s.tileId, s.data );
|
||||
if( s.tileId == Tile::door_wood_Id )
|
||||
{
|
||||
DoorItem::place( level, worldX, worldY, worldZ, doorData, Tile::door_wood );
|
||||
}
|
||||
else
|
||||
{
|
||||
DoorItem::place( level, worldX, worldY, worldZ, doorData, Tile::door_iron );
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case eGenerateStructure_CheckBlock:
|
||||
{
|
||||
int block = getBlock(level, s.x0, s.y0, s.z0, chunkBB);
|
||||
bool match = (block != 0);
|
||||
|
||||
if (!s.v25.empty() && s.v25[0] == 0)
|
||||
{
|
||||
match = (block == 0);
|
||||
}
|
||||
|
||||
if (!match)
|
||||
{
|
||||
if (!s.v27.empty())
|
||||
{
|
||||
failures[s.v27[0]] = true;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1164,9 +990,7 @@ void StructurePiece::generateStructureFromData( Level *level, BoundingBox *chunk
|
||||
|
||||
bool process = true;
|
||||
if ( (int)objectPlacedFlags.size() == (int)piece->objects.size() )
|
||||
{
|
||||
process = objectPlacedFlags[i];
|
||||
}
|
||||
|
||||
bool placed = false;
|
||||
|
||||
@@ -1187,13 +1011,9 @@ void StructurePiece::generateStructureFromData( Level *level, BoundingBox *chunk
|
||||
|
||||
int rollOffset = random->nextInt( o.rollWeight );
|
||||
if ( o.id == eGenerateObject_Chest )
|
||||
{
|
||||
placed = createChest( level, chunkBB, random, o.x, o.y, o.z, treasure, o.rollCount + rollOffset );
|
||||
}
|
||||
else
|
||||
{
|
||||
placed = createDispenser( level, chunkBB, random, o.x, o.y, o.z, o.dispenserDir, treasure, o.rollCount + rollOffset );
|
||||
}
|
||||
|
||||
delete book;
|
||||
}
|
||||
@@ -1201,13 +1021,9 @@ void StructurePiece::generateStructureFromData( Level *level, BoundingBox *chunk
|
||||
{
|
||||
int rollOffset = random->nextInt( o.rollWeight );
|
||||
if ( o.id == eGenerateObject_Chest )
|
||||
{
|
||||
placed = createChest( level, chunkBB, random, o.x, o.y, o.z, treasureItems, o.rollCount + rollOffset );
|
||||
}
|
||||
else
|
||||
{
|
||||
placed = createDispenser( level, chunkBB, random, o.x, o.y, o.z, o.dispenserDir, treasureItems, o.rollCount + rollOffset );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1222,17 +1038,13 @@ void StructurePiece::generateStructureFromData( Level *level, BoundingBox *chunk
|
||||
const StructureTable::EntityData &e = piece->entities[j];
|
||||
|
||||
if ( j >= entitySpawnCounts.size() )
|
||||
{
|
||||
entitySpawnCounts.push_back( 0 );
|
||||
}
|
||||
|
||||
spawnEntity( level, chunkBB, e.x, e.y, e.z, (eGenerateEntity)e.id, e.count, const_cast<vector<int>&>( e.professions ), entitySpawnCounts[j] );
|
||||
}
|
||||
|
||||
for (int i = 0; i < treasureItems.length; i++)
|
||||
{
|
||||
delete treasureItems[i];
|
||||
}
|
||||
}
|
||||
|
||||
void StructurePiece::setDirty()
|
||||
@@ -1251,9 +1063,7 @@ void StructurePiece::spawnEntity( Level *level, BoundingBox *chunkBB, int x, int
|
||||
worldX += entitySpawnCounts;
|
||||
|
||||
if ( !chunkBB->isInside( worldX, worldY, worldZ ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( entityType == eGenerateEntity_Witch )
|
||||
{
|
||||
@@ -1334,9 +1144,7 @@ void StructurePiece::addBoolSaveData(DataOutputStream *dos, vector<bool> &data)
|
||||
outData.append( woss.str() );
|
||||
|
||||
if ( i < data.size() - 1 )
|
||||
{
|
||||
outData.append( L"," );
|
||||
}
|
||||
}
|
||||
|
||||
dos->writeUTF( outData );
|
||||
@@ -1375,9 +1183,7 @@ void StructurePiece::addIntSaveData(DataOutputStream *dos, vector<int> &data)
|
||||
outData.append( woss.str() );
|
||||
|
||||
if ( i < data.size() - 1 )
|
||||
{
|
||||
outData.append( L"," );
|
||||
}
|
||||
}
|
||||
|
||||
dos->writeUTF( outData );
|
||||
|
||||
Reference in New Issue
Block a user