Sync latest changes from original repository

- Incorporates latest fixes and features from the original repo
- Prepares main for new branches/PRsupdates from upstream/main into my fork
This commit is contained in:
IsraelDXPP 2026-03-04 11:02:45 -07:00
commit 33e9590c00
7 changed files with 104 additions and 30 deletions

View file

@ -1098,7 +1098,15 @@ void IUIScene_CreativeMenu::handleAdditionalKeyPress(int iAction)
} }
break; break;
case ACTION_MENU_OTHER_STICK_DOWN: case ACTION_MENU_OTHER_STICK_DOWN:
++m_tabPage[m_curTab]; {
int pageStep = TabSpec::rows;
#ifdef _WINDOWS64
if (g_KBMInput.WasMouseWheelConsumed())
{
pageStep = 1;
}
#endif
m_tabPage[m_curTab] += pageStep;
if(m_tabPage[m_curTab] >= specs[m_curTab]->getPageCount()) if(m_tabPage[m_curTab] >= specs[m_curTab]->getPageCount())
{ {
m_tabPage[m_curTab] = specs[m_curTab]->getPageCount() - 1; m_tabPage[m_curTab] = specs[m_curTab]->getPageCount() - 1;
@ -1107,9 +1115,18 @@ void IUIScene_CreativeMenu::handleAdditionalKeyPress(int iAction)
{ {
switchTab(m_curTab); switchTab(m_curTab);
} }
}
break; break;
case ACTION_MENU_OTHER_STICK_UP: case ACTION_MENU_OTHER_STICK_UP:
--m_tabPage[m_curTab]; {
int pageStep = TabSpec::rows;
#ifdef _WINDOWS64
if (g_KBMInput.WasMouseWheelConsumed())
{
pageStep = 1;
}
#endif
m_tabPage[m_curTab] -= pageStep;
if(m_tabPage[m_curTab] < 0) if(m_tabPage[m_curTab] < 0)
{ {
m_tabPage[m_curTab] = 0; m_tabPage[m_curTab] = 0;
@ -1118,6 +1135,7 @@ void IUIScene_CreativeMenu::handleAdditionalKeyPress(int iAction)
{ {
switchTab(m_curTab); switchTab(m_curTab);
} }
}
break; break;
} }
} }

View file

