diff --git a/Minecraft.World/SandTile.cpp b/Minecraft.World/SandTile.cpp index eb273636..33b874bc 100644 --- a/Minecraft.World/SandTile.cpp +++ b/Minecraft.World/SandTile.cpp @@ -5,124 +5,31 @@ #include "FireTile.h" #include "net.minecraft.world.h" -const unsigned int SandTile::SAND_NAMES[SAND_NAMES_LENGTH] = { IDS_TILE_SAND, -IDS_TILE_SAND}; +const unsigned int SandTile::SAND_NAMES[SAND_NAMES_LENGTH] = { IDS_TILE_SAND, IDS_TILE_SAND }; +const wstring SandTile::TEXTURE_NAMES[] = { L"sand", L"red_sand" }; -const wstring SandTile::TEXTURE_NAMES[] = { L"sand", - L"red_sand" }; - -bool SandTile::instaFall = false; - -SandTile::SandTile(int type, bool isSolidRender) : Tile(type, Material::sand, isSolidRender) +SandTile::SandTile(int type, bool isSolidRender) : HeavyTile(type, Material::sand, isSolidRender) { - icons = nullptr; + icons = nullptr; } int SandTile::getSpawnResourcesAuxValue(int data) { - if (data < 0 || data >= SAND_NAMES_LENGTH) data = 0; - - return data; -} - -void SandTile::onPlace(Level* level, int x, int y, int z) -{ - level->addToTickNextTick(x, y, z, id, getTickDelay(level)); -} - -void SandTile::neighborChanged(Level* level, int x, int y, int z, int type) -{ - level->addToTickNextTick(x, y, z, id, getTickDelay(level)); -} - -void SandTile::tick(Level* level, int x, int y, int z, Random* random) -{ - if (!level->isClientSide) - { - checkSlide(level, x, y, z); - } -} - -void SandTile::checkSlide(Level* level, int x, int y, int z) -{ - int x2 = x; - int y2 = y; - int z2 = z; - - if (level->isNew || !level->hasChunksAt(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1)) - { - return; - } - - if (y2 > 0 && isFree(level, x2, y2 - 1, z2)) - { - int r = 32; - - if (instaFall || !level->hasChunksAt(x - r, y - r, z - r, x + r, y + r, z + r)) - { - level->removeTile(x, y, z); - while (y > 0 && isFree(level, x, y - 1, z)) - y--; - if (y > 0) - { - level->setTileAndUpdate(x, y, z, id); - } - } - else if (!level->isClientSide) - { - // 4J added - don't do anything just now if we can't create any new falling tiles - if (!level->newFallingTileAllowed()) - { - level->addToTickNextTick(x, y, z, id, getTickDelay(level)); - return; - } - - shared_ptr e = std::make_shared(level, x + 0.5f, y + 0.5f, z + 0.5f, id, level->getData(x, y, z)); - falling(e); - level->addEntity(e); - } - } -} - -void SandTile::falling(shared_ptr entity) -{ -} - -int SandTile::getTickDelay(Level* level) -{ - return 2; -} - -bool SandTile::isFree(Level* level, int x, int y, int z) -{ - int t = level->getTile(x, y, z); - if (t == 0) return true; - if (t == Tile::fire_Id) return true; - Material* material = Tile::tiles[t]->material; - if (material == Material::water) return true; - if (material == Material::lava) return true; - return false; -} - -void SandTile::onLand(Level* level, int xt, int yt, int zt, int data) -{ + if (data < 0 || data >= SAND_NAMES_LENGTH) data = 0; + return data; } Icon* SandTile::getTexture(int face, int data) { - if (data < 0 || data >= SAND_NAMES_LENGTH) - { - data = 0; - } - return icons[data]; + if (data < 0 || data >= SAND_NAMES_LENGTH) data = 0; + return icons[data]; } void SandTile::registerIcons(IconRegister* iconRegister) { - icons = new Icon * [SAND_NAMES_LENGTH]; - - for (int i = 0; i < SAND_NAMES_LENGTH; i++) - { - icons[i] = iconRegister->registerIcon(TEXTURE_NAMES[i]); - } + icons = new Icon * [SAND_NAMES_LENGTH]; + for (int i = 0; i < SAND_NAMES_LENGTH; i++) + { + icons[i] = iconRegister->registerIcon(TEXTURE_NAMES[i]); + } } \ No newline at end of file diff --git a/Minecraft.World/SandTile.h b/Minecraft.World/SandTile.h index bb81fb91..c9200d15 100644 --- a/Minecraft.World/SandTile.h +++ b/Minecraft.World/SandTile.h @@ -1,36 +1,19 @@ #pragma once -#include "Tile.h" +#include "HeavyTile.h" -class Random; -class Level; -class FallingTile; - -class SandTile : public Tile +class SandTile : public HeavyTile { public: - static bool instaFall; + static const int RED_SAND = 1; + static const int SAND_NAMES_LENGTH = 2; + static const unsigned int SAND_NAMES[SAND_NAMES_LENGTH]; + static const wstring TEXTURE_NAMES[]; - static const int RED_SAND = 1; + SandTile(int type, bool isSolidRender = true); + virtual int getSpawnResourcesAuxValue(int data) override; + virtual Icon* getTexture(int face, int data) override; + void registerIcons(IconRegister* iconRegister) override; - static const int SAND_NAMES_LENGTH = 2; - - static const unsigned int SAND_NAMES[SAND_NAMES_LENGTH]; - static const wstring TEXTURE_NAMES[]; - - SandTile(int type, bool isSolidRender = true); - virtual void onPlace(Level* level, int x, int y, int z); - virtual void neighborChanged(Level* level, int x, int y, int z, int type); - virtual void tick(Level* level, int x, int y, int z, Random* random); private: - Icon** icons; - void checkSlide(Level* level, int x, int y, int z); -protected: - virtual void falling(shared_ptr entity); -public: - virtual int getTickDelay(Level* level); - static bool isFree(Level* level, int x, int y, int z); - virtual int getSpawnResourcesAuxValue(int data); - virtual void onLand(Level* level, int xt, int yt, int zt, int data); - virtual Icon* getTexture(int face, int data); - void registerIcons(IconRegister* iconRegister); -}; + Icon** icons; +}; \ No newline at end of file diff --git a/Minecraft.World/Tile.h b/Minecraft.World/Tile.h index 9f194c08..aea8b5b6 100644 --- a/Minecraft.World/Tile.h +++ b/Minecraft.World/Tile.h @@ -404,8 +404,26 @@ public: static const int jungle_door_Id = 195; static const int acacia_door_Id = 196; static const int dark_oak_door_Id = 197; - - + //end_rod 198 + //chorus_plant 199 + //chorus_flower 200 + //purpur_block 201 + //purpur_pillar 202 + //purpur_stairs 203 + //purpur_double_slab 204 + //purpur_slab 205 + //end_bricks 206 + //beetroots 207 + //grass_path 208 + //end_gateway 209 + //frosted_ice 212 + //magma 213 + //nether_wart_block 214 + //red_nether_brick 215 + //bone_block 216 + //structure_void 217 + // + // static Tile *stone;