format everything
Some checks are pending
Build (Linux, x86-64) / build-linux (push) Waiting to run
Format Check / clang-format (push) Waiting to run

This commit is contained in:
Tropical 2026-04-01 13:48:29 -05:00
parent 3e813592e4
commit dd93cfe91e
380 changed files with 2698 additions and 2595 deletions

View file

@ -660,6 +660,8 @@ void C_4JInput::CancelQueuedVerifyStrings(int (*)(void*,
void C_4JInput::CancelAllVerifyInProgress() {} void C_4JInput::CancelAllVerifyInProgress() {}
// Primary pad (moved from Profile) // Primary pad (moved from Profile)
namespace { int s_inputPrimaryPad = 0; } namespace {
int s_inputPrimaryPad = 0;
}
int C_4JInput::GetPrimaryPad() { return s_inputPrimaryPad; } int C_4JInput::GetPrimaryPad() { return s_inputPrimaryPad; }
void C_4JInput::SetPrimaryPad(int iPad) { s_inputPrimaryPad = iPad; } void C_4JInput::SetPrimaryPad(int iPad) { s_inputPrimaryPad = iPad; }

View file

@ -51,7 +51,6 @@
class C_4JInput : public IPlatformInput { class C_4JInput : public IPlatformInput {
public: public:
void Initialise(int iInputStateC, unsigned char ucMapC, void Initialise(int iInputStateC, unsigned char ucMapC,
unsigned char ucActionC, unsigned char ucMenuActionC); unsigned char ucActionC, unsigned char ucMenuActionC);
void Tick(void); void Tick(void);

View file

@ -158,8 +158,9 @@ std::wstring C_4JProfile::GetDisplayName(int iPad) {
return s_displayNames[p]; return s_displayNames[p];
} }
int C_4JProfile::SetDefaultOptionsCallback( int C_4JProfile::SetDefaultOptionsCallback(int (*Func)(void*, PROFILESETTINGS*,
int (*Func)(void*, PROFILESETTINGS*, const int iPad), void* lpParam) { const int iPad),
void* lpParam) {
s_defaultOptionsCallback = Func; s_defaultOptionsCallback = Func;
s_defaultOptionsCallbackParam = lpParam; s_defaultOptionsCallbackParam = lpParam;
return 0; return 0;

View file

@ -71,17 +71,25 @@ public:
void Tick() {} void Tick() {}
unsigned int RequestSignInUI(bool, bool, bool, bool, bool, unsigned int RequestSignInUI(bool, bool, bool, bool, bool,
int (*)(void*, const bool, const int),
void*, int = XUSER_INDEX_ANY) { return 0; }
unsigned int DisplayOfflineProfile(int (*)(void*, const bool, const int),
void*, int = XUSER_INDEX_ANY) { return 0; }
unsigned int RequestConvertOfflineToGuestUI(
int (*)(void*, const bool, const int), void*, int (*)(void*, const bool, const int), void*,
int = XUSER_INDEX_ANY) { return 0; } int = XUSER_INDEX_ANY) {
return 0;
}
unsigned int DisplayOfflineProfile(int (*)(void*, const bool, const int),
void*, int = XUSER_INDEX_ANY) {
return 0;
}
unsigned int RequestConvertOfflineToGuestUI(int (*)(void*, const bool,
const int),
void*, int = XUSER_INDEX_ANY) {
return 0;
}
void SetPrimaryPlayerChanged(bool) {} void SetPrimaryPlayerChanged(bool) {}
void ShowProfileCard(int, PlayerUID) {} void ShowProfileCard(int, PlayerUID) {}
bool GetProfileAvatar(int, int (*)(void*, std::uint8_t*, unsigned int), bool GetProfileAvatar(int, int (*)(void*, std::uint8_t*, unsigned int),
void*) { return false; } void*) {
return false;
}
void CancelProfileAvatarRequest() {} void CancelProfileAvatarRequest() {}
void SetSignInChangeCallback(void (*)(void*, bool, unsigned int), void*) {} void SetSignInChangeCallback(void (*)(void*, bool, unsigned int), void*) {}
void SetNotificationsCallback(void (*)(void*, std::uint32_t, unsigned int), void SetNotificationsCallback(void (*)(void*, std::uint32_t, unsigned int),
@ -93,13 +101,15 @@ public:
void SetProfileReadErrorCallback(void (*)(void*), void*) {} void SetProfileReadErrorCallback(void (*)(void*), void*) {}
int SetOldProfileVersionCallback(int (*)(void*, unsigned char*, int SetOldProfileVersionCallback(int (*)(void*, unsigned char*,
const unsigned short, const int), const unsigned short, const int),
void*) { return 0; } void*) {
return 0;
}
void WriteToProfile(int, bool = false, bool = false) {} void WriteToProfile(int, bool = false, bool = false) {}
void ForceQueuedProfileWrites(int = XUSER_INDEX_ANY) {} void ForceQueuedProfileWrites(int = XUSER_INDEX_ANY) {}
void ResetProfileProcessState() {} void ResetProfileProcessState() {}
void RegisterAward(int, int, EAwardType, bool = false, void RegisterAward(int, int, EAwardType, bool = false,
CXuiStringTable* = nullptr, int = -1, int = -1, CXuiStringTable* = nullptr, int = -1, int = -1, int = -1,
int = -1, char* = nullptr, unsigned int = 0L) {} char* = nullptr, unsigned int = 0L) {}
int GetAwardId(int) { return 0; } int GetAwardId(int) { return 0; }
EAwardType GetAwardType(int) { return eAwardType_Achievement; } EAwardType GetAwardType(int) { return eAwardType_Achievement; }
bool CanBeAwarded(int, int) { return false; } bool CanBeAwarded(int, int) { return false; }

View file

@ -66,7 +66,6 @@
#include <thread> #include <thread>
#include <chrono> #include <chrono>
// CMinecraftApp app; // CMinecraftApp app;
unsigned int CMinecraftApp::m_uiLastSignInData = 0; unsigned int CMinecraftApp::m_uiLastSignInData = 0;
@ -2212,8 +2211,10 @@ void CMinecraftApp::HandleXuiActions(void) {
// CSocialManager::Instance() // CSocialManager::Instance()
// ->AreAllUsersAllowedToPostImages()) { // ->AreAllUsersAllowedToPostImages()) {
// // disable character name tags for the shot // // disable character name tags for the shot
// // m_bwasHidingGui = pMinecraft->options->hideGui; // // m_bwasHidingGui =
// // // 4J Stu - Removed 1.8.2 bug fix (TU6) as don't // pMinecraft->options->hideGui;
// // // 4J Stu - Removed 1.8.2 bug fix (TU6) as
// don't
// // need this // // need this
// pMinecraft->options->hideGui = true; // pMinecraft->options->hideGui = true;
@ -2577,8 +2578,7 @@ void CMinecraftApp::HandleXuiActions(void) {
return; return;
} }
// flag to capture the save thumbnail // flag to capture the save thumbnail
SetAction(i, eAppAction_ExitWorldCapturedThumbnail, SetAction(i, eAppAction_ExitWorldCapturedThumbnail, param);
param);
// Change the presence info // Change the presence info
// Are we offline or online, and how many players are there // Are we offline or online, and how many players are there
@ -2878,7 +2878,8 @@ void CMinecraftApp::HandleXuiActions(void) {
bool gameStarted = false; bool gameStarted = false;
for (int j = 0; j < pMinecraft->levels.size(); for (int j = 0; j < pMinecraft->levels.size();
j++) { j++) {
if (pMinecraft->levels.data()[j] != nullptr) { if (pMinecraft->levels.data()[j] !=
nullptr) {
gameStarted = true; gameStarted = true;
break; break;
} }
@ -3078,9 +3079,8 @@ void CMinecraftApp::HandleXuiActions(void) {
uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[0] = IDS_CONFIRM_CANCEL;
uiIDA[1] = IDS_CONFIRM_OK; uiIDA[1] = IDS_CONFIRM_OK;
ui.RequestAlertMessage( ui.RequestAlertMessage(
IDS_EXIT_GAME, IDS_CONFIRM_LEAVE_VIA_INVITE, IDS_EXIT_GAME, IDS_CONFIRM_LEAVE_VIA_INVITE, uiIDA,
uiIDA, 2, i, 2, i, &CMinecraftApp::ExitAndJoinFromInvite, this);
&CMinecraftApp::ExitAndJoinFromInvite, this);
} }
} break; } break;
case eAppAction_ExitAndJoinFromInviteConfirmed: { case eAppAction_ExitAndJoinFromInviteConfirmed: {
@ -3381,7 +3381,6 @@ void CMinecraftApp::HandleXuiActions(void) {
// can't ban the level at that point // can't ban the level at that point
if (g_NetworkManager.IsInGameplay() && if (g_NetworkManager.IsInGameplay() &&
!g_NetworkManager.IsLeavingGame()) { !g_NetworkManager.IsLeavingGame()) {
// primary player would exit the world, secondary would // primary player would exit the world, secondary would
// exit the player // exit the player
if (ProfileManager.GetPrimaryPad() == i) { if (ProfileManager.GetPrimaryPad() == i) {
@ -3636,7 +3635,8 @@ void CMinecraftApp::loadStringTable() {
} }
std::wstring localisationFile = L"languages.loc"; std::wstring localisationFile = L"languages.loc";
if (m_mediaArchive->hasFile(localisationFile)) { if (m_mediaArchive->hasFile(localisationFile)) {
std::vector<uint8_t> locFile = m_mediaArchive->getFile(localisationFile); std::vector<uint8_t> locFile =
m_mediaArchive->getFile(localisationFile);
m_stringTable = new StringTable(locFile.data(), locFile.size()); m_stringTable = new StringTable(locFile.data(), locFile.size());
} else { } else {
m_stringTable = nullptr; m_stringTable = nullptr;
@ -4369,8 +4369,7 @@ void CMinecraftApp::UpdateTime() {
m_Time.qwAppTime += qwDeltaTime; m_Time.qwAppTime += qwDeltaTime;
m_Time.qwTime = qwNewTime; m_Time.qwTime = qwNewTime;
m_Time.fElapsedTime = m_Time.fElapsedTime = m_Time.fSecsPerTick * static_cast<float>(qwDeltaTime);
m_Time.fSecsPerTick * static_cast<float>(qwDeltaTime);
m_Time.fAppTime = m_Time.fAppTime =
m_Time.fSecsPerTick * static_cast<float>(m_Time.qwAppTime); m_Time.fSecsPerTick * static_cast<float>(m_Time.qwAppTime);
} }
@ -4873,8 +4872,7 @@ void CMinecraftApp::InitialiseTips() {
int CMinecraftApp::GetNextTip() { int CMinecraftApp::GetNextTip() {
static bool bShowSkinDLCTip = true; static bool bShowSkinDLCTip = true;
if (app.GetNewDLCAvailable() && if (app.GetNewDLCAvailable() && app.DisplayNewDLCTip()) {
app.DisplayNewDLCTip()) {
return IDS_TIPS_GAMETIP_NEWDLC; return IDS_TIPS_GAMETIP_NEWDLC;
} else { } else {
if (bShowSkinDLCTip) { if (bShowSkinDLCTip) {
@ -5702,7 +5700,6 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid,
if (pBannedListData != nullptr) { if (pBannedListData != nullptr) {
if (IsEqualXUID(pBannedListData->xuid, xuid) && if (IsEqualXUID(pBannedListData->xuid, xuid) &&
(strcmp(pBannedListData->pszLevelName, pszLevelName) == 0)) { (strcmp(pBannedListData->pszLevelName, pszLevelName) == 0)) {
// match found, so remove this entry // match found, so remove this entry
it = m_vBannedListA[iPad]->erase(it); it = m_vBannedListA[iPad]->erase(it);
} else { } else {
@ -7115,7 +7112,8 @@ bool CMinecraftApp::hasArchiveFile(const std::wstring& filename) {
return m_mediaArchive->hasFile(filename); return m_mediaArchive->hasFile(filename);
} }
std::vector<uint8_t> CMinecraftApp::getArchiveFile(const std::wstring& filename) { std::vector<uint8_t> CMinecraftApp::getArchiveFile(
const std::wstring& filename) {
TexturePack* tPack = nullptr; TexturePack* tPack = nullptr;
Minecraft* pMinecraft = Minecraft::GetInstance(); Minecraft* pMinecraft = Minecraft::GetInstance();
if (pMinecraft && pMinecraft->skins) if (pMinecraft && pMinecraft->skins)

View file

@ -184,7 +184,8 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume,
if (szId[i] == '.') szId[i] = '/'; if (szId[i] == '.') szId[i] = '/';
std::string base = PathHelper::GetExecutableDirA() + "/"; std::string base = PathHelper::GetExecutableDirA() + "/";
const char* roots[] = {"Sound/Minecraft/", "Minecraft.Client/Common/Sound/Minecraft/", const char* roots[] = {
"Sound/Minecraft/", "Minecraft.Client/Common/Sound/Minecraft/",
"Minecraft.Client/Common/res/TitleUpdate/res/Sound/Minecraft/"}; "Minecraft.Client/Common/res/TitleUpdate/res/Sound/Minecraft/"};
char finalPath[512] = {0}; char finalPath[512] = {0};
bool found = false; bool found = false;
@ -457,7 +458,8 @@ void SoundEngine::playMusicTick() {
bool found = false; bool found = false;
m_szStreamName[0] = '\0'; m_szStreamName[0] = '\0';
const char* roots[] = {"Minecraft.Client/Common/music/", "music/", "./"}; const char* roots[] = {"Minecraft.Client/Common/music/",
"music/", "./"};
for (const char* r : roots) { for (const char* r : roots) {
for (const char* e : {".ogg", ".mp3", ".wav"}) { for (const char* e : {".ogg", ".mp3", ".wav"}) {
@ -1135,8 +1137,10 @@ void SoundEngine::tick(std::shared_ptr<Mob>* players, float a) {
float yRot = players[i]->yRotO + float yRot = players[i]->yRotO +
(players[i]->yRot - players[i]->yRotO) * a; (players[i]->yRot - players[i]->yRotO) * a;
float yCos = (float)cos(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); float yCos =
float ySin = (float)sin(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); (float)cos(-yRot * Mth::DEG_TO_RAD - std::numbers::pi);
float ySin =
(float)sin(-yRot * Mth::DEG_TO_RAD - std::numbers::pi);
// store the listener positions for splitscreen // store the listener positions for splitscreen
m_ListenerA[i].vPosition.x = x; m_ListenerA[i].vPosition.x = x;

View file

@ -112,9 +112,8 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
memset(pSkinBox, 0, sizeof(SKIN_BOX)); memset(pSkinBox, 0, sizeof(SKIN_BOX));
swscanf(value.c_str(), L"%9ls%f%f%f%f%f%f%f%f", wchBodyPart, 10, swscanf(value.c_str(), L"%9ls%f%f%f%f%f%f%f%f", wchBodyPart, 10,
&pSkinBox->fX, &pSkinBox->fY, &pSkinBox->fZ, &pSkinBox->fX, &pSkinBox->fY, &pSkinBox->fZ, &pSkinBox->fW,
&pSkinBox->fW, &pSkinBox->fH, &pSkinBox->fD, &pSkinBox->fH, &pSkinBox->fD, &pSkinBox->fU, &pSkinBox->fV);
&pSkinBox->fU, &pSkinBox->fV);
if (wcscmp(wchBodyPart, L"HEAD") == 0) { if (wcscmp(wchBodyPart, L"HEAD") == 0) {
pSkinBox->ePart = eBodyPart_Head; pSkinBox->ePart = eBodyPart_Head;

View file

@ -199,7 +199,6 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions* lgo, uint8_t* dIn,
dis.close(); dis.close();
bais.close(); bais.close();
ByteArrayInputStream bais2(content); ByteArrayInputStream bais2(content);
DataInputStream dis2(&bais2); DataInputStream dis2(&bais2);
@ -228,7 +227,6 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions* lgo, uint8_t* dIn,
delete lgo; delete lgo;
} }
// Close and return. // Close and return.
dis2.close(); dis2.close();
bais2.close(); bais2.close();
@ -286,8 +284,8 @@ void GameRuleManager::saveGameRules(uint8_t** dOut, unsigned int* dSize) {
// Write string table. // Write string table.
uint8_t* stbaPtr = nullptr; uint8_t* stbaPtr = nullptr;
unsigned int stbaSize = 0; unsigned int stbaSize = 0;
m_currentGameRuleDefinitions->getStringTable()->getData( m_currentGameRuleDefinitions->getStringTable()->getData(&stbaPtr,
&stbaPtr, &stbaSize); &stbaSize);
std::vector<uint8_t> stba(stbaPtr, stbaPtr + stbaSize); std::vector<uint8_t> stba(stbaPtr, stbaPtr + stbaSize);
compr_dos.writeInt(stba.size()); compr_dos.writeInt(stba.size());
compr_dos.write(stba); compr_dos.write(stba);
@ -313,7 +311,6 @@ void GameRuleManager::saveGameRules(uint8_t** dOut, unsigned int* dSize) {
dos.writeInt(compr_baos.buf.size()); dos.writeInt(compr_baos.buf.size());
dos.write(compr_ba); dos.write(compr_ba);
compr_dos.close(); compr_dos.close();
compr_baos.close(); compr_baos.close();
// -- END COMPRESSED -- // // -- END COMPRESSED -- //
@ -416,7 +413,8 @@ bool GameRuleManager::readRuleFile(
std::vector<uint8_t> compressedBuffer(compressedSize); std::vector<uint8_t> compressedBuffer(compressedSize);
dis.read(compressedBuffer); dis.read(compressedBuffer);
std::vector<uint8_t> decompressedBuffer = std::vector<uint8_t>(uncompressedSize); std::vector<uint8_t> decompressedBuffer =
std::vector<uint8_t>(uncompressedSize);
unsigned int decompressedSize = uncompressedSize; unsigned int decompressedSize = uncompressedSize;
switch (compressionType) { switch (compressionType) {
@ -467,7 +465,6 @@ bool GameRuleManager::readRuleFile(
*/ */
}; };
contentBais = new ByteArrayInputStream(decompressedBuffer); contentBais = new ByteArrayInputStream(decompressedBuffer);
contentDis = new DataInputStream(contentBais); contentDis = new DataInputStream(contentBais);
} }

View file

@ -181,12 +181,10 @@ void ApplySchematicRuleDefinition::processSchematic(AABB* chunkBox,
m_totalBlocksChanged += m_schematic->applyBlocksAndData( m_totalBlocksChanged += m_schematic->applyBlocksAndData(
chunk, chunkBox, &*m_locationBox, m_rotation); chunk, chunkBox, &*m_locationBox, m_rotation);
// Add the tileEntities // Add the tileEntities
m_schematic->applyTileEntities(chunk, chunkBox, &*m_locationBox, m_schematic->applyTileEntities(chunk, chunkBox, &*m_locationBox,
m_rotation); m_rotation);
// TODO This does not take into account things that go outside the // TODO This does not take into account things that go outside the
// bounds of the world // bounds of the world
int targetBlocks = (m_locationBox->x1 - m_locationBox->x0) * int targetBlocks = (m_locationBox->x1 - m_locationBox->x0) *
@ -199,7 +197,6 @@ void ApplySchematicRuleDefinition::processSchematic(AABB* chunkBox,
// m_schematic = nullptr; // m_schematic = nullptr;
} }
} }
} }
void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox, void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox,
@ -222,7 +219,6 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox,
m_totalBlocksChangedLighting += m_schematic->applyLighting( m_totalBlocksChangedLighting += m_schematic->applyLighting(
chunk, chunkBox, &*m_locationBox, m_rotation); chunk, chunkBox, &*m_locationBox, m_rotation);
// TODO This does not take into account things that go outside the // TODO This does not take into account things that go outside the
// bounds of the world // bounds of the world
int targetBlocks = (m_locationBox->x1 - m_locationBox->x0) * int targetBlocks = (m_locationBox->x1 - m_locationBox->x0) *
@ -235,7 +231,6 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox,
// m_schematic = nullptr; // m_schematic = nullptr;
} }
} }
} }
bool ApplySchematicRuleDefinition::checkIntersects(int x0, int y0, int z0, bool ApplySchematicRuleDefinition::checkIntersects(int x0, int y0, int z0,

View file

@ -62,7 +62,6 @@ void ConsoleSchematicFile::save(DataOutputStream* dos) {
dos->write(ba); dos->write(ba);
save_tags(dos); save_tags(dos);
} }
} }
@ -126,7 +125,6 @@ void ConsoleSchematicFile::load(DataInputStream* dis) {
Compression::getCompression()->SetDecompressionType( Compression::getCompression()->SetDecompressionType(
APPROPRIATE_COMPRESSION_TYPE); APPROPRIATE_COMPRESSION_TYPE);
}; };
} }
// READ TAGS // // READ TAGS //
@ -228,13 +226,14 @@ int64_t ConsoleSchematicFile::applyBlocksAndData(LevelChunk* chunk,
int rowBlockCount = getYSize() * getZSize(); int rowBlockCount = getYSize() * getZSize();
int totalBlockCount = getXSize() * rowBlockCount; int totalBlockCount = getXSize() * rowBlockCount;
std::vector<uint8_t> blockData = std::vector<uint8_t>(Level::CHUNK_TILE_COUNT); std::vector<uint8_t> blockData =
std::vector<uint8_t>(Level::CHUNK_TILE_COUNT);
chunk->getBlockData(blockData); chunk->getBlockData(blockData);
std::vector<uint8_t> dataData = std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT); std::vector<uint8_t> dataData =
std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT);
chunk->getDataData(dataData); chunk->getDataData(dataData);
// Ignore light data // Ignore light data
int blockLightP = -1; int blockLightP = -1;
int skyLightP = -1; int skyLightP = -1;
@ -310,7 +309,6 @@ int64_t ConsoleSchematicFile::applyBlocksAndData(LevelChunk* chunk,
chunk->recalcHeightmapOnly(); chunk->recalcHeightmapOnly();
chunk->setDataData(dataData); chunk->setDataData(dataData);
// A basic pass through to roughly do the lighting. At this point of // A basic pass through to roughly do the lighting. At this point of
// post-processing, we don't have all the neighbouring chunks loaded in, so // post-processing, we don't have all the neighbouring chunks loaded in, so
// any lighting here should be things that won't propagate out of this // any lighting here should be things that won't propagate out of this
@ -637,8 +635,8 @@ void ConsoleSchematicFile::generateSchematicFile(
// Write zSize // Write zSize
if (dos != nullptr) dos->writeInt(zSize); if (dos != nullptr) dos->writeInt(zSize);
// std::vector<uint8_t> rawBuffer = level->getBlocksAndData(xStart, yStart, zStart, // std::vector<uint8_t> rawBuffer = level->getBlocksAndData(xStart, yStart,
// xSize, ySize, zSize, false); // zStart, xSize, ySize, zSize, false);
int xRowSize = ySize * zSize; int xRowSize = ySize * zSize;
int blockCount = xSize * xRowSize; int blockCount = xSize * xRowSize;
std::vector<uint8_t> result(blockCount * 3 / 2); std::vector<uint8_t> result(blockCount * 3 / 2);
@ -701,7 +699,8 @@ void ConsoleSchematicFile::generateSchematicFile(
break; break;
}; };
std::vector<uint8_t> buffer = std::vector<uint8_t>(ucTemp, ucTemp + inputSize); std::vector<uint8_t> buffer =
std::vector<uint8_t>(ucTemp, ucTemp + inputSize);
delete[] ucTemp; delete[] ucTemp;
if (dos != nullptr) dos->writeInt(inputSize); if (dos != nullptr) dos->writeInt(inputSize);
@ -794,11 +793,11 @@ void ConsoleSchematicFile::generateSchematicFile(
if (dos != nullptr) NbtIo::write(&tag, dos); if (dos != nullptr) NbtIo::write(&tag, dos);
} }
void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8_t>* data, void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk,
int x0, int y0, int z0, int x1, std::vector<uint8_t>* data, int x0,
int y1, int z1, int& blocksP, int y0, int z0, int x1, int y1,
int& dataP, int& blockLightP, int z1, int& blocksP, int& dataP,
int& skyLightP) { int& blockLightP, int& skyLightP) {
// 4J Stu - Needs updated to work with higher worlds, should still work with // 4J Stu - Needs updated to work with higher worlds, should still work with
// non-optimised version below // non-optimised version below
// int xs = x1 - x0; // int xs = x1 - x0;
@ -806,22 +805,23 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
// int zs = z1 - z0; // int zs = z1 - z0;
// if (xs * ys * zs == LevelChunk::BLOCKS_LENGTH) // if (xs * ys * zs == LevelChunk::BLOCKS_LENGTH)
//{ //{
// std::vector<uint8_t> blockData = std::vector<uint8_t>(data->data + blocksP, // std::vector<uint8_t> blockData = std::vector<uint8_t>(data->data +
// blocksP,
// Level::CHUNK_TILE_COUNT); chunk->getBlockData(blockData); // Level::CHUNK_TILE_COUNT); chunk->getBlockData(blockData);
// blocksP += blockData.size(); // blocksP += blockData.size();
// std::vector<uint8_t> dataData = std::vector<uint8_t>(data->data + dataP, 16384); // std::vector<uint8_t> dataData = std::vector<uint8_t>(data->data + dataP,
// chunk->getBlockLightData(dataData); // 16384); chunk->getBlockLightData(dataData); dataP +=
// dataP += dataData.size(); // dataData.size();
// std::vector<uint8_t> blockLightData = std::vector<uint8_t>(data->data + blockLightP, 16384); // std::vector<uint8_t> blockLightData = std::vector<uint8_t>(data->data +
// chunk->getBlockLightData(blockLightData); // blockLightP, 16384); chunk->getBlockLightData(blockLightData);
// blockLightP += blockLightData.size(); // blockLightP
//+= blockLightData.size();
// std::vector<uint8_t> skyLightData = std::vector<uint8_t>(data->data + skyLightP, 16384); // std::vector<uint8_t> skyLightData = std::vector<uint8_t>(data->data +
// chunk->getSkyLightData(skyLightData); // skyLightP, 16384); chunk->getSkyLightData(skyLightData); skyLightP
// skyLightP += skyLightData.size(); // += skyLightData.size(); return;
// return;
//} //}
bool bHasLower, bHasUpper; bool bHasLower, bHasUpper;
@ -843,7 +843,8 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
bHasUpper = true; bHasUpper = true;
} }
std::vector<uint8_t> blockData = std::vector<uint8_t>(Level::CHUNK_TILE_COUNT); std::vector<uint8_t> blockData =
std::vector<uint8_t>(Level::CHUNK_TILE_COUNT);
chunk->getBlockData(blockData); chunk->getBlockData(blockData);
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++) { for (int z = z0; z < z1; z++) {
@ -851,7 +852,9 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
int slot = x << Level::genDepthBitsPlusFour | int slot = x << Level::genDepthBitsPlusFour |
z << Level::genDepthBits | lowerY0; z << Level::genDepthBits | lowerY0;
int len = lowerY1 - lowerY0; int len = lowerY1 - lowerY0;
std::copy(blockData.data() + slot, blockData.data() + slot + len, data->data() + blocksP); std::copy(blockData.data() + slot,
blockData.data() + slot + len,
data->data() + blocksP);
blocksP += len; blocksP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -859,12 +862,15 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
z << Level::genDepthBits | upperY0) + z << Level::genDepthBits | upperY0) +
Level::COMPRESSED_CHUNK_SECTION_TILES; Level::COMPRESSED_CHUNK_SECTION_TILES;
int len = upperY1 - upperY0; int len = upperY1 - upperY0;
std::copy(blockData.data() + slot, blockData.data() + slot + len, data->data() + blocksP); std::copy(blockData.data() + slot,
blockData.data() + slot + len,
data->data() + blocksP);
blocksP += len; blocksP += len;
} }
} }
std::vector<uint8_t> dataData = std::vector<uint8_t>(Level::CHUNK_TILE_COUNT); std::vector<uint8_t> dataData =
std::vector<uint8_t>(Level::CHUNK_TILE_COUNT);
chunk->getDataData(dataData); chunk->getDataData(dataData);
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++) { for (int z = z0; z < z1; z++) {
@ -873,7 +879,8 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
z << Level::genDepthBits | lowerY0) >> z << Level::genDepthBits | lowerY0) >>
1; 1;
int len = (lowerY1 - lowerY0) / 2; int len = (lowerY1 - lowerY0) / 2;
std::copy(dataData.data() + slot, dataData.data() + slot + len, data->data() + dataP); std::copy(dataData.data() + slot, dataData.data() + slot + len,
data->data() + dataP);
dataP += len; dataP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -882,14 +889,16 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
Level::COMPRESSED_CHUNK_SECTION_TILES) >> Level::COMPRESSED_CHUNK_SECTION_TILES) >>
1; 1;
int len = (upperY1 - upperY0) / 2; int len = (upperY1 - upperY0) / 2;
std::copy(dataData.data() + slot, dataData.data() + slot + len, data->data() + dataP); std::copy(dataData.data() + slot, dataData.data() + slot + len,
data->data() + dataP);
dataP += len; dataP += len;
} }
} }
// 4J Stu - Allow ignoring light data // 4J Stu - Allow ignoring light data
if (blockLightP > -1) { if (blockLightP > -1) {
std::vector<uint8_t> blockLightData = std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT); std::vector<uint8_t> blockLightData =
std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT);
chunk->getBlockLightData(blockLightData); chunk->getBlockLightData(blockLightData);
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++) { for (int z = z0; z < z1; z++) {
@ -898,7 +907,9 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
z << Level::genDepthBits | lowerY0) >> z << Level::genDepthBits | lowerY0) >>
1; 1;
int len = (lowerY1 - lowerY0) / 2; int len = (lowerY1 - lowerY0) / 2;
std::copy(blockLightData.data() + slot, blockLightData.data() + slot + len, data->data() + blockLightP); std::copy(blockLightData.data() + slot,
blockLightData.data() + slot + len,
data->data() + blockLightP);
blockLightP += len; blockLightP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -907,7 +918,9 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
1) + 1) +
(Level::COMPRESSED_CHUNK_SECTION_TILES / 2); (Level::COMPRESSED_CHUNK_SECTION_TILES / 2);
int len = (upperY1 - upperY0) / 2; int len = (upperY1 - upperY0) / 2;
std::copy(blockLightData.data() + slot, blockLightData.data() + slot + len, data->data() + blockLightP); std::copy(blockLightData.data() + slot,
blockLightData.data() + slot + len,
data->data() + blockLightP);
blockLightP += len; blockLightP += len;
} }
} }
@ -915,7 +928,8 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
// 4J Stu - Allow ignoring light data // 4J Stu - Allow ignoring light data
if (skyLightP > -1) { if (skyLightP > -1) {
std::vector<uint8_t> skyLightData = std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT); std::vector<uint8_t> skyLightData =
std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT);
chunk->getSkyLightData(skyLightData); chunk->getSkyLightData(skyLightData);
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++) { for (int z = z0; z < z1; z++) {
@ -924,7 +938,9 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
z << Level::genDepthBits | lowerY0) >> z << Level::genDepthBits | lowerY0) >>
1; 1;
int len = (lowerY1 - lowerY0) / 2; int len = (lowerY1 - lowerY0) / 2;
std::copy(skyLightData.data() + slot, skyLightData.data() + slot + len, data->data() + skyLightP); std::copy(skyLightData.data() + slot,
skyLightData.data() + slot + len,
data->data() + skyLightP);
skyLightP += len; skyLightP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -933,7 +949,9 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
1) + 1) +
(Level::COMPRESSED_CHUNK_SECTION_TILES / 2); (Level::COMPRESSED_CHUNK_SECTION_TILES / 2);
int len = (upperY1 - upperY0) / 2; int len = (upperY1 - upperY0) / 2;
std::copy(skyLightData.data() + slot, skyLightData.data() + slot + len, data->data() + skyLightP); std::copy(skyLightData.data() + slot,
skyLightData.data() + slot + len,
data->data() + skyLightP);
skyLightP += len; skyLightP += len;
} }
} }
@ -943,9 +961,10 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
} }
void ConsoleSchematicFile::setBlocksAndData( void ConsoleSchematicFile::setBlocksAndData(
LevelChunk* chunk, std::vector<uint8_t>& blockData, std::vector<uint8_t>& dataData, LevelChunk* chunk, std::vector<uint8_t>& blockData,
std::vector<uint8_t> inputData, int x0, int y0, int z0, int x1, int y1, int z1, std::vector<uint8_t>& dataData, std::vector<uint8_t> inputData, int x0,
int& blocksP, int& dataP, int& blockLightP, int& skyLightP) { int y0, int z0, int x1, int y1, int z1, int& blocksP, int& dataP,
int& blockLightP, int& skyLightP) {
bool bHasLower, bHasUpper; bool bHasLower, bHasUpper;
bHasLower = bHasUpper = false; bHasLower = bHasUpper = false;
int lowerY0, lowerY1, upperY0, upperY1; int lowerY0, lowerY1, upperY0, upperY1;
@ -970,7 +989,9 @@ void ConsoleSchematicFile::setBlocksAndData(
int slot = x << Level::genDepthBitsPlusFour | int slot = x << Level::genDepthBitsPlusFour |
z << Level::genDepthBits | lowerY0; z << Level::genDepthBits | lowerY0;
int len = lowerY1 - lowerY0; int len = lowerY1 - lowerY0;
std::copy(inputData.data() + blocksP, inputData.data() + blocksP + len, blockData.data() + slot); std::copy(inputData.data() + blocksP,
inputData.data() + blocksP + len,
blockData.data() + slot);
blocksP += len; blocksP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -978,12 +999,13 @@ void ConsoleSchematicFile::setBlocksAndData(
z << Level::genDepthBits | upperY0) + z << Level::genDepthBits | upperY0) +
Level::COMPRESSED_CHUNK_SECTION_TILES; Level::COMPRESSED_CHUNK_SECTION_TILES;
int len = upperY1 - upperY0; int len = upperY1 - upperY0;
std::copy(inputData.data() + blocksP, inputData.data() + blocksP + len, blockData.data() + slot); std::copy(inputData.data() + blocksP,
inputData.data() + blocksP + len,
blockData.data() + slot);
blocksP += len; blocksP += len;
} }
} }
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++) { for (int z = z0; z < z1; z++) {
if (bHasLower) { if (bHasLower) {
@ -991,7 +1013,9 @@ void ConsoleSchematicFile::setBlocksAndData(
z << Level::genDepthBits | lowerY0) >> z << Level::genDepthBits | lowerY0) >>
1; 1;
int len = (lowerY1 - lowerY0) / 2; int len = (lowerY1 - lowerY0) / 2;
std::copy(inputData.data() + dataP, inputData.data() + dataP + len, dataData.data() + slot); std::copy(inputData.data() + dataP,
inputData.data() + dataP + len,
dataData.data() + slot);
dataP += len; dataP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -1000,14 +1024,17 @@ void ConsoleSchematicFile::setBlocksAndData(
Level::COMPRESSED_CHUNK_SECTION_TILES) >> Level::COMPRESSED_CHUNK_SECTION_TILES) >>
1; 1;
int len = (upperY1 - upperY0) / 2; int len = (upperY1 - upperY0) / 2;
std::copy(inputData.data() + dataP, inputData.data() + dataP + len, dataData.data() + slot); std::copy(inputData.data() + dataP,
inputData.data() + dataP + len,
dataData.data() + slot);
dataP += len; dataP += len;
} }
} }
// 4J Stu - Allow ignoring light data // 4J Stu - Allow ignoring light data
if (blockLightP > -1) { if (blockLightP > -1) {
std::vector<uint8_t> blockLightData = std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT); std::vector<uint8_t> blockLightData =
std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT);
chunk->getBlockLightData(blockLightData); chunk->getBlockLightData(blockLightData);
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++) { for (int z = z0; z < z1; z++) {
@ -1016,7 +1043,9 @@ void ConsoleSchematicFile::setBlocksAndData(
z << Level::genDepthBits | lowerY0) >> z << Level::genDepthBits | lowerY0) >>
1; 1;
int len = (lowerY1 - lowerY0) / 2; int len = (lowerY1 - lowerY0) / 2;
std::copy(inputData.data() + blockLightP, inputData.data() + blockLightP + len, blockLightData.data() + slot); std::copy(inputData.data() + blockLightP,
inputData.data() + blockLightP + len,
blockLightData.data() + slot);
blockLightP += len; blockLightP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -1025,7 +1054,9 @@ void ConsoleSchematicFile::setBlocksAndData(
1) + 1) +
(Level::COMPRESSED_CHUNK_SECTION_TILES / 2); (Level::COMPRESSED_CHUNK_SECTION_TILES / 2);
int len = (upperY1 - upperY0) / 2; int len = (upperY1 - upperY0) / 2;
std::copy(inputData.data() + blockLightP, inputData.data() + blockLightP + len, blockLightData.data() + slot); std::copy(inputData.data() + blockLightP,
inputData.data() + blockLightP + len,
blockLightData.data() + slot);
blockLightP += len; blockLightP += len;
} }
} }
@ -1034,7 +1065,8 @@ void ConsoleSchematicFile::setBlocksAndData(
// 4J Stu - Allow ignoring light data // 4J Stu - Allow ignoring light data
if (skyLightP > -1) { if (skyLightP > -1) {
std::vector<uint8_t> skyLightData = std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT); std::vector<uint8_t> skyLightData =
std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT);
chunk->getSkyLightData(skyLightData); chunk->getSkyLightData(skyLightData);
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++) { for (int z = z0; z < z1; z++) {
@ -1043,7 +1075,9 @@ void ConsoleSchematicFile::setBlocksAndData(
z << Level::genDepthBits | lowerY0) >> z << Level::genDepthBits | lowerY0) >>
1; 1;
int len = (lowerY1 - lowerY0) / 2; int len = (lowerY1 - lowerY0) / 2;
std::copy(inputData.data() + skyLightP, inputData.data() + skyLightP + len, skyLightData.data() + slot); std::copy(inputData.data() + skyLightP,
inputData.data() + skyLightP + len,
skyLightData.data() + slot);
skyLightP += len; skyLightP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -1051,7 +1085,9 @@ void ConsoleSchematicFile::setBlocksAndData(
z << Level::genDepthBits | upperY0) + z << Level::genDepthBits | upperY0) +
(Level::COMPRESSED_CHUNK_SECTION_TILES / 2); (Level::COMPRESSED_CHUNK_SECTION_TILES / 2);
int len = (upperY1 - upperY0) / 2; int len = (upperY1 - upperY0) / 2;
std::copy(inputData.data() + skyLightP, inputData.data() + skyLightP + len, skyLightData.data() + slot); std::copy(inputData.data() + skyLightP,
inputData.data() + skyLightP + len,
skyLightData.data() + slot);
skyLightP += len; skyLightP += len;
} }
} }

