Author SHA1 Message Date
ThePixelMoonandGitHub 87c9733e09 Merge pull request #80 from zukrmn/fix/linux-compiler-warnings
fix: resolve high-severity Linux compiler warnings
2026-03-07 03:23:05 +02:00
zukrmn e3fc6ebe52 fix: resolve high-severity Linux compiler warnings 2026-03-06 22:57:02 +00:00
Leah AndersonandGitHub 41314fa873 Merge pull request #72 from MrShrekThird/dev
Update CONTRIBUTING.md
2026-03-06 11:41:18 -07:00
MrShrekThirdandGitHub 04cadcf953 Removed README.md link lol 2026-03-06 18:37:31 +00:00
MrShrekThirdandGitHub daf43609ca Update CONTRIBUTING.md with README link
Added a note to visit README.md for compilation instructions.
2026-03-06 18:25:52 +00:00
MrShrekThirdandGitHub 42e84f9f4a Update CONTRIBUTING.md
Removed outdated and redundant compilation instructions.
2026-03-06 18:19:13 +00:00
JuiceyDevandGitHub dc57bf5634 Merge pull request #62 from 4jcraft/fix/byte-typealias
fix: remove `byte` type alias
2026-03-06 18:40:36 +01:00
JuiceyDevandGitHub a875a6ef98 Merge pull request #69 from 4jcraft/refactor/optional-llvm-toolchain
refactor(build): make `lld` optional and recommend clang/llvm in README
2026-03-06 18:35:19 +01:00
Tropical 79404297d1 docs: remove mention of discord server unavailability 2026-03-06 11:07:07 -06:00
Tropical 6778dc7f92 refactor(build): make lld optional and recommend clang/llvm in README 2026-03-06 10:26:49 -06:00
JuiceyDevandGitHub 14aeba8992 Merge pull request #67 from zukrmn/add-devcontainer-and-fix-deps
docs: add devcontainer and missing libpng-dev dependency
2026-03-06 16:46:27 +01:00
zukrmn ff7276be18 docs: add devcontainer and missing libpng-dev dependency 2026-03-06 15:30:21 +00:00
ThePixelMoon a0c92dacc6 4J.Render: use stb_image 2026-03-06 14:54:55 +02:00
13 changed files with 8119 additions and 111 deletions
+36
View File
@@ -0,0 +1,36 @@
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
ENV DEBIAN_FRONTEND=noninteractive
# Dependencies
RUN apt-get update \
&& apt-get install -y software-properties-common \
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& apt-get update \
&& apt-get install -y \
build-essential \
cmake \
libglfw3-dev \
libgl-dev \
libglu1-mesa-dev \
libopenal-dev \
libvorbis-dev \
libpng-dev \
libpthread-stubs0-dev \
lld \
meson \
ninja-build \
gcc-15 \
g++-15 \
# Clean up lol
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Set GCC 15 as default
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-15 100 \
&& update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-15 100 \
&& update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 100 \
&& update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 100
ENV DEBIAN_FRONTEND=dialog
+17
View File
@@ -0,0 +1,17 @@
{
"name": "4JCraft Dev Container",
"build": {
"dockerfile": "Dockerfile"
},
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack",
"mesonbuild.mesonbuild"
]
}
},
"remoteUser": "vscode"
}
+34 -75
View File
@@ -11,6 +11,9 @@
#include <cmath>
#include <pthread.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
C4JRender RenderManager;
static GLFWwindow *s_window = nullptr;
@@ -495,106 +498,62 @@ void C4JRender::TextureDynamicUpdateEnd() {}
void C4JRender::Tick() {}
void C4JRender::UpdateGamma(unsigned short) {}
// really don't know if this is nessesary but didn't find any other functions to load images properly as a png..
// im sorry.
#ifdef __linux__
#include <png.h>
#include <stdio.h>
#include <string.h>
static HRESULT LoadPNGFromRows(png_structp png, png_infop info, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut)
// This sucks, but at least better than libpng
static HRESULT LoadFromSTB(unsigned char* data, int width, int height, D3DXIMAGE_INFO* pSrcInfo, int** ppDataOut)
{
int width = png_get_image_width(png, info);
int height = png_get_image_height(png, info);
png_byte color_type = png_get_color_type(png, info);
png_byte bit_depth = png_get_bit_depth(png, info);
int pixelCount = width * height;
int* pixels = new int[pixelCount];
if (bit_depth == 16) png_set_strip_16(png);
if (color_type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png);
if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png);
if (png_get_valid(png, info, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png);
if (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_PALETTE)
png_set_filler(png, 0xFF, PNG_FILLER_AFTER);
if (color_type == PNG_COLOR_TYPE_GRAY || color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb(png);
png_read_update_info(png, info);
unsigned char *buf = new unsigned char[width * height * 4];
png_bytep *rows = new png_bytep[height];
for (int y = 0; y < height; y++)
rows[y] = buf + y * width * 4;
png_read_image(png, rows);
delete[] rows;
// considering i worked on previous projects with raw pngs,,,,,
int *pixels = new int[width * height];
for (int i = 0; i < width * height; i++)
for (int i = 0; i < pixelCount; i++)
{
unsigned char r = buf[i * 4 + 0];
unsigned char g = buf[i * 4 + 1];
unsigned char b = buf[i * 4 + 2];
unsigned char a = buf[i * 4 + 3];
unsigned char r = data[i * 4 + 0];
unsigned char g = data[i * 4 + 1];
unsigned char b = data[i * 4 + 2];
unsigned char a = data[i * 4 + 3];
//pixels[i] = (a << 24) | (b << 16) | (g << 8) | r;
pixels[i] = (a << 24) | (r << 16) | (g << 8) | b;
}
delete[] buf;
pSrcInfo->Width = width;
pSrcInfo->Height = height;
if (pSrcInfo)
{
pSrcInfo->Width = width;
pSrcInfo->Height = height;
}
*ppDataOut = pixels;
return S_OK;
}
HRESULT C4JRender::LoadTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut)
HRESULT C4JRender::LoadTextureData(const char* szFilename, D3DXIMAGE_INFO* pSrcInfo, int** ppDataOut)
{
FILE *fp = fopen(szFilename, "rb");
if (!fp) return E_FAIL;
int width, height, channels;
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png) { fclose(fp); return E_FAIL; }
png_infop info = png_create_info_struct(png);
if (!info) { png_destroy_read_struct(&png, NULL, NULL); fclose(fp); return E_FAIL; }
if (setjmp(png_jmpbuf(png))) { png_destroy_read_struct(&png, &info, NULL); fclose(fp); return E_FAIL; }
unsigned char* data = stbi_load(szFilename, &width, &height, &channels, 4);
if (!data)
return E_FAIL;
png_init_io(png, fp);
png_read_info(png, info);
HRESULT hr = LoadFromSTB(data, width, height, pSrcInfo, ppDataOut);
HRESULT hr = LoadPNGFromRows(png, info, pSrcInfo, ppDataOut);
png_destroy_read_struct(&png, &info, NULL);
fclose(fp);
stbi_image_free(data);
return hr;
}
struct PNGMemReader { const unsigned char *data; png_size_t pos; png_size_t size; };
static void png_mem_read(png_structp png, png_bytep out, png_size_t len)
HRESULT C4JRender::LoadTextureData(BYTE* pbData, DWORD dwBytes, D3DXIMAGE_INFO* pSrcInfo, int** ppDataOut)
{
PNGMemReader *r = (PNGMemReader *)png_get_io_ptr(png);
if (r->pos + len > r->size) len = r->size - r->pos;
memcpy(out, r->data + r->pos, len);
r->pos += len;
}
int width, height, channels;
HRESULT C4JRender::LoadTextureData(BYTE *pbData, DWORD dwBytes, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut)
{
png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png) return E_FAIL;
png_infop info = png_create_info_struct(png);
if (!info) { png_destroy_read_struct(&png, NULL, NULL); return E_FAIL; }
if (setjmp(png_jmpbuf(png))) { png_destroy_read_struct(&png, &info, NULL); return E_FAIL; }
unsigned char* data = stbi_load_from_memory(pbData, dwBytes, &width, &height, &channels, 4);
if (!data)
return E_FAIL;
PNGMemReader reader = { pbData, 0, dwBytes };
png_set_read_fn(png, &reader, png_mem_read);
png_read_info(png, info);
HRESULT hr = LoadFromSTB(data, width, height, pSrcInfo, ppDataOut);
HRESULT hr = LoadPNGFromRows(png, info, pSrcInfo, ppDataOut);
png_destroy_read_struct(&png, &info, NULL);
stbi_image_free(data);
return hr;
}
#else
HRESULT C4JRender::LoadTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut) { return S_OK; }
HRESULT C4JRender::LoadTextureData(BYTE *pbData, DWORD dwBytes, D3DXIMAGE_INFO *pSrcInfo, int **ppDataOut) { return S_OK; }
#endif
HRESULT C4JRender::SaveTextureData(const char *szFilename, D3DXIMAGE_INFO *pSrcInfo, int *ppDataOut) { return S_OK; }
HRESULT C4JRender::SaveTextureDataToMemory(void *pOutput, int outputCapacity, int *outputLength, int width, int height, int *ppDataIn) { return S_OK; }
void C4JRender::TextureGetStats() {}
File diff suppressed because it is too large Load Diff
-8
View File
@@ -24,11 +24,3 @@ Simple rules for publishing code:
Make sure your code compiles before making a pull request! and make sure that it's readable
Remember ALL your changes will be licensed under GNU General Public License V3.0.
## Compiling the project:
> [!NOTE]
> The project is currently in a non-compilable state (as of 3/3/2026)
1. Install CMake, Make, GCC (>= 15.0), G++ (>= 15.0).
2. Create a new directory named build after cloning the repository.
3. Enter the new directory and run `cmake ..` and then run `make`
+1
View File
@@ -49,6 +49,7 @@ void GameMode::render(float a)
bool GameMode::useItem(shared_ptr<Player> player, Level *level, shared_ptr<ItemInstance> item, bool bTestUseOnly)
{
return false;
}
void GameMode::initPlayer(shared_ptr<Player> player)
@@ -225,7 +225,7 @@ Texture *StitchedTexture::getSource()
Texture *StitchedTexture::getFrame(int i)
{
return frames->at(0);
return frames->at(i);
}
int StitchedTexture::getFrames()
@@ -102,7 +102,7 @@ void ConsoleSaveFileConverter::ConvertSave(ConsoleSaveFile *sourceSave, ConsoleS
{
FileEntry *sourceFe = sourceSave->createFile( sourcePlayerDatPath );
FileEntry *targetFe = targetSave->createFile( targetPlayerDatPath );
printf("Processing player dat file %s\n", playerFiles->at(fileIdx)->data.filename);
wprintf(L"Processing player dat file %ls\n", playerFiles->at(fileIdx)->data.filename);
ProcessSimpleFile(sourceSave, sourceFe, targetSave, targetFe);
targetFe->data.lastModifiedTime = sourceFe->data.lastModifiedTime;
@@ -86,7 +86,7 @@ void FileOutputStream::write(unsigned int b)
);
#else // LINUX
int fileDescriptor = (int)(intptr_t)(m_fileHandle);
ssize_t numberOfBytesWritten = ::write(fileDescriptor, NULL, 1);
ssize_t numberOfBytesWritten = ::write(fileDescriptor, &value, 1);
int result = static_cast<int>(numberOfBytesWritten);
#endif // _WIN32
@@ -115,7 +115,7 @@ void FileOutputStream::write(byteArray b)
);
#else // Linux
int fileDescriptor = (int)(intptr_t)(m_fileHandle);
ssize_t numberOfBytesWritten = ::write(fileDescriptor, NULL, 1);
ssize_t numberOfBytesWritten = ::write(fileDescriptor, static_cast<const void*>(b.data), b.length);
int result = static_cast<int>(numberOfBytesWritten);
#endif // _WIN32
@@ -44,6 +44,8 @@ void ChunkStorageProfilerDecorator::tick()
#ifndef _CONTENT_PACKAGE
#ifdef __PSVITA__
sprintf(buf,"Average load time: %f (%lld)",0.000001 * (double) timeSpentLoading / (double) loadCount, loadCount);
#elif defined(__linux__)
sprintf(buf,"Average load time: %f (%lld)",0.000001 * (double) timeSpentLoading / (double) loadCount, (long long)loadCount);
#else
sprintf(buf,"Average load time: %f (%I64d)",0.000001 * (double) timeSpentLoading / (double) loadCount, loadCount);
#endif
@@ -55,6 +57,8 @@ void ChunkStorageProfilerDecorator::tick()
#ifndef _CONTENT_PACKAGE
#ifdef __PSVITA__
sprintf(buf,"Average save time: %f (%lld)",0.000001 * (double) timeSpentSaving / (double) loadCount, loadCount);
#elif defined(__linux__)
sprintf(buf,"Average save time: %f (%lld)",0.000001 * (double) timeSpentSaving / (double) loadCount, (long long)loadCount);
#else
sprintf(buf,"Average save time: %f (%I64d)",0.000001 * (double) timeSpentSaving / (double) loadCount, loadCount);
#endif
+30 -21
View File
@@ -9,7 +9,7 @@
4JCraft is a modified version of the Minecraft Console Legacy Edition aimed on porting old Minecraft to different platforms (such as Linux, Android, Emscripten, etc.)
Join our community:
* Discord (Not currently available): https://discord.gg/zFCwRWkkUg
* Discord: https://discord.gg/zFCwRWkkUg
* Steam: https://steamcommunity.com/groups/4JCraft
## Planned platforms to be supported:
@@ -32,7 +32,7 @@ sudo apt install \
build-essential cmake \
libglfw3-dev libgl-dev libglu1-mesa-dev \
libopenal-dev libvorbis-dev \
libpthread-stubs0-dev
libpng-dev libpthread-stubs0-dev
```
On Arch/Manjaro:
@@ -43,32 +43,27 @@ sudo pacman -S base-devel gcc pkgconf cmake glfw-x11 mesa openal libvorbis glu
If you are on wayland, you may swap `glfw-x11` to `glfw-wayland` for native wayland windowing instead of xwayland.
On Docker:
If you don't want to deal with installing dependencies, you can use the included devcontainer. Open the project in VS Code with the [Dev Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension and it will set everything up for you — GCC 15, Meson, Ninja, lld, and all the libraries.
Alternatively, you can build and use the container manually:
```bash
docker build -t 4jcraft-dev .devcontainer/
docker run -it -v $(pwd):/workspaces/4jcraft -w /workspaces/4jcraft 4jcraft-dev bash
```
### Configure & Build
> [!IMPORTANT]
> GCC 15 or newer is currently *required* to build this project. Ubuntu installations in particular may have older versions preinstalled, so verify your compiler version with `gcc --version`.
> If you are using GCC, then GCC 15 or newer is currently *required* to build this project. Ubuntu installations in particular may have older versions preinstalled, so verify your compiler version with `gcc --version`.
This project uses the [Meson](https://mesonbuild.com/) (with [Ninja](https://ninja-build.org/)) as a build system and [lld](https://lld.llvm.org/) as a linker.
This project uses the [Meson](https://mesonbuild.com/) build system (with [Ninja](https://ninja-build.org/)).
#### Install Tooling
1. Follow [this Quickstart guide](https://mesonbuild.com/Quick-guide.html) for installing or building Meson and Ninja on your respective distro.
2. Install the `lld` linker using your distro's package manager. This may be distributed as part of an [LLVM toolchain](https://llvm.org/).
Debian/Ubuntu:
```bash
sudo apt-get install lld
```
RedHat/Fedora:
```bash
sudo dnf install lld
```
Arch/Manjaro:
```bash
sudo pacman -S lld
```
Follow [this Quickstart guide](https://mesonbuild.com/Quick-guide.html) for installing or building Meson and Ninja on your respective distro.
#### Configure & Build
@@ -80,6 +75,20 @@ meson setup build
meson compile -C build
```
> [!TIP]
>
> For the fastest compilation speeds, you may want to use the compilers and linkers provided by an [LLVM toolchain](https://llvm.org/) (`clang`/`lld`) over your system compiler and linker. To do this, install `clang` and `lld`, and configure your build using the `llvm_native.txt` nativescript in `/scripts`:
>
> ```bash
> meson setup --native-file ./scripts/llvm_native.txt build
> ```
>
> ...or if you've already configured a build directory:
>
> ```bash
> meson setup --native-file ./scripts/llvm_native.txt build --reconfigure
> ```
The binary is output to:
```
-3
View File
@@ -11,9 +11,6 @@ project('4jcraft-chucklegrounds', ['cpp', 'c'],
cc = meson.get_compiler('cpp')
# Use LLD for dramatically faster linking (ld.lld must be installed)
add_project_link_arguments('-fuse-ld=lld', language : ['c', 'cpp'])
# system deps
gl_dep = dependency('gl')
glu_dep = dependency('glu')
+5
View File
@@ -0,0 +1,5 @@
[binaries]
c = 'clang'
cpp = 'clang++'
c_ld = 'lld'
cpp_ld = 'lld'