This commit is contained in:
MijaeLio 2026-03-03 16:24:55 -05:00
commit 0beb5b4dad
17 changed files with 134 additions and 87 deletions

55
.clang-format Normal file
View file

@ -0,0 +1,55 @@
---
BasedOnStyle: Microsoft
AccessModifierOffset: -2
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: Always
AfterEnum: true
AfterExternBlock: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
ColumnLimit: 0
IncludeBlocks: Preserve
IndentAccessModifiers: false
IndentCaseBlocks: true
IndentCaseLabels: false
IndentExportBlock: true
IndentExternBlock: AfterExternBlock
IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 4
InsertBraces: true
InsertNewlineAtEOF: true
NamespaceIndentation: None
PointerAlignment: Right
RemoveParentheses: Leave
RemoveSemicolon: false
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SkipMacroDefinitionBody: false
SortIncludes:
Enabled: true
IgnoreCase: false
SpacesInParens: Never
SpacesInParensOptions:
ExceptDoubleParentheses: false
InCStyleCasts: false
InConditionalStatements: false
InEmptyParentheses: false
Other: false
SpacesInSquareBrackets: false
Standard: Latest
TabWidth: 4
UseTab: Never

View file

@ -1,23 +1,23 @@
# Pull Request <!--
Note: IF YOUR PR CHANGES THE GAME BEHAVIOR VISIBLY, REMEMBER TO ATTACH A GAMEPLAY FOOTAGE (or at least a screenshot) OF YOU *ACTUALLY* PLAYING THE GAME WITH YOUR CHANGES. Untested PRs are *NOT* welcome. Please don't forget to describe what did you do in each commit in your PR.
## Note: IF YOUR PR CHANGES THE GAME BEHAVIOR VISIBLY, REMEMBER TO ATTACH A GAMEPLAY FOOTAGE (or at least a screenshot) OF YOU *ACTUALLY* PLAYING THE GAME WITH YOUR CHANGES. Untested PRs are *NOT* welcome. Please don't forget to describe what did you do in each commit in your PR. -->
## Description ## Description
Briefly describe the changes this PR introduces. <!-- Briefly describe the changes this PR introduces. -->
## Changes ## Changes
### Previous Behavior ### Previous Behavior
*Describe how the code behaved before this change.* <!-- Describe how the code behaved before this change. -->
### Root Cause ### Root Cause
*Explain the core reason behind the erroneous/old behavior (e.g., bug, design flaw, missing edge case).* <!-- Explain the core reason behind the erroneous/old behavior (e.g., bug, design flaw, missing edge case). -->
### New Behavior ### New Behavior
*Describe how the code behaves after this change.* <!-- Describe how the code behaves after this change. -->
### Fix Implementation ### Fix Implementation
*Detail exactly how the issue was resolved (specific code changes, algorithms, logic flows).* <!-- Detail exactly how the issue was resolved (specific code changes, algorithms, logic flows). -->
## Related Issues ## Related Issues
- Fixes #[issue-number] - Fixes #[issue-number]

View file

@ -8,6 +8,7 @@ on:
paths-ignore: paths-ignore:
- '.gitignore' - '.gitignore'
- '*.md' - '*.md'
- '.github/*.md'
jobs: jobs:
build: build:
@ -35,5 +36,8 @@ jobs:
with: with:
tag_name: nightly tag_name: nightly
name: Nightly Release name: Nightly Release
body: Compiled with MSVC v14.44.35207 in Release mode with Whole Program Optimization, as well as `/O2 /Ot /Oi /Ob3 /GF`. (So far the floating point model is `/fp:strict` to avoid undefined behavior before we refactor for performance). Requires at least Windows 7 and DirectX 11 compatible GPU to run. body: Requires at least Windows 7 and DirectX 11 compatible GPU to run. Compiled with MSVC v14.44.35207 in Release mode with Whole Program Optimization, as well as `/O2 /Ot /Oi /Ob3 /GF /fp:precise`.
files: LCEWindows64.zip files: |
LCEWindows64.zip
./x64/Release/Minecraft.Client.exe
./x64/Release/Minecraft.Client.pdb