View file

@ -92,18 +92,19 @@ public:
int xEnd, int yEnd, int zEnd, int xEnd, int yEnd, int zEnd,
bool bSaveMobs, bool bSaveMobs,
Compression::ECompressionTypes); Compression::ECompressionTypes);
static void setBlocksAndData(LevelChunk* chunk, std::vector<uint8_t>& blockData, static void setBlocksAndData(LevelChunk* chunk,
std::vector<uint8_t>& dataData, std::vector<uint8_t> data, int x0, std::vector<uint8_t>& blockData,
int y0, int z0, int x1, int y1, int z1, std::vector<uint8_t>& dataData,
int& blocksP, int& dataP, int& blockLightP, std::vector<uint8_t> data, int x0, int y0,
int& skyLightP); int z0, int x1, int y1, int z1, int& blocksP,
int& dataP, int& blockLightP, int& skyLightP);
private: private:
void save_tags(DataOutputStream* dos); void save_tags(DataOutputStream* dos);
void load_tags(DataInputStream* dis); void load_tags(DataInputStream* dis);
static void getBlocksAndData(LevelChunk* chunk, std::vector<uint8_t>* data, int x0, static void getBlocksAndData(LevelChunk* chunk, std::vector<uint8_t>* data,
int y0, int z0, int x1, int y1, int z1, int x0, int y0, int z0, int x1, int y1, int z1,
int& blocksP, int& dataP, int& blockLightP, int& blocksP, int& dataP, int& blockLightP,
int& skyLightP); int& skyLightP);
static std::vector<std::shared_ptr<TileEntity> >* getTileEntitiesInRegion( static std::vector<std::shared_ptr<TileEntity> >* getTileEntitiesInRegion(

View file

@ -277,7 +277,6 @@ void LevelGenerationOptions::processSchematics(LevelChunk* chunk) {
delete bb; delete bb;
} }
} }
} }
void LevelGenerationOptions::processSchematicsLighting(LevelChunk* chunk) { void LevelGenerationOptions::processSchematicsLighting(LevelChunk* chunk) {
@ -288,12 +287,10 @@ void LevelGenerationOptions::processSchematicsLighting(LevelChunk* chunk) {
ApplySchematicRuleDefinition* rule = *it; ApplySchematicRuleDefinition* rule = *it;
rule->processSchematicLighting(&chunkBox, chunk); rule->processSchematicLighting(&chunkBox, chunk);
} }
} }
bool LevelGenerationOptions::checkIntersects(int x0, int y0, int z0, int x1, bool LevelGenerationOptions::checkIntersects(int x0, int y0, int z0, int x1,
int y1, int z1) { int y1, int z1) {
// As an optimisation, we can quickly discard things below a certain y which // As an optimisation, we can quickly discard things below a certain y which
// makes most ore checks faster due to a) ores generally being below // makes most ore checks faster due to a) ores generally being below
// ground/sea level and b) tutorial world additions generally being above // ground/sea level and b) tutorial world additions generally being above
@ -513,7 +510,9 @@ int LevelGenerationOptions::packMounted(void* pParam, int iPad, uint32_t dwErr,
if (fileHandle) { if (fileHandle) {
uint32_t dwFileSize = grf.length(); uint32_t dwFileSize = grf.length();
uint8_t* pbData = (uint8_t*)new uint8_t[dwFileSize]; uint8_t* pbData = (uint8_t*)new uint8_t[dwFileSize];
fileHandle.read(reinterpret_cast<char*>(pbData), static_cast<std::streamsize>(dwFileSize)); fileHandle.read(
reinterpret_cast<char*>(pbData),
static_cast<std::streamsize>(dwFileSize));
if (!fileHandle) { if (!fileHandle) {
app.FatalLoadError(); app.FatalLoadError();
} }
@ -540,7 +539,8 @@ int LevelGenerationOptions::packMounted(void* pParam, int iPad, uint32_t dwErr,
if (saveHandle) { if (saveHandle) {
auto dwFileSize = std::filesystem::file_size(savePath); auto dwFileSize = std::filesystem::file_size(savePath);
uint8_t* pbData = (uint8_t*)new uint8_t[dwFileSize]; uint8_t* pbData = (uint8_t*)new uint8_t[dwFileSize];
saveHandle.read(reinterpret_cast<char*>(pbData), static_cast<std::streamsize>(dwFileSize)); saveHandle.read(reinterpret_cast<char*>(pbData),
static_cast<std::streamsize>(dwFileSize));
if (!saveHandle) { if (!saveHandle) {
app.FatalLoadError(); app.FatalLoadError();
} }

View file

@ -144,10 +144,12 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft,
std::ifstream fileHandle(grfPath, std::ios::binary); std::ifstream fileHandle(grfPath, std::ios::binary);
if (fileHandle) { if (fileHandle) {
auto dwFileSize = std::filesystem::file_size(grfPath); auto dwFileSize =
std::filesystem::file_size(grfPath);
uint8_t* pbData = uint8_t* pbData =
(uint8_t*)new uint8_t[dwFileSize]; (uint8_t*)new uint8_t[dwFileSize];
fileHandle.read(reinterpret_cast<char*>(pbData), fileHandle.read(
reinterpret_cast<char*>(pbData),
static_cast<std::streamsize>(dwFileSize)); static_cast<std::streamsize>(dwFileSize));
if (!fileHandle) { if (!fileHandle) {
app.FatalLoadError(); app.FatalLoadError();

View file

@ -11,7 +11,6 @@
#include "NetworkPlayerInterface.h" #include "NetworkPlayerInterface.h"
#include "SessionInfo.h" #include "SessionInfo.h"
class ClientConnection; class ClientConnection;
class Minecraft; class Minecraft;
class CGameNetworkManager; class CGameNetworkManager;

View file

@ -81,7 +81,8 @@ Socket::Socket(bool response) {
if (s_serverConnection != nullptr) { if (s_serverConnection != nullptr) {
s_serverConnection->NewIncomingSocket(socket); s_serverConnection->NewIncomingSocket(socket);
} else { } else {
fprintf(stderr, fprintf(
stderr,
"SOCKET: Warning - attempted to notify server of new incoming " "SOCKET: Warning - attempted to notify server of new incoming "
"socket but s_serverConnection is nullptr\n"); "socket but s_serverConnection is nullptr\n");
} }
@ -142,7 +143,8 @@ void Socket::pushDataToQueue(const std::uint8_t* pbData, std::size_t dataSize,
if (!fromHost) queueIdx = SOCKET_SERVER_END; if (!fromHost) queueIdx = SOCKET_SERVER_END;
if (queueIdx != m_end && !m_hostLocal) { if (queueIdx != m_end && !m_hostLocal) {
fprintf(stderr, fprintf(
stderr,
"SOCKET: Error pushing data to queue. End is %d but queue idx id " "SOCKET: Error pushing data to queue. End is %d but queue idx id "
"%d\n", "%d\n",
m_end, queueIdx); m_end, queueIdx);
@ -275,7 +277,8 @@ int Socket::SocketInputStreamLocal::read(std::vector<uint8_t>& b) {
// Try and get an input range of bytes, blocking until enough bytes are // Try and get an input range of bytes, blocking until enough bytes are
// available // available
int Socket::SocketInputStreamLocal::read(std::vector<uint8_t>& b, unsigned int offset, int Socket::SocketInputStreamLocal::read(std::vector<uint8_t>& b,
unsigned int offset,
unsigned int length) { unsigned int length) {
while (m_streamOpen) { while (m_streamOpen) {
{ {
@ -326,7 +329,8 @@ void Socket::SocketOutputStreamLocal::write(const std::vector<uint8_t>& b) {
write(b, 0, b.size()); write(b, 0, b.size());
} }
void Socket::SocketOutputStreamLocal::write(const std::vector<uint8_t>& b, unsigned int offset, void Socket::SocketOutputStreamLocal::write(const std::vector<uint8_t>& b,
unsigned int offset,
unsigned int length) { unsigned int length) {
if (m_streamOpen != true) { if (m_streamOpen != true) {
return; return;
@ -386,7 +390,8 @@ int Socket::SocketInputStreamNetwork::read(std::vector<uint8_t>& b) {
// Try and get an input range of bytes, blocking until enough bytes are // Try and get an input range of bytes, blocking until enough bytes are
// available // available
int Socket::SocketInputStreamNetwork::read(std::vector<uint8_t>& b, unsigned int offset, int Socket::SocketInputStreamNetwork::read(std::vector<uint8_t>& b,
unsigned int offset,
unsigned int length) { unsigned int length) {
while (m_streamOpen) { while (m_streamOpen) {
{ {
@ -431,14 +436,14 @@ void Socket::SocketOutputStreamNetwork::write(const std::vector<uint8_t>& b) {
write(b, 0, b.size()); write(b, 0, b.size());
} }
void Socket::SocketOutputStreamNetwork::write(const std::vector<uint8_t>& b, unsigned int offset, void Socket::SocketOutputStreamNetwork::write(const std::vector<uint8_t>& b,
unsigned int offset,
unsigned int length) { unsigned int length) {
writeWithFlags(b, offset, length, 0); writeWithFlags(b, offset, length, 0);
} }
void Socket::SocketOutputStreamNetwork::writeWithFlags(const std::vector<uint8_t>& b, void Socket::SocketOutputStreamNetwork::writeWithFlags(
unsigned int offset, const std::vector<uint8_t>& b, unsigned int offset, unsigned int length,
unsigned int length,
int flags) { int flags) {
if (m_streamOpen != true) return; if (m_streamOpen != true) return;
if (length == 0) return; if (length == 0) return;
@ -467,7 +472,8 @@ void Socket::SocketOutputStreamNetwork::writeWithFlags(const std::vector<uint8_t
INetworkPlayer* hostPlayer = g_NetworkManager.GetHostPlayer(); INetworkPlayer* hostPlayer = g_NetworkManager.GetHostPlayer();
if (hostPlayer == nullptr) { if (hostPlayer == nullptr) {
fprintf(stderr, fprintf(
stderr,
"Trying to write to network, but the hostPlayer is nullptr\n"); "Trying to write to network, but the hostPlayer is nullptr\n");
return; return;
} }

View file

@ -30,8 +30,9 @@ public:
class SocketOutputStream : public OutputStream { class SocketOutputStream : public OutputStream {
public: public:
// The flags are those that can be used for the QNet SendData function // The flags are those that can be used for the QNet SendData function
virtual void writeWithFlags(const std::vector<uint8_t>& b, unsigned int offset, virtual void writeWithFlags(const std::vector<uint8_t>& b,
unsigned int length, int flags) { unsigned int offset, unsigned int length,
int flags) {
write(b, offset, length); write(b, offset, length);
} }
}; };
@ -49,7 +50,8 @@ private:
virtual int read(); virtual int read();
virtual int read(std::vector<uint8_t>& b); virtual int read(std::vector<uint8_t>& b);
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual int64_t skip(int64_t n) { virtual int64_t skip(int64_t n) {
return n; return n;
@ -85,7 +87,8 @@ private:
virtual int read(); virtual int read();
virtual int read(std::vector<uint8_t>& b); virtual int read(std::vector<uint8_t>& b);
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual int64_t skip(int64_t n) { virtual int64_t skip(int64_t n) {
return n; return n;
@ -104,8 +107,9 @@ private:
virtual void write(const std::vector<uint8_t>& b); virtual void write(const std::vector<uint8_t>& b);
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length); unsigned int length);
virtual void writeWithFlags(const std::vector<uint8_t>& b, unsigned int offset, virtual void writeWithFlags(const std::vector<uint8_t>& b,
unsigned int length, int flags); unsigned int offset, unsigned int length,
int flags);
virtual void close(); virtual void close();
virtual void flush() {} virtual void flush() {}
}; };

View file

@ -184,11 +184,11 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/)
// END OF BASIC TUTORIAL // END OF BASIC TUTORIAL
addTask(e_Tutorial_State_Gameplay, addTask(
e_Tutorial_State_Gameplay,
new ChoiceTask(this, IDS_TUTORIAL_TASK_BASIC_COMPLETE, new ChoiceTask(this, IDS_TUTORIAL_TASK_BASIC_COMPLETE,
IDS_TUTORIAL_PROMPT_BASIC_COMPLETE, true, IDS_TUTORIAL_PROMPT_BASIC_COMPLETE, true, ACTION_MENU_A,
ACTION_MENU_A, ACTION_MENU_B, ACTION_MENU_B, e_Tutorial_Completion_Jump_To_Last_Task));
e_Tutorial_Completion_Jump_To_Last_Task));
// START OF FULL TUTORIAL // START OF FULL TUTORIAL

View file

@ -13,8 +13,7 @@
#include "Minecraft.Client/Common/src/Tutorial/Tasks/TutorialTask.h" #include "Minecraft.Client/Common/src/Tutorial/Tasks/TutorialTask.h"
#include "Minecraft.Client/Linux/Linux_UIController.h" #include "Minecraft.Client/Linux/Linux_UIController.h"
InfoTask::InfoTask( InfoTask::InfoTask(Tutorial* tutorial, int descriptionId, int promptId /*= -1*/,
Tutorial* tutorial, int descriptionId, int promptId /*= -1*/,
bool requiresUserInput /*= false*/, int iMapping /*= 0*/) bool requiresUserInput /*= false*/, int iMapping /*= 0*/)
: TutorialTask(tutorial, descriptionId, false, nullptr, true, false, : TutorialTask(tutorial, descriptionId, false, nullptr, true, false,
false) { false) {

View file

@ -15,8 +15,7 @@ private:
bool CompletionMaskIsValid(); bool CompletionMaskIsValid();
public: public:
InfoTask( InfoTask(Tutorial* tutorial, int descriptionId, int promptId = -1,
Tutorial* tutorial, int descriptionId, int promptId = -1,
bool requiresUserInput = false, int iMapping = 0); bool requiresUserInput = false, int iMapping = 0);
virtual bool isCompleted(); virtual bool isCompleted();
virtual int getPromptId(); virtual int getPromptId();

View file

@ -2366,8 +2366,8 @@ void Tutorial::tick() {
} }
} }
if (m_hintDisplayed && if (m_hintDisplayed && (lastMessageTime + m_iTutorialDisplayMessageTime) <
(lastMessageTime + m_iTutorialDisplayMessageTime) < PlatformTime::GetTickCount()) { PlatformTime::GetTickCount()) {
m_hintDisplayed = false; m_hintDisplayed = false;
} }
@ -2402,7 +2402,8 @@ bool Tutorial::setMessage(PopupMessageDetails* message) {
m_lastMessageState == m_CurrentState && m_lastMessageState == m_CurrentState &&
message->isSameContent(m_lastMessage) && message->isSameContent(m_lastMessage) &&
(!message->m_isReminder || (!message->m_isReminder ||
((lastMessageTime + m_iTutorialReminderTime) > PlatformTime::GetTickCount() && ((lastMessageTime + m_iTutorialReminderTime) >
PlatformTime::GetTickCount() &&
message->m_isReminder))) { message->m_isReminder))) {
delete message; delete message;
return false; return false;
@ -2412,7 +2413,8 @@ bool Tutorial::setMessage(PopupMessageDetails* message) {
(message->m_messageId > 0 || !message->m_messageString.empty())) { (message->m_messageId > 0 || !message->m_messageString.empty())) {
m_lastMessageState = m_CurrentState; m_lastMessageState = m_CurrentState;
if (!message->m_replaceCurrent) lastMessageTime = PlatformTime::GetTickCount(); if (!message->m_replaceCurrent)
lastMessageTime = PlatformTime::GetTickCount();
std::wstring text; std::wstring text;
if (!message->m_messageString.empty()) { if (!message->m_messageString.empty()) {

View file

@ -145,8 +145,8 @@ std::vector<uint8_t> ArchiveFile::getFile(const std::wstring& filename) {
uncompressedBuffer, &decompressedSize, out.data() + 4, uncompressedBuffer, &decompressedSize, out.data() + 4,
out.size() - 4); out.size() - 4);
out = std::vector<uint8_t>(uncompressedBuffer,
out = std::vector<uint8_t>(uncompressedBuffer, uncompressedBuffer + decompressedSize); uncompressedBuffer + decompressedSize);
delete[] uncompressedBuffer; delete[] uncompressedBuffer;
} }

View file

@ -630,7 +630,8 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() {
} }
} }
*/ */
std::vector<Recipy*>* recipes = ((Recipes*)Recipes::getInstance())->getRecipies(); std::vector<Recipy*>* recipes =
((Recipes*)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray(); Recipes::getInstance()->getRecipeIngredientsArray();
int iRecipeC = (int)recipes->size(); int iRecipeC = (int)recipes->size();
@ -871,7 +872,8 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() {
// run through the canbemade list and update the icons displayed // run through the canbemade list and update the icons displayed
int iIndex = 0; int iIndex = 0;
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); // std::vector<Recipy*> *recipes = ((Recipes
// *)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray(); Recipes::getInstance()->getRecipeIngredientsArray();
@ -993,7 +995,8 @@ void IUIScene_CraftingMenu::UpdateHighlight() {
// //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void IUIScene_CraftingMenu::UpdateVerticalSlots() { void IUIScene_CraftingMenu::UpdateVerticalSlots() {
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); // std::vector<Recipy*> *recipes = ((Recipes
// *)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray(); Recipes::getInstance()->getRecipeIngredientsArray();
@ -1064,7 +1067,8 @@ void IUIScene_CraftingMenu::UpdateVerticalSlots() {
// //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void IUIScene_CraftingMenu::DisplayIngredients() { void IUIScene_CraftingMenu::DisplayIngredients() {
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); // std::vector<Recipy*> *recipes = ((Recipes
// *)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray(); Recipes::getInstance()->getRecipeIngredientsArray();
@ -1231,7 +1235,8 @@ void IUIScene_CraftingMenu::DisplayIngredients() {
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void IUIScene_CraftingMenu::UpdateDescriptionText(bool bCanBeMade) { void IUIScene_CraftingMenu::UpdateDescriptionText(bool bCanBeMade) {
int iIDSString = 0; int iIDSString = 0;
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); // std::vector<Recipy*> *recipes = ((Recipes
// *)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray(); Recipes::getInstance()->getRecipeIngredientsArray();
@ -1319,7 +1324,8 @@ void IUIScene_CraftingMenu::UpdateDescriptionText(bool bCanBeMade) {
// //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void IUIScene_CraftingMenu::UpdateTooltips() { void IUIScene_CraftingMenu::UpdateTooltips() {
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); // std::vector<Recipy*> *recipes = ((Recipes
// *)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray(); Recipes::getInstance()->getRecipeIngredientsArray();
// Update tooltips // Update tooltips

View file

@ -1,7 +1,6 @@
#include <thread> #include <thread>
#include <chrono> #include <chrono>
#include "IUIScene_PauseMenu.h" #include "IUIScene_PauseMenu.h"
#include "Minecraft.Client/Common/src/UI/UIScene.h" #include "Minecraft.Client/Common/src/UI/UIScene.h"
#include "minecraft/client/Minecraft.h" #include "minecraft/client/Minecraft.h"

View file

@ -1,7 +1,6 @@
#include <thread> #include <thread>
#include <chrono> #include <chrono>
#include "Minecraft.Client/Common/src/UI/UI.h" #include "Minecraft.Client/Common/src/UI/UI.h"
#include "UIScene_LoadOrJoinMenu.h" #include "UIScene_LoadOrJoinMenu.h"

View file

@ -10,7 +10,6 @@
#include "minecraft/client/Minecraft.h" #include "minecraft/client/Minecraft.h"
#include "UIScene_MainMenu.h" #include "UIScene_MainMenu.h"
Random* UIScene_MainMenu::random = new Random(); Random* UIScene_MainMenu::random = new Random();
int UIScene_MainMenu::eNavigateWhenReady = -1; int UIScene_MainMenu::eNavigateWhenReady = -1;
@ -245,9 +244,9 @@ void UIScene_MainMenu::handlePress(F64 controlId, F64 childId) {
unsigned int uiIDA[2]; unsigned int uiIDA[2];
uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[0] = IDS_CONFIRM_CANCEL;
uiIDA[1] = IDS_CONFIRM_OK; uiIDA[1] = IDS_CONFIRM_OK;
ui.RequestErrorMessage( ui.RequestErrorMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA,
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, 2, XUSER_INDEX_ANY,
XUSER_INDEX_ANY, &UIScene_MainMenu::ExitGameReturned, this); &UIScene_MainMenu::ExitGameReturned, this);
} break; } break;
default: default:
@ -304,7 +303,6 @@ void UIScene_MainMenu::RunAction(int iPad) {
void UIScene_MainMenu::customDraw(IggyCustomDrawCallbackRegion* region) { void UIScene_MainMenu::customDraw(IggyCustomDrawCallbackRegion* region) {
if (std::char_traits<char16_t>::compare(region->name, u"Splash", 6) == 0) { if (std::char_traits<char16_t>::compare(region->name, u"Splash", 6) == 0) {
customDrawSplash(region); customDrawSplash(region);
} }
} }
@ -874,10 +872,10 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) {
// you can't see the store // you can't see the store
unsigned int uiIDA[1]; unsigned int uiIDA[1];
uiIDA[0] = IDS_CONFIRM_OK; uiIDA[0] = IDS_CONFIRM_OK;
ui.RequestErrorMessage( ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE,
IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, IDS_CONTENT_RESTRICTION, uiIDA, 1,
uiIDA, 1, ProfileManager.GetPrimaryPad(), nullptr, ProfileManager.GetPrimaryPad(),
this); nullptr, this);
#endif #endif
} else { } else {
ProfileManager.SetLockedProfile(iPad); ProfileManager.SetLockedProfile(iPad);
@ -897,8 +895,8 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) {
} else { } else {
unsigned int uiIDA[1]; unsigned int uiIDA[1];
uiIDA[0] = IDS_OK; uiIDA[0] = IDS_OK;
ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT,
IDS_PRO_NOTONLINE_TEXT, uiIDA, 1); uiIDA, 1);
} }
} }

View file

@ -42,7 +42,6 @@ void UIScene_TrialExitUpsell::handleInput(int iPad, int key, bool repeat,
if (ProfileManager.IsSignedIn(iPad)) { if (ProfileManager.IsSignedIn(iPad)) {
// CD - Added for audio // CD - Added for audio
ui.PlayUISFX(eSFX_Press); ui.PlayUISFX(eSFX_Press);
} }
break; break;
} }

View file

@ -5,8 +5,7 @@
#include "UIScene_LanguageSelector.h" #include "UIScene_LanguageSelector.h"
// strings for buttons in the list // strings for buttons in the list
const unsigned int UIScene_LanguageSelector::m_uiHTPButtonNameA[]= const unsigned int UIScene_LanguageSelector::m_uiHTPButtonNameA[] = {
{
IDS_LANG_SYSTEM, IDS_LANG_SYSTEM,
IDS_LANG_ENGLISH, IDS_LANG_ENGLISH,
IDS_LANG_GERMAN, IDS_LANG_GERMAN,

View file

@ -8,8 +8,7 @@
class UIScene_LanguageSelector : public UIScene { class UIScene_LanguageSelector : public UIScene {
public: public:
enum ELangButtons enum ELangButtons {
{
eLanguageSelector_LabelNone = -1, eLanguageSelector_LabelNone = -1,
eLanguageSelector_system, eLanguageSelector_system,
eLanguageSelector_EN_US, eLanguageSelector_EN_US,
@ -73,58 +72,28 @@ protected:
void handlePress(F64 controlId, F64 childId); void handlePress(F64 controlId, F64 childId);
}; };
const int uiLangMap[UIScene_LanguageSelector::eLanguageSelector_MAX] = const int uiLangMap[UIScene_LanguageSelector::eLanguageSelector_MAX] = {
{ MINECRAFT_LANGUAGE_DEFAULT, XC_LANGUAGE_ENGLISH, XC_LANGUAGE_GERMAN,
MINECRAFT_LANGUAGE_DEFAULT, XC_LANGUAGE_SPANISH, XC_LANGUAGE_SPANISH, XC_LANGUAGE_FRENCH,
XC_LANGUAGE_ENGLISH, XC_LANGUAGE_ITALIAN, XC_LANGUAGE_PORTUGUESE, XC_LANGUAGE_PORTUGUESE,
XC_LANGUAGE_GERMAN, XC_LANGUAGE_JAPANESE, XC_LANGUAGE_KOREAN, XC_LANGUAGE_TCHINESE,
XC_LANGUAGE_SPANISH, XC_LANGUAGE_SCHINESE, XC_LANGUAGE_DANISH, XC_LANGUAGE_FINISH,
XC_LANGUAGE_SPANISH, XC_LANGUAGE_DUTCH, XC_LANGUAGE_POLISH, XC_LANGUAGE_RUSSIAN,
XC_LANGUAGE_FRENCH, XC_LANGUAGE_SWEDISH, XC_LANGUAGE_BNORWEGIAN, XC_LANGUAGE_SLOVAK,
XC_LANGUAGE_ITALIAN, XC_LANGUAGE_CZECH, XC_LANGUAGE_GREEK, XC_LANGUAGE_TURKISH,
XC_LANGUAGE_PORTUGUESE,
XC_LANGUAGE_PORTUGUESE,
XC_LANGUAGE_JAPANESE,
XC_LANGUAGE_KOREAN,
XC_LANGUAGE_TCHINESE,
XC_LANGUAGE_SCHINESE,
XC_LANGUAGE_DANISH,
XC_LANGUAGE_FINISH,
XC_LANGUAGE_DUTCH,
XC_LANGUAGE_POLISH,
XC_LANGUAGE_RUSSIAN,
XC_LANGUAGE_SWEDISH,
XC_LANGUAGE_BNORWEGIAN,
XC_LANGUAGE_SLOVAK,
XC_LANGUAGE_CZECH,
XC_LANGUAGE_GREEK,
XC_LANGUAGE_TURKISH,
}; };
const int uiLocaleMap[UIScene_LanguageSelector::eLanguageSelector_MAX] = const int uiLocaleMap[UIScene_LanguageSelector::eLanguageSelector_MAX] = {
{ MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, XC_LOCALE_SPAIN,
MINECRAFT_LANGUAGE_DEFAULT, XC_LOCALE_LATIN_AMERICA, MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, XC_LOCALE_PORTUGAL,
XC_LOCALE_SPAIN, XC_LOCALE_BRAZIL, MINECRAFT_LANGUAGE_DEFAULT,
XC_LOCALE_LATIN_AMERICA, MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT,
XC_LOCALE_PORTUGAL, MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT,
XC_LOCALE_BRAZIL, MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
}; };

View file

@ -117,8 +117,7 @@ void UIScene_DeathMenu::handlePress(F64 controlId, F64 childId) {
ui.RequestAlertMessage( ui.RequestAlertMessage(
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2,
m_iPad, m_iPad, &IUIScene_PauseMenu::ExitGameDialogReturned,
&IUIScene_PauseMenu::ExitGameDialogReturned,
(void*)GetCallbackUniqueId()); (void*)GetCallbackUniqueId());
} }
} }

View file

@ -91,7 +91,8 @@ void UIScene_PauseMenu::tick() { UIScene::tick(); }
void UIScene_PauseMenu::updateTooltips() { void UIScene_PauseMenu::updateTooltips() {
// bool bUserisClientSide = ProfileManager.IsSignedInLive(m_iPad); // bool bUserisClientSide = ProfileManager.IsSignedInLive(m_iPad);
// bool bIsisPrimaryHost = // bool bIsisPrimaryHost =
// g_NetworkManager.IsHost() && (ProfileManager.GetPrimaryPad() == m_iPad); // g_NetworkManager.IsHost() && (ProfileManager.GetPrimaryPad() ==
// m_iPad);
int iY = -1; int iY = -1;
int iRB = -1; int iRB = -1;
@ -333,15 +334,13 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) {
IDS_EXIT_GAME, IDS_EXIT_GAME,
IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE,
uiIDA, 3, m_iPad, uiIDA, 3, m_iPad,
&UIScene_PauseMenu:: &UIScene_PauseMenu::ExitGameSaveDialogReturned,
ExitGameSaveDialogReturned,
(void*)GetCallbackUniqueId()); (void*)GetCallbackUniqueId());
} else { } else {
ui.RequestAlertMessage( ui.RequestAlertMessage(
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3,
3, m_iPad, m_iPad,
&UIScene_PauseMenu:: &UIScene_PauseMenu::ExitGameSaveDialogReturned,
ExitGameSaveDialogReturned,
(void*)GetCallbackUniqueId()); (void*)GetCallbackUniqueId());
} }
} else { } else {
@ -350,8 +349,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) {
ui.RequestAlertMessage( ui.RequestAlertMessage(
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2,
m_iPad, m_iPad, &IUIScene_PauseMenu::ExitGameDialogReturned,
&IUIScene_PauseMenu::ExitGameDialogReturned,
(void*)GetCallbackUniqueId()); (void*)GetCallbackUniqueId());
} }
} }

View file

@ -5,7 +5,6 @@
#include "console_helpers/StringHelpers.h" #include "console_helpers/StringHelpers.h"
#define KEYBOARD_DONE_TIMER_ID 0 #define KEYBOARD_DONE_TIMER_ID 0
#define KEYBOARD_DONE_TIMER_TIME 100 #define KEYBOARD_DONE_TIMER_TIME 100

View file

@ -316,15 +316,18 @@ UIController::EFont UIController::getFontForLanguage(int language) {
UITTFFont* UIController::createFont(EFont fontLanguage) { UITTFFont* UIController::createFont(EFont fontLanguage) {
switch (fontLanguage) { switch (fontLanguage) {
case eFont_Japanese: case eFont_Japanese:
return new UITTFFont("Mojangles_TTF_jaJP", return new UITTFFont(
"Mojangles_TTF_jaJP",
"Minecraft.Client/Common/Media/font/JPN/DFGMaruGothic-Md.ttf", "Minecraft.Client/Common/Media/font/JPN/DFGMaruGothic-Md.ttf",
0x2022); // JPN 0x2022); // JPN
case eFont_TradChinese: case eFont_TradChinese:
return new UITTFFont("Mojangles_TTF_cnTD", return new UITTFFont(
"Mojangles_TTF_cnTD",
"Minecraft.Client/Common/Media/font/CHT/DFHeiMedium-B5.ttf", "Minecraft.Client/Common/Media/font/CHT/DFHeiMedium-B5.ttf",
0x2022); // CHT 0x2022); // CHT
case eFont_Korean: case eFont_Korean:
return new UITTFFont("Mojangles_TTF_koKR", return new UITTFFont(
"Mojangles_TTF_koKR",
"Minecraft.Client/Common/Media/font/KOR/BOKMSD.ttf", "Minecraft.Client/Common/Media/font/KOR/BOKMSD.ttf",
0x2022); // KOR 0x2022); // KOR
// 4J-JEV, Cyrillic characters have been added to this font now, // 4J-JEV, Cyrillic characters have been added to this font now,
@ -800,16 +803,12 @@ void UIController::renderScenes() {
!m_groups[eUIGroup_Fullscreen]->hidesLowerScenes()) { !m_groups[eUIGroup_Fullscreen]->hidesLowerScenes()) {
for (int i = eUIGroup_Player1; i < eUIGroup_COUNT; ++i) { for (int i = eUIGroup_Player1; i < eUIGroup_COUNT; ++i) {
m_groups[i]->render(); m_groups[i]->render();
} }
} }
// Always render the fullscreen group // Always render the fullscreen group
m_groups[eUIGroup_Fullscreen]->render(); m_groups[eUIGroup_Fullscreen]->render();
#if defined(ENABLE_IGGY_PERFMON) #if defined(ENABLE_IGGY_PERFMON)
if (m_iggyPerfmonEnabled) { if (m_iggyPerfmonEnabled) {
IggyPerfmonPad pm_pad; IggyPerfmonPad pm_pad;
@ -962,7 +961,6 @@ void UIController::setupCustomDrawGameState() {
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
glDepthMask(true); glDepthMask(true);
} }
void UIController::setupCustomDrawMatrices(UIScene* scene, void UIController::setupCustomDrawMatrices(UIScene* scene,
@ -1142,7 +1140,8 @@ void UIController::registerSubstitutionTexture(const std::wstring& textureName,
// Remove it if it already exists // Remove it if it already exists
unregisterSubstitutionTexture(textureName, false); unregisterSubstitutionTexture(textureName, false);
m_substitutionTextures[textureName] = std::vector<uint8_t>(pbData, pbData + dwLength); m_substitutionTextures[textureName] =
std::vector<uint8_t>(pbData, pbData + dwLength);
} }
void UIController::unregisterSubstitutionTexture( void UIController::unregisterSubstitutionTexture(

View file

@ -147,7 +147,8 @@ private:
static std::uint32_t m_dwTrialTimerLimitSecs; static std::uint32_t m_dwTrialTimerLimitSecs;
std::unordered_map<std::wstring, std::vector<uint8_t>> m_substitutionTextures; std::unordered_map<std::wstring, std::vector<uint8_t>>
m_substitutionTextures;
typedef struct _CachedMovieData { typedef struct _CachedMovieData {
std::vector<uint8_t> m_ba; std::vector<uint8_t> m_ba;

View file

@ -145,7 +145,6 @@ void UILayer::render(S32 width, S32 height, C4JRender::eViewportType viewport) {
if (itRef != m_componentRefCount.end() && itRef->second.second) { if (itRef != m_componentRefCount.end() && itRef->second.second) {
if ((*it)->isVisible()) { if ((*it)->isVisible()) {
(*it)->render(width, height, viewport); (*it)->render(width, height, viewport);
} }
} }
} }
@ -162,7 +161,6 @@ void UILayer::render(S32 width, S32 height, C4JRender::eViewportType viewport) {
m_sceneStack[lowestRenderable]->getSceneType() == m_sceneStack[lowestRenderable]->getSceneType() ==
eUIScene_Timer)) { eUIScene_Timer)) {
m_sceneStack[lowestRenderable]->render(width, height, viewport); m_sceneStack[lowestRenderable]->render(width, height, viewport);
} }
} }
} }

View file

@ -564,7 +564,6 @@ void UIScene::customDrawSlotControl(IggyCustomDrawCallbackRegion* region,
useCommandBuffers); useCommandBuffers);
delete customDrawRegion; delete customDrawRegion;
// Draw all the cached slots // Draw all the cached slots
for (auto it = m_cachedSlotDraw.begin(); for (auto it = m_cachedSlotDraw.begin();
it != m_cachedSlotDraw.end(); ++it) { it != m_cachedSlotDraw.end(); ++it) {
@ -598,7 +597,6 @@ void UIScene::customDrawSlotControl(IggyCustomDrawCallbackRegion* region,
drawData->customDrawRegion = ui.calculateCustomDraw(region); drawData->customDrawRegion = ui.calculateCustomDraw(region);
m_cachedSlotDraw.push_back(drawData); m_cachedSlotDraw.push_back(drawData);
} }
} else { } else {
// Setup GDraw, normal game render states and matrices // Setup GDraw, normal game render states and matrices
@ -681,7 +679,6 @@ void UIScene::_customDrawSlotControl(CustomDrawData* region, int iPad,
pMinecraft->font, pMinecraft->textures, item, x, y, scaleX, scaleY, pMinecraft->font, pMinecraft->textures, item, x, y, scaleX, scaleY,
fAlpha, isFoil, false, !usingCommandBuffer); fAlpha, isFoil, false, !usingCommandBuffer);
if (pop > 0) { if (pop > 0) {
glPopMatrix(); glPopMatrix();
} }

View file

@ -21,8 +21,7 @@ CConsoleMinecraftApp app;
CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() {} CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() {}
void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId) { void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId) {}
}
void CConsoleMinecraftApp::StoreLaunchData() {} void CConsoleMinecraftApp::StoreLaunchData() {}
void CConsoleMinecraftApp::ExitGame() { void CConsoleMinecraftApp::ExitGame() {

View file

@ -771,15 +771,12 @@ int main(int argc, const char* argv[]) {
RenderManager.Tick(); RenderManager.Tick();
// Tick the social networking manager. // Tick the social networking manager.
// CSocialManager::Instance()->Tick(); // CSocialManager::Instance()->Tick();
// Tick sentient. // Tick sentient.
// SentientManager.Tick(); // SentientManager.Tick();
g_NetworkManager.DoWork(); g_NetworkManager.DoWork();
// Render game graphics. // Render game graphics.
@ -856,10 +853,8 @@ int main(int argc, const char* argv[]) {
app.uiGameDefinedDataChangedBitmask = 0; app.uiGameDefinedDataChangedBitmask = 0;
} }
g_NetworkManager.DoWork(); g_NetworkManager.DoWork();
// Any threading type things to deal with from the xui side? // Any threading type things to deal with from the xui side?
app.HandleXuiActions(); app.HandleXuiActions();

View file

@ -8,7 +8,6 @@
#include "Minecraft.Client/Linux/Linux_App.h" #include "Minecraft.Client/Linux/Linux_App.h"
#include "Minecraft.Client/Linux/Iggy/gdraw/gdraw.h" #include "Minecraft.Client/Linux/Iggy/gdraw/gdraw.h"
ConsoleUIController ui; ConsoleUIController ui;
static void restoreFixedFunctionStateAfterIggy() { static void restoreFixedFunctionStateAfterIggy() {

View file

@ -1,8 +1,6 @@
// Minecraft.cpp : Defines the entry point for the application. // Minecraft.cpp : Defines the entry point for the application.
// //
#include <assert.h> #include <assert.h>
#include <mutex> #include <mutex>
#include "minecraft/server/MinecraftServer.h" #include "minecraft/server/MinecraftServer.h"
@ -797,18 +795,14 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
RenderManager.Tick(); RenderManager.Tick();
// Tick the social networking manager. // Tick the social networking manager.
// CSocialManager::Instance()->Tick(); // CSocialManager::Instance()->Tick();
// Tick sentient. // Tick sentient.
// SentientManager.Tick(); // SentientManager.Tick();
// g_NetworkManager.DoWork(); // g_NetworkManager.DoWork();
// LeaderboardManager::Instance()->Tick(); // LeaderboardManager::Instance()->Tick();
// Render game graphics. // Render game graphics.
if (app.GetGameStarted()) { if (app.GetGameStarted()) {

View file

@ -97,11 +97,9 @@ void ConsoleUIController::render() {
void ConsoleUIController::beginIggyCustomDraw4J( void ConsoleUIController::beginIggyCustomDraw4J(
IggyCustomDrawCallbackRegion* region, CustomDrawData* customDrawRegion) { IggyCustomDrawCallbackRegion* region, CustomDrawData* customDrawRegion) {
// get the correct object-to-world matrix from GDraw, and set the render // get the correct object-to-world matrix from GDraw, and set the render
// state to a normal state // state to a normal state
gdraw_D3D11_BeginCustomDraw_4J(region, customDrawRegion->mat); gdraw_D3D11_BeginCustomDraw_4J(region, customDrawRegion->mat);
} }
CustomDrawData* ConsoleUIController::setupCustomDraw( CustomDrawData* ConsoleUIController::setupCustomDraw(
@ -138,7 +136,6 @@ void ConsoleUIController::endCustomDraw(IggyCustomDrawCallbackRegion* region) {
endCustomDrawGameStateAndMatrices(); endCustomDrawGameStateAndMatrices();
gdraw_D3D11_EndCustomDraw(region); gdraw_D3D11_EndCustomDraw(region);
} }
void ConsoleUIController::setTileOrigin(S32 xPos, S32 yPos) { void ConsoleUIController::setTileOrigin(S32 xPos, S32 yPos) {

View file

@ -26,8 +26,9 @@ public:
int getWidth(); int getWidth();
int getHeight(); int getHeight();
void getRGB(int startX, int startY, int w, int h, std::vector<int>& out, int offset, void getRGB(int startX, int startY, int w, int h, std::vector<int>& out,
int scansize, int level = 0); // 4J Added level param int offset, int scansize,
int level = 0); // 4J Added level param
int* getData(); // 4J added int* getData(); // 4J added
int* getData(int level); // 4J added int* getData(int level); // 4J added
Graphics* getGraphics(); Graphics* getGraphics();

View file

@ -68,10 +68,7 @@ public:
typedef void* XMEMDECOMPRESSION_CONTEXT; typedef void* XMEMDECOMPRESSION_CONTEXT;
typedef void* XMEMCOMPRESSION_CONTEXT; typedef void* XMEMCOMPRESSION_CONTEXT;
enum XMEMCODEC_TYPE { enum XMEMCODEC_TYPE { XMEMCODEC_DEFAULT = 0, XMEMCODEC_LZX = 1 };
XMEMCODEC_DEFAULT = 0,
XMEMCODEC_LZX = 1
};
int32_t XMemDecompress(XMEMDECOMPRESSION_CONTEXT Context, void* pDestination, int32_t XMemDecompress(XMEMDECOMPRESSION_CONTEXT Context, void* pDestination,
size_t* pDestSize, void* pSource, size_t SrcSize); size_t* pDestSize, void* pSource, size_t SrcSize);

View file

@ -186,8 +186,9 @@ int BufferedImage::getWidth() { return width; }
int BufferedImage::getHeight() { return height; } int BufferedImage::getHeight() { return height; }
void BufferedImage::getRGB(int startX, int startY, int w, int h, std::vector<int>& out, void BufferedImage::getRGB(int startX, int startY, int w, int h,
int offset, int scansize, int level) { std::vector<int>& out, int offset, int scansize,
int level) {
int ww = width >> level; int ww = width >> level;
for (int y = 0; y < h; y++) { for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) { for (int x = 0; x < w; x++) {
@ -225,13 +226,12 @@ BufferedImage* BufferedImage::getSubimage(int x, int y, int w, int h) {
BufferedImage* img = new BufferedImage(w, h, 0); BufferedImage* img = new BufferedImage(w, h, 0);
// 4jcraft: Copy pixel data directly into img->data[0]. // 4jcraft: Copy pixel data directly into img->data[0].
// The old arrayWithLength.h (custom vector impl) was a non-owning wrapper, std::vector copies // The old arrayWithLength.h (custom vector impl) was a non-owning wrapper,
// so we write to the raw array directly instead. // std::vector copies so we write to the raw array directly instead.
int srcW = width; int srcW = width;
for (int row = 0; row < h; row++) { for (int row = 0; row < h; row++) {
for (int col = 0; col < w; col++) { for (int col = 0; col < w; col++) {
img->data[0][row * w + col] = img->data[0][row * w + col] = data[0][(y + row) * srcW + (x + col)];
data[0][(y + row) * srcW + (x + col)];
} }
} }

View file

@ -25,14 +25,14 @@ inline std::int64_t QueryPerformanceCounter() {
// Ticks per second for the high-resolution counter. // Ticks per second for the high-resolution counter.
inline std::int64_t QueryPerformanceFrequency() { inline std::int64_t QueryPerformanceFrequency() {
return static_cast<std::int64_t>(std::chrono::steady_clock::period::den) return static_cast<std::int64_t>(std::chrono::steady_clock::period::den) /
/ static_cast<std::int64_t>(std::chrono::steady_clock::period::num); static_cast<std::int64_t>(std::chrono::steady_clock::period::num);
} }
// Elapsed seconds between two counter values. // Elapsed seconds between two counter values.
inline double ElapsedSeconds(std::int64_t start, std::int64_t end) { inline double ElapsedSeconds(std::int64_t start, std::int64_t end) {
return static_cast<double>(end - start) return static_cast<double>(end - start) /
/ static_cast<double>(QueryPerformanceFrequency()); static_cast<double>(QueryPerformanceFrequency());
} }
} // namespace PlatformTime } // namespace PlatformTime

View file

@ -90,7 +90,6 @@ int32_t Compression::CompressLZXRLE(void* pDestination, unsigned int* pDestSize,
} while (pucIn != pucEnd); } while (pucIn != pucEnd);
unsigned int rleSize = (unsigned int)(pucOut - rleCompressBuf); unsigned int rleSize = (unsigned int)(pucOut - rleCompressBuf);
Compress(pDestination, pDestSize, rleCompressBuf, rleSize); Compress(pDestination, pDestSize, rleCompressBuf, rleSize);
// printf("Compressed from %d to %d to %d\n",SrcSize,rleSize,*pDestSize); // printf("Compressed from %d to %d to %d\n",SrcSize,rleSize,*pDestSize);
@ -139,7 +138,6 @@ int32_t Compression::CompressRLE(void* pDestination, unsigned int* pDestSize,
} }
} while (pucIn != pucEnd); } while (pucIn != pucEnd);
rleSize = (unsigned int)(pucOut - rleCompressBuf); rleSize = (unsigned int)(pucOut - rleCompressBuf);
} }
// Return // Return

View file

@ -8,32 +8,32 @@ class Biome;
class Arrays { class Arrays {
public: public:
static void fill(std::vector<double>& arr, unsigned int from, unsigned int to, static void fill(std::vector<double>& arr, unsigned int from,
double value) { unsigned int to, double value) {
assert(from >= 0); assert(from >= 0);
assert(from <= to); assert(from <= to);
assert(to <= arr.size()); assert(to <= arr.size());
std::fill(arr.data() + from, arr.data() + to, value); std::fill(arr.data() + from, arr.data() + to, value);
} }
static void fill(std::vector<float>& arr, unsigned int from, unsigned int to, static void fill(std::vector<float>& arr, unsigned int from,
float value) { unsigned int to, float value) {
assert(from >= 0); assert(from >= 0);
assert(from <= to); assert(from <= to);
assert(to <= arr.size()); assert(to <= arr.size());
std::fill(arr.data() + from, arr.data() + to, value); std::fill(arr.data() + from, arr.data() + to, value);
} }
static void fill(std::vector<Biome*>& arr, unsigned int from, unsigned int to, static void fill(std::vector<Biome*>& arr, unsigned int from,
Biome* value) { unsigned int to, Biome* value) {
assert(from >= 0); assert(from >= 0);
assert(from <= to); assert(from <= to);
assert(to <= arr.size()); assert(to <= arr.size());
std::fill(arr.data() + from, arr.data() + to, value); std::fill(arr.data() + from, arr.data() + to, value);
} }
static void fill(std::vector<uint8_t>& arr, unsigned int from, unsigned int to, static void fill(std::vector<uint8_t>& arr, unsigned int from,
uint8_t value) { unsigned int to, uint8_t value) {
assert(from >= 0); assert(from >= 0);
assert(from <= to); assert(from <= to);
assert(to <= arr.size()); assert(to <= arr.size());

View file

@ -21,7 +21,8 @@ public:
virtual void flush(); virtual void flush();
virtual void close(); virtual void close();
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void write(const std::vector<uint8_t>& b); virtual void write(const std::vector<uint8_t>& b);
virtual void write(unsigned int b); virtual void write(unsigned int b);
}; };

View file

@ -8,8 +8,8 @@
class ByteArrayInputStream : public InputStream { class ByteArrayInputStream : public InputStream {
protected: protected:
std::vector<uint8_t> buf; // An array of bytes that was provided by the creator of the std::vector<uint8_t> buf; // An array of bytes that was provided by the
// stream. // creator of the stream.
unsigned int count; // The index one greater than the last valid character unsigned int count; // The index one greater than the last valid character
// in the input stream buffer. // in the input stream buffer.
unsigned int mark; // The currently marked position in the stream. unsigned int mark; // The currently marked position in the stream.
@ -23,7 +23,8 @@ public:
virtual ~ByteArrayInputStream(); virtual ~ByteArrayInputStream();
virtual int read(); virtual int read();
virtual int read(std::vector<uint8_t>& b); virtual int read(std::vector<uint8_t>& b);
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual int64_t skip(int64_t n); virtual int64_t skip(int64_t n);

View file

@ -6,8 +6,8 @@
#include <cstdint> #include <cstdint>
class ByteArrayOutputStream : public OutputStream { class ByteArrayOutputStream : public OutputStream {
// Note - when actually implementing, std::vector<uint8_t> will need to grow as data is // Note - when actually implementing, std::vector<uint8_t> will need to grow
// written // as data is written
public: public:
std::vector<uint8_t> buf; // The buffer where data is stored. std::vector<uint8_t> buf; // The buffer where data is stored.
@ -22,7 +22,8 @@ public:
virtual void flush() {} virtual void flush() {}
virtual void write(unsigned int b); virtual void write(unsigned int b);
virtual void write(const std::vector<uint8_t>& b); virtual void write(const std::vector<uint8_t>& b);
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual std::vector<uint8_t> toByteArray(); virtual std::vector<uint8_t> toByteArray();

View file

@ -8,7 +8,8 @@ class DataInput {
public: public:
virtual int read() = 0; virtual int read() = 0;
virtual int read(std::vector<uint8_t>& b) = 0; virtual int read(std::vector<uint8_t>& b) = 0;
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length) = 0; virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) = 0;
virtual bool readBoolean() = 0; virtual bool readBoolean() = 0;
virtual uint8_t readByte() = 0; virtual uint8_t readByte() = 0;
virtual unsigned char readUnsignedByte() = 0; virtual unsigned char readUnsignedByte() = 0;

View file

@ -16,7 +16,8 @@ public:
DataInputStream(InputStream* in); DataInputStream(InputStream* in);
virtual int read(); virtual int read();
virtual int read(std::vector<uint8_t>& b); virtual int read(std::vector<uint8_t>& b);
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual bool readBoolean(); virtual bool readBoolean();
virtual uint8_t readByte(); virtual uint8_t readByte();

View file

@ -23,7 +23,8 @@ public:
virtual void write(unsigned int b); virtual void write(unsigned int b);
virtual void write(const std::vector<uint8_t>& b); virtual void write(const std::vector<uint8_t>& b);
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual void writeByte(uint8_t a); virtual void writeByte(uint8_t a);
virtual void writeDouble(double a); virtual void writeDouble(double a);

View file

@ -14,7 +14,8 @@ public:
virtual ~FileInputStream(); virtual ~FileInputStream();
virtual int read(); virtual int read();
virtual int read(std::vector<uint8_t>& b); virtual int read(std::vector<uint8_t>& b);
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual int64_t skip(int64_t n); virtual int64_t skip(int64_t n);

View file

@ -13,7 +13,8 @@ public:
virtual ~FileOutputStream(); virtual ~FileOutputStream();
virtual void write(unsigned int b); virtual void write(unsigned int b);
virtual void write(const std::vector<uint8_t>& b); virtual void write(const std::vector<uint8_t>& b);
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual void flush(); virtual void flush();

View file

@ -14,7 +14,8 @@ public:
GZIPInputStream(InputStream* out) : stream(out) {}; GZIPInputStream(InputStream* out) : stream(out) {};
virtual int read() { return stream->read(); }; virtual int read() { return stream->read(); };
virtual int read(std::vector<uint8_t>& b) { return stream->read(b); }; virtual int read(std::vector<uint8_t>& b) { return stream->read(b); };
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length) { virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) {
return stream->read(b, offset, length); return stream->read(b, offset, length);
}; };
virtual void close() { return stream->close(); }; virtual void close() { return stream->close(); };

View file

@ -12,7 +12,8 @@ public:
GZIPOutputStream(OutputStream* out) : stream(out) {}; GZIPOutputStream(OutputStream* out) : stream(out) {};
virtual void write(unsigned int b) { stream->write(b); }; virtual void write(unsigned int b) { stream->write(b); };
virtual void write(const std::vector<uint8_t>& b) { stream->write(b); }; virtual void write(const std::vector<uint8_t>& b) { stream->write(b); };
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, unsigned int length) { virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) {
stream->write(b, offset, length); stream->write(b, offset, length);
}; };
virtual void close() { stream->close(); }; virtual void close() { stream->close(); };

View file

@ -12,7 +12,8 @@ public:
virtual int read() = 0; virtual int read() = 0;
virtual int read(std::vector<uint8_t>& b) = 0; virtual int read(std::vector<uint8_t>& b) = 0;
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length) = 0; virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) = 0;
virtual void close() = 0; virtual void close() = 0;
virtual int64_t skip(int64_t n) = 0; virtual int64_t skip(int64_t n) = 0;

View file

@ -393,7 +393,9 @@ ByteBuffer* ByteBuffer::put(std::vector<uint8_t>& inputArray) {
return this; return this;
} }
std::vector<uint8_t> ByteBuffer::array() { return std::vector<uint8_t>(buffer, buffer + m_capacity); } std::vector<uint8_t> ByteBuffer::array() {
return std::vector<uint8_t>(buffer, buffer + m_capacity);
}
// Creates a view of this byte buffer as an int buffer. // Creates a view of this byte buffer as an int buffer.
// The content of the new buffer will start at this buffer's current position. // The content of the new buffer will start at this buffer's current position.

View file

@ -64,8 +64,8 @@ void BufferedOutputStream::close() {
// b - the data. // b - the data.
// off - the start offset in the data. // off - the start offset in the data.
// len - the number of bytes to write. // len - the number of bytes to write.
void BufferedOutputStream::write(const std::vector<uint8_t>& b, unsigned int offset, void BufferedOutputStream::write(const std::vector<uint8_t>& b,
unsigned int length) { unsigned int offset, unsigned int length) {
// Over the length of what we can store in our buffer - just flush the // Over the length of what we can store in our buffer - just flush the
// buffer and output directly // buffer and output directly
if (length >= buf.size()) { if (length >= buf.size()) {
@ -84,7 +84,9 @@ void BufferedOutputStream::write(const std::vector<uint8_t>& b, unsigned int off
// //
// Note that this method does not call the one-argument write method of its // Note that this method does not call the one-argument write method of its
// underlying stream with the single argument b. // underlying stream with the single argument b.
void BufferedOutputStream::write(const std::vector<uint8_t>& b) { write(b, 0, b.size()); } void BufferedOutputStream::write(const std::vector<uint8_t>& b) {
write(b, 0, b.size());
}
// Writes the specified byte to this buffered output stream. // Writes the specified byte to this buffered output stream.
// Overrides: // Overrides:

View file

@ -12,9 +12,12 @@
#include "java/InputOutputStream/ByteArrayInputStream.h" #include "java/InputOutputStream/ByteArrayInputStream.h"
ByteArrayInputStream::ByteArrayInputStream(std::vector<uint8_t>& buf, unsigned int offset, ByteArrayInputStream::ByteArrayInputStream(std::vector<uint8_t>& buf,
unsigned int offset,
unsigned int length) unsigned int length)
: pos(offset), count(std::min(offset + length, (unsigned int)buf.size())), mark(offset) { : pos(offset),
count(std::min(offset + length, (unsigned int)buf.size())),
mark(offset) {
this->buf = buf; this->buf = buf;
} }
@ -59,7 +62,9 @@ int ByteArrayInputStream::read() {
// Returns: // Returns:
// the total number of bytes read into the buffer, or -1 is there is no more // the total number of bytes read into the buffer, or -1 is there is no more
// data because the end of the stream has been reached. // data because the end of the stream has been reached.
int ByteArrayInputStream::read(std::vector<uint8_t>& b) { return read(b, 0, b.size()); } int ByteArrayInputStream::read(std::vector<uint8_t>& b) {
return read(b, 0, b.size());
}
// Reads up to len bytes of data into an array of bytes from this input stream. // Reads up to len bytes of data into an array of bytes from this input stream.
// If pos equals count, then -1 is returned to indicate end of file. Otherwise, // If pos equals count, then -1 is returned to indicate end of file. Otherwise,
@ -110,5 +115,4 @@ int64_t ByteArrayInputStream::skip(int64_t n) {
return k; return k;
} }
ByteArrayInputStream::~ByteArrayInputStream() { ByteArrayInputStream::~ByteArrayInputStream() {}
}

View file

@ -18,8 +18,7 @@ ByteArrayOutputStream::ByteArrayOutputStream(unsigned int size) {
buf = std::vector<uint8_t>(size); buf = std::vector<uint8_t>(size);
} }
ByteArrayOutputStream::~ByteArrayOutputStream() { ByteArrayOutputStream::~ByteArrayOutputStream() {}
}
// Writes the specified byte to this byte array output stream. // Writes the specified byte to this byte array output stream.
// Parameters: // Parameters:
@ -35,18 +34,21 @@ void ByteArrayOutputStream::write(unsigned int b) {
// Writes b.size() bytes from the specified byte array to this output stream. // Writes b.size() bytes from the specified byte array to this output stream.
// The general contract for write(b) is that it should have exactly the same // The general contract for write(b) is that it should have exactly the same
// effect as the call write(b, 0, b.size()). // effect as the call write(b, 0, b.size()).
void ByteArrayOutputStream::write(const std::vector<uint8_t>& b) { write(b, 0, b.size()); } void ByteArrayOutputStream::write(const std::vector<uint8_t>& b) {
write(b, 0, b.size());
}
// Writes len bytes from the specified byte array starting at offset off to this // Writes len bytes from the specified byte array starting at offset off to this
// byte array output stream. Parameters: b - the data. off - the start offset in // byte array output stream. Parameters: b - the data. off - the start offset in
// the data. len - the number of bytes to write. // the data. len - the number of bytes to write.
void ByteArrayOutputStream::write(const std::vector<uint8_t>& b, unsigned int offset, void ByteArrayOutputStream::write(const std::vector<uint8_t>& b,
unsigned int length) { unsigned int offset, unsigned int length) {
assert(b.size() >= offset + length); assert(b.size() >= offset + length);
// If we will fill the buffer we need to make it bigger // If we will fill the buffer we need to make it bigger
if (count + length >= buf.size()) if (count + length >= buf.size())
buf.resize(std::max(count + length + 1, (unsigned int)(buf.size() * 2))); buf.resize(
std::max(count + length + 1, (unsigned int)(buf.size() * 2)));
std::memcpy(&buf[count], &b[offset], length); std::memcpy(&buf[count], &b[offset], length);
// std::copy( b->data+offset, b->data+offset+length, buf->data + count ); // // std::copy( b->data+offset, b->data+offset+length, buf->data + count ); //

View file

@ -56,7 +56,8 @@ int DataInputStream::read() {
int DataInputStream::read(std::vector<uint8_t>& b) { int DataInputStream::read(std::vector<uint8_t>& b) {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataInputStream::read(std::vector<uint8_t>) called but underlying stream is " "DataInputStream::read(std::vector<uint8_t>) called but "
"underlying stream is "
"nullptr\n"); "nullptr\n");
return -1; return -1;
} }
@ -96,7 +97,8 @@ int DataInputStream::read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) { unsigned int length) {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataInputStream::read(std::vector<uint8_t>,offset,length) called but " "DataInputStream::read(std::vector<uint8_t>,offset,length) "
"called but "
"underlying stream is nullptr\n"); "underlying stream is nullptr\n");
return -1; return -1;
} }
@ -134,7 +136,8 @@ bool DataInputStream::readBoolean() {
// the 8-bit value read. // the 8-bit value read.
uint8_t DataInputStream::readByte() { uint8_t DataInputStream::readByte() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(
stderr,
"DataInputStream::readByte() but underlying stream is nullptr\n"); "DataInputStream::readByte() but underlying stream is nullptr\n");
return 0; return 0;
} }
@ -159,7 +162,8 @@ unsigned char DataInputStream::readUnsignedByte() {
// interface DataOutput. Returns: the char value read. // interface DataOutput. Returns: the char value read.
wchar_t DataInputStream::readChar() { wchar_t DataInputStream::readChar() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(
stderr,
"DataInputStream::readChar() but underlying stream is nullptr\n"); "DataInputStream::readChar() but underlying stream is nullptr\n");
return 0; return 0;
} }
@ -190,7 +194,8 @@ bool DataInputStream::readFully(std::vector<uint8_t>& b) {
// InputStreams // InputStreams
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataInputStream::readFully(std::vector<uint8_t>) but underlying stream is " "DataInputStream::readFully(std::vector<uint8_t>) but "
"underlying stream is "
"nullptr\n"); "nullptr\n");
return false; return false;
} }
@ -212,7 +217,8 @@ bool DataInputStream::readFully(std::vector<char>& b) {
// InputStreams // InputStreams
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataInputStream::readFully(std::vector<char>) but underlying stream is " "DataInputStream::readFully(std::vector<char>) but underlying "
"stream is "
"nullptr\n"); "nullptr\n");
return false; return false;
} }
@ -260,7 +266,8 @@ float DataInputStream::readFloat() {
// interface DataOutput. Returns: the int value read. // interface DataOutput. Returns: the int value read.
int DataInputStream::readInt() { int DataInputStream::readInt() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(
stderr,
"DataInputStream::readInt() but underlying stream is nullptr\n"); "DataInputStream::readInt() but underlying stream is nullptr\n");
return 0; return 0;
} }
@ -292,7 +299,8 @@ int DataInputStream::readInt() {
// the long value read. // the long value read.
int64_t DataInputStream::readLong() { int64_t DataInputStream::readLong() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(
stderr,
"DataInputStream::readLong() but underlying stream is nullptr\n"); "DataInputStream::readLong() but underlying stream is nullptr\n");
return 0; return 0;
} }
@ -321,7 +329,8 @@ int64_t DataInputStream::readLong() {
// method of interface DataOutput. Returns: the 16-bit value read. // method of interface DataOutput. Returns: the 16-bit value read.
short DataInputStream::readShort() { short DataInputStream::readShort() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(
stderr,
"DataInputStream::readShort() but underlying stream is nullptr\n"); "DataInputStream::readShort() but underlying stream is nullptr\n");
return 0; return 0;
} }
@ -391,7 +400,8 @@ unsigned short DataInputStream::readUnsignedShort() {
std::wstring DataInputStream::readUTF() { std::wstring DataInputStream::readUTF() {
std::wstring outputString; std::wstring outputString;
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(
stderr,
"DataInputStream::readUTF() but underlying stream is nullptr\n"); "DataInputStream::readUTF() but underlying stream is nullptr\n");
return outputString; return outputString;
} }

View file

@ -47,7 +47,9 @@ void DataOutputStream::flush() {
// Writes b.size() bytes from the specified byte array to this output stream. // Writes b.size() bytes from the specified byte array to this output stream.
// The general contract for write(b) is that it should have exactly the same // The general contract for write(b) is that it should have exactly the same
// effect as the call write(b, 0, b.size()). Parameters: b - the data. // effect as the call write(b, 0, b.size()). Parameters: b - the data.
void DataOutputStream::write(const std::vector<uint8_t>& b) { write(b, 0, b.size()); } void DataOutputStream::write(const std::vector<uint8_t>& b) {
write(b, 0, b.size());
}
// Writes len bytes from the specified byte array starting at offset off to the // Writes len bytes from the specified byte array starting at offset off to the
// underlying output stream. If no exception is thrown, the counter written is // underlying output stream. If no exception is thrown, the counter written is
@ -57,7 +59,8 @@ void DataOutputStream::write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) { unsigned int length) {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataOutputStream::write(std::vector<uint8_t>,...) called but underlying " "DataOutputStream::write(std::vector<uint8_t>,...) called but "
"underlying "
"stream is nullptr\n"); "stream is nullptr\n");
return; return;
} }
@ -154,7 +157,8 @@ void DataOutputStream::writeShort(short a) {
void DataOutputStream::writeUnsignedShort(unsigned short a) { void DataOutputStream::writeUnsignedShort(unsigned short a) {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(
stderr,
"DataOutputStream::writeUnsignedShort() but underlying stream is " "DataOutputStream::writeUnsignedShort() but underlying stream is "
"nullptr\n"); "nullptr\n");
return; return;
@ -258,4 +262,6 @@ void DataOutputStream::writeUTF(const std::wstring& str) {
} }
// 4J Added // 4J Added
void DataOutputStream::writePlayerUID(unsigned long long player) { writeLong(player); } void DataOutputStream::writePlayerUID(unsigned long long player) {
writeLong(player);
}

View file

@ -1017,8 +1017,7 @@ void Minecraft::run_middle() {
// } // }
// 4J-PB - AUTOSAVE TIMER - if the player is the host // 4J-PB - AUTOSAVE TIMER - if the player is the host
if (level != nullptr && if (level != nullptr && g_NetworkManager.IsHost()) {
g_NetworkManager.IsHost()) {
/*if(!bAutosaveTimerSet) /*if(!bAutosaveTimerSet)
{ {
// set the timer // set the timer
@ -1086,8 +1085,10 @@ void Minecraft::run_middle() {
#if !defined(_CONTENT_PACKAGE) #if !defined(_CONTENT_PACKAGE)
{ {
// print the time // print the time
auto now_tp = std::chrono::system_clock::now(); auto now_tp = std::chrono::
std::time_t now_tt = std::chrono::system_clock::to_time_t(now_tp); system_clock::now();
std::time_t now_tt = std::chrono::
system_clock::to_time_t(now_tp);
std::tm utcTime{}; std::tm utcTime{};
#if defined(_WIN32) #if defined(_WIN32)
gmtime_s(&utcTime, &now_tt); gmtime_s(&utcTime, &now_tt);
@ -1580,13 +1581,9 @@ void Minecraft::run_middle() {
soundEngine->tick((std::shared_ptr<Mob>*)localplayers, soundEngine->tick((std::shared_ptr<Mob>*)localplayers,
timer->a); timer->a);
// if (level != nullptr) level->updateLights(); // if (level != nullptr) level->updateLights();
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
// if (!Keyboard::isKeyDown(Keyboard.KEY_F7)) // if (!Keyboard::isKeyDown(Keyboard.KEY_F7))
// Display.update(); // 4J - removed // Display.update(); // 4J - removed
@ -1607,7 +1604,6 @@ void Minecraft::run_middle() {
gameRenderer->render(timer->a, bFirst); gameRenderer->render(timer->a, bFirst);
bFirst = false; bFirst = false;
if (i == iPrimaryPad) { if (i == iPrimaryPad) {
// check to see if we need to capture a // check to see if we need to capture a
// screenshot for the save game thumbnail // screenshot for the save game thumbnail
@ -1700,12 +1696,10 @@ void Minecraft::run_middle() {
// std::chrono::milliseconds(0)); // 4J - was // std::chrono::milliseconds(0)); // 4J - was
// Thread.yield()) // Thread.yield())
// if (Keyboard::isKeyDown(Keyboard::KEY_F7)) // if (Keyboard::isKeyDown(Keyboard::KEY_F7))
// Display.update(); // 4J - removed condition // Display.update(); // 4J - removed condition
Display::update(); Display::update();
// checkScreenshot(); // 4J - removed // checkScreenshot(); // 4J - removed
/* 4J - removed /* 4J - removed
@ -1981,7 +1975,6 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
textures->loadTexture(TN_TERRAIN)); // L"/terrain.png")); textures->loadTexture(TN_TERRAIN)); // L"/terrain.png"));
if (bFirst) { if (bFirst) {
if (!pause) textures->tick(bUpdateTextures); if (!pause) textures->tick(bUpdateTextures);
} }
/* /*
@ -3523,7 +3516,6 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
if (!pause) gameRenderer->tick(bFirst); if (!pause) gameRenderer->tick(bFirst);
// 4J - we want to tick each level once only per frame, and do it when a // 4J - we want to tick each level once only per frame, and do it when a
// player that is actually in that level happens to be active. This is // player that is actually in that level happens to be active. This is
// important as things that get called in the level tick (eg the // important as things that get called in the level tick (eg the
@ -3573,7 +3565,6 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
if (!pause) { if (!pause) {
if (levels[i]->skyFlashTime > 0) levels[i]->skyFlashTime--; if (levels[i]->skyFlashTime > 0) levels[i]->skyFlashTime--;
levels[i]->tickEntities(); levels[i]->tickEntities();
} }
// optimisation to set the culling off early, in parallel with // optimisation to set the culling off early, in parallel with
@ -3585,19 +3576,17 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
// app.DebugPrintf("Minecraft::tick spawn settings - // app.DebugPrintf("Minecraft::tick spawn settings -
// Difficulty = %d",options->difficulty); // Difficulty = %d",options->difficulty);
levels[i]->setSpawnSettings(level->difficulty > 0, true); levels[i]->setSpawnSettings(level->difficulty > 0, true);
#if defined(DISABLE_LEVELTICK_THREAD) #if defined(DISABLE_LEVELTICK_THREAD)
levels[i]->tick(); levels[i]->tick();
#else #else
levelTickEventQueue->sendEvent(levels[i]); levelTickEventQueue->sendEvent(levels[i]);
#endif #endif
} }
} }
} }
if (bFirst) { if (bFirst) {
if (!pause) particleEngine->tick(); if (!pause) particleEngine->tick();
} }
// 4J Stu - Keep ticking the connections if paused so that they don't // 4J Stu - Keep ticking the connections if paused so that they don't

View file

@ -2,7 +2,6 @@
#include <memory> #include <memory>
#include "minecraft/client/gui/inventory/AbstractContainerScreen.h" #include "minecraft/client/gui/inventory/AbstractContainerScreen.h"
#include "minecraft/world/inventory/AnvilMenu.h" #include "minecraft/world/inventory/AnvilMenu.h"
#include "minecraft/world/inventory/net.minecraft.world.inventory.ContainerListener.h" #include "minecraft/world/inventory/net.minecraft.world.inventory.ContainerListener.h"

View file

@ -170,12 +170,12 @@ void BeaconScreen::renderBg(float a) {
// Render payment item icons // Render payment item icons
itemRenderer->renderGuiItem( itemRenderer->renderGuiItem(
font, minecraft->textures, font, minecraft->textures,
std::make_shared<ItemInstance>(Item::emerald_Id, 1, 0), std::make_shared<ItemInstance>(Item::emerald_Id, 1, 0), xo + 42,
xo + 42, yo + 109); yo + 109);
itemRenderer->renderGuiItem( itemRenderer->renderGuiItem(
font, minecraft->textures, font, minecraft->textures,
std::make_shared<ItemInstance>(Item::diamond_Id, 1, 0), std::make_shared<ItemInstance>(Item::diamond_Id, 1, 0), xo + 42 + 22,
xo + 42 + 22, yo + 109); yo + 109);
itemRenderer->renderGuiItem(font, minecraft->textures, itemRenderer->renderGuiItem(font, minecraft->textures,
std::shared_ptr<ItemInstance>( std::shared_ptr<ItemInstance>(
new ItemInstance(Item::goldIngot_Id, 1, 0)), new ItemInstance(Item::goldIngot_Id, 1, 0)),

View file

@ -223,8 +223,10 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot,
arm0->zRot = 0.0f; arm0->zRot = 0.0f;
arm1->zRot = 0.0f; arm1->zRot = 0.0f;
} else if (uiBitmaskOverrideAnim & (1 << eAnim_SingleArms)) { } else if (uiBitmaskOverrideAnim & (1 << eAnim_SingleArms)) {
arm0->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 2.0f) * r * 0.5f; arm0->xRot =
arm1->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 2.0f) * r * 0.5f; (cosf(time * 0.6662f + std::numbers::pi) * 2.0f) * r * 0.5f;
arm1->xRot =
(cosf(time * 0.6662f + std::numbers::pi) * 2.0f) * r * 0.5f;
arm0->zRot = 0.0f; arm0->zRot = 0.0f;
arm1->zRot = 0.0f; arm1->zRot = 0.0f;
} }
@ -232,12 +234,13 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot,
// that's up // that's up
else if ((uiBitmaskOverrideAnim & (1 << eAnim_StatueOfLiberty)) && else if ((uiBitmaskOverrideAnim & (1 << eAnim_StatueOfLiberty)) &&
(holdingRightHand == 0) && (attackTime == 0.0f)) { (holdingRightHand == 0) && (attackTime == 0.0f)) {
arm0->xRot = -std::numbers::pi ; arm0->xRot = -std::numbers::pi;
arm0->zRot = -0.3f; arm0->zRot = -0.3f;
arm1->xRot = (cosf(time * 0.6662f) * 2.0f) * r * 0.5f; arm1->xRot = (cosf(time * 0.6662f) * 2.0f) * r * 0.5f;
arm1->zRot = 0.0f; arm1->zRot = 0.0f;
} else { } else {
arm0->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 2.0f) * r * 0.5f; arm0->xRot =
(cosf(time * 0.6662f + std::numbers::pi) * 2.0f) * r * 0.5f;
arm1->xRot = (cosf(time * 0.6662f) * 2.0f) * r * 0.5f; arm1->xRot = (cosf(time * 0.6662f) * 2.0f) * r * 0.5f;
arm0->zRot = 0.0f; arm0->zRot = 0.0f;
arm1->zRot = 0.0f; arm1->zRot = 0.0f;
@ -310,7 +313,8 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot,
swing *= swing; swing *= swing;
swing = 1.0f - swing; swing = 1.0f - swing;
float aa = sinf(swing * std::numbers::pi); float aa = sinf(swing * std::numbers::pi);
float bb = sinf(attackTime * std::numbers::pi) * -(head->xRot - 0.7f) * 0.75f; float bb = sinf(attackTime * std::numbers::pi) *
-(head->xRot - 0.7f) * 0.75f;
arm0->xRot -= aa * 1.2f + bb; // 4J - changed 1.2 -> 1.2f arm0->xRot -= aa * 1.2f + bb; // 4J - changed 1.2 -> 1.2f
arm0->yRot += body->yRot * 2.0f; arm0->yRot += body->yRot * 2.0f;
@ -331,7 +335,8 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot,
is = is * is * is; is = is * is * is;
is = is * is * is; is = is * is * is;
float iss = 1 - is; float iss = 1 - is;
arm0->xRot = -std::abs(cosf(eating_t / 4.0f * std::numbers::pi) * 0.1f) * arm0->xRot =
-std::abs(cosf(eating_t / 4.0f * std::numbers::pi) * 0.1f) *
(eating_swing > 0.2 ? 1.0f : 0.0f) * (eating_swing > 0.2 ? 1.0f : 0.0f) *
2.0f; // This factor is the chomping bit (conditional 2.0f; // This factor is the chomping bit (conditional
// factor is so that he doesn't eat whilst the // factor is so that he doesn't eat whilst the

View file

@ -544,8 +544,7 @@ void ModelHorse::prepareMobModel(std::shared_ptr<LivingEntity> mob, float wp,
Leg2B->y = Leg2B->y =
Leg2A->y + Leg2A->y +
(sinf(r90 + standAngle + iStanding * (legAnim1 * 0.5f * ws)) * (sinf(r90 + standAngle + iStanding * (legAnim1 * 0.5f * ws)) * 7.f);
7.f);
Leg2B->z = Leg2B->z =
Leg2A->z + Leg2A->z +
(cosf(r270 + standAngle + iStanding * (legAnim1 * 0.5f * ws)) * (cosf(r270 + standAngle + iStanding * (legAnim1 * 0.5f * ws)) *
@ -576,14 +575,16 @@ void ModelHorse::prepareMobModel(std::shared_ptr<LivingEntity> mob, float wp,
Leg3A->xRot = rlegRot; Leg3A->xRot = rlegRot;
Leg3B->xRot = Leg3B->xRot =
(Leg3A->xRot + std::numbers::pi * std::max(0.0f, (.2f + bobValue * .2f))) * (Leg3A->xRot +
std::numbers::pi * std::max(0.0f, (.2f + bobValue * .2f))) *
standing + standing +
(legXRotAnim + std::max(0.0f, legAnim1 * 0.5f * ws)) * iStanding; (legXRotAnim + std::max(0.0f, legAnim1 * 0.5f * ws)) * iStanding;
Leg3C->xRot = Leg3B->xRot; Leg3C->xRot = Leg3B->xRot;
Leg4A->xRot = llegRot; Leg4A->xRot = llegRot;
Leg4B->xRot = Leg4B->xRot =
(Leg4A->xRot + std::numbers::pi * std::max(0.0f, (.2f - bobValue * .2f))) * (Leg4A->xRot +
std::numbers::pi * std::max(0.0f, (.2f - bobValue * .2f))) *
standing + standing +
(-legXRotAnim + std::max(0.0f, -legAnim1 * 0.5f * ws)) * iStanding; (-legXRotAnim + std::max(0.0f, -legAnim1 * 0.5f * ws)) * iStanding;
Leg4C->xRot = Leg4B->xRot; Leg4C->xRot = Leg4B->xRot;

View file

@ -162,19 +162,26 @@ void OcelotModel::setupAnim(float time, float r, float bob, float yRot,
backLegL->xRot = ((float)cosf(time * 0.6662f) * 1.f) * r; backLegL->xRot = ((float)cosf(time * 0.6662f) * 1.f) * r;
backLegR->xRot = ((float)cosf(time * 0.6662f + 0.3f) * 1.f) * r; backLegR->xRot = ((float)cosf(time * 0.6662f + 0.3f) * 1.f) * r;
frontLegL->xRot = frontLegL->xRot =
((float)cosf(time * 0.6662f + std::numbers::pi + 0.3f) * 1.f) * r; ((float)cosf(time * 0.6662f + std::numbers::pi + 0.3f) * 1.f) *
frontLegR->xRot = ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r; r;
tail2->xRot = 0.55f * std::numbers::pi + 0.1f * std::numbers::pi * cosf(time) * r; frontLegR->xRot =
((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r;
tail2->xRot = 0.55f * std::numbers::pi +
0.1f * std::numbers::pi * cosf(time) * r;
} else { } else {
backLegL->xRot = ((float)cosf(time * 0.6662f) * 1.f) * r; backLegL->xRot = ((float)cosf(time * 0.6662f) * 1.f) * r;
backLegR->xRot = ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r; backLegR->xRot =
frontLegL->xRot = ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r; ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r;
frontLegL->xRot =
((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r;
frontLegR->xRot = ((float)cosf(time * 0.6662f) * 1.f) * r; frontLegR->xRot = ((float)cosf(time * 0.6662f) * 1.f) * r;
if (state == WALK_STATE) if (state == WALK_STATE)
tail2->xRot = 0.55f * std::numbers::pi + 0.25f * std::numbers::pi * cosf(time) * r; tail2->xRot = 0.55f * std::numbers::pi +
0.25f * std::numbers::pi * cosf(time) * r;
else else
tail2->xRot = 0.55f * std::numbers::pi + 0.15f * std::numbers::pi * cosf(time) * r; tail2->xRot = 0.55f * std::numbers::pi +
0.15f * std::numbers::pi * cosf(time) * r;
} }
} }
} }

View file

@ -73,10 +73,10 @@ void SilverfishModel::setupAnim(float time, float r, float bob, float yRot,
std::shared_ptr<Entity> entity, std::shared_ptr<Entity> entity,
unsigned int uiBitmaskOverrideAnim) { unsigned int uiBitmaskOverrideAnim) {
for (unsigned int i = 0; i < bodyParts.size(); i++) { for (unsigned int i = 0; i < bodyParts.size(); i++) {
bodyParts[i]->yRot = cosf(bob * .9f + i * .15f * std::numbers::pi) * std::numbers::pi * .05f * bodyParts[i]->yRot = cosf(bob * .9f + i * .15f * std::numbers::pi) *
(1 + abs((int)i - 2)); std::numbers::pi * .05f * (1 + abs((int)i - 2));
bodyParts[i]->x = bodyParts[i]->x = sinf(bob * .9f + i * .15f * std::numbers::pi) *
sinf(bob * .9f + i * .15f * std::numbers::pi) * std::numbers::pi * .2f * abs((int)i - 2); std::numbers::pi * .2f * abs((int)i - 2);
} }
bodyLayers[0]->yRot = bodyParts[2]->yRot; bodyLayers[0]->yRot = bodyParts[2]->yRot;

View file

@ -120,22 +120,38 @@ void SpiderModel::setupAnim(float time, float r, float bob, float yRot,
leg7->yRot = +ur * 2.0f - ro; leg7->yRot = +ur * 2.0f - ro;
float c0 = float c0 =
-((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 0 / 4.0f) * 0.4f) * r; -((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 0 / 4.0f) *
0.4f) *
r;
float c1 = float c1 =
-((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 2 / 4.0f) * 0.4f) * r; -((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 2 / 4.0f) *
0.4f) *
r;
float c2 = float c2 =
-((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 1 / 4.0f) * 0.4f) * r; -((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 1 / 4.0f) *
0.4f) *
r;
float c3 = float c3 =
-((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 3 / 4.0f) * 0.4f) * r; -((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 3 / 4.0f) *
0.4f) *
r;
float s0 = float s0 =
std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 0 / 4.0f) * 0.4f) * r; std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 0 / 4.0f) *
0.4f) *
r;
float s1 = float s1 =
std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 2 / 4.0f) * 0.4f) * r; std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 2 / 4.0f) *
0.4f) *
r;
float s2 = float s2 =
std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 1 / 4.0f) * 0.4f) * r; std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 1 / 4.0f) *
0.4f) *
r;
float s3 = float s3 =
std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 3 / 4.0f) * 0.4f) * r; std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 3 / 4.0f) *
0.4f) *
r;
leg0->yRot += +c0; leg0->yRot += +c0;
leg1->yRot += -c0; leg1->yRot += -c0;

View file

@ -78,7 +78,8 @@ void VillagerModel::setupAnim(float time, float r, float bob, float yRot,
arms->xRot = -0.75f; arms->xRot = -0.75f;
leg0->xRot = ((float)cosf(time * 0.6662f) * 1.4f) * r * 0.5f; leg0->xRot = ((float)cosf(time * 0.6662f) * 1.4f) * r * 0.5f;
leg1->xRot = ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.4f) * r * 0.5f; leg1->xRot =
((float)cosf(time * 0.6662f + std::numbers::pi) * 1.4f) * r * 0.5f;
leg0->yRot = 0; leg0->yRot = 0;
leg1->yRot = 0; leg1->yRot = 0;
} }

View file

@ -43,7 +43,8 @@ void VillagerZombieModel::setupAnim(float time, float r, float bob, float yRot,
uiBitmaskOverrideAnim); uiBitmaskOverrideAnim);
float attack2 = sinf(attackTime * std::numbers::pi); float attack2 = sinf(attackTime * std::numbers::pi);
float attack = sinf((1 - (1 - attackTime) * (1 - attackTime)) * std::numbers::pi); float attack =
sinf((1 - (1 - attackTime) * (1 - attackTime)) * std::numbers::pi);
arm0->zRot = 0; arm0->zRot = 0;
arm1->zRot = 0; arm1->zRot = 0;
arm0->yRot = -(0.1f - attack2 * 0.6f); arm0->yRot = -(0.1f - attack2 * 0.6f);

View file

@ -62,9 +62,11 @@ void WitchModel::setupAnim(float time, float r, float bob, float yRot,
nose->translateX = nose->translateY = nose->translateZ = 0; nose->translateX = nose->translateY = nose->translateZ = 0;
float speed = 0.01f * (entity->entityId % 10); float speed = 0.01f * (entity->entityId % 10);
nose->xRot = (sin(entity->tickCount * speed) * 4.5f) * std::numbers::pi / 180; nose->xRot =
(sin(entity->tickCount * speed) * 4.5f) * std::numbers::pi / 180;
nose->yRot = 0; nose->yRot = 0;
nose->zRot = (cos(entity->tickCount * speed) * 2.5f) * std::numbers::pi / 180; nose->zRot =
(cos(entity->tickCount * speed) * 2.5f) * std::numbers::pi / 180;
if (holdingItem) { if (holdingItem) {
nose->xRot = -0.9f; nose->xRot = -0.9f;

View file

@ -73,8 +73,8 @@ void WitherBossModel::prepareMobModel(std::shared_ptr<LivingEntity> mob,
std::dynamic_pointer_cast<WitherBoss>(mob); std::dynamic_pointer_cast<WitherBoss>(mob);
for (int i = 1; i < 3; i++) { for (int i = 1; i < 3; i++) {
heads[i]->yRot = heads[i]->yRot = (boss->getHeadYRot(i - 1) - mob->yBodyRot) /
(boss->getHeadYRot(i - 1) - mob->yBodyRot) / (180 / std::numbers::pi); (180 / std::numbers::pi);
heads[i]->xRot = boss->getHeadXRot(i - 1) / (180 / std::numbers::pi); heads[i]->xRot = boss->getHeadXRot(i - 1) / (180 / std::numbers::pi);
} }
} }

View file

@ -22,7 +22,8 @@ void ZombieModel::setupAnim(float time, float r, float bob, float yRot,
uiBitmaskOverrideAnim); uiBitmaskOverrideAnim);
float attack2 = sinf(attackTime * std::numbers::pi); float attack2 = sinf(attackTime * std::numbers::pi);
float attack = sinf((1 - (1 - attackTime) * (1 - attackTime)) * std::numbers::pi); float attack =
sinf((1 - (1 - attackTime) * (1 - attackTime)) * std::numbers::pi);
arm0->zRot = 0; arm0->zRot = 0;
arm1->zRot = 0; arm1->zRot = 0;
arm0->yRot = -(0.1f - attack2 * 0.6f); arm0->yRot = -(0.1f - attack2 * 0.6f);

View file

@ -135,12 +135,15 @@ void DragonModel::render(std::shared_ptr<Entity> entity, float time, float r,
float rotScale = 1.5f; float rotScale = 1.5f;
double startComponents[3]; double startComponents[3];
std::vector<double> start = std::vector<double>(startComponents, startComponents + 3); std::vector<double> start =
std::vector<double>(startComponents, startComponents + 3);
dragon->getLatencyPos(start, 6, a); dragon->getLatencyPos(start, 6, a);
double latencyPosAComponents[3], latencyPosBComponents[3]; double latencyPosAComponents[3], latencyPosBComponents[3];
std::vector<double> latencyPosA = std::vector<double>(latencyPosAComponents, latencyPosAComponents + 3); std::vector<double> latencyPosA =
std::vector<double> latencyPosB = std::vector<double>(latencyPosBComponents, latencyPosBComponents + 3); std::vector<double>(latencyPosAComponents, latencyPosAComponents + 3);
std::vector<double> latencyPosB =
std::vector<double>(latencyPosBComponents, latencyPosBComponents + 3);
dragon->getLatencyPos(latencyPosA, 5, a); dragon->getLatencyPos(latencyPosA, 5, a);
dragon->getLatencyPos(latencyPosB, 10, a); dragon->getLatencyPos(latencyPosB, 10, a);
float rot2 = rotWrap(latencyPosA[0] - latencyPosB[0]); float rot2 = rotWrap(latencyPosA[0] - latencyPosB[0]);
@ -159,14 +162,16 @@ void DragonModel::render(std::shared_ptr<Entity> entity, float time, float r,
dragon->getLatencyPos(p, 5 - i, a); dragon->getLatencyPos(p, 5 - i, a);
rr = (float)cosf(i * 0.45f + roff) * 0.15f; rr = (float)cosf(i * 0.45f + roff) * 0.15f;
neck->yRot = rotWrap(dragon->getHeadPartYRotDiff(i, start, p)) * std::numbers::pi / neck->yRot = rotWrap(dragon->getHeadPartYRotDiff(i, start, p)) *
180.0f * rotScale; // 4J replaced "p[0] - start[0] with std::numbers::pi / 180.0f *
rotScale; // 4J replaced "p[0] - start[0] with
// call to getHeadPartYRotDiff // call to getHeadPartYRotDiff
neck->xRot = rr + (float)(dragon->getHeadPartYOffset(i, start, p)) * neck->xRot = rr + (float)(dragon->getHeadPartYOffset(i, start, p)) *
std::numbers::pi / 180.0f * rotScale * std::numbers::pi / 180.0f * rotScale *
5.0f; // 4J replaced "p[1] - start[1]" with call 5.0f; // 4J replaced "p[1] - start[1]" with call
// to getHeadPartYOffset // to getHeadPartYOffset
neck->zRot = -rotWrap(p[0] - rot) * std::numbers::pi / 180.0f * rotScale; neck->zRot =
-rotWrap(p[0] - rot) * std::numbers::pi / 180.0f * rotScale;
neck->y = yy; neck->y = yy;
neck->z = zz; neck->z = zz;
@ -182,10 +187,11 @@ void DragonModel::render(std::shared_ptr<Entity> entity, float time, float r,
head->x = xx; head->x = xx;
dragon->getLatencyPos(p, 0, a); dragon->getLatencyPos(p, 0, a);
head->yRot = head->yRot =
rotWrap(dragon->getHeadPartYRotDiff(6, start, p)) * std::numbers::pi / 180.0f * rotWrap(dragon->getHeadPartYRotDiff(6, start, p)) * std::numbers::pi /
180.0f *
1; // 4J replaced "p[0] - start[0] with call to getHeadPartYRotDiff 1; // 4J replaced "p[0] - start[0] with call to getHeadPartYRotDiff
head->xRot = (float)(dragon->getHeadPartYOffset(6, start, p)) * std::numbers::pi / head->xRot = (float)(dragon->getHeadPartYOffset(6, start, p)) *
180.0f * rotScale * 5.0f; // 4J Added std::numbers::pi / 180.0f * rotScale * 5.0f; // 4J Added
head->zRot = -rotWrap(p[0] - rot) * std::numbers::pi / 180 * 1; head->zRot = -rotWrap(p[0] - rot) * std::numbers::pi / 180 * 1;
head->render(scale, usecompiled); head->render(scale, usecompiled);
glPushMatrix(); glPushMatrix();
@ -231,8 +237,10 @@ void DragonModel::render(std::shared_ptr<Entity> entity, float time, float r,
for (int i = 0; i < 12; i++) { for (int i = 0; i < 12; i++) {
dragon->getLatencyPos(p, 12 + i, a); dragon->getLatencyPos(p, 12 + i, a);
rr += sinf(i * 0.45f + roff) * 0.05f; rr += sinf(i * 0.45f + roff) * 0.05f;
neck->yRot = (rotWrap(p[0] - start[0]) * rotScale + 180) * std::numbers::pi / 180; neck->yRot = (rotWrap(p[0] - start[0]) * rotScale + 180) *
neck->xRot = rr + (float)(p[1] - start[1]) * std::numbers::pi / 180 * rotScale * 5; std::numbers::pi / 180;
neck->xRot = rr + (float)(p[1] - start[1]) * std::numbers::pi / 180 *
rotScale * 5;
neck->zRot = rotWrap(p[0] - rot) * std::numbers::pi / 180 * rotScale; neck->zRot = rotWrap(p[0] - rot) * std::numbers::pi / 180 * rotScale;
neck->y = yy; neck->y = yy;
neck->z = zz; neck->z = zz;

View file

@ -1059,9 +1059,6 @@ void ClientConnection::handleChunkTilesUpdate(
dimensionLevel->shareChunkAt(xo, dimensionLevel->shareChunkAt(xo,
zo); // 4J - added - only shares if chunks zo); // 4J - added - only shares if chunks
// are same on server & client // are same on server & client
} }
} }
@ -1071,7 +1068,6 @@ void ClientConnection::handleBlockRegionUpdate(
MultiPlayerLevel* dimensionLevel = MultiPlayerLevel* dimensionLevel =
(MultiPlayerLevel*)minecraft->levels[packet->levelIdx]; (MultiPlayerLevel*)minecraft->levels[packet->levelIdx];
if (dimensionLevel) { if (dimensionLevel) {
int y1 = packet->y + packet->ys; int y1 = packet->y + packet->ys;
if (packet->bIsFullChunk) { if (packet->bIsFullChunk) {
y1 = Level::maxBuildHeight; y1 = Level::maxBuildHeight;
@ -1079,21 +1075,18 @@ void ClientConnection::handleBlockRegionUpdate(
LevelChunk::reorderBlocksAndDataToXZY(packet->y, packet->xs, LevelChunk::reorderBlocksAndDataToXZY(packet->y, packet->xs,
packet->ys, packet->zs, packet->ys, packet->zs,
&packet->buffer); &packet->buffer);
} }
} }
dimensionLevel->clearResetRegion(packet->x, packet->y, packet->z, dimensionLevel->clearResetRegion(packet->x, packet->y, packet->z,
packet->x + packet->xs - 1, y1 - 1, packet->x + packet->xs - 1, y1 - 1,
packet->z + packet->zs - 1); packet->z + packet->zs - 1);
// Only full chunks send lighting information now - added flag to end of // Only full chunks send lighting information now - added flag to end of
// this call // this call
dimensionLevel->setBlocksAndData(packet->x, packet->y, packet->z, dimensionLevel->setBlocksAndData(packet->x, packet->y, packet->z,
packet->xs, packet->ys, packet->zs, packet->xs, packet->ys, packet->zs,
packet->buffer, packet->bIsFullChunk); packet->buffer, packet->bIsFullChunk);
// OutputDebugString("END BRU\n"); // OutputDebugString("END BRU\n");
// 4J - remove any tite entities in this region which are associated // 4J - remove any tite entities in this region which are associated
@ -1105,7 +1098,6 @@ void ClientConnection::handleBlockRegionUpdate(
packet->x, packet->y, packet->z, packet->x + packet->xs, y1, packet->x, packet->y, packet->z, packet->x + packet->xs, y1,
packet->z + packet->zs); packet->z + packet->zs);
// If this is a full packet for a chunk, make sure that the cache now // If this is a full packet for a chunk, make sure that the cache now
// considers that it has data for this chunk - this is used to determine // considers that it has data for this chunk - this is used to determine
// whether to bother rendering mobs or not, so we don't have them in // whether to bother rendering mobs or not, so we don't have them in
@ -1113,9 +1105,7 @@ void ClientConnection::handleBlockRegionUpdate(
if (packet->bIsFullChunk) { if (packet->bIsFullChunk) {
dimensionLevel->dataReceivedForChunk(packet->x >> 4, dimensionLevel->dataReceivedForChunk(packet->x >> 4,
packet->z >> 4); packet->z >> 4);
} }
} }
} }
@ -1135,7 +1125,6 @@ void ClientConnection::handleTileUpdate(
MultiPlayerLevel* dimensionLevel = MultiPlayerLevel* dimensionLevel =
(MultiPlayerLevel*)minecraft->levels[packet->levelIdx]; (MultiPlayerLevel*)minecraft->levels[packet->levelIdx];
if (dimensionLevel) { if (dimensionLevel) {
if (g_NetworkManager.IsHost()) { if (g_NetworkManager.IsHost()) {
// 4J Stu - Unshare before we make any changes incase the server is // 4J Stu - Unshare before we make any changes incase the server is
// already another step ahead of us Fix for #7904 - Gameplay: // already another step ahead of us Fix for #7904 - Gameplay:
@ -1148,7 +1137,6 @@ void ClientConnection::handleTileUpdate(
dimensionLevel->getData(packet->x, packet->y, packet->z); dimensionLevel->getData(packet->x, packet->y, packet->z);
if (packet->block != prevTile || packet->data != prevData) { if (packet->block != prevTile || packet->data != prevData) {
dimensionLevel->unshareChunkAt(packet->x, packet->z); dimensionLevel->unshareChunkAt(packet->x, packet->z);
} }
} }
@ -1164,8 +1152,6 @@ void ClientConnection::handleTileUpdate(
bool tileWasSet = dimensionLevel->doSetTileAndData( bool tileWasSet = dimensionLevel->doSetTileAndData(
packet->x, packet->y, packet->z, packet->block, packet->data); packet->x, packet->y, packet->z, packet->block, packet->data);
// 4J - remove any tite entities in this region which are associated // 4J - remove any tite entities in this region which are associated
// with a tile that is now no longer a tile entity. Without doing this // with a tile that is now no longer a tile entity. Without doing this
// we end up with stray tile entities kicking round, which leads to a // we end up with stray tile entities kicking round, which leads to a
@ -1178,9 +1164,6 @@ void ClientConnection::handleTileUpdate(
dimensionLevel->shareChunkAt( dimensionLevel->shareChunkAt(
packet->x, packet->z); // 4J - added - only shares if chunks are packet->x, packet->z); // 4J - added - only shares if chunks are
// same on server & client // same on server & client
} }
} }
@ -2454,7 +2437,6 @@ void ClientConnection::handleExplosion(std::shared_ptr<ExplodePacket> packet) {
e->finalizeExplosion(true, &packet->toBlow); e->finalizeExplosion(true, &packet->toBlow);
mpLevel->enableResetChanges(true); mpLevel->enableResetChanges(true);
delete e; delete e;
} else { } else {
// app.DebugPrintf("Received ExplodePacket with knockback only data\n"); // app.DebugPrintf("Received ExplodePacket with knockback only data\n");
@ -2708,8 +2690,8 @@ void ClientConnection::handleContainerAck(
} }
if (menu != nullptr) { if (menu != nullptr) {
if (!packet->accepted) { if (!packet->accepted) {
send(std::make_shared<ContainerAckPacket>( send(std::make_shared<ContainerAckPacket>(packet->containerId,
packet->containerId, packet->uid, true)); packet->uid, true));
} }
} }
} }
@ -2835,7 +2817,6 @@ void ClientConnection::handleTileEvent(
std::shared_ptr<TileEventPacket> packet) { std::shared_ptr<TileEventPacket> packet) {
minecraft->level->tileEvent(packet->x, packet->y, packet->z, packet->tile, minecraft->level->tileEvent(packet->x, packet->y, packet->z, packet->tile,
packet->b0, packet->b1); packet->b0, packet->b1);
} }
void ClientConnection::handleTileDestruction( void ClientConnection::handleTileDestruction(
@ -2877,8 +2858,7 @@ void ClientConnection::handleGameEvent(
app.DebugPrintf("handleGameEvent packet for WIN_GAME - %d\n", app.DebugPrintf("handleGameEvent packet for WIN_GAME - %d\n",
m_userIndex); m_userIndex);
// This just allows it to be shown // This just allows it to be shown
if (minecraft->localgameModes[InputManager.GetPrimaryPad()] != if (minecraft->localgameModes[InputManager.GetPrimaryPad()] != nullptr)
nullptr)
minecraft->localgameModes[InputManager.GetPrimaryPad()] minecraft->localgameModes[InputManager.GetPrimaryPad()]
->getTutorial() ->getTutorial()
->showTutorialPopup(false); ->showTutorialPopup(false);
@ -3446,7 +3426,8 @@ void ClientConnection::checkDeferredEntityLinkPackets(int newEntityId) {
bool remove = false; bool remove = false;
// Only consider recently deferred packets // Only consider recently deferred packets
int tickInterval = PlatformTime::GetTickCount() - deferred->m_recievedTick; int tickInterval =
PlatformTime::GetTickCount() - deferred->m_recievedTick;
if (tickInterval < MAX_ENTITY_LINK_DEFERRAL_INTERVAL) { if (tickInterval < MAX_ENTITY_LINK_DEFERRAL_INTERVAL) {
// Note: we assume it's the destination entity // Note: we assume it's the destination entity
if (deferred->m_packet->destId == newEntityId) { if (deferred->m_packet->destId == newEntityId) {

View file

@ -26,8 +26,7 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level* level) {
memset(hasData, 0, sizeof(bool) * XZSIZE * XZSIZE); memset(hasData, 0, sizeof(bool) * XZSIZE * XZSIZE);
std::vector<uint8_t> emptyBlocks(16 * 16 * Level::maxBuildHeight); std::vector<uint8_t> emptyBlocks(16 * 16 * Level::maxBuildHeight);
emptyChunk = new EmptyLevelChunk( emptyChunk = new EmptyLevelChunk(level, emptyBlocks, 0, 0);
level, emptyBlocks, 0, 0);
// For normal world dimension, create a chunk that can be used to create the // For normal world dimension, create a chunk that can be used to create the
// illusion of infinite water at the edge of the world // illusion of infinite water at the edge of the world
@ -63,7 +62,6 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level* level) {
waterChunk = new WaterLevelChunk(level, bytes, 0, 0); waterChunk = new WaterLevelChunk(level, bytes, 0, 0);
if (level->getLevelData()->getGenerator() == LevelType::lvl_flat) { if (level->getLevelData()->getGenerator() == LevelType::lvl_flat) {
for (int x = 0; x < 16; x++) for (int x = 0; x < 16; x++)
for (int y = 0; y < 128; y++) for (int y = 0; y < 128; y++)

View file

@ -129,20 +129,17 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) {
} }
if (localPlayerMode->isCreative()) { if (localPlayerMode->isCreative()) {
connection->send( connection->send(std::make_shared<PlayerActionPacket>(
std::make_shared<PlayerActionPacket>(
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)); PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face));
creativeDestroyBlock(minecraft, this, x, y, z, face); creativeDestroyBlock(minecraft, this, x, y, z, face);
destroyDelay = 5; destroyDelay = 5;
} else if (!isDestroying || !sameDestroyTarget(x, y, z)) { } else if (!isDestroying || !sameDestroyTarget(x, y, z)) {
if (isDestroying) { if (isDestroying) {
connection->send( connection->send(std::make_shared<PlayerActionPacket>(
std::make_shared<PlayerActionPacket>(
PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock,
yDestroyBlock, zDestroyBlock, face)); yDestroyBlock, zDestroyBlock, face));
} }
connection->send( connection->send(std::make_shared<PlayerActionPacket>(
std::make_shared<PlayerActionPacket>(
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)); PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face));
int t = minecraft->level->getTile(x, y, z); int t = minecraft->level->getTile(x, y, z);
if (t > 0 && destroyProgress == 0) if (t > 0 && destroyProgress == 0)
@ -172,8 +169,7 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) {
void MultiPlayerGameMode::stopDestroyBlock() { void MultiPlayerGameMode::stopDestroyBlock() {
if (isDestroying) { if (isDestroying) {
connection->send( connection->send(std::make_shared<PlayerActionPacket>(
std::make_shared<PlayerActionPacket>(
PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock,
yDestroyBlock, zDestroyBlock, -1)); yDestroyBlock, zDestroyBlock, -1));
} }
@ -199,8 +195,7 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) {
if (localPlayerMode->isCreative()) { if (localPlayerMode->isCreative()) {
destroyDelay = 5; destroyDelay = 5;
connection->send( connection->send(std::make_shared<PlayerActionPacket>(
std::make_shared<PlayerActionPacket>(
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)); PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face));
creativeDestroyBlock(minecraft, this, x, y, z, face); creativeDestroyBlock(minecraft, this, x, y, z, face);
return; return;
@ -232,8 +227,7 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) {
if (destroyProgress >= 1) { if (destroyProgress >= 1) {
isDestroying = false; isDestroying = false;
connection->send( connection->send(std::make_shared<PlayerActionPacket>(
std::make_shared<PlayerActionPacket>(
PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face)); PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face));
destroyBlock(x, y, z, face); destroyBlock(x, y, z, face);
destroyProgress = 0; destroyProgress = 0;
@ -533,6 +527,5 @@ bool MultiPlayerGameMode::handleCraftItem(int recipe,
void MultiPlayerGameMode::handleDebugOptions(unsigned int uiVal, void MultiPlayerGameMode::handleDebugOptions(unsigned int uiVal,
std::shared_ptr<Player> player) { std::shared_ptr<Player> player) {
player->SetDebugOptions(uiVal); player->SetDebugOptions(uiVal);
connection->send( connection->send(std::make_shared<DebugOptionsPacket>(uiVal));
std::make_shared<DebugOptionsPacket>(uiVal));
} }

View file

@ -55,8 +55,8 @@ MultiPlayerLevel::ResetInfo::ResetInfo(int x, int y, int z, int tile,
MultiPlayerLevel::MultiPlayerLevel(ClientConnection* connection, MultiPlayerLevel::MultiPlayerLevel(ClientConnection* connection,
LevelSettings* levelSettings, int dimension, LevelSettings* levelSettings, int dimension,
int difficulty) int difficulty)
: Level(std::make_shared<MockedLevelStorage>(), : Level(std::make_shared<MockedLevelStorage>(), L"MpServer",
L"MpServer", Dimension::getNew(dimension), levelSettings, false) { Dimension::getNew(dimension), levelSettings, false) {
minecraft = Minecraft::GetInstance(); minecraft = Minecraft::GetInstance();
// 4J - this this used to be called in parent ctor via a virtual fn // 4J - this this used to be called in parent ctor via a virtual fn
@ -141,7 +141,6 @@ void MultiPlayerLevel::tick() {
} }
}*/ }*/
{ {
std::lock_guard<std::recursive_mutex> lock(m_entitiesCS); std::lock_guard<std::recursive_mutex> lock(m_entitiesCS);
for (int i = 0; i < 10 && !reEntries.empty(); i++) { for (int i = 0; i < 10 && !reEntries.empty(); i++) {
@ -152,7 +151,6 @@ void MultiPlayerLevel::tick() {
} }
} }
// 4J HEG - Copy the connections vector to prevent crash when moving to // 4J HEG - Copy the connections vector to prevent crash when moving to
// Nether // Nether
std::vector<ClientConnection*> connectionsTemp = connections; std::vector<ClientConnection*> connectionsTemp = connections;
@ -161,7 +159,6 @@ void MultiPlayerLevel::tick() {
(*connection)->tick(); (*connection)->tick();
} }
unsigned int lastIndexToRemove = 0; unsigned int lastIndexToRemove = 0;
bool eraseElements = false; bool eraseElements = false;
for (unsigned int i = 0; i < updatesToReset.size(); i++) { for (unsigned int i = 0; i < updatesToReset.size(); i++) {
@ -186,7 +183,6 @@ void MultiPlayerLevel::tick() {
updatesToReset.begin() + lastIndexToRemove); updatesToReset.begin() + lastIndexToRemove);
} }
chunkCache->tick(); chunkCache->tick();
tickTiles(); tickTiles();
@ -411,7 +407,6 @@ void MultiPlayerLevel::tickTiles() {
Level::tickTiles(); Level::tickTiles();
auto itEndCtp = chunksToPoll.end(); auto itEndCtp = chunksToPoll.end();
for (auto it = chunksToPoll.begin(); it != itEndCtp; it++) { for (auto it = chunksToPoll.begin(); it != itEndCtp; it++) {
ChunkPos cp = *it; ChunkPos cp = *it;
@ -422,8 +417,6 @@ void MultiPlayerLevel::tickTiles() {
tickClientSideTiles(xo, zo, lc); tickClientSideTiles(xo, zo, lc);
} }
} }
void MultiPlayerLevel::setChunkVisible(int x, int z, bool visible) { void MultiPlayerLevel::setChunkVisible(int x, int z, bool visible) {
@ -915,7 +908,6 @@ void MultiPlayerLevel::tickAllConnections() {
for (auto it = connections.begin(); it < connections.end(); ++it) { for (auto it = connections.begin(); it < connections.end(); ++it) {
(*it)->tick(); (*it)->tick();
} }
} }
void MultiPlayerLevel::dataReceivedForChunk(int x, int z) { void MultiPlayerLevel::dataReceivedForChunk(int x, int z) {

View file

@ -99,11 +99,9 @@ void MultiplayerLocalPlayer::tick() {
if (minecraft->localgameModes[m_iPad]->getTutorial()->canMoveToPosition( if (minecraft->localgameModes[m_iPad]->getTutorial()->canMoveToPosition(
tempX, tempY, tempZ, x, y, z)) { tempX, tempY, tempZ, x, y, z)) {
if (isRiding()) { if (isRiding()) {
connection->send( connection->send(std::make_shared<MovePlayerPacket::Rot>(
std::make_shared<MovePlayerPacket::Rot>(
yRot, xRot, onGround, abilities.flying)); yRot, xRot, onGround, abilities.flying));
connection->send( connection->send(std::make_shared<PlayerInputPacket>(
std::make_shared<PlayerInputPacket>(
xxa, yya, input->jumping, input->sneaking)); xxa, yya, input->jumping, input->sneaking));
} else { } else {
sendPosition(); sendPosition();
@ -119,12 +117,10 @@ void MultiplayerLocalPlayer::sendPosition() {
bool sprinting = isSprinting(); bool sprinting = isSprinting();
if (sprinting != lastSprinting) { if (sprinting != lastSprinting) {
if (sprinting) if (sprinting)
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>(
shared_from_this(), PlayerCommandPacket::START_SPRINTING)); shared_from_this(), PlayerCommandPacket::START_SPRINTING));
else else
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>(
shared_from_this(), PlayerCommandPacket::STOP_SPRINTING)); shared_from_this(), PlayerCommandPacket::STOP_SPRINTING));
lastSprinting = sprinting; lastSprinting = sprinting;
@ -133,12 +129,10 @@ void MultiplayerLocalPlayer::sendPosition() {
bool sneaking = isSneaking(); bool sneaking = isSneaking();
if (sneaking != lastSneaked) { if (sneaking != lastSneaked) {
if (sneaking) if (sneaking)
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>(
shared_from_this(), PlayerCommandPacket::START_SNEAKING)); shared_from_this(), PlayerCommandPacket::START_SNEAKING));
else else
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>(
shared_from_this(), PlayerCommandPacket::STOP_SNEAKING)); shared_from_this(), PlayerCommandPacket::STOP_SNEAKING));
lastSneaked = sneaking; lastSneaked = sneaking;
@ -147,12 +141,10 @@ void MultiplayerLocalPlayer::sendPosition() {
bool idle = isIdle(); bool idle = isIdle();
if (idle != lastIdle) { if (idle != lastIdle) {
if (idle) if (idle)
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>(
shared_from_this(), PlayerCommandPacket::START_IDLEANIM)); shared_from_this(), PlayerCommandPacket::START_IDLEANIM));
else else
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>(
shared_from_this(), PlayerCommandPacket::STOP_IDLEANIM)); shared_from_this(), PlayerCommandPacket::STOP_IDLEANIM));
lastIdle = idle; lastIdle = idle;
@ -169,22 +161,18 @@ void MultiplayerLocalPlayer::sendPosition() {
positionReminder >= POSITION_REMINDER_INTERVAL; positionReminder >= POSITION_REMINDER_INTERVAL;
bool rot = rydd != 0 || rxdd != 0; bool rot = rydd != 0 || rxdd != 0;
if (riding != nullptr) { if (riding != nullptr) {
connection->send( connection->send(std::make_shared<MovePlayerPacket::PosRot>(
std::make_shared<MovePlayerPacket::PosRot>(
xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying)); xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying));
move = false; move = false;
} else { } else {
if (move && rot) { if (move && rot) {
connection->send( connection->send(std::make_shared<MovePlayerPacket::PosRot>(
std::make_shared<MovePlayerPacket::PosRot>(
x, bb.y0, y, z, yRot, xRot, onGround, abilities.flying)); x, bb.y0, y, z, yRot, xRot, onGround, abilities.flying));
} else if (move) { } else if (move) {
connection->send( connection->send(std::make_shared<MovePlayerPacket::Pos>(
std::make_shared<MovePlayerPacket::Pos>(
x, bb.y0, y, z, onGround, abilities.flying)); x, bb.y0, y, z, onGround, abilities.flying));
} else if (rot) { } else if (rot) {
connection->send( connection->send(std::make_shared<MovePlayerPacket::Rot>(
std::make_shared<MovePlayerPacket::Rot>(
yRot, xRot, onGround, abilities.flying)); yRot, xRot, onGround, abilities.flying));
} else { } else {
connection->send(std::shared_ptr<MovePlayerPacket>( connection->send(std::shared_ptr<MovePlayerPacket>(
@ -295,8 +283,7 @@ void MultiplayerLocalPlayer::clientSideCloseContainer() {
LocalPlayer::closeContainer(); LocalPlayer::closeContainer();
} }
void MultiplayerLocalPlayer::hurtTo(float newHealth, void MultiplayerLocalPlayer::hurtTo(float newHealth, uint8_t damageSource) {
uint8_t damageSource) {
if (flashOnSetHealth) { if (flashOnSetHealth) {
LocalPlayer::hurtTo(newHealth, damageSource); LocalPlayer::hurtTo(newHealth, damageSource);
} else { } else {
@ -305,7 +292,8 @@ void MultiplayerLocalPlayer::hurtTo(float newHealth,
} }
} }
void MultiplayerLocalPlayer::awardStat(Stat* stat, const std::vector<uint8_t>& param) { void MultiplayerLocalPlayer::awardStat(Stat* stat,
const std::vector<uint8_t>& param) {
if (stat == nullptr) { if (stat == nullptr) {
return; return;
} }
@ -317,7 +305,8 @@ void MultiplayerLocalPlayer::awardStat(Stat* stat, const std::vector<uint8_t>& p
} }
} }
void MultiplayerLocalPlayer::awardStatFromServer(Stat* stat, std::vector<uint8_t>& param) { void MultiplayerLocalPlayer::awardStatFromServer(Stat* stat,
std::vector<uint8_t>& param) {
if (stat != nullptr && !stat->awardLocallyOnly) { if (stat != nullptr && !stat->awardLocallyOnly) {
LocalPlayer::awardStat(stat, param); LocalPlayer::awardStat(stat, param);
} }
@ -331,15 +320,13 @@ void MultiplayerLocalPlayer::onUpdateAbilities() {
bool MultiplayerLocalPlayer::isLocalPlayer() { return true; } bool MultiplayerLocalPlayer::isLocalPlayer() { return true; }
void MultiplayerLocalPlayer::sendRidingJump() { void MultiplayerLocalPlayer::sendRidingJump() {
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>(
shared_from_this(), PlayerCommandPacket::RIDING_JUMP, shared_from_this(), PlayerCommandPacket::RIDING_JUMP,
(int)(getJumpRidingScale() * 100.0f))); (int)(getJumpRidingScale() * 100.0f)));
} }
void MultiplayerLocalPlayer::sendOpenInventory() { void MultiplayerLocalPlayer::sendOpenInventory() {
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>(
shared_from_this(), PlayerCommandPacket::OPEN_INVENTORY)); shared_from_this(), PlayerCommandPacket::OPEN_INVENTORY));
} }
@ -371,8 +358,7 @@ void MultiplayerLocalPlayer::ride(std::shared_ptr<Entity> e) {
} }
void MultiplayerLocalPlayer::StopSleeping() { void MultiplayerLocalPlayer::StopSleeping() {
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>(
shared_from_this(), PlayerCommandPacket::STOP_SLEEPING)); shared_from_this(), PlayerCommandPacket::STOP_SLEEPING));
} }
@ -398,8 +384,7 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomCape(std::uint32_t capeId) {
customTextureUrl2.c_str()); customTextureUrl2.c_str());
#endif #endif
if (getCustomCape() != oldCapeIndex) if (getCustomCape() != oldCapeIndex)
connection->send( connection->send(std::make_shared<TextureChangePacket>(
std::make_shared<TextureChangePacket>(
shared_from_this(), TextureChangePacket::e_TextureChange_Cape, shared_from_this(), TextureChangePacket::e_TextureChange_Cape,
app.GetPlayerCapeName(GetXboxPad()))); app.GetPlayerCapeName(GetXboxPad())));
} }

View file

@ -20,8 +20,7 @@ void ReceivingLevelScreen::init() { buttons.clear(); }
void ReceivingLevelScreen::tick() { void ReceivingLevelScreen::tick() {
tickCount++; tickCount++;
if (tickCount % 20 == 0) { if (tickCount % 20 == 0) {
connection->send( connection->send(std::make_shared<KeepAlivePacket>());
std::make_shared<KeepAlivePacket>());
} }
if (connection != nullptr) { if (connection != nullptr) {
connection->tick(); connection->tick();

View file

@ -104,7 +104,8 @@ void FireworksParticles::FireworksStarter::tick() {
int type = compoundTag->getByte(FireworksItem::TAG_E_TYPE); int type = compoundTag->getByte(FireworksItem::TAG_E_TYPE);
bool trail = compoundTag->getBoolean(FireworksItem::TAG_E_TRAIL); bool trail = compoundTag->getBoolean(FireworksItem::TAG_E_TRAIL);
bool flicker = compoundTag->getBoolean(FireworksItem::TAG_E_FLICKER); bool flicker = compoundTag->getBoolean(FireworksItem::TAG_E_FLICKER);
std::vector<int> colors = compoundTag->getIntArray(FireworksItem::TAG_E_COLORS); std::vector<int> colors =
compoundTag->getIntArray(FireworksItem::TAG_E_COLORS);
std::vector<int> fadeColors = std::vector<int> fadeColors =
compoundTag->getIntArray(FireworksItem::TAG_E_FADECOLORS); compoundTag->getIntArray(FireworksItem::TAG_E_FADECOLORS);
@ -120,7 +121,8 @@ void FireworksParticles::FireworksStarter::tick() {
150.0 / 245.0, -197.0 / 245.0, 150.0 / 245.0, -197.0 / 245.0,
0.0, -88.0 / 245.0, 0.0, -88.0 / 245.0,
}; };
std::vector<std::vector<double>> coordsArray(6, std::vector<double>(2)); std::vector<std::vector<double>> coordsArray(
6, std::vector<double>(2));
for (unsigned int i = 0; i < coordsArray.size(); ++i) { for (unsigned int i = 0; i < coordsArray.size(); ++i) {
for (unsigned int j = 0; j < coordsArray[i].size(); ++j) { for (unsigned int j = 0; j < coordsArray[i].size(); ++j) {
coordsArray[i][j] = coords[i][j]; coordsArray[i][j] = coords[i][j];
@ -137,7 +139,8 @@ void FireworksParticles::FireworksStarter::tick() {
0.0, 0.2, 0.2, 0.2, 0.2, 0.6, 0.6, 0.6, 0.6, 0.2, 0.2, 0.2, 0.0, 0.2, 0.2, 0.2, 0.2, 0.6, 0.6, 0.6, 0.6, 0.2, 0.2, 0.2,
0.2, 0.0, 0.4, 0.0, 0.4, -0.6, 0.2, -0.6, 0.2, -0.4, 0.0, -0.4, 0.2, 0.0, 0.4, 0.0, 0.4, -0.6, 0.2, -0.6, 0.2, -0.4, 0.0, -0.4,
}; };
std::vector<std::vector<double>> coordsArray(12, std::vector<double>(2)); std::vector<std::vector<double>> coordsArray(
12, std::vector<double>(2));
for (unsigned int i = 0; i < coordsArray.size(); ++i) { for (unsigned int i = 0; i < coordsArray.size(); ++i) {
for (unsigned int j = 0; j < coordsArray[i].size(); ++j) { for (unsigned int j = 0; j < coordsArray[i].size(); ++j) {
coordsArray[i][j] = coords[i][j]; coordsArray[i][j] = coords[i][j];
@ -195,7 +198,8 @@ bool FireworksParticles::FireworksStarter::isFarAwayFromCamera() {
void FireworksParticles::FireworksStarter::createParticle( void FireworksParticles::FireworksStarter::createParticle(
double x, double y, double z, double xa, double ya, double za, double x, double y, double z, double xa, double ya, double za,
const std::vector<int>& rgbColors, const std::vector<int>& fadeColors, bool trail, bool flicker) { const std::vector<int>& rgbColors, const std::vector<int>& fadeColors,
bool trail, bool flicker) {
std::shared_ptr<FireworksSparkParticle> fireworksSparkParticle = std::shared_ptr<FireworksSparkParticle> fireworksSparkParticle =
std::shared_ptr<FireworksSparkParticle>( std::shared_ptr<FireworksSparkParticle>(
new FireworksSparkParticle(level, x, y, z, xa, ya, za, engine)); new FireworksSparkParticle(level, x, y, z, xa, ya, za, engine));
@ -213,8 +217,8 @@ void FireworksParticles::FireworksStarter::createParticle(
} }
void FireworksParticles::FireworksStarter::createParticleBall( void FireworksParticles::FireworksStarter::createParticleBall(
double baseSpeed, int steps, const std::vector<int>& rgbColors, const std::vector<int>& fadeColors, double baseSpeed, int steps, const std::vector<int>& rgbColors,
bool trail, bool flicker) { const std::vector<int>& fadeColors, bool trail, bool flicker) {
double xx = x; double xx = x;
double yy = y; double yy = y;
double zz = z; double zz = z;
@ -244,8 +248,9 @@ void FireworksParticles::FireworksStarter::createParticleBall(
} }
void FireworksParticles::FireworksStarter::createParticleShape( void FireworksParticles::FireworksStarter::createParticleShape(
double baseSpeed, std::vector<std::vector<double>> coords, const std::vector<int>& rgbColors, double baseSpeed, std::vector<std::vector<double>> coords,
const std::vector<int>& fadeColors, bool trail, bool flicker, bool flat) { const std::vector<int>& rgbColors, const std::vector<int>& fadeColors,
bool trail, bool flicker, bool flat) {
double sx = coords[0][0]; double sx = coords[0][0];
double sy = coords[0][1]; double sy = coords[0][1];
@ -285,7 +290,8 @@ void FireworksParticles::FireworksStarter::createParticleShape(
} }
void FireworksParticles::FireworksStarter::createParticleBurst( void FireworksParticles::FireworksStarter::createParticleBurst(
const std::vector<int>& rgbColors, const std::vector<int>& fadeColors, bool trail, bool flicker) { const std::vector<int>& rgbColors, const std::vector<int>& fadeColors,
bool trail, bool flicker) {
double baseOffX = random->nextGaussian() * .05; double baseOffX = random->nextGaussian() * .05;
double baseOffZ = random->nextGaussian() * .05; double baseOffZ = random->nextGaussian() * .05;

View file

@ -8,7 +8,8 @@
class ParticleEngine; class ParticleEngine;
class CompoundTag; class CompoundTag;
class Level; class Level;
template <class T> class ListTag; template <class T>
class ListTag;
class FireworksParticles { class FireworksParticles {
public: public:
@ -31,15 +32,21 @@ public:
virtual void tick(); virtual void tick();
bool isFarAwayFromCamera(); bool isFarAwayFromCamera();
void createParticle(double x, double y, double z, double xa, double ya, void createParticle(double x, double y, double z, double xa, double ya,
double za, const std::vector<int>& rgbColors, const std::vector<int>& fadeColors, double za, const std::vector<int>& rgbColors,
bool trail, bool flicker); const std::vector<int>& fadeColors, bool trail,
void createParticleBall(double baseSpeed, int steps, const std::vector<int>& rgbColors, bool flicker);
const std::vector<int>& fadeColors, bool trail, bool flicker); void createParticleBall(double baseSpeed, int steps,
void createParticleShape(double baseSpeed, std::vector<std::vector<double>> coords, const std::vector<int>& rgbColors,
const std::vector<int>& rgbColors, const std::vector<int>& fadeColors, const std::vector<int>& fadeColors, bool trail,
bool trail, bool flicker, bool flat); bool flicker);
void createParticleBurst(const std::vector<int>& rgbColors, const std::vector<int>& fadeColors, void createParticleShape(double baseSpeed,
bool trail, bool flicker); std::vector<std::vector<double>> coords,
const std::vector<int>& rgbColors,
const std::vector<int>& fadeColors, bool trail,
bool flicker, bool flat);
void createParticleBurst(const std::vector<int>& rgbColors,
const std::vector<int>& fadeColors, bool trail,
bool flicker);
public: public:
int getParticleTexture(); int getParticleTexture();

View file

@ -24,9 +24,10 @@ gMin = ( (cMin>>8)&0xFF )/255.0, bMin = ( cMin&0xFF )/255.0; double rMax = (
(cMax>>16)&0xFF )/255.0f, gMax = ( (cMax>>8)&0xFF )/255.0, bMax = ( cMax&0xFF (cMax>>16)&0xFF )/255.0f, gMax = ( (cMax>>8)&0xFF )/255.0, bMax = ( cMax&0xFF
)/255.0; )/255.0;
rCol = sinf(((float) xa + 0.0f / 3) * std::numbers::pi * 2) * (rMax - rMin) + rMin; rCol = sinf(((float) xa + 0.0f / 3) * std::numbers::pi * 2) * (rMax - rMin) +
gCol = sinf(((float) xa + 1.0f / 3) * std::numbers::pi * 2) * (gMax - gMin) + gMin; rMin; gCol = sinf(((float) xa + 1.0f / 3) * std::numbers::pi * 2) * (gMax -
bCol = sinf(((float) xa + 2.0f / 3) * std::numbers::pi * 2) * (bMax - bMin) + bMin; gMin) + gMin; bCol = sinf(((float) xa + 2.0f / 3) * std::numbers::pi * 2) *
(bMax - bMin) + bMin;
*/ */
// 4J-JEV: Added, // 4J-JEV: Added,

View file

@ -113,7 +113,8 @@ void Input::tick(LocalPlayer* player) {
} }
tx = ty = 0.0f; tx = ty = 0.0f;
} }
player->interpolateTurn(tx * std::abs(tx) * turnSpeed, ty * std::abs(ty) * turnSpeed); player->interpolateTurn(tx * std::abs(tx) * turnSpeed,
ty * std::abs(ty) * turnSpeed);
// jumping = controller.isButtonPressed(0); // jumping = controller.isButtonPressed(0);

View file

@ -154,7 +154,8 @@ void LocalPlayer::serverAiStep() {
// Don't bother for tiny inputs // Don't bother for tiny inputs
if (fMag >= 0.1f) { if (fMag >= 0.1f) {
// Get angle (in player rotated space) of input controls // Get angle (in player rotated space) of input controls
float yRotInput = atan2f(input->ya, input->xa) * (180.0f / std::numbers::pi); float yRotInput =
atan2f(input->ya, input->xa) * (180.0f / std::numbers::pi);
// Now get in world space // Now get in world space
float yRotFinal = yRotInput + yRot; float yRotFinal = yRotInput + yRot;
// Snap this to nearest 90 degrees // Snap this to nearest 90 degrees
@ -165,8 +166,10 @@ void LocalPlayer::serverAiStep() {
float yRotInputAdjust = yRotInput + yRotDiff; float yRotInputAdjust = yRotInput + yRotDiff;
// Calculate final x/y player-space movement required // Calculate final x/y player-space movement required
this->xxa = cos(yRotInputAdjust * (std::numbers::pi / 180.0f)) * fMag; this->xxa =
this->yya = sin(yRotInputAdjust * (std::numbers::pi / 180.0f)) * fMag; cos(yRotInputAdjust * (std::numbers::pi / 180.0f)) * fMag;
this->yya =
sin(yRotInputAdjust * (std::numbers::pi / 180.0f)) * fMag;
} else { } else {
this->xxa = input->xa; this->xxa = input->xa;
this->yya = input->ya; this->yya = input->ya;
@ -748,8 +751,7 @@ void LocalPlayer::magicCrit(std::shared_ptr<Entity> e) {
} }
void LocalPlayer::take(std::shared_ptr<Entity> e, int orgCount) { void LocalPlayer::take(std::shared_ptr<Entity> e, int orgCount) {
minecraft->particleEngine->add( minecraft->particleEngine->add(std::make_shared<TakeAnimationParticle>(
std::make_shared<TakeAnimationParticle>(
(Level*)minecraft->level, e, shared_from_this(), -0.5f)); (Level*)minecraft->level, e, shared_from_this(), -0.5f));
} }
@ -822,7 +824,6 @@ void LocalPlayer::awardStat(Stat* stat, const std::vector<uint8_t>& param) {
// players cannot get theme/avatar/gamerpic and Trial players cannot // players cannot get theme/avatar/gamerpic and Trial players cannot
// get any This causes some extreme flooding of some awards // get any This causes some extreme flooding of some awards
if (ProfileManager.CanBeAwarded(m_iPad, ach->getAchievementID())) { if (ProfileManager.CanBeAwarded(m_iPad, ach->getAchievementID())) {
// 4J Stu - Some awards cause a menu to popup. This can be bad, // 4J Stu - Some awards cause a menu to popup. This can be bad,
// especially if you are surrounded by mobs! We cannot pause the // especially if you are surrounded by mobs! We cannot pause the
// game unless in offline single player, but lets at least do it // game unless in offline single player, but lets at least do it

View file

@ -222,7 +222,6 @@ void Chunk::makeCopyForRebuild(Chunk* source) {
} }
void Chunk::rebuild() { void Chunk::rebuild() {
// if (!dirty) return; // if (!dirty) return;
#if defined(_LARGE_WORLDS) #if defined(_LARGE_WORLDS)
@ -257,8 +256,6 @@ void Chunk::rebuild() {
2; 2;
lists += levelRenderer->chunkLists; lists += levelRenderer->chunkLists;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 4J - optimisation begins. // 4J - optimisation begins.
@ -275,9 +272,12 @@ void Chunk::rebuild() {
#endif #endif
std::vector<uint8_t> tileArray(16 * 16 * Level::maxBuildHeight); std::vector<uint8_t> tileArray(16 * 16 * Level::maxBuildHeight);
level->getChunkAt(x, z)->getBlockData(tileArray); level->getChunkAt(x, z)->getBlockData(tileArray);
memcpy(tileIds, tileArray.data(), 16 * 16 * Level::maxBuildHeight); // 4J - TODO - now our data has been re-arranged, we could memcpy(
// just extra the vertical slice of this chunk rather than tileIds, tileArray.data(),
// the whole thing 16 * 16 * Level::maxBuildHeight); // 4J - TODO - now our data has been
// re-arranged, we could just extra
// the vertical slice of this chunk
// rather than the whole thing
LevelSource* region = LevelSource* region =
new Region(level, x0 - r, y0 - r, z0 - r, x1 + r, y1 + r, z1 + r, r); new Region(level, x0 - r, y0 - r, z0 - r, x1 + r, y1 + r, z1 + r, r);
@ -546,8 +546,6 @@ void Chunk::rebuild() {
delete tileRenderer; delete tileRenderer;
delete region; delete region;
// 4J - have rewritten the way that tile entities are stored globally to // 4J - have rewritten the way that tile entities are stored globally to
// make it work more easily with split screen. Chunks are now stored // make it work more easily with split screen. Chunks are now stored
// globally in the levelrenderer, in a hashmap with a special key made up // globally in the levelrenderer, in a hashmap with a special key made up
@ -558,7 +556,6 @@ void Chunk::rebuild() {
reconcileRenderableTileEntities(renderableTileEntities); reconcileRenderableTileEntities(renderableTileEntities);
} }
// 4J - These removed items are now also removed from // 4J - These removed items are now also removed from
// globalRenderableTileEntities // globalRenderableTileEntities

View file

@ -11,8 +11,7 @@ EntityTileRenderer::EntityTileRenderer() {
chest = std::make_shared<ChestTileEntity>(); chest = std::make_shared<ChestTileEntity>();
trappedChest = std::shared_ptr<ChestTileEntity>( trappedChest = std::shared_ptr<ChestTileEntity>(
new ChestTileEntity(ChestTile::TYPE_TRAP)); new ChestTileEntity(ChestTile::TYPE_TRAP));
enderChest = enderChest = std::make_shared<EnderChestTileEntity>();
std::make_shared<EnderChestTileEntity>();
} }
void EntityTileRenderer::render(Tile* tile, int data, float brightness, void EntityTileRenderer::render(Tile* tile, int data, float brightness,

View file

@ -256,7 +256,6 @@ void GameRenderer::tick(bool first) // 4J - add bFirst
tickRain(); tickRain();
darkenWorldAmountO = darkenWorldAmount; darkenWorldAmountO = darkenWorldAmount;
if (BossMobGuiInfo::darkenWorld) { if (BossMobGuiInfo::darkenWorld) {
darkenWorldAmount += darkenWorldAmount +=
@ -459,7 +458,8 @@ void GameRenderer::bobView(float a) {
glTranslatef((float)sinf(b * std::numbers::pi) * bob * 0.5f, glTranslatef((float)sinf(b * std::numbers::pi) * bob * 0.5f,
-(float)std::abs(cosf(b * std::numbers::pi) * bob), 0); -(float)std::abs(cosf(b * std::numbers::pi) * bob), 0);
glRotatef((float)sinf(b * std::numbers::pi) * bob * 3, 0, 0, 1); glRotatef((float)sinf(b * std::numbers::pi) * bob * 3, 0, 0, 1);
glRotatef((float)std::abs(cosf(b * std::numbers::pi - 0.2f) * bob) * 5, 1, 0, 0); glRotatef((float)std::abs(cosf(b * std::numbers::pi - 0.2f) * bob) * 5, 1,
0, 0);
glRotatef((float)tilt, 1, 0, 0); glRotatef((float)tilt, 1, 0, 0);
} }
@ -530,10 +530,10 @@ void GameRenderer::moveCameraToPlayer(float a) {
xRot += 180.0f; xRot += 180.0f;
} }
double xd = -sinf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi) * double xd = -sinf(yRot / 180 * std::numbers::pi) *
cameraDist; cosf(xRot / 180 * std::numbers::pi) * cameraDist;
double zd = cosf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi) * double zd = cosf(yRot / 180 * std::numbers::pi) *
cameraDist; cosf(xRot / 180 * std::numbers::pi) * cameraDist;
double yd = -sinf(xRot / 180 * std::numbers::pi) * cameraDist; double yd = -sinf(xRot / 180 * std::numbers::pi) * cameraDist;
for (int i = 0; i < 8; i++) { for (int i = 0; i < 8; i++) {
@ -1288,7 +1288,6 @@ void GameRenderer::renderLevel(float a, int64_t until) {
mc->levelRenderer->cull(frustum, a); mc->levelRenderer->cull(frustum, a);
} }
#if !defined(MULTITHREAD_ENABLE) #if !defined(MULTITHREAD_ENABLE)
if ((i == 0) && updateChunks) // 4J - added updateChunks condition if ((i == 0) && updateChunks) // 4J - added updateChunks condition
{ {
@ -1305,7 +1304,6 @@ void GameRenderer::renderLevel(float a, int64_t until) {
if (diff < 0) break; if (diff < 0) break;
if (diff > 1000000000) break; if (diff > 1000000000) break;
} while (true); } while (true);
} }
#endif #endif
@ -1325,7 +1323,6 @@ void GameRenderer::renderLevel(float a, int64_t until) {
Lighting::turnOff(); Lighting::turnOff();
levelRenderer->render(cameraEntity, 0, a, updateChunks); levelRenderer->render(cameraEntity, 0, a, updateChunks);
GL11::glShadeModel(GL11::GL_FLAT); GL11::glShadeModel(GL11::GL_FLAT);
if (cameraFlip == 0) { if (cameraFlip == 0) {
@ -1412,13 +1409,11 @@ void GameRenderer::renderLevel(float a, int64_t until) {
updateChunks); // 4J - chanaged, used to be updateChunks); // 4J - chanaged, used to be
// renderSameAsLast but we don't support // renderSameAsLast but we don't support
// that anymore // that anymore
} }
GL11::glShadeModel(GL11::GL_FLAT); GL11::glShadeModel(GL11::GL_FLAT);
} else { } else {
levelRenderer->render(cameraEntity, 1, a, updateChunks); levelRenderer->render(cameraEntity, 1, a, updateChunks);
} }
// 4J - added - have split out translucent particle rendering so that it // 4J - added - have split out translucent particle rendering so that it
@ -1557,11 +1552,9 @@ void GameRenderer::tickRain() {
float za = random->nextFloat(); float za = random->nextFloat();
if (t > 0) { if (t > 0) {
if (Tile::tiles[t]->material == Material::lava) { if (Tile::tiles[t]->material == Material::lava) {
mc->particleEngine->add( mc->particleEngine->add(std::make_shared<SmokeParticle>(
std::make_shared<SmokeParticle>( level, x + xa, y + 0.1f - Tile::tiles[t]->getShapeY0(),
level, x + xa, z + za, 0, 0, 0));
y + 0.1f - Tile::tiles[t]->getShapeY0(), z + za, 0,
0, 0));
} else { } else {
if (random->nextInt(++rainPosSamples) == 0) { if (random->nextInt(++rainPosSamples) == 0) {
rainPosX = x + xa; rainPosX = x + xa;
@ -1867,8 +1860,8 @@ void GameRenderer::setupClearColor(float a) {
fb = (float)fogColor.z; fb = (float)fogColor.z;
if (mc->options->viewDistance < 2) { if (mc->options->viewDistance < 2) {
Vec3 sunAngle = sinf(level->getSunAngle(a)) > 0 ? Vec3(-1, 0, 0) Vec3 sunAngle =
: Vec3(1, 0, 0); sinf(level->getSunAngle(a)) > 0 ? Vec3(-1, 0, 0) : Vec3(1, 0, 0);
float d = (float)player->getViewVector(a).dot(sunAngle); float d = (float)player->getViewVector(a).dot(sunAngle);
if (d < 0) d = 0; if (d < 0) d = 0;
if (d > 0) { if (d > 0) {

View file

@ -501,7 +501,8 @@ void ItemInHandRenderer::render(float a) {
float swing1 = sinf(swing * std::numbers::pi); float swing1 = sinf(swing * std::numbers::pi);
float swing2 = sinf((sqrt(swing)) * std::numbers::pi); float swing2 = sinf((sqrt(swing)) * std::numbers::pi);
glTranslatef(-swing2 * 0.4f, sinf(sqrt(swing) * std::numbers::pi * 2) * 0.2f, glTranslatef(-swing2 * 0.4f,
sinf(sqrt(swing) * std::numbers::pi * 2) * 0.2f,
-swing1 * 0.2f); -swing1 * 0.2f);
} }
@ -601,7 +602,6 @@ void ItemInHandRenderer::render(float a) {
minimap->render(minecraft->player, minecraft->textures, data, minimap->render(minecraft->player, minecraft->textures, data,
minecraft->player->entityId); minecraft->player->entityId);
glPopMatrix(); glPopMatrix();
} else if (item != nullptr) { } else if (item != nullptr) {
glPushMatrix(); glPushMatrix();
@ -635,7 +635,8 @@ void ItemInHandRenderer::render(float a) {
float swing1 = sinf(swing * std::numbers::pi); float swing1 = sinf(swing * std::numbers::pi);
float swing2 = sinf((sqrt(swing)) * std::numbers::pi); float swing2 = sinf((sqrt(swing)) * std::numbers::pi);
glTranslatef(-swing2 * 0.4f, sinf(sqrt(swing) * std::numbers::pi * 2) * 0.2f, glTranslatef(-swing2 * 0.4f,
sinf(sqrt(swing) * std::numbers::pi * 2) * 0.2f,
-swing1 * 0.2f); -swing1 * 0.2f);
} }
@ -673,9 +674,9 @@ void ItemInHandRenderer::render(float a) {
pow = ((pow * pow) + pow * 2) / 3; pow = ((pow * pow) + pow * 2) / 3;
if (pow > 1) pow = 1; if (pow > 1) pow = 1;
if (pow > 0.1f) { if (pow > 0.1f) {
glTranslatef(0, glTranslatef(
sinf((timeHeld - 0.1f) * 1.3f) * 0.01f * 0,
(pow - 0.1f), sinf((timeHeld - 0.1f) * 1.3f) * 0.01f * (pow - 0.1f),
0); 0);
} }
glTranslatef(0, 0, pow * 0.1f); glTranslatef(0, 0, pow * 0.1f);
@ -721,7 +722,8 @@ void ItemInHandRenderer::render(float a) {
float swing1 = sinf(swing * std::numbers::pi); float swing1 = sinf(swing * std::numbers::pi);
float swing2 = sinf((sqrt(swing)) * std::numbers::pi); float swing2 = sinf((sqrt(swing)) * std::numbers::pi);
glTranslatef(-swing2 * 0.3f, sinf(sqrt(swing) * std::numbers::pi * 2) * 0.4f, glTranslatef(-swing2 * 0.3f,
sinf(sqrt(swing) * std::numbers::pi * 2) * 0.4f,
-swing1 * 0.4f); -swing1 * 0.4f);
} }

View file

@ -981,8 +981,8 @@ void LevelRenderer::renderSky(float alpha) {
{ {
glRotatef(90, 1, 0, 0); glRotatef(90, 1, 0, 0);
glRotatef( glRotatef(
sinf(level[playerIndex]->getSunAngle(alpha)) < 0 ? 180 : 0, sinf(level[playerIndex]->getSunAngle(alpha)) < 0 ? 180 : 0, 0,
0, 0, 1); 0, 1);
glRotatef(90, 0, 0, 1); glRotatef(90, 0, 0, 1);
float r = c[0]; float r = c[0];
@ -1934,7 +1934,6 @@ bool LevelRenderer::updateDirtyChunks() {
} }
// app.DebugPrintf("[%d,%d,%d]\n",nearestClipChunks.empty(),considered,wouldBeNearButEmpty); // app.DebugPrintf("[%d,%d,%d]\n",nearestClipChunks.empty(),considered,wouldBeNearButEmpty);
} }
} }
} }
@ -2127,8 +2126,7 @@ void LevelRenderer::renderHit(std::shared_ptr<Player> player, HitResult* h,
glBlendFunc(GL_SRC_ALPHA, GL_ONE); glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glColor4f( glColor4f(
1, 1, 1, 1, 1, 1,
((float)(sinf(Minecraft::currentTimeMillis() / 100.0f)) * 0.2f + ((float)(sinf(Minecraft::currentTimeMillis() / 100.0f)) * 0.2f + 0.4f) *
0.4f) *
0.5f); 0.5f);
if (mode != 0 && inventoryItem != nullptr) { if (mode != 0 && inventoryItem != nullptr) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -2391,7 +2389,6 @@ void LevelRenderer::setDirty(int x0, int y0, int z0, int x1, int y1, int z1,
dirtyChunksLockFreeStack.Push( dirtyChunksLockFreeStack.Push(
(int*)(intptr_t)(uintptr_t)(index + 2)); (int*)(intptr_t)(uintptr_t)(index + 2));
#endif #endif
} }
// setGlobalChunkFlag(x * 16, y * // setGlobalChunkFlag(x * 16, y *
// 16, z * 16, level, CHUNK_FLAG_DIRTY); // 16, z * 16, level, CHUNK_FLAG_DIRTY);
@ -3113,8 +3110,7 @@ std::shared_ptr<Particle> LevelRenderer::addParticleInternal(
new FlameParticle(lev, x, y, z, xa, ya, za)); new FlameParticle(lev, x, y, z, xa, ya, za));
break; break;
case eParticleType_lava: case eParticleType_lava:
particle = particle = std::make_shared<LavaParticle>(lev, x, y, z);
std::make_shared<LavaParticle>(lev, x, y, z);
break; break;
case eParticleType_footstep: case eParticleType_footstep:
particle = std::shared_ptr<Particle>( particle = std::shared_ptr<Particle>(
@ -3349,7 +3345,8 @@ void LevelRenderer::levelEvent(std::shared_ptr<Player> source, int type, int x,
random->nextDouble() * 0.2, random->nextDouble() * 0.2,
random->nextGaussian() * .15); random->nextGaussian() * .15);
} }
for (double a = 0; a < std::numbers::pi * 2.0; a += std::numbers::pi * 0.05) { for (double a = 0; a < std::numbers::pi * 2.0;
a += std::numbers::pi * 0.05) {
addParticle(eParticleType_ender, xp + cos(a) * 5, yp - .4, addParticle(eParticleType_ender, xp + cos(a) * 5, yp - .4,
zp + sin(a) * 5, cos(a) * -5, 0, sin(a) * -5); zp + sin(a) * 5, cos(a) * -5, 0, sin(a) * -5);
addParticle(eParticleType_ender, xp + cos(a) * 5, yp - .4, addParticle(eParticleType_ender, xp + cos(a) * 5, yp - .4,

View file

@ -271,7 +271,8 @@ public:
int veryNearCount); // For chunk rebuilding to inform the manager int veryNearCount); // For chunk rebuilding to inform the manager
// that a chunk (a 16x16x16 tile render chunk) // that a chunk (a 16x16x16 tile render chunk)
// has been updated // has been updated
void addAABBs(Level* level, AABB* box, void addAABBs(
Level* level, AABB* box,
std::vector<AABB>* boxes); // For game to get any AABBs that the std::vector<AABB>* boxes); // For game to get any AABBs that the
// user should be colliding with as // user should be colliding with as
// render data has not yet been updated // render data has not yet been updated

View file

@ -105,7 +105,8 @@ void Tesselator::end() {
if (mode == GL_QUADS && TRIANGLE_MODE) { if (mode == GL_QUADS && TRIANGLE_MODE) {
// glDrawArrays(GL_TRIANGLES, 0, vertices); // 4J - changed for xbox // glDrawArrays(GL_TRIANGLES, 0, vertices); // 4J - changed for xbox
RenderManager.DrawVertices( RenderManager.DrawVertices(
C4JRender::PRIMITIVE_TYPE_TRIANGLE_LIST, vertices, _array->data(), C4JRender::PRIMITIVE_TYPE_TRIANGLE_LIST, vertices,
_array->data(),
useCompactFormat360 useCompactFormat360
? C4JRender::VERTEX_TYPE_COMPRESSED ? C4JRender::VERTEX_TYPE_COMPRESSED
: C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, : C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1,
@ -122,8 +123,8 @@ void Tesselator::end() {
int vertexCount = vertices; int vertexCount = vertices;
if (useCompactFormat360) { if (useCompactFormat360) {
RenderManager.DrawVertices( RenderManager.DrawVertices(
(C4JRender::ePrimitiveType)mode, vertexCount, _array->data(), (C4JRender::ePrimitiveType)mode, vertexCount,
C4JRender::VERTEX_TYPE_COMPRESSED, _array->data(), C4JRender::VERTEX_TYPE_COMPRESSED,
C4JRender::PIXEL_SHADER_TYPE_STANDARD); C4JRender::PIXEL_SHADER_TYPE_STANDARD);
} else { } else {
if (useProjectedTexturePixelShader) { if (useProjectedTexturePixelShader) {

View file

@ -383,7 +383,8 @@ std::vector<int> Textures::loadTexturePixels(BufferedImage* img) {
return loadTexturePixels(img, pixels); return loadTexturePixels(img, pixels);
} }
std::vector<int> Textures::loadTexturePixels(BufferedImage* img, std::vector<int>& pixels) { std::vector<int> Textures::loadTexturePixels(BufferedImage* img,
std::vector<int>& pixels) {
int w = img->getWidth(); int w = img->getWidth();
int h = img->getHeight(); int h = img->getHeight();
img->getRGB(0, 0, w, h, pixels, 0, w); img->getRGB(0, 0, w, h, pixels, 0, w);
@ -461,7 +462,8 @@ void Textures::bindTextureLayers(ResourceLocation* resource) {
continue; continue;
} }
std::wstring resourceName = std::wstring(preLoaded[textureName]) + L".png"; std::wstring resourceName =
std::wstring(preLoaded[textureName]) + L".png";
BufferedImage* image = readImage(textureName, resourceName); BufferedImage* image = readImage(textureName, resourceName);
if (image == nullptr) { if (image == nullptr) {
continue; continue;
@ -513,7 +515,6 @@ void Textures::bindTextureLayers(ResourceLocation* resource) {
(outA << 24) | (outR << 16) | (outG << 8) | outB; (outA << 24) | (outR << 16) | (outG << 8) | outB;
} }
} }
} }
if (hasMergedPixels) { if (hasMergedPixels) {
@ -729,7 +730,6 @@ void Textures::loadTexture(BufferedImage* img, int id, bool blur, bool clamp) {
pixels->put(newPixels); pixels->put(newPixels);
pixels->position(0)->limit(newPixels.size()); pixels->position(0)->limit(newPixels.size());
if (MIPMAP) { if (MIPMAP) {
// 4J-PB - In the new XDK, the CreateTexture will fail if the number of // 4J-PB - In the new XDK, the CreateTexture will fail if the number of
// mipmaps is higher than the width & height passed in will allow! // mipmaps is higher than the width & height passed in will allow!
@ -827,11 +827,11 @@ std::vector<int> Textures::anaglyph(std::vector<int>& rawPixels) {
result[i] = a << 24 | rr << 16 | gg << 8 | bb; result[i] = a << 24 | rr << 16 | gg << 8 | bb;
} }
return result; return result;
} }
void Textures::replaceTexture(std::vector<int>& rawPixels, int w, int h, int id) { void Textures::replaceTexture(std::vector<int>& rawPixels, int w, int h,
int id) {
bind(id); bind(id);
// Removed in Java // Removed in Java
@ -887,7 +887,8 @@ void Textures::replaceTexture(std::vector<int>& rawPixels, int w, int h, int id)
// 4J - added. This is a more minimal version of replaceTexture that assumes the // 4J - added. This is a more minimal version of replaceTexture that assumes the
// texture bytes are already in order, and so doesn't do any of the extra // texture bytes are already in order, and so doesn't do any of the extra
// copying round that the original java version does // copying round that the original java version does
void Textures::replaceTextureDirect(const std::vector<int>& rawPixels, int w, int h, int id) { void Textures::replaceTextureDirect(const std::vector<int>& rawPixels, int w,
int h, int id) {
glBindTexture(GL_TEXTURE_2D, id); glBindTexture(GL_TEXTURE_2D, id);
// Remove in Java // Remove in Java
@ -899,14 +900,15 @@ void Textures::replaceTextureDirect(const std::vector<int>& rawPixels, int w, in
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
RenderManager.TextureDataUpdate(0, 0, w, h, const_cast<int*>(rawPixels.data()), 0); RenderManager.TextureDataUpdate(0, 0, w, h,
const_cast<int*>(rawPixels.data()), 0);
} }
// 4J - added. This is a more minimal version of replaceTexture that assumes the // 4J - added. This is a more minimal version of replaceTexture that assumes the
// texture bytes are already in order, and so doesn't do any of the extra // texture bytes are already in order, and so doesn't do any of the extra
// copying round that the original java version does // copying round that the original java version does
void Textures::replaceTextureDirect(const std::vector<short>& rawPixels, int w, int h, void Textures::replaceTextureDirect(const std::vector<short>& rawPixels, int w,
int id) { int h, int id) {
glBindTexture(GL_TEXTURE_2D, id); glBindTexture(GL_TEXTURE_2D, id);
// Remove in Java // Remove in Java
@ -918,7 +920,8 @@ void Textures::replaceTextureDirect(const std::vector<short>& rawPixels, int w,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
RenderManager.TextureDataUpdate(0, 0, w, h, const_cast<short*>(rawPixels.data()), 0); RenderManager.TextureDataUpdate(0, 0, w, h,
const_cast<short*>(rawPixels.data()), 0);
} }
void Textures::releaseTexture(int id) { void Textures::releaseTexture(int id) {

View file

@ -309,7 +309,8 @@ public:
private: private:
std::vector<int> loadTexturePixels(BufferedImage* img); std::vector<int> loadTexturePixels(BufferedImage* img);
std::vector<int> loadTexturePixels(BufferedImage* img, std::vector<int>& pixels); std::vector<int> loadTexturePixels(BufferedImage* img,
std::vector<int>& pixels);
void setTextureFormat(const std::wstring& resourceName); // 4J added void setTextureFormat(const std::wstring& resourceName); // 4J added
public: public:
@ -331,9 +332,9 @@ private:
public: public:
int loadTexture(int idx); // 4J added int loadTexture(int idx); // 4J added
int getTexture( int getTexture(BufferedImage* img,
BufferedImage* img, IPlatformRender::eTextureFormat format =
IPlatformRender::eTextureFormat format = IPlatformRender::TEXTURE_FORMAT_RxGyBzAw, IPlatformRender::TEXTURE_FORMAT_RxGyBzAw,
bool mipmap = true); bool mipmap = true);
void loadTexture(BufferedImage* img, int id); void loadTexture(BufferedImage* img, int id);
void loadTexture(BufferedImage* img, int id, bool blur, bool clamp); void loadTexture(BufferedImage* img, int id, bool blur, bool clamp);

View file

@ -800,7 +800,8 @@ bool TileRenderer::tesselateBrewingStandInWorld(BrewingStandTile* tt, int x,
int data = level->getData(x, y, z); int data = level->getData(x, y, z);
for (int arm = 0; arm < 3; arm++) { for (int arm = 0; arm < 3; arm++) {
float angle = arm * std::numbers::pi * 2.0f / 3.0f + std::numbers::pi * 0.5f; float angle =
arm * std::numbers::pi * 2.0f / 3.0f + std::numbers::pi * 0.5f;
float u0 = tex->getU(8, true); float u0 = tex->getU(8, true);
float u1 = tex->getU1(true); float u1 = tex->getU1(true);
@ -2056,10 +2057,14 @@ bool TileRenderer::tesselateTripwireSourceInWorld(Tile* tt, int x, int y,
corners[i].xRot(90 * std::numbers::pi / 180); corners[i].xRot(90 * std::numbers::pi / 180);
if (dir == Direction::NORTH) corners[i].yRot(0 * std::numbers::pi / 180); if (dir == Direction::NORTH)
if (dir == Direction::SOUTH) corners[i].yRot(180 * std::numbers::pi / 180); corners[i].yRot(0 * std::numbers::pi / 180);
if (dir == Direction::WEST) corners[i].yRot(90 * std::numbers::pi / 180); if (dir == Direction::SOUTH)
if (dir == Direction::EAST) corners[i].yRot(-90 * std::numbers::pi / 180); corners[i].yRot(180 * std::numbers::pi / 180);
if (dir == Direction::WEST)
corners[i].yRot(90 * std::numbers::pi / 180);
if (dir == Direction::EAST)
corners[i].yRot(-90 * std::numbers::pi / 180);
corners[i].x += x + 0.5; corners[i].x += x + 0.5;
corners[i].y += y + 5 / 16.0f; corners[i].y += y + 5 / 16.0f;
@ -2145,10 +2150,14 @@ bool TileRenderer::tesselateTripwireSourceInWorld(Tile* tt, int x, int y,
corners[i].xRot(50 * std::numbers::pi / 180); corners[i].xRot(50 * std::numbers::pi / 180);
} }
if (dir == Direction::NORTH) corners[i].yRot(0 * std::numbers::pi / 180); if (dir == Direction::NORTH)
if (dir == Direction::SOUTH) corners[i].yRot(180 * std::numbers::pi / 180); corners[i].yRot(0 * std::numbers::pi / 180);
if (dir == Direction::WEST) corners[i].yRot(90 * std::numbers::pi / 180); if (dir == Direction::SOUTH)
if (dir == Direction::EAST) corners[i].yRot(-90 * std::numbers::pi / 180); corners[i].yRot(180 * std::numbers::pi / 180);
if (dir == Direction::WEST)
corners[i].yRot(90 * std::numbers::pi / 180);
if (dir == Direction::EAST)
corners[i].yRot(-90 * std::numbers::pi / 180);
corners[i].x += x + 0.5; corners[i].x += x + 0.5;
corners[i].y += y + 5 / 16.0f; corners[i].y += y + 5 / 16.0f;

View file

@ -11,8 +11,10 @@ ViewportCuller::Face::Face(double x, double y, double z, float yRot,
this->yc = y; this->yc = y;
this->zc = z; this->zc = z;
xd = sinf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi); xd = sinf(yRot / 180 * std::numbers::pi) *
zd = -cosf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi); cosf(xRot / 180 * std::numbers::pi);
zd = -cosf(yRot / 180 * std::numbers::pi) *
cosf(xRot / 180 * std::numbers::pi);
yd = -sinf(xRot / 180 * std::numbers::pi); yd = -sinf(xRot / 180 * std::numbers::pi);
cullOffs = xc * xd + yc * yd + zc * zd; cullOffs = xc * xd + yc * yd + zc * zd;
@ -59,8 +61,10 @@ ViewportCuller::ViewportCuller(std::shared_ptr<LivingEntity> mob,
double y = mob->yOld + (mob->y - mob->yOld) * a; double y = mob->yOld + (mob->y - mob->yOld) * a;
double z = mob->zOld + (mob->z - mob->zOld) * a; double z = mob->zOld + (mob->z - mob->zOld) * a;
double xd = sinf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi); double xd = sinf(yRot / 180 * std::numbers::pi) *
double zd = -cosf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi); cosf(xRot / 180 * std::numbers::pi);
double zd = -cosf(yRot / 180 * std::numbers::pi) *
cosf(xRot / 180 * std::numbers::pi);
double yd = -sinf(xRot / 180 * std::numbers::pi); double yd = -sinf(xRot / 180 * std::numbers::pi);
float xFov = 30; float xFov = 30;

View file

@ -34,8 +34,7 @@ void BoatRenderer::render(std::shared_ptr<Entity> _boat, double x, double y,
float dmg = boat->getDamage() - a; float dmg = boat->getDamage() - a;
if (dmg < 0) dmg = 0; if (dmg < 0) dmg = 0;
if (hurt > 0) { if (hurt > 0) {
glRotatef(sinf(hurt) * hurt * dmg / 10 * boat->getHurtDir(), 1, 0, glRotatef(sinf(hurt) * hurt * dmg / 10 * boat->getHurtDir(), 1, 0, 0);
0);
} }
float ss = 12 / 16.0f; float ss = 12 / 16.0f;

Some files were not shown because too many files have changed in this diff Show more