aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/CactusTile.cpp
diff options
context:
space:
mode:
authordaoge <3523206925@qq.com>2026-03-03 03:04:10 +0800
committerGitHub <noreply@github.com>2026-03-03 03:04:10 +0800
commitb3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch)
tree267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/CactusTile.cpp
parent84c31a2331f7a0ec85b9d438992e244f60e5020f (diff)
feat: TU19 (Dec 2014) Features & Content (#155)
* try to resolve merge conflict * feat: TU19 (Dec 2014) Features & Content (#32) * December 2014 files * Working release build * Fix compilation issues * Add sound to Windows64Media * Add DLC content and force Tutorial DLC * Revert "Add DLC content and force Tutorial DLC" This reverts commit 97a43994725008e35fceb984d5549df9c8cea470. * Disable broken light packing * Disable breakpoint during DLC texture map load Allows DLC loading but the DLC textures are still broken * Fix post build not working * ... * fix vs2022 build * fix cmake build --------- Co-authored-by: Loki <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.World/CactusTile.cpp')
-rw-r--r--Minecraft.World/CactusTile.cpp49
1 files changed, 25 insertions, 24 deletions
diff --git a/Minecraft.World/CactusTile.cpp b/Minecraft.World/CactusTile.cpp
index b72570e1..cdce293c 100644
--- a/Minecraft.World/CactusTile.cpp
+++ b/Minecraft.World/CactusTile.cpp
@@ -12,7 +12,7 @@ CactusTile::CactusTile(int id) : Tile(id, Material::cactus,isSolidRender())
{
setTicking(true);
iconTop = NULL;
- iconBottom = NULL;
+ iconBottom = NULL;
}
void CactusTile::tick(Level *level, int x, int y, int z, Random *random)
@@ -29,11 +29,13 @@ void CactusTile::tick(Level *level, int x, int y, int z, Random *random)
int age = level->getData(x, y, z);
if (age == 15)
{
- level->setTile(x, y + 1, z, id);
- level->setData(x, y, z, 0);
- } else
+ level->setTileAndUpdate(x, y + 1, z, id);
+ level->setData(x, y, z, 0, Tile::UPDATE_NONE);
+ neighborChanged(level, x, y + 1, z, id);
+ }
+ else
{
- level->setData(x, y, z, age + 1);
+ level->setData(x, y, z, age + 1, Tile::UPDATE_NONE);
}
}
}
@@ -41,22 +43,22 @@ void CactusTile::tick(Level *level, int x, int y, int z, Random *random)
AABB *CactusTile::getAABB(Level *level, int x, int y, int z)
{
- float r = 1 / 16.0f;
- return AABB::newTemp(x + r, y, z + r, x + 1 - r, y + 1 - r, z + 1 - r);
+ float r = 1 / 16.0f;
+ return AABB::newTemp(x + r, y, z + r, x + 1 - r, y + 1 - r, z + 1 - r);
}
AABB *CactusTile::getTileAABB(Level *level, int x, int y, int z)
{
- float r = 1 / 16.0f;
- return AABB::newTemp(x + r, y, z + r, x + 1 - r, y + 1, z + 1 - r);
+ float r = 1 / 16.0f;
+ return AABB::newTemp(x + r, y, z + r, x + 1 - r, y + 1, z + 1 - r);
}
Icon *CactusTile::getTexture(int face, int data)
{
- if (face == Facing::UP) return iconTop;
- if (face == Facing::DOWN) return iconBottom;
- else return icon;
+ if (face == Facing::UP) return iconTop;
+ if (face == Facing::DOWN) return iconBottom;
+ else return icon;
}
bool CactusTile::isCubeShaped()
@@ -76,28 +78,27 @@ int CactusTile::getRenderShape()
bool CactusTile::mayPlace(Level *level, int x, int y, int z)
{
- if (!Tile::mayPlace(level, x, y, z)) return false;
+ if (!Tile::mayPlace(level, x, y, z)) return false;
- return canSurvive(level, x, y, z);
+ return canSurvive(level, x, y, z);
}
void CactusTile::neighborChanged(Level *level, int x, int y, int z, int type)
{
- if (!canSurvive(level, x, y, z))
+ if (!canSurvive(level, x, y, z))
{
- this->spawnResources(level, x, y, z, level->getData(x, y, z), 0);
- level->setTile(x, y, z, 0);
+ level->destroyTile(x, y, z, true);
}
}
bool CactusTile::canSurvive(Level *level, int x, int y, int z)
{
- if (level->getMaterial(x - 1, y, z)->isSolid()) return false;
- if (level->getMaterial(x + 1, y, z)->isSolid()) return false;
- if (level->getMaterial(x, y, z - 1)->isSolid()) return false;
- if (level->getMaterial(x, y, z + 1)->isSolid()) return false;
- int below = level->getTile(x, y - 1, z);
- return below == Tile::cactus_Id || below == Tile::sand_Id;
+ if (level->getMaterial(x - 1, y, z)->isSolid()) return false;
+ if (level->getMaterial(x + 1, y, z)->isSolid()) return false;
+ if (level->getMaterial(x, y, z - 1)->isSolid()) return false;
+ if (level->getMaterial(x, y, z + 1)->isSolid()) return false;
+ int below = level->getTile(x, y - 1, z);
+ return below == Tile::cactus_Id || below == Tile::sand_Id;
}
void CactusTile::entityInside(Level *level, int x, int y, int z, shared_ptr<Entity> entity)
@@ -114,5 +115,5 @@ void CactusTile::registerIcons(IconRegister *iconRegister)
bool CactusTile::shouldTileTick(Level *level, int x,int y,int z)
{
- return level->isEmptyTile(x, y + 1, z);
+ return level->isEmptyTile(x, y + 1, z);
}