View file

@ -829,6 +829,7 @@ enum EControllerActions
ACTION_MENU_OTHER_STICK_LEFT, ACTION_MENU_OTHER_STICK_LEFT,
ACTION_MENU_OTHER_STICK_RIGHT, ACTION_MENU_OTHER_STICK_RIGHT,
ACTION_MENU_PAUSEMENU, ACTION_MENU_PAUSEMENU,
ACTION_MENU_QUICK_MOVE,
#ifdef _DURANGO #ifdef _DURANGO
ACTION_MENU_GTC_PAUSE, ACTION_MENU_GTC_PAUSE,

View file

@ -1978,7 +1978,7 @@ bool CGameNetworkManager::AllowedToPlayMultiplayer(int playerIdx)
return ProfileManager.AllowedToPlayMultiplayer(playerIdx); return ProfileManager.AllowedToPlayMultiplayer(playerIdx);
} }
char *CGameNetworkManager::GetOnlineName(int playerIdx) const char *CGameNetworkManager::GetOnlineName(int playerIdx)
{ {
return ProfileManager.GetGamertag(playerIdx); return ProfileManager.GetGamertag(playerIdx);
} }

View file

@ -196,7 +196,7 @@ private:
int GetLockedProfile(); int GetLockedProfile();
bool IsSignedInLive(int playerIdx); bool IsSignedInLive(int playerIdx);
bool AllowedToPlayMultiplayer(int playerIdx); bool AllowedToPlayMultiplayer(int playerIdx);
char *GetOnlineName(int playerIdx); const char *GetOnlineName(int playerIdx);
C4JThread::Event* m_hServerStoppedEvent; C4JThread::Event* m_hServerStoppedEvent;
C4JThread::Event* m_hServerReadyEvent; C4JThread::Event* m_hServerReadyEvent;

View file

