mirror of
https://github.com/neoStudiosLCE/neoLegacy.git
synced 2026-06-08 23:13:00 +00:00
saplings now have all the id 6
This commit is contained in:
parent
60c74a768f
commit
8c6da7ea22
|
|
@ -206,8 +206,8 @@ void IUIScene_CreativeMenu::staticCtor()
|
|||
ITEM_AUX(Tile::sapling_Id, Sapling::TYPE_EVERGREEN)
|
||||
ITEM_AUX(Tile::sapling_Id, Sapling::TYPE_BIRCH)
|
||||
ITEM_AUX(Tile::sapling_Id, Sapling::TYPE_JUNGLE)
|
||||
ITEM_AUX(Tile::sapling2_Id, Sapling2::TYPE_ACACIA)
|
||||
ITEM_AUX(Tile::sapling2_Id, Sapling2::TYPE_DARK_OAK)
|
||||
ITEM_AUX(Tile::sapling_Id, Sapling::TYPE_ACACIA)
|
||||
ITEM_AUX(Tile::sapling_Id, Sapling::TYPE_DARK_OAK)
|
||||
ITEM_AUX(Tile::leaves_Id, LeafTile::NORMAL_LEAF)
|
||||
ITEM_AUX(Tile::leaves_Id, LeafTile::EVERGREEN_LEAF)
|
||||
ITEM_AUX(Tile::leaves_Id, LeafTile::BIRCH_LEAF)
|
||||
|
|
|
|||
|
|
@ -183,18 +183,7 @@ bool DyePowderItem::growCrop(shared_ptr<ItemInstance> itemInstance, Level *level
|
|||
}
|
||||
return true;
|
||||
}
|
||||
if (tile == Tile::sapling2_Id)
|
||||
{
|
||||
if(!bTestUseOnOnly)
|
||||
{
|
||||
if (!level->isClientSide)
|
||||
{
|
||||
if (level->random->nextFloat() < 0.45) static_cast<Sapling2 *>(Tile::tiles[Tile::sapling2_Id])->growTree(level, x, y, z, level->random);
|
||||
itemInstance->count--;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
else if (tile == Tile::mushroom_brown_Id || tile == Tile::mushroom_red_Id)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ bool HugeMushroomFeature::place(Level *level, Random *random, int x, int y, int
|
|||
if (yy >= 0 && yy < Level::maxBuildHeight)
|
||||
{
|
||||
int tt = level->getTile(xx, yy, zz);
|
||||
if (tt != 0 && tt != Tile::leaves_Id && tt != Tile::leaves2_Id && tt != Tile::tallgrass_Id && tt != Tile::sapling_Id && tt != Tile::sapling2_Id)
|
||||
if (tt != 0 && tt != Tile::leaves_Id && tt != Tile::leaves2_Id && tt != Tile::tallgrass_Id && tt != Tile::sapling_Id)
|
||||
free = false;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ void LeafTile2::spawnResources(Level *level, int x, int y, int z, int data, floa
|
|||
{
|
||||
|
||||
|
||||
popResource(level, x, y, z, std::make_shared<ItemInstance>(Tile::sapling2_Id, 1, data & 3));
|
||||
popResource(level, x, y, z, std::make_shared<ItemInstance>(Tile::sapling_Id, 1, data & 3));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2720,7 +2720,6 @@
|
|||
<ClInclude Include="RoofedForestBiome.h" />
|
||||
<ClInclude Include="RotatedPillarTile.h" />
|
||||
<ClInclude Include="SandTile.h" />
|
||||
<ClInclude Include="Sapling2.h" />
|
||||
<ClInclude Include="SavannaBiome.h" />
|
||||
<ClInclude Include="SavannaTreeFeature.h" />
|
||||
<ClInclude Include="Score.h" />
|
||||
|
|
@ -3664,7 +3663,6 @@
|
|||
<ClInclude Include="Rose.h" />
|
||||
<ClCompile Include="RotatedPillarTile.cpp" />
|
||||
<ClCompile Include="SandTile.cpp" />
|
||||
<ClCompile Include="Sapling2.cpp" />
|
||||
<ClCompile Include="SavannaBiome.cpp" />
|
||||
<ClCompile Include="SavannaTreeFeature.cpp" />
|
||||
<ClCompile Include="Score.cpp" />
|
||||
|
|
|
|||
|
|
@ -821,7 +821,6 @@
|
|||
<ClCompile Include="PackedIceTile.cpp" />
|
||||
<ClCompile Include="LeafTile2.cpp" />
|
||||
<ClCompile Include="LeafTileItem2.cpp" />
|
||||
<ClCompile Include="Sapling2.cpp" />
|
||||
<ClCompile Include="SavannaTreeFeature.cpp" />
|
||||
<ClCompile Include="DarkOakFeature.cpp" />
|
||||
<ClCompile Include="SavannaBiome.cpp" />
|
||||
|
|
@ -1818,7 +1817,6 @@
|
|||
<ClInclude Include="PackedIceTile.h" />
|
||||
<ClInclude Include="LeafTile2.h" />
|
||||
<ClInclude Include="LeafTileItem2.h" />
|
||||
<ClInclude Include="Sapling2.h" />
|
||||
<ClInclude Include="SavannaTreeFeature.h" />
|
||||
<ClInclude Include="DarkOakFeature.h" />
|
||||
<ClInclude Include="SavannaBiome.h" />
|
||||
|
|
|
|||
|
|
@ -5,165 +5,213 @@
|
|||
#include "net.minecraft.world.h"
|
||||
|
||||
#include "Sapling.h"
|
||||
#include "SavannaTreeFeature.h"
|
||||
#include "DarkOakFeature.h"
|
||||
|
||||
int Sapling::SAPLING_NAMES[SAPLING_NAMES_SIZE] = { IDS_TILE_SAPLING_OAK,
|
||||
IDS_TILE_SAPLING_SPRUCE,
|
||||
IDS_TILE_SAPLING_BIRCH,
|
||||
IDS_TILE_SAPLING_JUNGLE
|
||||
int Sapling::SAPLING_NAMES[SAPLING_NAMES_SIZE] = {
|
||||
IDS_TILE_SAPLING_OAK,
|
||||
IDS_TILE_SAPLING_SPRUCE,
|
||||
IDS_TILE_SAPLING_BIRCH,
|
||||
IDS_TILE_SAPLING_JUNGLE,
|
||||
IDS_TILE_SAPLING_ACACIA,
|
||||
IDS_TILE_SAPLING_DARK_OAK
|
||||
};
|
||||
|
||||
const wstring Sapling::TEXTURE_NAMES[] = {L"sapling", L"sapling_spruce", L"sapling_birch", L"sapling_jungle"};
|
||||
const wstring Sapling::TEXTURE_NAMES[] = {
|
||||
L"sapling",
|
||||
L"sapling_spruce",
|
||||
L"sapling_birch",
|
||||
L"sapling_jungle",
|
||||
L"sapling_acacia",
|
||||
L"sapling_dark_oak"
|
||||
};
|
||||
|
||||
Sapling::Sapling(int id) : Bush( id )
|
||||
{
|
||||
this->updateDefaultShape();
|
||||
icons = nullptr;
|
||||
this->updateDefaultShape();
|
||||
icons = nullptr;
|
||||
}
|
||||
|
||||
// 4J Added override
|
||||
void Sapling::updateDefaultShape()
|
||||
{
|
||||
float ss = 0.4f;
|
||||
this->setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, ss * 2, 0.5f + ss);
|
||||
float ss = 0.4f;
|
||||
this->setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, ss * 2, 0.5f + ss);
|
||||
}
|
||||
|
||||
void Sapling::tick(Level *level, int x, int y, int z, Random *random)
|
||||
{
|
||||
if (level->isClientSide) return;
|
||||
if (level->isClientSide) return;
|
||||
|
||||
Bush::tick(level, x, y, z, random);
|
||||
Bush::tick(level, x, y, z, random);
|
||||
|
||||
if (level->getRawBrightness(x, y + 1, z) >= Level::MAX_BRIGHTNESS - 6)
|
||||
{
|
||||
if (random->nextInt(7) == 0)
|
||||
{
|
||||
advanceTree(level, x, y, z, random);
|
||||
}
|
||||
}
|
||||
if (level->getRawBrightness(x, y + 1, z) >= Level::MAX_BRIGHTNESS - 6)
|
||||
{
|
||||
if (random->nextInt(7) == 0)
|
||||
{
|
||||
advanceTree(level, x, y, z, random);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Icon *Sapling::getTexture(int face, int data)
|
||||
{
|
||||
data = data & TYPE_MASK;
|
||||
return icons[data];
|
||||
data = data & TYPE_MASK;
|
||||
if (data < 0 || data >= SAPLING_NAMES_SIZE) data = 0;
|
||||
return icons[data];
|
||||
}
|
||||
|
||||
void Sapling::advanceTree(Level *level, int x, int y, int z, Random *random)
|
||||
{
|
||||
int data = level->getData(x, y, z);
|
||||
if ((data & AGE_BIT) == 0)
|
||||
{
|
||||
level->setData(x, y, z, data | AGE_BIT, Tile::UPDATE_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
growTree(level, x, y, z, random);
|
||||
}
|
||||
int data = level->getData(x, y, z);
|
||||
if ((data & AGE_BIT) == 0)
|
||||
{
|
||||
level->setData(x, y, z, data | AGE_BIT, Tile::UPDATE_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
growTree(level, x, y, z, random);
|
||||
}
|
||||
}
|
||||
|
||||
void Sapling::growTree(Level *level, int x, int y, int z, Random *random)
|
||||
{
|
||||
int data = level->getData(x, y, z) & TYPE_MASK;
|
||||
int data = level->getData(x, y, z) & TYPE_MASK;
|
||||
|
||||
Feature *f = nullptr;
|
||||
Feature *f = nullptr;
|
||||
|
||||
int ox = 0, oz = 0;
|
||||
bool multiblock = false;
|
||||
int ox = 0, oz = 0;
|
||||
bool multiblock = false;
|
||||
|
||||
if (data == TYPE_EVERGREEN)
|
||||
{
|
||||
f = new SpruceFeature(true);
|
||||
}
|
||||
else if (data == TYPE_BIRCH)
|
||||
{
|
||||
f = new BirchFeature(true);
|
||||
}
|
||||
else if (data == TYPE_JUNGLE)
|
||||
{
|
||||
// check for mega tree
|
||||
for (ox = 0; ox >= -1; ox--)
|
||||
{
|
||||
for (oz = 0; oz >= -1; oz--)
|
||||
{
|
||||
if (isSapling(level, x + ox, y, z + oz, TYPE_JUNGLE) && isSapling(level, x + ox + 1, y, z + oz, TYPE_JUNGLE) && isSapling(level, x + ox, y, z + oz + 1, TYPE_JUNGLE)
|
||||
&& isSapling(level, x + ox + 1, y, z + oz + 1, TYPE_JUNGLE))
|
||||
{
|
||||
f = new MegaTreeFeature(true, 10 + random->nextInt(20), TreeTile::JUNGLE_TRUNK, LeafTile::JUNGLE_LEAF);
|
||||
multiblock = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (f != nullptr)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (f == nullptr)
|
||||
{
|
||||
ox = oz = 0;
|
||||
f = new TreeFeature(true, 4 + random->nextInt(7), TreeTile::JUNGLE_TRUNK, LeafTile::JUNGLE_LEAF, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
f = new TreeFeature(true);
|
||||
if (random->nextInt(10) == 0)
|
||||
{
|
||||
delete f;
|
||||
f = new BasicTree(true);
|
||||
}
|
||||
}
|
||||
if (multiblock)
|
||||
{
|
||||
level->setTileAndData(x + ox, y, z + oz, 0, 0, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox + 1, y, z + oz, 0, 0, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox, y, z + oz + 1, 0, 0, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox + 1, y, z + oz + 1, 0, 0, Tile::UPDATE_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
level->setTileAndData(x, y, z, 0, 0, Tile::UPDATE_NONE);
|
||||
}
|
||||
if (!f->place(level, random, x + ox, y, z + oz))
|
||||
{
|
||||
if (multiblock)
|
||||
{
|
||||
level->setTileAndData(x + ox, y, z + oz, id, data, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox + 1, y, z + oz, id, data, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox, y, z + oz + 1, id, data, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox + 1, y, z + oz + 1, id, data, Tile::UPDATE_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
level->setTileAndData(x, y, z, id, data, Tile::UPDATE_NONE);
|
||||
}
|
||||
}
|
||||
if( f != nullptr )
|
||||
delete f;
|
||||
if (data == TYPE_EVERGREEN)
|
||||
{
|
||||
f = new SpruceFeature(true);
|
||||
}
|
||||
else if (data == TYPE_BIRCH)
|
||||
{
|
||||
f = new BirchFeature(true);
|
||||
}
|
||||
else if (data == TYPE_JUNGLE)
|
||||
{
|
||||
for (ox = 0; ox >= -1; ox--)
|
||||
{
|
||||
for (oz = 0; oz >= -1; oz--)
|
||||
{
|
||||
if (isSapling(level, x + ox, y, z + oz, TYPE_JUNGLE) &&
|
||||
isSapling(level, x + ox + 1, y, z + oz, TYPE_JUNGLE) &&
|
||||
isSapling(level, x + ox, y, z + oz + 1, TYPE_JUNGLE) &&
|
||||
isSapling(level, x + ox + 1, y, z + oz + 1, TYPE_JUNGLE))
|
||||
{
|
||||
f = new MegaTreeFeature(true, 10 + random->nextInt(20), TreeTile::JUNGLE_TRUNK, LeafTile::JUNGLE_LEAF);
|
||||
multiblock = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (f != nullptr)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (f == nullptr)
|
||||
{
|
||||
ox = oz = 0;
|
||||
f = new TreeFeature(true, 4 + random->nextInt(7), TreeTile::JUNGLE_TRUNK, LeafTile::JUNGLE_LEAF, false);
|
||||
}
|
||||
}
|
||||
else if (data == TYPE_ACACIA)
|
||||
{
|
||||
f = new SavannaTreeFeature(true);
|
||||
}
|
||||
else if (data == TYPE_DARK_OAK)
|
||||
{
|
||||
for (ox = 0; ox >= -1; ox--)
|
||||
{
|
||||
for (oz = 0; oz >= -1; oz--)
|
||||
{
|
||||
if (isSapling(level, x + ox, y, z + oz, TYPE_DARK_OAK) &&
|
||||
isSapling(level, x + ox + 1, y, z + oz, TYPE_DARK_OAK) &&
|
||||
isSapling(level, x + ox, y, z + oz + 1, TYPE_DARK_OAK) &&
|
||||
isSapling(level, x + ox + 1, y, z + oz + 1, TYPE_DARK_OAK))
|
||||
{
|
||||
f = new DarkOakFeature(true);
|
||||
multiblock = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (f != nullptr) break;
|
||||
}
|
||||
|
||||
if (f == nullptr) return;
|
||||
}
|
||||
else
|
||||
{
|
||||
f = new TreeFeature(true);
|
||||
if (random->nextInt(10) == 0)
|
||||
{
|
||||
delete f;
|
||||
f = new BasicTree(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (multiblock)
|
||||
{
|
||||
level->setTileAndData(x + ox, y, z + oz, 0, 0, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox + 1, y, z + oz, 0, 0, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox, y, z + oz + 1, 0, 0, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox + 1, y, z + oz + 1, 0, 0, Tile::UPDATE_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
level->setTileAndData(x, y, z, 0, 0, Tile::UPDATE_NONE);
|
||||
}
|
||||
|
||||
if (!f->place(level, random, x + ox, y, z + oz))
|
||||
{
|
||||
if (multiblock)
|
||||
{
|
||||
level->setTileAndData(x + ox, y, z + oz, id, data, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox + 1, y, z + oz, id, data, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox, y, z + oz + 1, id, data, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox + 1, y, z + oz + 1, id, data, Tile::UPDATE_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
level->setTileAndData(x, y, z, id, data, Tile::UPDATE_NONE);
|
||||
}
|
||||
}
|
||||
|
||||
if( f != nullptr )
|
||||
delete f;
|
||||
}
|
||||
|
||||
unsigned int Sapling::getDescriptionId(int iData /*= -1*/)
|
||||
unsigned int Sapling::getDescriptionId(int iData )
|
||||
{
|
||||
if(iData < 0 ) iData = 0;
|
||||
return Sapling::SAPLING_NAMES[iData];
|
||||
if(iData < 0 || iData >= SAPLING_NAMES_SIZE) iData = 0;
|
||||
return Sapling::SAPLING_NAMES[iData];
|
||||
}
|
||||
|
||||
int Sapling::getSpawnResourcesAuxValue(int data)
|
||||
{
|
||||
return data & TYPE_MASK;
|
||||
return data & TYPE_MASK;
|
||||
}
|
||||
|
||||
bool Sapling::isSapling(Level *level, int x, int y, int z, int type)
|
||||
{
|
||||
return (level->getTile(x, y, z) == id) && ((level->getData(x, y, z) & TYPE_MASK) == type);
|
||||
return (level->getTile(x, y, z) == id) && ((level->getData(x, y, z) & TYPE_MASK) == type);
|
||||
}
|
||||
|
||||
bool Sapling::fertilize(Level *level, int x, int y, int z)
|
||||
{
|
||||
this->advanceTree(level, x, y, z, level->random);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Sapling::registerIcons(IconRegister *iconRegister)
|
||||
{
|
||||
icons = new Icon*[SAPLING_NAMES_SIZE];
|
||||
icons = new Icon*[SAPLING_NAMES_SIZE];
|
||||
|
||||
for (int i = 0; i < SAPLING_NAMES_SIZE; i++)
|
||||
{
|
||||
icons[i] = iconRegister->registerIcon(TEXTURE_NAMES[i]);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < SAPLING_NAMES_SIZE; i++)
|
||||
{
|
||||
icons[i] = iconRegister->registerIcon(TEXTURE_NAMES[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +1,56 @@
|
|||
#pragma once
|
||||
|
||||
#include "LeafTile.h"
|
||||
#include "LeafTile2.h"
|
||||
#include "Bush.h"
|
||||
|
||||
class Random;
|
||||
class ChunkRebuildData;
|
||||
class Tile;
|
||||
|
||||
class Sapling : public Bush
|
||||
{
|
||||
friend class Tile;
|
||||
friend class ChunkRebuildData;
|
||||
{
|
||||
friend class Tile;
|
||||
friend class ChunkRebuildData;
|
||||
public:
|
||||
static const int TYPE_DEFAULT = LeafTile::NORMAL_LEAF;
|
||||
static const int TYPE_EVERGREEN = LeafTile::EVERGREEN_LEAF;
|
||||
static const int TYPE_BIRCH = LeafTile::BIRCH_LEAF;
|
||||
static const int TYPE_JUNGLE = LeafTile::JUNGLE_LEAF;
|
||||
static const int TYPE_DEFAULT = LeafTile::NORMAL_LEAF;
|
||||
static const int TYPE_EVERGREEN = LeafTile::EVERGREEN_LEAF;
|
||||
static const int TYPE_BIRCH = LeafTile::BIRCH_LEAF;
|
||||
static const int TYPE_JUNGLE = LeafTile::JUNGLE_LEAF;
|
||||
static const int TYPE_ACACIA = LeafTile2::ACACIA_LEAF+4;
|
||||
static const int TYPE_DARK_OAK = LeafTile2::DARK_OAK_LEAF+4;
|
||||
|
||||
static const int SAPLING_NAMES_SIZE = 4;
|
||||
static const int SAPLING_NAMES_SIZE = 6;
|
||||
|
||||
static int SAPLING_NAMES[SAPLING_NAMES_SIZE];
|
||||
static int SAPLING_NAMES[SAPLING_NAMES_SIZE];
|
||||
|
||||
private:
|
||||
static const wstring TEXTURE_NAMES[];
|
||||
static const wstring TEXTURE_NAMES[];
|
||||
|
||||
Icon **icons;
|
||||
Icon **icons;
|
||||
|
||||
static const int TYPE_MASK = 3;
|
||||
static const int AGE_BIT = 8;
|
||||
static const int TYPE_MASK = 7;
|
||||
static const int AGE_BIT = 8;
|
||||
|
||||
protected:
|
||||
Sapling(int id);
|
||||
Sapling(int id);
|
||||
|
||||
public:
|
||||
virtual void updateDefaultShape(); // 4J Added override
|
||||
virtual void tick(Level *level, int x, int y, int z, Random *random);
|
||||
virtual void updateDefaultShape(); // 4J Added override
|
||||
virtual void tick(Level *level, int x, int y, int z, Random *random);
|
||||
|
||||
virtual Icon *getTexture(int face, int data);
|
||||
virtual void advanceTree(Level *level, int x, int y, int z, Random *random);
|
||||
void growTree(Level *level, int x, int y, int z, Random *random);
|
||||
virtual Icon *getTexture(int face, int data);
|
||||
virtual void advanceTree(Level *level, int x, int y, int z, Random *random);
|
||||
void growTree(Level *level, int x, int y, int z, Random *random);
|
||||
|
||||
virtual unsigned int getDescriptionId(int iData = -1);
|
||||
bool isSapling(Level *level, int x, int y, int z, int type);
|
||||
virtual unsigned int getDescriptionId(int iData = -1);
|
||||
bool isSapling(Level *level, int x, int y, int z, int type);
|
||||
|
||||
virtual bool fertilize(Level *level, int x, int y, int z);
|
||||
|
||||
protected:
|
||||
int getSpawnResourcesAuxValue(int data);
|
||||
int getSpawnResourcesAuxValue(int data);
|
||||
|
||||
public:
|
||||
void registerIcons(IconRegister *iconRegister);
|
||||
};
|
||||
void registerIcons(IconRegister *iconRegister);
|
||||
};
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
#include "stdafx.h"
|
||||
#include "net.minecraft.world.level.h"
|
||||
#include "net.minecraft.world.level.tile.h"
|
||||
#include "net.minecraft.world.level.levelgen.feature.h"
|
||||
#include "net.minecraft.world.h"
|
||||
|
||||
#include "SavannaTreeFeature.h"
|
||||
#include "DarkOakFeature.h"
|
||||
#include "Sapling2.h"
|
||||
|
||||
|
||||
int Sapling2::SAPLING_NAMES[SAPLING_NAMES_SIZE] = {
|
||||
IDS_TILE_SAPLING_ACACIA,
|
||||
IDS_TILE_SAPLING_DARK_OAK
|
||||
};
|
||||
|
||||
const wstring Sapling2::TEXTURE_NAMES[] = { L"sapling_acacia", L"sapling_dark_oak" };
|
||||
|
||||
Sapling2::Sapling2(int id) : Bush(id)
|
||||
{
|
||||
this->updateDefaultShape();
|
||||
icons = nullptr;
|
||||
}
|
||||
|
||||
void Sapling2::updateDefaultShape()
|
||||
{
|
||||
float ss = 0.4f;
|
||||
this->setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, ss * 2, 0.5f + ss);
|
||||
}
|
||||
|
||||
bool Sapling2::isSapling(Level *level, int x, int y, int z, int type)
|
||||
{
|
||||
return level->getTile(x, y, z) == this->id && (level->getData(x, y, z) & TYPE_MASK) == type;
|
||||
}
|
||||
|
||||
void Sapling2::tick(Level *level, int x, int y, int z, Random *random)
|
||||
{
|
||||
if (level->isClientSide) return;
|
||||
Bush::tick(level, x, y, z, random);
|
||||
|
||||
if (level->getRawBrightness(x, y + 1, z) >= 9 && random->nextInt(7) == 0)
|
||||
{
|
||||
this->growTree(level, x, y, z, random);
|
||||
}
|
||||
}
|
||||
|
||||
Icon *Sapling2::getTexture(int face, int data)
|
||||
{
|
||||
|
||||
if (icons == nullptr)
|
||||
{
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int type = data & TYPE_MASK;
|
||||
if (type < 0 || type >= SAPLING_NAMES_SIZE) type = 0;
|
||||
return icons[type];
|
||||
}
|
||||
|
||||
void Sapling2::registerIcons(IconRegister *iconRegister)
|
||||
{
|
||||
icons = new Icon*[SAPLING_NAMES_SIZE];
|
||||
for (int i = 0; i < SAPLING_NAMES_SIZE; ++i)
|
||||
{
|
||||
icons[i] = iconRegister->registerIcon(TEXTURE_NAMES[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void Sapling2::growTree(Level *level, int x, int y, int z, Random *random)
|
||||
{
|
||||
int data = level->getData(x, y, z) & TYPE_MASK;
|
||||
Feature *f = nullptr;
|
||||
int ox = 0, oz = 0;
|
||||
bool multiblock = false;
|
||||
|
||||
if (data == TYPE_ACACIA)
|
||||
{
|
||||
f = new SavannaTreeFeature(true);
|
||||
}
|
||||
else if (data == TYPE_DARK_OAK)
|
||||
{
|
||||
|
||||
for (ox = 0; ox >= -1; ox--)
|
||||
{
|
||||
for (oz = 0; oz >= -1; oz--)
|
||||
{
|
||||
if (isSapling(level, x + ox, y, z + oz, TYPE_DARK_OAK) &&
|
||||
isSapling(level, x + ox + 1, y, z + oz, TYPE_DARK_OAK) &&
|
||||
isSapling(level, x + ox, y, z + oz + 1, TYPE_DARK_OAK) &&
|
||||
isSapling(level, x + ox + 1, y, z + oz + 1, TYPE_DARK_OAK))
|
||||
{
|
||||
f = new DarkOakFeature(true);
|
||||
multiblock = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (f != nullptr) break;
|
||||
}
|
||||
if (f == nullptr) return;
|
||||
}
|
||||
|
||||
// Deletion
|
||||
if (multiblock)
|
||||
{
|
||||
level->setTileAndData(x + ox, y, z + oz, 0, 0, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox + 1, y, z + oz, 0, 0, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox, y, z + oz + 1, 0, 0, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox + 1, y, z + oz + 1, 0, 0, Tile::UPDATE_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
level->setTileAndData(x, y, z, 0, 0, Tile::UPDATE_NONE);
|
||||
}
|
||||
|
||||
// Generation
|
||||
if (f != nullptr)
|
||||
{
|
||||
if (!f->place(level, random, x + ox, y, z + oz))
|
||||
{
|
||||
if (multiblock)
|
||||
{
|
||||
level->setTileAndData(x + ox, y, z + oz, id, data, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox + 1, y, z + oz, id, data, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox, y, z + oz + 1, id, data, Tile::UPDATE_NONE);
|
||||
level->setTileAndData(x + ox + 1, y, z + oz + 1, id, data, Tile::UPDATE_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
level->setTileAndData(x, y, z, id, data, Tile::UPDATE_NONE);
|
||||
}
|
||||
}
|
||||
delete f;
|
||||
}
|
||||
}
|
||||
|
||||
bool Sapling2::fertilize(Level *level, int x, int y, int z)
|
||||
{
|
||||
this->growTree(level, x, y, z, level->random);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "LeafTile2.h"
|
||||
#include "Bush.h"
|
||||
#include "Sapling.h"
|
||||
|
||||
class Sapling2 : public Bush
|
||||
{
|
||||
friend class Tile;
|
||||
public:
|
||||
|
||||
static const int TYPE_ACACIA = 0;
|
||||
static const int TYPE_DARK_OAK = 1;
|
||||
|
||||
static const int SAPLING_NAMES_SIZE = 2;
|
||||
static int SAPLING_NAMES[SAPLING_NAMES_SIZE];
|
||||
|
||||
private:
|
||||
static const wstring TEXTURE_NAMES[];
|
||||
Icon **icons;
|
||||
|
||||
static const int TYPE_MASK = 7;
|
||||
static const int AGE_BIT = 8;
|
||||
|
||||
protected:
|
||||
Sapling2(int id);
|
||||
|
||||
bool isSapling(Level *level, int x, int y, int z, int type);
|
||||
public:
|
||||
virtual void updateDefaultShape();
|
||||
virtual void tick(Level *level, int x, int y, int z, Random *random);
|
||||
virtual Icon *getTexture(int face, int data);
|
||||
void growTree(Level *level, int x, int y, int z, Random *random);
|
||||
virtual bool fertilize(Level *level, int x, int y, int z);
|
||||
|
||||
virtual void registerIcons(IconRegister *iconRegister);
|
||||
};
|
||||
|
|
@ -52,7 +52,7 @@ Tile *Tile::dirt = nullptr;
|
|||
Tile *Tile::cobblestone = nullptr;
|
||||
Tile *Tile::wood = nullptr;
|
||||
Tile *Tile::sapling = nullptr;
|
||||
Tile *Tile::sapling2 = nullptr;
|
||||
//Tile *Tile::sapling2 = nullptr;
|
||||
Tile *Tile::unbreakable = nullptr;
|
||||
LiquidTile *Tile::water = nullptr;
|
||||
Tile *Tile::calmWater = nullptr;
|
||||
|
|
@ -300,8 +300,8 @@ void Tile::staticCtor()
|
|||
Tile::dirt = (new DirtTile(3)) ->setDestroyTime(0.5f)->setSoundType(Tile::SOUND_GRAVEL)->setIconName(L"dirt")->setDescriptionId(IDS_TILE_DIRT)->setUseDescriptionId(IDS_DESC_DIRT);
|
||||
Tile::cobblestone = (new Tile(4, Material::stone)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"cobblestone")->setDescriptionId(IDS_TILE_STONE_BRICK)->setUseDescriptionId(IDS_DESC_STONE_BRICK);
|
||||
Tile::wood = (new WoodTile(5)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_structwoodstuff, Item::eMaterial_wood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"planks")->setDescriptionId(IDS_TILE_OAKWOOD_PLANKS)->sendTileData()->setUseDescriptionId(IDS_DESC_WOODENPLANKS);
|
||||
Tile::sapling = (new Sapling(6)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"sapling")->setDescriptionId(IDS_TILE_SAPLING)->sendTileData()->setUseDescriptionId(IDS_DESC_SAPLING)->disableMipmap();
|
||||
Tile::sapling2 = (new Sapling2(199)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"sapling2")->setDescriptionId(IDS_TILE_SAPLING)->sendTileData()->setUseDescriptionId(IDS_DESC_SAPLING)->disableMipmap();
|
||||
Tile::sapling = (new Sapling(6))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"sapling")->setDescriptionId(IDS_TILE_SAPLING)->sendTileData()->setUseDescriptionId(IDS_DESC_SAPLING)->disableMipmap();
|
||||
//Tile::sapling2 = (new Sapling2(199)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"sapling2")->setDescriptionId(IDS_TILE_SAPLING)->sendTileData()->setUseDescriptionId(IDS_DESC_SAPLING)->disableMipmap();
|
||||
Tile::unbreakable = (new Tile(7, Material::stone)) ->setIndestructible()->setExplodeable(6000000)->setSoundType(Tile::SOUND_STONE)->setIconName(L"bedrock")->setDescriptionId(IDS_TILE_BEDROCK)->setNotCollectStatistics()->setUseDescriptionId(IDS_DESC_BEDROCK);
|
||||
Tile::water = static_cast<LiquidTile *>((new LiquidTileDynamic(8, Material::water))->setDestroyTime(100.0f)->setLightBlock(3)->setIconName(L"water_flow")->setDescriptionId(IDS_TILE_WATER)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_WATER));
|
||||
Tile::calmWater = (new LiquidTileStatic(9, Material::water)) ->setDestroyTime(100.0f)->setLightBlock(3)->setIconName(L"water_still")->setDescriptionId(IDS_TILE_WATER)->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_WATER);
|
||||
|
|
@ -529,8 +529,8 @@ void Tile::staticCtor()
|
|||
Item::items[stoneSlab_Id] = ( new StoneSlabTileItem(Tile::stoneSlab_Id - 256, Tile::stoneSlabHalf, Tile::stoneSlab, true))->setIconName(L"stoneSlab")->setDescriptionId(IDS_DESC_STONESLAB)->setUseDescriptionId(IDS_DESC_SLAB);
|
||||
Item::items[woodSlabHalf_Id] = ( new StoneSlabTileItem(Tile::woodSlabHalf_Id - 256, Tile::woodSlabHalf, Tile::woodSlab, false))->setIconName(L"woodSlab")->setDescriptionId(IDS_DESC_WOODSLAB)->setUseDescriptionId(IDS_DESC_WOODSLAB);
|
||||
Item::items[woodSlab_Id] = ( new StoneSlabTileItem(Tile::woodSlab_Id - 256, Tile::woodSlabHalf, Tile::woodSlab, true))->setIconName(L"woodSlab")->setDescriptionId(IDS_DESC_WOODSLAB)->setUseDescriptionId(IDS_DESC_WOODSLAB);
|
||||
Item::items[sapling_Id] = ( new MultiTextureTileItem(Tile::sapling_Id - 256, Tile::sapling, Sapling::SAPLING_NAMES, 4) )->setIconName(L"sapling")->setDescriptionId(IDS_TILE_SAPLING)->setUseDescriptionId(IDS_DESC_SAPLING);
|
||||
Item::items[sapling2_Id] = ( new MultiTextureTileItem(Tile::sapling2_Id - 256, Tile::sapling2, Sapling2::SAPLING_NAMES, 2) )->setIconName(L"sapling2")->setDescriptionId(IDS_TILE_SAPLING)->setUseDescriptionId(IDS_DESC_SAPLING);
|
||||
Item::items[sapling_Id] = (new MultiTextureTileItem(Tile::sapling_Id - 256, Tile::sapling, Sapling::SAPLING_NAMES, Sapling::SAPLING_NAMES_SIZE))->setIconName(L"sapling")->setDescriptionId(IDS_TILE_SAPLING)->setUseDescriptionId(IDS_DESC_SAPLING);;
|
||||
//Item::items[sapling2_Id] = ( new MultiTextureTileItem(Tile::sapling2_Id - 256, Tile::sapling2, Sapling2::SAPLING_NAMES, 2) )->setIconName(L"sapling2")->setDescriptionId(IDS_TILE_SAPLING)->setUseDescriptionId(IDS_DESC_SAPLING);
|
||||
Item::items[leaves_Id] = ( new LeafTileItem(Tile::leaves_Id - 256) )->setIconName(L"leaves")->setDescriptionId(IDS_TILE_LEAVES)->setUseDescriptionId(IDS_DESC_LEAVES);
|
||||
Item::items[leaves2_Id] = ( new LeafTileItem(Tile::leaves2_Id - 256) )->setIconName(L"leaves_acacia")->setDescriptionId(IDS_TILE_LEAVES)->setUseDescriptionId(IDS_DESC_LEAVES);
|
||||
Item::items[vine_Id] = ( new ColoredTileItem(Tile::vine_Id - 256, false))->setDescriptionId(IDS_TILE_VINE)->setUseDescriptionId(IDS_DESC_VINE);
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ public:
|
|||
static const int cobblestone_Id = 4;
|
||||
static const int wood_Id = 5;
|
||||
static const int sapling_Id = 6;
|
||||
static const int sapling2_Id = 199;//should go inside sapling.
|
||||
//static const int sapling2_Id = 199;//should go inside sapling.
|
||||
static const int unbreakable_Id = 7;
|
||||
static const int water_Id = 8;
|
||||
static const int calmWater_Id = 9;
|
||||
|
|
@ -404,7 +404,7 @@ public:
|
|||
static Tile *cobblestone;
|
||||
static Tile *wood;
|
||||
static Tile *sapling;
|
||||
static Tile *sapling2;
|
||||
//static Tile *sapling2;
|
||||
static Tile *unbreakable;
|
||||
static LiquidTile *water;
|
||||
static Tile *calmWater;
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@
|
|||
#include "RotatedPillarTile.h"
|
||||
#include "SandStoneTile.h"
|
||||
#include "Sapling.h"
|
||||
#include "Sapling2.h"
|
||||
|
||||
#include "SignTile.h"
|
||||
#include "SkullTile.h"
|
||||
#include "SmoothStoneBrickTile.h"
|
||||
|
|
|
|||
Loading…
Reference in a new issue