Exemplo n.º 1
0
int tools_uniformInt(int a, int b)
{
  if (a < 0)
  {
    return uniformUINT(0, b - a) + a;
  }
  return uniformUINT(a, b);
}
Exemplo n.º 2
0
void Drop::getDrop(int16_t& item, uint8_t& count, uint8_t& meta)
{
  Drop *cur = this;
  while (cur)
  {
    if (cur->probability >= uniformUINT(0, 9999))
    {
      item = cur->item_id;
      count = cur->count;
      if (cur->meta != -1) meta = (uint8_t)cur->meta;
      return;
    }
    else
    {
      cur = cur->alt_drop.get();
    }
  }
  count = 0;
}
Exemplo n.º 3
0
void BiomeGen::AddDeposit(int x, int y, int z, int map, uint8_t block, int minDepoSize, int maxDepoSize, sChunk* chunk)
{
  int depoSize = uniformUINT(maxDepoSize - minDepoSize, maxDepoSize);

  for (int i = 0; i < depoSize; i++)
  {
    if (chunk->blocks[x + (z << 4) + (y << 8)] == BLOCK_STONE)
    {
      chunk->blocks[x + (z << 4) + (y << 8)] = block;
    }

    z = z + int(uniform_0_1()) - 1;
    x = x + int(uniform_0_1()) - 1;
    y = y + int(uniform_0_1()) - 1;

    // If over chunk borders
    if (z < 0 || z > 15 || x < 0 || x > 15 || y < 1)
    {
      break;
    }
  }
}
Exemplo n.º 4
0
void BiomeGen::AddOre(int x, int z, int map, uint8_t type)
{
  sChunk* chunk = ServerInstance->map(map)->getChunk(x, z);

  int blockX, blockY, blockZ;
  uint8_t block;

  // Parameters for deposits
  int startHeight, minDepoSize, maxDepoSize;
  unsigned int count;

  switch (type)
  {
  case BLOCK_COAL_ORE:
    count = uniform_20_30(); // 20-30 coal deposits
    startHeight = 90;
    minDepoSize = 8;
    maxDepoSize = 20;
    break;
  case BLOCK_IRON_ORE:
    count = uniform_10_18(); // 10-18 iron deposits
    startHeight = 60;
    minDepoSize = 5;
    maxDepoSize = 10;
    break;
  case BLOCK_GOLD_ORE:
    count = uniform_4_9(); // 4-9 gold deposits
    startHeight = 32;
    minDepoSize = 5;
    maxDepoSize = 8;
    break;
  case BLOCK_DIAMOND_ORE:
    count = uniform_1_3(); // 1-3 diamond deposits
    startHeight = 17;
    minDepoSize = 4;
    maxDepoSize = 7;
    break;
  case BLOCK_REDSTONE_ORE:
    count = uniform_5_10(); // 5-10 redstone deposits
    startHeight = 25;
    minDepoSize = 5;
    maxDepoSize = 20;
    break;
  case BLOCK_LAPIS_ORE:
    count = uniform_1_3(); // 1-3 lapis lazuli deposits
    startHeight = 17;
    minDepoSize = 5;
    maxDepoSize = 20;
    break;
  case BLOCK_GRAVEL:
    count = uniform_10_30(); // 10-30 gravel deposits
    startHeight = 90;
    minDepoSize = 5;
    maxDepoSize = 50;
    break;
  default:
    return;
  }

  for (unsigned int i = 0; i < count; ++i)
  {
    blockX = uniform_8_12();
    blockZ = uniform_8_12();

    blockY = heightmap_pointer[(blockZ << 4) + blockX];
    blockY -= 5;

    // Check that startheight is not higher than height at that column
    if (blockY > startHeight)
    {
      blockY = startHeight;
    }

    //blockX += xBlockpos;
    //blockZ += zBlockpos;

    // Calculate Y
    blockY = uniformUINT(0, blockY);

    
    block = chunk->blocks[blockX + (blockZ << 4) + (blockY << 8)];

    // No ore in caves
    if (block == BLOCK_AIR)
    {
      continue;
    }

    AddDeposit(blockX, blockY, blockZ, map, type, minDepoSize, maxDepoSize, chunk);
  }
}