@ -1304,42 +1304,60 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b
#endif #endif
int buttonNum=0; // 0 = LeftMouse, 1 = RightMouse int buttonNum=0; // 0 = LeftMouse, 1 = RightMouse
BOOL quickKeyHeld=FALSE; // Represents shift key on PC BOOL quickKeyHeld=false; // Represents shift key on PC
BOOL quickKeyDown = false; // Represents shift key on PC
BOOL validKeyPress = FALSE; BOOL validKeyPress = false;
bool itemEditorKeyPress = false; bool itemEditorKeyPress = false;
// Ignore input from other players // Ignore input from other players
//if(pMinecraft->player->GetXboxPad()!=pInputData->UserIndex) return S_OK; //if(pMinecraft->player->GetXboxPad()!=pInputData->UserIndex) return S_OK;
switch(iAction) switch(iAction)
{ {
#ifdef _DEBUG_MENUS_ENABLED #ifdef _DEBUG_MENUS_ENABLED
case ACTION_MENU_OTHER_STICK_PRESS: case ACTION_MENU_OTHER_STICK_PRESS:
itemEditorKeyPress = TRUE; itemEditorKeyPress = TRUE;
break; break;
#endif #endif
case ACTION_MENU_A: case ACTION_MENU_A:
#ifdef __ORBIS__ #ifdef __ORBIS__
case ACTION_MENU_TOUCHPAD_PRESS: case ACTION_MENU_TOUCHPAD_PRESS:
#endif #endif
if(!bRepeat) if (!bRepeat)
{ {
validKeyPress = TRUE; validKeyPress = TRUE;
// Standard left click // Standard left click
buttonNum = 0; buttonNum = 0;
quickKeyHeld = FALSE; if (KMInput.IsKeyDown(VK_SHIFT))
if( IsSectionSlotList( m_eCurrSection ) )
{ {
int currentIndex = getCurrentIndex( m_eCurrSection ) - getSectionStartOffset(m_eCurrSection); {
validKeyPress = TRUE;
bool bSlotHasItem = !isSlotEmpty(m_eCurrSection, currentIndex); // Shift and left click
if ( bSlotHasItem ) buttonNum = 0;
ui.PlayUISFX(eSFX_Press); quickKeyHeld = TRUE;
if (IsSectionSlotList(m_eCurrSection))
{
int currentIndex = getCurrentIndex(m_eCurrSection) - getSectionStartOffset(m_eCurrSection);
bool bSlotHasItem = !isSlotEmpty(m_eCurrSection, currentIndex);
if (bSlotHasItem)
ui.PlayUISFX(eSFX_Press);
}
}
}
else {
if (IsSectionSlotList(m_eCurrSection))
{
int currentIndex = getCurrentIndex(m_eCurrSection) - getSectionStartOffset(m_eCurrSection);
bool bSlotHasItem = !isSlotEmpty(m_eCurrSection, currentIndex);
if (bSlotHasItem)
ui.PlayUISFX(eSFX_Press);
}
//
} }
//
} }
break; break;
case ACTION_MENU_X: case ACTION_MENU_X:
@ -1361,6 +1379,7 @@ bool IUIScene_AbstractContainerMenu::handleKeyDown(int iPad, int iAction, bool b
} }
} }
break; break;
case ACTION_MENU_Y: case ACTION_MENU_Y:
if(!bRepeat) if(!bRepeat)
{ {

View file

@ -1012,6 +1012,7 @@ void UIController::handleKeyPress(unsigned int iPad, unsigned int key)
case ACTION_MENU_PAUSEMENU: kbDown = KMInput.IsKeyDown(VK_ESCAPE); kbPressed = KMInput.IsKeyPressed(VK_ESCAPE); kbReleased = KMInput.IsKeyReleased(VK_ESCAPE); break; case ACTION_MENU_PAUSEMENU: kbDown = KMInput.IsKeyDown(VK_ESCAPE); kbPressed = KMInput.IsKeyPressed(VK_ESCAPE); kbReleased = KMInput.IsKeyReleased(VK_ESCAPE); break;
case ACTION_MENU_LEFT_SCROLL: kbDown = KMInput.IsKeyDown('Q'); kbPressed = KMInput.IsKeyPressed('Q'); kbReleased = KMInput.IsKeyReleased('Q'); break; case ACTION_MENU_LEFT_SCROLL: kbDown = KMInput.IsKeyDown('Q'); kbPressed = KMInput.IsKeyPressed('Q'); kbReleased = KMInput.IsKeyReleased('Q'); break;
case ACTION_MENU_RIGHT_SCROLL: kbDown = KMInput.IsKeyDown('E'); kbPressed = KMInput.IsKeyPressed('E'); kbReleased = KMInput.IsKeyReleased('E'); break; case ACTION_MENU_RIGHT_SCROLL: kbDown = KMInput.IsKeyDown('E'); kbPressed = KMInput.IsKeyPressed('E'); kbReleased = KMInput.IsKeyReleased('E'); break;
case ACTION_MENU_QUICK_MOVE: kbDown = KMInput.IsKeyDown(VK_SHIFT); kbPressed = KMInput.IsKeyPressed(VK_SHIFT); kbReleased = KMInput.IsKeyReleased(VK_SHIFT); break;
} }
pressed = pressed || kbPressed; pressed = pressed || kbPressed;
released = released || kbReleased; released = released || kbReleased;

View file

@ -77,12 +77,7 @@ void EnderDragonRenderer::renderModel(shared_ptr<LivingEntity> _mob, float wp, f
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(1, 0, 0, 0.5f); glColor4f(1, 0, 0, 0.5f);
#ifdef __PSVITA__
// AP - not sure that the usecompiled flag is supposed to be false. This makes it really slow on vita. Making it true still seems to look the same
model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, true); model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, true);
#else
model->render(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale, false);
#endif
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glDisable(GL_BLEND); glDisable(GL_BLEND);
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);

