mirror of
https://github.com/celisej567/mcpe.git
synced 2026-01-05 18:10:09 +03:00
* Add Saplings
* Add headers to CreateWorldScreen and SavingWorldScreen
This commit is contained in:
@@ -115,8 +115,8 @@ enum eTileID
|
||||
TILE_DIRT,
|
||||
TILE_STONEBRICK,
|
||||
TILE_WOOD,
|
||||
|
||||
TILE_BEDROCK = 7,
|
||||
TILE_SAPLING,
|
||||
TILE_BEDROCK,
|
||||
|
||||
TILE_WATER = 8,
|
||||
TILE_WATER_CALM,
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "CreateWorldScreen.hpp"
|
||||
#include "SelectWorldScreen.hpp"
|
||||
#include "ProgressScreen.hpp"
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Screen.hpp"
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "SavingWorldScreen.hpp"
|
||||
#include "RenameMPLevelScreen.hpp"
|
||||
#include "StartMenuScreen.hpp"
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Screen.hpp"
|
||||
|
||||
@@ -156,7 +156,7 @@ Inventory::Inventory(Player* pPlayer)
|
||||
m_items[41] = Tile::clay->m_ID;
|
||||
m_items[42] = Tile::farmland->m_ID;
|
||||
m_items[43] = Tile::lapisOre->m_ID;
|
||||
m_items[44] = Item::door_iron->m_itemID;
|
||||
m_items[44] = Tile::sapling->m_ID;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
57
source/World/Tile/Sapling.cpp
Normal file
57
source/World/Tile/Sapling.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#include "Tile.hpp"
|
||||
#include "Level.hpp"
|
||||
|
||||
Sapling::Sapling(int id, int texture) : Bush(id, texture)
|
||||
{
|
||||
}
|
||||
|
||||
int Sapling::getTexture(int dir, int data)
|
||||
{
|
||||
return TEXTURE_SAPLING; // we don't have the other saplings' textures...
|
||||
}
|
||||
|
||||
void Sapling::tick(Level* level, int x, int y, int z, Random* random)
|
||||
{
|
||||
Bush::tick(level, x, y, z, random);
|
||||
|
||||
if (level->getRawBrightness(x, y, z) > 8 && random->nextInt(7) == 0)
|
||||
{
|
||||
int data = level->getData(x, y, z);
|
||||
|
||||
if (data & 8)
|
||||
growTree(level, x, y, z, random);
|
||||
else
|
||||
level->setDataNoUpdate(x, y, z, data | 8);
|
||||
}
|
||||
}
|
||||
|
||||
bool Sapling::maybeGrowTree(Level* level, int x, int y, int z, Random* random)
|
||||
{
|
||||
// this is fine... these are not heavy at all
|
||||
TreeFeature treeFeature;
|
||||
BirchFeature birchFeature;
|
||||
SpruceFeature spruceFeature;
|
||||
|
||||
Feature* pFeature = &treeFeature;
|
||||
|
||||
int data = level->getData(x, y, z);
|
||||
switch (data)
|
||||
{
|
||||
case 1:
|
||||
pFeature = &birchFeature;
|
||||
break;
|
||||
case 2:
|
||||
pFeature = &spruceFeature;
|
||||
break;
|
||||
}
|
||||
|
||||
return treeFeature.place(level, random, x, y, z);
|
||||
}
|
||||
|
||||
void Sapling::growTree(Level* level, int x, int y, int z, Random* random)
|
||||
{
|
||||
level->setTileNoUpdate(x, y, z, TILE_AIR);
|
||||
|
||||
if (!maybeGrowTree(level, x, y, z, random))
|
||||
level->setTileNoUpdate(x, y, z, m_ID);
|
||||
}
|
||||
@@ -606,6 +606,12 @@ void Tile::initTiles()
|
||||
->setSoundType(Tile::SOUND_CLOTH)
|
||||
->setDescriptionId("cloth");
|
||||
|
||||
Tile::sapling = (new Sapling(TILE_SAPLING, TEXTURE_SAPLING))
|
||||
->init()
|
||||
->setDestroyTime(0.0f)
|
||||
->setSoundType(Tile::SOUND_GRASS)
|
||||
->setDescriptionId("sapling");
|
||||
|
||||
for (int i = 0; i < C_MAX_TILES; i++)
|
||||
{
|
||||
if (Tile::tiles[i])
|
||||
@@ -1212,4 +1218,5 @@ Tile
|
||||
*Tile::stairs_wood,
|
||||
*Tile::stairs_stone,
|
||||
*Tile::door_wood,
|
||||
*Tile::door_iron;
|
||||
*Tile::door_iron,
|
||||
*Tile::sapling;
|
||||
|
||||
@@ -198,7 +198,8 @@ public: // static variables
|
||||
* stairs_wood,
|
||||
* stairs_stone,
|
||||
* door_wood,
|
||||
* door_iron;
|
||||
* door_iron,
|
||||
* sapling;
|
||||
|
||||
public:
|
||||
int m_TextureFrame = 1;
|
||||
@@ -365,18 +366,29 @@ class Bush : public Tile
|
||||
public:
|
||||
Bush(int id, int texture);
|
||||
|
||||
bool canSurvive(Level*, int x, int y, int z) override;
|
||||
AABB* getAABB(Level*, int x, int y, int z) override;
|
||||
int getRenderShape() override;
|
||||
bool isCubeShaped() override;
|
||||
bool isSolidRender() override;
|
||||
bool mayPlace(Level*, int x, int y, int z) override;
|
||||
void tick(Level*, int x, int y, int z, Random*) override;
|
||||
void neighborChanged(Level*, int x, int y, int z, int dir) override;
|
||||
virtual bool canSurvive(Level*, int x, int y, int z) override;
|
||||
virtual AABB* getAABB(Level*, int x, int y, int z) override;
|
||||
virtual int getRenderShape() override;
|
||||
virtual bool isCubeShaped() override;
|
||||
virtual bool isSolidRender() override;
|
||||
virtual bool mayPlace(Level*, int x, int y, int z) override;
|
||||
virtual void tick(Level*, int x, int y, int z, Random*) override;
|
||||
virtual void neighborChanged(Level*, int x, int y, int z, int dir) override;
|
||||
|
||||
void checkAlive(Level*, int x, int y, int z);
|
||||
};
|
||||
|
||||
class Sapling : public Bush
|
||||
{
|
||||
public:
|
||||
Sapling(int id, int texture);
|
||||
|
||||
int getTexture(int dir, int data) override;
|
||||
void tick(Level*, int x, int y, int z, Random*) override;
|
||||
|
||||
void growTree(Level*, int x, int y, int z, Random*);
|
||||
bool maybeGrowTree(Level*, int x, int y, int z, Random*);
|
||||
};
|
||||
|
||||
class TopSnowTile : public Tile
|
||||
{
|
||||
|
||||
@@ -514,6 +514,7 @@
|
||||
<ClCompile Include="..\source\World\Tile\ReedTile.cpp" />
|
||||
<ClCompile Include="..\source\World\Tile\SandStoneTile.cpp" />
|
||||
<ClCompile Include="..\source\World\Tile\SandTile.cpp" />
|
||||
<ClCompile Include="..\source\World\Tile\Sapling.cpp" />
|
||||
<ClCompile Include="..\source\World\Tile\StairTile.cpp" />
|
||||
<ClCompile Include="..\source\World\Tile\StoneSlabTile.cpp" />
|
||||
<ClCompile Include="..\source\World\Tile\StoneTile.cpp" />
|
||||
|
||||
Reference in New Issue
Block a user