From 4c8e38c721f081a1205fb958437c2428c228f228 Mon Sep 17 00:00:00 2001 From: Lord_Cambion Date: Mon, 20 Apr 2026 02:24:41 +0200 Subject: [PATCH] feat: stoneslab2 fully implemented stoneslab2 with craftings and revisited existing slabs according to wii u decomp todo:Material.cs --- .../Common/UI/IUIScene_CreativeMenu.cpp | 1 + .../Windows64Media/loc/stringsGeneric.xml | 3 + Minecraft.World/Facing.cpp | 7 +- Minecraft.World/Facing.h | 1 + Minecraft.World/HalfSlabTile.cpp | 228 ++++++++++-------- Minecraft.World/HalfSlabTile.h | 70 ++++-- Minecraft.World/Recipes.cpp | 14 ++ Minecraft.World/StoneSlabTile.cpp | 104 ++++---- Minecraft.World/StoneSlabTile.h | 60 +++-- Minecraft.World/StoneSlabTile2.cpp | 61 +++++ Minecraft.World/StoneSlabTile2.h | 44 ++++ Minecraft.World/StructureRecipies.cpp | 31 +++ Minecraft.World/Tile.cpp | 22 +- Minecraft.World/Tile.h | 6 +- Minecraft.World/WoodSlabTile.cpp | 37 ++- Minecraft.World/WoodSlabTile.h | 47 ++-- Minecraft.World/cmake/sources/Common.cmake | 2 + .../net.minecraft.world.level.tile.h | 1 + 18 files changed, 490 insertions(+), 249 deletions(-) create mode 100644 Minecraft.World/StoneSlabTile2.cpp create mode 100644 Minecraft.World/StoneSlabTile2.h diff --git a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp index ce90b26f..29125a97 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp @@ -159,6 +159,7 @@ void IUIScene_CreativeMenu::staticCtor() ITEM_AUX(Tile::stoneSlabHalf_Id,StoneSlabTile::SMOOTHBRICK_SLAB) ITEM_AUX(Tile::stoneSlabHalf_Id,StoneSlabTile::NETHERBRICK_SLAB) ITEM_AUX(Tile::stoneSlabHalf_Id,StoneSlabTile::QUARTZ_SLAB) + ITEM_AUX(Tile::stone_slab2_Id ,StoneSlabTile2::RED_SANDSTONE_SLAB) ITEM(Tile::stairs_wood_Id) ITEM(Tile::stairs_birchwood_Id) ITEM(Tile::stairs_sprucewood_Id) diff --git a/Minecraft.Client/Windows64Media/loc/stringsGeneric.xml b/Minecraft.Client/Windows64Media/loc/stringsGeneric.xml index a4b3d375..6c2c33a3 100644 --- a/Minecraft.Client/Windows64Media/loc/stringsGeneric.xml +++ b/Minecraft.Client/Windows64Media/loc/stringsGeneric.xml @@ -9390,4 +9390,7 @@ All Ender Chests in a world are linked. Items placed into an Ender Chest are acc Luck of the Sea + + Red Sandstone Slab + diff --git a/Minecraft.World/Facing.cpp b/Minecraft.World/Facing.cpp index 33742e92..b6bb9310 100644 --- a/Minecraft.World/Facing.cpp +++ b/Minecraft.World/Facing.cpp @@ -21,4 +21,9 @@ const int Facing::STEP_Z[6] = 0, 0, -1, 1, 0, 0 }; -const wstring Facing::NAMES[] = {L"DOWN", L"UP", L"NORTH", L"SOUTH", L"WEST", L"EAST"}; \ No newline at end of file +const wstring Facing::NAMES[] = {L"DOWN", L"UP", L"NORTH", L"SOUTH", L"WEST", L"EAST"}; + +int Facing::getOpposite(int facing) +{ + return OPPOSITE_FACING[facing]; +} \ No newline at end of file diff --git a/Minecraft.World/Facing.h b/Minecraft.World/Facing.h index b257e4bf..922bd9d9 100644 --- a/Minecraft.World/Facing.h +++ b/Minecraft.World/Facing.h @@ -16,4 +16,5 @@ public: static const int STEP_Z[6]; static const wstring NAMES[]; + static int getOpposite(int facing); }; \ No newline at end of file diff --git a/Minecraft.World/HalfSlabTile.cpp b/Minecraft.World/HalfSlabTile.cpp index 13308b9a..e38b28c3 100644 --- a/Minecraft.World/HalfSlabTile.cpp +++ b/Minecraft.World/HalfSlabTile.cpp @@ -1,152 +1,172 @@ #include "stdafx.h" #include "HalfSlabTile.h" #include "net.minecraft.world.level.h" -#include "net.minecraft.world.level.biome.h" -#include "net.minecraft.world.item.h" -#include "net.minecraft.stats.h" +#include "net.minecraft.world.level.tile.h" +#include "net.minecraft.h" #include "Facing.h" - -HalfSlabTile::HalfSlabTile(int id, bool fullSize, Material *material) : Tile(id, material, fullSize) +HalfSlabTile::HalfSlabTile(int id, Material *material) + : Tile(id, material, true) { - this->fullSize = fullSize; - - if (fullSize) - { - solid[id] = true; - } - else - { - setShape(0, 0, 0, 1, 0.5f, 1); - } - setLightBlock(255); + + Tile::lightBlock[id] = 0xFF; } -void HalfSlabTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr forceEntity) // 4J added forceData, forceEntity param +void HalfSlabTile::DerivedInit() { - if (fullSize) - { - setShape(0, 0, 0, 1, 1, 1); - } - else - { - bool upper = (level->getData(x, y, z) & TOP_SLOT_BIT) != 0; - if (upper) - { - setShape(0, 0.5f, 0, 1, 1, 1); - } - else - { - setShape(0, 0, 0, 1, 0.5f, 1); - } - } + + if (!isFullSize()) + setShape(0.0f, 0.0f, 0.0f, 1.0f, 0.5f, 1.0f); + else + Tile::solid[id] = true; } -void HalfSlabTile::updateDefaultShape() +void HalfSlabTile::updateDefaultShape() { - if (fullSize) - { - setShape(0, 0, 0, 1, 1, 1); - } - else - { - setShape(0, 0, 0, 1, 0.5f, 1); - } + + if (isFullSize()) + setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); + else + setShape(0.0f, 0.0f, 0.0f, 1.0f, 0.5f, 1.0f); } -void HalfSlabTile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr source) +void HalfSlabTile::updateShape( + LevelSource *level, int x, int y, int z, + int forceData, shared_ptr forceEntity) { - updateShape(level, x, y, z); - Tile::addAABBs(level, x, y, z, box, boxes, source); + + if (isFullSize()) + { + setShape(0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); + return; + } + + int data = (forceData >= 0) ? forceData : level->getData(x, y, z); + bool isUpper = (data & TOP_SLOT_BIT) != 0; + + if (isUpper) + setShape(0.0f, 0.5f, 0.0f, 1.0f, 1.0f, 1.0f); + else + setShape(0.0f, 0.0f, 0.0f, 1.0f, 0.5f, 1.0f); } -bool HalfSlabTile::isSolidRender(bool isServerLevel) +void HalfSlabTile::addAABBs( + Level *level, int x, int y, int z, + AABB *box, AABBList *boxes, shared_ptr source) { - return fullSize; + + updateShape(level, x, y, z); + Tile::addAABBs(level, x, y, z, box, boxes, source); } -int HalfSlabTile::getPlacedOnFaceDataValue(Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, int itemValue) +bool HalfSlabTile::isSolidRender(bool isServerLevel) { - if (fullSize) return itemValue; - - if (face == Facing::DOWN || (face != Facing::UP && clickY > 0.5)) - { - return itemValue | TOP_SLOT_BIT; - } - return itemValue; + + return isFullSize() != 0; } -int HalfSlabTile::getResourceCount(Random *random) +bool HalfSlabTile::isSilkTouchable() { - if (fullSize) - { - return 2; - } - return 1; + + return false; } -int HalfSlabTile::getSpawnResourcesAuxValue(int data) +int HalfSlabTile::getResourceCount(Random *random) { - return data & TYPE_MASK; + + return isFullSize() ? 2 : 1; } -bool HalfSlabTile::isCubeShaped() +bool HalfSlabTile::isCubeShaped() { - return fullSize; + + return isFullSize() != 0; } -bool HalfSlabTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face) +bool HalfSlabTile::shouldRenderFace( + LevelSource *level, int x, int y, int z, int face) { - if (fullSize) return Tile::shouldRenderFace(level, x, y, z, face); + + if (isFullSize()) + return Tile::shouldRenderFace(level, x, y, z, face); - if (face != Facing::UP && face != Facing::DOWN && !Tile::shouldRenderFace(level, x, y, z, face)) - { - return false; - } + + if (face != Facing::UP && face != Facing::DOWN + && !Tile::shouldRenderFace(level, x, y, z, face)) + return false; - int ox = x, oy = y, oz = z; - ox += Facing::STEP_X[Facing::OPPOSITE_FACING[face]]; - oy += Facing::STEP_Y[Facing::OPPOSITE_FACING[face]]; - oz += Facing::STEP_Z[Facing::OPPOSITE_FACING[face]]; + int oppFace = Facing::getOpposite(face); + int nx = x, ny = y, nz = z; + + if (oppFace == Facing::DOWN) ny--; + if (oppFace == Facing::UP) ny++; + if (oppFace == Facing::NORTH) nz--; + if (oppFace == Facing::SOUTH) nz++; + if (oppFace == Facing::WEST) nx--; + if (oppFace == Facing::EAST) nx++; - boolean isUpper = (level->getData(ox, oy, oz) & TOP_SLOT_BIT) != 0; - if (isUpper) - { - if (face == Facing::DOWN) return true; - if (face == Facing::UP && Tile::shouldRenderFace(level, x, y, z, face)) return true; - return !(isHalfSlab(level->getTile(x, y, z)) && (level->getData(x, y, z) & TOP_SLOT_BIT) != 0); - } - else - { - if (face == Facing::UP) return true; - if (face == Facing::DOWN && Tile::shouldRenderFace(level, x, y, z, face)) return true; - return !(isHalfSlab(level->getTile(x, y, z)) && (level->getData(x, y, z) & TOP_SLOT_BIT) == 0); - } + int currentData = level->getData(x, y, z); + int neighborData = level->getData(nx, ny, nz); + int currentTile = level->getTile(x, y, z); + int neighborTile = level->getTile(nx, ny, nz); + + bool currentIsUpper = (currentData & TOP_SLOT_BIT) != 0; + bool neighborIsUpper = (neighborData & TOP_SLOT_BIT) != 0; + + bool currentIsSlab = isHalfSlab(currentTile); + bool neighborIsSlab = isHalfSlab(neighborTile); + + + if (neighborIsSlab && neighborIsUpper) + { + if (face == Facing::DOWN) + return true; + if (face == Facing::UP && !Tile::shouldRenderFace(level, x, y, z, face)) + return currentIsSlab && !currentIsUpper ? false : true; + return !(currentIsSlab && currentIsUpper); + } + + if (face == Facing::UP || (face == Facing::DOWN + && Tile::shouldRenderFace(level, x, y, z, face))) + return true; + + return !(currentIsSlab && !currentIsUpper); } -bool HalfSlabTile::isHalfSlab(int tileId) +int HalfSlabTile::getSpawnResourcesAuxValue(int data) { - return tileId == Tile::stoneSlabHalf_Id || tileId == Tile::woodSlabHalf_Id; + return data & TYPE_MASK; } int HalfSlabTile::cloneTileData(Level *level, int x, int y, int z) { - return Tile::cloneTileData(level, x, y, z) & TYPE_MASK; + + return level->getData(x, y, z) & TYPE_MASK; } int HalfSlabTile::cloneTileId(Level *level, int x, int y, int z) { - if (isHalfSlab(id)) - { - return id; - } - if (id == Tile::stoneSlab_Id) - { - return Tile::stoneSlabHalf_Id; - } - if (id == Tile::woodSlab_Id) - { - return Tile::woodSlabHalf_Id; - } - return Tile::stoneSlabHalf_Id; + return id; +} + +int HalfSlabTile::getPlacedOnFaceDataValue( + Level *level, int x, int y, int z, + int face, float clickX, float clickY, float clickZ, + int itemValue) +{ + + if (face == Facing::DOWN) + return itemValue | TOP_SLOT_BIT; + if (face == Facing::UP) + return itemValue; + + return (clickY > 0.5f) ? (itemValue | TOP_SLOT_BIT) : itemValue; +} + + bool HalfSlabTile::isHalfSlab(int tileId) +{ + if (tileId <= 0 || Tile::tiles[tileId] == nullptr) + return false; + return dynamic_cast(Tile::tiles[tileId]) != nullptr + && !Tile::tiles[tileId]->isCubeShaped(); } \ No newline at end of file diff --git a/Minecraft.World/HalfSlabTile.h b/Minecraft.World/HalfSlabTile.h index 6399d827..7d65247b 100644 --- a/Minecraft.World/HalfSlabTile.h +++ b/Minecraft.World/HalfSlabTile.h @@ -1,33 +1,57 @@ #pragma once - #include "Tile.h" - -class HalfSlabTile : public Tile +class HalfSlabTile : public Tile { public: - static const int TYPE_MASK = 7; - static const int TOP_SLOT_BIT = 8; + static const int TYPE_MASK = 7; + static const int TOP_SLOT_BIT = 8; -protected: - bool fullSize; + + enum class Half + { + TOP, + BOTTOM + }; public: - HalfSlabTile(int id, bool fullSize, Material *material); - virtual void updateShape(LevelSource *level, int x, int y, int z, int forceData = -1, shared_ptr forceEntity = shared_ptr()); // 4J added forceData, forceEntity param - virtual void updateDefaultShape(); - virtual void addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr source); - virtual bool isSolidRender(bool isServerLevel); - virtual int getPlacedOnFaceDataValue(Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, int itemValue); - virtual int getResourceCount(Random *random); - virtual int getSpawnResourcesAuxValue(int data); - virtual bool isCubeShaped(); - virtual bool shouldRenderFace(LevelSource *level, int x, int y, int z, int face); + HalfSlabTile(int id, Material *material); + + virtual void DerivedInit(); + + virtual int isFullSize() = 0; + + virtual void updateShape( + LevelSource *level, int x, int y, int z, + int forceData = -1, + shared_ptr forceEntity = shared_ptr()) override; + + virtual void updateDefaultShape() override; + + virtual void addAABBs( + Level *level, int x, int y, int z, + AABB *box, AABBList *boxes, + shared_ptr source) override; + + virtual bool isSolidRender(bool isServerLevel = false) override; + virtual bool isSilkTouchable() override; + + virtual int getPlacedOnFaceDataValue( + Level *level, int x, int y, int z, + int face, float clickX, float clickY, float clickZ, + int itemValue) override; + + virtual int getResourceCount(Random *random) override; + virtual int getSpawnResourcesAuxValue(int data) override; + virtual bool isCubeShaped() override; + virtual bool shouldRenderFace( + LevelSource *level, int x, int y, int z, int face) override; + + virtual int cloneTileData(Level *level, int x, int y, int z) override; + virtual int cloneTileId(Level *level, int x, int y, int z) override; + + virtual int getAuxName(int auxValue) = 0; + private: - static bool isHalfSlab(int tileId); -public: - virtual int getAuxName(int auxValue) = 0; - - virtual int cloneTileData(Level *level, int x, int y, int z); - virtual int cloneTileId(Level *level, int x, int y, int z); + static bool isHalfSlab(int tileId); }; \ No newline at end of file diff --git a/Minecraft.World/Recipes.cpp b/Minecraft.World/Recipes.cpp index ba7e407c..85042b9e 100644 --- a/Minecraft.World/Recipes.cpp +++ b/Minecraft.World/Recipes.cpp @@ -411,6 +411,14 @@ Recipes::Recipes() L'#', Tile::sandStone, L'S'); + addShapedRecipy(new ItemInstance(Tile::stairs_red_sandstone, 4), // + L"sssctg", + L"# ", // + L"## ", // + L"###", // + + L'#', Tile::red_sandstone, + L'S'); addShapedRecipy(new ItemInstance(Tile::woodStairsBirch, 4), // L"sssczg", @@ -555,6 +563,12 @@ Recipes::Recipes() L'#', Tile::sandStone, L'S'); + addShapedRecipy(new ItemInstance(Tile::stoneSlab2Half, 6, StoneSlabTile2::RED_SANDSTONE_SLAB), // + L"sctg", + L"###", // + + L'#', Tile::red_sandstone, + L'S'); addShapedRecipy(new ItemInstance(Tile::stoneSlabHalf, 6, StoneSlabTile::STONE_SLAB), // L"sctg", diff --git a/Minecraft.World/StoneSlabTile.cpp b/Minecraft.World/StoneSlabTile.cpp index 10f1ee71..37f09404 100644 --- a/Minecraft.World/StoneSlabTile.cpp +++ b/Minecraft.World/StoneSlabTile.cpp @@ -5,80 +5,78 @@ #include "net.minecraft.world.h" #include "StoneSlabTile.h" +const unsigned int StoneSlabTile::SLAB_NAMES[SLAB_NAMES_LENGTH] = { + IDS_TILE_STONESLAB_STONE, + IDS_TILE_STONESLAB_SAND, + IDS_TILE_STONESLAB_WOOD, + IDS_TILE_STONESLAB_COBBLE, + IDS_TILE_STONESLAB_BRICK, + IDS_TILE_STONESLAB_SMOOTHBRICK, + IDS_TILE_STONESLAB_NETHERBRICK, + IDS_TILE_STONESLAB_QUARTZ, +}; -const unsigned int StoneSlabTile::SLAB_NAMES[SLAB_NAMES_LENGTH] = { IDS_TILE_STONESLAB_STONE, - IDS_TILE_STONESLAB_SAND, - IDS_TILE_STONESLAB_WOOD, - IDS_TILE_STONESLAB_COBBLE, - IDS_TILE_STONESLAB_BRICK, - IDS_TILE_STONESLAB_SMOOTHBRICK, - IDS_TILE_STONESLAB_NETHERBRICK, - IDS_TILE_STONESLAB_QUARTZ, - }; - -StoneSlabTile::StoneSlabTile(int id, bool fullSize) : HalfSlabTile(id, fullSize, Material::stone) +StoneSlabTile::StoneSlabTile(int id) + : HalfSlabTile(id, Material::stone) { } Icon *StoneSlabTile::getTexture(int face, int data) { - int type = data & TYPE_MASK; - if (fullSize && (data & TOP_SLOT_BIT) != 0) - { - face = Facing::UP; - } - switch(type) - { - case STONE_SLAB: - if (face == Facing::UP || face == Facing::DOWN) return icon; - return iconSide; - break; - case SAND_SLAB: - return Tile::sandStone->getTexture(face); - case WOOD_SLAB: - return Tile::wood->getTexture(face); - case COBBLESTONE_SLAB: - return Tile::cobblestone->getTexture(face); - case BRICK_SLAB: - return Tile::redBrick->getTexture(face); - case SMOOTHBRICK_SLAB: - return Tile::stoneBrick->getTexture(face, SmoothStoneBrickTile::TYPE_DEFAULT); - case NETHERBRICK_SLAB: - return Tile::netherBrick->getTexture(Facing::UP); - case QUARTZ_SLAB: - return Tile::quartzBlock->getTexture(face); - } - - return icon; + int type = data & TYPE_MASK; + + if (isFullSize() && (data & TOP_SLOT_BIT) != 0) + face = Facing::UP; + + switch (type) + { + case STONE_SLAB: + if (face == Facing::UP || face == Facing::DOWN) return icon; + return iconSide; + case SAND_SLAB: + return Tile::sandStone->getTexture(face); + case WOOD_SLAB: + return Tile::wood->getTexture(face); + case COBBLESTONE_SLAB: + return Tile::cobblestone->getTexture(face); + case BRICK_SLAB: + return Tile::redBrick->getTexture(face); + case SMOOTHBRICK_SLAB: + return Tile::stoneBrick->getTexture(face, SmoothStoneBrickTile::TYPE_DEFAULT); + case NETHERBRICK_SLAB: + return Tile::netherBrick->getTexture(Facing::UP); + case QUARTZ_SLAB: + return Tile::quartzBlock->getTexture(face); + } + + return icon; } void StoneSlabTile::registerIcons(IconRegister *iconRegister) { - icon = iconRegister->registerIcon(L"stoneslab_top"); - iconSide = iconRegister->registerIcon(L"stoneslab_side"); + icon = iconRegister->registerIcon(L"stoneslab_top"); + iconSide = iconRegister->registerIcon(L"stoneslab_side"); } int StoneSlabTile::getResource(int data, Random *random, int playerBonusLevel) { - return Tile::stoneSlabHalf_Id; + return Tile::stoneSlabHalf_Id; } -unsigned int StoneSlabTile::getDescriptionId(int iData /*= -1*/) +unsigned int StoneSlabTile::getDescriptionId(int iData) { - if(iData < 0 ) iData = 0; - return StoneSlabTile::SLAB_NAMES[iData]; + if (iData < 0) iData = 0; + return StoneSlabTile::SLAB_NAMES[iData]; } -int StoneSlabTile::getAuxName(int auxValue) +int StoneSlabTile::getAuxName(int auxValue) { - if (auxValue < 0 || auxValue >= SLAB_NAMES_LENGTH) - { - auxValue = 0; - } - return SLAB_NAMES[auxValue];//super.getDescriptionId() + "." + SLAB_NAMES[auxValue]; + if (auxValue < 0 || auxValue >= SLAB_NAMES_LENGTH) + auxValue = 0; + return SLAB_NAMES[auxValue];//super.getDescriptionId() + "." + SLAB_NAMES[auxValue]; } shared_ptr StoneSlabTile::getSilkTouchItemInstance(int data) { - return std::make_shared(Tile::stoneSlabHalf_Id, 2, data & TYPE_MASK); -} + return make_shared(Tile::stoneSlabHalf_Id, 2, data & TYPE_MASK); +} \ No newline at end of file diff --git a/Minecraft.World/StoneSlabTile.h b/Minecraft.World/StoneSlabTile.h index 4380b04c..e2679fe7 100644 --- a/Minecraft.World/StoneSlabTile.h +++ b/Minecraft.World/StoneSlabTile.h @@ -1,39 +1,53 @@ #pragma once -using namespace std; - #include "HalfSlabTile.h" class ChunkRebuildData; class StoneSlabTile : public HalfSlabTile { - friend ChunkRebuildData; + friend class ChunkRebuildData; public: - static const int STONE_SLAB = 0; - static const int SAND_SLAB = 1; - static const int WOOD_SLAB = 2; - static const int COBBLESTONE_SLAB = 3; - static const int BRICK_SLAB = 4; - static const int SMOOTHBRICK_SLAB = 5; - static const int NETHERBRICK_SLAB = 6; - static const int QUARTZ_SLAB = 7; - - static const int SLAB_NAMES_LENGTH = 8; - - static const unsigned int SLAB_NAMES[SLAB_NAMES_LENGTH]; + static const int STONE_SLAB = 0; + static const int SAND_SLAB = 1; + static const int WOOD_SLAB = 2; + static const int COBBLESTONE_SLAB = 3; + static const int BRICK_SLAB = 4; + static const int SMOOTHBRICK_SLAB = 5; + static const int NETHERBRICK_SLAB = 6; + static const int QUARTZ_SLAB = 7; + static const int SLAB_NAMES_LENGTH = 8; + static const unsigned int SLAB_NAMES[SLAB_NAMES_LENGTH]; private: - Icon *iconSide; + Icon *iconSide; public: - StoneSlabTile(int id, bool fullSize); + StoneSlabTile(int id); - virtual Icon *getTexture(int face, int data); + virtual int isFullSize() = 0; + + virtual Icon *getTexture(int face, int data) override; + virtual void registerIcons(IconRegister *iconRegister) override; + virtual int getResource(int data, Random *random, int playerBonusLevel) override; + virtual unsigned int getDescriptionId(int iData = -1) override; + virtual int getAuxName(int auxValue) override; - void registerIcons(IconRegister *iconRegister); - virtual int getResource(int data, Random *random, int playerBonusLevel); - virtual unsigned int getDescriptionId(int iData = -1); - virtual int getAuxName(int auxValue); protected: - virtual shared_ptr getSilkTouchItemInstance(int data); + virtual shared_ptr getSilkTouchItemInstance(int data) override; +}; + + + +class HalfStoneSlabTile : public StoneSlabTile +{ +public: + HalfStoneSlabTile(int id) : StoneSlabTile(id) { DerivedInit(); } + virtual int isFullSize() override { return 0; } +}; + +class FullStoneSlabTile : public StoneSlabTile +{ +public: + FullStoneSlabTile(int id) : StoneSlabTile(id) { DerivedInit(); } + virtual int isFullSize() override { return 1; } }; \ No newline at end of file diff --git a/Minecraft.World/StoneSlabTile2.cpp b/Minecraft.World/StoneSlabTile2.cpp new file mode 100644 index 00000000..a2c8392e --- /dev/null +++ b/Minecraft.World/StoneSlabTile2.cpp @@ -0,0 +1,61 @@ +#include "stdafx.h" +#include "net.minecraft.h" +#include "net.minecraft.world.level.h" +#include "net.minecraft.world.level.tile.h" +#include "net.minecraft.world.h" +#include "StoneSlabTile2.h" +#include "RedSandStoneTile.h" + +const unsigned int StoneSlabTile2::SLAB_NAMES[SLAB_NAMES_LENGTH] = { + IDS_TILE_STONESLAB_REDSAND, +}; + +StoneSlabTile2::StoneSlabTile2(int id) + : HalfSlabTile(id, Material::stone) +{ +} + +Icon *StoneSlabTile2::getTexture(int face, int data) +{ + int type = data & TYPE_MASK; + + if (isFullSize() && (data & TOP_SLOT_BIT) != 0) + face = Facing::UP; + + switch (type) + { + case RED_SANDSTONE_SLAB: + return Tile::red_sandstone->getTexture(face); + } + + return icon; +} + +void StoneSlabTile2::registerIcons(IconRegister *iconRegister) +{ + icon = iconRegister->registerIcon(L"red_sandstone_top"); + iconSide = iconRegister->registerIcon(L"red_sandstone_normal"); +} + +int StoneSlabTile2::getResource(int data, Random *random, int playerBonusLevel) +{ + return Tile::stone_slab2_Id; +} + +unsigned int StoneSlabTile2::getDescriptionId(int iData) +{ + if (iData < 0) iData = 0; + return StoneSlabTile2::SLAB_NAMES[iData]; +} + +int StoneSlabTile2::getAuxName(int auxValue) +{ + if (auxValue < 0 || auxValue >= SLAB_NAMES_LENGTH) + auxValue = 0; + return SLAB_NAMES[auxValue];//super.getDescriptionId() + "." + SLAB_NAMES[auxValue]; +} + +shared_ptr StoneSlabTile2::getSilkTouchItemInstance(int data) +{ + return make_shared(Tile::stone_slab2_Id, 2, data & TYPE_MASK); +} \ No newline at end of file diff --git a/Minecraft.World/StoneSlabTile2.h b/Minecraft.World/StoneSlabTile2.h new file mode 100644 index 00000000..12174323 --- /dev/null +++ b/Minecraft.World/StoneSlabTile2.h @@ -0,0 +1,44 @@ +#pragma once +#include "HalfSlabTile.h" + +class ChunkRebuildData; + +class StoneSlabTile2 : public HalfSlabTile +{ + friend class ChunkRebuildData; +public: + static const int RED_SANDSTONE_SLAB = 0; + static const int SLAB_NAMES_LENGTH = 1; + static const unsigned int SLAB_NAMES[SLAB_NAMES_LENGTH]; + +private: + Icon *iconSide; + +public: + StoneSlabTile2(int id); + + virtual int isFullSize() = 0; + + virtual Icon *getTexture(int face, int data) override; + virtual void registerIcons(IconRegister *iconRegister) override; + virtual int getResource(int data, Random *random, int playerBonusLevel) override; + virtual unsigned int getDescriptionId(int iData = -1) override; + virtual int getAuxName(int auxValue) override; + +protected: + virtual shared_ptr getSilkTouchItemInstance(int data) override; +}; + +class HalfStoneSlabTile2 : public StoneSlabTile2 +{ +public: + HalfStoneSlabTile2(int id) : StoneSlabTile2(id) { DerivedInit(); } + virtual int isFullSize() override { return 0; } +}; + +class FullStoneSlabTile2 : public StoneSlabTile2 +{ +public: + FullStoneSlabTile2(int id) : StoneSlabTile2(id) { DerivedInit(); } + virtual int isFullSize() override { return 1; } +}; \ No newline at end of file diff --git a/Minecraft.World/StructureRecipies.cpp b/Minecraft.World/StructureRecipies.cpp index 6004c83b..2ab4d28d 100644 --- a/Minecraft.World/StructureRecipies.cpp +++ b/Minecraft.World/StructureRecipies.cpp @@ -15,6 +15,7 @@ void StructureRecipies::addRecipes(Recipes *r) L'#', Tile::sand, L'S'); + r->addShapedRecipy(new ItemInstance(Tile::sandStone, 4, SandStoneTile::TYPE_SMOOTHSIDE), // L"ssczg", L"##", // @@ -31,6 +32,35 @@ void StructureRecipies::addRecipes(Recipes *r) L'#', new ItemInstance(Tile::stoneSlabHalf, 1, StoneSlabTile::SAND_SLAB), L'S'); + + r->addShapedRecipy(new ItemInstance(Tile::red_sandstone), // + L"ssczg", + L"##", // + L"##", // + + L'#',new ItemInstance(Tile::sand, 1, SandTile::RED_SAND), + L'S'); + + r->addShapedRecipy(new ItemInstance(Tile::red_sandstone, 4, RedSandStoneTile::TYPE_SMOOTHSIDE), // + L"ssczg", + L"##", // + L"##", // + + L'#', new ItemInstance(Tile::red_sandstone), + L'S'); + + + r->addShapedRecipy(new ItemInstance(Tile::red_sandstone, 1, RedSandStoneTile::TYPE_HEIROGLYPHS), // + L"ssczg", + L"#", // + L"#", // + + L'#', new ItemInstance(Tile::stoneSlab2Half, 1, StoneSlabTile2::RED_SANDSTONE_SLAB), + L'S'); + + + + r->addShapedRecipy(new ItemInstance(Tile::quartzBlock, 1, QuartzBlockTile::TYPE_CHISELED), // L"ssczg", L"#", // @@ -47,6 +77,7 @@ void StructureRecipies::addRecipes(Recipes *r) L'#', new ItemInstance(Tile::quartzBlock, 1, QuartzBlockTile::TYPE_DEFAULT), L'S'); + // 4J Stu - Changed the order, as the blocks that go with sandstone cause a 3-icon scroll // that touches the text "Structures" in the title in 720 fullscreen. diff --git a/Minecraft.World/Tile.cpp b/Minecraft.World/Tile.cpp index c1e27960..df064a91 100644 --- a/Minecraft.World/Tile.cpp +++ b/Minecraft.World/Tile.cpp @@ -256,6 +256,8 @@ Tile* Tile::darkGate = nullptr; Tile* Tile::invertedDaylightDetector = nullptr; Tile* Tile::red_sandstone = nullptr; Tile* Tile::stairs_red_sandstone = nullptr; +HalfSlabTile* Tile::stoneSlab2 = nullptr; +HalfSlabTile* Tile::stoneSlab2Half = nullptr; Tile* Tile::seaLantern = nullptr; Tile* Tile::prismarine = nullptr; @@ -370,8 +372,8 @@ void Tile::staticCtor() Tile::goldBlock = (new MetalTile(41)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_block, Item::eMaterial_gold)->setDestroyTime(3.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_METAL)->setIconName(L"gold_block")->setDescriptionId(IDS_TILE_BLOCK_GOLD)->setUseDescriptionId(IDS_DESC_BLOCK_GOLD); Tile::ironBlock = (new MetalTile(42)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_block, Item::eMaterial_iron)->setDestroyTime(5.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_METAL)->setIconName(L"iron_block")->setDescriptionId(IDS_TILE_BLOCK_IRON)->setUseDescriptionId(IDS_DESC_BLOCK_IRON); - Tile::stoneSlab = static_cast((new StoneSlabTile(Tile::stoneSlab_Id, true))->setBaseItemTypeAndMaterial(Item::eBaseItemType_slab, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stoneSlab")->setDescriptionId(IDS_TILE_STONESLAB)->setUseDescriptionId(IDS_DESC_SLAB)); - Tile::stoneSlabHalf = static_cast((new StoneSlabTile(Tile::stoneSlabHalf_Id, false))->setBaseItemTypeAndMaterial(Item::eBaseItemType_halfslab, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stoneSlab")->setDescriptionId(IDS_TILE_STONESLAB)->setUseDescriptionId(IDS_DESC_HALFSLAB)); + Tile::stoneSlab = static_cast((new FullStoneSlabTile(Tile::stoneSlab_Id))->setBaseItemTypeAndMaterial(Item::eBaseItemType_slab, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stoneSlab")->setDescriptionId(IDS_TILE_STONESLAB)->setUseDescriptionId(IDS_DESC_SLAB)); + Tile::stoneSlabHalf = static_cast((new HalfStoneSlabTile(Tile::stoneSlabHalf_Id))->setBaseItemTypeAndMaterial(Item::eBaseItemType_halfslab, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"stoneSlab")->setDescriptionId(IDS_TILE_STONESLAB)->setUseDescriptionId(IDS_DESC_HALFSLAB)); Tile::redBrick = (new Tile(45, Material::stone)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_brick)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->setIconName(L"brick")->setDescriptionId(IDS_TILE_BRICK)->setUseDescriptionId(IDS_DESC_BRICK); Tile::tnt = (new TntTile(46)) ->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"tnt")->setDescriptionId(IDS_TILE_TNT)->setUseDescriptionId(IDS_DESC_TNT); Tile::bookshelf = (new BookshelfTile(47)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_paper, Item::eMaterial_bookshelf)->setDestroyTime(1.5f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"bookshelf")->setDescriptionId(IDS_TILE_BOOKSHELF)->setUseDescriptionId(IDS_DESC_BOOKSHELF); @@ -470,8 +472,9 @@ void Tile::staticCtor() Tile::dragonEgg = (new EggTile(122)) ->setDestroyTime(3.0f)->setExplodeable(15)->setSoundType(SOUND_STONE)->setLightEmission(2.0f / 16.0f)->setIconName(L"dragon_egg")->setDescriptionId(IDS_TILE_DRAGONEGG)->setUseDescriptionId(IDS_DESC_DRAGONEGG); Tile::redstoneLight = (new RedlightTile(123, false)) ->setDestroyTime(0.3f)->setSoundType(SOUND_GLASS)->setIconName(L"redstone_lamp_off")->setDescriptionId(IDS_TILE_REDSTONE_LIGHT)->setUseDescriptionId(IDS_DESC_REDSTONE_LIGHT); Tile::redstoneLight_lit = (new RedlightTile(124, true)) ->setDestroyTime(0.3f)->setSoundType(SOUND_GLASS)->setIconName(L"redstone_lamp_on")->setDescriptionId(IDS_TILE_REDSTONE_LIGHT)->setUseDescriptionId(IDS_DESC_REDSTONE_LIGHT); - Tile::woodSlab = static_cast((new WoodSlabTile(Tile::woodSlab_Id, true))->setBaseItemTypeAndMaterial(Item::eBaseItemType_slab, Item::eMaterial_wood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"woodSlab")->setDescriptionId(IDS_DESC_WOODSLAB)->setUseDescriptionId(IDS_DESC_WOODSLAB)); - Tile::woodSlabHalf = static_cast((new WoodSlabTile(Tile::woodSlabHalf_Id, false))->setBaseItemTypeAndMaterial(Item::eBaseItemType_halfslab, Item::eMaterial_wood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"woodSlab")->setDescriptionId(IDS_DESC_WOODSLAB)->setUseDescriptionId(IDS_DESC_WOODSLAB)); + Tile::woodSlab = static_cast((new FullWoodSlabTile(Tile::woodSlab_Id))->setBaseItemTypeAndMaterial(Item::eBaseItemType_slab, Item::eMaterial_wood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"woodSlab")->setDescriptionId(IDS_DESC_WOODSLAB)->setUseDescriptionId(IDS_DESC_WOODSLAB)); + Tile::woodSlabHalf = static_cast((new HalfWoodSlabTile(Tile::woodSlabHalf_Id))->setBaseItemTypeAndMaterial(Item::eBaseItemType_halfslab, Item::eMaterial_wood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"woodSlab")->setDescriptionId(IDS_DESC_WOODSLAB)->setUseDescriptionId(IDS_DESC_WOODSLAB)); + Tile::cocoa = (new CocoaTile(127)) ->setDestroyTime(0.2f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"cocoa")->sendTileData()->setDescriptionId(IDS_TILE_COCOA)->setUseDescriptionId(IDS_DESC_COCOA); Tile::stairs_sandstone = (new StairTile(128, Tile::sandStone,0)) ->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_sand) ->setIconName(L"stairsSandstone")->setDescriptionId(IDS_TILE_STAIRS_SANDSTONE) ->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS); Tile::emeraldOre = (new OreTile(129)) ->setDestroyTime(3.0f)->setExplodeable(5)->setSoundType(SOUND_STONE)->setIconName(L"emerald_ore")->setDescriptionId(IDS_TILE_EMERALDORE)->setUseDescriptionId(IDS_DESC_EMERALDORE); @@ -525,9 +528,12 @@ void Tile::staticCtor() Tile::packedIce = (new PackedIceTile(174))->setDestroyTime(0.5f)->setSoundType(SOUND_GLASS)->setIconName(L"packed_ice")->setDescriptionId(IDS_TILE_PACKED_ICE)->setUseDescriptionId(IDS_DESC_PACKED_ICE); Tile::invertedDaylightDetector = static_cast((new DaylightDetectorTile(178, true))->setDestroyTime(0.2f)->setSoundType(SOUND_WOOD)->setIconName(L"daylight_detector")->setDescriptionId(IDS_TILE_DAYLIGHT_DETECTOR)->setUseDescriptionId(IDS_DESC_DAYLIGHT_DETECTOR)); - Tile::red_sandstone = (new RedSandStoneTile(179))->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_sand)->setSoundType(Tile::SOUND_STONE)->setDestroyTime(0.8f)->sendTileData()->setIconName(L"red_sandstone")->setDescriptionId(IDS_TILE_RED_SANDSTONE)->setUseDescriptionId(IDS_DESC_RED_SANDSTONE)->sendTileData(); - Tile::stairs_red_sandstone = (new StairTile(180, Tile::red_sandstone, 0))->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_sand)->setIconName(L"stairsRedSandstone")->setDescriptionId(IDS_TILE_STAIRS_RED_SANDSTONE)->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS); + Tile::red_sandstone = (new RedSandStoneTile(red_sandstone_Id))->setBaseItemTypeAndMaterial(Item::eBaseItemType_structblock, Item::eMaterial_sand)->setSoundType(Tile::SOUND_STONE)->setDestroyTime(0.8f)->sendTileData()->setIconName(L"red_sandstone")->setDescriptionId(IDS_TILE_RED_SANDSTONE)->setUseDescriptionId(IDS_DESC_RED_SANDSTONE)->sendTileData(); + Tile::stairs_red_sandstone = (new StairTile(stairs_red_sandstone_Id, Tile::red_sandstone, 0))->setBaseItemTypeAndMaterial(Item::eBaseItemType_stairs, Item::eMaterial_sand)->setIconName(L"stairsRedSandstone")->setDescriptionId(IDS_TILE_STAIRS_RED_SANDSTONE)->sendTileData()->setUseDescriptionId(IDS_DESC_STAIRS); + Tile::stoneSlab2 = static_cast((new FullStoneSlabTile2(double_stone_slab2_Id))->setBaseItemTypeAndMaterial(Item::eBaseItemType_slab, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->sendTileData()->setIconName(L"red_sandstone")->setDescriptionId(IDS_TILE_RED_SANDSTONE)->setUseDescriptionId(IDS_DESC_SLAB)); + Tile::stoneSlab2Half = static_cast((new HalfStoneSlabTile2(stone_slab2_Id))->setBaseItemTypeAndMaterial(Item::eBaseItemType_halfslab, Item::eMaterial_stone)->setDestroyTime(2.0f)->setExplodeable(10)->setSoundType(Tile::SOUND_STONE)->sendTileData()->setIconName(L"red_sandstone")->setDescriptionId(IDS_TILE_RED_SANDSTONE)->setUseDescriptionId(IDS_DESC_HALFSLAB)); + Tile::spruceGate = (new FenceGateTile(183))->setBaseItemTypeAndMaterial(Item::eBaseItemType_fenceGate, Item::eMaterial_sprucewood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"planks_spruce")->setDescriptionId(IDS_TILE_SPRUCE_GATE)->sendTileData()->setUseDescriptionId(IDS_DESC_FENCE_GATE); Tile::birchGate = (new FenceGateTile(184))->setBaseItemTypeAndMaterial(Item::eBaseItemType_fenceGate, Item::eMaterial_birchwood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"planks_birch")->setDescriptionId(IDS_TILE_BIRCH_GATE)->sendTileData()->setUseDescriptionId(IDS_DESC_FENCE_GATE); Tile::jungleGate = (new FenceGateTile(185))->setBaseItemTypeAndMaterial(Item::eBaseItemType_fenceGate, Item::eMaterial_junglewood)->setDestroyTime(2.0f)->setExplodeable(5)->setSoundType(SOUND_WOOD)->setIconName(L"planks_jungle")->setDescriptionId(IDS_TILE_JUNGLE_GATE)->sendTileData()->setUseDescriptionId(IDS_DESC_FENCE_GATE); @@ -580,7 +586,9 @@ void Tile::staticCtor() Item::items[rose_Id] = (new MultiTextureTileItem(Tile::rose_Id - 256, rose, (int*)Rose::FLOWER_NAMES, Rose::FLOWER_NAMES_LENGTH))->setIconName(L"flower_rose")->setDescriptionId(IDS_TILE_ROSE)->setUseDescriptionId(IDS_DESC_FLOWER); Item::items[sand_Id] = (new MultiTextureTileItem(Tile::sand_Id - 256, sand, (int*)SandTile::SAND_NAMES, SandTile::SAND_NAMES_LENGTH))->setIconName(L"sand")->setDescriptionId(IDS_TILE_SAND)->setUseDescriptionId(IDS_DESC_SAND); - Item::items[red_sandstone_Id] = (new MultiTextureTileItem(Tile::red_sandstone_Id - 256, red_sandstone, (int*)RedSandStoneTile::SANDSTONE_NAMES, RedSandStoneTile::SANDSTONE_BLOCK_NAMES))->setIconName(L"red_sandstone")->setDescriptionId(IDS_TILE_SANDSTONE)->setUseDescriptionId(IDS_DESC_SANDSTONE); + Item::items[red_sandstone_Id] = (new MultiTextureTileItem(Tile::red_sandstone_Id - 256, red_sandstone, (int*)RedSandStoneTile::SANDSTONE_NAMES, RedSandStoneTile::SANDSTONE_BLOCK_NAMES))->setIconName(L"red_sandstone")->setDescriptionId(IDS_TILE_RED_SANDSTONE)->setUseDescriptionId(IDS_DESC_SANDSTONE); + Item::items[stone_slab2_Id] = (new StoneSlabTileItem(Tile::stone_slab2_Id - 256, Tile::stoneSlab2Half, Tile::stoneSlab2, false))->setIconName(L"red_sandstone")->setDescriptionId(IDS_TILE_RED_SANDSTONE)->setUseDescriptionId(IDS_DESC_HALFSLAB); + Item::items[double_stone_slab2_Id] = (new StoneSlabTileItem(Tile::double_stone_slab2_Id - 256, Tile::stoneSlab2Half, Tile::stoneSlab2, true))->setIconName(L"red_sandstone")->setDescriptionId(IDS_TILE_RED_SANDSTONE)->setUseDescriptionId(IDS_DESC_SLAB); Item::items[tree2Trunk_Id] = (new MultiTextureTileItem(Tile::tree2Trunk_Id - 256, tree2Trunk, (int*)TreeTile2::TREE_NAMES, TreeTile2::TREE_NAMES_LENGTH))->setIconName(L"log")->setDescriptionId(IDS_TILE_LOG)->setUseDescriptionId(IDS_DESC_LOG); Item::items[sponge_Id] = (new MultiTextureTileItem(Tile::sponge_Id - 256, sponge, (int*)Sponge::SPONGE_NAMES, Sponge::SPONGE_NAMES_LENGTH))->setIconName(L"sponge")->setDescriptionId(IDS_TILE_SPONGE)->setUseDescriptionId(IDS_DESC_SPONGE); diff --git a/Minecraft.World/Tile.h b/Minecraft.World/Tile.h index 29faecdf..4224afb5 100644 --- a/Minecraft.World/Tile.h +++ b/Minecraft.World/Tile.h @@ -388,8 +388,8 @@ public: static const int invertedDaylightDetector_Id = 178; static const int red_sandstone_Id = 179; static const int stairs_red_sandstone_Id = 180; - //181 double_stone_slab2 : sandstoneslab - //182 stone_slab2 : sandstoneslab + static const int double_stone_slab2_Id = 181; + static const int stone_slab2_Id = 182; static const int spruceGate_Id = 183; static const int birchGate_Id = 184; static const int jungleGate_Id = 185; @@ -629,6 +629,8 @@ public: static Tile* invertedDaylightDetector; static Tile* red_sandstone; static Tile* stairs_red_sandstone; + static HalfSlabTile* stoneSlab2; + static HalfSlabTile* stoneSlab2Half; static Tile* tree2Trunk; static Tile* packedIce; static Tile* seaLantern; diff --git a/Minecraft.World/WoodSlabTile.cpp b/Minecraft.World/WoodSlabTile.cpp index a3a4bc6d..434e2b1f 100644 --- a/Minecraft.World/WoodSlabTile.cpp +++ b/Minecraft.World/WoodSlabTile.cpp @@ -7,47 +7,44 @@ #include "net.minecraft.world.item.h" #include "net.minecraft.stats.h" -const unsigned int WoodSlabTile::SLAB_NAMES[SLAB_NAMES_LENGTH] = { IDS_TILE_STONESLAB_OAK, - IDS_TILE_STONESLAB_SPRUCE, - IDS_TILE_STONESLAB_BIRCH, - IDS_TILE_STONESLAB_JUNGLE, - IDS_TILE_STONESLAB_ACACIA, - IDS_TILE_STONESLAB_DARK_OAK +const unsigned int WoodSlabTile::SLAB_NAMES[SLAB_NAMES_LENGTH] = { + IDS_TILE_STONESLAB_OAK, + IDS_TILE_STONESLAB_SPRUCE, + IDS_TILE_STONESLAB_BIRCH, + IDS_TILE_STONESLAB_JUNGLE, + IDS_TILE_STONESLAB_ACACIA, + IDS_TILE_STONESLAB_DARK_OAK }; -// public static final String[] WOOD_NAMES = { -// "oak", "spruce", "birch", "jungle" -// }; - -WoodSlabTile::WoodSlabTile(int id, bool fullSize) : HalfSlabTile(id, fullSize, Material::wood) +WoodSlabTile::WoodSlabTile(int id) + : HalfSlabTile(id, Material::wood) { } Icon *WoodSlabTile::getTexture(int face, int data) { - return Tile::wood->getTexture(face, data & TYPE_MASK); + + return Tile::wood->getTexture(face, data & TYPE_MASK); } int WoodSlabTile::getResource(int data, Random *random, int playerBonusLevel) { - return Tile::woodSlabHalf_Id; + return Tile::woodSlabHalf_Id; } shared_ptr WoodSlabTile::getSilkTouchItemInstance(int data) { - return std::make_shared(Tile::woodSlabHalf, 2, data & TYPE_MASK); + return std::make_shared(Tile::woodSlabHalf, 2, data & TYPE_MASK); } int WoodSlabTile::getAuxName(int auxValue) { - if (auxValue < 0 || auxValue >= SLAB_NAMES_LENGTH) - { - auxValue = 0; - } - return SLAB_NAMES[auxValue];//super.getDescriptionId() + "." + SLAB_NAMES[auxValue]; + if (auxValue < 0 || auxValue >= SLAB_NAMES_LENGTH) + auxValue = 0; + return SLAB_NAMES[auxValue]; } void WoodSlabTile::registerIcons(IconRegister *iconRegister) { - // None + } \ No newline at end of file diff --git a/Minecraft.World/WoodSlabTile.h b/Minecraft.World/WoodSlabTile.h index 9069ae47..1eba55e3 100644 --- a/Minecraft.World/WoodSlabTile.h +++ b/Minecraft.World/WoodSlabTile.h @@ -1,25 +1,40 @@ #pragma once - -#include "Tile.h" #include "HalfSlabTile.h" class Player; -class WoodSlabTile : HalfSlabTile -{ - - friend class Tile; +class WoodSlabTile : public HalfSlabTile +{ + friend class Tile; public: - static const int TYPE_MASK = 7; - static const int TOP_SLOT_BIT = 8; - static const int SLAB_NAMES_LENGTH = 6; - static const unsigned int SLAB_NAMES[SLAB_NAMES_LENGTH]; + static const int SLAB_NAMES_LENGTH = 6; + static const unsigned int SLAB_NAMES[SLAB_NAMES_LENGTH]; - WoodSlabTile(int id, bool fullSize); - virtual Icon *getTexture(int face, int data); - virtual int getResource(int data, Random *random, int playerBonusLevel); - virtual int getAuxName(int auxValue); +public: + WoodSlabTile(int id); - virtual shared_ptr getSilkTouchItemInstance(int data); - void registerIcons(IconRegister *iconRegister); + virtual int isFullSize() = 0; + + virtual Icon *getTexture(int face, int data) override; + virtual int getResource(int data, Random *random, int playerBonusLevel) override; + virtual int getAuxName(int auxValue) override; + virtual void registerIcons(IconRegister *iconRegister) override; + +protected: + virtual shared_ptr getSilkTouchItemInstance(int data) override; +}; + + +class HalfWoodSlabTile : public WoodSlabTile +{ +public: + HalfWoodSlabTile(int id) : WoodSlabTile(id) { DerivedInit(); } + virtual int isFullSize() override { return 0; } +}; + +class FullWoodSlabTile : public WoodSlabTile +{ +public: + FullWoodSlabTile(int id) : WoodSlabTile(id) { DerivedInit(); } + virtual int isFullSize() override { return 1; } }; \ No newline at end of file diff --git a/Minecraft.World/cmake/sources/Common.cmake b/Minecraft.World/cmake/sources/Common.cmake index 8757c517..941492e2 100644 --- a/Minecraft.World/cmake/sources/Common.cmake +++ b/Minecraft.World/cmake/sources/Common.cmake @@ -1966,6 +1966,8 @@ set(_MINECRAFT_WORLD_COMMON_NET_MINECRAFT_WORLD_LEVEL_TILE "${CMAKE_CURRENT_SOURCE_DIR}/StoneMonsterTile.h" "${CMAKE_CURRENT_SOURCE_DIR}/StoneSlabTile.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/StoneSlabTile.h" + "${CMAKE_CURRENT_SOURCE_DIR}/StoneSlabTile2.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/StoneSlabTile2.h" "${CMAKE_CURRENT_SOURCE_DIR}/StoneTile.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/StoneTile.h" "${CMAKE_CURRENT_SOURCE_DIR}/TallGrass.cpp" diff --git a/Minecraft.World/net.minecraft.world.level.tile.h b/Minecraft.World/net.minecraft.world.level.tile.h index ea8bea76..0b650e77 100644 --- a/Minecraft.World/net.minecraft.world.level.tile.h +++ b/Minecraft.World/net.minecraft.world.level.tile.h @@ -141,5 +141,6 @@ #include "TallGrass2.h" #include "PackedIceTile.h" +#include "StoneSlabTile2.h"