View file

@ -589,8 +589,21 @@ char fakeGamerTag[32] = "PlayerName";
void SetFakeGamertag(char* name) { strcpy_s(fakeGamerTag, name); } void SetFakeGamertag(char* name) { strcpy_s(fakeGamerTag, name); }
char* C_4JProfile::GetGamertag(int iPad) { return fakeGamerTag; } char* C_4JProfile::GetGamertag(int iPad) { return fakeGamerTag; }
#else #else
char* C_4JProfile::GetGamertag(int iPad) { extern char g_Win64Username[17]; return g_Win64Username; } #include <windows.h>
wstring C_4JProfile::GetDisplayName(int iPad) { extern wchar_t g_Win64UsernameW[17]; return g_Win64UsernameW; }
const char* C_4JProfile::GetGamertag(int iPad)
{
static std::string narrowName;
const wchar_t* wideName = g_playerName.c_str();
int sizeNeeded = WideCharToMultiByte(CP_UTF8, 0, wideName, -1, nullptr, 0, nullptr, nullptr);
narrowName.resize(sizeNeeded);
WideCharToMultiByte(CP_UTF8, 0, wideName, -1, &narrowName[0], sizeNeeded, nullptr, nullptr);
return narrowName.c_str();
}
wstring C_4JProfile::GetDisplayName(int iPad) { return g_playerName; }
#endif #endif
bool C_4JProfile::IsFullVersion() { return s_bProfileIsFullVersion; } bool C_4JProfile::IsFullVersion() { return s_bProfileIsFullVersion; }
void C_4JProfile::SetSignInChangeCallback(void (*Func)(LPVOID, bool, unsigned int), LPVOID lpParam) {} void C_4JProfile::SetSignInChangeCallback(void (*Func)(LPVOID, bool, unsigned int), LPVOID lpParam) {}

View file