@ -104,7 +104,7 @@ void Input::tick(LocalPlayer *player)
} }
} }
// Left Ctrl + forward = sprint (hold to sprint) // Ctrl + forward = sprint (hold to sprint)
if (!player->abilities.flying) if (!player->abilities.flying)
{ {
bool ctrlHeld = g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_SPRINT); bool ctrlHeld = g_KBMInput.IsKeyDown(KeyboardMouseInput::KEY_SPRINT);

View file

@ -487,11 +487,11 @@ void LivingEntityRenderer::renderNameTag(shared_ptr<LivingEntity> mob, const wst
Font *font = getFont(); Font *font = getFont();
float size = 1.60f; constexpr float size = 1.60f;
float s = 1 / 60.0f * size; constexpr float s = 1 / 60.0f * size;
glPushMatrix(); glPushMatrix();
glTranslatef((float) x + 0, (float) y + 2.3f, (float) z); glTranslatef(static_cast<float>(x) + 0, static_cast<float>(y) + mob->bbHeight + 0.5f, static_cast<float>(z));
glNormal3f(0, 1, 0); glNormal3f(0, 1, 0);
glRotatef(-this->entityRenderDispatcher->playerRotY, 0, 1, 0); glRotatef(-this->entityRenderDispatcher->playerRotY, 0, 1, 0);

View file

@ -31,6 +31,9 @@
#include "..\Minecraft.World\net.minecraft.world.item.h" #include "..\Minecraft.World\net.minecraft.world.item.h"
#include "..\Minecraft.World\net.minecraft.world.item.enchantment.h" #include "..\Minecraft.World\net.minecraft.world.item.enchantment.h"
#include "..\Minecraft.World\net.minecraft.world.damagesource.h" #include "..\Minecraft.World\net.minecraft.world.damagesource.h"
#ifdef _WINDOWS64
#include "Windows64\Network\WinsockNetLayer.h"
#endif
#include <sstream> #include <sstream>
#ifdef SPLIT_SAVES #ifdef SPLIT_SAVES
#include "..\Minecraft.World\ConsoleSaveFileSplit.h" #include "..\Minecraft.World\ConsoleSaveFileSplit.h"
@ -83,6 +86,30 @@ bool MinecraftServer::s_slowQueuePacketSent = false;
unordered_map<wstring, int> MinecraftServer::ironTimers; unordered_map<wstring, int> MinecraftServer::ironTimers;
static bool ShouldUseDedicatedServerProperties()
{
#ifdef _WINDOWS64
return g_Win64DedicatedServer;
#else
return false;
#endif
}
static int GetDedicatedServerInt(Settings *settings, const wchar_t *key, int defaultValue)
{
return (ShouldUseDedicatedServerProperties() && settings != NULL) ? settings->getInt(key, defaultValue) : defaultValue;
}
static bool GetDedicatedServerBool(Settings *settings, const wchar_t *key, bool defaultValue)
{
return (ShouldUseDedicatedServerProperties() && settings != NULL) ? settings->getBoolean(key, defaultValue) : defaultValue;
}
static wstring GetDedicatedServerString(Settings *settings, const wchar_t *key, const wstring &defaultValue)
{
return (ShouldUseDedicatedServerProperties() && settings != NULL) ? settings->getString(key, defaultValue) : defaultValue;
}
static void PrintConsoleLine(const wchar_t *prefix, const wstring &message) static void PrintConsoleLine(const wchar_t *prefix, const wstring &message)
{ {
wprintf(L"%ls%ls\n", prefix, message.c_str()); wprintf(L"%ls%ls\n", prefix, message.c_str());
@ -589,14 +616,14 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW
#endif #endif
settings = new Settings(new File(L"server.properties")); settings = new Settings(new File(L"server.properties"));
app.SetGameHostOption(eGameHostOption_Difficulty, settings->getInt(L"difficulty", app.GetGameHostOption(eGameHostOption_Difficulty))); app.SetGameHostOption(eGameHostOption_Difficulty, GetDedicatedServerInt(settings, L"difficulty", app.GetGameHostOption(eGameHostOption_Difficulty)));
app.SetGameHostOption(eGameHostOption_GameType, settings->getInt(L"gamemode", app.GetGameHostOption(eGameHostOption_GameType))); app.SetGameHostOption(eGameHostOption_GameType, GetDedicatedServerInt(settings, L"gamemode", app.GetGameHostOption(eGameHostOption_GameType)));
app.SetGameHostOption(eGameHostOption_Structures, settings->getBoolean(L"generate-structures", app.GetGameHostOption(eGameHostOption_Structures) > 0) ? 1 : 0); app.SetGameHostOption(eGameHostOption_Structures, GetDedicatedServerBool(settings, L"generate-structures", app.GetGameHostOption(eGameHostOption_Structures) > 0) ? 1 : 0);
app.SetGameHostOption(eGameHostOption_BonusChest, settings->getBoolean(L"bonus-chest", app.GetGameHostOption(eGameHostOption_BonusChest) > 0) ? 1 : 0); app.SetGameHostOption(eGameHostOption_BonusChest, GetDedicatedServerBool(settings, L"bonus-chest", app.GetGameHostOption(eGameHostOption_BonusChest) > 0) ? 1 : 0);
app.SetGameHostOption(eGameHostOption_PvP, settings->getBoolean(L"pvp", app.GetGameHostOption(eGameHostOption_PvP) > 0) ? 1 : 0); app.SetGameHostOption(eGameHostOption_PvP, GetDedicatedServerBool(settings, L"pvp", app.GetGameHostOption(eGameHostOption_PvP) > 0) ? 1 : 0);
app.SetGameHostOption(eGameHostOption_TrustPlayers, settings->getBoolean(L"trust-players", app.GetGameHostOption(eGameHostOption_TrustPlayers) > 0) ? 1 : 0); app.SetGameHostOption(eGameHostOption_TrustPlayers, GetDedicatedServerBool(settings, L"trust-players", app.GetGameHostOption(eGameHostOption_TrustPlayers) > 0) ? 1 : 0);
app.SetGameHostOption(eGameHostOption_FireSpreads, settings->getBoolean(L"fire-spreads", app.GetGameHostOption(eGameHostOption_FireSpreads) > 0) ? 1 : 0); app.SetGameHostOption(eGameHostOption_FireSpreads, GetDedicatedServerBool(settings, L"fire-spreads", app.GetGameHostOption(eGameHostOption_FireSpreads) > 0) ? 1 : 0);
app.SetGameHostOption(eGameHostOption_TNT, settings->getBoolean(L"tnt", app.GetGameHostOption(eGameHostOption_TNT) > 0) ? 1 : 0); app.SetGameHostOption(eGameHostOption_TNT, GetDedicatedServerBool(settings, L"tnt", app.GetGameHostOption(eGameHostOption_TNT) > 0) ? 1 : 0);
app.DebugPrintf("\n*** SERVER SETTINGS ***\n"); app.DebugPrintf("\n*** SERVER SETTINGS ***\n");
app.DebugPrintf("ServerSettings: host-friends-only is %s\n",(app.GetGameHostOption(eGameHostOption_FriendsOfFriends)>0)?"on":"off"); app.DebugPrintf("ServerSettings: host-friends-only is %s\n",(app.GetGameHostOption(eGameHostOption_FriendsOfFriends)>0)?"on":"off");
@ -615,13 +642,13 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW
//motd = settings->getString(L"motd", L"A Minecraft Server"); //motd = settings->getString(L"motd", L"A Minecraft Server");
//motd.replace('<27>', '$'); //motd.replace('<27>', '$');
setAnimals(settings->getBoolean(L"spawn-animals", true)); setAnimals(GetDedicatedServerBool(settings, L"spawn-animals", true));
setNpcsEnabled(settings->getBoolean(L"spawn-npcs", true)); setNpcsEnabled(GetDedicatedServerBool(settings, L"spawn-npcs", true));
setPvpAllowed(app.GetGameHostOption( eGameHostOption_PvP )>0?true:false); setPvpAllowed(app.GetGameHostOption( eGameHostOption_PvP )>0?true:false);
// 4J Stu - We should never have hacked clients flying when they shouldn't be like the PC version, so enable flying always // 4J Stu - We should never have hacked clients flying when they shouldn't be like the PC version, so enable flying always
// Fix for #46612 - TU5: Code: Multiplayer: A client can be banned for flying when accidentaly being blown by dynamite // Fix for #46612 - TU5: Code: Multiplayer: A client can be banned for flying when accidentaly being blown by dynamite
setFlightAllowed(settings->getBoolean(L"allow-flight", true)); setFlightAllowed(GetDedicatedServerBool(settings, L"allow-flight", true));
// 4J Stu - Enabling flight to stop it kicking us when we use it // 4J Stu - Enabling flight to stop it kicking us when we use it
#ifdef _DEBUG_MENUS_ENABLED #ifdef _DEBUG_MENUS_ENABLED
@ -667,7 +694,7 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW
__int64 levelNanoTime = System::nanoTime(); __int64 levelNanoTime = System::nanoTime();
wstring levelName = (initData && !initData->levelName.empty()) ? initData->levelName : settings->getString(L"level-name", L"world"); wstring levelName = (initData && !initData->levelName.empty()) ? initData->levelName : GetDedicatedServerString(settings, L"level-name", L"world");
wstring levelTypeString; wstring levelTypeString;
bool gameRuleUseFlatWorld = false; bool gameRuleUseFlatWorld = false;
@ -677,11 +704,11 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW
} }
if(gameRuleUseFlatWorld || app.GetGameHostOption(eGameHostOption_LevelType)>0) if(gameRuleUseFlatWorld || app.GetGameHostOption(eGameHostOption_LevelType)>0)
{ {
levelTypeString = settings->getString(L"level-type", L"flat"); levelTypeString = GetDedicatedServerString(settings, L"level-type", L"flat");
} }
else else
{ {
levelTypeString = settings->getString(L"level-type",L"default"); levelTypeString = GetDedicatedServerString(settings, L"level-type",L"default");
} }
LevelType *pLevelType = LevelType::getLevelType(levelTypeString); LevelType *pLevelType = LevelType::getLevelType(levelTypeString);
@ -702,7 +729,7 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW
#endif #endif
} }
setMaxBuildHeight(settings->getInt(L"max-build-height", Level::maxBuildHeight)); setMaxBuildHeight(GetDedicatedServerInt(settings, L"max-build-height", Level::maxBuildHeight));
setMaxBuildHeight(((getMaxBuildHeight() + 8) / 16) * 16); setMaxBuildHeight(((getMaxBuildHeight() + 8) / 16) * 16);
setMaxBuildHeight(Mth::clamp(getMaxBuildHeight(), 64, Level::maxBuildHeight)); setMaxBuildHeight(Mth::clamp(getMaxBuildHeight(), 64, Level::maxBuildHeight));
//settings->setProperty(L"max-build-height", maxBuildHeight); //settings->setProperty(L"max-build-height", maxBuildHeight);
@ -851,7 +878,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring
// 4J TODO - free levels here if there are already some? // 4J TODO - free levels here if there are already some?
levels = ServerLevelArray(3); levels = ServerLevelArray(3);
int gameTypeId = settings->getInt(L"gamemode", app.GetGameHostOption(eGameHostOption_GameType));//LevelSettings::GAMETYPE_SURVIVAL); int gameTypeId = GetDedicatedServerInt(settings, L"gamemode", app.GetGameHostOption(eGameHostOption_GameType));//LevelSettings::GAMETYPE_SURVIVAL);
GameType *gameType = LevelSettings::validateGameType(gameTypeId); GameType *gameType = LevelSettings::validateGameType(gameTypeId);
app.DebugPrintf("Default game type: %d\n" , gameTypeId); app.DebugPrintf("Default game type: %d\n" , gameTypeId);
@ -950,7 +977,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring
#if DEBUG_SERVER_DONT_SPAWN_MOBS #if DEBUG_SERVER_DONT_SPAWN_MOBS
levels[i]->setSpawnSettings(false, false); levels[i]->setSpawnSettings(false, false);
#else #else
levels[i]->setSpawnSettings(settings->getBoolean(L"spawn-monsters", true), animals); levels[i]->setSpawnSettings(GetDedicatedServerBool(settings, L"spawn-monsters", true), animals);
#endif #endif
levels[i]->getLevelData()->setGameType(gameType); levels[i]->getLevelData()->setGameType(gameType);
@ -1038,7 +1065,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring
for (int i = 0; i < levels.length ; i++) for (int i = 0; i < levels.length ; i++)
{ {
// logger.info("Preparing start region for level " + i); // logger.info("Preparing start region for level " + i);
if (i == 0 || settings->getBoolean(L"allow-nether", true)) if (i == 0 || GetDedicatedServerBool(settings, L"allow-nether", true))
{ {
ServerLevel *level = levels[i]; ServerLevel *level = levels[i];
if(levelChunksNeedConverted) if(levelChunksNeedConverted)
@ -1780,7 +1807,7 @@ void MinecraftServer::run(__int64 seed, void *lpParameter)
MinecraftServer::setTimeOfDayAtEndOfTick = false; MinecraftServer::setTimeOfDayAtEndOfTick = false;
for (unsigned int i = 0; i < levels.length; i++) for (unsigned int i = 0; i < levels.length; i++)
{ {
if (i == 0 || settings->getBoolean(L"allow-nether", true)) if (i == 0 || GetDedicatedServerBool(settings, L"allow-nether", true))
{ {
ServerLevel *level = levels[i]; ServerLevel *level = levels[i];
level->setDayTime( MinecraftServer::setTimeOfDay ); level->setDayTime( MinecraftServer::setTimeOfDay );

View file

@ -53,14 +53,12 @@ PlayerList::PlayerList(MinecraftServer *server)
//int viewDistance = server->settings->getInt(L"view-distance", 10); //int viewDistance = server->settings->getInt(L"view-distance", 10);
maxPlayers = server->settings->getInt(L"max-players", 20);
doWhiteList = false;
#ifdef _WINDOWS64 #ifdef _WINDOWS64
maxPlayers = MINECRAFT_NET_MAX_PLAYERS; maxPlayers = MINECRAFT_NET_MAX_PLAYERS;
#else #else
maxPlayers = server->settings->getInt(L"max-players", 20); maxPlayers = server->settings->getInt(L"max-players", 20);
#endif #endif
doWhiteList = false;
InitializeCriticalSection(&m_kickPlayersCS); InitializeCriticalSection(&m_kickPlayersCS);
InitializeCriticalSection(&m_closePlayersCS); InitializeCriticalSection(&m_closePlayersCS);
} }

View file

@ -12,6 +12,21 @@ extern HWND g_hWnd;
// Forward declaration // Forward declaration
static void ClipCursorToWindow(HWND hWnd); static void ClipCursorToWindow(HWND hWnd);
static bool IsModifierKeyDown(const bool* keyState, int vkCode)
{
switch (vkCode)
{
case VK_SHIFT:
return keyState[VK_LSHIFT] || keyState[VK_RSHIFT];
case VK_CONTROL:
return keyState[VK_LCONTROL] || keyState[VK_RCONTROL];
case VK_MENU:
return keyState[VK_LMENU] || keyState[VK_RMENU];
default:
return false;
}
}
void KeyboardMouseInput::Init() void KeyboardMouseInput::Init()
{ {
memset(m_keyDown, 0, sizeof(m_keyDown)); memset(m_keyDown, 0, sizeof(m_keyDown));
@ -33,6 +48,7 @@ void KeyboardMouseInput::Init()
m_mouseDeltaAccumX = 0; m_mouseDeltaAccumX = 0;
m_mouseDeltaAccumY = 0; m_mouseDeltaAccumY = 0;
m_mouseWheelAccum = 0; m_mouseWheelAccum = 0;
m_mouseWheelConsumed = false;
m_mouseGrabbed = false; m_mouseGrabbed = false;
m_cursorHiddenForUI = false; m_cursorHiddenForUI = false;
m_windowFocused = true; m_windowFocused = true;
@ -67,6 +83,7 @@ void KeyboardMouseInput::ClearAllState()
m_mouseDeltaAccumX = 0; m_mouseDeltaAccumX = 0;
m_mouseDeltaAccumY = 0; m_mouseDeltaAccumY = 0;
m_mouseWheelAccum = 0; m_mouseWheelAccum = 0;
m_mouseWheelConsumed = false;
} }
void KeyboardMouseInput::Tick() void KeyboardMouseInput::Tick()
@ -88,6 +105,7 @@ void KeyboardMouseInput::Tick()
m_mouseDeltaY = m_mouseDeltaAccumY; m_mouseDeltaY = m_mouseDeltaAccumY;
m_mouseDeltaAccumX = 0; m_mouseDeltaAccumX = 0;
m_mouseDeltaAccumY = 0; m_mouseDeltaAccumY = 0;
m_mouseWheelConsumed = false;
m_hasInput = (m_mouseDeltaX != 0 || m_mouseDeltaY != 0 || m_mouseWheelAccum != 0); m_hasInput = (m_mouseDeltaX != 0 || m_mouseDeltaY != 0 || m_mouseWheelAccum != 0);
if (!m_hasInput) if (!m_hasInput)
@ -172,6 +190,8 @@ void KeyboardMouseInput::OnMouseWheel(int delta)
int KeyboardMouseInput::GetMouseWheel() int KeyboardMouseInput::GetMouseWheel()
{ {
int val = m_mouseWheelAccum; int val = m_mouseWheelAccum;
if (val != 0)
m_mouseWheelConsumed = true;
m_mouseWheelAccum = 0; m_mouseWheelAccum = 0;
return val; return val;
} }
@ -184,6 +204,9 @@ void KeyboardMouseInput::OnRawMouseDelta(int dx, int dy)
bool KeyboardMouseInput::IsKeyDown(int vkCode) const bool KeyboardMouseInput::IsKeyDown(int vkCode) const
{ {
if (vkCode == VK_SHIFT || vkCode == VK_CONTROL || vkCode == VK_MENU)
return IsModifierKeyDown(m_keyDown, vkCode);
if (vkCode >= 0 && vkCode < MAX_KEYS) if (vkCode >= 0 && vkCode < MAX_KEYS)
return m_keyDown[vkCode]; return m_keyDown[vkCode];
return false; return false;
@ -191,6 +214,9 @@ bool KeyboardMouseInput::IsKeyDown(int vkCode) const
bool KeyboardMouseInput::IsKeyPressed(int vkCode) const bool KeyboardMouseInput::IsKeyPressed(int vkCode) const
{ {
if (vkCode == VK_SHIFT || vkCode == VK_CONTROL || vkCode == VK_MENU)
return IsModifierKeyDown(m_keyPressed, vkCode);
if (vkCode >= 0 && vkCode < MAX_KEYS) if (vkCode >= 0 && vkCode < MAX_KEYS)
return m_keyPressed[vkCode]; return m_keyPressed[vkCode];
return false; return false;
@ -198,6 +224,9 @@ bool KeyboardMouseInput::IsKeyPressed(int vkCode) const
bool KeyboardMouseInput::IsKeyReleased(int vkCode) const bool KeyboardMouseInput::IsKeyReleased(int vkCode) const
{ {
if (vkCode == VK_SHIFT || vkCode == VK_CONTROL || vkCode == VK_MENU)
return IsModifierKeyDown(m_keyReleased, vkCode);
if (vkCode >= 0 && vkCode < MAX_KEYS) if (vkCode >= 0 && vkCode < MAX_KEYS)
return m_keyReleased[vkCode]; return m_keyReleased[vkCode];
return false; return false;

View file

@ -20,7 +20,7 @@ public:
static const int KEY_RIGHT = 'D'; static const int KEY_RIGHT = 'D';
static const int KEY_JUMP = VK_SPACE; static const int KEY_JUMP = VK_SPACE;
static const int KEY_SNEAK = VK_LSHIFT; static const int KEY_SNEAK = VK_LSHIFT;
static const int KEY_SPRINT = VK_LCONTROL; static const int KEY_SPRINT = VK_CONTROL;
static const int KEY_INVENTORY = 'E'; static const int KEY_INVENTORY = 'E';
static const int KEY_DROP = 'Q'; static const int KEY_DROP = 'Q';
static const int KEY_CRAFTING = 'C'; static const int KEY_CRAFTING = 'C';
@ -59,7 +59,8 @@ public:
int GetMouseWheel(); int GetMouseWheel();
int PeekMouseWheel() const { return m_mouseWheelAccum; } int PeekMouseWheel() const { return m_mouseWheelAccum; }
void ConsumeMouseWheel() { m_mouseWheelAccum = 0; } void ConsumeMouseWheel() { if (m_mouseWheelAccum != 0) m_mouseWheelConsumed = true; m_mouseWheelAccum = 0; }
bool WasMouseWheelConsumed() const { return m_mouseWheelConsumed; }
// Per-frame delta consumption for low-latency mouse look. // Per-frame delta consumption for low-latency mouse look.
// Reads and clears the raw accumulators (not the per-tick snapshot). // Reads and clears the raw accumulators (not the per-tick snapshot).
@ -114,6 +115,7 @@ private:
int m_mouseDeltaAccumY; int m_mouseDeltaAccumY;
int m_mouseWheelAccum; int m_mouseWheelAccum;
bool m_mouseWheelConsumed;
bool m_mouseGrabbed; bool m_mouseGrabbed;