Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
976dcc0
Add bit7z library for loading zip files along with 7zip dll to be cop…
Soggy-Pancake Mar 14, 2026
4e91d5c
Implement ZipFile and ZipEntry
Soggy-Pancake Mar 14, 2026
be4bae8
Add nice pixel union for modifying pixel data if needed.
Soggy-Pancake Mar 14, 2026
4b2b909
Add misc indexed textures translation map
Soggy-Pancake Mar 14, 2026
025e93b
Add pack texture size check method
Soggy-Pancake Mar 14, 2026
8a2bc70
Add hasFile checks and java misc translations
Soggy-Pancake Mar 14, 2026
8ceaf1e
Implement autostitching of terrain and items atlas
Soggy-Pancake Mar 14, 2026
7dfc7e1
Generate stitched atlas when game retrieves atlas
Soggy-Pancake Mar 14, 2026
5f284aa
New custom icon macros so the item icon name is used instead of needi…
Soggy-Pancake Mar 14, 2026
6635d35
Update all item icon slots to use current java names
Soggy-Pancake Mar 14, 2026
4eaea8d
Update all tiles to use their given icon names and register with new …
Soggy-Pancake Mar 14, 2026
b25c8aa
Prevent crashes from unsafe cast with dummy function and define gener…
Soggy-Pancake Mar 14, 2026
7b8b75b
Update names of block destruction level icons
Soggy-Pancake Mar 14, 2026
7fd77dd
FileTexturePack is now functional and loads from a zip file in ./reso…
Soggy-Pancake Mar 14, 2026
9332177
Create fileTexturePack instances for each found zip file on load
Soggy-Pancake Mar 14, 2026
ad1a4ec
Merge with upstream
Soggy-Pancake Mar 14, 2026
624af99
Reupdate tile and item names
Soggy-Pancake Mar 14, 2026
3f7745b
Force add lib files for bit7z
Soggy-Pancake Mar 16, 2026
5d459c0
Remove static buffers from `StringHelpers` to prevent overwriting str…
Soggy-Pancake Mar 20, 2026
dbba7bc
Use the first frame from animated textures instead of discarding
Soggy-Pancake Mar 22, 2026
077a60e
Id is already set by base class no need for this
Soggy-Pancake Mar 22, 2026
66343a5
Implement folderTexturePack
Soggy-Pancake Mar 22, 2026
caaca12
Load folder texture packs
Soggy-Pancake Mar 22, 2026
cc74830
Merge with upstream again
Soggy-Pancake Mar 22, 2026
55ff656
Fix for cmake compatibility
Soggy-Pancake Mar 22, 2026
35acf52
Add bit7z include to Minecraft.World
Soggy-Pancake Mar 22, 2026
ecd3774
Add bit7z to server cmakelists
Soggy-Pancake Mar 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
803 changes: 770 additions & 33 deletions Minecraft.Client/AbstractTexturePack.cpp

Large diffs are not rendered by default.

17 changes: 12 additions & 5 deletions Minecraft.Client/AbstractTexturePack.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
#pragma once
using namespace std;

#include <cstdint>
#include "TexturePack.h"

class BufferedImage;
union Pixel;

