From 454da0ce3cb7ccf215db02652fec5e42cab11f75 Mon Sep 17 00:00:00 2001 From: Tranqlmao <110073921+Tranqlmao@users.noreply.github.com> Date: Wed, 15 Jul 2026 14:50:09 -0400 Subject: [PATCH] Banners Complete! Fixed improper behaviors of banners to adhere to LCE, as well as redid the banner recipes! --- Minecraft.Client/BannerRenderer.cpp | 4 +- .../Common/UI/IUIScene_CreativeMenu.cpp | 28 +- Minecraft.Client/ItemInHandRenderer.cpp | 8 +- Minecraft.Client/ItemRenderer.cpp | 8 +- Minecraft.World/BannerItem.cpp | 57 ++-- Minecraft.World/BannerPatternRecipe.cpp | 267 ++++++++++++++++++ Minecraft.World/BannerPatternRecipe.h | 30 ++ Minecraft.World/BannerTile.cpp | 11 +- Minecraft.World/BannerTileEntity.cpp | 4 + Minecraft.World/BannerTileEntity.h | 4 + Minecraft.World/Recipes.cpp | 5 +- Minecraft.World/Tile.cpp | 3 +- Minecraft.World/Tile.h | 2 +- Minecraft.World/cmake/sources/Common.cmake | 2 + .../net.minecraft.world.item.crafting.h | 3 +- 15 files changed, 389 insertions(+), 47 deletions(-) create mode 100644 Minecraft.World/BannerPatternRecipe.cpp create mode 100644 Minecraft.World/BannerPatternRecipe.h diff --git a/Minecraft.Client/BannerRenderer.cpp b/Minecraft.Client/BannerRenderer.cpp index 56bf5b7d..df1eb885 100644 --- a/Minecraft.Client/BannerRenderer.cpp +++ b/Minecraft.Client/BannerRenderer.cpp @@ -163,13 +163,13 @@ void BannerRenderer::render(shared_ptr _banner, double x, double y, if (!banner) return; Tile *tile = banner->getTile(); - if (tile != Tile::standing_banner && tile != Tile::wall_banner) return; + if (tile != Tile::standing_banner) return; const float f = 0.6666667f; glDisable(GL_LIGHTING); glPushMatrix(); - if (tile == Tile::standing_banner) + if (!banner->isWall()) { glTranslatef((float)x + 0.5f, (float)y + 0.75f * f, (float)z + 0.5f); float rot = banner->getData() * 360.0f / 16.0f; diff --git a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp index 77d91ced..1a307870 100644 --- a/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp +++ b/Minecraft.Client/Common/UI/IUIScene_CreativeMenu.cpp @@ -311,20 +311,20 @@ void IUIScene_CreativeMenu::staticCtor() ITEM(Tile::bookshelf_Id) ITEM(Item::flower_pot_Id) ITEM(Tile::hay_block_Id) - ITEM_AUX(Tile::standing_banner_Id, 1) // Red - ITEM_AUX(Tile::standing_banner_Id, 14) // Orange - ITEM_AUX(Tile::standing_banner_Id, 11) // Yellow - ITEM_AUX(Tile::standing_banner_Id, 10) // Green - ITEM_AUX(Tile::standing_banner_Id, 12) // Light Blue - ITEM_AUX(Tile::standing_banner_Id, 6) // Cyan - ITEM_AUX(Tile::standing_banner_Id, 4) // Blue - ITEM_AUX(Tile::standing_banner_Id, 5) // Purple - ITEM_AUX(Tile::standing_banner_Id, 13) // Magenta - ITEM_AUX(Tile::standing_banner_Id, 9) // Pink - ITEM_AUX(Tile::standing_banner_Id, 15) // White - ITEM_AUX(Tile::standing_banner_Id, 8) // Dark Grey - ITEM_AUX(Tile::standing_banner_Id, 7) // Light Grey - ITEM_AUX(Tile::standing_banner_Id, 0) // Black + ITEM_AUX(Tile::standing_banner_Id, 14) // Red + ITEM_AUX(Tile::standing_banner_Id, 1) // Orange + ITEM_AUX(Tile::standing_banner_Id, 4) // Yellow + ITEM_AUX(Tile::standing_banner_Id, 5) // Green + ITEM_AUX(Tile::standing_banner_Id, 3) // Light Blue + ITEM_AUX(Tile::standing_banner_Id, 9) // Cyan + ITEM_AUX(Tile::standing_banner_Id, 11) // Blue + ITEM_AUX(Tile::standing_banner_Id, 10) // Purple + ITEM_AUX(Tile::standing_banner_Id, 2) // Magenta + ITEM_AUX(Tile::standing_banner_Id, 6) // Pink + ITEM_AUX(Tile::standing_banner_Id, 0) // White + ITEM_AUX(Tile::standing_banner_Id, 7) // Dark Grey + ITEM_AUX(Tile::standing_banner_Id, 8) // Light Grey + ITEM_AUX(Tile::standing_banner_Id, 15) // Black ITEM_AUX(Tile::wool_Id,14) // Red ITEM_AUX(Tile::wool_Id,1) // Orange ITEM_AUX(Tile::wool_Id,4) // Yellow diff --git a/Minecraft.Client/ItemInHandRenderer.cpp b/Minecraft.Client/ItemInHandRenderer.cpp index 8b4fc060..7c42ddee 100644 --- a/Minecraft.Client/ItemInHandRenderer.cpp +++ b/Minecraft.Client/ItemInHandRenderer.cpp @@ -259,8 +259,8 @@ void ItemInHandRenderer::renderItem(shared_ptr mob, shared_ptr(item->getItem()) != nullptr && BannerRenderer::instance != nullptr) { - int baseColor = item->getAuxValue() & 15; - BannerRenderer::instance->renderBannerForHand(1.0f, baseColor); + int baseColor = 15 - (item->getAuxValue() & 15); + BannerRenderer::instance->renderBannerForHand(1.0f, baseColor, item); glPopMatrix(); return; } @@ -721,12 +721,12 @@ void ItemInHandRenderer::render(float a) } else if (dynamic_cast(item->getItem()) != nullptr && BannerRenderer::instance != nullptr) { - int baseColor = item->getAuxValue() & 15; + int baseColor = 15 - (item->getAuxValue() & 15); glRotatef(50.0f, 0.0f, 1.0f, 0.0f); glTranslatef(0.0f, 0.05f, 0.0f); const float bs = 0.6f; glScalef(bs, -bs, -bs); - BannerRenderer::instance->renderBannerForHand(1.0f, baseColor); + BannerRenderer::instance->renderBannerForHand(1.0f, baseColor, item); glPopMatrix(); return; } diff --git a/Minecraft.Client/ItemRenderer.cpp b/Minecraft.Client/ItemRenderer.cpp index fab05391..a85866a9 100644 --- a/Minecraft.Client/ItemRenderer.cpp +++ b/Minecraft.Client/ItemRenderer.cpp @@ -98,11 +98,11 @@ void ItemRenderer::render(shared_ptr _itemEntity, double x, double y, do } else if (dynamic_cast(item->getItem()) != nullptr && BannerRenderer::instance != nullptr) { - int baseColor = item->getAuxValue() & 15; + int baseColor = 15 - (item->getAuxValue() & 15); glRotatef(spin, 0.0f, 1.0f, 0.0f); const float s = 0.18f; glScalef(s, -s, -s); - BannerRenderer::instance->renderBannerForHand(1.0f, baseColor); + BannerRenderer::instance->renderBannerForHand(1.0f, baseColor, item); } else if ((item->getIconType() == Icon::TYPE_TERRAIN && tile != nullptr && TileRenderer::canRender(tile->getRenderShape())) && item->id != Tile::barrier_Id) { @@ -415,8 +415,8 @@ void ItemRenderer::renderGuiItem(Font *font, Textures *textures, shared_ptr(item->getItem()) != nullptr && BannerRenderer::instance != nullptr) { - int baseColor = item->getAuxValue() & 15; - BannerRenderer::instance->renderBannerForGui(x, y, fScaleX, fScaleY, fAlpha, baseColor); + int baseColor = 15 - (item->getAuxValue() & 15); + BannerRenderer::instance->renderBannerForGui(x, y, fScaleX, fScaleY, fAlpha, baseColor, item); return; } diff --git a/Minecraft.World/BannerItem.cpp b/Minecraft.World/BannerItem.cpp index 01de6e81..66e233cc 100644 --- a/Minecraft.World/BannerItem.cpp +++ b/Minecraft.World/BannerItem.cpp @@ -6,26 +6,27 @@ #include "ItemInstance.h" #include "BannerItem.h" #include "BannerTileEntity.h" +#include "com.mojang.nbt.h" #include "Mth.h" const unsigned int BannerItem::COLOR_DESCS[16] = { - IDS_TILE_BANNER_BLACK, - IDS_TILE_BANNER_RED, - IDS_TILE_BANNER_GREEN, - IDS_TILE_BANNER_BROWN, - IDS_TILE_BANNER_BLUE, - IDS_TILE_BANNER_PURPLE, - IDS_TILE_BANNER_CYAN, - IDS_TILE_BANNER_SILVER, - IDS_TILE_BANNER_GRAY, - IDS_TILE_BANNER_PINK, - IDS_TILE_BANNER_LIME, - IDS_TILE_BANNER_YELLOW, - IDS_TILE_BANNER_LIGHT_BLUE, - IDS_TILE_BANNER_MAGENTA, - IDS_TILE_BANNER_ORANGE, IDS_TILE_BANNER_WHITE, + IDS_TILE_BANNER_ORANGE, + IDS_TILE_BANNER_MAGENTA, + IDS_TILE_BANNER_LIGHT_BLUE, + IDS_TILE_BANNER_YELLOW, + IDS_TILE_BANNER_LIME, + IDS_TILE_BANNER_PINK, + IDS_TILE_BANNER_GRAY, + IDS_TILE_BANNER_SILVER, + IDS_TILE_BANNER_CYAN, + IDS_TILE_BANNER_PURPLE, + IDS_TILE_BANNER_BLUE, + IDS_TILE_BANNER_BROWN, + IDS_TILE_BANNER_GREEN, + IDS_TILE_BANNER_RED, + IDS_TILE_BANNER_BLACK, }; BannerItem::BannerItem(int id) : Item(id) @@ -64,14 +65,38 @@ bool BannerItem::useOn(shared_ptr instance, shared_ptr pla } else { - level->setTileAndData(x, y, z, Tile::wall_banner_Id, face, Tile::UPDATE_CLIENTS); + level->setTileAndData(x, y, z, Tile::standing_banner_Id, face, Tile::UPDATE_CLIENTS); } shared_ptr bte = dynamic_pointer_cast(level->getTileEntity(x, y, z)); if (bte != nullptr) { + if (face != 1) bte->setIsWall(true); int color = 15 - (instance->getAuxValue() & 15); bte->setBaseColor(color); + + if (instance->hasTag()) + { + CompoundTag* tag = instance->getTag(); + if (tag->contains(L"BlockEntityTag", Tag::TAG_Compound)) + { + CompoundTag* bet = tag->getCompound(L"BlockEntityTag"); + if (bet->contains(L"Patterns")) + { + ListTag* list = static_cast*>( + static_cast(bet->getList(L"Patterns"))); + if (list) + { + for (int j = 0; j < list->size() && j < 6; j++) + { + CompoundTag* entry = list->get(j); + bte->addPattern(entry->getString(L"Pattern"), entry->getInt(L"Color")); + } + } + } + } + } + bte->setChanged(); } diff --git a/Minecraft.World/BannerPatternRecipe.cpp b/Minecraft.World/BannerPatternRecipe.cpp new file mode 100644 index 00000000..5b9a6027 --- /dev/null +++ b/Minecraft.World/BannerPatternRecipe.cpp @@ -0,0 +1,267 @@ +#include "stdafx.h" +#include "net.minecraft.world.item.h" +#include "net.minecraft.world.level.tile.h" +#include "BannerItem.h" +#include "BannerPatternRecipe.h" +#include "Rose.h" +#include "com.mojang.nbt.h" +#include "ItemInstance.h" +#include "Recipes.h" + + +const BannerPatternRecipe::PatternInfo BannerPatternRecipe::PATTERNS[] = +{ + { L"bl", {" ", " ", "# "}, 0, -1 }, + { L"br", {" ", " ", " #"}, 0, -1 }, + { L"tl", {"# ", " ", " "}, 0, -1 }, + { L"tr", {" #", " ", " "}, 0, -1 }, + { L"bs", {" ", " ", "###"}, 0, -1 }, + { L"ts", {"###", " ", " "}, 0, -1 }, + { L"ls", {"# ", "# ", "# "}, 0, -1 }, + { L"rs", {" #", " #", " #"}, 0, -1 }, + { L"cs", {" # ", " # ", " # "}, 0, -1 }, + { L"ms", {" ", "###", " "}, 0, -1 }, + { L"drs", {"# ", " # ", " #"}, 0, -1 }, + { L"dls", {" #", " # ", "# "}, 0, -1 }, + { L"ss", {"# #", "# #", " "}, 0, -1 }, + { L"cr", {"# #", " # ", "# #"}, 0, -1 }, + { L"sc", {" # ", "###", " # "}, 0, -1 }, + { L"bt", {" ", " # ", "# #"}, 0, -1 }, + { L"tt", {"# #", " # ", " "}, 0, -1 }, + { L"bts", {" ", "# #", " # "}, 0, -1 }, + { L"tts", {" # ", "# #", " "}, 0, -1 }, + { L"ld", {"## ", "# ", " "}, 0, -1 }, + { L"rd", {" ", " #", " ##"}, 0, -1 }, + { L"lud", {" ", "# ", "## "}, 0, -1 }, + { L"rud", {" ##", " #", " "}, 0, -1 }, + { L"mc", {" ", " # ", " "}, 0, -1 }, + { L"mr", {" # ", "# #", " # "}, 0, -1 }, + { L"vh", {"## ", "## ", "## "}, 0, -1 }, + { L"hh", {"###", "###", " "}, 0, -1 }, + { L"vhr", {" ##", " ##", " ##"}, 0, -1 }, + { L"hhb", {" ", "###", "###"}, 0, -1 }, + { L"bo", {"###", "# #", "###"}, 0, -1 }, + { L"gra", {"# #", " # ", " # "}, 0, -1 }, + { L"gru", {" # ", " # ", "# #"}, 0, -1 }, + { L"cbo", {nullptr, nullptr, nullptr}, Tile::vine_Id, -1 }, + { L"bri", {nullptr, nullptr, nullptr}, Tile::brick_block_Id, -1 }, + { L"cre", {nullptr, nullptr, nullptr}, Item::skull_Id, 4 }, + { L"sku", {nullptr, nullptr, nullptr}, Item::skull_Id, 1 }, + { L"flo", {nullptr, nullptr, nullptr}, Tile::red_flower_Id, Rose::OXEYE_DAISY }, + { L"moj", {nullptr, nullptr, nullptr}, Item::golden_apple_Id, 1 }, +}; + +const int BannerPatternRecipe::PATTERN_COUNT = static_cast(sizeof(PATTERNS) / sizeof(PATTERNS[0])); + +int BannerPatternRecipe::getBannerPatternCount(shared_ptr banner) +{ + if (!banner->hasTag()) return 0; + CompoundTag* tag = banner->getTag(); + if (!tag->contains(L"BlockEntityTag", Tag::TAG_Compound)) return 0; + CompoundTag* bet = tag->getCompound(L"BlockEntityTag"); + if (!bet->contains(L"Patterns")) return 0; + ListTag* list = bet->getList(L"Patterns"); + return list ? list->size() : 0; +} + +const wchar_t* BannerPatternRecipe::matchPattern(shared_ptr craftSlots, int& outDyeColor) +{ + int slots = craftSlots->getContainerSize(); + + for (int p = 0; p < PATTERN_COUNT; p++) + { + const PatternInfo& pat = PATTERNS[p]; + bool gridBased = (pat.rows[0] != nullptr); + + if (gridBased) + { + if (slots != 9) continue; + + int dyeColor = -1; + bool ok = true; + + for (int k = 0; k < 9 && ok; k++) + { + int row = k / 3; + int col = k % 3; + shared_ptr item = craftSlots->getItem(k); + char cell = pat.rows[row][col]; + + if (item != nullptr && dynamic_cast(item->getItem()) == nullptr) + { + if (item->id != Item::dye_Id) { ok = false; break; } + if (cell == ' ') { ok = false; break; } + if (dyeColor != -1 && dyeColor != item->getAuxValue()) { ok = false; break; } + dyeColor = item->getAuxValue(); + } + else + { + if (cell != ' ') { ok = false; break; } + } + } + + if (ok && dyeColor != -1) + { + outDyeColor = dyeColor; + return pat.id; + } + } + else + { + // item-based pattern: needs banner + dye + one special item, classic crafting only + if (slots != 9) continue; + + bool hasSpecial = false; + int dyeColor = -1; + bool ok = true; + + for (int k = 0; k < slots && ok; k++) + { + shared_ptr item = craftSlots->getItem(k); + if (item == nullptr) continue; + + if (dynamic_cast(item->getItem()) != nullptr) continue; + + if (item->id == Item::dye_Id) + { + if (dyeColor != -1) { ok = false; break; } + dyeColor = item->getAuxValue(); + } + else if (item->id == pat.specialItemId && + (pat.specialItemAux == -1 || item->getAuxValue() == pat.specialItemAux)) + { + if (hasSpecial) { ok = false; break; } + hasSpecial = true; + } + else + { + ok = false; break; + } + } + + if (ok && hasSpecial && dyeColor != -1) + { + outDyeColor = dyeColor; + return pat.id; + } + } + } + + return nullptr; +} + +bool BannerPatternRecipe::matches(shared_ptr craftSlots, Level* level) +{ + if (craftSlots->getContainerSize() != 9) return false; + + shared_ptr banner = nullptr; + + for (int i = 0; i < craftSlots->getContainerSize(); i++) + { + shared_ptr item = craftSlots->getItem(i); + if (item == nullptr) continue; + + if (dynamic_cast(item->getItem()) != nullptr) + { + if (banner != nullptr) return false; + if (getBannerPatternCount(item) >= 6) return false; + banner = item; + } + } + + if (banner == nullptr) return false; + + int dyeColor = -1; + return matchPattern(craftSlots, dyeColor) != nullptr; +} + +shared_ptr BannerPatternRecipe::assemble(shared_ptr craftSlots) +{ + if (craftSlots == nullptr) + return std::make_shared(Tile::standing_banner_Id, 1, 0); + + shared_ptr banner = nullptr; + + for (int i = 0; i < craftSlots->getContainerSize(); i++) + { + shared_ptr item = craftSlots->getItem(i); + if (item != nullptr && dynamic_cast(item->getItem()) != nullptr) + { + banner = item; + break; + } + } + + if (banner == nullptr) return nullptr; + + int dyeColor = -1; + const wchar_t* patternId = matchPattern(craftSlots, dyeColor); + if (patternId == nullptr || dyeColor == -1) return nullptr; + + shared_ptr result = banner->copy(); + result->count = 1; + + if (!result->hasTag()) result->setTag(new CompoundTag()); + CompoundTag* tag = result->getTag(); + + if (!tag->contains(L"BlockEntityTag", Tag::TAG_Compound)) + tag->putCompound(L"BlockEntityTag", new CompoundTag()); + CompoundTag* bet = tag->getCompound(L"BlockEntityTag"); + + ListTag* list; + if (bet->contains(L"Patterns")) + { + list = static_cast*>(static_cast(bet->getList(L"Patterns"))); + } + else + { + list = new ListTag(); + bet->put(L"Patterns", list); + } + + CompoundTag* entry = new CompoundTag(); + entry->putString(L"Pattern", patternId); + entry->putInt(L"Color", dyeColor); + list->add(entry); + + return result; +} + +int BannerPatternRecipe::size() +{ + return 10; +} + +const ItemInstance* BannerPatternRecipe::getResultItem() +{ + return nullptr; +} + +const int BannerPatternRecipe::getGroup() +{ + return eGroupType_Max; +} + +bool BannerPatternRecipe::reqs(int iRecipe) +{ + return false; +} + +void BannerPatternRecipe::reqs(INGREDIENTS_REQUIRED* pIngReq) +{ + pIngReq->iIngC = 0; + pIngReq->iType = RECIPE_TYPE_3x3; + pIngReq->iIngIDA = new int[1](); + pIngReq->iIngValA = new int[1](); + pIngReq->iIngAuxValA = new int[1](); + pIngReq->uiGridA = new unsigned int[9](); + + pIngReq->pRecipy = this; + for (unsigned int i = 0; i < XUSER_MAX_COUNT; ++i) + pIngReq->bCanMake[i] = false; +} + +void BannerPatternRecipe::writeToStream(DataOutputStream* dos) +{ + dos->writeByte(99); +} diff --git a/Minecraft.World/BannerPatternRecipe.h b/Minecraft.World/BannerPatternRecipe.h new file mode 100644 index 00000000..bc0e9ee6 --- /dev/null +++ b/Minecraft.World/BannerPatternRecipe.h @@ -0,0 +1,30 @@ +#pragma once +#include "Recipy.h" + +class BannerPatternRecipe : public Recipy +{ +public: + bool matches(shared_ptr craftSlots, Level* level) override; + shared_ptr assemble(shared_ptr craftSlots) override; + int size() override; + const ItemInstance* getResultItem() override; + const int getGroup() override; + bool reqs(int iRecipe) override; + void reqs(INGREDIENTS_REQUIRED* pIngReq) override; + void writeToStream(DataOutputStream* dos) override; + +private: + struct PatternInfo + { + const wchar_t* id; + const char* rows[3]; + int specialItemId; + int specialItemAux; + }; + + static const PatternInfo PATTERNS[]; + static const int PATTERN_COUNT; + + static int getBannerPatternCount(shared_ptr banner); + const wchar_t* matchPattern(shared_ptr craftSlots, int& outDyeColor); +}; diff --git a/Minecraft.World/BannerTile.cpp b/Minecraft.World/BannerTile.cpp index d99dd377..dfb60a0e 100644 --- a/Minecraft.World/BannerTile.cpp +++ b/Minecraft.World/BannerTile.cpp @@ -47,7 +47,10 @@ AABB *BannerTile::getTileAABB(Level *level, int x, int y, int z) void BannerTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr forceEntity) { - if (onGround) return; + shared_ptr bte = forceEntity + ? dynamic_pointer_cast(forceEntity) + : dynamic_pointer_cast(level->getTileEntity(x, y, z)); + if (!bte || !bte->isWall()) return; int face = level->getData(x, y, z); @@ -96,9 +99,11 @@ int BannerTile::getResource(int data, Random *random, int playerBonusLevel) void BannerTile::neighborChanged(Level *level, int x, int y, int z, int type) { + shared_ptr bte = dynamic_pointer_cast(level->getTileEntity(x, y, z)); + bool isWall = bte && bte->isWall(); bool remove = false; - if (onGround) + if (!isWall) { if (!level->getMaterial(x, y - 1, z)->isSolid()) remove = true; } @@ -144,7 +149,7 @@ void BannerTile::spawnResources(Level *level, int x, int y, int z, int data, flo int color = m_dropColor; shared_ptr bte = dynamic_pointer_cast(level->getTileEntity(x, y, z)); - if (bte != nullptr) color = bte->getBaseColor() & 15; + if (bte != nullptr) color = 15 - (bte->getBaseColor() & 15); int count = getResourceCountForLootBonus(playerBonusLevel, level->random); for (int i = 0; i < count; i++) diff --git a/Minecraft.World/BannerTileEntity.cpp b/Minecraft.World/BannerTileEntity.cpp index abaa3992..1deb87bb 100644 --- a/Minecraft.World/BannerTileEntity.cpp +++ b/Minecraft.World/BannerTileEntity.cpp @@ -7,12 +7,14 @@ BannerTileEntity::BannerTileEntity() : TileEntity() { baseColor = 15; + m_isWall = false; } void BannerTileEntity::save(CompoundTag *tag) { TileEntity::save(tag); tag->putInt(L"Base", baseColor); + tag->putByte(L"IsWall", m_isWall ? 1 : 0); if (!patterns.empty()) { @@ -32,6 +34,7 @@ void BannerTileEntity::load(CompoundTag *tag) { TileEntity::load(tag); baseColor = tag->getInt(L"Base"); + m_isWall = tag->contains(L"IsWall") && tag->getByte(L"IsWall") != 0; patterns.clear(); if (tag->contains(L"Patterns")) @@ -65,6 +68,7 @@ shared_ptr BannerTileEntity::clone() shared_ptr result = std::make_shared(); TileEntity::clone(result); result->baseColor = baseColor; + result->m_isWall = m_isWall; result->patterns = patterns; return result; } diff --git a/Minecraft.World/BannerTileEntity.h b/Minecraft.World/BannerTileEntity.h index 792759b6..3b887d36 100644 --- a/Minecraft.World/BannerTileEntity.h +++ b/Minecraft.World/BannerTileEntity.h @@ -18,6 +18,7 @@ public: private: int baseColor; + bool m_isWall; vector patterns; public: @@ -27,6 +28,9 @@ public: int getBaseColor() const { return baseColor; } void setBaseColor(int color) { baseColor = color; } + bool isWall() const { return m_isWall; } + void setIsWall(bool wall) { m_isWall = wall; } + const vector &getPatterns() const { return patterns; } void addPattern(const wstring &pattern, int color) { patterns.push_back({ pattern, color }); } void clearPatterns() { patterns.clear(); } diff --git a/Minecraft.World/Recipes.cpp b/Minecraft.World/Recipes.cpp index 3501d1e1..c52f4dd6 100644 --- a/Minecraft.World/Recipes.cpp +++ b/Minecraft.World/Recipes.cpp @@ -48,6 +48,8 @@ void Recipes::_init() void Recipes::_compileRecipes() { + recipies->push_back(new BannerPatternRecipe()); + addShapedRecipy(new ItemInstance(Tile::wood, 4, 0), // L"sczg", L"#", // @@ -1634,6 +1636,7 @@ void Recipes::loadFromPacket(byteArray packetData) DataInputStream input(&bais); this->_wipeRecipes(); + recipies->push_back(new BannerPatternRecipe()); { int iCount = input.readInt(); for (int i = 0; i < iCount; i++) { @@ -1662,4 +1665,4 @@ std::shared_ptr Recipes::createUpdatePacket() } return std::make_shared(CustomPayloadPacket::UPDATE_RECIPE_REGISTRY, baos.toByteArray()); -} +} \ No newline at end of file diff --git a/Minecraft.World/Tile.cpp b/Minecraft.World/Tile.cpp index 63d5f8a0..944ed8a9 100644 --- a/Minecraft.World/Tile.cpp +++ b/Minecraft.World/Tile.cpp @@ -622,7 +622,8 @@ void Tile::staticCtor() Tile::double_plant = static_cast((new TallGrass2(175))->setDestroyTime(0.0f)->setSoundType(Tile::SOUND_GRASS)->setIconName(L"tallgrass2_tall_grass_upper")->setDescriptionId(IDS_DESC_DOUBLE_TALL_GRASS)->setUseDescriptionId(IDS_DESC_TALL_GRASS)->disableMipmap()->sendTileData(0xFF)); Tile::standing_banner = static_cast((new BannerTile(176, true))->setDestroyTime(1.0f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"planks_oak")->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_SIGN)); - Tile::wall_banner = static_cast((new BannerTile(177, false))->setDestroyTime(1.0f)->setSoundType(Tile::SOUND_WOOD)->setIconName(L"planks_oak")->setNotCollectStatistics()->sendTileData()->setUseDescriptionId(IDS_DESC_SIGN)); + Tile::wall_banner = Tile::standing_banner; + Tile::tiles[177] = Tile::standing_banner; Item::items[standing_banner_Id] = (new BannerItem(standing_banner_Id - 256))->setIconName(L"sign")->setDescriptionId(IDS_TILE_BANNER)->setUseDescriptionId(IDS_DESC_SIGN); diff --git a/Minecraft.World/Tile.h b/Minecraft.World/Tile.h index 5e2a63d8..2f2361a6 100644 --- a/Minecraft.World/Tile.h +++ b/Minecraft.World/Tile.h @@ -417,7 +417,7 @@ public: static const int packed_ice_Id = 174; static const int double_plant_Id = 175; static const int standing_banner_Id = 176; - static const int wall_banner_Id = 177; + static const int wall_banner_Id = 176; static const int daylight_detector_inverted_Id = 178; static const int red_sandstone_Id = 179; static const int red_sandstone_stairs_Id = 180; diff --git a/Minecraft.World/cmake/sources/Common.cmake b/Minecraft.World/cmake/sources/Common.cmake index 18c109e8..6d33412c 100644 --- a/Minecraft.World/cmake/sources/Common.cmake +++ b/Minecraft.World/cmake/sources/Common.cmake @@ -1199,6 +1199,8 @@ source_group("net/minecraft/world/item/alchemy" FILES ${_MINECRAFT_WORLD_COMMON_ set(_MINECRAFT_WORLD_COMMON_NET_MINECRAFT_WORLD_ITEM_CRAFTING "${CMAKE_CURRENT_SOURCE_DIR}/ArmorDyeRecipe.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/ArmorDyeRecipe.h" + "${CMAKE_CURRENT_SOURCE_DIR}/BannerPatternRecipe.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/BannerPatternRecipe.h" "${CMAKE_CURRENT_SOURCE_DIR}/ArmorRecipes.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/ArmorRecipes.h" "${CMAKE_CURRENT_SOURCE_DIR}/ClothDyeRecipes.cpp" diff --git a/Minecraft.World/net.minecraft.world.item.crafting.h b/Minecraft.World/net.minecraft.world.item.crafting.h index f547c15e..f4d6ebf5 100644 --- a/Minecraft.World/net.minecraft.world.item.crafting.h +++ b/Minecraft.World/net.minecraft.world.item.crafting.h @@ -13,4 +13,5 @@ #include "ShapelessRecipy.h" #include "StructureRecipies.h" #include "ToolRecipies.h" -#include "WeaponRecipies.h" \ No newline at end of file +#include "WeaponRecipies.h" +#include "BannerPatternRecipe.h" \ No newline at end of file