From dac0e883b659f2e6cfce651a8fa3b1d8dc2274fe Mon Sep 17 00:00:00 2001 From: MathiewMay Date: Mon, 9 Mar 2026 21:45:08 -0400 Subject: [PATCH 01/16] Rewrote the entity movement packets to use full 16-bit signed short increasing the entity ID limit from 2048 (artifical lce limit) to 32768 ids (0 to 32767) --- .../Network/Packets/MoveEntityPacket.cpp | 72 ++++++------ .../Network/Packets/MoveEntityPacketSmall.cpp | 106 +++++++----------- .../Network/Packets/SetEntityMotionPacket.cpp | 70 +++--------- .../Network/Packets/TeleportEntityPacket.cpp | 8 +- 4 files changed, 94 insertions(+), 162 deletions(-) diff --git a/Minecraft.World/Network/Packets/MoveEntityPacket.cpp b/Minecraft.World/Network/Packets/MoveEntityPacket.cpp index 3fde6d6ab..b0f6298fc 100644 --- a/Minecraft.World/Network/Packets/MoveEntityPacket.cpp +++ b/Minecraft.World/Network/Packets/MoveEntityPacket.cpp @@ -4,7 +4,7 @@ #include "PacketListener.h" #include "MoveEntityPacket.h" -MoveEntityPacket::MoveEntityPacket() +MoveEntityPacket::MoveEntityPacket() { hasRot = false; @@ -28,7 +28,7 @@ MoveEntityPacket::MoveEntityPacket(int id) xRot = 0; } -void MoveEntityPacket::read(DataInputStream *dis) //throws IOException +void MoveEntityPacket::read(DataInputStream *dis) //throws IOException { id = dis->readShort(); } @@ -48,7 +48,7 @@ void MoveEntityPacket::handle(PacketListener *listener) listener->handleMoveEntity(shared_from_this()); } -int MoveEntityPacket::getEstimatedSize() +int MoveEntityPacket::getEstimatedSize() { return 2; } @@ -71,40 +71,40 @@ MoveEntityPacket::PosRot::PosRot() MoveEntityPacket::PosRot::PosRot(int id, char xa, char ya, char za, char yRot, char xRot) : MoveEntityPacket( id ) { - this->xa = xa; - this->ya = ya; - this->za = za; - this->yRot = yRot; - this->xRot = xRot; + this->xa = (int)(signed char)xa; + this->ya = (int)(signed char)ya; + this->za = (int)(signed char)za; + this->yRot = (int)(signed char)yRot; + this->xRot = (int)(signed char)xRot; hasRot = true; } -void MoveEntityPacket::PosRot::read(DataInputStream *dis) //throws IOException +void MoveEntityPacket::PosRot::read(DataInputStream *dis) //throws IOException { MoveEntityPacket::read(dis); - xa = (int)dis->readByte(); - ya = (int)dis->readByte(); - za = (int)dis->readByte(); - yRot = (int)dis->readByte(); - xRot = (int)dis->readByte(); + xa = (int)(signed char)dis->readByte(); + ya = (int)(signed char)dis->readByte(); + za = (int)(signed char)dis->readByte(); + yRot = (int)(signed char)dis->readByte(); + xRot = (int)(signed char)dis->readByte(); } -void MoveEntityPacket::PosRot::write(DataOutputStream *dos) //throws IOException +void MoveEntityPacket::PosRot::write(DataOutputStream *dos) //throws IOException { MoveEntityPacket::write(dos); - dos->writeByte((uint8_t)xa); - dos->writeByte((uint8_t)ya); - dos->writeByte((uint8_t)za); - dos->writeByte((uint8_t)yRot); - dos->writeByte((uint8_t)xRot); + dos->writeByte((uint8_t)(xa & 0xFF)); + dos->writeByte((uint8_t)(ya & 0xFF)); + dos->writeByte((uint8_t)(za & 0xFF)); + dos->writeByte((uint8_t)(yRot & 0xFF)); + dos->writeByte((uint8_t)(xRot & 0xFF)); } -int MoveEntityPacket::PosRot::getEstimatedSize() +int MoveEntityPacket::PosRot::getEstimatedSize() { return 2+5; } -MoveEntityPacket::Pos::Pos() +MoveEntityPacket::Pos::Pos() { } @@ -115,20 +115,20 @@ MoveEntityPacket::Pos::Pos(int id, char xa, char ya, char za) : MoveEntityPacket this->za = za; } -void MoveEntityPacket::Pos::read(DataInputStream *dis) //throws IOException +void MoveEntityPacket::Pos::read(DataInputStream *dis) //throws IOException { MoveEntityPacket::read(dis); - xa = (int)dis->readByte(); - ya = (int)dis->readByte(); - za = (int)dis->readByte(); + xa = (int)(signed char)dis->readByte(); + ya = (int)(signed char)dis->readByte(); + za = (int)(signed char)dis->readByte(); } void MoveEntityPacket::Pos::write(DataOutputStream *dos) //throws IOException { MoveEntityPacket::write(dos); - dos->writeByte((uint8_t)xa); - dos->writeByte((uint8_t)ya); - dos->writeByte((uint8_t)za); + dos->writeByte((uint8_t)(xa & 0xFF)); + dos->writeByte((uint8_t)(ya & 0xFF)); + dos->writeByte((uint8_t)(za & 0xFF)); } int MoveEntityPacket::Pos::getEstimatedSize() @@ -136,7 +136,7 @@ int MoveEntityPacket::Pos::getEstimatedSize() return 2+3; } -MoveEntityPacket::Rot::Rot() +MoveEntityPacket::Rot::Rot() { hasRot = true; } @@ -148,18 +148,18 @@ MoveEntityPacket::Rot::Rot(int id, char yRot, char xRot) : MoveEntityPacket(id) hasRot = true; } -void MoveEntityPacket::Rot::read(DataInputStream *dis) //throws IOException +void MoveEntityPacket::Rot::read(DataInputStream *dis) //throws IOException { MoveEntityPacket::read(dis); - yRot = (int)dis->readByte(); - xRot = (int)dis->readByte(); + yRot = (int)(signed char)dis->readByte(); + xRot = (int)(signed char)dis->readByte(); } -void MoveEntityPacket::Rot::write(DataOutputStream *dos) //throws IOException +void MoveEntityPacket::Rot::write(DataOutputStream *dos) //throws IOException { MoveEntityPacket::write(dos); - dos->writeByte((uint8_t)yRot); - dos->writeByte((uint8_t)xRot); + dos->writeByte((uint8_t)(yRot & 0xFF)); + dos->writeByte((uint8_t)(xRot & 0xFF)); } int MoveEntityPacket::Rot::getEstimatedSize() diff --git a/Minecraft.World/Network/Packets/MoveEntityPacketSmall.cpp b/Minecraft.World/Network/Packets/MoveEntityPacketSmall.cpp index 23cf4af51..1c698f720 100644 --- a/Minecraft.World/Network/Packets/MoveEntityPacketSmall.cpp +++ b/Minecraft.World/Network/Packets/MoveEntityPacketSmall.cpp @@ -19,30 +19,19 @@ MoveEntityPacketSmall::MoveEntityPacketSmall() MoveEntityPacketSmall::MoveEntityPacketSmall(int id) { - if( (id < 0 ) || (id >= 2048 ) ) - { - // We shouln't be tracking an entity that doesn't have a short type of id - __debugbreak(); - } - this->id = id; hasRot = false; - - xa = 0; - ya = 0; - za = 0; - yRot = 0; - xRot = 0; + xa = ya = za = yRot = xRot = 0; } -void MoveEntityPacketSmall::read(DataInputStream *dis) //throws IOException +void MoveEntityPacketSmall::read(DataInputStream *dis) //throws IOException { id = dis->readShort(); } void MoveEntityPacketSmall::write(DataOutputStream *dos) //throws IOException { - if( (id < 0 ) || (id >= 2048 ) ) + if(id < 0 || id > 32767 ) { // We shouln't be tracking an entity that doesn't have a short type of id __debugbreak(); @@ -55,7 +44,7 @@ void MoveEntityPacketSmall::handle(PacketListener *listener) listener->handleMoveEntitySmall(shared_from_this()); } -int MoveEntityPacketSmall::getEstimatedSize() +int MoveEntityPacketSmall::getEstimatedSize() { return 2; } @@ -86,36 +75,32 @@ MoveEntityPacketSmall::PosRot::PosRot(int id, char xa, char ya, char za, char yR hasRot = true; } -void MoveEntityPacketSmall::PosRot::read(DataInputStream *dis) //throws IOException +void MoveEntityPacketSmall::PosRot::read(DataInputStream *dis) //throws IOException { - int idAndRot = dis->readShort(); - this->id = idAndRot & 0x07ff; - this->yRot = idAndRot >> 11; - int xAndYAndZ = (int)dis->readShort(); - this->xa = xAndYAndZ >> 11; - this->ya = (xAndYAndZ << 21 ) >> 26; - this->za = (xAndYAndZ << 27 ) >> 27; + MoveEntityPacketSmall::read(dis); + xa = (signed char)dis->readByte(); + ya = (signed char)dis->readByte(); + za = (signed char)dis->readByte(); + yRot = (signed char)dis->readByte(); + xRot = (signed char)dis->readByte(); } -void MoveEntityPacketSmall::PosRot::write(DataOutputStream *dos) //throws IOException +void MoveEntityPacketSmall::PosRot::write(DataOutputStream *dos) //throws IOException { - if( (id < 0 ) || (id >= 2048 ) ) - { - // We shouln't be tracking an entity that doesn't have a short type of id - __debugbreak(); - } - short idAndRot = id | yRot << 11; - dos->writeShort(idAndRot); - short xAndYAndZ = ( xa << 11 ) | ( ( ya & 0x3f ) << 5 ) | ( za & 0x1f ); - dos->writeShort(xAndYAndZ); + MoveEntityPacketSmall::write(dos); + dos->writeByte((uint8_t)(xa & 0xFF)); + dos->writeByte((uint8_t)(ya & 0xFF)); + dos->writeByte((uint8_t)(za & 0xFF)); + dos->writeByte((uint8_t)(yRot & 0xFF)); + dos->writeByte((uint8_t)(xRot & 0xFF)); } -int MoveEntityPacketSmall::PosRot::getEstimatedSize() +int MoveEntityPacketSmall::PosRot::getEstimatedSize() { - return 4; + return 2+5; } -MoveEntityPacketSmall::Pos::Pos() +MoveEntityPacketSmall::Pos::Pos() { } @@ -126,35 +111,28 @@ MoveEntityPacketSmall::Pos::Pos(int id, char xa, char ya, char za) : MoveEntityP this->za = za; } -void MoveEntityPacketSmall::Pos::read(DataInputStream *dis) //throws IOException +void MoveEntityPacketSmall::Pos::read(DataInputStream *dis) //throws IOException { - int idAndY = dis->readShort(); - this->id = idAndY & 0x07ff; - this->ya = idAndY >> 11; - int XandZ = (int)((signed char)(dis->readByte())); - xa = XandZ >> 4; - za = ( XandZ << 28 ) >> 28; + MoveEntityPacketSmall::read(dis); + xa = (signed char)dis->readByte(); + ya = (signed char)dis->readByte(); + za = (signed char)dis->readByte(); } void MoveEntityPacketSmall::Pos::write(DataOutputStream *dos) //throws IOException { - if( (id < 0 ) || (id >= 2048 ) ) - { - // We shouln't be tracking an entity that doesn't have a short type of id - __debugbreak(); - } - short idAndY = id | ya << 11; - dos->writeShort(idAndY); - char XandZ = ( xa << 4 ) | ( za & 0x0f ); - dos->writeByte((uint8_t)XandZ); + MoveEntityPacketSmall::write(dos); + dos->writeByte((uint8_t)(xa & 0xFF)); + dos->writeByte((uint8_t)(ya & 0xFF)); + dos->writeByte((uint8_t)(za & 0xFF)); } int MoveEntityPacketSmall::Pos::getEstimatedSize() { - return 3; + return 2+3; } -MoveEntityPacketSmall::Rot::Rot() +MoveEntityPacketSmall::Rot::Rot() { hasRot = true; } @@ -167,25 +145,19 @@ MoveEntityPacketSmall::Rot::Rot(int id, char yRot, char xRot) : MoveEntityPacket hasRot = true; } -void MoveEntityPacketSmall::Rot::read(DataInputStream *dis) //throws IOException +void MoveEntityPacketSmall::Rot::read(DataInputStream *dis) //throws IOException { - int idAndRot = (int)dis->readShort(); - this->id = idAndRot & 0x07ff; - this->yRot = idAndRot >> 11; + MoveEntityPacketSmall::read(dis); + yRot = (signed char)dis->readByte(); } -void MoveEntityPacketSmall::Rot::write(DataOutputStream *dos) //throws IOException +void MoveEntityPacketSmall::Rot::write(DataOutputStream *dos) //throws IOException { - if( (id < 0 ) || (id >= 2048 ) ) - { - // We shouln't be tracking an entity that doesn't have a short type of id - __debugbreak(); - } - short idAndRot = id | yRot << 11; - dos->writeShort(idAndRot); + MoveEntityPacketSmall::write(dos); + dos->writeByte((uint8_t)(yRot & 0xFF)); } int MoveEntityPacketSmall::Rot::getEstimatedSize() { - return 2; + return 2+1; } diff --git a/Minecraft.World/Network/Packets/SetEntityMotionPacket.cpp b/Minecraft.World/Network/Packets/SetEntityMotionPacket.cpp index cb6d2a42c..70ea64f92 100644 --- a/Minecraft.World/Network/Packets/SetEntityMotionPacket.cpp +++ b/Minecraft.World/Network/Packets/SetEntityMotionPacket.cpp @@ -20,19 +20,11 @@ void SetEntityMotionPacket::_init(int id, double xd, double yd, double zd) xa = (int) (xd * 8000.0); ya = (int) (yd * 8000.0); za = (int) (zd * 8000.0); - // 4J - if we could transmit this as bytes (in 1/16 accuracy) then flag to do so - if( ( xa >= (-128 * 16 ) ) && ( ya >= (-128 * 16 ) ) && ( za >= (-128 * 16 ) ) && - ( xa < (128 * 16 ) ) && ( ya < (128 * 16 ) ) && ( za < (128 * 16 ) ) ) - { - useBytes = true; - } - else - { - useBytes = false; - } + + useBytes = false; } -SetEntityMotionPacket::SetEntityMotionPacket() +SetEntityMotionPacket::SetEntityMotionPacket() { _init(0, 0.0f, 0.0f, 0.0f); } @@ -44,53 +36,27 @@ SetEntityMotionPacket::SetEntityMotionPacket(std::shared_ptr e) SetEntityMotionPacket::SetEntityMotionPacket(int id, double xd, double yd, double zd) { - _init(id, xd, yd, zd); + _init(id, xd, yd, zd); } -void SetEntityMotionPacket::read(DataInputStream *dis) //throws IOException +void SetEntityMotionPacket::read(DataInputStream *dis) //throws IOException { - short idAndFlag = dis->readShort(); - id = idAndFlag & 0x07ff; - if( idAndFlag & 0x0800 ) - { - xa = (int)dis->readByte(); - ya = (int)dis->readByte(); - za = (int)dis->readByte(); - xa = ( xa << 24 ) >> 24; - ya = ( ya << 24 ) >> 24; - za = ( za << 24 ) >> 24; - xa *= 16; - ya *= 16; - za *= 16; - useBytes = true; - } - else - { - xa = dis->readShort(); - ya = dis->readShort(); - za = dis->readShort(); - useBytes = false; - } + id = dis->readShort(); + + xa = dis->readShort(); + ya = dis->readShort(); + za = dis->readShort(); + + useBytes = false; } void SetEntityMotionPacket::write(DataOutputStream *dos) //throws IOException { - if( useBytes ) - { - // Masking the id to 11 bits before writing to account for large entitty ids. - dos->writeShort((id & 0x07FF) | 0x800); - dos->writeByte(xa/16); - dos->writeByte(ya/16); - dos->writeByte(za/16); - } - else - { - // same thing as line 80 here - dos->writeShort((id & 0x07FF)); - dos->writeShort(xa); - dos->writeShort(ya); - dos->writeShort(za); - } + dos->writeShort(id); + + dos->writeShort(xa); + dos->writeShort(ya); + dos->writeShort(za); } void SetEntityMotionPacket::handle(PacketListener *listener) @@ -100,7 +66,7 @@ void SetEntityMotionPacket::handle(PacketListener *listener) int SetEntityMotionPacket::getEstimatedSize() { - return useBytes ? 5 : 8; + return 8; } bool SetEntityMotionPacket::canBeInvalidated() diff --git a/Minecraft.World/Network/Packets/TeleportEntityPacket.cpp b/Minecraft.World/Network/Packets/TeleportEntityPacket.cpp index fcd88af71..3a0c9927f 100644 --- a/Minecraft.World/Network/Packets/TeleportEntityPacket.cpp +++ b/Minecraft.World/Network/Packets/TeleportEntityPacket.cpp @@ -55,16 +55,10 @@ void TeleportEntityPacket::read(DataInputStream *dis) //throws IOException void TeleportEntityPacket::write(DataOutputStream *dos) //throws IOException { - dos->writeShort(id); -#ifdef _LARGE_WORLDS + dos->writeShort((short)id); dos->writeInt(x); dos->writeInt(y); dos->writeInt(z); -#else - dos->writeShort(x); - dos->writeShort(y); - dos->writeShort(z); -#endif dos->write(yRot); dos->write(xRot); } From 752daaa8732d41179b15e4204810217dc638a636 Mon Sep 17 00:00:00 2001 From: MathiewMay Date: Mon, 9 Mar 2026 21:45:08 -0400 Subject: [PATCH 02/16] Removed the remaining turnOnLightLayer in GameRender, this fixes the particles being dark. --- Minecraft.Client/Rendering/GameRenderer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Minecraft.Client/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp index 9335fee5b..0b157937a 100644 --- a/Minecraft.Client/Rendering/GameRenderer.cpp +++ b/Minecraft.Client/Rendering/GameRenderer.cpp @@ -1402,7 +1402,7 @@ void GameRenderer::renderLevel(float a, __int64 until) #endif PIXEndNamedEvent(); PIXBeginNamedEvent(0,"Particle render"); - turnOnLightLayer(a); // 4J - brought forward from 1.8.2 + //turnOnLightLayer(a); // 4J - brought forward from 1.8.2 particleEngine->renderLit(cameraEntity, a); Lighting::turnOff(); setupFog(0, a); @@ -1619,7 +1619,7 @@ void GameRenderer::renderSnowAndRain(float a) // 4J - rain is relatively low poly, but high fill-rate - better to clip it RenderManager.StateSetEnableViewportClipPlanes(true); - this->turnOnLightLayer(a); + //this->turnOnLightLayer(a); if (rainXa == NULL) { From 41d8202c478bba47103d050758faf7ae7cd8dca7 Mon Sep 17 00:00:00 2001 From: MathiewMay Date: Tue, 10 Mar 2026 18:20:33 -0400 Subject: [PATCH 03/16] applied changes requested by tropicaaal "i would prefer that these be cast to sized integer types int8_t for portability reasons." "The light layer changes are ultimately a hack over the broken renderer implementation and probably out of scope for this PR. There's an in-progress fix for the root cause of this, so this should be removed." "std::numeric_limits::max()" --- Minecraft.Client/Rendering/GameRenderer.cpp | 2 +- .../Network/Packets/MoveEntityPacket.cpp | 36 +++++++-------- .../Network/Packets/MoveEntityPacket.h | 8 ++-- .../Network/Packets/MoveEntityPacketSmall.cpp | 45 ++++++++++--------- .../Network/Packets/MoveEntityPacketSmall.h | 12 ++--- .../Network/Packets/SetEntityMotionPacket.cpp | 6 +-- .../Network/Packets/SetEntityMotionPacket.h | 2 +- .../Network/Packets/TeleportEntityPacket.cpp | 10 ++--- .../Network/Packets/TeleportEntityPacket.h | 8 ++-- 9 files changed, 65 insertions(+), 64 deletions(-) diff --git a/Minecraft.Client/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp index 0b157937a..6a0fe0d4c 100644 --- a/Minecraft.Client/Rendering/GameRenderer.cpp +++ b/Minecraft.Client/Rendering/GameRenderer.cpp @@ -1402,7 +1402,7 @@ void GameRenderer::renderLevel(float a, __int64 until) #endif PIXEndNamedEvent(); PIXBeginNamedEvent(0,"Particle render"); - //turnOnLightLayer(a); // 4J - brought forward from 1.8.2 + turnOnLightLayer(a); // 4J - brought forward from 1.8.2 particleEngine->renderLit(cameraEntity, a); Lighting::turnOff(); setupFog(0, a); diff --git a/Minecraft.World/Network/Packets/MoveEntityPacket.cpp b/Minecraft.World/Network/Packets/MoveEntityPacket.cpp index b0f6298fc..6b5cc94c8 100644 --- a/Minecraft.World/Network/Packets/MoveEntityPacket.cpp +++ b/Minecraft.World/Network/Packets/MoveEntityPacket.cpp @@ -69,24 +69,24 @@ MoveEntityPacket::PosRot::PosRot() hasRot = true; } -MoveEntityPacket::PosRot::PosRot(int id, char xa, char ya, char za, char yRot, char xRot) : MoveEntityPacket( id ) +MoveEntityPacket::PosRot::PosRot(int id, int8_t xa, int8_t ya, int8_t za, int8_t yRot, int8_t xRot) : MoveEntityPacket( id ) { - this->xa = (int)(signed char)xa; - this->ya = (int)(signed char)ya; - this->za = (int)(signed char)za; - this->yRot = (int)(signed char)yRot; - this->xRot = (int)(signed char)xRot; + this->xa = (int)(int8_t)xa; + this->ya = (int)(int8_t)ya; + this->za = (int)(int8_t)za; + this->yRot = (int)(int8_t)yRot; + this->xRot = (int)(int8_t)xRot; hasRot = true; } void MoveEntityPacket::PosRot::read(DataInputStream *dis) //throws IOException { MoveEntityPacket::read(dis); - xa = (int)(signed char)dis->readByte(); - ya = (int)(signed char)dis->readByte(); - za = (int)(signed char)dis->readByte(); - yRot = (int)(signed char)dis->readByte(); - xRot = (int)(signed char)dis->readByte(); + xa = (int)(int8_t)dis->readByte(); + ya = (int)(int8_t)dis->readByte(); + za = (int)(int8_t)dis->readByte(); + yRot = (int)(int8_t)dis->readByte(); + xRot = (int)(int8_t)dis->readByte(); } void MoveEntityPacket::PosRot::write(DataOutputStream *dos) //throws IOException @@ -108,7 +108,7 @@ MoveEntityPacket::Pos::Pos() { } -MoveEntityPacket::Pos::Pos(int id, char xa, char ya, char za) : MoveEntityPacket(id) +MoveEntityPacket::Pos::Pos(int id, int8_t xa, int8_t ya, int8_t za) : MoveEntityPacket(id) { this->xa = xa; this->ya = ya; @@ -118,9 +118,9 @@ MoveEntityPacket::Pos::Pos(int id, char xa, char ya, char za) : MoveEntityPacket void MoveEntityPacket::Pos::read(DataInputStream *dis) //throws IOException { MoveEntityPacket::read(dis); - xa = (int)(signed char)dis->readByte(); - ya = (int)(signed char)dis->readByte(); - za = (int)(signed char)dis->readByte(); + xa = (int)(int8_t)dis->readByte(); + ya = (int)(int8_t)dis->readByte(); + za = (int)(int8_t)dis->readByte(); } void MoveEntityPacket::Pos::write(DataOutputStream *dos) //throws IOException @@ -141,7 +141,7 @@ MoveEntityPacket::Rot::Rot() hasRot = true; } -MoveEntityPacket::Rot::Rot(int id, char yRot, char xRot) : MoveEntityPacket(id) +MoveEntityPacket::Rot::Rot(int id, int8_t yRot, int8_t xRot) : MoveEntityPacket(id) { this->yRot = yRot; this->xRot = xRot; @@ -151,8 +151,8 @@ MoveEntityPacket::Rot::Rot(int id, char yRot, char xRot) : MoveEntityPacket(id) void MoveEntityPacket::Rot::read(DataInputStream *dis) //throws IOException { MoveEntityPacket::read(dis); - yRot = (int)(signed char)dis->readByte(); - xRot = (int)(signed char)dis->readByte(); + yRot = (int)(int8_t)dis->readByte(); + xRot = (int)(int8_t)dis->readByte(); } void MoveEntityPacket::Rot::write(DataOutputStream *dos) //throws IOException diff --git a/Minecraft.World/Network/Packets/MoveEntityPacket.h b/Minecraft.World/Network/Packets/MoveEntityPacket.h index 62560809f..8d2ac049c 100644 --- a/Minecraft.World/Network/Packets/MoveEntityPacket.h +++ b/Minecraft.World/Network/Packets/MoveEntityPacket.h @@ -13,7 +13,7 @@ public: class Rot; int id; - char xa, ya, za, yRot, xRot; + int8_t xa, ya, za, yRot, xRot; bool hasRot; MoveEntityPacket(); @@ -35,7 +35,7 @@ class MoveEntityPacket::PosRot : public MoveEntityPacket { public: PosRot(); - PosRot(int id, char xa, char ya, char za, char yRot, char xRot); + PosRot(int id, int8_t xa, int8_t ya, int8_t za, int8_t yRot, int8_t xRot); virtual void read(DataInputStream *dis); virtual void write(DataOutputStream *dos); @@ -50,7 +50,7 @@ class MoveEntityPacket::Pos : public MoveEntityPacket { public: Pos(); - Pos(int id, char xa, char ya, char za); + Pos(int id, int8_t xa, int8_t ya, int8_t za); virtual void read(DataInputStream *dis); virtual void write(DataOutputStream *dos); @@ -65,7 +65,7 @@ class MoveEntityPacket::Rot : public MoveEntityPacket { public: Rot(); - Rot(int id, char yRot, char xRot); + Rot(int id, int8_t yRot, int8_t xRot); virtual void read(DataInputStream *dis); virtual void write(DataOutputStream *dos); diff --git a/Minecraft.World/Network/Packets/MoveEntityPacketSmall.cpp b/Minecraft.World/Network/Packets/MoveEntityPacketSmall.cpp index 1c698f720..daf3eb8a9 100644 --- a/Minecraft.World/Network/Packets/MoveEntityPacketSmall.cpp +++ b/Minecraft.World/Network/Packets/MoveEntityPacketSmall.cpp @@ -1,5 +1,6 @@ #include "../../Platform/stdafx.h" #include +#include #include "../../IO/Streams/InputOutputStream.h" #include "PacketListener.h" #include "MoveEntityPacketSmall.h" @@ -31,7 +32,7 @@ void MoveEntityPacketSmall::read(DataInputStream *dis) //throws IOException void MoveEntityPacketSmall::write(DataOutputStream *dos) //throws IOException { - if(id < 0 || id > 32767 ) + if(id < 0 || id > std::numeric_limits::max() ) { // We shouln't be tracking an entity that doesn't have a short type of id __debugbreak(); @@ -65,7 +66,7 @@ MoveEntityPacketSmall::PosRot::PosRot() hasRot = true; } -MoveEntityPacketSmall::PosRot::PosRot(int id, char xa, char ya, char za, char yRot, char xRot) : MoveEntityPacketSmall( id ) +MoveEntityPacketSmall::PosRot::PosRot(int id, int8_t xa, int8_t ya, int8_t za, int8_t yRot, int8_t xRot) : MoveEntityPacketSmall( id ) { this->xa = xa; this->ya = ya; @@ -77,22 +78,22 @@ MoveEntityPacketSmall::PosRot::PosRot(int id, char xa, char ya, char za, char yR void MoveEntityPacketSmall::PosRot::read(DataInputStream *dis) //throws IOException { - MoveEntityPacketSmall::read(dis); - xa = (signed char)dis->readByte(); - ya = (signed char)dis->readByte(); - za = (signed char)dis->readByte(); - yRot = (signed char)dis->readByte(); - xRot = (signed char)dis->readByte(); + MoveEntityPacketSmall::read(dis); + xa = (int8_t)dis->readByte(); + ya = (int8_t)dis->readByte(); + za = (int8_t)dis->readByte(); + yRot = (int8_t)dis->readByte(); + xRot = (int8_t)dis->readByte(); } void MoveEntityPacketSmall::PosRot::write(DataOutputStream *dos) //throws IOException { - MoveEntityPacketSmall::write(dos); - dos->writeByte((uint8_t)(xa & 0xFF)); - dos->writeByte((uint8_t)(ya & 0xFF)); - dos->writeByte((uint8_t)(za & 0xFF)); - dos->writeByte((uint8_t)(yRot & 0xFF)); - dos->writeByte((uint8_t)(xRot & 0xFF)); + MoveEntityPacketSmall::write(dos); + dos->writeByte((uint8_t)(xa & 0xFF)); + dos->writeByte((uint8_t)(ya & 0xFF)); + dos->writeByte((uint8_t)(za & 0xFF)); + dos->writeByte((uint8_t)(yRot & 0xFF)); + dos->writeByte((uint8_t)(xRot & 0xFF)); } int MoveEntityPacketSmall::PosRot::getEstimatedSize() @@ -104,7 +105,7 @@ MoveEntityPacketSmall::Pos::Pos() { } -MoveEntityPacketSmall::Pos::Pos(int id, char xa, char ya, char za) : MoveEntityPacketSmall(id) +MoveEntityPacketSmall::Pos::Pos(int id, int8_t xa, int8_t ya, int8_t za) : MoveEntityPacketSmall(id) { this->xa = xa; this->ya = ya; @@ -113,10 +114,10 @@ MoveEntityPacketSmall::Pos::Pos(int id, char xa, char ya, char za) : MoveEntityP void MoveEntityPacketSmall::Pos::read(DataInputStream *dis) //throws IOException { - MoveEntityPacketSmall::read(dis); - xa = (signed char)dis->readByte(); - ya = (signed char)dis->readByte(); - za = (signed char)dis->readByte(); + MoveEntityPacketSmall::read(dis); + xa = (int8_t)dis->readByte(); + ya = (int8_t)dis->readByte(); + za = (int8_t)dis->readByte(); } void MoveEntityPacketSmall::Pos::write(DataOutputStream *dos) //throws IOException @@ -137,7 +138,7 @@ MoveEntityPacketSmall::Rot::Rot() hasRot = true; } -MoveEntityPacketSmall::Rot::Rot(int id, char yRot, char xRot) : MoveEntityPacketSmall(id) +MoveEntityPacketSmall::Rot::Rot(int id, int8_t yRot, int8_t xRot) : MoveEntityPacketSmall(id) { this->yRot = yRot; @@ -147,8 +148,8 @@ MoveEntityPacketSmall::Rot::Rot(int id, char yRot, char xRot) : MoveEntityPacket void MoveEntityPacketSmall::Rot::read(DataInputStream *dis) //throws IOException { - MoveEntityPacketSmall::read(dis); - yRot = (signed char)dis->readByte(); + MoveEntityPacketSmall::read(dis); + yRot = (int8_t)dis->readByte(); } void MoveEntityPacketSmall::Rot::write(DataOutputStream *dos) //throws IOException diff --git a/Minecraft.World/Network/Packets/MoveEntityPacketSmall.h b/Minecraft.World/Network/Packets/MoveEntityPacketSmall.h index fffdc7e56..a5cb220ac 100644 --- a/Minecraft.World/Network/Packets/MoveEntityPacketSmall.h +++ b/Minecraft.World/Network/Packets/MoveEntityPacketSmall.h @@ -13,8 +13,8 @@ public: class Rot; int id; - char xa, ya, za, yRot, xRot; - bool hasRot; + int8_t xa, ya, za, yRot, xRot; + bool hasRot; MoveEntityPacketSmall(); MoveEntityPacketSmall(int id); @@ -34,8 +34,8 @@ public: class MoveEntityPacketSmall::PosRot : public MoveEntityPacketSmall { public: - PosRot(); - PosRot(int id, char xa, char ya, char za, char yRot, char xRot); + PosRot(); + PosRot(int id, int8_t xa, int8_t ya, int8_t za, int8_t yRot, int8_t xRot); virtual void read(DataInputStream *dis); virtual void write(DataOutputStream *dos); @@ -50,7 +50,7 @@ class MoveEntityPacketSmall::Pos : public MoveEntityPacketSmall { public: Pos(); - Pos(int id, char xa, char ya, char za); + Pos(int id, int8_t xa, int8_t ya, int8_t za); virtual void read(DataInputStream *dis); virtual void write(DataOutputStream *dos); @@ -66,7 +66,7 @@ class MoveEntityPacketSmall::Rot : public MoveEntityPacketSmall { public: Rot(); - Rot(int id, char yRot, char xRot); + Rot(int id, int8_t yRot, int8_t xRot); virtual void read(DataInputStream *dis); virtual void write(DataOutputStream *dos); diff --git a/Minecraft.World/Network/Packets/SetEntityMotionPacket.cpp b/Minecraft.World/Network/Packets/SetEntityMotionPacket.cpp index 70ea64f92..72ee76ee7 100644 --- a/Minecraft.World/Network/Packets/SetEntityMotionPacket.cpp +++ b/Minecraft.World/Network/Packets/SetEntityMotionPacket.cpp @@ -17,9 +17,9 @@ void SetEntityMotionPacket::_init(int id, double xd, double yd, double zd) if (xd > m) xd = m; if (yd > m) yd = m; if (zd > m) zd = m; - xa = (int) (xd * 8000.0); - ya = (int) (yd * 8000.0); - za = (int) (zd * 8000.0); + xa = (int16_t) (xd * 8000.0); + ya = (int16_t) (yd * 8000.0); + za = (int16_t) (zd * 8000.0); useBytes = false; } diff --git a/Minecraft.World/Network/Packets/SetEntityMotionPacket.h b/Minecraft.World/Network/Packets/SetEntityMotionPacket.h index 537c5a4fd..5c3702577 100644 --- a/Minecraft.World/Network/Packets/SetEntityMotionPacket.h +++ b/Minecraft.World/Network/Packets/SetEntityMotionPacket.h @@ -7,7 +7,7 @@ class SetEntityMotionPacket : public Packet, public std::enable_shared_from_this { public: int id; - int xa, ya, za; + int16_t xa, ya, za; bool useBytes; // 4J added private: diff --git a/Minecraft.World/Network/Packets/TeleportEntityPacket.cpp b/Minecraft.World/Network/Packets/TeleportEntityPacket.cpp index 3a0c9927f..9dc2742ed 100644 --- a/Minecraft.World/Network/Packets/TeleportEntityPacket.cpp +++ b/Minecraft.World/Network/Packets/TeleportEntityPacket.cpp @@ -17,7 +17,7 @@ TeleportEntityPacket::TeleportEntityPacket() xRot = 0; } -TeleportEntityPacket::TeleportEntityPacket(std::shared_ptr e) +TeleportEntityPacket::TeleportEntityPacket(std::shared_ptr e) { id = e->entityId; x = Mth::floor(e->x * 32); @@ -27,7 +27,7 @@ TeleportEntityPacket::TeleportEntityPacket(std::shared_ptr e) xRot = (uint8_t) (e->xRot * 256 / 360); } -TeleportEntityPacket::TeleportEntityPacket(int id, int x, int y, int z, uint8_t yRot, uint8_t xRot) +TeleportEntityPacket::TeleportEntityPacket(int id, int32_t x, int32_t y, int32_t z, uint8_t yRot, uint8_t xRot) { this->id = id; this->x = x; @@ -53,7 +53,7 @@ void TeleportEntityPacket::read(DataInputStream *dis) //throws IOException xRot = (uint8_t) dis->read(); } -void TeleportEntityPacket::write(DataOutputStream *dos) //throws IOException +void TeleportEntityPacket::write(DataOutputStream *dos) //throws IOException { dos->writeShort((short)id); dos->writeInt(x); @@ -63,12 +63,12 @@ void TeleportEntityPacket::write(DataOutputStream *dos) //throws IOException dos->write(xRot); } -void TeleportEntityPacket::handle(PacketListener *listener) +void TeleportEntityPacket::handle(PacketListener *listener) { listener->handleTeleportEntity(shared_from_this()); } -int TeleportEntityPacket::getEstimatedSize() +int TeleportEntityPacket::getEstimatedSize() { return 2 + 2 + 2 + 2 + 1 + 1; } diff --git a/Minecraft.World/Network/Packets/TeleportEntityPacket.h b/Minecraft.World/Network/Packets/TeleportEntityPacket.h index 0b85a3b99..5ee91255d 100644 --- a/Minecraft.World/Network/Packets/TeleportEntityPacket.h +++ b/Minecraft.World/Network/Packets/TeleportEntityPacket.h @@ -7,19 +7,19 @@ class TeleportEntityPacket : public Packet, public std::enable_shared_from_this< { public: int id; - int x, y, z; - uint8_t yRot, xRot; + int32_t x, y, z; + uint8_t yRot, xRot; TeleportEntityPacket(); TeleportEntityPacket(std::shared_ptr e); - TeleportEntityPacket(int id, int x, int y, int z, uint8_t yRot, uint8_t xRot); + TeleportEntityPacket(int id, int32_t x, int32_t y, int32_t z, uint8_t yRot, uint8_t xRot); virtual void read(DataInputStream *dis); virtual void write(DataOutputStream *dos); virtual void handle(PacketListener *listener); virtual int getEstimatedSize(); virtual bool canBeInvalidated(); - virtual bool isInvalidatedBy(std::shared_ptr packet); + virtual bool isInvalidatedBy(std::shared_ptr packet); public: static std::shared_ptr create() { return std::shared_ptr(new TeleportEntityPacket()); } From c774e1eb18b48fffc5b902853497f4ea94df228b Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Tue, 10 Mar 2026 22:42:14 -0500 Subject: [PATCH 04/16] feat(input): add sprint keys --- 4J.Input/4J_Input.cpp | 9 ++++++--- Minecraft.Client/Input/Input.cpp | 9 +++------ Minecraft.Client/Input/Input.h | 1 + Minecraft.Client/Platform/Common/App_enums.h | 1 + Minecraft.Client/Player/LocalPlayer.cpp | 13 ++++++++++--- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/4J.Input/4J_Input.cpp b/4J.Input/4J_Input.cpp index 2ed4de5e4..012d385e5 100644 --- a/4J.Input/4J_Input.cpp +++ b/4J.Input/4J_Input.cpp @@ -215,7 +215,8 @@ bool C_4JInput::ButtonDown(int iPad, unsigned char ucAction) { switch (ucAction) { case MINECRAFT_ACTION_ACTION: return MouseLDown() || KDown(SDL_SCANCODE_RETURN); case MINECRAFT_ACTION_USE: return MouseRDown() || KDown(SDL_SCANCODE_F); - case MINECRAFT_ACTION_SNEAK_TOGGLE: return KDown(SDL_SCANCODE_LSHIFT) || KDown(SDL_SCANCODE_RSHIFT) || KDown(SDL_SCANCODE_LCTRL) || KDown(SDL_SCANCODE_RCTRL); + case MINECRAFT_ACTION_SNEAK_TOGGLE: return KDown(SDL_SCANCODE_LSHIFT) || KDown(SDL_SCANCODE_RSHIFT); + case MINECRAFT_ACTION_SPRINT: return KDown(SDL_SCANCODE_LCTRL) || KDown(SDL_SCANCODE_RCTRL); case MINECRAFT_ACTION_LEFT_SCROLL: case ACTION_MENU_LEFT_SCROLL: return ScrollSnap() > 0; case MINECRAFT_ACTION_RIGHT_SCROLL: @@ -229,7 +230,8 @@ bool C_4JInput::ButtonPressed(int iPad, unsigned char ucAction) { switch (ucAction) { case MINECRAFT_ACTION_ACTION: return MouseLPressed() || KPressed(SDL_SCANCODE_RETURN); case MINECRAFT_ACTION_USE: return MouseRPressed() || KPressed(SDL_SCANCODE_F); - case MINECRAFT_ACTION_SNEAK_TOGGLE: return KPressed(SDL_SCANCODE_LSHIFT) || KPressed(SDL_SCANCODE_RSHIFT) || KPressed(SDL_SCANCODE_LCTRL) || KPressed(SDL_SCANCODE_RCTRL); + case MINECRAFT_ACTION_SNEAK_TOGGLE: return KPressed(SDL_SCANCODE_LSHIFT) || KPressed(SDL_SCANCODE_RSHIFT); + case MINECRAFT_ACTION_SPRINT: return KPressed(SDL_SCANCODE_LCTRL) || KPressed(SDL_SCANCODE_RCTRL); case MINECRAFT_ACTION_LEFT_SCROLL: case ACTION_MENU_LEFT_SCROLL: return ScrollSnap() > 0; case MINECRAFT_ACTION_RIGHT_SCROLL: @@ -243,7 +245,8 @@ bool C_4JInput::ButtonReleased(int iPad, unsigned char ucAction) { switch (ucAction) { case MINECRAFT_ACTION_ACTION: return MouseLReleased() || KReleased(SDL_SCANCODE_RETURN); case MINECRAFT_ACTION_USE: return MouseRReleased() || KReleased(SDL_SCANCODE_F); - case MINECRAFT_ACTION_SNEAK_TOGGLE: return KReleased(SDL_SCANCODE_LSHIFT) || KReleased(SDL_SCANCODE_RSHIFT) || KReleased(SDL_SCANCODE_LCTRL) || KReleased(SDL_SCANCODE_RCTRL); + case MINECRAFT_ACTION_SNEAK_TOGGLE: return KReleased(SDL_SCANCODE_LSHIFT) || KReleased(SDL_SCANCODE_RSHIFT); + case MINECRAFT_ACTION_SPRINT: KReleased(SDL_SCANCODE_LCTRL) || KReleased(SDL_SCANCODE_RCTRL); case MINECRAFT_ACTION_LEFT_SCROLL: case ACTION_MENU_LEFT_SCROLL: case MINECRAFT_ACTION_RIGHT_SCROLL: diff --git a/Minecraft.Client/Input/Input.cpp b/Minecraft.Client/Input/Input.cpp index 3349b8381..439a0e536 100644 --- a/Minecraft.Client/Input/Input.cpp +++ b/Minecraft.Client/Input/Input.cpp @@ -15,6 +15,7 @@ Input::Input() wasJumping = false; jumping = false; sneaking = false; + sprintKey = false; lReset = false; rReset = false; @@ -103,12 +104,8 @@ void Input::tick(LocalPlayer *player) //jumping = controller.isButtonPressed(0); - - unsigned int jump = InputManager.GetValue(iPad, MINECRAFT_ACTION_JUMP); - if( jump > 0 && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP) ) - jumping = true; - else - jumping = false; + sprintKey = InputManager.GetValue(iPad, MINECRAFT_ACTION_SPRINT) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_SPRINT); + jumping = InputManager.GetValue(iPad, MINECRAFT_ACTION_JUMP) && pMinecraft->localgameModes[iPad]->isInputAllowed(MINECRAFT_ACTION_JUMP); #ifndef _CONTENT_PACKAGE if (app.GetFreezePlayers()) jumping = false; diff --git a/Minecraft.Client/Input/Input.h b/Minecraft.Client/Input/Input.h index daac8bf6d..d30df79a2 100644 --- a/Minecraft.Client/Input/Input.h +++ b/Minecraft.Client/Input/Input.h @@ -10,6 +10,7 @@ public: bool wasJumping; bool jumping; bool sneaking; + bool sprintKey; Input(); // 4J - added virtual ~Input(){} diff --git a/Minecraft.Client/Platform/Common/App_enums.h b/Minecraft.Client/Platform/Common/App_enums.h index b6c484dc8..d4f639e05 100644 --- a/Minecraft.Client/Platform/Common/App_enums.h +++ b/Minecraft.Client/Platform/Common/App_enums.h @@ -828,6 +828,7 @@ enum EControllerActions MINECRAFT_ACTION_PAUSEMENU, MINECRAFT_ACTION_DROP, MINECRAFT_ACTION_SNEAK_TOGGLE, + MINECRAFT_ACTION_SPRINT, MINECRAFT_ACTION_CRAFTING, MINECRAFT_ACTION_RENDER_THIRD_PERSON, MINECRAFT_ACTION_GAME_INFO, diff --git a/Minecraft.Client/Player/LocalPlayer.cpp b/Minecraft.Client/Player/LocalPlayer.cpp index dee185522..9653cf19e 100644 --- a/Minecraft.Client/Player/LocalPlayer.cpp +++ b/Minecraft.Client/Player/LocalPlayer.cpp @@ -305,7 +305,7 @@ void LocalPlayer::aiStep() // 4J - altered this slightly to make sure that the joypad returns to below returnTreshold in between registering two movements up to runThreshold if (onGround && !isSprinting() && enoughFoodToSprint && !isUsingItem() && !hasEffect(MobEffect::blindness)) { - if( !wasRunning && input->ya >= runTreshold ) + if( !wasRunning && (input->ya >= runTreshold) ) { if (sprintTriggerTime == 0) { @@ -316,6 +316,7 @@ void LocalPlayer::aiStep() { if( sprintTriggerRegisteredReturn ) { + printf("setSprinting true\n"); setSprinting(true); sprintTriggerTime = 0; sprintTriggerRegisteredReturn = false; @@ -326,14 +327,20 @@ void LocalPlayer::aiStep() { sprintTriggerRegisteredReturn = true; } + else if (input->sprintKey) + { + printf("setSprinting true\n"); + setSprinting(true); + } } if (isSneaking()) sprintTriggerTime = 0; // 4J-PB - try not stopping sprint on collision //if (isSprinting() && (input->ya < runTreshold || horizontalCollision || !enoughFoodToSprint)) - if (isSprinting() && (input->ya < runTreshold || !enoughFoodToSprint)) + if (isSprinting() && ((input->ya < runTreshold && !input->sprintKey) || !enoughFoodToSprint)) { + printf("setSprinting false\n"); setSprinting(false); - } + } // 4J Stu - Fix for #52705 - Customer Encountered: Player can fly in bed while being in Creative mode. if (!isSleeping() && (abilities.mayfly || isAllowedToFly() )) From 5baab016fab3f71bfc76a11de23c76f12abde0cf Mon Sep 17 00:00:00 2001 From: Emily <106335580+Vozath@users.noreply.github.com> Date: Tue, 10 Mar 2026 23:57:13 -0400 Subject: [PATCH 05/16] meowww --- 4J.Render/4J_Render.cpp | 11 ++++++++++- meson.build | 6 ++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/4J.Render/4J_Render.cpp b/4J.Render/4J_Render.cpp index c16920e82..a22e5ff1b 100644 --- a/4J.Render/4J_Render.cpp +++ b/4J.Render/4J_Render.cpp @@ -70,6 +70,9 @@ static void onFramebufferResize(int w, int h) ::glViewport(0, 0, w, h); } +// V-Sync + + // Initialize OpenGL & The SDL window. void C4JRender::Initialise() { @@ -121,8 +124,14 @@ void C4JRender::Initialise() SDL_Quit(); return; } - SDL_GL_SetSwapInterval(0); // V-Sync Off Please. + // 4JCraft VSync/V-Sync + #ifdef ENABLE_VSYNC + SDL_GL_SetSwapInterval(1); // V-Sync On Please. + #else + SDL_GL_SetSwapInterval(0); // V-Sync Off Please. + #endif + int fw, fh; SDL_GetWindowSize(s_window, &fw, &fh); onFramebufferResize(fw, fh); // We initialize the OpenGL states. Touching those values makes some funny artifacts appear. diff --git a/meson.build b/meson.build index 7ec53a62e..e8e00dc3b 100644 --- a/meson.build +++ b/meson.build @@ -37,6 +37,12 @@ global_cpp_defs = [ '-DDEBUG', ] +if get_option('enable_vsync') + global_cpp_defs += '-DENABLE_VSYNC' + message('v-sync enabled') +endif + + if host_machine.system() == 'linux' global_cpp_defs += [ '-Dlinux', From 0f605b8997b072ed2c084944b18b326055f6dd3b Mon Sep 17 00:00:00 2001 From: Emily <106335580+Vozath@users.noreply.github.com> Date: Wed, 11 Mar 2026 00:09:07 -0400 Subject: [PATCH 06/16] mrrrp (V-Sync Changes) --- Minecraft.Client/GameState/Options.cpp | 8 +++++++- Minecraft.Client/Rendering/GameRenderer.cpp | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Minecraft.Client/GameState/Options.cpp b/Minecraft.Client/GameState/Options.cpp index ed1f7eca5..06b08d5bd 100644 --- a/Minecraft.Client/GameState/Options.cpp +++ b/Minecraft.Client/GameState/Options.cpp @@ -116,7 +116,13 @@ void Options::init() bobView = true; anaglyph3d = false; advancedOpengl = false; + + //4JCRAFT V-Sync / VSync + #ifdef ENABLE_VSYNC framerateLimit = 2; + #else + framerateLimit = 3; + #endif fancyGraphics = true; ambientOcclusion = true; renderClouds = true; @@ -522,4 +528,4 @@ void Options::save() bool Options::isCloudsOn() { return viewDistance < 2 && renderClouds; -} \ No newline at end of file +} diff --git a/Minecraft.Client/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp index 9335fee5b..c81a243b8 100644 --- a/Minecraft.Client/Rendering/GameRenderer.cpp +++ b/Minecraft.Client/Rendering/GameRenderer.cpp @@ -2189,6 +2189,8 @@ int GameRenderer::getFpsCap(int option) int maxFps = 200; if (option == 1) maxFps = 120; if (option == 2) maxFps = 35; + if (option == 3) maxFps = 0; + return maxFps; } From bfc83f78306e51bbba04caf9c3f3e7693ba5d606 Mon Sep 17 00:00:00 2001 From: Emily <106335580+Vozath@users.noreply.github.com> Date: Wed, 11 Mar 2026 00:13:09 -0400 Subject: [PATCH 07/16] forgot to add meson.options --- meson.options | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 meson.options diff --git a/meson.options b/meson.options new file mode 100644 index 000000000..c10135e97 --- /dev/null +++ b/meson.options @@ -0,0 +1,4 @@ +option('enable_vsync', + type : 'boolean', + value : true, + description : 'Toggles weather V-Sync will be toggle on or off.') From c42f71ba22f297d99510ac5880e7f6eb355cc865 Mon Sep 17 00:00:00 2001 From: Sally Knight Date: Wed, 11 Mar 2026 07:13:48 +0300 Subject: [PATCH 08/16] fix: restore and fix entity, block and hand lighting Block and entity light layers are done differently for now due to some caveats with light map transformation --- 4J.Render/4J_Render.cpp | 15 +++++++- 4J.Render/4J_Render.h | 2 +- .../Leaderboards/LeaderboardManager.cpp | 2 -- .../Leaderboards/LinuxLeaderboardManager.cpp | 5 +++ .../Leaderboards/LinuxLeaderboardManager.h | 36 +++++++++++++++++++ Minecraft.Client/Rendering/GameRenderer.cpp | 19 ++++++---- Minecraft.Client/Rendering/GameRenderer.h | 2 +- Minecraft.Client/Rendering/LevelRenderer.cpp | 8 ++--- Minecraft.Client/Rendering/Tesselator.cpp | 8 ++++- 9 files changed, 80 insertions(+), 17 deletions(-) create mode 100644 Minecraft.Client/Platform/Linux/Leaderboards/LinuxLeaderboardManager.cpp create mode 100644 Minecraft.Client/Platform/Linux/Leaderboards/LinuxLeaderboardManager.h diff --git a/4J.Render/4J_Render.cpp b/4J.Render/4J_Render.cpp index c16920e82..3ac57d9a6 100644 --- a/4J.Render/4J_Render.cpp +++ b/4J.Render/4J_Render.cpp @@ -560,7 +560,7 @@ void C4JRender::TextureBind(int idx) } } -void C4JRender::TextureBindVertex(int idx) +void C4JRender::TextureBindVertex(int idx, bool scaleLight) { // Unit 1 used for lightmapping in fixed-function or standard shaders ::glActiveTexture(GL_TEXTURE1); @@ -574,7 +574,20 @@ void C4JRender::TextureBindVertex(int idx) ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); ::glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + + // 4jcraft: jank workaround for entities + // referenced from the disabled code in GameRenderer::turnOnLightLayer + if (scaleLight) + { + ::glMatrixMode(GL_TEXTURE); + ::glLoadIdentity(); + float s = 1 / 16.0f / 15.0f * 15 / 16; + ::glScalef(s, s, s); + ::glTranslatef(8.0f, 8.0f, 8.0f); + ::glMatrixMode(GL_MODELVIEW); + } } + ::glActiveTexture(GL_TEXTURE0); ::glFlush(); } diff --git a/4J.Render/4J_Render.h b/4J.Render/4J_Render.h index 738ab91eb..aa69717bc 100644 --- a/4J.Render/4J_Render.h +++ b/4J.Render/4J_Render.h @@ -155,7 +155,7 @@ public: int TextureCreate(); void TextureFree(int idx); void TextureBind(int idx); - void TextureBindVertex(int idx); + void TextureBindVertex(int idx, bool scaleLight = false); void TextureSetTextureLevels(int levels); int TextureGetTextureLevels(); void TextureData(int width, int height, void *data, int level, eTextureFormat format = TEXTURE_FORMAT_RxGyBzAw); diff --git a/Minecraft.Client/Platform/Common/Leaderboards/LeaderboardManager.cpp b/Minecraft.Client/Platform/Common/Leaderboards/LeaderboardManager.cpp index 996a678f1..6afee4421 100644 --- a/Minecraft.Client/Platform/Common/Leaderboards/LeaderboardManager.cpp +++ b/Minecraft.Client/Platform/Common/Leaderboards/LeaderboardManager.cpp @@ -9,8 +9,6 @@ const std::wstring LeaderboardManager::filterNames[eNumFilterModes] = L"Friends", L"MyScore", L"TopRank" }; -LeaderboardManager *LeaderboardManager::m_instance = NULL; - void LeaderboardManager::DeleteInstance() { delete m_instance; diff --git a/Minecraft.Client/Platform/Linux/Leaderboards/LinuxLeaderboardManager.cpp b/Minecraft.Client/Platform/Linux/Leaderboards/LinuxLeaderboardManager.cpp new file mode 100644 index 000000000..ebb870584 --- /dev/null +++ b/Minecraft.Client/Platform/Linux/Leaderboards/LinuxLeaderboardManager.cpp @@ -0,0 +1,5 @@ +#include "../../../../Minecraft.World/Platform/stdafx.h" + +#include "LinuxLeaderboardManager.h" + +LeaderboardManager *LeaderboardManager::m_instance = new LinuxLeaderboardManager(); //Singleton instance of the LeaderboardManager \ No newline at end of file diff --git a/Minecraft.Client/Platform/Linux/Leaderboards/LinuxLeaderboardManager.h b/Minecraft.Client/Platform/Linux/Leaderboards/LinuxLeaderboardManager.h new file mode 100644 index 000000000..50696c37d --- /dev/null +++ b/Minecraft.Client/Platform/Linux/Leaderboards/LinuxLeaderboardManager.h @@ -0,0 +1,36 @@ +#pragma once + +#include "../../Common/Leaderboards/LeaderboardManager.h" + +class LinuxLeaderboardManager : public LeaderboardManager +{ +public: + virtual void Tick() {} + + //Open a session + virtual bool OpenSession() { return true; } + + //Close a session + virtual void CloseSession() {} + + //Delete a session + virtual void DeleteSession() {} + + //Write the given stats + //This is called synchronously and will not free any memory allocated for views when it is done + + virtual bool WriteStats(unsigned int viewCount, ViewIn views) { return false; } + + virtual bool ReadStats_Friends(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID) { return false; } + virtual bool ReadStats_MyScore(LeaderboardReadListener *callback, int difficulty, EStatsType type, PlayerUID myUID, unsigned int readCount) { return false; } + virtual bool ReadStats_TopRank(LeaderboardReadListener *callback, int difficulty, EStatsType type, unsigned int startIndex, unsigned int readCount) { return false; } + + //Perform a flush of the stats + virtual void FlushStats() {} + + //Cancel the current operation + virtual void CancelOperation() {} + + //Is the leaderboard manager idle. + virtual bool isIdle() { return true; } +}; diff --git a/Minecraft.Client/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp index 9335fee5b..46bb4ea86 100644 --- a/Minecraft.Client/Rendering/GameRenderer.cpp +++ b/Minecraft.Client/Rendering/GameRenderer.cpp @@ -777,14 +777,14 @@ void GameRenderer::renderItemInHand(float a, int eye) { if (!mc->options->hideGui && !mc->gameMode->isCutScene()) { - //turnOnLightLayer(a); // 4jcraft: disable light layer on handrenderer similarly to how it was done on the chunk render (this makes the hand look proper) + turnOnLightLayer(a, true); PIXBeginNamedEvent(0,"Item in hand render"); // 4jcraft: add null pointer check to itemInHandRenderer to prevent a occasional seg fault if (itemInHandRenderer != nullptr) { itemInHandRenderer->render(a); } PIXEndNamedEvent(); - //turnOffLightLayer(a); // 4jcraft: disable light layer on handrenderer similarly to how it was done on the chunk render (this makes the hand look proper) + turnOffLightLayer(a); } } glPopMatrix(); @@ -806,21 +806,26 @@ void GameRenderer::renderItemInHand(float a, int eye) // 4J - change brought forward from 1.8.2 void GameRenderer::turnOffLightLayer(double alpha) { // 4J - TODO -#if 0 + // 4jcraft: manually handle this in order to ensure that the light layer is turned off correctly +#if 1 if (SharedConstants::TEXTURE_LIGHTING) { glClientActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1); + glMatrixMode(GL_TEXTURE); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); glDisable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, 0); glClientActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0); } #endif - RenderManager.TextureBindVertex(-1); + //RenderManager.TextureBindVertex(-1); } // 4J - change brought forward from 1.8.2 -void GameRenderer::turnOnLightLayer(double alpha) +void GameRenderer::turnOnLightLayer(double alpha, bool scaleLight) { // 4J - TODO #if 0 if (SharedConstants::TEXTURE_LIGHTING) @@ -851,7 +856,7 @@ void GameRenderer::turnOnLightLayer(double alpha) #endif // update light texture // todo: check implementation of getLightTexture. - RenderManager.TextureBindVertex(getLightTexture(mc->player->GetXboxPad(), mc->level)); + RenderManager.TextureBindVertex(getLightTexture(mc->player->GetXboxPad(), mc->level), scaleLight); #if 0 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -971,7 +976,7 @@ void GameRenderer::updateLightTexture(float a) int g = (int) (_g * 255); int b = (int) (_b * 255); -#if ( defined _DURANGO || defined _WIN64 || __PSVITA__ ) +#if ( defined _DURANGO || defined _WIN64 || __PSVITA__ || __linux__ ) lightPixels[j][i] = a << 24 | b << 16 | g << 8 | r; #elif ( defined _XBOX || defined __ORBIS__ ) lightPixels[j][i] = a << 24 | r << 16 | g << 8 | b; diff --git a/Minecraft.Client/Rendering/GameRenderer.h b/Minecraft.Client/Rendering/GameRenderer.h index 5026704bb..f5cdedecc 100644 --- a/Minecraft.Client/Rendering/GameRenderer.h +++ b/Minecraft.Client/Rendering/GameRenderer.h @@ -104,7 +104,7 @@ public: float blg; float blgt; void turnOffLightLayer(double alpha); - void turnOnLightLayer(double alpha); + void turnOnLightLayer(double alpha, bool scaleLight = false); private: void tickLightTexture(); void updateLightTexture(float a); diff --git a/Minecraft.Client/Rendering/LevelRenderer.cpp b/Minecraft.Client/Rendering/LevelRenderer.cpp index 538529ac4..01d97cf09 100644 --- a/Minecraft.Client/Rendering/LevelRenderer.cpp +++ b/Minecraft.Client/Rendering/LevelRenderer.cpp @@ -518,7 +518,7 @@ void LevelRenderer::renderEntities(Vec3 *cam, Culler *culler, float a) TileEntityRenderDispatcher::yOff = (player->yOld + (player->y - player->yOld) * a); TileEntityRenderDispatcher::zOff = (player->zOld + (player->z - player->zOld) * a); - // mc->gameRenderer->turnOnLightLayer(a); // 4J - brought forward from 1.8.2 + mc->gameRenderer->turnOnLightLayer(a, true); // 4J - brought forward from 1.8.2 std::vector > entities = level[playerIndex]->getAllEntities(); totalEntities = (int)entities.size(); @@ -600,7 +600,7 @@ void LevelRenderer::renderEntities(Vec3 *cam, Culler *culler, float a) LeaveCriticalSection(&m_csRenderableTileEntities); - // mc->gameRenderer->turnOffLightLayer(a); // 4J - brought forward from 1.8.2 + mc->gameRenderer->turnOffLightLayer(a); // 4J - brought forward from 1.8.2 } std::wstring LevelRenderer::gatherStats1() @@ -742,7 +742,7 @@ int LevelRenderer::renderChunks(int from, int to, int layer, double alpha) #if 1 // 4J - cut down version, we're not using offsetted render lists, or a sorted chunk list, anymore - // mc->gameRenderer->turnOnLightLayer(alpha); // 4J - brought forward from 1.8.2 + mc->gameRenderer->turnOnLightLayer(alpha); // 4J - brought forward from 1.8.2 shared_ptr player = mc->cameraTargetPlayer; double xOff = player->xOld + (player->x - player->xOld) * alpha; double yOff = player->yOld + (player->y - player->yOld) * alpha; @@ -838,7 +838,7 @@ int LevelRenderer::renderChunks(int from, int to, int layer, double alpha) #endif // __PS3__ glPopMatrix(); - // mc->gameRenderer->turnOffLightLayer(alpha); // 4J - brought forward from 1.8.2 + mc->gameRenderer->turnOffLightLayer(alpha); // 4J - brought forward from 1.8.2 #else _renderChunks.clear(); diff --git a/Minecraft.Client/Rendering/Tesselator.cpp b/Minecraft.Client/Rendering/Tesselator.cpp index e1c7373b3..821ec037b 100644 --- a/Minecraft.Client/Rendering/Tesselator.cpp +++ b/Minecraft.Client/Rendering/Tesselator.cpp @@ -942,9 +942,15 @@ void Tesselator::vertex(float x, float y, float z) #ifdef _XBOX _array->data[p + 7] = ( ( _tex2 >> 16 ) & 0xffff ) | ( _tex2 << 16 ); #else - #ifdef __PS3__ + // 4jcraft: we will be lighting the blocks right in here + #if defined(__PS3__) || defined (__linux__) + #ifdef __PS3__ int16_t tex2U = ((int16_t*)&_tex2)[1] + 8; int16_t tex2V = ((int16_t*)&_tex2)[0] + 8; + #else + int16_t tex2U = ((int16_t*)&_tex2)[0] + 8; + int16_t tex2V = ((int16_t*)&_tex2)[1] + 8; + #endif int16_t* pShortArray = (int16_t*)&_array->data[p + 7]; pShortArray[0] = tex2U; pShortArray[1] = tex2V; From 4e286dd92c691460f423b79e45ff14be68771143 Mon Sep 17 00:00:00 2001 From: Emily <106335580+Vozath@users.noreply.github.com> Date: Wed, 11 Mar 2026 00:29:19 -0400 Subject: [PATCH 09/16] ifdef the option 3 --- Minecraft.Client/Rendering/GameRenderer.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Minecraft.Client/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp index c81a243b8..bf7a01f28 100644 --- a/Minecraft.Client/Rendering/GameRenderer.cpp +++ b/Minecraft.Client/Rendering/GameRenderer.cpp @@ -2189,8 +2189,9 @@ int GameRenderer::getFpsCap(int option) int maxFps = 200; if (option == 1) maxFps = 120; if (option == 2) maxFps = 35; + #ifndef ENABLE_VSYNC if (option == 3) maxFps = 0; - + #endif return maxFps; } From 559cdfd2810ad95e345b43c9cfcfe14e45abe7dd Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Tue, 10 Mar 2026 23:31:13 -0500 Subject: [PATCH 10/16] chore: remove test prints --- Minecraft.Client/Player/LocalPlayer.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Minecraft.Client/Player/LocalPlayer.cpp b/Minecraft.Client/Player/LocalPlayer.cpp index 9653cf19e..d2b4cb83c 100644 --- a/Minecraft.Client/Player/LocalPlayer.cpp +++ b/Minecraft.Client/Player/LocalPlayer.cpp @@ -316,7 +316,6 @@ void LocalPlayer::aiStep() { if( sprintTriggerRegisteredReturn ) { - printf("setSprinting true\n"); setSprinting(true); sprintTriggerTime = 0; sprintTriggerRegisteredReturn = false; @@ -329,7 +328,6 @@ void LocalPlayer::aiStep() } else if (input->sprintKey) { - printf("setSprinting true\n"); setSprinting(true); } } From 19bc286818ab1f9fb5e2864bf6eecc28fcd0faeb Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Tue, 10 Mar 2026 23:33:12 -0500 Subject: [PATCH 11/16] chore: remove another test print --- Minecraft.Client/Player/LocalPlayer.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Minecraft.Client/Player/LocalPlayer.cpp b/Minecraft.Client/Player/LocalPlayer.cpp index d2b4cb83c..91adb3300 100644 --- a/Minecraft.Client/Player/LocalPlayer.cpp +++ b/Minecraft.Client/Player/LocalPlayer.cpp @@ -336,7 +336,6 @@ void LocalPlayer::aiStep() //if (isSprinting() && (input->ya < runTreshold || horizontalCollision || !enoughFoodToSprint)) if (isSprinting() && ((input->ya < runTreshold && !input->sprintKey) || !enoughFoodToSprint)) { - printf("setSprinting false\n"); setSprinting(false); } From c9f19ebcbadcdbd8df50562d8a8554febdacdc15 Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Wed, 11 Mar 2026 00:03:04 -0500 Subject: [PATCH 12/16] fix: undo turnOnLightLayer comment --- Minecraft.Client/Rendering/GameRenderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Minecraft.Client/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp index 6a0fe0d4c..9335fee5b 100644 --- a/Minecraft.Client/Rendering/GameRenderer.cpp +++ b/Minecraft.Client/Rendering/GameRenderer.cpp @@ -1619,7 +1619,7 @@ void GameRenderer::renderSnowAndRain(float a) // 4J - rain is relatively low poly, but high fill-rate - better to clip it RenderManager.StateSetEnableViewportClipPlanes(true); - //this->turnOnLightLayer(a); + this->turnOnLightLayer(a); if (rainXa == NULL) { From 5b4319556d0ba3703ffd65c93f0b15f67ab394fa Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Wed, 11 Mar 2026 00:20:23 -0500 Subject: [PATCH 13/16] refactor: remove redundant casts in MoveEntityPacket --- .../Network/Packets/MoveEntityPacket.cpp | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/Minecraft.World/Network/Packets/MoveEntityPacket.cpp b/Minecraft.World/Network/Packets/MoveEntityPacket.cpp index 6b5cc94c8..241f5f021 100644 --- a/Minecraft.World/Network/Packets/MoveEntityPacket.cpp +++ b/Minecraft.World/Network/Packets/MoveEntityPacket.cpp @@ -71,22 +71,22 @@ MoveEntityPacket::PosRot::PosRot() MoveEntityPacket::PosRot::PosRot(int id, int8_t xa, int8_t ya, int8_t za, int8_t yRot, int8_t xRot) : MoveEntityPacket( id ) { - this->xa = (int)(int8_t)xa; - this->ya = (int)(int8_t)ya; - this->za = (int)(int8_t)za; - this->yRot = (int)(int8_t)yRot; - this->xRot = (int)(int8_t)xRot; + this->xa = xa; + this->ya = ya; + this->za = za; + this->yRot = yRot; + this->xRot = xRot; hasRot = true; } void MoveEntityPacket::PosRot::read(DataInputStream *dis) //throws IOException { MoveEntityPacket::read(dis); - xa = (int)(int8_t)dis->readByte(); - ya = (int)(int8_t)dis->readByte(); - za = (int)(int8_t)dis->readByte(); - yRot = (int)(int8_t)dis->readByte(); - xRot = (int)(int8_t)dis->readByte(); + xa = (int8_t)dis->readByte(); + ya = (int8_t)dis->readByte(); + za = (int8_t)dis->readByte(); + yRot = (int8_t)dis->readByte(); + xRot = (int8_t)dis->readByte(); } void MoveEntityPacket::PosRot::write(DataOutputStream *dos) //throws IOException @@ -118,9 +118,9 @@ MoveEntityPacket::Pos::Pos(int id, int8_t xa, int8_t ya, int8_t za) : MoveEntity void MoveEntityPacket::Pos::read(DataInputStream *dis) //throws IOException { MoveEntityPacket::read(dis); - xa = (int)(int8_t)dis->readByte(); - ya = (int)(int8_t)dis->readByte(); - za = (int)(int8_t)dis->readByte(); + xa = (int8_t)dis->readByte(); + ya = (int8_t)dis->readByte(); + za = (int8_t)dis->readByte(); } void MoveEntityPacket::Pos::write(DataOutputStream *dos) //throws IOException @@ -151,8 +151,8 @@ MoveEntityPacket::Rot::Rot(int id, int8_t yRot, int8_t xRot) : MoveEntityPacket( void MoveEntityPacket::Rot::read(DataInputStream *dis) //throws IOException { MoveEntityPacket::read(dis); - yRot = (int)(int8_t)dis->readByte(); - xRot = (int)(int8_t)dis->readByte(); + yRot = (int8_t)dis->readByte(); + xRot = (int8_t)dis->readByte(); } void MoveEntityPacket::Rot::write(DataOutputStream *dos) //throws IOException From 2f92fb2805775dd531694a3507e3d3c3caf57009 Mon Sep 17 00:00:00 2001 From: "Echo J." Date: Wed, 11 Mar 2026 08:01:09 +0000 Subject: [PATCH 14/16] CI: Re-add missing cmake dependency Fixes a silent ccache not found error (which prevents ccache from working) --- .github/workflows/build-linux.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index fceea68b3..745a3b9df 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -32,7 +32,7 @@ jobs: - name: Install system dependencies run: | sudo apt-get update - sudo apt-get install -y build-essential python3 ninja-build meson libsdl2-dev libgl-dev libglu1-mesa-dev libpthread-stubs0-dev + sudo apt-get install -y build-essential ccache python3 ninja-build meson libsdl2-dev libgl-dev libglu1-mesa-dev libpthread-stubs0-dev # Set a reasonable ccache size ccache -M 5G || true @@ -86,7 +86,7 @@ jobs: - name: Install system dependencies run: | sudo apt-get update - sudo apt-get install -y build-essential python3 ninja-build meson libsdl2-dev libgl-dev libglu1-mesa-dev libpthread-stubs0-dev + sudo apt-get install -y build-essential ccache python3 ninja-build meson libsdl2-dev libgl-dev libglu1-mesa-dev libpthread-stubs0-dev # Set a reasonable ccache size ccache -M 5G || true From e9fe7fee4d2451dcf69db1cf617da79a91eced32 Mon Sep 17 00:00:00 2001 From: "Echo J." Date: Wed, 11 Mar 2026 08:07:00 +0000 Subject: [PATCH 15/16] LevelRenderer: Add missing namespace for player variable This caused compile errors on my GitHub Actions instance --- Minecraft.Client/Rendering/LevelRenderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Minecraft.Client/Rendering/LevelRenderer.cpp b/Minecraft.Client/Rendering/LevelRenderer.cpp index 01d97cf09..51436e959 100644 --- a/Minecraft.Client/Rendering/LevelRenderer.cpp +++ b/Minecraft.Client/Rendering/LevelRenderer.cpp @@ -743,7 +743,7 @@ int LevelRenderer::renderChunks(int from, int to, int layer, double alpha) #if 1 // 4J - cut down version, we're not using offsetted render lists, or a sorted chunk list, anymore mc->gameRenderer->turnOnLightLayer(alpha); // 4J - brought forward from 1.8.2 - shared_ptr player = mc->cameraTargetPlayer; + std::shared_ptr player = mc->cameraTargetPlayer; double xOff = player->xOld + (player->x - player->xOld) * alpha; double yOff = player->yOld + (player->y - player->yOld) * alpha; double zOff = player->zOld + (player->z - player->zOld) * alpha; From 9add609856be6343d046373a339e5b34aba34d9a Mon Sep 17 00:00:00 2001 From: Hadi Chokr Date: Wed, 11 Mar 2026 08:24:28 +0100 Subject: [PATCH 16/16] flake.nix: Fix Input and make it a real package --- .gitignore | 3 +++ flake.nix | 65 +++++++++++++++++++++++++++++++++--------------------- 2 files changed, 43 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 0c9c8e1f4..185d7a0a8 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ builddir/ build_meson/ cmake-build-debug/ +# Nix flake output +result + # Final binaries and platform output /Linux/ /x64/ diff --git a/flake.nix b/flake.nix index dc9acfbb7..a4eaaf3a1 100644 --- a/flake.nix +++ b/flake.nix @@ -1,11 +1,11 @@ { - description = "4jcraft-nix dev shell"; + description = "4jcraft-nix package and dev shell"; inputs = { nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; }; - outputs = { nixpkgs, ... }: + outputs = { self, nixpkgs, ... }: let allSystems = [ "x86_64-linux" @@ -19,30 +19,45 @@ }); in { - devShells = forAllSystems ({ pkgs }: - let - libs = with pkgs; [ - openssl.dev - libGL - libGLU - sdl2 - zlib - ]; - packages = with pkgs; [ - clang - lld - cmake - gnumake - meson - ninja - pkg-config - ]; - in + packages = forAllSystems ({ pkgs }: { - default = pkgs.mkShell { - LD_LIBRARY_PATH = "/run/opengl-driver/lib"; - buildInputs = libs; - nativeBuildInputs = packages; + default = pkgs.clangStdenv.mkDerivation { + pname = "4jcraft"; + version = "0.1.0"; + + src = ./.; + + buildInputs = with pkgs; [ + openssl.dev + libGL + libGLU + SDL2 + zlib + ]; + + nativeBuildInputs = with pkgs; [ + lld + meson + ninja + pkg-config + python3 + makeWrapper + ]; + + installPhase = '' + mkdir -p $out/share/4jcraft + cp -r Minecraft.Client/. $out/share/4jcraft/ + + mkdir -p $out/bin + makeWrapper $out/share/4jcraft/Minecraft.Client \ + $out/bin/4jcraft \ + --run "cd $out/share/4jcraft" + ''; + + meta = { + description = "4JCraft"; + platforms = pkgs.lib.platforms.linux; + }; }; } );