@ -1964,8 +1964,8 @@ bool LevelRenderer::updateDirtyChunks()
{ {
if( (!onlyRebuild) || if( (!onlyRebuild) ||
globalChunkFlags[ pClipChunk->globalIdx ] & CHUNK_FLAG_COMPILED || globalChunkFlags[ pClipChunk->globalIdx ] & CHUNK_FLAG_COMPILED ||
( distSq < 20 * 20 ) ) // Always rebuild really near things or else building (say) at tower up into empty blocks when we are low on memory will not create render data ( distSq < 96 * 96 ) ) // Always rebuild really near things or else building (say) at tower up into empty blocks when we are low on memory will not create render data
{ { // distSq adjusted from 20 * 20 to 96 * 96 - updated by detectiveren
considered++; considered++;
// Is this chunk nearer than our nearest? // Is this chunk nearer than our nearest?
#ifdef _LARGE_WORLDS #ifdef _LARGE_WORLDS

View file

@ -52,14 +52,16 @@ public:
static const int CHUNK_SIZE = 16; static const int CHUNK_SIZE = 16;
#endif #endif
static const int CHUNK_Y_COUNT = Level::maxBuildHeight / CHUNK_SIZE; static const int CHUNK_Y_COUNT = Level::maxBuildHeight / CHUNK_SIZE;
#if (defined _XBOX_ONE || defined _WINDOWS64) #if defined _WINDOWS64
static const int MAX_COMMANDBUFFER_ALLOCATIONS = 2047 * 1024 * 1024; // Changed to 2047. 4J had set to 512. static const int MAX_COMMANDBUFFER_ALLOCATIONS = 2047 * 1024 * 1024; // Changed to 2047. 4J had set to 512.
#elif defined _XBOX_ONE
static const int MAX_COMMANDBUFFER_ALLOCATIONS = 512 * 1024 * 1024; // 4J - added
#elif defined __ORBIS__ #elif defined __ORBIS__
static const int MAX_COMMANDBUFFER_ALLOCATIONS = 448 * 1024 * 1024; // 4J - added - hard limit is 512 so giving a lot of headroom here for fragmentation (have seen 16MB lost to fragmentation in multiplayer crash dump before) static const int MAX_COMMANDBUFFER_ALLOCATIONS = 448 * 1024 * 1024; // 4J - added - hard limit is 512 so giving a lot of headroom here for fragmentation (have seen 16MB lost to fragmentation in multiplayer crash dump before)
#elif defined __PS3__ #elif defined __PS3__
static const int MAX_COMMANDBUFFER_ALLOCATIONS = 110 * 1024 * 1024; // 4J - added static const int MAX_COMMANDBUFFER_ALLOCATIONS = 110 * 1024 * 1024; // 4J - added
#else #else
static const int MAX_COMMANDBUFFER_ALLOCATIONS = 55 * 1024 * 1024; // 4J - added static const int MAX_COMMANDBUFFER_ALLOCATIONS = 55 * 1024 * 1024; // 4J - added
#endif #endif
public: public:
LevelRenderer(Minecraft *mc, Textures *textures); LevelRenderer(Minecraft *mc, Textures *textures);
@ -270,10 +272,10 @@ public:
bool dirtyChunkPresent; bool dirtyChunkPresent;
__int64 lastDirtyChunkFound; __int64 lastDirtyChunkFound;
static const int FORCE_DIRTY_CHUNK_CHECK_PERIOD_MS = 250; static const int FORCE_DIRTY_CHUNK_CHECK_PERIOD_MS = 125; // decreased from 250 to 125 - updated by detectiveren
#ifdef _LARGE_WORLDS #ifdef _LARGE_WORLDS
static const int MAX_CONCURRENT_CHUNK_REBUILDS = 4; static const int MAX_CONCURRENT_CHUNK_REBUILDS = 8; // increased from 4 to 8 - updated by detectiveren
static const int MAX_CHUNK_REBUILD_THREADS = MAX_CONCURRENT_CHUNK_REBUILDS - 1; static const int MAX_CHUNK_REBUILD_THREADS = MAX_CONCURRENT_CHUNK_REBUILDS - 1;
static Chunk permaChunk[MAX_CONCURRENT_CHUNK_REBUILDS]; static Chunk permaChunk[MAX_CONCURRENT_CHUNK_REBUILDS];
static C4JThread *rebuildThreads[MAX_CHUNK_REBUILD_THREADS]; static C4JThread *rebuildThreads[MAX_CHUNK_REBUILD_THREADS];

View file

@ -1456,7 +1456,7 @@ void Minecraft::run_middle()
if (KMInput.ConsumeKeyPress('C')) localplayers[i]->ullButtonsPressed |= 1LL<<MINECRAFT_ACTION_CRAFTING; if (KMInput.ConsumeKeyPress('C')) localplayers[i]->ullButtonsPressed |= 1LL<<MINECRAFT_ACTION_CRAFTING;
if (KMInput.ConsumeKeyPress(VK_F5)) localplayers[i]->ullButtonsPressed |= 1LL<<MINECRAFT_ACTION_RENDER_THIRD_PERSON; if (KMInput.ConsumeKeyPress(VK_F5)) localplayers[i]->ullButtonsPressed |= 1LL<<MINECRAFT_ACTION_RENDER_THIRD_PERSON;
// In flying mode, Shift held = sneak/descend // In flying mode, Shift held = sneak/descend
if (localplayers[i]->abilities.flying && KMInput.IsKeyDown(VK_SHIFT)) if (localplayers[i]->abilities.flying && KMInput.IsKeyDown(VK_SHIFT) && !ui.GetMenuDisplayed(i))
localplayers[i]->ullButtonsPressed |= 1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE; localplayers[i]->ullButtonsPressed |= 1LL<<MINECRAFT_ACTION_SNEAK_TOGGLE;
} }
#endif #endif

View file

@ -75,7 +75,7 @@ public:
// SYS // SYS
int GetPrimaryPad(); int GetPrimaryPad();
void SetPrimaryPad(int iPad); void SetPrimaryPad(int iPad);
char* GetGamertag(int iPad); const char* GetGamertag(int iPad);
wstring GetDisplayName(int iPad); wstring GetDisplayName(int iPad);
bool IsFullVersion(); bool IsFullVersion();
void SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam); void SetSignInChangeCallback(void ( *Func)(LPVOID, bool, unsigned int),LPVOID lpParam);

View file

@ -33,6 +33,7 @@ public:
virtual void TemporaryCreateGameStart(); virtual void TemporaryCreateGameStart();
bool m_bShutdown; bool m_bShutdown;
wstring g_playerName;
}; };
extern CConsoleMinecraftApp app; extern CConsoleMinecraftApp app;

