From b3feddfef372618c8a9d7a0abcaf18cfad866c18 Mon Sep 17 00:00:00 2001 From: daoge <3523206925@qq.com> Date: Tue, 3 Mar 2026 03:04:10 +0800 Subject: 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 --- Minecraft.World/FireworksChargeItem.cpp | 211 ++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 Minecraft.World/FireworksChargeItem.cpp (limited to 'Minecraft.World/FireworksChargeItem.cpp') diff --git a/Minecraft.World/FireworksChargeItem.cpp b/Minecraft.World/FireworksChargeItem.cpp new file mode 100644 index 00000000..2de2be04 --- /dev/null +++ b/Minecraft.World/FireworksChargeItem.cpp @@ -0,0 +1,211 @@ +#include "stdafx.h" +#include "net.minecraft.world.item.h" +#include "net.minecraft.world.h" +#include "FireworksChargeItem.h" + +FireworksChargeItem::FireworksChargeItem(int id) : Item(id) +{ +} + +Icon *FireworksChargeItem::getLayerIcon(int auxValue, int spriteLayer) +{ + if (spriteLayer > 0) + { + return overlay; + } + return Item::getLayerIcon(auxValue, spriteLayer); +} + +int FireworksChargeItem::getColor(shared_ptr item, int spriteLayer) +{ + if (spriteLayer == 1) + { + Tag *colorTag = getExplosionTagField(item, FireworksItem::TAG_E_COLORS); + if (colorTag != NULL) + { + IntArrayTag *colors = (IntArrayTag *) colorTag; + if (colors->data.length == 1) + { + return colors->data[0]; + } + int totalRed = 0; + int totalGreen = 0; + int totalBlue = 0; + for (unsigned int i = 0; i < colors->data.length; ++i) + { + int c = colors->data[i]; + totalRed += (c & 0xff0000) >> 16; + totalGreen += (c & 0x00ff00) >> 8; + totalBlue += (c & 0x0000ff) >> 0; + } + totalRed /= colors->data.length; + totalGreen /= colors->data.length; + totalBlue /= colors->data.length; + return (totalRed << 16) | (totalGreen << 8) | totalBlue; + } + return 0x8a8a8a; + } + return Item::getColor(item, spriteLayer); +} + +bool FireworksChargeItem::hasMultipleSpriteLayers() +{ + return true; +} + +Tag *FireworksChargeItem::getExplosionTagField(shared_ptr instance, const wstring &field) +{ + if (instance->hasTag()) + { + CompoundTag *explosion = instance->getTag()->getCompound(FireworksItem::TAG_EXPLOSION); + if (explosion != NULL) + { + return explosion->get(field); + } + } + return NULL; +} + +void FireworksChargeItem::appendHoverText(shared_ptr itemInstance, shared_ptr player, vector *lines, bool advanced) +{ + if (itemInstance->hasTag()) + { + CompoundTag *explosion = itemInstance->getTag()->getCompound(FireworksItem::TAG_EXPLOSION); + if (explosion != NULL) + { + appendHoverText(explosion, lines); + } + } +} + +const unsigned int FIREWORKS_CHARGE_TYPE_NAME[] = +{ + IDS_FIREWORKS_CHARGE_TYPE_0, + IDS_FIREWORKS_CHARGE_TYPE_1, + IDS_FIREWORKS_CHARGE_TYPE_2, + IDS_FIREWORKS_CHARGE_TYPE_3, + IDS_FIREWORKS_CHARGE_TYPE_4 +}; + +const unsigned int FIREWORKS_CHARGE_COLOUR_NAME[] = +{ + IDS_FIREWORKS_CHARGE_BLACK, + IDS_FIREWORKS_CHARGE_RED, + IDS_FIREWORKS_CHARGE_GREEN, + IDS_FIREWORKS_CHARGE_BROWN, + IDS_FIREWORKS_CHARGE_BLUE, + IDS_FIREWORKS_CHARGE_PURPLE, + IDS_FIREWORKS_CHARGE_CYAN, + IDS_FIREWORKS_CHARGE_SILVER, + IDS_FIREWORKS_CHARGE_GRAY, + IDS_FIREWORKS_CHARGE_PINK, + IDS_FIREWORKS_CHARGE_LIME, + IDS_FIREWORKS_CHARGE_YELLOW, + IDS_FIREWORKS_CHARGE_LIGHT_BLUE, + IDS_FIREWORKS_CHARGE_MAGENTA, + IDS_FIREWORKS_CHARGE_ORANGE, + IDS_FIREWORKS_CHARGE_WHITE +}; + +void FireworksChargeItem::appendHoverText(CompoundTag *expTag, vector *lines) +{ + // shape + byte type = expTag->getByte(FireworksItem::TAG_E_TYPE); + if (type >= FireworksItem::TYPE_MIN && type <= FireworksItem::TYPE_MAX) + { + lines->push_back(HtmlString(app.GetString(FIREWORKS_CHARGE_TYPE_NAME[type]))); + } + else + { + lines->push_back(HtmlString(app.GetString(IDS_FIREWORKS_CHARGE_TYPE))); + } + + // colors + intArray colorList = expTag->getIntArray(FireworksItem::TAG_E_COLORS); + if (colorList.length > 0) + { + + bool first = true; + wstring output = L""; + for (unsigned int i = 0; i < colorList.length; ++i) + { + int c = colorList[i]; + if (!first) + { + output += L",\n"; // 4J-PB - without the newline, they tend to go offscreen in split-screen or localised languages + } + first = false; + + // find color name by lookup + bool found = false; + for (int dc = 0; dc < 16; dc++) + { + if (c == DyePowderItem::COLOR_RGB[dc]) + { + found = true; + output += app.GetString(FIREWORKS_CHARGE_COLOUR_NAME[dc]); + break; + } + } + if (!found) + { + output += app.GetString(IDS_FIREWORKS_CHARGE_CUSTOM); + } + } + lines->push_back(output); + } + + // has fade? + intArray fadeList = expTag->getIntArray(FireworksItem::TAG_E_FADECOLORS); + if (fadeList.length > 0) + { + bool first = true; + wstring output = wstring(app.GetString(IDS_FIREWORKS_CHARGE_FADE_TO)) + L" "; + for (unsigned int i = 0; i < fadeList.length; ++i) + { + int c = fadeList[i]; + if (!first) + { + output += L",\n";// 4J-PB - without the newline, they tend to go offscreen in split-screen or localised languages + } + first = false; + + // find color name by lookup + bool found = false; + for (int dc = 0; dc < 16; dc++) + { + if (c == DyePowderItem::COLOR_RGB[dc]) + { + found = true; + output += app.GetString(FIREWORKS_CHARGE_COLOUR_NAME[dc]); + break; + } + } + if (!found) + { + output += app.GetString(IDS_FIREWORKS_CHARGE_CUSTOM); + } + } + lines->push_back(output); + } + + // has trail + bool trail = expTag->getBoolean(FireworksItem::TAG_E_TRAIL); + if (trail) + { + lines->push_back(HtmlString(app.GetString(IDS_FIREWORKS_CHARGE_TRAIL))); + } + + // has flicker + bool flicker = expTag->getBoolean(FireworksItem::TAG_E_FLICKER); + if (flicker) + { + lines->push_back(HtmlString(app.GetString(IDS_FIREWORKS_CHARGE_FLICKER))); + } +} + +void FireworksChargeItem::registerIcons(IconRegister *iconRegister) +{ + Item::registerIcons(iconRegister); + overlay = iconRegister->registerIcon(getIconName() + L"_overlay"); +} \ No newline at end of file -- cgit v1.2.3