class AbstractTexturePack : public TexturePack
{
public:
static const unordered_map<std::wstring, std::wstring> INDEXED_TO_JAVA_MAP;

private:
const DWORD id;
const wstring name;
int texSize;

protected:
File *file;
Expand All @@ -28,9 +32,10 @@ class AbstractTexturePack : public TexturePack
TexturePack *fallback;

ColourTable *m_colourTable;

protected:

BufferedImage *iconImage;
std::unique_ptr<BufferedImage> terrainAtlas, itemAtlas, bedTexCache;
BufferedImage* AbstractTexturePack::grabFromDefault(pair<wstring, Icon*> item, Pixel* ogAtlas, pair<int, int> ogDimensions);

private:
int textureId;
Expand All @@ -46,6 +51,7 @@ class AbstractTexturePack : public TexturePack
virtual void loadComparison();
virtual void loadDescription();
virtual void loadName();
void checkTexSize();

public:
virtual InputStream *getResource(const wstring &name, bool allowFallback); //throws IOException
Expand All @@ -66,8 +72,9 @@ class AbstractTexturePack : public TexturePack
virtual wstring getDesc1();
virtual wstring getDesc2();
virtual wstring getWorldName();

virtual wstring getAnimationString(const wstring &textureName, const wstring &path, bool allowFallback);
BufferedImage* AbstractTexturePack::getBedTex(std::wstring name);
virtual void generateStitched(unordered_map<wstring, Icon*> texturesByName);

protected:
virtual wstring getAnimationString(const wstring &textureName, const wstring &path);
Expand Down
6 changes: 3 additions & 3 deletions Minecraft.Client/BufferedImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ BufferedImage::BufferedImage(const wstring& File, bool filenameHasExtension /*=f
name = wDrive + L"res" + filePath.substr(0,filePath.length()-4) + mipMapPath + L".png";
}

const char *pchTextureName=wstringtofilename(name);
auto pchTextureName=wstringtofilename(name);

#ifndef _CONTENT_PACKAGE
app.DebugPrintf("\n--- Loading TEXTURE - %s\n\n",pchTextureName);
app.DebugPrintf("\n--- Loading TEXTURE - %s\n\n",pchTextureName.c_str());
#endif

D3DXIMAGE_INFO ImageInfo;
ZeroMemory(&ImageInfo,sizeof(D3DXIMAGE_INFO));
hr=RenderManager.LoadTextureData(pchTextureName,&ImageInfo,&data[l]);
hr=RenderManager.LoadTextureData(pchTextureName.c_str(), &ImageInfo, &data[l]);


if(hr!=ERROR_SUCCESS)
Expand Down
11 changes: 11 additions & 0 deletions Minecraft.Client/BufferedImage.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
#pragma once
#include <cstdint>
using namespace std;

class Graphics;
class DLCPack;

union Pixel { // Could be a duplicate but I didnt search that hard
uint32_t raw;
struct { // argb flipped because of endianness
unsigned char b;
unsigned char g;
unsigned char r;
unsigned char a;
};
};

class BufferedImage
{
private:
Expand Down
3 changes: 3 additions & 0 deletions Minecraft.Client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ target_include_directories(Minecraft.Client PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/${PLATFORM_NAME}/Iggy/include"
"${CMAKE_SOURCE_DIR}/include/"
"${CMAKE_CURRENT_SOURCE_DIR}/Common/libs/bit7z/include"
)
target_compile_definitions(Minecraft.Client PRIVATE
${MINECRAFT_SHARED_DEFINES}
Expand All @@ -60,11 +61,13 @@ target_link_libraries(Minecraft.Client PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/${PLATFORM_NAME}/4JLibs/libs/4J_Input_d.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/${PLATFORM_NAME}/4JLibs/libs/4J_Storage_d.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/${PLATFORM_NAME}/4JLibs/libs/4J_Render_PC_d.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Common/libs/bit7z/lib/x64/Debug/bit7z.lib"
>
$<$<NOT:$<CONFIG:Debug>>: # Release 4J libraries
"${CMAKE_CURRENT_SOURCE_DIR}/${PLATFORM_NAME}/4JLibs/libs/4J_Input.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/${PLATFORM_NAME}/4JLibs/libs/4J_Storage.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/${PLATFORM_NAME}/4JLibs/libs/4J_Render_PC.lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Common/libs/bit7z/lib/x64/Release/bit7z.lib"
>
)

Expand Down
8 changes: 4 additions & 4 deletions Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,9 @@ int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD
nullptr // Unsupported
);
#else
const char *pchFilename=wstringtofilename(grf.getPath());
std::string pchFilename=wstringtofilename(grf.getPath());
HANDLE fileHandle = CreateFile(
pchFilename, // file name
pchFilename.c_str(), // file name
GENERIC_READ, // access mode
0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but...
nullptr, // Unused
Expand Down Expand Up @@ -640,9 +640,9 @@ int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD
nullptr // Unsupported
);
#else
const char *pchFilename=wstringtofilename(save.getPath());
auto pchFilename=wstringtofilename(save.getPath());
HANDLE fileHandle = CreateFile(
pchFilename, // file name
pchFilename.c_str(), // file name
GENERIC_READ, // access mode
0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but...
nullptr, // Unused
Expand Down
4 changes: 2 additions & 2 deletions Minecraft.Client/Common/Network/GameNetworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame
nullptr // Unsupported
);
#else
const char *pchFilename=wstringtofilename(grf.getPath());
std::string pchFilename=wstringtofilename(grf.getPath());
HANDLE fileHandle = CreateFile(
pchFilename, // file name
pchFilename.c_str(), // file name
GENERIC_READ, // access mode
0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but...
nullptr, // Unused
Expand Down
25 changes: 25 additions & 0 deletions Minecraft.Client/Common/libs/bit7z/include/bit7z.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* bit7z - A C++ static library to interface with the 7-zip shared libraries.
* Copyright (c) 2014-2023 Riccardo Ostani - All Rights Reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

#ifndef BIT7Z_HPP
#define BIT7Z_HPP

#include "bitarchiveeditor.hpp"
#include "bitarchivereader.hpp"
#include "bitarchivewriter.hpp"
#include "bitexception.hpp"
#include "bitfilecompressor.hpp"
#include "bitfileextractor.hpp"
#include "bitmemcompressor.hpp"
#include "bitmemextractor.hpp"
#include "bitstreamcompressor.hpp"
#include "bitstreamextractor.hpp"

#endif // BIT7Z_HPP

101 changes: 101 additions & 0 deletions Minecraft.Client/Common/libs/bit7z/include/bit7zlibrary.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
* bit7z - A C++ static library to interface with the 7-zip shared libraries.
* Copyright (c) 2014-2023 Riccardo Ostani - All Rights Reserved.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

#ifndef BIT7ZLIBRARY_HPP
#define BIT7ZLIBRARY_HPP

#include <string>

#include "bitformat.hpp"
#include "bittypes.hpp"
#include "bitwindows.hpp"

//! @cond IGNORE_BLOCK_IN_DOXYGEN
struct IInArchive;
struct IOutArchive;

template< typename T >
class CMyComPtr;
//! @endcond

/**
* @brief The main namespace of the bit7z library.
*/
namespace bit7z {

/**
* @brief The default file path for the 7-zip shared library to be used by bit7z
* in case the user doesn't pass a path to the constructor of the Bit7zLibrary class.
*
* @note On Windows, the default library is 7z.dll, and it is searched following the Win32 API rules
* (https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order).
*
* @note On Linux, the default library is the absolute path to the "7z.so" installed by p7zip.
*
* @note In all other cases, the value will be the relative path to a "7z.so" in the working directory of the program.
*/
#ifdef __DOXYGEN__
constexpr auto kDefaultLibrary = "<platform-dependent value>";
#elif defined( _WIN32 )
constexpr auto kDefaultLibrary = BIT7Z_STRING( "7z.dll" );
#elif defined( __linux__ )
constexpr auto kDefaultLibrary = "/usr/lib/p7zip/7z.so"; // Default installation path of the p7zip shared library.
#else
constexpr auto kDefaultLibrary = "./7z.so";
#endif

/**
* @brief The Bit7zLibrary class allows accessing the basic functionalities provided by the 7z DLLs.
*/
class Bit7zLibrary final {
public:
Bit7zLibrary( const Bit7zLibrary& ) = delete;

Bit7zLibrary( Bit7zLibrary&& ) = delete;

auto operator=( const Bit7zLibrary& ) -> Bit7zLibrary& = delete;

auto operator=( Bit7zLibrary&& ) -> Bit7zLibrary& = delete;

/**
* @brief Constructs a Bit7zLibrary object by loading the specified 7zip shared library.
*
* By default, it searches a 7z.dll in the same path of the application.
*
* @param libraryPath the path to the shared library file to be loaded.
*/
explicit Bit7zLibrary( const tstring& libraryPath = kDefaultLibrary );

/**
* @brief Destructs the Bit7zLibrary object, freeing the loaded shared library.
*/
~Bit7zLibrary();

/**
* @brief Set the 7-zip shared library to use large memory pages.
*/
void setLargePageMode();

private:
HMODULE mLibrary;
FARPROC mCreateObjectFunc;

BIT7Z_NODISCARD
auto initInArchive( const BitInFormat& format ) const -> CMyComPtr< IInArchive >;

BIT7Z_NODISCARD
auto initOutArchive( const BitInOutFormat& format ) const -> CMyComPtr< IOutArchive >;

friend class BitInputArchive;
friend class BitOutputArchive;
};

} // namespace bit7z

#endif // BIT7ZLIBRARY_HPP
Loading