View file

@ -85,8 +85,6 @@ BOOL g_bWidescreen = TRUE;
int g_iScreenWidth = 1920; int g_iScreenWidth = 1920;
int g_iScreenHeight = 1080; int g_iScreenHeight = 1080;
char g_Win64Username[17] = { 0 };
wchar_t g_Win64UsernameW[17] = { 0 };
UINT g_ScreenWidth = 1920; UINT g_ScreenWidth = 1920;
UINT g_ScreenHeight = 1080; UINT g_ScreenHeight = 1080;
@ -764,42 +762,8 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
//g_iScreenWidth = 960; //g_iScreenWidth = 960;
//g_iScreenHeight = 544; //g_iScreenHeight = 544;
} }
char cmdLineA[1024];
strncpy_s(cmdLineA, sizeof(cmdLineA), lpCmdLine, _TRUNCATE);
char* nameArg = strstr(cmdLineA, "-name ");
if (nameArg)
{
nameArg += 6;
while (*nameArg == ' ') nameArg++;
char nameBuf[17];
int n = 0;
while (nameArg[n] && nameArg[n] != ' ' && n < 16) { nameBuf[n] = nameArg[n]; n++; }
nameBuf[n] = 0;
strncpy_s(g_Win64Username, 17, nameBuf, _TRUNCATE);
}
} }
if (g_Win64Username[0] == 0)
{
DWORD sz = 17;
static bool seeded = false;
if (!seeded)
{
seeded = true;
srand((unsigned int)time(NULL));
}
int r = rand() % 10000; // 0<>9999
snprintf(g_Win64Username, 17, "Player%04d", r);
g_Win64Username[16] = 0;
}
MultiByteToWideChar(CP_ACP, 0, g_Win64Username, -1, g_Win64UsernameW, 17);
// Initialize global strings // Initialize global strings
MyRegisterClass(hInstance); MyRegisterClass(hInstance);
@ -971,8 +935,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
IQNet::m_player[i].m_isHostPlayer = (i == 0); IQNet::m_player[i].m_isHostPlayer = (i == 0);
swprintf_s(IQNet::m_player[i].m_gamertag, 32, L"Player%d", i); swprintf_s(IQNet::m_player[i].m_gamertag, 32, L"Player%d", i);
} }
extern wchar_t g_Win64UsernameW[17];
wcscpy_s(IQNet::m_player[0].m_gamertag, 32, g_Win64UsernameW);
WinsockNetLayer::Initialize(); WinsockNetLayer::Initialize();

View file

@ -33,13 +33,7 @@ Basic LAN multiplayer is available on the Windows build
- Other players on the same LAN can discover the session from the in-game Join Game menu - Other players on the same LAN can discover the session from the in-game Join Game menu
- Game connections use TCP port `25565` by default - Game connections use TCP port `25565` by default
- LAN discovery uses UDP port `25566` - LAN discovery uses UDP port `25566`
- You can override your in-game username at launch with `-name` - You can override your in-game username at launch with `username.txt`
Example:
```powershell
Minecraft.Client.exe -name Steve
```
This feature is based on [LCEMP](https://github.com/LCEMP/LCEMP/) This feature is based on [LCEMP](https://github.com/LCEMP/LCEMP/)