Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Minecraft.Client/Common/Consoles_App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5699,13 +5699,19 @@ bool CMinecraftApp::isXuidDeadmau5(PlayerUID xuid)

void CMinecraftApp::AddMemoryTextureFile(const wstring &wName,PBYTE pbData,DWORD dwBytes)
{
#ifdef _WINDOWS64
extern bool g_Win64Verbose;
#endif
EnterCriticalSection(&csMemFilesLock);
// check it's not already in
PMEMDATA pData=nullptr;
auto it = m_MEM_Files.find(wName);
if(it != m_MEM_Files.end())
{
#ifndef _CONTENT_PACKAGE
#ifdef _WINDOWS64
if (g_Win64Verbose)
#endif
wprintf(L"Incrementing the memory texture file count for %ls\n", wName.c_str());
#endif
pData = (*it).second;
Expand Down
4 changes: 2 additions & 2 deletions Minecraft.Client/Common/UI/IUIScene_HUD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ void IUIScene_HUD::renderPlayerHealth()
// Update health
bool blink = pMinecraft->localplayers[iPad]->invulnerableTime / 3 % 2 == 1;
if (pMinecraft->localplayers[iPad]->invulnerableTime < 10) blink = false;
int currentHealth = pMinecraft->localplayers[iPad]->getHealth();
int oldHealth = pMinecraft->localplayers[iPad]->lastHealth;
int currentHealth = static_cast<int>(ceil(pMinecraft->localplayers[iPad]->getHealth()));
int oldHealth = static_cast<int>(ceil(pMinecraft->localplayers[iPad]->lastHealth));
bool bHasPoison = pMinecraft->localplayers[iPad]->hasEffect(MobEffect::poison);
bool bHasWither = pMinecraft->localplayers[iPad]->hasEffect(MobEffect::wither);
AttributeInstance *maxHealthAttribute = pMinecraft->localplayers[iPad]->getAttribute(SharedMonsterAttributes::MAX_HEALTH);
Expand Down
4 changes: 4 additions & 0 deletions Minecraft.Client/Minecraft.Client.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20728,7 +20728,9 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
<ClInclude Include="Rect2i.h" />
<ClInclude Include="ResourceLocation.h" />
<ClInclude Include="ServerCommandDispatcher.h" />
<ClInclude Include="ServerCommands.h" />
<ClInclude Include="ServerConnection.h" />
<ClInclude Include="ServerConsole.h" />
<ClInclude Include="ServerInterface.h" />
<ClInclude Include="ServerPlayerGameMode.h" />
<ClInclude Include="ServerLevelListener.h" />
Expand Down Expand Up @@ -37956,7 +37958,9 @@ xcopy /q /y /i /s /e $(ProjectDir)Durango\CU $(LayoutDir)Image\Loose\CU</Comman
<ClCompile Include="SelectWorldScreen.cpp" />
<ClCompile Include="ServerChunkCache.cpp" />
<ClCompile Include="ServerCommandDispatcher.cpp" />
<ClCompile Include="ServerCommands.cpp" />
<ClCompile Include="ServerConnection.cpp" />
<ClCompile Include="ServerConsole.cpp" />
<ClCompile Include="ServerPlayerGameMode.cpp" />
<ClCompile Include="ServerLevel.cpp" />
<ClCompile Include="ServerLevelListener.cpp" />
Expand Down
12 changes: 12 additions & 0 deletions Minecraft.Client/Minecraft.Client.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,12 @@
<ClInclude Include="Common\XUI\XUI_DebugTips.h">
<Filter>Xbox\Source Files\XUI\Menu screens\Debug</Filter>
</ClInclude>
<ClInclude Include="ServerCommands.h">
<Filter>net\minecraft\server</Filter>
</ClInclude>
<ClInclude Include="ServerConsole.h">
<Filter>net\minecraft\server</Filter>
</ClInclude>
<ClInclude Include="ServerConnection.h">
<Filter>net\minecraft\server\network</Filter>
</ClInclude>
Expand Down Expand Up @@ -4254,6 +4260,12 @@
<ClCompile Include="ConsoleInput.cpp">
<Filter>net\minecraft\server</Filter>
</ClCompile>
<ClCompile Include="ServerCommands.cpp">
<Filter>net\minecraft\server</Filter>
</ClCompile>
<ClCompile Include="ServerConsole.cpp">
<Filter>net\minecraft\server</Filter>
</ClCompile>
<ClCompile Include="MinecraftServer.cpp">
<Filter>net\minecraft\server</Filter>
</ClCompile>
Expand Down
42 changes: 41 additions & 1 deletion Minecraft.Client/MinecraftServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
#include "DispenserBootstrap.h"
#include "EntityTracker.h"
#include "MinecraftServer.h"
#ifdef _WINDOWS64
#include "ServerConsole.h"
#endif
#include "Options.h"
#include "PlayerList.h"
#include "ServerChunkCache.h"
Expand Down Expand Up @@ -58,6 +61,9 @@
#include "..\Minecraft.World\BiomeSource.h"
#include "PlayerChunkMap.h"
#include "Common\Telemetry\TelemetryManager.h"
#include "ServerCommands.h"
#ifdef _WINDOWS64
#endif
#include "PlayerConnection.h"
#ifdef _XBOX_ONE
#include "Durango\Network\NetworkPlayerDurango.h"
Expand Down Expand Up @@ -726,13 +732,30 @@ bool MinecraftServer::initServer(int64_t seed, NetworkGameInitData *initData, DW
ProgressRenderer *mcprogress = Minecraft::GetInstance()->progressRenderer;
mcprogress->progressStart(IDS_PROGRESS_INITIALISING_SERVER);

if (ShouldUseDedicatedServerProperties())
{
wstring seedStr = GetDedicatedServerString(settings, L"seed", L"");
if (!seedStr.empty())
{
int64_t parsedSeed = _wtoi64(seedStr.c_str());
if (parsedSeed != 0)
seed = parsedSeed;
}
if (seed == 0 && !findSeed)
findSeed = true;
}

if( findSeed )
{
#ifdef __PSVITA__
seed = BiomeSource::findSeed(pLevelType, &running);
#else
seed = BiomeSource::findSeed(pLevelType);
#endif
if (ShouldUseDedicatedServerProperties() && settings != nullptr)
{
settings->setStringAndSave(L"seed", std::to_wstring(seed));
}
}

setMaxBuildHeight(GetDedicatedServerInt(settings, L"max-build-height", Level::maxBuildHeight));
Expand Down Expand Up @@ -2208,10 +2231,13 @@ void MinecraftServer::handleConsoleInputs()
pendingInputs.swap(consoleInput);
LeaveCriticalSection(&m_consoleInputCS);

ServerCommands::initialize();

for (size_t i = 0; i < pendingInputs.size(); ++i)
{
ConsoleInput *input = pendingInputs[i];
ExecuteConsoleCommand(this, input->msg);
CommandSource source(this, input->source, CommandSource::CONSOLE, L"CONSOLE");
ServerCommands::execute(this, input->msg, source);
delete input;
}
}
Expand Down Expand Up @@ -2245,11 +2271,25 @@ File *MinecraftServer::getFile(const wstring& name)

void MinecraftServer::info(const wstring& string)
{
#ifdef _WINDOWS64
if (ServerConsole::getInstance())
{
ServerConsole::logInfo(string.c_str());
return;
}
#endif
PrintConsoleLine(L"[INFO] ", string);
}

void MinecraftServer::warn(const wstring& string)
{
#ifdef _WINDOWS64
if (ServerConsole::getInstance())
{
ServerConsole::logWarn(string.c_str());
return;
}
#endif
PrintConsoleLine(L"[WARN] ", string);
}

Expand Down
2 changes: 1 addition & 1 deletion Minecraft.Client/MinecraftServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class MinecraftServer : public ConsoleInputSource
bool loadLevel(LevelStorageSource *storageSource, const wstring& name, int64_t levelSeed, LevelType *pLevelType, NetworkGameInitData *initData);
void setProgress(const wstring& status, int progress);
void endProgress();
void saveAllChunks();
void saveAllChunks();
void saveGameRules();
void stopServer(bool didInit);
#ifdef _LARGE_WORLDS
Expand Down
5 changes: 5 additions & 0 deletions Minecraft.Client/PendingConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "ServerLevel.h"
#include "PlayerList.h"
#include "MinecraftServer.h"
#include "ServerCommands.h"
#include "..\Minecraft.World\net.minecraft.network.h"
#include "..\Minecraft.World\pos.h"
#include "..\Minecraft.World\net.minecraft.world.level.dimension.h"
Expand Down Expand Up @@ -188,6 +189,10 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
{
disconnect(DisconnectPacket::eDisconnect_Banned);
}
else if (ServerCommands::getBanList().isBanned(name))
{
disconnect(DisconnectPacket::eDisconnect_Banned);
}
else if (duplicateXuid)
{
// Reject the incoming connection — a player with this UID is already
Expand Down
8 changes: 4 additions & 4 deletions Minecraft.Client/PlayerConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
// 4J Added
#include "..\Minecraft.World\net.minecraft.world.item.crafting.h"
#include "Options.h"
#include "ServerCommands.h"

Random PlayerConnection::random;

Expand Down Expand Up @@ -633,10 +634,9 @@ void PlayerConnection::handleChat(shared_ptr<ChatPacket> packet)

void PlayerConnection::handleCommand(const wstring& message)
{
// 4J - TODO
#if 0
server.getCommandDispatcher().performCommand(player, message);
#endif
ServerCommands::initialize();
CommandSource source(server, player);
ServerCommands::execute(server, message, source);
}

void PlayerConnection::handleAnimate(shared_ptr<AnimatePacket> packet)
Expand Down
Loading