diff --git a/minecraft/Minecraft.Client/Common/Source Files/Audio/SoundEngine.cpp b/minecraft/Minecraft.Client/Common/Source Files/Audio/SoundEngine.cpp index d1d23b288..e60952c88 100644 --- a/minecraft/Minecraft.Client/Common/Source Files/Audio/SoundEngine.cpp +++ b/minecraft/Minecraft.Client/Common/Source Files/Audio/SoundEngine.cpp @@ -5,7 +5,7 @@ #include "../../../net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.h" #include "Minecraft.World/net/minecraft/world/level/net.minecraft.world.level.h" #include "Minecraft.World/net/minecraft/world/level/storage/LevelData.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "../../../net/minecraft/client/skins/TexturePackRepository.h" #include "../../../net/minecraft/client/skins/DLCTexturePack.h" #include "../DLC/DLCAudioFile.h" @@ -733,8 +733,8 @@ void SoundEngine::tick(shared_ptr* players, float a) { float yRot = players[i]->yRotO + (players[i]->yRot - players[i]->yRotO) * a; - float yCos = (float)cos(yRot * Mth::RAD_TO_GRAD); - float ySin = (float)sin(yRot * Mth::RAD_TO_GRAD); + float yCos = (float)cos(yRot * GameMath::DEG_TO_RAD); + float ySin = (float)sin(yRot * GameMath::DEG_TO_RAD); // store the listener positions for splitscreen m_ListenerA[i].vPosition.x = x; @@ -1111,8 +1111,8 @@ void SoundEngine::tick(std::shared_ptr* players, float a) { float yRot = players[i]->yRotO + (players[i]->yRot - players[i]->yRotO) * a; - float yCos = (float)cos(-yRot * Mth::RAD_TO_GRAD - M_PI); - float ySin = (float)sin(-yRot * Mth::RAD_TO_GRAD - M_PI); + float yCos = (float)cos(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); + float ySin = (float)sin(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); // store the listener positions for splitscreen m_ListenerA[i].vPosition.x = x; diff --git a/minecraft/Minecraft.Client/Common/Source Files/UI/Controls/UIControl_PlayerSkinPreview.cpp b/minecraft/Minecraft.Client/Common/Source Files/UI/Controls/UIControl_PlayerSkinPreview.cpp index df9579734..95d621c7f 100644 --- a/minecraft/Minecraft.Client/Common/Source Files/UI/Controls/UIControl_PlayerSkinPreview.cpp +++ b/minecraft/Minecraft.Client/Common/Source Files/UI/Controls/UIControl_PlayerSkinPreview.cpp @@ -373,8 +373,8 @@ void UIControl_PlayerSkinPreview::render(EntityRenderer* renderer, double x, float yr = 1; // mob->yBodyRotO + (mob->yBodyRot - mob->yBodyRotO) * a; - double xa = sin(yr * M_PI / 180); - double za = -cos(yr * M_PI / 180); + double xa = sin(yr * std::numbers::pi / 180); + double za = -cos(yr * std::numbers::pi / 180); float flap = (float)yd * 10; if (flap < -6) flap = -6; diff --git a/minecraft/Minecraft.Client/Common/Source Files/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp b/minecraft/Minecraft.Client/Common/Source Files/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp index dc5f4d9a6..5d7207626 100644 --- a/minecraft/Minecraft.Client/Common/Source Files/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp +++ b/minecraft/Minecraft.Client/Common/Source Files/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "Minecraft.World/ConsoleHelpers/StringHelpers.h" #include "java/Random.h" #include "../../../../../net/minecraft/client/User.h" @@ -347,8 +347,8 @@ void UIScene_MainMenu::customDrawSplash(IggyCustomDrawCallbackRegion* region) { glTranslatef(xo, yo, 0); glRotatef(-17, 0, 0, 1); - float sss = 1.8f - Mth::abs(Mth::sin(System::currentTimeMillis() % 1000 / - 1000.0f * M_PI * 2) * + float sss = 1.8f - GameMath::abs(sinf(System::currentTimeMillis() % 1000 / + 1000.0f * std::numbers::pi * 2) * 0.1f); sss *= (m_fScreenWidth / m_fRawWidth); diff --git a/minecraft/Minecraft.Client/Source Files/glWrapper.cpp b/minecraft/Minecraft.Client/Source Files/glWrapper.cpp index c7151fd30..fbfe6f3c4 100644 --- a/minecraft/Minecraft.Client/Source Files/glWrapper.cpp +++ b/minecraft/Minecraft.Client/Source Files/glWrapper.cpp @@ -16,7 +16,7 @@ void glTranslatef(float x, float y, float z) { } void glRotatef(float angle, float x, float y, float z) { - RenderManager.MatrixRotate(angle * (M_PI / 180.0f), x, y, z); + RenderManager.MatrixRotate(angle * (std::numbers::pi / 180.0f), x, y, z); } void glPopMatrix() { RenderManager.MatrixPop(); } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/Camera.cpp b/minecraft/Minecraft.Client/net/minecraft/client/Camera.cpp index b1ff5c0d2..1dbc8bdbc 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/Camera.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/Camera.cpp @@ -63,12 +63,12 @@ zPlayerOffs = position->get(2); float xRot = player->xRot; float yRot = player->yRot; - xa = cosf(yRot * M_PI / 180.0f) * (1 - flipCamera * 2); - za = sinf(yRot * M_PI / 180.0f) * (1 - flipCamera * 2); + xa = cosf(yRot * std::numbers::pi / 180.0f) * (1 - flipCamera * 2); + za = sinf(yRot * std::numbers::pi / 180.0f) * (1 - flipCamera * 2); - xa2 = -za * sinf(xRot * M_PI / 180.0f) * (1 - flipCamera * 2); - za2 = xa * sinf(xRot * M_PI / 180.0f) * (1 - flipCamera * 2); - ya = cosf(xRot * M_PI / 180.0f); + xa2 = -za * sinf(xRot * std::numbers::pi / 180.0f) * (1 - flipCamera * 2); + za2 = xa * sinf(xRot * std::numbers::pi / 180.0f) * (1 - flipCamera * 2); + ya = cosf(xRot * std::numbers::pi / 180.0f); } TilePos* Camera::getCameraTilePos(std::shared_ptr player, diff --git a/minecraft/Minecraft.Client/net/minecraft/client/Minecraft.cpp b/minecraft/Minecraft.Client/net/minecraft/client/Minecraft.cpp index 5a07931b2..623874bcf 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/Minecraft.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/Minecraft.cpp @@ -3559,9 +3559,9 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { // Level::animateTickDoWork() so we can take into account multiple // players in the one level. if (!pause && levels[i] != nullptr) - levels[i]->animateTick(Mth::floor(player->x), - Mth::floor(player->y), - Mth::floor(player->z)); + levels[i]->animateTick(GameMath::floor(player->x), + GameMath::floor(player->y), + GameMath::floor(player->z)); if (levelsTickedFlags & (1 << i)) continue; // Don't tick further if we've already ticked this diff --git a/minecraft/Minecraft.Client/net/minecraft/client/gui/Gui.cpp b/minecraft/Minecraft.Client/net/minecraft/client/gui/Gui.cpp index ed85f4abe..78415e6d8 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/gui/Gui.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/gui/Gui.cpp @@ -489,7 +489,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { double totalAbsorption = minecraft->localplayers[iPad]->getAbsorptionAmount(); int NUM_HEARTS_PER_ROW = 10; // 4jcraft: missing definition - int numHealthRows = Mth::ceil((maxHealth + totalAbsorption) / + int numHealthRows = GameMath::ceil((maxHealth + totalAbsorption) / 2 / (float)NUM_HEARTS_PER_ROW); int healthRowHeight = max(10 - (numHealthRows - 2), 3); yLine2 = yLine1 - (numHealthRows - 1) * healthRowHeight - 10; @@ -516,7 +516,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { } // minecraft.profiler.popPush("health"); - for (int i = Mth::ceil((maxHealth + totalAbsorption) / 2) - 1; + for (int i = GameMath::ceil((maxHealth + totalAbsorption) / 2) - 1; i >= 0; i--) { int healthTexBaseX = 16; if (minecraft->player->hasEffect(MobEffect::poison)) { @@ -529,7 +529,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { int bg = 0; if (blink) bg = 1; int rowIndex = - Mth::ceil((i + 1) / (float)NUM_HEARTS_PER_ROW) - 1; + GameMath::ceil((i + 1) / (float)NUM_HEARTS_PER_ROW) - 1; int xo = xLeft + (i % NUM_HEARTS_PER_ROW) * 8; int yo = yLine1 - rowIndex * healthRowHeight; if (currentHealth <= 4) { @@ -1010,15 +1010,15 @@ max) + "% (" + (total / 1024 / 1024) + "MB)"; drawString(font, msg, screenWidth font, L"f: " + _toString( - Mth::floor(minecraft->player->yRot * 4.0f / 360.0f + 0.5) & + GameMath::floor(minecraft->player->yRot * 4.0f / 360.0f + 0.5) & 0x3) + L"/ yRot: " + _toString(minecraft->player->yRot), iSafezoneXHalf + 2, iYPos + 8 * 3, 0xe0e0e0); iYPos += 8 * 4; - int px = Mth::floor(minecraft->player->x); - int py = Mth::floor(minecraft->player->y); - int pz = Mth::floor(minecraft->player->z); + int px = GameMath::floor(minecraft->player->x); + int py = GameMath::floor(minecraft->player->y); + int pz = GameMath::floor(minecraft->player->z); if (minecraft->level != nullptr && minecraft->level->hasChunkAt(px, py, pz)) { LevelChunk* chunkAt = minecraft->level->getChunkAt(px, pz); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/gui/PauseScreen.cpp b/minecraft/Minecraft.Client/net/minecraft/client/gui/PauseScreen.cpp index 54f8bf607..aeccaa1b7 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/gui/PauseScreen.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/gui/PauseScreen.cpp @@ -110,7 +110,7 @@ void PauseScreen::render(int xm, int ym, float a) { bool isSaving = false; //! minecraft->level->pauseSave(saveStep++); if (isSaving || visibleTime < 20) { float col = ((visibleTime % 10) + a) / 10.0f; - col = Mth::sin(col * M_PI * 2) * 0.2f + 0.8f; + col = sinf(col * std::numbers::pi * 2) * 0.2f + 0.8f; int br = (int)(255 * col); drawString(font, L"Saving level..", 8, height - 16, diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/BatModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/BatModel.cpp index da9ea2acc..3e5acb73f 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/BatModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/BatModel.cpp @@ -61,25 +61,25 @@ void BatModel::render(std::shared_ptr entity, float time, float r, bool usecompiled) { std::shared_ptr bat = std::dynamic_pointer_cast(entity); if (bat->isResting()) { - float rad = 180 / M_PI; + float rad = 180 / std::numbers::pi; head->xRot = xRot / rad; - head->yRot = M_PI - yRot / rad; - head->zRot = M_PI; + head->yRot = std::numbers::pi - yRot / rad; + head->zRot = std::numbers::pi; head->setPos(0, -2, 0); rightWing->setPos(-3, 0, 3); leftWing->setPos(3, 0, 3); - body->xRot = M_PI; + body->xRot = std::numbers::pi; - rightWing->xRot = -M_PI * .05f; - rightWing->yRot = -M_PI * .40f; - rightWingTip->yRot = -M_PI * .55f; + rightWing->xRot = -std::numbers::pi * .05f; + rightWing->yRot = -std::numbers::pi * .40f; + rightWingTip->yRot = -std::numbers::pi * .55f; leftWing->xRot = rightWing->xRot; leftWing->yRot = -rightWing->yRot; leftWingTip->yRot = -rightWingTip->yRot; } else { - float rad = 180 / M_PI; + float rad = 180 / std::numbers::pi; head->xRot = xRot / rad; head->yRot = yRot / rad; head->zRot = 0; @@ -88,10 +88,10 @@ void BatModel::render(std::shared_ptr entity, float time, float r, rightWing->setPos(0, 0, 0); leftWing->setPos(0, 0, 0); - body->xRot = M_PI * .25f + cos(bob * .1f) * .15f; + body->xRot = std::numbers::pi * .25f + cos(bob * .1f) * .15f; body->yRot = 0; - rightWing->yRot = cos(bob * 1.3f) * M_PI * .25f; + rightWing->yRot = cos(bob * 1.3f) * std::numbers::pi * .25f; leftWing->yRot = -rightWing->yRot; rightWingTip->yRot = rightWing->yRot * .5f; leftWingTip->yRot = -rightWing->yRot * .5f; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/BlazeModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/BlazeModel.cpp index 0e1be6311..27138d2fc 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/BlazeModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/BlazeModel.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "BlazeModel.h" #include "geom/ModelPart.h" @@ -40,29 +40,29 @@ void BlazeModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, std::shared_ptr entity, unsigned int uiBitmaskOverrideAnim) { - float angle = bob * M_PI * -.1f; + float angle = bob * std::numbers::pi * -.1f; for (int i = 0; i < 4; i++) { - upperBodyParts[i]->y = -2 + Mth::cos((i * 2 + bob) * .25f); - upperBodyParts[i]->x = Mth::cos(angle) * 9.0f; - upperBodyParts[i]->z = Mth::sin(angle) * 9.0f; - angle += M_PI * 0.5f; + upperBodyParts[i]->y = -2 + cosf((i * 2 + bob) * .25f); + upperBodyParts[i]->x = cosf(angle) * 9.0f; + upperBodyParts[i]->z = sinf(angle) * 9.0f; + angle += std::numbers::pi * 0.5f; } - angle = .25f * M_PI + bob * M_PI * .03f; + angle = .25f * std::numbers::pi + bob * std::numbers::pi * .03f; for (int i = 4; i < 8; i++) { - upperBodyParts[i]->y = 2 + Mth::cos((i * 2 + bob) * .25f); - upperBodyParts[i]->x = Mth::cos(angle) * 7.0f; - upperBodyParts[i]->z = Mth::sin(angle) * 7.0f; - angle += M_PI * 0.5f; + upperBodyParts[i]->y = 2 + cosf((i * 2 + bob) * .25f); + upperBodyParts[i]->x = cosf(angle) * 7.0f; + upperBodyParts[i]->z = sinf(angle) * 7.0f; + angle += std::numbers::pi * 0.5f; } - angle = .15f * M_PI + bob * M_PI * -.05f; + angle = .15f * std::numbers::pi + bob * std::numbers::pi * -.05f; for (int i = 8; i < 12; i++) { - upperBodyParts[i]->y = 11 + Mth::cos((i * 1.5f + bob) * .5f); - upperBodyParts[i]->x = Mth::cos(angle) * 5.0f; - upperBodyParts[i]->z = Mth::sin(angle) * 5.0f; - angle += M_PI * 0.5f; + upperBodyParts[i]->y = 11 + cosf((i * 1.5f + bob) * .5f); + upperBodyParts[i]->x = cosf(angle) * 5.0f; + upperBodyParts[i]->z = sinf(angle) * 5.0f; + angle += std::numbers::pi * 0.5f; } - head->yRot = yRot / (float)(180 / M_PI); - head->xRot = xRot / (float)(180 / M_PI); + head->yRot = yRot / (float)(180 / std::numbers::pi); + head->xRot = xRot / (float)(180 / std::numbers::pi); } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/BoatModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/BoatModel.cpp index 5ff6edb22..f2c7b1327 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/BoatModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/BoatModel.cpp @@ -28,10 +28,10 @@ BoatModel::BoatModel() : Model() { cubes[4]->addBox((float)(-w / 2 + 2), (float)(-d - 1), -1, w - 4, d, 2, 0); cubes[4]->setPos(0, (float)(0 + yOff), (float)(+h / 2 - 1)); - cubes[0]->xRot = M_PI / 2; - cubes[1]->yRot = M_PI / 2 * 3; - cubes[2]->yRot = M_PI / 2 * 1; - cubes[3]->yRot = M_PI / 2 * 2; + cubes[0]->xRot = std::numbers::pi / 2; + cubes[1]->yRot = std::numbers::pi / 2 * 3; + cubes[2]->yRot = std::numbers::pi / 2 * 1; + cubes[3]->yRot = std::numbers::pi / 2 * 2; // 4J added - compile now to avoid random performance hit first time cubes // are rendered diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/BookModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/BookModel.cpp index e0b1dc449..c28b07971 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/BookModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/BookModel.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "BookModel.h" #include "geom/ModelPart.h" @@ -30,7 +30,7 @@ BookModel::BookModel() { leftLid->setPos(0, 0, -1); rightLid->setPos(0, 0, 1); - seam->yRot = M_PI / 2; + seam->yRot = std::numbers::pi / 2; // 4J added - compile now to avoid random performance hit first time cubes // are rendered @@ -63,9 +63,9 @@ void BookModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, std::shared_ptr entity, unsigned int uiBitmaskOverrideAnim) { - float openness = (Mth::sin(time * 0.02f) * 0.10f + 1.25f) * yRot; + float openness = (sinf(time * 0.02f) * 0.10f + 1.25f) * yRot; - leftLid->yRot = M_PI + openness; + leftLid->yRot = std::numbers::pi + openness; rightLid->yRot = -openness; leftPages->yRot = +openness; rightPages->yRot = -openness; @@ -73,8 +73,8 @@ void BookModel::setupAnim(float time, float r, float bob, float yRot, flipPage1->yRot = +openness - openness * 2 * r; flipPage2->yRot = +openness - openness * 2 * bob; - leftPages->x = Mth::sin(openness); - rightPages->x = Mth::sin(openness); - flipPage1->x = Mth::sin(openness); - flipPage2->x = Mth::sin(openness); + leftPages->x = sinf(openness); + rightPages->x = sinf(openness); + flipPage1->x = sinf(openness); + flipPage2->x = sinf(openness); } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/ChickenModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/ChickenModel.cpp index e05e2b3a5..987576c8c 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/ChickenModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/ChickenModel.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "ChickenModel.h" #include "geom/ModelPart.h" @@ -86,8 +86,8 @@ void ChickenModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, std::shared_ptr entity, unsigned int uiBitmaskOverrideAnim) { - head->xRot = xRot / (float)(180 / M_PI); - head->yRot = yRot / (float)(180 / M_PI); + head->xRot = xRot / (float)(180 / std::numbers::pi); + head->yRot = yRot / (float)(180 / std::numbers::pi); beak->xRot = head->xRot; beak->yRot = head->yRot; @@ -95,10 +95,10 @@ void ChickenModel::setupAnim(float time, float r, float bob, float yRot, redThing->xRot = head->xRot; redThing->yRot = head->yRot; - body->xRot = 90 / (float)(180 / M_PI); + body->xRot = 90 / (float)(180 / std::numbers::pi); - leg0->xRot = (Mth::cos(time * 0.6662f) * 1.4f) * r; - leg1->xRot = (Mth::cos(time * 0.6662f + M_PI) * 1.4f) * r; + leg0->xRot = (cosf(time * 0.6662f) * 1.4f) * r; + leg1->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 1.4f) * r; wing0->zRot = bob; wing1->zRot = -bob; } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/CreeperModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/CreeperModel.cpp index 92d0bcae0..3e02a17ff 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/CreeperModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/CreeperModel.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "CreeperModel.h" #include "geom/ModelPart.h" @@ -67,11 +67,11 @@ void CreeperModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, std::shared_ptr entity, unsigned int uiBitmaskOverrideAnim) { - head->yRot = yRot / (float)(180 / M_PI); - head->xRot = xRot / (float)(180 / M_PI); + head->yRot = yRot / (float)(180 / std::numbers::pi); + head->xRot = xRot / (float)(180 / std::numbers::pi); - leg0->xRot = (Mth::cos(time * 0.6662f) * 1.4f) * r; - leg1->xRot = (Mth::cos(time * 0.6662f + M_PI) * 1.4f) * r; - leg2->xRot = (Mth::cos(time * 0.6662f + M_PI) * 1.4f) * r; - leg3->xRot = (Mth::cos(time * 0.6662f) * 1.4f) * r; + leg0->xRot = (cosf(time * 0.6662f) * 1.4f) * r; + leg1->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 1.4f) * r; + leg2->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 1.4f) * r; + leg3->xRot = (cosf(time * 0.6662f) * 1.4f) * r; } \ No newline at end of file diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/GhastModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/GhastModel.cpp index 92b9ca1ae..bc99db9c4 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/GhastModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/GhastModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "java/Random.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "GhastModel.h" #include "geom/ModelPart.h" @@ -39,7 +39,7 @@ void GhastModel::setupAnim(float time, float r, float bob, float yRot, unsigned int uiBitmaskOverrideAnim) { for (int i = 0; i < TENTACLESLENGTH; i++) // 4J - 9 was tentacles.size() { - tentacles[i]->xRot = 0.2f * Mth::sin(bob * 0.3f + i) + 0.4f; + tentacles[i]->xRot = 0.2f * sinf(bob * 0.3f + i) + 0.4f; } } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/HumanoidModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/HumanoidModel.cpp index 977892b09..301b4b477 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/HumanoidModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/HumanoidModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "HumanoidModel.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "Minecraft.World/net/minecraft/world/entity/Entity.h" #include "geom/ModelPart.h" @@ -196,8 +196,8 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, // bool bIsAttacking = (attackTime > -9990.0f); { - head->yRot = yRot / (float)(180.0f / M_PI); - head->xRot = xRot / (float)(180.0f / M_PI); + head->yRot = yRot / (float)(180.0f / std::numbers::pi); + head->xRot = xRot / (float)(180.0f / std::numbers::pi); hair->yRot = head->yRot; hair->xRot = head->xRot; body->z = 0.0f; @@ -216,8 +216,8 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, arm0->zRot = 0.0f; arm1->zRot = 0.0f; } else if (uiBitmaskOverrideAnim & (1 << eAnim_SingleArms)) { - arm0->xRot = (Mth::cos(time * 0.6662f + M_PI) * 2.0f) * r * 0.5f; - arm1->xRot = (Mth::cos(time * 0.6662f + M_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 + std::numbers::pi) * 2.0f) * r * 0.5f; arm0->zRot = 0.0f; arm1->zRot = 0.0f; } @@ -225,13 +225,13 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, // that's up else if ((uiBitmaskOverrideAnim & (1 << eAnim_StatueOfLiberty)) && (holdingRightHand == 0) && (attackTime == 0.0f)) { - arm0->xRot = -M_PI ; + arm0->xRot = -std::numbers::pi ; arm0->zRot = -0.3f; - arm1->xRot = (Mth::cos(time * 0.6662f) * 2.0f) * r * 0.5f; + arm1->xRot = (cosf(time * 0.6662f) * 2.0f) * r * 0.5f; arm1->zRot = 0.0f; } else { - arm0->xRot = (Mth::cos(time * 0.6662f + M_PI) * 2.0f) * r * 0.5f; - arm1->xRot = (Mth::cos(time * 0.6662f) * 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; arm0->zRot = 0.0f; arm1->zRot = 0.0f; } @@ -271,11 +271,11 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, leg0->yRot = 0.0f; leg1->yRot = 0.0f; } else if (uiBitmaskOverrideAnim & (1 << eAnim_SingleLegs)) { - leg0->xRot = (Mth::cos(time * 0.6662f) * 1.4f) * r; - leg1->xRot = (Mth::cos(time * 0.6662f) * 1.4f) * r; + leg0->xRot = (cosf(time * 0.6662f) * 1.4f) * r; + leg1->xRot = (cosf(time * 0.6662f) * 1.4f) * r; } else { - leg0->xRot = (Mth::cos(time * 0.6662f) * 1.4f) * r; - leg1->xRot = (Mth::cos(time * 0.6662f + M_PI) * 1.4f) * r; + leg0->xRot = (cosf(time * 0.6662f) * 1.4f) * r; + leg1->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 1.4f) * r; } if (holdingLeftHand != 0) { @@ -289,11 +289,11 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, arm1->yRot = 0.0f; if (attackTime > -9990.0f) { float swing = attackTime; - body->yRot = Mth::sin(sqrt(swing) * M_PI * 2.0f) * 0.2f; - arm0->z = Mth::sin(body->yRot) * 5.0f; - arm0->x = -Mth::cos(body->yRot) * 5.0f; - arm1->z = -Mth::sin(body->yRot) * 5.0f; - arm1->x = Mth::cos(body->yRot) * 5.0f; + body->yRot = sinf(sqrt(swing) * std::numbers::pi * 2.0f) * 0.2f; + arm0->z = sinf(body->yRot) * 5.0f; + arm0->x = -cosf(body->yRot) * 5.0f; + arm1->z = -sinf(body->yRot) * 5.0f; + arm1->x = cosf(body->yRot) * 5.0f; arm0->yRot += body->yRot; arm1->yRot += body->yRot; arm1->xRot += body->yRot; @@ -302,16 +302,16 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, swing *= swing; swing *= swing; swing = 1.0f - swing; - float aa = Mth::sin(swing * M_PI); - float bb = Mth::sin(attackTime * M_PI) * -(head->xRot - 0.7f) * 0.75f; + float aa = sinf(swing * std::numbers::pi); + 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->yRot += body->yRot * 2.0f; if ((uiBitmaskOverrideAnim & (1 << eAnim_StatueOfLiberty)) && (holdingRightHand == 0) && (attackTime == 0.0f)) { - arm0->zRot -= Mth::sin(attackTime * M_PI) * -0.4f; + arm0->zRot -= sinf(attackTime * std::numbers::pi) * -0.4f; } else { - arm0->zRot = Mth::sin(attackTime * M_PI) * -0.4f; + arm0->zRot = sinf(attackTime * std::numbers::pi) * -0.4f; } } @@ -324,7 +324,7 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, is = is * is * is; is = is * is * is; float iss = 1 - is; - arm0->xRot = -Mth::abs(Mth::cos(eating_t / 4.0f * M_PI) * 0.1f) * + arm0->xRot = -GameMath::abs(cosf(eating_t / 4.0f * std::numbers::pi) * 0.1f) * (eating_swing > 0.2 ? 1.0f : 0.0f) * 2.0f; // This factor is the chomping bit (conditional // factor is so that he doesn't eat whilst the @@ -400,10 +400,10 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, } } - arm0->zRot += ((Mth::cos(bob * 0.09f)) * 0.05f + 0.05f); - arm1->zRot -= ((Mth::cos(bob * 0.09f)) * 0.05f + 0.05f); - arm0->xRot += ((Mth::sin(bob * 0.067f)) * 0.05f); - arm1->xRot -= ((Mth::sin(bob * 0.067f)) * 0.05f); + arm0->zRot += ((cosf(bob * 0.09f)) * 0.05f + 0.05f); + arm1->zRot -= ((cosf(bob * 0.09f)) * 0.05f + 0.05f); + arm0->xRot += ((sinf(bob * 0.067f)) * 0.05f); + arm1->xRot -= ((sinf(bob * 0.067f)) * 0.05f); if (bowAndArrow) { float attack2 = 0.0f; @@ -417,10 +417,10 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, arm1->xRot = -M_PI_2 + head->xRot; arm0->xRot -= attack2 * 1.2f - attack * 0.4f; arm1->xRot -= attack2 * 1.2f - attack * 0.4f; - arm0->zRot += ((float)(Mth::cos(bob * 0.09f)) * 0.05f + 0.05f); - arm1->zRot -= ((float)(Mth::cos(bob * 0.09f)) * 0.05f + 0.05f); - arm0->xRot += ((float)(Mth::sin(bob * 0.067f)) * 0.05f); - arm1->xRot -= ((float)(Mth::sin(bob * 0.067f)) * 0.05f); + arm0->zRot += ((float)(cosf(bob * 0.09f)) * 0.05f + 0.05f); + arm1->zRot -= ((float)(cosf(bob * 0.09f)) * 0.05f + 0.05f); + arm0->xRot += ((float)(sinf(bob * 0.067f)) * 0.05f); + arm1->xRot -= ((float)(sinf(bob * 0.067f)) * 0.05f); } } } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/LavaSlimeModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/LavaSlimeModel.cpp index 9a8d6c0d9..9fc6c140f 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/LavaSlimeModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/LavaSlimeModel.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "LavaSlimeModel.h" #include "geom/ModelPart.h" #include "Minecraft.World/net/minecraft/world/entity/monster/LavaSlime.h" diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/LeashKnotModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/LeashKnotModel.cpp index fe00c4620..aee2acf53 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/LeashKnotModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/LeashKnotModel.cpp @@ -30,6 +30,6 @@ void LeashKnotModel::setupAnim(float time, float r, float bob, float yRot, unsigned int uiBitmaskOverrideAnim) { Model::setupAnim(time, r, bob, yRot, xRot, scale, entity); - knot->yRot = yRot / (180 / M_PI); - knot->xRot = xRot / (180 / M_PI); + knot->yRot = yRot / (180 / std::numbers::pi); + knot->xRot = xRot / (180 / std::numbers::pi); } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/MinecartModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/MinecartModel.cpp index cb976a263..7d0b2df80 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/MinecartModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/MinecartModel.cpp @@ -34,11 +34,11 @@ MinecartModel::MinecartModel() : Model() { cubes[4]->addBox((float)(-w / 2 + 2), (float)(-d - 1), -1, w - 4, d, 2, 0); cubes[4]->setPos(0, (float)(0 + yOff), (float)(+h / 2 - 1)); - cubes[0]->xRot = M_PI / 2; - cubes[1]->yRot = M_PI / 2 * 3; - cubes[2]->yRot = M_PI / 2 * 1; - cubes[3]->yRot = M_PI / 2 * 2; - cubes[5]->xRot = -M_PI / 2; + cubes[0]->xRot = std::numbers::pi / 2; + cubes[1]->yRot = std::numbers::pi / 2 * 3; + cubes[2]->yRot = std::numbers::pi / 2 * 1; + cubes[3]->yRot = std::numbers::pi / 2 * 2; + cubes[5]->xRot = -std::numbers::pi / 2; // 4J added - compile now to avoid random performance hit first time cubes // are rendered diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/ModelHorse.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/ModelHorse.cpp index 1a278b18f..c1ebd5d01 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/ModelHorse.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/ModelHorse.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "Minecraft.World/net/minecraft/world/entity/animal/net.minecraft.world.entity.animal.h" #include "ModelHorse.h" #include "geom/ModelPart.h" @@ -450,7 +450,7 @@ void ModelHorse::prepareMobModel(std::shared_ptr mob, float wp, // animations { // TODO: Magic numbers - Head->xRot = standing * ((15 * Mth::DEGRAD) + (HeadXRot)) + + Head->xRot = standing * ((15 * GameMath::DEG_TO_RAD) + (HeadXRot)) + eating * 2.18166f + (1.0f - std::max(standing, eating)) * Head->xRot; Head->yRot = standing * (headRotMinusBodyRot / 57.29578f) + @@ -491,8 +491,8 @@ void ModelHorse::prepareMobModel(std::shared_ptr mob, float wp, MuleEarL->xRot = Head->xRot; MuleEarR->xRot = Head->xRot; Neck->xRot = Head->xRot; - UMouth->xRot = 0 - (M_PI * .03f) * openMouth; - LMouth->xRot = 0 + (M_PI * .05f) * openMouth; + UMouth->xRot = 0 - (std::numbers::pi * .03f) * openMouth; + LMouth->xRot = 0 + (std::numbers::pi * .05f) * openMouth; Mane->xRot = Head->xRot; @@ -513,11 +513,11 @@ void ModelHorse::prepareMobModel(std::shared_ptr mob, float wp, * knee joints Leg1 and Leg4 use LLegXRot Leg2 and Leg3 use RLegXRot */ { - float r90 = M_PI * .5f; - float r270 = M_PI * 1.5f; - float r300 = -60 * Mth::DEGRAD; - float standAngle = 15 * Mth::DEGRAD * standing; - float bobValue = Mth::cos((bob * 0.6f) + 3.141593f); + float r90 = std::numbers::pi * .5f; + float r270 = std::numbers::pi * 1.5f; + float r300 = -60 * GameMath::DEG_TO_RAD; + float standAngle = 15 * GameMath::DEG_TO_RAD * standing; + float bobValue = cosf((bob * 0.6f) + 3.141593f); Leg3A->y = -2.f * standing + 9.f * iStanding; Leg3A->z = -2.f * standing + -8.f * iStanding; @@ -526,55 +526,55 @@ void ModelHorse::prepareMobModel(std::shared_ptr mob, float wp, Leg1B->y = Leg1A->y + - (Mth::sin(r90 + standAngle + iStanding * (-legAnim1 * 0.5f * ws)) * + (sinf(r90 + standAngle + iStanding * (-legAnim1 * 0.5f * ws)) * 7.f); Leg1B->z = Leg1A->z + - (Mth::cos(r270 + standAngle + iStanding * (-legAnim1 * 0.5f * ws)) * + (cosf(r270 + standAngle + iStanding * (-legAnim1 * 0.5f * ws)) * 7.f); Leg2B->y = Leg2A->y + - (Mth::sin(r90 + standAngle + iStanding * (legAnim1 * 0.5f * ws)) * + (sinf(r90 + standAngle + iStanding * (legAnim1 * 0.5f * ws)) * 7.f); Leg2B->z = Leg2A->z + - (Mth::cos(r270 + standAngle + iStanding * (legAnim1 * 0.5f * ws)) * + (cosf(r270 + standAngle + iStanding * (legAnim1 * 0.5f * ws)) * 7.f); float rlegRot = (r300 + bobValue) * standing + legXRotAnim * iStanding; float llegRot = (r300 + -bobValue) * standing + -legXRotAnim * iStanding; - Leg3B->y = Leg3A->y + (Mth::sin(r90 + rlegRot) * 7.f); - Leg3B->z = Leg3A->z + (Mth::cos(r270 + rlegRot) * 7.f); + Leg3B->y = Leg3A->y + (sinf(r90 + rlegRot) * 7.f); + Leg3B->z = Leg3A->z + (cosf(r270 + rlegRot) * 7.f); - Leg4B->y = Leg4A->y + (Mth::sin(r90 + llegRot) * 7.f); - Leg4B->z = Leg4A->z + (Mth::cos(r270 + llegRot) * 7.f); + Leg4B->y = Leg4A->y + (sinf(r90 + llegRot) * 7.f); + Leg4B->z = Leg4A->z + (cosf(r270 + llegRot) * 7.f); Leg1A->xRot = standAngle + (-legAnim1 * 0.5f * ws) * iStanding; Leg1B->xRot = - (-5 * Mth::DEGRAD) * standing + + (-5 * GameMath::DEG_TO_RAD) * standing + ((-legAnim1 * 0.5f * ws) - std::max(0.0f, legAnim1 * .5f * ws)) * iStanding; Leg1C->xRot = Leg1B->xRot; Leg2A->xRot = standAngle + (legAnim1 * 0.5f * ws) * iStanding; Leg2B->xRot = - (-5 * Mth::DEGRAD) * standing + + (-5 * GameMath::DEG_TO_RAD) * standing + ((legAnim1 * 0.5f * ws) - std::max(0.0f, -legAnim1 * .5f * ws)) * iStanding; Leg2C->xRot = Leg2B->xRot; Leg3A->xRot = rlegRot; Leg3B->xRot = - (Leg3A->xRot + M_PI * std::max(0.0f, (.2f + bobValue * .2f))) * + (Leg3A->xRot + std::numbers::pi * std::max(0.0f, (.2f + bobValue * .2f))) * standing + (legXRotAnim + std::max(0.0f, legAnim1 * 0.5f * ws)) * iStanding; Leg3C->xRot = Leg3B->xRot; Leg4A->xRot = llegRot; Leg4B->xRot = - (Leg4A->xRot + M_PI * std::max(0.0f, (.2f - bobValue * .2f))) * + (Leg4A->xRot + std::numbers::pi * std::max(0.0f, (.2f - bobValue * .2f))) * standing + (-legXRotAnim + std::max(0.0f, -legAnim1 * 0.5f * ws)) * iStanding; Leg4C->xRot = Leg4B->xRot; @@ -667,7 +667,7 @@ void ModelHorse::prepareMobModel(std::shared_ptr mob, float wp, } if (tail) { - TailA->yRot = Mth::cos(bob * 0.7f); + TailA->yRot = cosf(bob * 0.7f); tailMov = 0; } else { TailA->yRot = 0.f; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/OcelotModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/OcelotModel.cpp index b89b83ddd..1fd47b162 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/OcelotModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/OcelotModel.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "geom/ModelPart.h" #include "Minecraft.World/net/minecraft/world/entity/animal/net.minecraft.world.entity.animal.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "OcelotModel.h" const float OcelotModel::xo = 0; @@ -147,29 +147,29 @@ void OcelotModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, std::shared_ptr entity, unsigned int uiBitmaskOverrideAnim) { - head->xRot = xRot / (float)(180 / M_PI); - head->yRot = yRot / (float)(180 / M_PI); + head->xRot = xRot / (float)(180 / std::numbers::pi); + head->yRot = yRot / (float)(180 / std::numbers::pi); if (state == SITTING_STATE) { } else { - body->xRot = 90 / (float)(180 / M_PI); + body->xRot = 90 / (float)(180 / std::numbers::pi); if (state == SPRINT_STATE) { - backLegL->xRot = ((float)Mth::cos(time * 0.6662f) * 1.f) * r; - backLegR->xRot = ((float)Mth::cos(time * 0.6662f + 0.3f) * 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; frontLegL->xRot = - ((float)Mth::cos(time * 0.6662f + M_PI + 0.3f) * 1.f) * r; - frontLegR->xRot = ((float)Mth::cos(time * 0.6662f + M_PI) * 1.f) * r; - tail2->xRot = 0.55f * M_PI + 0.1f * M_PI * Mth::cos(time) * r; + ((float)cosf(time * 0.6662f + std::numbers::pi + 0.3f) * 1.f) * 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 { - backLegL->xRot = ((float)Mth::cos(time * 0.6662f) * 1.f) * r; - backLegR->xRot = ((float)Mth::cos(time * 0.6662f + M_PI) * 1.f) * r; - frontLegL->xRot = ((float)Mth::cos(time * 0.6662f + M_PI) * 1.f) * r; - frontLegR->xRot = ((float)Mth::cos(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; + frontLegL->xRot = ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r; + frontLegR->xRot = ((float)cosf(time * 0.6662f) * 1.f) * r; if (state == WALK_STATE) - tail2->xRot = 0.55f * M_PI + 0.25f * M_PI * Mth::cos(time) * r; + tail2->xRot = 0.55f * std::numbers::pi + 0.25f * std::numbers::pi * cosf(time) * r; else - tail2->xRot = 0.55f * M_PI + 0.15f * M_PI * Mth::cos(time) * r; + tail2->xRot = 0.55f * std::numbers::pi + 0.15f * std::numbers::pi * cosf(time) * r; } } } @@ -198,17 +198,17 @@ void OcelotModel::prepareMobModel(std::shared_ptr mob, float time, tail1->y += 1; tail2->y += -4; tail2->z += 2; - tail1->xRot = 0.5f * M_PI; - tail2->xRot = 0.5f * M_PI; + tail1->xRot = 0.5f * std::numbers::pi; + tail2->xRot = 0.5f * std::numbers::pi; state = SNEAK_STATE; } else if (ozelot->isSprinting()) { tail2->y = tail1->y; tail2->z += 2; - tail1->xRot = 0.5f * M_PI; - tail2->xRot = 0.5f * M_PI; + tail1->xRot = 0.5f * std::numbers::pi; + tail2->xRot = 0.5f * std::numbers::pi; state = SPRINT_STATE; } else if (ozelot->isSitting()) { - body->xRot = 45 / (float)(180 / M_PI); + body->xRot = 45 / (float)(180 / std::numbers::pi); body->y += -4; body->z += 5; head->y += -3.3f; @@ -218,14 +218,14 @@ void OcelotModel::prepareMobModel(std::shared_ptr mob, float time, tail1->z += -2; tail2->y += 2; tail2->z += -0.8f; - tail1->xRot = M_PI * 0.55f; - tail2->xRot = M_PI * 0.85f; + tail1->xRot = std::numbers::pi * 0.55f; + tail2->xRot = std::numbers::pi * 0.85f; - frontLegL->xRot = frontLegR->xRot = -M_PI * 0.05f; + frontLegL->xRot = frontLegR->xRot = -std::numbers::pi * 0.05f; frontLegL->y = frontLegR->y = frontLegY + 2; frontLegL->z = frontLegR->z = -7; - backLegL->xRot = backLegR->xRot = -M_PI * 0.5f; + backLegL->xRot = backLegR->xRot = -std::numbers::pi * 0.5f; backLegL->y = backLegR->y = backLegY + 3; backLegL->z = backLegR->z = backLegZ - 4; state = SITTING_STATE; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/QuadrupedModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/QuadrupedModel.cpp index 8f46e1568..325e89fe2 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/QuadrupedModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/QuadrupedModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "QuadrupedModel.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "geom/ModelPart.h" QuadrupedModel::QuadrupedModel(int legSize, float g) : Model() { @@ -75,15 +75,15 @@ void QuadrupedModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, std::shared_ptr entity, unsigned int uiBitmaskOverrideAnim) { - float rad = (float)(180 / M_PI); + float rad = (float)(180 / std::numbers::pi); head->xRot = xRot / rad; head->yRot = yRot / rad; body->xRot = 90 / rad; - leg0->xRot = (Mth::cos(time * 0.6662f) * 1.4f) * r; - leg1->xRot = (Mth::cos(time * 0.6662f + M_PI) * 1.4f) * r; - leg2->xRot = (Mth::cos(time * 0.6662f + M_PI) * 1.4f) * r; - leg3->xRot = (Mth::cos(time * 0.6662f) * 1.4f) * r; + leg0->xRot = (cosf(time * 0.6662f) * 1.4f) * r; + leg1->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 1.4f) * r; + leg2->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 1.4f) * r; + leg3->xRot = (cosf(time * 0.6662f) * 1.4f) * r; } void QuadrupedModel::render(QuadrupedModel* model, float scale, diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/SilverfishModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/SilverfishModel.cpp index 51471cd46..f3740510b 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/SilverfishModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/SilverfishModel.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "SilverfishModel.h" #include "geom/Cube.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "geom/ModelPart.h" const int SilverfishModel::BODY_SIZES[BODY_COUNT][3] = { @@ -71,10 +71,10 @@ void SilverfishModel::setupAnim(float time, float r, float bob, float yRot, std::shared_ptr entity, unsigned int uiBitmaskOverrideAnim) { for (unsigned int i = 0; i < bodyParts.size(); i++) { - bodyParts[i]->yRot = Mth::cos(bob * .9f + i * .15f * M_PI) * M_PI * .05f * + bodyParts[i]->yRot = cosf(bob * .9f + i * .15f * std::numbers::pi) * std::numbers::pi * .05f * (1 + abs((int)i - 2)); bodyParts[i]->x = - Mth::sin(bob * .9f + i * .15f * M_PI) * M_PI * .2f * abs((int)i - 2); + sinf(bob * .9f + i * .15f * std::numbers::pi) * std::numbers::pi * .2f * abs((int)i - 2); } bodyLayers[0]->yRot = bodyParts[2]->yRot; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/SkeletonHeadModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/SkeletonHeadModel.cpp index 037cdf43e..29634e164 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/SkeletonHeadModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/SkeletonHeadModel.cpp @@ -40,6 +40,6 @@ void SkeletonHeadModel::setupAnim(float time, float r, float bob, float yRot, Model::setupAnim(time, r, bob, yRot, xRot, scale, entity, uiBitmaskOverrideAnim); - head->yRot = yRot / (180 / M_PI); - head->xRot = xRot / (180 / M_PI); + head->yRot = yRot / (180 / std::numbers::pi); + head->xRot = xRot / (180 / std::numbers::pi); } \ No newline at end of file diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/SkeletonModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/SkeletonModel.cpp index e82f6a3f4..09a0af1cb 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/SkeletonModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/SkeletonModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "SkeletonModel.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "Minecraft.World/net/minecraft/world/entity/monster/net.minecraft.world.entity.monster.h" #include "geom/ModelPart.h" diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/SkiModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/SkiModel.cpp index 0c1ba585c..74c576c76 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/SkiModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/SkiModel.cpp @@ -36,10 +36,10 @@ void SkiModel::render(std::shared_ptr entity, float time, float r, void SkiModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, std::shared_ptr entity) { cubes[0]->y = 24.2f; - cubes[0]->xRot = M_PI * .5f; + cubes[0]->xRot = std::numbers::pi * .5f; cubes[1]->y = 24.2f; - cubes[1]->xRot = M_PI * .5f; + cubes[1]->xRot = std::numbers::pi * .5f; if (leftSki) { cubes[0]->z = -26 - 12 * (cos(time * 0.6662f) * 0.7f) * r; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/SnowManModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/SnowManModel.cpp index d90047517..523d8a051 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/SnowManModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/SnowManModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "SnowManModel.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "geom/ModelPart.h" SnowManModel::SnowManModel() : Model() { @@ -41,17 +41,17 @@ void SnowManModel::setupAnim(float time, float r, float bob, float yRot, std::shared_ptr entity, unsigned int uiBitmaskOverrideAnim) { Model::setupAnim(time, r, bob, yRot, xRot, scale, entity); - head->yRot = yRot / (float)(180 / M_PI); - head->xRot = xRot / (float)(180 / M_PI); - piece1->yRot = (yRot / (float)(180 / M_PI)) * 0.25f; + head->yRot = yRot / (float)(180 / std::numbers::pi); + head->xRot = xRot / (float)(180 / std::numbers::pi); + piece1->yRot = (yRot / (float)(180 / std::numbers::pi)) * 0.25f; - float s = Mth::sin(piece1->yRot); - float c = Mth::cos(piece1->yRot); + float s = sinf(piece1->yRot); + float c = cosf(piece1->yRot); arm1->zRot = 1; arm2->zRot = -1; arm1->yRot = 0 + piece1->yRot; - arm2->yRot = M_PI + piece1->yRot; + arm2->yRot = std::numbers::pi + piece1->yRot; arm1->x = (c) * 5; arm1->z = (-s) * 5; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/SpiderModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/SpiderModel.cpp index 750b41da0..bca55bc95 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/SpiderModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/SpiderModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "SpiderModel.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "geom/ModelPart.h" SpiderModel::SpiderModel() : Model() { @@ -89,10 +89,10 @@ void SpiderModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, std::shared_ptr entity, unsigned int uiBitmaskOverrideAnim) { - head->yRot = yRot / (float)(180 / M_PI); - head->xRot = xRot / (float)(180 / M_PI); + head->yRot = yRot / (float)(180 / std::numbers::pi); + head->xRot = xRot / (float)(180 / std::numbers::pi); - float sr = (float)M_PI / 4.0f; + float sr = (float)std::numbers::pi / 4.0f; leg0->zRot = -sr; leg1->zRot = sr; @@ -105,8 +105,8 @@ void SpiderModel::setupAnim(float time, float r, float bob, float yRot, leg6->zRot = -sr; leg7->zRot = sr; - float ro = -(float)M_PI / 2.0f * 0; - float ur = (float)M_PI / 8.0f; + float ro = -(float)std::numbers::pi / 2.0f * 0; + float ur = (float)std::numbers::pi / 8.0f; leg0->yRot = +ur * 2.0f + ro; leg1->yRot = -ur * 2.0f - ro; leg2->yRot = +ur * 1.0f + ro; @@ -117,22 +117,22 @@ void SpiderModel::setupAnim(float time, float r, float bob, float yRot, leg7->yRot = +ur * 2.0f - ro; float c0 = - -((float)Mth::cos(time * 0.6662f * 2 + M_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)Mth::cos(time * 0.6662f * 2 + M_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)Mth::cos(time * 0.6662f * 2 + M_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)Mth::cos(time * 0.6662f * 2 + M_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 = - abs((float)Mth::sin(time * 0.6662f + M_PI * 2 * 0 / 4.0f) * 0.4f) * r; + abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 0 / 4.0f) * 0.4f) * r; float s1 = - abs((float)Mth::sin(time * 0.6662f + M_PI * 2 * 2 / 4.0f) * 0.4f) * r; + abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 2 / 4.0f) * 0.4f) * r; float s2 = - abs((float)Mth::sin(time * 0.6662f + M_PI * 2 * 1 / 4.0f) * 0.4f) * r; + abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 1 / 4.0f) * 0.4f) * r; float s3 = - abs((float)Mth::sin(time * 0.6662f + M_PI * 2 * 3 / 4.0f) * 0.4f) * r; + abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 3 / 4.0f) * 0.4f) * r; leg0->yRot += +c0; leg1->yRot += -c0; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/SquidModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/SquidModel.cpp index 778d45bb0..d4488645e 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/SquidModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/SquidModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "SquidModel.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "geom/ModelPart.h" SquidModel::SquidModel() : Model() { @@ -13,18 +13,18 @@ SquidModel::SquidModel() : Model() { { tentacles[i] = new ModelPart(this, 48, 0); - double angle = i * M_PI * 2.0 / + double angle = i * std::numbers::pi * 2.0 / (double)TENTACLES_LENGTH; // 4J - 8 was tentacles.size() - float xo = Mth::cos((float)angle) * 5; - float yo = Mth::sin((float)angle) * 5; + float xo = cosf((float)angle) * 5; + float yo = sinf((float)angle) * 5; tentacles[i]->addBox(-1, 0, -1, 2, 18, 2); tentacles[i]->x = xo; tentacles[i]->z = yo; tentacles[i]->y = (float)(31 + yoffs); - angle = i * M_PI * -2.0 / (double)TENTACLES_LENGTH + - M_PI * .5; // 4J - 8 was tentacles.size() + angle = i * std::numbers::pi * -2.0 / (double)TENTACLES_LENGTH + + std::numbers::pi * .5; // 4J - 8 was tentacles.size() tentacles[i]->yRot = (float)angle; // 4J added - compile now to avoid random performance hit first time diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerGolemModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerGolemModel.cpp index 09b6260d0..6c15a56d9 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerGolemModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerGolemModel.cpp @@ -52,8 +52,8 @@ void VillagerGolemModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, std::shared_ptr entity, unsigned int uiBitmaskOverrideAnim) { - head->yRot = yRot / (float)(180 / M_PI); - head->xRot = xRot / (float)(180 / M_PI); + head->yRot = yRot / (float)(180 / std::numbers::pi); + head->xRot = xRot / (float)(180 / std::numbers::pi); leg0->xRot = (-1.5f * triangleWave(time, 13)) * r; leg1->xRot = (1.5f * triangleWave(time, 13)) * r; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerModel.cpp index 2f2184083..00895c0cf 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "VillagerModel.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "geom/ModelPart.h" void VillagerModel::_init(float g, float yOffset, int xTexSize, int yTexSize) { @@ -67,15 +67,15 @@ void VillagerModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, std::shared_ptr entity, unsigned int uiBitmaskOverrideAnim) { - head->yRot = yRot / (float)(180 / M_PI); - head->xRot = xRot / (float)(180 / M_PI); + head->yRot = yRot / (float)(180 / std::numbers::pi); + head->xRot = xRot / (float)(180 / std::numbers::pi); arms->y = 3; arms->z = -1; arms->xRot = -0.75f; - leg0->xRot = ((float)Mth::cos(time * 0.6662f) * 1.4f) * r * 0.5f; - leg1->xRot = ((float)Mth::cos(time * 0.6662f + M_PI) * 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; leg0->yRot = 0; leg1->yRot = 0; } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerZombieModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerZombieModel.cpp index 6c11c71d1..84e986f2e 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerZombieModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerZombieModel.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "geom/ModelPart.h" #include "VillagerZombieModel.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" void VillagerZombieModel::_init(float g, float yOffset, bool isArmor) { delete head; @@ -39,19 +39,19 @@ void VillagerZombieModel::setupAnim(float time, float r, float bob, float yRot, HumanoidModel::setupAnim(time, r, bob, yRot, xRot, scale, entity, uiBitmaskOverrideAnim); - float attack2 = Mth::sin(attackTime * M_PI); - float attack = Mth::sin((1 - (1 - attackTime) * (1 - attackTime)) * M_PI); + float attack2 = sinf(attackTime * std::numbers::pi); + float attack = sinf((1 - (1 - attackTime) * (1 - attackTime)) * std::numbers::pi); arm0->zRot = 0; arm1->zRot = 0; arm0->yRot = -(0.1f - attack2 * 0.6f); arm1->yRot = +(0.1f - attack2 * 0.6f); - arm0->xRot = -M_PI / 2.0f; - arm1->xRot = -M_PI / 2.0f; + arm0->xRot = -std::numbers::pi / 2.0f; + arm1->xRot = -std::numbers::pi / 2.0f; arm0->xRot -= attack2 * 1.2f - attack * 0.4f; arm1->xRot -= attack2 * 1.2f - attack * 0.4f; - arm0->zRot += (Mth::cos(bob * 0.09f) * 0.05f + 0.05f); - arm1->zRot -= (Mth::cos(bob * 0.09f) * 0.05f + 0.05f); - arm0->xRot += (Mth::sin(bob * 0.067f) * 0.05f); - arm1->xRot -= (Mth::sin(bob * 0.067f) * 0.05f); + arm0->zRot += (cosf(bob * 0.09f) * 0.05f + 0.05f); + arm1->zRot -= (cosf(bob * 0.09f) * 0.05f + 0.05f); + arm0->xRot += (sinf(bob * 0.067f) * 0.05f); + arm1->xRot -= (sinf(bob * 0.067f) * 0.05f); } \ No newline at end of file diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/WitchModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/WitchModel.cpp index c637fad03..291526a65 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/WitchModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/WitchModel.cpp @@ -2,7 +2,7 @@ #include "geom/ModelPart.h" #include "WitchModel.h" #include "VillagerModel.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" WitchModel::WitchModel(float g) : VillagerModel(g, 0, 64, 128) { mole = (new ModelPart(this))->setTexSize(64, 128); @@ -19,24 +19,24 @@ WitchModel::WitchModel(float g) : VillagerModel(g, 0, 64, 128) { hat2->setTexSize(64, 128); hat2->setPos(1.75f, -4, 2.f); hat2->texOffs(0, 76)->addBox(0, 0, 0, 7, 4, 7); - hat2->xRot = -3.f * Mth::RAD_TO_GRAD; - hat2->zRot = 1.5f * Mth::RAD_TO_GRAD; + hat2->xRot = -3.f * GameMath::DEG_TO_RAD; + hat2->zRot = 1.5f * GameMath::DEG_TO_RAD; hat->addChild(hat2); ModelPart* hat3 = new ModelPart(this); hat3->setTexSize(64, 128); hat3->setPos(1.75f, -4, 2.f); hat3->texOffs(0, 87)->addBox(0, 0, 0, 4, 4, 4); - hat3->xRot = -6.f * Mth::RAD_TO_GRAD; - hat3->zRot = 3.f * Mth::RAD_TO_GRAD; + hat3->xRot = -6.f * GameMath::DEG_TO_RAD; + hat3->zRot = 3.f * GameMath::DEG_TO_RAD; hat2->addChild(hat3); ModelPart* hat4 = new ModelPart(this); hat4->setTexSize(64, 128); hat4->setPos(1.75f, -2, 2.f); hat4->texOffs(0, 95)->addBox(0, 0, 0, 1, 2, 1, 0.25f); - hat4->xRot = -12.f * Mth::RAD_TO_GRAD; - hat4->zRot = 6.f * Mth::RAD_TO_GRAD; + hat4->xRot = -12.f * GameMath::DEG_TO_RAD; + hat4->zRot = 6.f * GameMath::DEG_TO_RAD; hat3->addChild(hat4); // 4J added - compile now to avoid random performance hit first time cubes @@ -57,9 +57,9 @@ void WitchModel::setupAnim(float time, float r, float bob, float yRot, nose->translateX = nose->translateY = nose->translateZ = 0; float speed = 0.01f * (entity->entityId % 10); - nose->xRot = (sin(entity->tickCount * speed) * 4.5f) * M_PI / 180; + nose->xRot = (sin(entity->tickCount * speed) * 4.5f) * std::numbers::pi / 180; nose->yRot = 0; - nose->zRot = (cos(entity->tickCount * speed) * 2.5f) * M_PI / 180; + nose->zRot = (cos(entity->tickCount * speed) * 2.5f) * std::numbers::pi / 180; if (holdingItem) { nose->xRot = -0.9f; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/WitherBossModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/WitherBossModel.cpp index b13b2d17d..b8f140965 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/WitherBossModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/WitherBossModel.cpp @@ -56,14 +56,14 @@ void WitherBossModel::setupAnim(float time, float r, float bob, float yRot, std::shared_ptr entity, unsigned int uiBitmaskOverrideAnim) { float anim = cos(bob * .1f); - upperBodyParts[1]->xRot = (.065f + .05f * anim) * M_PI; + upperBodyParts[1]->xRot = (.065f + .05f * anim) * std::numbers::pi; upperBodyParts[2]->setPos(-2.f, 6.9f + cos(upperBodyParts[1]->xRot) * 10.f, -.5f + sin(upperBodyParts[1]->xRot) * 10.f); - upperBodyParts[2]->xRot = (.265f + .1f * anim) * M_PI; + upperBodyParts[2]->xRot = (.265f + .1f * anim) * std::numbers::pi; - heads[0]->yRot = yRot / (180 / M_PI); - heads[0]->xRot = xRot / (180 / M_PI); + heads[0]->yRot = yRot / (180 / std::numbers::pi); + heads[0]->xRot = xRot / (180 / std::numbers::pi); } void WitherBossModel::prepareMobModel(std::shared_ptr mob, @@ -73,7 +73,7 @@ void WitherBossModel::prepareMobModel(std::shared_ptr mob, for (int i = 1; i < 3; i++) { heads[i]->yRot = - (boss->getHeadYRot(i - 1) - mob->yBodyRot) / (180 / M_PI); - heads[i]->xRot = boss->getHeadXRot(i - 1) / (180 / M_PI); + (boss->getHeadYRot(i - 1) - mob->yBodyRot) / (180 / std::numbers::pi); + heads[i]->xRot = boss->getHeadXRot(i - 1) / (180 / std::numbers::pi); } } \ No newline at end of file diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/WolfModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/WolfModel.cpp index a6b271cd0..fbd6c5586 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/WolfModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/WolfModel.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "WolfModel.h" #include "Minecraft.World/net/minecraft/world/entity/animal/Wolf.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "geom/ModelPart.h" WolfModel::WolfModel() { @@ -99,31 +99,31 @@ void WolfModel::prepareMobModel(std::shared_ptr mob, float time, if (wolf->isAngry()) { tail->yRot = 0; } else { - tail->yRot = (Mth::cos(time * 0.6662f) * 1.4f) * r; + tail->yRot = (cosf(time * 0.6662f) * 1.4f) * r; } if (wolf->isSitting()) { upperBody->setPos(-1.0f, 11 + 13.0f - 8, -3); - upperBody->xRot = .40f * M_PI; - upperBody->yRot = .0f * M_PI; + upperBody->xRot = .40f * std::numbers::pi; + upperBody->yRot = .0f * std::numbers::pi; body->setPos(0, 11 + 15 - legSize, 0); - body->xRot = .25f * M_PI; + body->xRot = .25f * std::numbers::pi; tail->setPos(-1, 11 + 18 - legSize, 6); leg0->setPos(-2.5f, 18 + 12 - legSize, 2); - leg0->xRot = 1.5f * M_PI; + leg0->xRot = 1.5f * std::numbers::pi; leg1->setPos(.5f, 18 + 12 - legSize, 2); - leg1->xRot = 1.5f * M_PI; + leg1->xRot = 1.5f * std::numbers::pi; - leg2->xRot = 1.85f * M_PI; + leg2->xRot = 1.85f * std::numbers::pi; leg2->setPos(-2.49f, 18 + 7.0f - legSize, -4); - leg3->xRot = 1.85f * M_PI; + leg3->xRot = 1.85f * std::numbers::pi; leg3->setPos(.51f, 18 + 7.0f - legSize, -4); } else { body->setPos(0, 11 + 11 - legSize, 2); - body->xRot = 90 / (float)(180 / M_PI); + body->xRot = 90 / (float)(180 / std::numbers::pi); upperBody->setPos(-1.0f, 11 + 11.0f - legSize, -3); upperBody->xRot = body->xRot; @@ -135,10 +135,10 @@ void WolfModel::prepareMobModel(std::shared_ptr mob, float time, leg2->setPos(-2.5f, 18 + 6 - legSize, -4); leg3->setPos(.5f, 18 + 6 - legSize, -4); - leg0->xRot = (Mth::cos(time * 0.6662f) * 1.4f) * r; - leg1->xRot = (Mth::cos(time * 0.6662f + M_PI) * 1.4f) * r; - leg2->xRot = (Mth::cos(time * 0.6662f + M_PI) * 1.4f) * r; - leg3->xRot = (Mth::cos(time * 0.6662f) * 1.4f) * r; + leg0->xRot = (cosf(time * 0.6662f) * 1.4f) * r; + leg1->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 1.4f) * r; + leg2->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 1.4f) * r; + leg3->xRot = (cosf(time * 0.6662f) * 1.4f) * r; } float angle = wolf->getHeadRollAngle(a) + wolf->getBodyRollAngle(a, 0); @@ -154,7 +154,7 @@ void WolfModel::setupAnim(float time, float r, float bob, float yRot, std::shared_ptr entity, unsigned int uiBitmaskOverrideAnim) { Model::setupAnim(time, r, bob, yRot, xRot, scale, entity); - head->xRot = xRot / (float)(180 / M_PI); - head->yRot = yRot / (float)(180 / M_PI); + head->xRot = xRot / (float)(180 / std::numbers::pi); + head->yRot = yRot / (float)(180 / std::numbers::pi); tail->xRot = bob; } \ No newline at end of file diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/ZombieModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/ZombieModel.cpp index 9d531e417..a0fcf35c2 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/ZombieModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/ZombieModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "ZombieModel.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "geom/ModelPart.h" ZombieModel::ZombieModel() : HumanoidModel(0, 0, 64, 32) {} @@ -18,18 +18,18 @@ void ZombieModel::setupAnim(float time, float r, float bob, float yRot, HumanoidModel::setupAnim(time, r, bob, yRot, xRot, scale, entity, uiBitmaskOverrideAnim); - float attack2 = Mth::sin(attackTime * M_PI); - float attack = Mth::sin((1 - (1 - attackTime) * (1 - attackTime)) * M_PI); + float attack2 = sinf(attackTime * std::numbers::pi); + float attack = sinf((1 - (1 - attackTime) * (1 - attackTime)) * std::numbers::pi); arm0->zRot = 0; arm1->zRot = 0; arm0->yRot = -(0.1f - attack2 * 0.6f); arm1->yRot = +(0.1f - attack2 * 0.6f); - arm0->xRot = -(float)M_PI / 2.0f; - arm1->xRot = -(float)M_PI / 2.0f; + arm0->xRot = -(float)std::numbers::pi / 2.0f; + arm1->xRot = -(float)std::numbers::pi / 2.0f; arm0->xRot -= attack2 * 1.2f - attack * 0.4f; arm1->xRot -= attack2 * 1.2f - attack * 0.4f; - arm0->zRot += ((Mth::cos(bob * 0.09f)) * 0.05f + 0.05f); - arm1->zRot -= ((Mth::cos(bob * 0.09f)) * 0.05f + 0.05f); - arm0->xRot += ((Mth::sin(bob * 0.067f)) * 0.05f); - arm1->xRot -= ((Mth::sin(bob * 0.067f)) * 0.05f); + arm0->zRot += ((cosf(bob * 0.09f)) * 0.05f + 0.05f); + arm1->zRot -= ((cosf(bob * 0.09f)) * 0.05f + 0.05f); + arm0->xRot += ((sinf(bob * 0.067f)) * 0.05f); + arm1->xRot -= ((sinf(bob * 0.067f)) * 0.05f); } \ No newline at end of file diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/dragon/DragonModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/dragon/DragonModel.cpp index 239f4edf1..59ffff7dd 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/dragon/DragonModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/dragon/DragonModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "DragonModel.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderDragon.h" DragonModel::DragonModel(float g) : Model() { @@ -119,9 +119,9 @@ void DragonModel::render(std::shared_ptr entity, float time, float r, std::dynamic_pointer_cast(entity); float ttt = dragon->oFlapTime + (dragon->flapTime - dragon->oFlapTime) * a; - jaw->xRot = (float)(Mth::sin(ttt * M_PI * 2) + 1) * 0.2f; + jaw->xRot = (float)(sinf(ttt * std::numbers::pi * 2) + 1) * 0.2f; - float yo = (float)(Mth::sin(ttt * M_PI * 2 - 1) + 1); + float yo = (float)(sinf(ttt * std::numbers::pi * 2 - 1) + 1); yo = (yo * yo * 1 + yo * 2) * 0.05f; glTranslatef(0, yo - 2.0f, -3); @@ -148,7 +148,7 @@ void DragonModel::render(std::shared_ptr entity, float time, float r, yy += 2.0f; float rr = 0; - float roff = ttt * M_PI * 2.0f; + float roff = ttt * std::numbers::pi * 2.0f; yy = 20.0f; zz = -12.0f; double pComponents[3]; @@ -157,22 +157,22 @@ void DragonModel::render(std::shared_ptr entity, float time, float r, for (int i = 0; i < 5; i++) { dragon->getLatencyPos(p, 5 - i, a); - rr = (float)Mth::cos(i * 0.45f + roff) * 0.15f; - neck->yRot = rotWrap(dragon->getHeadPartYRotDiff(i, start, p)) * M_PI / + rr = (float)cosf(i * 0.45f + roff) * 0.15f; + neck->yRot = rotWrap(dragon->getHeadPartYRotDiff(i, start, p)) * std::numbers::pi / 180.0f * rotScale; // 4J replaced "p[0] - start[0] with // call to getHeadPartYRotDiff neck->xRot = rr + (float)(dragon->getHeadPartYOffset(i, start, p)) * - M_PI / 180.0f * rotScale * + std::numbers::pi / 180.0f * rotScale * 5.0f; // 4J replaced "p[1] - start[1]" with call // to getHeadPartYOffset - neck->zRot = -rotWrap(p[0] - rot) * M_PI / 180.0f * rotScale; + neck->zRot = -rotWrap(p[0] - rot) * std::numbers::pi / 180.0f * rotScale; neck->y = yy; neck->z = zz; neck->x = xx; - yy += Mth::sin(neck->xRot) * 10.0f; - zz -= Mth::cos(neck->yRot) * Mth::cos(neck->xRot) * 10.0f; - xx -= Mth::sin(neck->yRot) * Mth::cos(neck->xRot) * 10.0f; + yy += sinf(neck->xRot) * 10.0f; + zz -= cosf(neck->yRot) * cosf(neck->xRot) * 10.0f; + xx -= sinf(neck->yRot) * cosf(neck->xRot) * 10.0f; neck->render(scale, usecompiled); } @@ -181,11 +181,11 @@ void DragonModel::render(std::shared_ptr entity, float time, float r, head->x = xx; dragon->getLatencyPos(p, 0, a); head->yRot = - rotWrap(dragon->getHeadPartYRotDiff(6, start, p)) * M_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 - head->xRot = (float)(dragon->getHeadPartYOffset(6, start, p)) * M_PI / + head->xRot = (float)(dragon->getHeadPartYOffset(6, start, p)) * std::numbers::pi / 180.0f * rotScale * 5.0f; // 4J Added - head->zRot = -rotWrap(p[0] - rot) * M_PI / 180 * 1; + head->zRot = -rotWrap(p[0] - rot) * std::numbers::pi / 180 * 1; head->render(scale, usecompiled); glPushMatrix(); glTranslatef(0, 1, 0); @@ -196,11 +196,11 @@ void DragonModel::render(std::shared_ptr entity, float time, float r, glEnable(GL_CULL_FACE); for (int i = 0; i < 2; i++) { - float flapTime = ttt * M_PI * 2; - wing->xRot = 0.125f - (float)(Mth::cos(flapTime)) * 0.2f; + float flapTime = ttt * std::numbers::pi * 2; + wing->xRot = 0.125f - (float)(cosf(flapTime)) * 0.2f; wing->yRot = 0.25f; - wing->zRot = (float)(Mth::sin(flapTime) + 0.125f) * 0.8f; - wingTip->zRot = -(float)(Mth::sin(flapTime + 2.0f) + 0.5f) * 0.75f; + wing->zRot = (float)(sinf(flapTime) + 0.125f) * 0.8f; + wingTip->zRot = -(float)(sinf(flapTime + 2.0f) + 0.5f) * 0.75f; rearLeg->xRot = 1.0f + yo * 0.1f; rearLegTip->xRot = 0.5f + yo * 0.1f; @@ -221,24 +221,24 @@ void DragonModel::render(std::shared_ptr entity, float time, float r, glCullFace(GL_BACK); glDisable(GL_CULL_FACE); - rr = -(float)Mth::sin(ttt * M_PI * 2) * 0.0f; - roff = ttt * M_PI * 2; + rr = -(float)sinf(ttt * std::numbers::pi * 2) * 0.0f; + roff = ttt * std::numbers::pi * 2; yy = 10; zz = 60; xx = 0; dragon->getLatencyPos(start, 11, a); for (int i = 0; i < 12; i++) { dragon->getLatencyPos(p, 12 + i, a); - rr += Mth::sin(i * 0.45f + roff) * 0.05f; - neck->yRot = (rotWrap(p[0] - start[0]) * rotScale + 180) * M_PI / 180; - neck->xRot = rr + (float)(p[1] - start[1]) * M_PI / 180 * rotScale * 5; - neck->zRot = rotWrap(p[0] - rot) * M_PI / 180 * rotScale; + rr += sinf(i * 0.45f + roff) * 0.05f; + neck->yRot = (rotWrap(p[0] - start[0]) * rotScale + 180) * 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->y = yy; neck->z = zz; neck->x = xx; - yy += Mth::sin(neck->xRot) * 10; - zz -= Mth::cos(neck->yRot) * Mth::cos(neck->xRot) * 10; - xx -= Mth::sin(neck->yRot) * Mth::cos(neck->xRot) * 10; + yy += sinf(neck->xRot) * 10; + zz -= cosf(neck->yRot) * cosf(neck->xRot) * 10; + xx -= sinf(neck->yRot) * cosf(neck->xRot) * 10; neck->render(scale, usecompiled); } glPopMatrix(); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/geom/ModelPart.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/geom/ModelPart.cpp index 99e5d0601..3b1f04986 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/geom/ModelPart.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/geom/ModelPart.cpp @@ -3,7 +3,7 @@ #include "ModelPart.h" #include "Cube.h" -const float ModelPart::RAD = (180.0f / M_PI); +const float ModelPart::RAD = (180.0f / std::numbers::pi); void ModelPart::_init() { xTexSize = 64.0f; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/ClientConnection.cpp b/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/ClientConnection.cpp index 78477c82d..914d65732 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/ClientConnection.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/ClientConnection.cpp @@ -2579,9 +2579,9 @@ void ClientConnection::handleContainerOpen( } } break; case ContainerOpenPacket::WORKBENCH: { - if (player->startCrafting(Mth::floor(player->x), - Mth::floor(player->y), - Mth::floor(player->z))) { + if (player->startCrafting(GameMath::floor(player->x), + GameMath::floor(player->y), + GameMath::floor(player->z))) { player->containerMenu->containerId = packet->containerId; } else { failed = true; @@ -2589,8 +2589,8 @@ void ClientConnection::handleContainerOpen( } break; case ContainerOpenPacket::ENCHANTMENT: { if (player->startEnchanting( - Mth::floor(player->x), Mth::floor(player->y), - Mth::floor(player->z), + GameMath::floor(player->x), GameMath::floor(player->y), + GameMath::floor(player->z), packet->customName ? packet->title : L"")) { player->containerMenu->containerId = packet->containerId; } else { @@ -2621,9 +2621,9 @@ void ClientConnection::handleContainerOpen( } } break; case ContainerOpenPacket::REPAIR_TABLE: { - if (player->startRepairing(Mth::floor(player->x), - Mth::floor(player->y), - Mth::floor(player->z))) { + if (player->startRepairing(GameMath::floor(player->x), + GameMath::floor(player->y), + GameMath::floor(player->z))) { player->containerMenu->containerId = packet->containerId; } else { failed = true; @@ -2655,9 +2655,9 @@ void ClientConnection::handleContainerOpen( } } break; case ContainerOpenPacket::FIREWORKS: { - if (player->openFireworks(Mth::floor(player->x), - Mth::floor(player->y), - Mth::floor(player->z))) { + if (player->openFireworks(GameMath::floor(player->x), + GameMath::floor(player->y), + GameMath::floor(player->z))) { player->containerMenu->containerId = packet->containerId; } else { failed = true; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp index ae6f1142b..635b7ed9b 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp @@ -4,7 +4,7 @@ #include "ClientConnection.h" #include "Minecraft.World/net/minecraft/world/level/net.minecraft.world.level.h" #include "Minecraft.World/net/minecraft/network/net.minecraft.network.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "Minecraft.World/net/minecraft/world/phys/AABB.h" #include "Minecraft.World/net/minecraft/stats/net.minecraft.stats.h" #include "Minecraft.World/net/minecraft/world/inventory/net.minecraft.world.inventory.h" @@ -61,7 +61,7 @@ void MultiplayerLocalPlayer::tick() { ); }*/ - if (!level->hasChunkAt(Mth::floor(x), 0, Mth::floor(z))) return; + if (!level->hasChunkAt(GameMath::floor(x), 0, GameMath::floor(z))) return; double tempX = x, tempY = y, tempZ = z; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/BubbleParticle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/BubbleParticle.cpp index f0c45e2b5..e75bf5ff1 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/BubbleParticle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/BubbleParticle.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "BubbleParticle.h" #include "java/Random.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "java/JavaMath.h" #include "Minecraft.World/net/minecraft/world/level/net.minecraft.world.level.h" #include "Minecraft.World/net/minecraft/world/level/material/net.minecraft.world.level.material.h" @@ -35,7 +35,7 @@ void BubbleParticle::tick() { yd *= 0.85f; zd *= 0.85f; - if (level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)) != + if (level->getMaterial(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)) != Material::water) remove(); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/DripParticle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/DripParticle.cpp index ad70defba..55114059e 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/DripParticle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/DripParticle.cpp @@ -3,7 +3,7 @@ #include "Minecraft.World/net/minecraft/world/level/material/net.minecraft.world.level.material.h" #include "Minecraft.World/net/minecraft/world/level/tile/net.minecraft.world.level.tile.h" #include "java/JavaMath.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "DripParticle.h" DripParticle::DripParticle(Level* level, double x, double y, double z, @@ -119,11 +119,11 @@ void DripParticle::tick() { } Material* m = - level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)); + level->getMaterial(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); if (m->isLiquid() || m->isSolid()) { - double y0 = Mth::floor(y) + 1 - + double y0 = GameMath::floor(y) + 1 - LiquidTile::getHeight(level->getData( - Mth::floor(x), Mth::floor(y), Mth::floor(z))); + GameMath::floor(x), GameMath::floor(y), GameMath::floor(z))); if (y < y0) { remove(); } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/FireworksParticles.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/FireworksParticles.cpp index cee4981f0..8ea22b88d 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/FireworksParticles.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/FireworksParticles.cpp @@ -240,10 +240,10 @@ void FireworksParticles::FireworksStarter::createParticleShape( fadeColors, trail, flicker); } - float baseAngle = random->nextFloat() * M_PI; + float baseAngle = random->nextFloat() * std::numbers::pi; double angleMod = (flat ? .034 : .34); for (int angleStep = 0; angleStep < 3; angleStep++) { - double angle = baseAngle + angleStep * M_PI * angleMod; + double angle = baseAngle + angleStep * std::numbers::pi * angleMod; double ox = sx; double oy = sy; @@ -428,7 +428,7 @@ void FireworksParticles::FireworksOverlayParticle::render(Tesselator* t, float u1 = u0 + 32.0f / 128.0f; float v0 = 16.0f / 128.0f; float v1 = v0 + 32.0f / 128.0f; - float r = 7.1f * sin(((float)age + a - 1.0f) * .25f * M_PI); + float r = 7.1f * sin(((float)age + a - 1.0f) * .25f * std::numbers::pi); alpha = 0.6f - ((float)age + a - 1.0f) * .25f * .5f; float x = (float)(xo + (this->x - xo) * a - xOff); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/FootstepParticle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/FootstepParticle.cpp index 6d73fc6af..2eec5f086 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/FootstepParticle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/FootstepParticle.cpp @@ -2,7 +2,7 @@ #include "FootstepParticle.h" #include "../renderer/Textures.h" #include "../renderer/Tesselator.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "Minecraft.World/net/minecraft/world/level/net.minecraft.world.level.h" #include "../resources/ResourceLocation.h" @@ -38,7 +38,7 @@ void FootstepParticle::render(Tesselator* t, float a, float xa, float ya, float zz = (float)(z - zOff); float br = - level->getBrightness(Mth::floor(x), Mth::floor(y), Mth::floor(z)); + level->getBrightness(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); textures->bindTexture(&FOOTPRINT_LOCATION); glEnable(GL_BLEND); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/NoteParticle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/NoteParticle.cpp index 74acfff1d..dc071eb9d 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/NoteParticle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/NoteParticle.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "NoteParticle.h" void NoteParticle::init(Level* level, double x, double y, double z, double xa, @@ -18,9 +18,9 @@ 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 )/255.0; -rCol = Mth::sin(((float) xa + 0.0f / 3) * M_PI * 2) * (rMax - rMin) + rMin; -gCol = Mth::sin(((float) xa + 1.0f / 3) * M_PI * 2) * (gMax - gMin) + gMin; -bCol = Mth::sin(((float) xa + 2.0f / 3) * M_PI * 2) * (bMax - bMin) + bMin; +rCol = sinf(((float) xa + 0.0f / 3) * std::numbers::pi * 2) * (rMax - rMin) + rMin; +gCol = sinf(((float) xa + 1.0f / 3) * std::numbers::pi * 2) * (gMax - gMin) + gMin; +bCol = sinf(((float) xa + 2.0f / 3) * std::numbers::pi * 2) * (bMax - bMin) + bMin; */ // 4J-JEV: Added, diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/Particle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/Particle.cpp index bf96905d3..909d374ea 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/Particle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/Particle.cpp @@ -2,7 +2,7 @@ #include "Particle.h" #include "../renderer/Tesselator.h" #include "java/Random.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "java/JavaMath.h" #include "Minecraft.World/net/minecraft/world/net.minecraft.world.h" @@ -56,7 +56,7 @@ Particle::Particle(Level* level, double x, double y, double z, double xa, zd = za + (float)(Math::random() * 2 - 1) * 0.4f; float speed = (float)(Math::random() + Math::random() + 1) * 0.15f; - float dd = (float)(Mth::sqrt(xd * xd + yd * yd + zd * zd)); + float dd = (float)(GameMath::sqrt(xd * xd + yd * yd + zd * zd)); xd = xd / dd * speed * 0.4f; yd = yd / dd * speed * 0.4f + 0.1f; zd = zd / dd * speed * 0.4f; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/ParticleEngine.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/ParticleEngine.cpp index d184f4e80..3776607c9 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/ParticleEngine.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/ParticleEngine.cpp @@ -155,13 +155,13 @@ void ParticleEngine::renderLit(std::shared_ptr player, float a, Particle::yOff = (player->yOld + (player->y - player->yOld) * a); Particle::zOff = (player->zOld + (player->z - player->zOld) * a); - float RAD = M_PI / 180; - float xa = (float)Mth::cos(player->yRot * RAD); - float za = (float)Mth::sin(player->yRot * RAD); + float RAD = std::numbers::pi / 180; + float xa = (float)cosf(player->yRot * RAD); + float za = (float)sinf(player->yRot * RAD); - float xa2 = -za * (float)Mth::sin(player->xRot * RAD); - float za2 = xa * (float)Mth::sin(player->xRot * RAD); - float ya = (float)Mth::cos(player->xRot * RAD); + float xa2 = -za * (float)sinf(player->xRot * RAD); + float za2 = xa * (float)sinf(player->xRot * RAD); + float ya = (float)cosf(player->xRot * RAD); int l = level->dimension->id == 0 ? 0 : (level->dimension->id == -1 ? 1 : 2); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/SuspendedParticle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/SuspendedParticle.cpp index e866c214b..95e80ca57 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/SuspendedParticle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/SuspendedParticle.cpp @@ -3,7 +3,7 @@ #include "java/Random.h" #include "Minecraft.World/net/minecraft/world/level/net.minecraft.world.level.h" #include "java/JavaMath.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "Minecraft.World/net/minecraft/world/level/material/net.minecraft.world.level.material.h" SuspendedParticle::SuspendedParticle(Level* level, double x, double y, double z, @@ -38,7 +38,7 @@ void SuspendedParticle::tick() { move(xd, yd, zd); - if (level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)) != + if (level->getMaterial(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)) != Material::water) remove(); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/TakeAnimationParticle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/TakeAnimationParticle.cpp index 910ab54d0..2b201d8a5 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/TakeAnimationParticle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/TakeAnimationParticle.cpp @@ -3,7 +3,7 @@ #include "../renderer/entity/EntityRenderDispatcher.h" #include "Minecraft.World/net/minecraft/world/item/net.minecraft.world.item.h" #include "Minecraft.World/net/minecraft/world/level/net.minecraft.world.level.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" TakeAnimationParticle::TakeAnimationParticle(Level* level, std::shared_ptr item, @@ -40,9 +40,9 @@ void TakeAnimationParticle::render(Tesselator* t, float a, float xa, float ya, double yy = yo + (yt - yo) * time; double zz = zo + (zt - zo) * time; - int xTile = Mth::floor(xx); - int yTile = Mth::floor(yy + heightOffset / 2.0f); - int zTile = Mth::floor(zz); + int xTile = GameMath::floor(xx); + int yTile = GameMath::floor(yy + heightOffset / 2.0f); + int zTile = GameMath::floor(zz); // 4J - change brought forward from 1.8.2 if (SharedConstants::TEXTURE_LIGHTING) { diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/WaterDropParticle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/WaterDropParticle.cpp index 93aa00677..dfda8fadd 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/WaterDropParticle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/WaterDropParticle.cpp @@ -43,11 +43,11 @@ void WaterDropParticle::tick() { } Material* m = - level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)); + level->getMaterial(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); if (m->isLiquid() || m->isSolid()) { - double y0 = Mth::floor(y) + 1 - + double y0 = GameMath::floor(y) + 1 - LiquidTile::getHeight(level->getData( - Mth::floor(x), Mth::floor(y), Mth::floor(z))); + GameMath::floor(x), GameMath::floor(y), GameMath::floor(z))); if (y < y0) { remove(); } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/player/LocalPlayer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/player/LocalPlayer.cpp index 262d7b5fd..9daa9a502 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/player/LocalPlayer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/player/LocalPlayer.cpp @@ -39,7 +39,7 @@ #include "nbt/com.mojang.nbt.h" #include "java/Random.h" #include "Minecraft.World/net/minecraft/world/level/tile/entity/TileEntity.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "../gui/achievement/AchievementPopup.h" #include "../particle/CritParticle.h" @@ -150,7 +150,7 @@ void LocalPlayer::serverAiStep() { // Don't bother for tiny inputs if (fMag >= 0.1f) { // Get angle (in player rotated space) of input controls - float yRotInput = atan2f(input->ya, input->xa) * (180.0f / M_PI); + float yRotInput = atan2f(input->ya, input->xa) * (180.0f / std::numbers::pi); // Now get in world space float yRotFinal = yRotInput + yRot; // Snap this to nearest 90 degrees @@ -161,8 +161,8 @@ void LocalPlayer::serverAiStep() { float yRotInputAdjust = yRotInput + yRotDiff; // Calculate final x/y player-space movement required - this->xxa = cos(yRotInputAdjust * (M_PI / 180.0f)) * fMag; - this->yya = sin(yRotInputAdjust * (M_PI / 180.0f)) * fMag; + this->xxa = cos(yRotInputAdjust * (std::numbers::pi / 180.0f)) * fMag; + this->yya = sin(yRotInputAdjust * (std::numbers::pi / 180.0f)) * fMag; } else { this->xxa = input->xa; this->yya = input->ya; @@ -354,11 +354,11 @@ void LocalPlayer::aiStep() { if (InputManager.GetJoypadMapVal(m_iPad) == 0) { if (ullDpad_filtered & (1LL << MINECRAFT_ACTION_DPAD_RIGHT)) { - xd = -0.15 * cos(yRotSnapped * M_PI / 180); - zd = -0.15 * sin(yRotSnapped * M_PI / 180); + xd = -0.15 * cos(yRotSnapped * std::numbers::pi / 180); + zd = -0.15 * sin(yRotSnapped * std::numbers::pi / 180); } else if (ullDpad_filtered & (1LL << MINECRAFT_ACTION_DPAD_LEFT)) { - xd = 0.15 * cos(yRotSnapped * M_PI / 180); - zd = 0.15 * sin(yRotSnapped * M_PI / 180); + xd = 0.15 * cos(yRotSnapped * std::numbers::pi / 180); + zd = 0.15 * sin(yRotSnapped * std::numbers::pi / 180); } } } @@ -1094,9 +1094,9 @@ bool LocalPlayer::isSolidBlock(int x, int y, int z) { } bool LocalPlayer::checkInTile(double x, double y, double z) { - int xTile = Mth::floor(x); - int yTile = Mth::floor(y); - int zTile = Mth::floor(z); + int xTile = GameMath::floor(x); + int yTile = GameMath::floor(y); + int zTile = GameMath::floor(z); double xd = x - xTile; double zd = z - zTile; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/player/RemotePlayer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/player/RemotePlayer.cpp index 6d5ffbcb2..2c500ba55 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/player/RemotePlayer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/player/RemotePlayer.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "RemotePlayer.h" #include "Minecraft.World/net/minecraft/world/item/net.minecraft.world.item.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" RemotePlayer::RemotePlayer(Level* level, const std::wstring& name) : Player(level, name) { @@ -46,7 +46,7 @@ void RemotePlayer::tick() { walkAnimSpeedO = walkAnimSpeed; double xxd = x - xo; double zzd = z - zo; - float wst = Mth::sqrt(xxd * xxd + zzd * zzd) * 4; + float wst = GameMath::sqrt(xxd * xxd + zzd * zzd) * 4; if (wst > 1) wst = 1; walkAnimSpeed += (wst - walkAnimSpeed) * 0.4f; walkAnimPos += walkAnimSpeed; @@ -98,7 +98,7 @@ void RemotePlayer::aiStep() { } oBob = bob; - float tBob = (float)Mth::sqrt(xd * xd + zd * zd); + float tBob = (float)GameMath::sqrt(xd * xd + zd * zd); float tTilt = (float)atan(-yd * 0.2f) * 15.0f; if (tBob > 0.1f) tBob = 0.1f; if (!onGround || getHealth() <= 0) tBob = 0; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/GameRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/GameRenderer.cpp index c64860bc5..6712eb6a7 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/GameRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/GameRenderer.cpp @@ -212,9 +212,9 @@ void GameRenderer::tick(bool first) // 4J - add bFirst mc->cameraTargetPlayer = std::dynamic_pointer_cast(mc->player); } - float brr = mc->level->getBrightness(Mth::floor(mc->cameraTargetPlayer->x), - Mth::floor(mc->cameraTargetPlayer->y), - Mth::floor(mc->cameraTargetPlayer->z)); + float brr = mc->level->getBrightness(GameMath::floor(mc->cameraTargetPlayer->x), + GameMath::floor(mc->cameraTargetPlayer->y), + GameMath::floor(mc->cameraTargetPlayer->z)); float whiteness = (3 - mc->options->viewDistance) / 3.0f; float fogBrT = brr * (1 - whiteness) + whiteness; fogBr += (fogBrT - fogBr) * 0.1f; @@ -407,7 +407,7 @@ void GameRenderer::bobHurt(float a) { if (hurt < 0) return; hurt /= player->hurtDuration; - hurt = (float)Mth::sin(hurt * hurt * hurt * hurt * M_PI); + hurt = (float)sinf(hurt * hurt * hurt * hurt * std::numbers::pi); float rr = player->hurtDir; @@ -426,10 +426,10 @@ void GameRenderer::bobView(float a) { float b = -(player->walkDist + wda * a); float bob = player->oBob + (player->bob - player->oBob) * a; float tilt = player->oTilt + (player->tilt - player->oTilt) * a; - glTranslatef((float)Mth::sin(b * M_PI) * bob * 0.5f, - -(float)abs(Mth::cos(b * M_PI) * bob), 0); - glRotatef((float)Mth::sin(b * M_PI) * bob * 3, 0, 0, 1); - glRotatef((float)abs(Mth::cos(b * M_PI - 0.2f) * bob) * 5, 1, 0, 0); + glTranslatef((float)sinf(b * std::numbers::pi) * bob * 0.5f, + -(float)abs(cosf(b * std::numbers::pi) * bob), 0); + glRotatef((float)sinf(b * std::numbers::pi) * bob * 3, 0, 0, 1); + glRotatef((float)abs(cosf(b * std::numbers::pi - 0.2f) * bob) * 5, 1, 0, 0); glRotatef((float)tilt, 1, 0, 0); } @@ -450,12 +450,12 @@ void GameRenderer::moveCameraToPlayer(float a) { glTranslatef(0.0f, 0.3f, 0); if (!mc->options->fixedCamera) { int t = - mc->level->getTile(Mth::floor(player->x), Mth::floor(player->y), - Mth::floor(player->z)); + mc->level->getTile(GameMath::floor(player->x), GameMath::floor(player->y), + GameMath::floor(player->z)); if (t == Tile::bed_Id) { - int data = mc->level->getData(Mth::floor(player->x), - Mth::floor(player->y), - Mth::floor(player->z)); + int data = mc->level->getData(GameMath::floor(player->x), + GameMath::floor(player->y), + GameMath::floor(player->z)); int direction = data & 3; glRotatef((float)direction * 90, 0.0f, 1.0f, 0.0f); @@ -500,11 +500,11 @@ void GameRenderer::moveCameraToPlayer(float a) { xRot += 180.0f; } - double xd = -Mth::sin(yRot / 180 * M_PI) * Mth::cos(xRot / 180 * M_PI) * + double xd = -sinf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi) * cameraDist; - double zd = Mth::cos(yRot / 180 * M_PI) * Mth::cos(xRot / 180 * M_PI) * + double zd = cosf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi) * cameraDist; - double yd = -Mth::sin(xRot / 180 * M_PI) * cameraDist; + double yd = -sinf(xRot / 180 * std::numbers::pi) * cameraDist; for (int i = 0; i < 8; i++) { float xo = (float)((i & 1) * 2 - 1); @@ -961,7 +961,7 @@ float GameRenderer::getNightVisionScale(std::shared_ptr player, return 1.0f; } else { float flash = std::max(0.0f, (float)duration - a); - return .7f + Mth::sin(flash * M_PI * .05f) * + return .7f + sinf(flash * std::numbers::pi * .05f) * .3f; // was: .7 + sin(flash*pi*0.2) * .3 } } @@ -1522,9 +1522,9 @@ void GameRenderer::tickRain() { std::shared_ptr player = mc->cameraTargetPlayer; Level* level = mc->level; - int x0 = Mth::floor(player->x); - int y0 = Mth::floor(player->y); - int z0 = Mth::floor(player->z); + int x0 = GameMath::floor(player->x); + int y0 = GameMath::floor(player->y); + int z0 = GameMath::floor(player->z); int r = 10; @@ -1575,9 +1575,9 @@ void GameRenderer::tickRain() { rainSoundTime = 0; MemSect(24); if (rainPosY > player->y + 1 && - level->getTopRainBlock(Mth::floor(player->x), - Mth::floor(player->z)) > - Mth::floor(player->y)) { + level->getTopRainBlock(GameMath::floor(player->x), + GameMath::floor(player->z)) > + GameMath::floor(player->y)) { mc->level->playLocalSound(rainPosX, rainPosY, rainPosZ, eSoundType_AMBIENT_WEATHER_RAIN, 0.1f, 0.5f); @@ -1608,7 +1608,7 @@ void GameRenderer::renderSnowAndRain(float a) { for (int x = 0; x < 32; x++) { float xa = x - 16; float za = z - 16; - float d = Mth::sqrt(xa * xa + za * za); + float d = GameMath::sqrt(xa * xa + za * za); rainXa[z << 5 | x] = -za / d; rainZa[z << 5 | x] = xa / d; } @@ -1618,9 +1618,9 @@ void GameRenderer::renderSnowAndRain(float a) { std::shared_ptr player = mc->cameraTargetPlayer; Level* level = mc->level; - int x0 = Mth::floor(player->x); - int y0 = Mth::floor(player->y); - int z0 = Mth::floor(player->z); + int x0 = GameMath::floor(player->x); + int y0 = GameMath::floor(player->y); + int z0 = GameMath::floor(player->z); Tesselator* t = Tesselator::getInstance(); glDisable(GL_CULL_FACE); @@ -1638,7 +1638,7 @@ void GameRenderer::renderSnowAndRain(float a) { double yo = player->yOld + (player->y - player->yOld) * a; double zo = player->zOld + (player->z - player->zOld) * a; - int yMin = Mth::floor(yo); + int yMin = GameMath::floor(yo); int r = 5; // 4J - was if(mc.options.fancyGraphics) r = 10; @@ -1703,7 +1703,7 @@ void GameRenderer::renderSnowAndRain(float a) { double xd = (x + 0.5f) - player->x; double zd = (z + 0.5f) - player->z; - float dd = (float)Mth::sqrt(xd * xd + zd * zd) / r; + float dd = (float)GameMath::sqrt(xd * xd + zd * zd) / r; float br = 1.0f; float s = 1.0f; @@ -1865,7 +1865,7 @@ void GameRenderer::setupClearColor(float a) { fb = (float)fogColor.z; if (mc->options->viewDistance < 2) { - Vec3 sunAngle = Mth::sin(level->getSunAngle(a)) > 0 ? Vec3(-1, 0, 0) + Vec3 sunAngle = sinf(level->getSunAngle(a)) > 0 ? Vec3(-1, 0, 0) : Vec3(1, 0, 0); float d = (float)player->getViewVector(a).dot(sunAngle); if (d < 0) d = 0; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/ItemInHandRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/ItemInHandRenderer.cpp index 94c83d650..2c6d8ac40 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/ItemInHandRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/ItemInHandRenderer.cpp @@ -432,13 +432,13 @@ void ItemInHandRenderer::render(float a) { std::shared_ptr item = selectedItem; float br = minecraft->level->getBrightness( - Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z)); + GameMath::floor(player->x), GameMath::floor(player->y), GameMath::floor(player->z)); // 4J - change brought forward from 1.8.2 if (SharedConstants::TEXTURE_LIGHTING) { br = 1; - int col = minecraft->level->getLightColor(Mth::floor(player->x), - Mth::floor(player->y), - Mth::floor(player->z), 0); + int col = minecraft->level->getLightColor(GameMath::floor(player->x), + GameMath::floor(player->y), + GameMath::floor(player->z), 0); int u = col % 65536; int v = col / 65536; #if defined(__linux__) @@ -477,16 +477,16 @@ void ItemInHandRenderer::render(float a) { { float swing = player->getAttackAnim(a); - float swing1 = Mth::sin(swing * M_PI); - float swing2 = Mth::sin((sqrt(swing)) * M_PI); - glTranslatef(-swing2 * 0.4f, Mth::sin(sqrt(swing) * M_PI * 2) * 0.2f, + float swing1 = sinf(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, -swing1 * 0.2f); } float tilt = 1 - xr / 45.0f + 0.1f; if (tilt < 0) tilt = 0; if (tilt > 1) tilt = 1; - tilt = -Mth::cos(tilt * M_PI) * 0.5f + 0.5f; + tilt = -cosf(tilt * std::numbers::pi) * 0.5f + 0.5f; glTranslatef(0.0f, 0.0f * d - (1 - h) * 1.2f - tilt * 0.5f + 0.04f, -0.9f * d); @@ -537,8 +537,8 @@ void ItemInHandRenderer::render(float a) { { float swing = player->getAttackAnim(a); - float swing3 = Mth::sin(swing * swing * M_PI); - float swing2 = Mth::sin(sqrt(swing) * M_PI); + float swing3 = sinf(swing * swing * std::numbers::pi); + float swing2 = sinf(sqrt(swing) * std::numbers::pi); glRotatef(-swing3 * 20, 0, 1, 0); glRotatef(-swing2 * 20, 0, 0, 1); glRotatef(-swing2 * 80, 1, 0, 0); @@ -603,7 +603,7 @@ void ItemInHandRenderer::render(float a) { is = is * is * is; float iss = 1 - is; glTranslatef(0, - Mth::abs(Mth::cos(t / 4 * M_PI) * 0.1f) * + GameMath::abs(cosf(t / 4 * std::numbers::pi) * 0.1f) * (swing > 0.2 ? 1 : 0), 0); glTranslatef(iss * 0.6f, -iss * 0.5f, 0); @@ -614,9 +614,9 @@ void ItemInHandRenderer::render(float a) { } else { float swing = powf(player->getAttackAnim(a), swingPowFactor); - float swing1 = Mth::sin(swing * M_PI); - float swing2 = Mth::sin((sqrt(swing)) * M_PI); - glTranslatef(-swing2 * 0.4f, Mth::sin(sqrt(swing) * M_PI * 2) * 0.2f, + float swing1 = sinf(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, -swing1 * 0.2f); } @@ -627,8 +627,8 @@ void ItemInHandRenderer::render(float a) { glEnable(GL_RESCALE_NORMAL); float swing = powf(player->getAttackAnim(a), swingPowFactor); - float swing3 = Mth::sin(swing * swing * M_PI); - float swing2 = Mth::sin(sqrt(swing) * M_PI); + float swing3 = sinf(swing * swing * std::numbers::pi); + float swing2 = sinf(sqrt(swing) * std::numbers::pi); glRotatef(-swing3 * 20, 0, 1, 0); glRotatef(-swing2 * 20, 0, 0, 1); glRotatef(-swing2 * 80, 1, 0, 0); @@ -655,7 +655,7 @@ void ItemInHandRenderer::render(float a) { if (pow > 1) pow = 1; if (pow > 0.1f) { glTranslatef(0, - Mth::sin((timeHeld - 0.1f) * 1.3f) * 0.01f * + sinf((timeHeld - 0.1f) * 1.3f) * 0.01f * (pow - 0.1f), 0); } @@ -700,9 +700,9 @@ void ItemInHandRenderer::render(float a) { { float swing = player->getAttackAnim(a); - float swing1 = Mth::sin(swing * M_PI); - float swing2 = Mth::sin((sqrt(swing)) * M_PI); - glTranslatef(-swing2 * 0.3f, Mth::sin(sqrt(swing) * M_PI * 2) * 0.4f, + float swing1 = sinf(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, -swing1 * 0.4f); } @@ -713,8 +713,8 @@ void ItemInHandRenderer::render(float a) { glEnable(GL_RESCALE_NORMAL); { float swing = player->getAttackAnim(a); - float swing3 = Mth::sin(swing * swing * M_PI); - float swing2 = Mth::sin(sqrt(swing) * M_PI); + float swing3 = sinf(swing * swing * std::numbers::pi); + float swing2 = sinf(sqrt(swing) * std::numbers::pi); glRotatef(swing2 * 70, 0, 1, 0); glRotatef(-swing3 * 20, 0, 0, 1); } @@ -769,9 +769,9 @@ void ItemInHandRenderer::renderScreenEffect(float a) { if (minecraft->player->isInWall()) // Inside a tile { - int x = Mth::floor(minecraft->player->x); - int y = Mth::floor(minecraft->player->y); - int z = Mth::floor(minecraft->player->z); + int x = GameMath::floor(minecraft->player->x); + int y = GameMath::floor(minecraft->player->y); + int z = GameMath::floor(minecraft->player->z); int tile = minecraft->level->getTile(x, y, z); if (minecraft->level->isSolidBlockingTile(x, y, z)) { @@ -784,9 +784,9 @@ void ItemInHandRenderer::renderScreenEffect(float a) { ((i >> 1) % 2 - 0.5f) * minecraft->player->bbHeight * 0.2f; float zo = ((i >> 2) % 2 - 0.5f) * minecraft->player->bbWidth * 0.9f; - int xt = Mth::floor(x + xo); - int yt = Mth::floor(y + yo); - int zt = Mth::floor(z + zo); + int xt = GameMath::floor(x + xo); + int yt = GameMath::floor(y + yo); + int zt = GameMath::floor(z + zo); if (minecraft->level->isSolidBlockingTile(xt, yt, zt)) { tile = minecraft->level->getTile(xt, yt, zt); } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/LevelRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/LevelRenderer.cpp index c932a9fe3..735cf1eff 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/LevelRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/LevelRenderer.cpp @@ -239,7 +239,7 @@ LevelRenderer::LevelRenderer(Minecraft* mc, Textures* textures) { 1000; // How much we raise the circle origin to make the circle // curve back towards us const int WIDTH = 10; - const float ARC_RADIANS = 2.0f * M_PI / ARC_SEGMENTS; + const float ARC_RADIANS = 2.0f * std::numbers::pi / ARC_SEGMENTS; const float HALF_ARC_SEG = ARC_SEGMENTS / 2; const float WIDE_ARC_SEGS = ARC_SEGMENTS / 8; const float WIDE_ARC_SEGS_SQR = WIDE_ARC_SEGS * WIDE_ARC_SEGS; @@ -307,7 +307,7 @@ void LevelRenderer::renderStars() { double xSin = sin(xRot); double xCos = cos(xRot); - double zRot = random.nextDouble() * M_PI * 2; + double zRot = random.nextDouble() * std::numbers::pi * 2; double zSin = sin(zRot); double zCos = cos(zRot); @@ -499,8 +499,8 @@ void LevelRenderer::allChanged(int playerIndex) { if (level[playerIndex] != nullptr) { std::shared_ptr player = mc->cameraTargetPlayer; if (player != nullptr) { - this->resortChunks(Mth::floor(player->x), Mth::floor(player->y), - Mth::floor(player->z)); + this->resortChunks(GameMath::floor(player->x), GameMath::floor(player->y), + GameMath::floor(player->z)); // sort(sortedChunks[playerIndex]->begin(),sortedChunks[playerIndex]->end(), // DistanceChunkSorter(player)); // 4J - removed - not sorting // our chunks anymore @@ -597,8 +597,8 @@ void LevelRenderer::renderEntities(Vec3* cam, Culler* culler, float a) { !mc->cameraTargetPlayer->isSleeping()) continue; - if (!level[playerIndex]->hasChunkAt(Mth::floor(entity->x), 0, - Mth::floor(entity->z))) { + if (!level[playerIndex]->hasChunkAt(GameMath::floor(entity->x), 0, + GameMath::floor(entity->z))) { continue; } renderedEntities++; @@ -731,8 +731,8 @@ int LevelRenderer::render(std::shared_ptr player, int layer, yOld[playerIndex] = player->y; zOld[playerIndex] = player->z; - resortChunks(Mth::floor(player->x), Mth::floor(player->y), - Mth::floor(player->z)); + resortChunks(GameMath::floor(player->x), GameMath::floor(player->y), + GameMath::floor(player->z)); // sort(sortedChunks[playerIndex]->begin(),sortedChunks[playerIndex]->end(), // DistanceChunkSorter(player)); // 4J - removed - not sorting // our chunks anymore @@ -939,7 +939,7 @@ void LevelRenderer::renderSky(float alpha) { { glRotatef(90, 1, 0, 0); glRotatef( - Mth::sin(level[playerIndex]->getSunAngle(alpha)) < 0 ? 180 : 0, + sinf(level[playerIndex]->getSunAngle(alpha)) < 0 ? 180 : 0, 0, 0, 1); glRotatef(90, 0, 0, 1); @@ -963,9 +963,9 @@ void LevelRenderer::renderSky(float alpha) { int steps = 16; t->color(c[0], c[1], c[2], 0.0f); for (int i = 0; i <= steps; i++) { - float a = i * M_PI * 2 / steps; - float _sin = Mth::sin(a); - float _cos = Mth::cos(a); + float a = i * std::numbers::pi * 2 / steps; + float _sin = sinf(a); + float _cos = cosf(a); t->vertex((float)(_sin * 120), (float)(_cos * 120), (float)(-_cos * 40 * c[3])); } @@ -1176,8 +1176,8 @@ void LevelRenderer::renderClouds(float alpha) { double zo = mc->cameraTargetPlayer->zo + (mc->cameraTargetPlayer->z - mc->cameraTargetPlayer->zo) * alpha; - int xOffs = Mth::floor(xo / 2048); - int zOffs = Mth::floor(zo / 2048); + int xOffs = GameMath::floor(xo / 2048); + int zOffs = GameMath::floor(zo / 2048); xo -= xOffs * 2048; zo -= zOffs * 2048; @@ -1419,8 +1419,8 @@ void LevelRenderer::renderAdvancedClouds(float alpha) { 0.33f; float yy = (float)(level[playerIndex]->dimension->getCloudHeight() - yOffs + 0.33f); - int xOffs = Mth::floor(xo / 2048); - int zOffs = Mth::floor(zo / 2048); + int xOffs = GameMath::floor(xo / 2048); + int zOffs = GameMath::floor(zo / 2048); xo -= xOffs * 2048; zo -= zOffs * 2048; @@ -1468,16 +1468,16 @@ void LevelRenderer::renderAdvancedClouds(float alpha) { float scale = 1 / 256.0f; - uo = (float)(Mth::floor(xo)) * scale; - vo = (float)(Mth::floor(zo)) * scale; + uo = (float)(GameMath::floor(xo)) * scale; + vo = (float)(GameMath::floor(zo)) * scale; // 4J - keep our UVs +ve - there's a small bug in the xbox GPU that // incorrectly rounds small -ve UVs (between -1/(64*size) and 0) up to 0, // which leaves gaps in our clouds... while (uo < 1.0f) uo += 1.0f; while (vo < 1.0f) vo += 1.0f; - float xoffs = (float)(xo - Mth::floor(xo)); - float zoffs = (float)(zo - Mth::floor(zo)); + float xoffs = (float)(xo - GameMath::floor(xo)); + float zoffs = (float)(zo - GameMath::floor(zo)); int D = 8; @@ -2094,16 +2094,16 @@ void LevelRenderer::renderHit(std::shared_ptr player, HitResult* h, glBlendFunc(GL_SRC_ALPHA, GL_ONE); glColor4f( 1, 1, 1, - ((float)(Mth::sin(Minecraft::currentTimeMillis() / 100.0f)) * 0.2f + + ((float)(sinf(Minecraft::currentTimeMillis() / 100.0f)) * 0.2f + 0.4f) * 0.5f); if (mode != 0 && inventoryItem != nullptr) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); float br = - (Mth::sin(Minecraft::currentTimeMillis() / 100.0f) * 0.2f + 0.8f); + (sinf(Minecraft::currentTimeMillis() / 100.0f) * 0.2f + 0.8f); glColor4f( br, br, br, - (Mth::sin(Minecraft::currentTimeMillis() / 200.0f) * 0.2f + 0.5f)); + (sinf(Minecraft::currentTimeMillis() / 200.0f) * 0.2f + 0.5f)); textures->bindTexture(&TextureAtlas::LOCATION_BLOCKS); } @@ -2278,12 +2278,12 @@ void LevelRenderer::setDirty(int x0, int y0, int z0, int x1, int y1, int z1, // come from when connection is being ticked outside of normal level tick, // and player won't be set up if (level == nullptr) level = this->level[mc->player->GetXboxPad()]; - int _x0 = Mth::intFloorDiv(x0, CHUNK_XZSIZE); - int _y0 = Mth::intFloorDiv(y0, CHUNK_SIZE); - int _z0 = Mth::intFloorDiv(z0, CHUNK_XZSIZE); - int _x1 = Mth::intFloorDiv(x1, CHUNK_XZSIZE); - int _y1 = Mth::intFloorDiv(y1, CHUNK_SIZE); - int _z1 = Mth::intFloorDiv(z1, CHUNK_XZSIZE); + int _x0 = GameMath::intFloorDiv(x0, CHUNK_XZSIZE); + int _y0 = GameMath::intFloorDiv(y0, CHUNK_SIZE); + int _z0 = GameMath::intFloorDiv(z0, CHUNK_XZSIZE); + int _x1 = GameMath::intFloorDiv(x1, CHUNK_XZSIZE); + int _y1 = GameMath::intFloorDiv(y1, CHUNK_SIZE); + int _z1 = GameMath::intFloorDiv(z1, CHUNK_XZSIZE); for (int x = _x0; x <= _x1; x++) { for (int y = _y0; y <= _y1; y++) { @@ -3318,7 +3318,7 @@ void LevelRenderer::levelEvent(std::shared_ptr source, int type, int x, random->nextDouble() * 0.2, random->nextGaussian() * .15); } - for (double a = 0; a < M_PI * 2.0; a += M_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, zp + sin(a) * 5, cos(a) * -5, 0, sin(a) * -5); addParticle(eParticleType_ender, xp + cos(a) * 5, yp - .4, @@ -3352,7 +3352,7 @@ void LevelRenderer::levelEvent(std::shared_ptr source, int type, int x, for (int i = 0; i < 100; i++) { double dist = random->nextDouble() * ThrownPotion::SPLASH_RANGE; - double angle = random->nextDouble() * M_PI * 2; + double angle = random->nextDouble() * std::numbers::pi * 2; double xs = cos(angle) * dist; double ys = 0.01 + random->nextDouble() * 0.5; double zs = sin(angle) * dist; @@ -3382,7 +3382,7 @@ void LevelRenderer::levelEvent(std::shared_ptr source, int type, int x, for (int i = 0; i < 200; i++) { double dist = random->nextDouble() * DragonFireball::SPLASH_RANGE; - double angle = random->nextDouble() * M_PI * 2; + double angle = random->nextDouble() * std::numbers::pi * 2; double xs = cos(angle) * dist; double ys = 0.01 + random->nextDouble() * 0.5; double zs = sin(angle) * dist; @@ -3608,10 +3608,10 @@ int LevelRenderer::getGlobalIndexForChunk(int x, int y, int z, // int xx = ( x / CHUNK_XZSIZE ) + ( MAX_LEVEL_RENDER_SIZE[dimIdx] / 2 ); // int yy = y / CHUNK_SIZE; // int zz = ( z / CHUNK_XZSIZE ) + ( MAX_LEVEL_RENDER_SIZE[dimIdx] / 2 ); - int xx = (Mth::intFloorDiv(x, CHUNK_XZSIZE)) + + int xx = (GameMath::intFloorDiv(x, CHUNK_XZSIZE)) + (MAX_LEVEL_RENDER_SIZE[dimIdx] / 2); - int yy = Mth::intFloorDiv(y, CHUNK_SIZE); - int zz = (Mth::intFloorDiv(z, CHUNK_XZSIZE)) + + int yy = GameMath::intFloorDiv(y, CHUNK_SIZE); + int zz = (GameMath::intFloorDiv(z, CHUNK_XZSIZE)) + (MAX_LEVEL_RENDER_SIZE[dimIdx] / 2); if ((xx < 0) || (xx >= MAX_LEVEL_RENDER_SIZE[dimIdx])) return -1; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/TileRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/TileRenderer.cpp index 79e93501e..1b96b2f0b 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/TileRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/TileRenderer.cpp @@ -748,7 +748,7 @@ bool TileRenderer::tesselateBrewingStandInWorld(BrewingStandTile* tt, int x, int data = level->getData(x, y, z); for (int arm = 0; arm < 3; arm++) { - float angle = arm * M_PI * 2.0f / 3.0f + M_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 u1 = tex->getU1(true); @@ -1832,26 +1832,26 @@ bool TileRenderer::tesselateLeverInWorld(Tile* tt, int x, int y, int z) { for (int i = 0; i < 8; i++) { if (flipped) { corners[i].z -= 1 / 16.0f; - corners[i].xRot(40 * M_PI / 180); + corners[i].xRot(40 * std::numbers::pi / 180); } else { corners[i].z += 1 / 16.0f; - corners[i].xRot(-40 * M_PI / 180); + corners[i].xRot(-40 * std::numbers::pi / 180); } if (dir == 0 || dir == 7) { - corners[i].zRot(180 * M_PI / 180); + corners[i].zRot(180 * std::numbers::pi / 180); } if (dir == 6 || dir == 0) { - corners[i].yRot(90 * M_PI / 180); + corners[i].yRot(90 * std::numbers::pi / 180); } if (dir > 0 && dir < 5) { corners[i].y -= 6 / 16.0f; - corners[i].xRot(90 * M_PI / 180); + corners[i].xRot(90 * std::numbers::pi / 180); - if (dir == 4) corners[i].yRot(0 * M_PI / 180); - if (dir == 3) corners[i].yRot(180 * M_PI / 180); - if (dir == 2) corners[i].yRot(90 * M_PI / 180); - if (dir == 1) corners[i].yRot(-90 * M_PI / 180); + if (dir == 4) corners[i].yRot(0 * std::numbers::pi / 180); + if (dir == 3) corners[i].yRot(180 * std::numbers::pi / 180); + if (dir == 2) corners[i].yRot(90 * std::numbers::pi / 180); + if (dir == 1) corners[i].yRot(-90 * std::numbers::pi / 180); corners[i].x += x + 0.5; corners[i].y += y + 8 / 16.0f; @@ -1992,22 +1992,22 @@ bool TileRenderer::tesselateTripwireSourceInWorld(Tile* tt, int x, int y, corners[i].z += 1 / 16.0f; if (powered) { - corners[i].xRot(30 * M_PI / 180); + corners[i].xRot(30 * std::numbers::pi / 180); corners[i].y -= 7 / 16.0f; } else if (attached) { - corners[i].xRot(5 * M_PI / 180); + corners[i].xRot(5 * std::numbers::pi / 180); corners[i].y -= 7 / 16.0f; } else { - corners[i].xRot(-40 * M_PI / 180); + corners[i].xRot(-40 * std::numbers::pi / 180); corners[i].y -= 6 / 16.0f; } - corners[i].xRot(90 * M_PI / 180); + corners[i].xRot(90 * std::numbers::pi / 180); - if (dir == Direction::NORTH) corners[i].yRot(0 * M_PI / 180); - if (dir == Direction::SOUTH) corners[i].yRot(180 * M_PI / 180); - if (dir == Direction::WEST) corners[i].yRot(90 * M_PI / 180); - if (dir == Direction::EAST) corners[i].yRot(-90 * M_PI / 180); + if (dir == Direction::NORTH) corners[i].yRot(0 * std::numbers::pi / 180); + if (dir == Direction::SOUTH) 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].y += y + 5 / 16.0f; @@ -2084,19 +2084,19 @@ bool TileRenderer::tesselateTripwireSourceInWorld(Tile* tt, int x, int y, if (powered) { corners[i].y -= 1.5 / 16.0f; corners[i].z -= 2.6 / 16.0f; - corners[i].xRot(0 * M_PI / 180); + corners[i].xRot(0 * std::numbers::pi / 180); } else if (attached) { corners[i].y += 0.25 / 16.0f; corners[i].z -= 2.75 / 16.0f; - corners[i].xRot(10 * M_PI / 180); + corners[i].xRot(10 * std::numbers::pi / 180); } else { - corners[i].xRot(50 * M_PI / 180); + corners[i].xRot(50 * std::numbers::pi / 180); } - if (dir == Direction::NORTH) corners[i].yRot(0 * M_PI / 180); - if (dir == Direction::SOUTH) corners[i].yRot(180 * M_PI / 180); - if (dir == Direction::WEST) corners[i].yRot(90 * M_PI / 180); - if (dir == Direction::EAST) corners[i].yRot(-90 * M_PI / 180); + if (dir == Direction::NORTH) corners[i].yRot(0 * std::numbers::pi / 180); + if (dir == Direction::SOUTH) 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].y += y + 5 / 16.0f; @@ -4585,8 +4585,8 @@ bool TileRenderer::tesselateWaterInWorld(Tile* tt, int x, int y, int z) { u11 = u10; v11 = v00; } else { - float s = Mth::sin(angle) * .25f; - float c = Mth::cos(angle) * .25f; + float s = sinf(angle) * .25f; + float c = cosf(angle) * .25f; float cc = SharedConstants::WORLD_RESOLUTION * .5f; u00 = tex->getU(cc + (-c - s) * SharedConstants::WORLD_RESOLUTION); v00 = tex->getV(cc + (-c + s) * SharedConstants::WORLD_RESOLUTION); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/culling/ViewportCuller.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/culling/ViewportCuller.cpp index 2db484bd7..10883f5e3 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/culling/ViewportCuller.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/culling/ViewportCuller.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "ViewportCuller.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" ViewportCuller::Face::Face(double x, double y, double z, float yRot, float xRot) { @@ -8,9 +8,9 @@ ViewportCuller::Face::Face(double x, double y, double z, float yRot, this->yc = y; this->zc = z; - xd = Mth::sin(yRot / 180 * M_PI) * Mth::cos(xRot / 180 * M_PI); - zd = -Mth::cos(yRot / 180 * M_PI) * Mth::cos(xRot / 180 * M_PI); - yd = -Mth::sin(xRot / 180 * M_PI); + xd = sinf(yRot / 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); cullOffs = xc * xd + yc * yd + zc * zd; } @@ -56,9 +56,9 @@ ViewportCuller::ViewportCuller(std::shared_ptr mob, double y = mob->yOld + (mob->y - mob->yOld) * a; double z = mob->zOld + (mob->z - mob->zOld) * a; - double xd = Mth::sin(yRot / 180 * M_PI) * Mth::cos(xRot / 180 * M_PI); - double zd = -Mth::cos(yRot / 180 * M_PI) * Mth::cos(xRot / 180 * M_PI); - double yd = -Mth::sin(xRot / 180 * M_PI); + double xd = sinf(yRot / 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); float xFov = 30; float yFov = 45; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ArrowRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ArrowRenderer.cpp index 89460bacc..3f457e390 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ArrowRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ArrowRenderer.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "ArrowRenderer.h" #include "Minecraft.World/net/minecraft/world/entity/projectile/net.minecraft.world.entity.projectile.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" ResourceLocation ArrowRenderer::ARROW_LOCATION = ResourceLocation(TN_ITEM_ARROWS); @@ -49,7 +49,7 @@ void ArrowRenderer::render(std::shared_ptr _arrow, double x, double y, glEnable(GL_RESCALE_NORMAL); float shake = arrow->shakeTime - a; if (shake > 0) { - float pow = -Mth::sin(shake * 3) * shake; + float pow = -sinf(shake * 3) * shake; glRotatef(pow, 0, 0, 1); } glRotatef(45, 1, 0, 0); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/BoatRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/BoatRenderer.cpp index b92817271..fc4721e00 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/BoatRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/BoatRenderer.cpp @@ -2,7 +2,7 @@ #include "BoatRenderer.h" #include "../../model/BoatModel.h" #include "Minecraft.World/net/minecraft/world/entity/item/net.minecraft.world.entity.item.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" ResourceLocation BoatRenderer::BOAT_LOCATION = ResourceLocation(TN_ITEM_BOAT); @@ -27,7 +27,7 @@ void BoatRenderer::render(std::shared_ptr _boat, double x, double y, float dmg = boat->getDamage() - a; if (dmg < 0) dmg = 0; if (hurt > 0) { - glRotatef(Mth::sin(hurt) * hurt * dmg / 10 * boat->getHurtDir(), 1, 0, + glRotatef(sinf(hurt) * hurt * dmg / 10 * boat->getHurtDir(), 1, 0, 0); } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ChickenRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ChickenRenderer.cpp index 2f3531d7c..926b05eb2 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ChickenRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ChickenRenderer.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "ChickenRenderer.h" #include "Minecraft.World/net/minecraft/world/entity/animal/net.minecraft.world.entity.animal.h" @@ -22,7 +22,7 @@ float ChickenRenderer::getBob(std::shared_ptr _mob, float a) { float flap = mob->oFlap + (mob->flap - mob->oFlap) * a; float flapSpeed = mob->oFlapSpeed + (mob->flapSpeed - mob->oFlapSpeed) * a; - return (Mth::sin(flap) + 1) * flapSpeed; + return (sinf(flap) + 1) * flapSpeed; } ResourceLocation* ChickenRenderer::getTextureLocation( diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/CreeperRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/CreeperRenderer.cpp index 27cf99351..88260a71c 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/CreeperRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/CreeperRenderer.cpp @@ -2,7 +2,7 @@ #include "CreeperRenderer.h" #include "../../model/CreeperModel.h" #include "Minecraft.World/net/minecraft/world/entity/monster/net.minecraft.world.entity.monster.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" ResourceLocation CreeperRenderer::POWER_LOCATION = ResourceLocation(TN_POWERED_CREEPER); @@ -18,7 +18,7 @@ void CreeperRenderer::scale(std::shared_ptr mob, float a) { float g = creeper->getSwelling(a); - float wobble = 1.0f + Mth::sin(g * 100) * g * 0.01f; + float wobble = 1.0f + sinf(g * 100) * g * 0.01f; if (g < 0) g = 0; if (g > 1) g = 1; g = g * g; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EnderDragonRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EnderDragonRenderer.cpp index 043ce2d16..e39c48586 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EnderDragonRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EnderDragonRenderer.cpp @@ -123,8 +123,8 @@ void EnderDragonRenderer::render(std::shared_ptr _mob, double x, glPushMatrix(); glTranslatef((float)x, (float)y + 2, (float)z); - glRotatef((float)(-atan2(zd, xd)) * 180.0f / M_PI - 90.0f, 0, 1, 0); - glRotatef((float)(-atan2(sdd, yd)) * 180.0f / M_PI - 90.0f, 1, 0, 0); + glRotatef((float)(-atan2(zd, xd)) * 180.0f / std::numbers::pi - 90.0f, 0, 1, 0); + glRotatef((float)(-atan2(sdd, yd)) * 180.0f / std::numbers::pi - 90.0f, 1, 0, 0); // 4J-PB - Rotating the healing beam too static float fRot = 0.0f; @@ -157,9 +157,9 @@ void EnderDragonRenderer::render(std::shared_ptr _mob, double x, int steps = 8; for (int i = 0; i <= steps; i++) { - double d = i % steps * M_PI * 2 / steps; - float s = sin(i % steps * M_PI * 2 / steps) * 0.75f; - float c = cos(i % steps * M_PI * 2 / steps) * 0.75f; + double d = i % steps * std::numbers::pi * 2 / steps; + float s = sin(i % steps * std::numbers::pi * 2 / steps) * 0.75f; + float c = cos(i % steps * std::numbers::pi * 2 / steps) * 0.75f; float u = i % steps * 1.0f / steps; // t->color(0x000000); t->vertexUV(s * 0.2f, c * 0.2f, 0, u, v1); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderDispatcher.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderDispatcher.cpp index b7009bca6..f87ad696d 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderDispatcher.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderDispatcher.cpp @@ -224,12 +224,12 @@ void EntityRenderDispatcher::prepare( this->crosshairPickMob = crosshairPickMob; if (player->isSleeping()) { - int t = level->getTile(Mth::floor(player->x), Mth::floor(player->y), - Mth::floor(player->z)); + int t = level->getTile(GameMath::floor(player->x), GameMath::floor(player->y), + GameMath::floor(player->z)); if (t == Tile::bed_Id) { int data = - level->getData(Mth::floor(player->x), Mth::floor(player->y), - Mth::floor(player->z)); + level->getData(GameMath::floor(player->x), GameMath::floor(player->y), + GameMath::floor(player->z)); int direction = data & 3; playerRotY = (float)(direction * 90 + 180); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderer.cpp index b83161cef..c9cd09ac0 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderer.cpp @@ -10,7 +10,7 @@ #include "Minecraft.World/net/minecraft/world/entity/net.minecraft.world.entity.h" #include "Minecraft.World/net/minecraft/world/level/Level.h" #include "Minecraft.World/net/minecraft/world/phys/AABB.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "Minecraft.World/net/minecraft/world/entity/animal/net.minecraft.world.entity.animal.h" ResourceLocation EntityRenderer::SHADOW_LOCATION = @@ -175,12 +175,12 @@ void EntityRenderer::renderShadow(std::shared_ptr e, double x, double y, } double ez = e->zOld + (e->z - e->zOld) * a; - int x0 = Mth::floor(ex - r); - int x1 = Mth::floor(ex + r); - int y0 = Mth::floor(ey - r); - int y1 = Mth::floor(ey); - int z0 = Mth::floor(ez - r); - int z1 = Mth::floor(ez + r); + int x0 = GameMath::floor(ex - r); + int x1 = GameMath::floor(ex + r); + int y0 = GameMath::floor(ey - r); + int y1 = GameMath::floor(ey); + int z0 = GameMath::floor(ez - r); + int z1 = GameMath::floor(ez + r); double xo = x - ex; double yo = y - ey; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ExperienceOrbRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ExperienceOrbRenderer.cpp index 034c47eac..69fd7e7c3 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ExperienceOrbRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ExperienceOrbRenderer.cpp @@ -5,7 +5,7 @@ #include "Minecraft.World/net/minecraft/world/item/net.minecraft.world.item.h" #include "../Tesselator.h" #include "EntityRenderDispatcher.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "java/JavaMath.h" ResourceLocation ExperienceOrbRenderer::XP_ORB_LOCATION = @@ -47,9 +47,9 @@ void ExperienceOrbRenderer::render(std::shared_ptr _orb, double x, } float br = 255.0f; float rr = (orb->tickCount + a) / 2; - int rc = (int)((Mth::sin(rr + 0 * M_PI * 2 / 3) + 1) * 0.5f * br); + int rc = (int)((sinf(rr + 0 * std::numbers::pi * 2 / 3) + 1) * 0.5f * br); int gc = (int)(br); - int bc = (int)((Mth::sin(rr + 2 * M_PI * 2 / 3) + 1) * 0.1f * br); + int bc = (int)((sinf(rr + 2 * std::numbers::pi * 2 / 3) + 1) * 0.1f * br); int col = rc << 16 | gc << 8 | bc; glRotatef(180 - entityRenderDispatcher->playerRotY, 0, 1, 0); glRotatef(-entityRenderDispatcher->playerRotX, 1, 0, 0); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FallingTileRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FallingTileRenderer.cpp index 00999b033..fe26c90f6 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FallingTileRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FallingTileRenderer.cpp @@ -39,28 +39,28 @@ void FallingTileRenderer::render(std::shared_ptr _tile, double x, tileRenderer->level = level; Tesselator* t = Tesselator::getInstance(); t->begin(); - t->offset(-Mth::floor(tile->x) - 0.5f, -Mth::floor(tile->y) - 0.5f, - -Mth::floor(tile->z) - 0.5f); + t->offset(-GameMath::floor(tile->x) - 0.5f, -GameMath::floor(tile->y) - 0.5f, + -GameMath::floor(tile->z) - 0.5f); tileRenderer->tesselateAnvilInWorld( - (AnvilTile*)tt, Mth::floor(tile->x), Mth::floor(tile->y), - Mth::floor(tile->z), tile->data); + (AnvilTile*)tt, GameMath::floor(tile->x), GameMath::floor(tile->y), + GameMath::floor(tile->z), tile->data); t->offset(0, 0, 0); t->end(); } else if (tt == Tile::dragonEgg) { tileRenderer->level = level; Tesselator* t = Tesselator::getInstance(); t->begin(); - t->offset(-Mth::floor(tile->x) - 0.5f, -Mth::floor(tile->y) - 0.5f, - -Mth::floor(tile->z) - 0.5f); - tileRenderer->tesselateInWorld(tt, Mth::floor(tile->x), - Mth::floor(tile->y), - Mth::floor(tile->z)); + t->offset(-GameMath::floor(tile->x) - 0.5f, -GameMath::floor(tile->y) - 0.5f, + -GameMath::floor(tile->z) - 0.5f); + tileRenderer->tesselateInWorld(tt, GameMath::floor(tile->x), + GameMath::floor(tile->y), + GameMath::floor(tile->z)); t->offset(0, 0, 0); t->end(); } else if (tt != nullptr) { tileRenderer->setShape(tt); - tileRenderer->renderBlock(tt, level, Mth::floor(tile->x), - Mth::floor(tile->y), Mth::floor(tile->z), + tileRenderer->renderBlock(tt, level, GameMath::floor(tile->x), + GameMath::floor(tile->y), GameMath::floor(tile->z), tile->data); } glEnable(GL_LIGHTING); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FishingHookRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FishingHookRenderer.cpp index 166d10e14..237e50309 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FishingHookRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FishingHookRenderer.cpp @@ -5,7 +5,7 @@ #include "Minecraft.World/net/minecraft/world/entity/projectile/net.minecraft.world.entity.projectile.h" #include "Minecraft.World/net/minecraft/world/entity/player/net.minecraft.world.entity.player.h" #include "Minecraft.World/net/minecraft/world/phys/Vec3.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "../../multiplayer/MultiPlayerLocalPlayer.h" ResourceLocation FishingHookRenderer::PARTICLE_LOCATION = @@ -56,15 +56,15 @@ void FishingHookRenderer::render(std::shared_ptr _hook, double x, if (hook->owner != nullptr) { float swing = hook->owner->getAttackAnim(a); - float swing2 = (float)Mth::sin(sqrt(swing) * M_PI); + float swing2 = (float)sinf(sqrt(swing) * std::numbers::pi); Vec3 vv(-0.5, 0.03, 0.8); vv.xRot(-(hook->owner->xRotO + (hook->owner->xRot - hook->owner->xRotO) * a) * - M_PI / 180); + std::numbers::pi / 180); vv.yRot(-(hook->owner->yRotO + (hook->owner->yRot - hook->owner->yRotO) * a) * - M_PI / 180); + std::numbers::pi / 180); vv.yRot(swing2 * 0.5f); vv.xRot(-swing2 * 0.7f); @@ -85,9 +85,9 @@ void FishingHookRenderer::render(std::shared_ptr _hook, double x, float rr = (float)(hook->owner->yBodyRotO + (hook->owner->yBodyRot - hook->owner->yBodyRotO) * a) * - M_PI / 180; - double ss = Mth::sin((float)rr); - double cc = Mth::cos((float)rr); + std::numbers::pi / 180; + double ss = sinf((float)rr); + double cc = cosf((float)rr); xp = hook->owner->xo + (hook->owner->x - hook->owner->xo) * a - cc * 0.35 - ss * 0.85; yp = hook->owner->yo + yOffset + diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemFrameRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemFrameRenderer.cpp index 681d634bc..193910be0 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemFrameRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemFrameRenderer.cpp @@ -179,7 +179,7 @@ void ItemFrameRenderer::drawItem(std::shared_ptr entity) { ct->rota = 0; ct->updateFromPosition( entity->level, entity->x, entity->z, - Mth::wrapDegrees((float)(180 + entity->dir * 90)), false, true); + GameMath::wrapDegrees((float)(180 + entity->dir * 90)), false, true); ct->rot = compassRot; ct->rota = compassRotA; } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemRenderer.cpp index 867bf4be1..57525026c 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemRenderer.cpp @@ -55,10 +55,10 @@ void ItemRenderer::render(std::shared_ptr _itemEntity, double x, glPushMatrix(); float bob = - Mth::sin((itemEntity->age + a) / 10.0f + itemEntity->bobOffs) * 0.1f + + sinf((itemEntity->age + a) / 10.0f + itemEntity->bobOffs) * 0.1f + 0.1f; float spin = - ((itemEntity->age + a) / 20.0f + itemEntity->bobOffs) * Mth::RADDEG; + ((itemEntity->age + a) / 20.0f + itemEntity->bobOffs) * GameMath::RAD_TO_DEG; int count = 1; if (itemEntity->getItem()->count > 1) count = 2; @@ -211,7 +211,7 @@ void ItemRenderer::renderItemBillboard(std::shared_ptr entity, glRotatef(180, 0, 1, 0); } else { glRotatef( - ((entity->age + a) / 20.0f + entity->bobOffs) * Mth::RADDEG, 0, + ((entity->age + a) / 20.0f + entity->bobOffs) * GameMath::RAD_TO_DEG, 0, 1, 0); } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/LivingEntityRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/LivingEntityRenderer.cpp index 831710ba5..08a1a1daa 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/LivingEntityRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/LivingEntityRenderer.cpp @@ -6,7 +6,7 @@ #include "EntityRenderDispatcher.h" #include "../../multiplayer/MultiPlayerLocalPlayer.h" #include "Minecraft.World/net/minecraft/world/entity/projectile/Arrow.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "Minecraft.World/net/minecraft/world/entity/player/Player.h" ResourceLocation LivingEntityRenderer::ENCHANT_GLINT_LOCATION = @@ -53,7 +53,7 @@ void LivingEntityRenderer::render(std::shared_ptr _mob, double x, std::dynamic_pointer_cast(mob->riding); bodyRot = rotlerp(riding->yBodyRotO, riding->yBodyRot, a); - float headDiff = Mth::wrapDegrees(headRot - bodyRot); + float headDiff = GameMath::wrapDegrees(headRot - bodyRot); if (headDiff < -85) headDiff = -85; if (headDiff >= 85) headDiff = +85; bodyRot = headRot - headDiff; @@ -319,8 +319,8 @@ void LivingEntityRenderer::renderArrows(std::shared_ptr mob, zd *= -1; } float sd = (float)sqrt(xd * xd + zd * zd); - arrow->yRotO = arrow->yRot = (float)(atan2(xd, zd) * 180 / M_PI); - arrow->xRotO = arrow->xRot = (float)(atan2(yd, sd) * 180 / M_PI); + arrow->yRotO = arrow->yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); + arrow->xRotO = arrow->xRot = (float)(atan2(yd, sd) * 180 / std::numbers::pi); double x = 0; double y = 0; double z = 0; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/MinecartRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/MinecartRenderer.cpp index 88a274b29..f80a73b63 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/MinecartRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/MinecartRenderer.cpp @@ -60,7 +60,7 @@ void MinecartRenderer::render(std::shared_ptr _cart, double x, double y, if (dir.length() == 0) { } else { dir = dir.normalize(); - rot = (float)(atan2(dir.z, dir.x) * 180 / M_PI); + rot = (float)(atan2(dir.z, dir.x) * 180 / std::numbers::pi); xRot = (float)(atan(dir.y) * 73); } } @@ -72,7 +72,7 @@ void MinecartRenderer::render(std::shared_ptr _cart, double x, double y, float dmg = cart->getDamage() - a; if (dmg < 0) dmg = 0; if (hurt > 0) { - glRotatef(Mth::sin(hurt) * hurt * dmg / 10 * cart->getHurtDir(), 1, 0, + glRotatef(sinf(hurt) * hurt * dmg / 10 * cart->getHurtDir(), 1, 0, 0); } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/MobRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/MobRenderer.cpp index 42e75ac04..a1102ce57 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/MobRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/MobRenderer.cpp @@ -6,7 +6,7 @@ #include "Minecraft.World/net/minecraft/world/entity/player/net.minecraft.world.entity.player.h" #include "Minecraft.World/net/minecraft/world/entity/projectile/net.minecraft.world.entity.projectile.h" #include "Minecraft.World/ConsoleHelpers/StringHelpers.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "EntityRenderDispatcher.h" MobRenderer::MobRenderer(Model* model, float shadow) @@ -37,9 +37,9 @@ void MobRenderer::renderLeash(std::shared_ptr entity, double x, double y, y -= (1.6 - entity->bbHeight) * .5; Tesselator* tessellator = Tesselator::getInstance(); double roperYRot = - lerp(roper->yRotO, roper->yRot, a * .5f) * Mth::RAD_TO_GRAD; + lerp(roper->yRotO, roper->yRot, a * .5f) * GameMath::DEG_TO_RAD; double roperXRot = - lerp(roper->xRotO, roper->xRot, a * .5f) * Mth::RAD_TO_GRAD; + lerp(roper->xRotO, roper->xRot, a * .5f) * GameMath::DEG_TO_RAD; double rotOffCos = cos(roperYRot); double rotOffSin = sin(roperYRot); double yOff = sin(roperXRot); @@ -58,8 +58,8 @@ void MobRenderer::renderLeash(std::shared_ptr entity, double x, double y, (rotOffCos * 0.5 * swingOff); double entityYRot = - lerp(entity->yBodyRotO, entity->yBodyRot, a) * Mth::RAD_TO_GRAD + - M_PI * .5; + lerp(entity->yBodyRotO, entity->yBodyRot, a) * GameMath::DEG_TO_RAD + + std::numbers::pi * .5; rotOffCos = cos(entityYRot) * entity->bbWidth * .4; rotOffSin = sin(entityYRot) * entity->bbWidth * .4; double startX = lerp(entity->xo, entity->x, a) + rotOffCos; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/PaintingRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/PaintingRenderer.cpp index 3445354f8..9bd21b7ec 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/PaintingRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/PaintingRenderer.cpp @@ -4,7 +4,7 @@ #include "Minecraft.World/net/minecraft/world/entity/net.minecraft.world.entity.h" #include "Minecraft.World/net/minecraft/world/level/net.minecraft.world.level.h" #include "java/Random.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" ResourceLocation PaintingRenderer::PAINTING_LOCATION(TN_ART_KZ); @@ -118,13 +118,13 @@ void PaintingRenderer::renderPainting(std::shared_ptr painting, int w, void PaintingRenderer::setBrightness(std::shared_ptr painting, float ss, float ya) { - int x = Mth::floor(painting->x); - int y = Mth::floor(painting->y + ya / 16.0f); - int z = Mth::floor(painting->z); - if (painting->dir == 0) x = Mth::floor(painting->x + ss / 16.0f); - if (painting->dir == 1) z = Mth::floor(painting->z - ss / 16.0f); - if (painting->dir == 2) x = Mth::floor(painting->x - ss / 16.0f); - if (painting->dir == 3) z = Mth::floor(painting->z + ss / 16.0f); + int x = GameMath::floor(painting->x); + int y = GameMath::floor(painting->y + ya / 16.0f); + int z = GameMath::floor(painting->z); + if (painting->dir == 0) x = GameMath::floor(painting->x + ss / 16.0f); + if (painting->dir == 1) z = GameMath::floor(painting->z - ss / 16.0f); + if (painting->dir == 2) x = GameMath::floor(painting->x - ss / 16.0f); + if (painting->dir == 3) z = GameMath::floor(painting->z + ss / 16.0f); int col = this->entityRenderDispatcher->level->getLightColor(x, y, z, 0); int u = col % 65536; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/PlayerRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/PlayerRenderer.cpp index 669fec242..bba0a5b90 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/PlayerRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/PlayerRenderer.cpp @@ -318,8 +318,8 @@ bool b2 = !mob->isCapeHidden();*/ float yr = mob->yBodyRotO + (mob->yBodyRot - mob->yBodyRotO) * a; - double xa = Mth::sin(yr * M_PI / 180); - double za = -Mth::cos(yr * M_PI / 180); + double xa = sinf(yr * std::numbers::pi / 180); + double za = -cosf(yr * std::numbers::pi / 180); float flap = (float)yd * 10; if (flap < -6) flap = -6; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/VillagerGolemRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/VillagerGolemRenderer.cpp index 9a46afa63..b650fa436 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/VillagerGolemRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/VillagerGolemRenderer.cpp @@ -55,7 +55,7 @@ void VillagerGolemRenderer::additionalRendering( glPushMatrix(); // dont ask me how I got the flower into his hand. - glRotatef(5 + 180 * golemModel->arm0->xRot / M_PI, 1, 0, 0); + glRotatef(5 + 180 * golemModel->arm0->xRot / std::numbers::pi, 1, 0, 0); glTranslatef(-11 / 16.0f, 20 / 16.0f, -15 / 16.0f); glRotatef(90, 1, 0, 0); float s = 0.8f; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ZombieRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ZombieRenderer.cpp index afa412c93..451be499d 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ZombieRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ZombieRenderer.cpp @@ -99,7 +99,7 @@ void ZombieRenderer::setupRotations(std::shared_ptr _mob, float bob, float bodyRot, float a) { std::shared_ptr mob = std::dynamic_pointer_cast(_mob); if (mob->isConverting()) { - bodyRot += (float)(cos(mob->tickCount * 3.25) * M_PI * .25f); + bodyRot += (float)(cos(mob->tickCount * 3.25) * std::numbers::pi * .25f); } HumanoidMobRenderer::setupRotations(mob, bob, bodyRot, a); } \ No newline at end of file diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/texture/custom/CompassTexture.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/texture/custom/CompassTexture.cpp index c33edc0ad..5b3a70ea6 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/texture/custom/CompassTexture.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/texture/custom/CompassTexture.cpp @@ -51,9 +51,9 @@ void CompassTexture::updateFromPosition(Level* level, double x, double z, double za = spawnPos->z - z; delete spawnPos; yRot = (int)yRot % 360; - rott = -((yRot - 90) * M_PI / 180 - atan2(za, xa)); + rott = -((yRot - 90) * std::numbers::pi / 180 - atan2(za, xa)); if (!level->dimension->isNaturalDimension()) { - rott = Math::random() * M_PI * 2; + rott = Math::random() * std::numbers::pi * 2; } } @@ -61,8 +61,8 @@ void CompassTexture::updateFromPosition(Level* level, double x, double z, rot = rott; } else { double rotd = rott - rot; - while (rotd < -M_PI ) rotd += M_PI * 2; - while (rotd >= M_PI) rotd -= M_PI * 2; + while (rotd < -std::numbers::pi ) rotd += std::numbers::pi * 2; + while (rotd >= std::numbers::pi) rotd -= std::numbers::pi * 2; if (rotd < -1) rotd = -1; if (rotd > 1) rotd = 1; rota += rotd * 0.1; @@ -73,7 +73,7 @@ void CompassTexture::updateFromPosition(Level* level, double x, double z, // 4J Stu - We share data with another texture if (m_dataTexture != nullptr) { int newFrame = - (int)(((rot / (M_PI * 2)) + 1.0) * m_dataTexture->frames->size()) % + (int)(((rot / (std::numbers::pi * 2)) + 1.0) * m_dataTexture->frames->size()) % m_dataTexture->frames->size(); while (newFrame < 0) { newFrame = (newFrame + m_dataTexture->frames->size()) % @@ -87,7 +87,7 @@ void CompassTexture::updateFromPosition(Level* level, double x, double z, } } else { int newFrame = - (int)(((rot / (M_PI * 2)) + 1.0) * frames->size()) % frames->size(); + (int)(((rot / (std::numbers::pi * 2)) + 1.0) * frames->size()) % frames->size(); while (newFrame < 0) { newFrame = (newFrame + frames->size()) % frames->size(); } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/BeaconRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/BeaconRenderer.cpp index fecabf317..96aa640b5 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/BeaconRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/BeaconRenderer.cpp @@ -44,15 +44,15 @@ void BeaconRenderer::render(std::shared_ptr _beacon, double x, double rr1 = r * 0.2; - double wnx = .5 + cos(rot + M_PI * .75) * rr1; - double wnz = .5 + sin(rot + M_PI * .75) * rr1; - double enx = .5 + cos(rot + M_PI * .25) * rr1; - double enz = .5 + sin(rot + M_PI * .25) * rr1; + double wnx = .5 + cos(rot + std::numbers::pi * .75) * rr1; + double wnz = .5 + sin(rot + std::numbers::pi * .75) * rr1; + double enx = .5 + cos(rot + std::numbers::pi * .25) * rr1; + double enz = .5 + sin(rot + std::numbers::pi * .25) * rr1; - double wsx = .5 + cos(rot + M_PI * 1.25) * rr1; - double wsz = .5 + sin(rot + M_PI * 1.25) * rr1; - double esx = .5 + cos(rot + M_PI * 1.75) * rr1; - double esz = .5 + sin(rot + M_PI * 1.75) * rr1; + double wsx = .5 + cos(rot + std::numbers::pi * 1.25) * rr1; + double wsz = .5 + sin(rot + std::numbers::pi * 1.25) * rr1; + double esx = .5 + cos(rot + std::numbers::pi * 1.75) * rr1; + double esz = .5 + sin(rot + std::numbers::pi * 1.75) * rr1; double top = 256 * scale; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/ChestRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/ChestRenderer.cpp index aecd7fa31..923b75618 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/ChestRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/ChestRenderer.cpp @@ -128,7 +128,7 @@ void ChestRenderer::render(std::shared_ptr _chest, double x, open = 1 - open; open = 1 - open * open * open; - model->lid->xRot = -(open * M_PI / 2); + model->lid->xRot = -(open * std::numbers::pi / 2); model->render(useCompiled); glDisable(GL_RESCALE_NORMAL); glPopMatrix(); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/EnchantTableRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/EnchantTableRenderer.cpp index 800b32e5d..03b5cce9b 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/EnchantTableRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/EnchantTableRenderer.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "../../model/BookModel.h" #include "Minecraft.World/net/minecraft/world/level/tile/entity/net.minecraft.world.level.tile.entity.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "EnchantTableRenderer.h" ResourceLocation EnchantTableRenderer::BOOK_LOCATION = @@ -25,19 +25,19 @@ void EnchantTableRenderer::render(std::shared_ptr _table, double x, glTranslatef(0, 0.1f + sin(tt * 0.1f) * 0.01f, 0); float orot = (table->rot - table->oRot); - while (orot >= M_PI) orot -= M_PI * 2; - while (orot < -M_PI ) orot += M_PI * 2; + while (orot >= std::numbers::pi) orot -= std::numbers::pi * 2; + while (orot < -std::numbers::pi ) orot += std::numbers::pi * 2; float yRot = table->oRot + orot * a; - glRotatef(-yRot * 180 / M_PI, 0, 1, 0); + glRotatef(-yRot * 180 / std::numbers::pi, 0, 1, 0); glRotatef(80, 0, 0, 1); bindTexture(&BOOK_LOCATION); // 4J was "/item/book.png" float ff1 = table->oFlip + (table->flip - table->oFlip) * a + 0.25f; float ff2 = table->oFlip + (table->flip - table->oFlip) * a + 0.75f; - ff1 = (ff1 - Mth::fastFloor(ff1)) * 1.6f - 0.3f; - ff2 = (ff2 - Mth::fastFloor(ff2)) * 1.6f - 0.3f; + ff1 = (ff1 - GameMath::fastFloor(ff1)) * 1.6f - 0.3f; + ff2 = (ff2 - GameMath::fastFloor(ff2)) * 1.6f - 0.3f; if (ff1 < 0) ff1 = 0; if (ff2 < 0) ff2 = 0; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/EnderChestRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/EnderChestRenderer.cpp index f4cf8d8b9..d0c8936bd 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/EnderChestRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/EnderChestRenderer.cpp @@ -42,7 +42,7 @@ void EnderChestRenderer::render(std::shared_ptr _chest, double x, open = 1 - open; open = 1 - open * open * open; - chestModel.lid->xRot = -(open * M_PI / 2); + chestModel.lid->xRot = -(open * std::numbers::pi / 2); chestModel.render(useCompiled); glDisable(GL_RESCALE_NORMAL); glPopMatrix(); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/title/TitleScreen.cpp b/minecraft/Minecraft.Client/net/minecraft/client/title/TitleScreen.cpp index 3be3b8b9c..dcb5551dc 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/title/TitleScreen.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/title/TitleScreen.cpp @@ -391,8 +391,8 @@ void TitleScreen::render(int xm, int ym, float a) { glTranslatef((float)width / 2 + 90, 70, 0); glRotatef(-20, 0, 0, 1); - float sss = 1.8f - Mth::abs(Mth::sin(System::currentTimeMillis() % 1000 / - 1000.0f * M_PI * 2) * + float sss = 1.8f - GameMath::abs(sinf(System::currentTimeMillis() % 1000 / + 1000.0f * std::numbers::pi * 2) * 0.1f); sss = sss * 100 / (font->width(splash) + 8 * 4); diff --git a/minecraft/Minecraft.Client/net/minecraft/server/MinecraftServer.cpp b/minecraft/Minecraft.Client/net/minecraft/server/MinecraftServer.cpp index 5c2a6113c..30900ffd7 100644 --- a/minecraft/Minecraft.Client/net/minecraft/server/MinecraftServer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/server/MinecraftServer.cpp @@ -206,7 +206,7 @@ bool MinecraftServer::initServer(int64_t seed, NetworkGameInitData* initData, settings->getInt(L"max-build-height", Level::maxBuildHeight)); setMaxBuildHeight(((getMaxBuildHeight() + 8) / 16) * 16); setMaxBuildHeight( - Mth::clamp(getMaxBuildHeight(), 64, Level::maxBuildHeight)); + GameMath::clamp(getMaxBuildHeight(), 64, Level::maxBuildHeight)); // settings->setProperty(L"max-build-height", maxBuildHeight); // logger.info("Preparing level \"" + levelName + "\""); @@ -1014,8 +1014,8 @@ bool MinecraftServer::isUnderSpawnProtection(Level* level, int x, int y, int z, if (getSpawnProtectionRadius() <= 0) return false; Pos* spawnPos = level->getSharedSpawnPos(); - int xd = Mth::abs(x - spawnPos->x); - int zd = Mth::abs(z - spawnPos->z); + int xd = GameMath::abs(x - spawnPos->x); + int zd = GameMath::abs(z - spawnPos->z); int dist = std::max(xd, zd); return dist <= getSpawnProtectionRadius(); diff --git a/minecraft/Minecraft.Client/net/minecraft/server/PlayerList.cpp b/minecraft/Minecraft.Client/net/minecraft/server/PlayerList.cpp index 250b3e538..96709c756 100644 --- a/minecraft/Minecraft.Client/net/minecraft/server/PlayerList.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/server/PlayerList.cpp @@ -373,17 +373,17 @@ void PlayerList::validatePlayerSpawnPosition( double targetX = 0; if (player->x < 0) - targetX = Mth::ceil(player->x) - 0.5; + targetX = GameMath::ceil(player->x) - 0.5; else - targetX = Mth::floor(player->x) + 0.5; + targetX = GameMath::floor(player->x) + 0.5; double targetY = floor(player->y); double targetZ = 0; if (player->z < 0) - targetZ = Mth::ceil(player->z) - 0.5; + targetZ = GameMath::ceil(player->z) - 0.5; else - targetZ = Mth::floor(player->z) + 0.5; + targetZ = GameMath::floor(player->z) + 0.5; player->setPos(targetX, targetY, targetZ); @@ -956,9 +956,9 @@ void PlayerList::repositionAcrossDimension(std::shared_ptr entity, } if (lastDimension != 1) { - xt = (double)Mth::clamp((int)xt, -Level::MAX_LEVEL_SIZE + 128, + xt = (double)GameMath::clamp((int)xt, -Level::MAX_LEVEL_SIZE + 128, Level::MAX_LEVEL_SIZE - 128); - zt = (double)Mth::clamp((int)zt, -Level::MAX_LEVEL_SIZE + 128, + zt = (double)GameMath::clamp((int)zt, -Level::MAX_LEVEL_SIZE + 128, Level::MAX_LEVEL_SIZE - 128); if (entity->isAlive()) { newLevel->addEntity(entity); diff --git a/minecraft/Minecraft.Client/net/minecraft/server/level/EntityTracker.cpp b/minecraft/Minecraft.Client/net/minecraft/server/level/EntityTracker.cpp index 83aec65e8..f07f00515 100644 --- a/minecraft/Minecraft.Client/net/minecraft/server/level/EntityTracker.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/server/level/EntityTracker.cpp @@ -5,7 +5,7 @@ #include "TrackedEntity.h" #include "ServerPlayer.h" #include "ServerLevel.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "Minecraft.World/net/minecraft/world/entity/net.minecraft.world.entity.h" #include "Minecraft.World/net/minecraft/world/entity/item/net.minecraft.world.entity.item.h" #include "Minecraft.World/net/minecraft/world/entity/monster/net.minecraft.world.entity.monster.h" diff --git a/minecraft/Minecraft.Client/net/minecraft/server/level/ServerLevel.cpp b/minecraft/Minecraft.Client/net/minecraft/server/level/ServerLevel.cpp index f6bbd39f5..66369b919 100644 --- a/minecraft/Minecraft.Client/net/minecraft/server/level/ServerLevel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/server/level/ServerLevel.cpp @@ -32,7 +32,7 @@ #include "Minecraft.World/net/minecraft/world/entity/item/PrimedTnt.h" #include "Minecraft.World/net/minecraft/world/entity/item/FallingTile.h" #include "Minecraft.World/net/minecraft/network/packet/net.minecraft.network.packet.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "Minecraft.World/net/minecraft/world/level/levelgen/structure/StructurePiece.h" #include "ServerLevelListener.h" #include "Minecraft.World/net/minecraft/util/WeighedTreasure.h" diff --git a/minecraft/Minecraft.Client/net/minecraft/server/level/ServerPlayer.cpp b/minecraft/Minecraft.Client/net/minecraft/server/level/ServerPlayer.cpp index 46ffb7d08..a3cfdec00 100644 --- a/minecraft/Minecraft.Client/net/minecraft/server/level/ServerPlayer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/server/level/ServerPlayer.cpp @@ -1663,7 +1663,7 @@ int ServerPlayer::getViewDistance() { return viewDistance; } // } Pos* ServerPlayer::getCommandSenderWorldPosition() { - return new Pos(Mth::floor(x), Mth::floor(y + .5), Mth::floor(z)); + return new Pos(GameMath::floor(x), GameMath::floor(y + .5), GameMath::floor(z)); } void ServerPlayer::resetLastActionTime() { diff --git a/minecraft/Minecraft.Client/net/minecraft/server/level/TrackedEntity.cpp b/minecraft/Minecraft.Client/net/minecraft/server/level/TrackedEntity.cpp index 272d03c00..750fb95c7 100644 --- a/minecraft/Minecraft.Client/net/minecraft/server/level/TrackedEntity.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/server/level/TrackedEntity.cpp @@ -2,7 +2,7 @@ #include "TrackedEntity.h" #include "ServerPlayer.h" #include "../network/PlayerConnection.h" -#include "Minecraft.World/net/minecraft/util/Mth.h" +#include "Minecraft.World/net/minecraft/util/GameMath.h" #include "Minecraft.World/net/minecraft/world/entity/net.minecraft.world.entity.h" #include "Minecraft.World/net/minecraft/world/entity/item/net.minecraft.world.entity.item.h" #include "Minecraft.World/net/minecraft/world/entity/monster/net.minecraft.world.entity.monster.h" @@ -39,13 +39,13 @@ TrackedEntity::TrackedEntity(std::shared_ptr e, int range, this->updateInterval = updateInterval; this->trackDelta = trackDelta; - xp = Mth::floor(e->x * 32); - yp = Mth::floor(e->y * 32); - zp = Mth::floor(e->z * 32); + xp = GameMath::floor(e->x * 32); + yp = GameMath::floor(e->y * 32); + zp = GameMath::floor(e->z * 32); - yRotp = Mth::floor(e->yRot * 256 / 360); - xRotp = Mth::floor(e->xRot * 256 / 360); - yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360); + yRotp = GameMath::floor(e->yRot * 256 / 360); + xRotp = GameMath::floor(e->xRot * 256 / 360); + yHeadRotp = GameMath::floor(e->getYHeadRot() * 256 / 360); } int c0a = 0, c0b = 0, c1a = 0, c1b = 0, c1c = 0, c2a = 0, c2b = 0; @@ -102,8 +102,8 @@ void TrackedEntity::tick(EntityTracker* tracker, } else if (tickCount % updateInterval == 0 || e->hasImpulse || e->getEntityData()->isDirty()) { // 4J: Moved this as it's shared - int yRotn = Mth::floor(e->yRot * 256 / 360); - int xRotn = Mth::floor(e->xRot * 256 / 360); + int yRotn = GameMath::floor(e->yRot * 256 / 360); + int xRotn = GameMath::floor(e->xRot * 256 / 360); // 4J: Changed rotation to be generally sent as a delta as well as // position @@ -113,9 +113,9 @@ void TrackedEntity::tick(EntityTracker* tracker, if (e->riding == nullptr) { teleportDelay++; - int xn = Mth::floor(e->x * 32.0); - int yn = Mth::floor(e->y * 32.0); - int zn = Mth::floor(e->z * 32.0); + int xn = GameMath::floor(e->x * 32.0); + int yn = GameMath::floor(e->y * 32.0); + int zn = GameMath::floor(e->z * 32.0); int xa = xn - xp; int ya = yn - yp; @@ -310,16 +310,16 @@ void TrackedEntity::tick(EntityTracker* tracker, xRotp = xRotn; } - xp = Mth::floor(e->x * 32.0); - yp = Mth::floor(e->y * 32.0); - zp = Mth::floor(e->z * 32.0); + xp = GameMath::floor(e->x * 32.0); + yp = GameMath::floor(e->y * 32.0); + zp = GameMath::floor(e->z * 32.0); sendDirtyEntityData(); wasRiding = true; } - int yHeadRot = Mth::floor(e->getYHeadRot() * 256 / 360); + int yHeadRot = GameMath::floor(e->getYHeadRot() * 256 / 360); if (abs(yHeadRot - yHeadRotp) >= TOLERANCE_LEVEL) { broadcast(std::shared_ptr( new RotateHeadPacket(e->entityId, (uint8_t)yHeadRot))); @@ -625,8 +625,8 @@ void TrackedEntity::updatePlayer(EntityTracker* tracker, std::shared_ptr( new EntityActionAtPositionPacket( e, EntityActionAtPositionPacket::START_SLEEP, - Mth::floor(e->x), Mth::floor(e->y), - Mth::floor(e->z)))); + GameMath::floor(e->x), GameMath::floor(e->y), + GameMath::floor(e->z)))); } } @@ -681,7 +681,7 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { // 4J-PB - replacing with a switch, rather than tons of ifs if (std::dynamic_pointer_cast(e) != nullptr) { - yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360); + yHeadRotp = GameMath::floor(e->getYHeadRot() * 256 / 360); return std::shared_ptr( new AddMobPacket(std::dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp)); @@ -717,7 +717,7 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { return std::shared_ptr(new AddEntityPacket( e, AddEntityPacket::BOAT, yRotp, xRotp, xp, yp, zp)); } else if (e->instanceof(eTYPE_ENDERDRAGON)) { - yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360); + yHeadRotp = GameMath::floor(e->getYHeadRot() * 256 / 360); return std::shared_ptr( new AddMobPacket(std::dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp)); @@ -812,9 +812,9 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { std::shared_ptr( new AddEntityPacket(e, AddEntityPacket::ITEM_FRAME, frame->dir, yRotp, xRotp, xp, yp, zp)); - packet->x = Mth::floor(frame->xTile * 32.0f); - packet->y = Mth::floor(frame->yTile * 32.0f); - packet->z = Mth::floor(frame->zTile * 32.0f); + packet->x = GameMath::floor(frame->xTile * 32.0f); + packet->y = GameMath::floor(frame->yTile * 32.0f); + packet->z = GameMath::floor(frame->zTile * 32.0f); return packet; } else if (e->instanceof(eTYPE_LEASHFENCEKNOT)) { std::shared_ptr knot = @@ -822,9 +822,9 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { std::shared_ptr packet = std::shared_ptr(new AddEntityPacket( e, AddEntityPacket::LEASH_KNOT, yRotp, xRotp, xp, yp, zp)); - packet->x = Mth::floor((float)knot->xTile * 32); - packet->y = Mth::floor((float)knot->yTile * 32); - packet->z = Mth::floor((float)knot->zTile * 32); + packet->x = GameMath::floor((float)knot->xTile * 32); + packet->y = GameMath::floor((float)knot->yTile * 32); + packet->z = GameMath::floor((float)knot->zTile * 32); return packet; } else if (e->instanceof(eTYPE_EXPERIENCEORB)) { return std::shared_ptr( diff --git a/minecraft/Minecraft.World/Header Files/stdafx.h b/minecraft/Minecraft.World/Header Files/stdafx.h index f84d51a2a..97b9a99cc 100644 --- a/minecraft/Minecraft.World/Header Files/stdafx.h +++ b/minecraft/Minecraft.World/Header Files/stdafx.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -46,7 +47,7 @@ #include "../ConsoleHelpers/Definitions.h" #include "java/Class.h" #include "java/Exceptions.h" -#include "../net/minecraft/util/Mth.h" +#include "../net/minecraft/util/GameMath.h" #include "../ConsoleHelpers/StringHelpers.h" #include "../ConsoleHelpers/ArrayWithLength.h" #include "java/Random.h" diff --git a/minecraft/Minecraft.World/net/minecraft/Direction.cpp b/minecraft/Minecraft.World/net/minecraft/Direction.cpp index ca3ece296..5131c4c0b 100644 --- a/minecraft/Minecraft.World/net/minecraft/Direction.cpp +++ b/minecraft/Minecraft.World/net/minecraft/Direction.cpp @@ -39,7 +39,7 @@ int Direction::RELATIVE_DIRECTION_FACING[4][6] = { Facing::NORTH}}; int Direction::getDirection(double xd, double zd) { - if (Mth::abs((float)xd) > Mth::abs((float)zd)) { + if (GameMath::abs((float)xd) > GameMath::abs((float)zd)) { if (xd > 0) { return WEST; } else { diff --git a/minecraft/Minecraft.World/net/minecraft/network/packet/AddExperienceOrbPacket.cpp b/minecraft/Minecraft.World/net/minecraft/network/packet/AddExperienceOrbPacket.cpp index 60e2b762b..1de478c29 100644 --- a/minecraft/Minecraft.World/net/minecraft/network/packet/AddExperienceOrbPacket.cpp +++ b/minecraft/Minecraft.World/net/minecraft/network/packet/AddExperienceOrbPacket.cpp @@ -13,9 +13,9 @@ AddExperienceOrbPacket::AddExperienceOrbPacket() { AddExperienceOrbPacket::AddExperienceOrbPacket( std::shared_ptr e) { id = e->entityId; - x = Mth::floor(e->x * 32); - y = Mth::floor(e->y * 32); - z = Mth::floor(e->z * 32); + x = GameMath::floor(e->x * 32); + y = GameMath::floor(e->y * 32); + z = GameMath::floor(e->z * 32); value = e->getValue(); } diff --git a/minecraft/Minecraft.World/net/minecraft/network/packet/AddGlobalEntityPacket.cpp b/minecraft/Minecraft.World/net/minecraft/network/packet/AddGlobalEntityPacket.cpp index 680715f55..287a20712 100644 --- a/minecraft/Minecraft.World/net/minecraft/network/packet/AddGlobalEntityPacket.cpp +++ b/minecraft/Minecraft.World/net/minecraft/network/packet/AddGlobalEntityPacket.cpp @@ -19,9 +19,9 @@ AddGlobalEntityPacket::AddGlobalEntityPacket() { AddGlobalEntityPacket::AddGlobalEntityPacket(std::shared_ptr e) { id = e->entityId; - x = Mth::floor(e->x * 32); - y = Mth::floor(e->y * 32); - z = Mth::floor(e->z * 32); + x = GameMath::floor(e->x * 32); + y = GameMath::floor(e->y * 32); + z = GameMath::floor(e->z * 32); if (e->instanceof(eTYPE_LIGHTNINGBOLT)) { type = LIGHTNING; } else { diff --git a/minecraft/Minecraft.World/net/minecraft/network/packet/AddMobPacket.cpp b/minecraft/Minecraft.World/net/minecraft/network/packet/AddMobPacket.cpp index f75dcb52e..71e2e024d 100644 --- a/minecraft/Minecraft.World/net/minecraft/network/packet/AddMobPacket.cpp +++ b/minecraft/Minecraft.World/net/minecraft/network/packet/AddMobPacket.cpp @@ -26,9 +26,9 @@ AddMobPacket::AddMobPacket(std::shared_ptr mob, int yRotp, type = EntityIO::getId(mob); // 4J Stu - We should add entities at their "last sent" position so that the // relative update packets put them in the correct place - x = xp; // Mth::floor(mob->x * 32); - y = yp; // Mth::floor(mob->y * 32); - z = zp; // Mth::floor(mob->z * 32); + x = xp; // GameMath::floor(mob->x * 32); + y = yp; // GameMath::floor(mob->y * 32); + z = zp; // GameMath::floor(mob->z * 32); // 4J - changed - send current "previously sent" value of rotations to put // this in sync with other clients yRot = static_cast(yRotp); diff --git a/minecraft/Minecraft.World/net/minecraft/network/packet/AddPlayerPacket.cpp b/minecraft/Minecraft.World/net/minecraft/network/packet/AddPlayerPacket.cpp index b35dafa55..c0e8e3739 100644 --- a/minecraft/Minecraft.World/net/minecraft/network/packet/AddPlayerPacket.cpp +++ b/minecraft/Minecraft.World/net/minecraft/network/packet/AddPlayerPacket.cpp @@ -36,9 +36,9 @@ AddPlayerPacket::AddPlayerPacket(std::shared_ptr player, PlayerUID xuid, // 4J Stu - Send "previously sent" value of position as well so that we stay // in sync - x = xp; // Mth::floor(player->x * 32); - y = yp; // Mth::floor(player->y * 32); - z = zp; // Mth::floor(player->z * 32); + x = xp; // GameMath::floor(player->x * 32); + y = yp; // GameMath::floor(player->y * 32); + z = zp; // GameMath::floor(player->z * 32); // 4J - changed - send current "previously sent" value of rotations to put // this in sync with other clients yRot = yRotp; diff --git a/minecraft/Minecraft.World/net/minecraft/network/packet/TeleportEntityPacket.cpp b/minecraft/Minecraft.World/net/minecraft/network/packet/TeleportEntityPacket.cpp index 6e1bdc75f..67399c60e 100644 --- a/minecraft/Minecraft.World/net/minecraft/network/packet/TeleportEntityPacket.cpp +++ b/minecraft/Minecraft.World/net/minecraft/network/packet/TeleportEntityPacket.cpp @@ -16,9 +16,9 @@ TeleportEntityPacket::TeleportEntityPacket() { TeleportEntityPacket::TeleportEntityPacket(std::shared_ptr e) { id = e->entityId; - x = Mth::floor(e->x * 32); - y = Mth::floor(e->y * 32); - z = Mth::floor(e->z * 32); + x = GameMath::floor(e->x * 32); + y = GameMath::floor(e->y * 32); + z = GameMath::floor(e->z * 32); yRot = (uint8_t)(e->yRot * 256 / 360); xRot = (uint8_t)(e->xRot * 256 / 360); } diff --git a/minecraft/Minecraft.World/net/minecraft/util/GameMath.cpp b/minecraft/Minecraft.World/net/minecraft/util/GameMath.cpp new file mode 100644 index 000000000..720d636ec --- /dev/null +++ b/minecraft/Minecraft.World/net/minecraft/util/GameMath.cpp @@ -0,0 +1,73 @@ +#include "../../../Header Files/stdafx.h" +#include "GameMath.h" +#include "java/Random.h" +#include "../../../ConsoleHelpers/StringHelpers.h" + +#include +#include + +constexpr size_t SIN_TAB_CNT = 65536; +constexpr float SIN_SCALE = SIN_TAB_CNT / (std::numbers::pi_v * 2.0f); + +static std::array makeSinTable() { + std::array t{}; + for (size_t i = 0; i < SIN_TAB_CNT; i++) + t[i] = (float)::sin(i * std::numbers::pi * 2.0 / (double)SIN_TAB_CNT); + return t; +} + +static const std::array sinTable = makeSinTable(); + +float GameMath::sin(float i) { + return sinTable[(int32_t)::fmodf(i * SIN_SCALE, (float)SIN_TAB_CNT) & + (SIN_TAB_CNT - 1)]; +} + +float GameMath::cos(float i) { + return sinTable[(int32_t)::fmodf(i * SIN_SCALE + (float)SIN_TAB_CNT / 4, + (float)SIN_TAB_CNT) & + (SIN_TAB_CNT - 1)]; +} + +// 4J Changed this to remove the use of the actual UUID type +std::wstring GameMath::createInsecureUUID(Random* random) { + wchar_t output[33]; + output[32] = 0; + int64_t high = (random->nextLong() & ~UUID_VERSION) | UUID_VERSION_TYPE_4; + int64_t low = (random->nextLong() & ~UUID_VARIANT) | UUID_VARIANT_2; + for (int i = 0; i < 16; i++) { + wchar_t nybbleHigh = high & 0xf; + wchar_t nybbleLow = low & 0xf; + nybbleHigh = + (nybbleHigh > 9) ? (nybbleHigh + (L'a' - 10)) : (nybbleHigh + L'0'); + nybbleLow = + (nybbleLow > 9) ? (nybbleLow + (L'a' - 10)) : (nybbleLow + L'0'); + high >>= 4; + low >>= 4; + output[31 - i] = nybbleLow; + output[15 - i] = nybbleHigh; + } + return std::wstring(output); +} + +int GameMath::getInt(const std::wstring& input, int def) { + std::wistringstream stream(input); + int result; + return (stream >> result) ? result : def; +} + +int GameMath::getInt(const std::wstring& input, int def, int min) { + int result = getInt(input, def); + return result < min ? min : result; +} + +double GameMath::getDouble(const std::wstring& input, double def) { + std::wistringstream stream(input); + double result; + return (stream >> result) ? result : def; +} + +double GameMath::getDouble(const std::wstring& input, double def, double min) { + double result = getDouble(input, def); + return result < min ? min : result; +} diff --git a/minecraft/Minecraft.World/net/minecraft/util/GameMath.h b/minecraft/Minecraft.World/net/minecraft/util/GameMath.h new file mode 100644 index 000000000..9b7f773b5 --- /dev/null +++ b/minecraft/Minecraft.World/net/minecraft/util/GameMath.h @@ -0,0 +1,59 @@ +#pragma once + +class Random; + +class GameMath { +public: + static constexpr float DEG_TO_RAD = std::numbers::pi_v / 180.0f; + static constexpr float RAD_TO_DEG = 180.0f / std::numbers::pi_v; + + static constexpr int64_t UUID_VERSION = 0x000000000000f000L; + static constexpr int64_t UUID_VERSION_TYPE_4 = 0x0000000000004000L; + static constexpr int64_t UUID_VARIANT = 0xc000000000000000L; + static constexpr int64_t UUID_VARIANT_2 = 0x8000000000000000L; + + static float sin(float i); + static float cos(float i); + + static float sqrt(float x) { return (float)::sqrt(x); } + static float sqrt(double x) { return (float)::sqrt(x); } + + static int floor(float v) { return (int)::floorf(v); } + static int floor(double v) { return (int)::floor(v); } + static int64_t lfloor(double v) { return (int64_t)::floor(v); } + + static int fastFloor(double x) { + return (int)(x + 1024.0) - 1024; + } + + static float abs(float v) { return v >= 0.0f ? v : -v; } + static int abs(int v) { return v >= 0 ? v : -v; } + + static int ceil(float v) { return (int)::ceilf(v); } + + static int clamp(int value, int min, int max) { + return std::clamp(value, min, max); + } + static float clamp(float value, float min, float max) { + return std::clamp(value, min, max); + } + + static int intFloorDiv(int a, int b) { + if (a < 0) return -((-a - 1) / b) - 1; + return a / b; + } + + static float wrapDegrees(float input) { + return (float)::remainder((double)input, 360.0); + } + static double wrapDegrees(double input) { + return ::remainder(input, 360.0); + } + + static std::wstring createInsecureUUID(Random* random); + + static int getInt(const std::wstring& input, int def); + static int getInt(const std::wstring& input, int def, int min); + static double getDouble(const std::wstring& input, double def); + static double getDouble(const std::wstring& input, double def, double min); +}; diff --git a/minecraft/Minecraft.World/net/minecraft/util/Mth.cpp b/minecraft/Minecraft.World/net/minecraft/util/Mth.cpp deleted file mode 100644 index 6c119fbb5..000000000 --- a/minecraft/Minecraft.World/net/minecraft/util/Mth.cpp +++ /dev/null @@ -1,212 +0,0 @@ -#include "../../../Header Files/stdafx.h" -#include "Mth.h" -#include "java/Random.h" -#include "../../../ConsoleHelpers/StringHelpers.h" - -const int Mth::BIG_ENOUGH_INT = 1024; -const float Mth::BIG_ENOUGH_FLOAT = BIG_ENOUGH_INT; -const float Mth::DEGRAD = M_PI / 180.0f; -const float Mth::RADDEG = 180.0f / M_PI; -const float Mth::RAD_TO_GRAD = M_PI / 180.0f; - -float* Mth::_sin = nullptr; - -// 4jcraft for clarity -constexpr size_t SIN_TAB_CNT = 65536; - -const float Mth::sinScale = 65536.0f / (float)(M_PI * 2); - -// 4J - added - was in static constructor -void Mth::init() { - _sin = new float[SIN_TAB_CNT]; - for (int i = 0; i < SIN_TAB_CNT; i++) { - _sin[i] = (float)::sin(i * M_PI * 2 / (float)SIN_TAB_CNT); - } -} - -float Mth::sin(float i) { - if (_sin == nullptr) init(); // 4J - added - - // 4jcraft changed, what ever this was, it was not safe - // fmodf returns between -65536 and 65536 (casted) - // last end is there to shift it into 0 to 65535 - - return _sin[(int32_t)fmodf(i * sinScale, (float)SIN_TAB_CNT) & - (SIN_TAB_CNT - 1)]; -} - -float Mth::cos(float i) { - if (_sin == nullptr) init(); // 4J - added - // 4jcraft same thing as ::sin but shift by SIN_TAB_CNT / 4 - // which is aquivalent to shift by M_PI / 2 - // and again the same modulo logic to cramp and map it onto the computed - // table - - return _sin[(int32_t)fmodf(i * sinScale + ((float)SIN_TAB_CNT / 4), - (float)SIN_TAB_CNT) & - (SIN_TAB_CNT - 1)]; -} - -float Mth::sqrt(float x) { return (float)::sqrt(x); } - -float Mth::sqrt(double x) { return (float)::sqrt(x); } - -int Mth::floor(float v) { - int i = (int)v; - return v < i ? i - 1 : i; -} - -int64_t Mth::lfloor(double v) { - int64_t i = (int64_t)v; - return v < i ? i - 1 : i; -} - -int Mth::fastFloor(double x) { - return (int)(x + BIG_ENOUGH_FLOAT) - BIG_ENOUGH_INT; -} - -int Mth::floor(double v) { - int i = (int)v; - return v < i ? i - 1 : i; -} - -int Mth::absFloor(double v) { return (int)(v >= 0 ? v : -v + 1); } - -float Mth::abs(float v) { return v >= 0 ? v : -v; } - -int Mth::abs(int v) { return v >= 0 ? v : -v; } - -int Mth::ceil(float v) { - int i = (int)v; - return v > i ? i + 1 : i; -} - -int Mth::clamp(int value, int min, int max) { - if (value < min) { - return min; - } - if (value > max) { - return max; - } - return value; -} - -float Mth::clamp(float value, float min, float max) { - if (value < min) { - return min; - } - if (value > max) { - return max; - } - return value; -} - -double Mth::asbMax(double a, double b) { - if (a < 0) a = -a; - if (b < 0) b = -b; - return a > b ? a : b; -} - -int Mth::intFloorDiv(int a, int b) { - if (a < 0) return -((-a - 1) / b) - 1; - return a / b; -} - -int Mth::nextInt(Random* random, int minInclusive, int maxInclusive) { - if (minInclusive >= maxInclusive) { - return minInclusive; - } - return random->nextInt(maxInclusive - minInclusive + 1) + minInclusive; -} - -float Mth::nextFloat(Random* random, float min, float max) { - if (min >= max) return min; - return (random->nextFloat() * (max - min)) + min; -} - -double Mth::nextDouble(Random* random, double min, double max) { - if (min >= max) return min; - return (random->nextDouble() * (max - min)) + min; -} - -float Mth::wrapDegrees(float input) { - // input %= 360; - while (input >= 180) { - input -= 360; - } - while (input < -180) { - input += 360; - } - return input; -} - -double Mth::wrapDegrees(double input) { - // input %= 360; - while (input >= 180) { - input -= 360; - } - while (input < -180) { - input += 360; - } - return input; -} - -int Mth::getInt(const std::wstring& input, int def) { - int result = def; - - result = _fromString(input); - - return result; -} - -int Mth::getInt(const std::wstring& input, int def, int min) { - int result = def; - - result = _fromString(input); - - if (result < min) result = min; - return result; -} - -double Mth::getDouble(const std::wstring& input, double def) { - double result = def; - - result = _fromString(input); - - return result; -} - -double Mth::getDouble(const std::wstring& input, double def, double min) { - double result = def; - - result = _fromString(input); - - if (result < min) result = min; - return result; -} - -// 4J Changed this to remove the use of the actuall UUID type -std::wstring Mth::createInsecureUUID(Random* random) { - wchar_t output[33]; - output[32] = 0; - int64_t high = (random->nextLong() & ~UUID_VERSION) | UUID_VERSION_TYPE_4; - int64_t low = (random->nextLong() & ~UUID_VARIANT) | UUID_VARIANT_2; - for (int i = 0; i < 16; i++) { - wchar_t nybbleHigh = high & 0xf; - wchar_t nybbleLow = low & 0xf; - nybbleHigh = - (nybbleHigh > 9) ? (nybbleHigh + (L'a' - 10)) : (nybbleHigh + L'0'); - nybbleLow = - (nybbleLow > 9) ? (nybbleLow + (L'a' - 10)) : (nybbleLow + L'0'); - high >>= 4; - low >>= 4; - output[31 - i] = nybbleLow; - output[15 - i] = nybbleHigh; - } - return std::wstring(output); -} - -// 4J Added -bool Mth::almostEquals(double double1, double double2, double precision) { - return (std::abs(double1 - double2) <= precision); -} \ No newline at end of file diff --git a/minecraft/Minecraft.World/net/minecraft/util/Mth.h b/minecraft/Minecraft.World/net/minecraft/util/Mth.h deleted file mode 100644 index c26851814..000000000 --- a/minecraft/Minecraft.World/net/minecraft/util/Mth.h +++ /dev/null @@ -1,55 +0,0 @@ -#pragma once -class Random; -class Mth { -private: - static const int BIG_ENOUGH_INT; - static const float BIG_ENOUGH_FLOAT; - -public: - static const float DEGRAD; - static const float RADDEG; - static const float RAD_TO_GRAD; - - static const int64_t UUID_VERSION = 0x000000000000f000L; - static const int64_t UUID_VERSION_TYPE_4 = 0x0000000000004000L; - static const int64_t UUID_VARIANT = 0xc000000000000000L; - static const int64_t UUID_VARIANT_2 = 0x8000000000000000L; - -private: - static float* _sin; - -private: - static const float sinScale; - -public: - static void init(); // 4J added - static float sin(float i); - static float cos(float i); - static float sqrt(float x); - static float sqrt(double x); - static int floor(float v); - static int64_t lfloor(double v); - static int fastFloor(double x); - static int floor(double v); - static int absFloor(double v); - static float abs(float v); - static int abs(int v); - static int ceil(float v); - static int clamp(int value, int min, int max); - static float clamp(float value, float min, float max); - static double asbMax(double a, double b); - static int intFloorDiv(int a, int b); - static int nextInt(Random* random, int minInclusive, int maxInclusive); - static float nextFloat(Random* random, float min, float max); - static double nextDouble(Random* random, double min, double max); - static float wrapDegrees(float input); - static double wrapDegrees(double input); - static std::wstring createInsecureUUID(Random* random); - static int getInt(const std::wstring& input, int def); - static int getInt(const std::wstring& input, int def, int min); - static double getDouble(const std::wstring& input, double def); - static double getDouble(const std::wstring& input, double def, double min); - - // 4J Added - static bool almostEquals(double double1, double double2, double precision); -}; \ No newline at end of file diff --git a/minecraft/Minecraft.World/net/minecraft/world/damageSource/CombatTracker.cpp b/minecraft/Minecraft.World/net/minecraft/world/damageSource/CombatTracker.cpp index 00591cc99..7b09def9d 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/damageSource/CombatTracker.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/damageSource/CombatTracker.cpp @@ -19,7 +19,7 @@ void CombatTracker::prepareForDamage() { if (mob->onLadder()) { int type = mob->level->getTile( - Mth::floor(mob->x), Mth::floor(mob->bb.y0), Mth::floor(mob->z)); + GameMath::floor(mob->x), GameMath::floor(mob->bb.y0), GameMath::floor(mob->z)); if (type == Tile::ladder->id) { nextLocation = eLocation_LADDER; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/Entity.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/Entity.cpp index 17cb728a1..bfc7c5edb 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/Entity.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/Entity.cpp @@ -334,7 +334,7 @@ void Entity::_init(bool useSmallId, Level* level) { portalEntranceDir = 0; invulnerable = false; if (useSmallId) { - uuid = L"ent" + Mth::createInsecureUUID(random); + uuid = L"ent" + GameMath::createInsecureUUID(random); } // 4J Added @@ -542,9 +542,9 @@ void Entity::baseTick() { } if (isSprinting() && !isInWater() && canCreateParticles()) { - int xt = Mth::floor(x); - int yt = Mth::floor(y - 0.2f - heightOffset); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(y - 0.2f - heightOffset); + int zt = GameMath::floor(z); int t = level->getTile(xt, yt, zt); int d = level->getData(xt, yt, zt); if (t > 0) { @@ -725,8 +725,8 @@ void Entity::move(double xa, double ya, double za, // 4J Stu - Particles (and possibly other entities) don't have xChunk and // zChunk set, so calculate the chunk instead - int xc = Mth::floor(x / 16); - int zc = Mth::floor(z / 16); + int xc = GameMath::floor(x / 16); + int zc = GameMath::floor(z / 16); if (!level->isClientSide || level->reallyHasChunk(xc, zc)) { // 4J Stu - It's horrible that the client is doing any movement at all! // But if we don't have the chunk data then all the collision info will @@ -853,9 +853,9 @@ void Entity::move(double xa, double ya, double za, double zm = z - zo; if (makeStepSound() && !isPlayerSneaking && riding == nullptr) { - int xt = Mth::floor(x); - int yt = Mth::floor(y - 0.2f - heightOffset); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(y - 0.2f - heightOffset); + int zt = GameMath::floor(z); int t = level->getTile(xt, yt, zt); if (t == 0) { int renderShape = level->getTileRenderShape(xt, yt - 1, zt); @@ -869,14 +869,14 @@ void Entity::move(double xa, double ya, double za, ym = 0; } - walkDist += Mth::sqrt(xm * xm + zm * zm) * 0.6; - moveDist += Mth::sqrt(xm * xm + ym * ym + zm * zm) * 0.6; + walkDist += GameMath::sqrt(xm * xm + zm * zm) * 0.6; + moveDist += GameMath::sqrt(xm * xm + ym * ym + zm * zm) * 0.6; if (moveDist > nextStep && t > 0) { nextStep = (int)moveDist + 1; if (isInWater()) { float speed = - Mth::sqrt(xd * xd * 0.2f + yd * yd + zd * zd * 0.2f) * + GameMath::sqrt(xd * xd * 0.2f + yd * yd + zd * zd * 0.2f) * 0.35f; if (speed > 1) speed = 1; playSound( @@ -912,12 +912,12 @@ void Entity::move(double xa, double ya, double za, } void Entity::checkInsideTiles() { - int x0 = Mth::floor(bb.x0 + 0.001); - int y0 = Mth::floor(bb.y0 + 0.001); - int z0 = Mth::floor(bb.z0 + 0.001); - int x1 = Mth::floor(bb.x1 - 0.001); - int y1 = Mth::floor(bb.y1 - 0.001); - int z1 = Mth::floor(bb.z1 - 0.001); + int x0 = GameMath::floor(bb.x0 + 0.001); + int y0 = GameMath::floor(bb.y0 + 0.001); + int z0 = GameMath::floor(bb.z0 + 0.001); + int x1 = GameMath::floor(bb.x1 - 0.001); + int y1 = GameMath::floor(bb.y1 - 0.001); + int z1 = GameMath::floor(bb.z1 - 0.001); if (level->hasChunksAt(x0, y0, z0, x1, y1, z1)) { for (int x = x0; x <= x1; x++) @@ -992,9 +992,9 @@ void Entity::causeFallDamage(float distance) { bool Entity::isInWaterOrRain() { return wasInWater || - (level->isRainingAt(Mth::floor(x), Mth::floor(y), Mth::floor(z)) || - level->isRainingAt(Mth::floor(x), Mth::floor(y + bbHeight), - Mth::floor(z))); + (level->isRainingAt(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)) || + level->isRainingAt(GameMath::floor(x), GameMath::floor(y + bbHeight), + GameMath::floor(z))); } bool Entity::isInWater() { return wasInWater; } @@ -1005,13 +1005,13 @@ bool Entity::updateInWaterState() { shared_from_this())) { if (!wasInWater && !firstTick && canCreateParticles()) { float speed = - Mth::sqrt(xd * xd * 0.2f + yd * yd + zd * zd * 0.2f) * 0.2f; + GameMath::sqrt(xd * xd * 0.2f + yd * yd + zd * zd * 0.2f) * 0.2f; if (speed > 1) speed = 1; MemSect(31); playSound(eSoundType_RANDOM_SPLASH, speed, 1 + (random->nextFloat() - random->nextFloat()) * 0.4f); MemSect(0); - float yt = (float)Mth::floor(bb.y0); + float yt = (float)GameMath::floor(bb.y0); for (int i = 0; i < 1 + bbWidth * 20; i++) { float xo = (random->nextFloat() * 2 - 1) * bbWidth; float zo = (random->nextFloat() * 2 - 1) * bbWidth; @@ -1036,10 +1036,10 @@ bool Entity::updateInWaterState() { bool Entity::isUnderLiquid(Material* material) { double yp = y + getHeadHeight(); - int xt = Mth::floor(x); - int yt = Mth::floor( + int xt = GameMath::floor(x); + int yt = GameMath::floor( yp); // 4J - this used to be a nested pair of floors for some reason - int zt = Mth::floor(z); + int zt = GameMath::floor(z); int t = level->getTile(xt, yt, zt); if (t != 0 && Tile::tiles[t]->material == material) { float hh = LiquidTile::getHeight(level->getData(xt, yt, zt)) - 1 / 9.0f; @@ -1066,8 +1066,8 @@ void Entity::moveRelative(float xa, float za, float speed) { xa *= dist; za *= dist; - float sinVar = Mth::sin(yRot * M_PI / 180); - float cosVar = Mth::cos(yRot * M_PI / 180); + float sinVar = sinf(yRot * std::numbers::pi / 180); + float cosVar = cosf(yRot * std::numbers::pi / 180); xd += xa * cosVar - za * sinVar; zd += za * cosVar + xa * sinVar; @@ -1075,12 +1075,12 @@ void Entity::moveRelative(float xa, float za, float speed) { // 4J - change brought forward from 1.8.2 int Entity::getLightColor(float a) { - int xTile = Mth::floor(x); - int zTile = Mth::floor(z); + int xTile = GameMath::floor(x); + int zTile = GameMath::floor(z); if (level->hasChunkAt(xTile, 0, zTile)) { double hh = (bb.y1 - bb.y0) * 0.66; - int yTile = Mth::floor(y - heightOffset + hh); + int yTile = GameMath::floor(y - heightOffset + hh); return level->getLightColor(xTile, yTile, zTile, 0); } return 0; @@ -1088,11 +1088,11 @@ int Entity::getLightColor(float a) { // 4J - changes brought forward from 1.8.2 float Entity::getBrightness(float a) { - int xTile = Mth::floor(x); - int zTile = Mth::floor(z); + int xTile = GameMath::floor(x); + int zTile = GameMath::floor(z); if (level->hasChunkAt(xTile, 0, zTile)) { double hh = (bb.y1 - bb.y0) * 0.66; - int yTile = Mth::floor(y - heightOffset + hh); + int yTile = GameMath::floor(y - heightOffset + hh); return level->getBrightness(xTile, yTile, zTile); } return 0; @@ -1160,7 +1160,7 @@ void Entity::push(std::shared_ptr e) { double xa = e->x - x; double za = e->z - z; - double dd = Mth::asbMax(xa, za); + double dd = std::max(fabs(xa), fabs(za)); if (dd >= 0.01f) { dd = sqrt(dd); @@ -1415,9 +1415,9 @@ bool Entity::isInWall() { float xo = ((i >> 0) % 2 - 0.5f) * bbWidth * 0.8f; float yo = ((i >> 1) % 2 - 0.5f) * 0.1f; float zo = ((i >> 2) % 2 - 0.5f) * bbWidth * 0.8f; - int xt = Mth::floor(x + xo); - int yt = Mth::floor(y + getHeadHeight() + yo); - int zt = Mth::floor(z + zo); + int xt = GameMath::floor(x + xo); + int yt = GameMath::floor(y + getHeadHeight() + yo); + int zt = GameMath::floor(z + zo); if (level->isSolidBlockingTile(xt, yt, zt)) { return true; } @@ -1659,9 +1659,9 @@ void Entity::thunderHit(const LightningBolt* lightningBolt) { void Entity::killed(std::shared_ptr mob) {} bool Entity::checkInTile(double x, double y, double z) { - int xTile = Mth::floor(x); - int yTile = Mth::floor(y); - int zTile = Mth::floor(z); + int xTile = GameMath::floor(x); + int yTile = GameMath::floor(y); + int zTile = GameMath::floor(z); double xd = x - (xTile); double yd = y - (yTile); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/EntityPos.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/EntityPos.cpp index 72981740f..7e5468659 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/EntityPos.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/EntityPos.cpp @@ -36,11 +36,11 @@ EntityPos* EntityPos::lerp(std::shared_ptr e, float f) { double yd = e->y + (y - e->y) * f; double zd = e->z + (z - e->z) * f; - float yrdd = Mth::wrapDegrees(yRot - e->yRot); - float xrdd = Mth::wrapDegrees(xRot - e->xRot); + float yrdd = GameMath::wrapDegrees(yRot - e->yRot); + float xrdd = GameMath::wrapDegrees(xRot - e->xRot); - float yrd = Mth::wrapDegrees(e->yRot + yrdd * f); - float xrd = Mth::wrapDegrees(e->xRot + xrdd * f); + float yrd = GameMath::wrapDegrees(e->yRot + yrdd * f); + float xrd = GameMath::wrapDegrees(e->xRot + xrdd * f); if (rot && move) { return new EntityPos(xd, yd, zd, yrd, xrd); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ExperienceOrb.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ExperienceOrb.cpp index 240928c49..a996b68e9 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ExperienceOrb.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ExperienceOrb.cpp @@ -76,7 +76,7 @@ void ExperienceOrb::tick() { zo = z; yd -= 0.03f; - if (level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)) == + if (level->getMaterial(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)) == Material::lava) { yd = 0.2f; xd = (random->nextFloat() - random->nextFloat()) * 0.2f; @@ -122,7 +122,7 @@ void ExperienceOrb::tick() { if (onGround) { friction = 0.6f * 0.98f; int t = - level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1, Mth::floor(z)); + level->getTile(GameMath::floor(x), GameMath::floor(bb.y0) - 1, GameMath::floor(z)); if (t > 0) { friction = Tile::tiles[t]->friction * 0.98f; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/FlyingMob.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/FlyingMob.cpp index 8d3213217..7d24d1fc2 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/FlyingMob.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/FlyingMob.cpp @@ -34,8 +34,8 @@ void FlyingMob::travel(float xa, float ya) { float friction = 0.91f; if (onGround) { friction = 0.6f * 0.91f; - int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1, - Mth::floor(z)); + int t = level->getTile(GameMath::floor(x), GameMath::floor(bb.y0) - 1, + GameMath::floor(z)); if (t > 0) { friction = Tile::tiles[t]->friction * 0.91f; } @@ -48,8 +48,8 @@ void FlyingMob::travel(float xa, float ya) { friction = 0.91f; if (onGround) { friction = 0.6f * 0.91f; - int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1, - Mth::floor(z)); + int t = level->getTile(GameMath::floor(x), GameMath::floor(bb.y0) - 1, + GameMath::floor(z)); if (t > 0) { friction = Tile::tiles[t]->friction * 0.91f; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/HangingEntity.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/HangingEntity.cpp index 3ed12ec66..8e900f597 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/HangingEntity.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/HangingEntity.cpp @@ -108,11 +108,11 @@ bool HangingEntity::survives() { int xt = xTile; int yt = yTile; int zt = zTile; - if (dir == Direction::NORTH) xt = Mth::floor(x - getWidth() / 32.0f); - if (dir == Direction::WEST) zt = Mth::floor(z - getWidth() / 32.0f); - if (dir == Direction::SOUTH) xt = Mth::floor(x - getWidth() / 32.0f); - if (dir == Direction::EAST) zt = Mth::floor(z - getWidth() / 32.0f); - yt = Mth::floor(y - getHeight() / 32.0f); + if (dir == Direction::NORTH) xt = GameMath::floor(x - getWidth() / 32.0f); + if (dir == Direction::WEST) zt = GameMath::floor(z - getWidth() / 32.0f); + if (dir == Direction::SOUTH) xt = GameMath::floor(x - getWidth() / 32.0f); + if (dir == Direction::EAST) zt = GameMath::floor(z - getWidth() / 32.0f); + yt = GameMath::floor(y - getHeight() / 32.0f); for (int ss = 0; ss < ws; ss++) { for (int yy = 0; yy < hs; yy++) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/LivingEntity.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/LivingEntity.cpp index d692871ff..b322c4636 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/LivingEntity.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/LivingEntity.cpp @@ -1,6 +1,6 @@ #include "../../../../Header Files/stdafx.h" #include "java/JavaMath.h" -#include "../../util/Mth.h" +#include "../../util/GameMath.h" #include "../../network/packet/net.minecraft.network.packet.h" #include "../level/net.minecraft.world.level.h" #include "../level/tile/net.minecraft.world.level.tile.h" @@ -113,7 +113,7 @@ LivingEntity::LivingEntity(Level* level) : Entity(level) { rotA = (float)(Math::random() + 1) * 0.01f; setPos(x, y, z); timeOffs = (float)Math::random() * 12398; - yRot = (float)(Math::random() * M_PI * 2); + yRot = (float)(Math::random() * std::numbers::pi * 2); yHeadRot = yRot; footSize = 0.5f; @@ -155,9 +155,9 @@ void LivingEntity::checkFallDamage(double ya, bool onGround) { } if (onGround && fallDistance > 0) { - int xt = Mth::floor(x); - int yt = Mth::floor(y - 0.2f - heightOffset); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(y - 0.2f - heightOffset); + int zt = GameMath::floor(z); int t = level->getTile(xt, yt, zt); if (t == 0) { int renderShape = level->getTileRenderShape(xt, yt - 1, zt); @@ -671,7 +671,7 @@ void LivingEntity::heal(float heal) { float LivingEntity::getHealth() { return entityData->getFloat(DATA_HEALTH_ID); } void LivingEntity::setHealth(float health) { - entityData->set(DATA_HEALTH_ID, Mth::clamp(health, 0.0f, getMaxHealth())); + entityData->set(DATA_HEALTH_ID, GameMath::clamp(health, 0.0f, getMaxHealth())); } bool LivingEntity::hurt(DamageSource* source, float dmg) { @@ -767,7 +767,7 @@ bool LivingEntity::hurt(DamageSource* source, float dmg) { xd = (Math::random() - Math::random()) * 0.01; zd = (Math::random() - Math::random()) * 0.01; } - hurtDir = (float)(atan2(zd, xd) * 180 / M_PI) - yRot; + hurtDir = (float)(atan2(zd, xd) * 180 / std::numbers::pi) - yRot; knockback(sourceEntity, dmg, xd, zd); } else { hurtDir = (float)(int)((Math::random() * 2) * @@ -795,13 +795,13 @@ void LivingEntity::breakItem(std::shared_ptr itemInstance) { for (int i = 0; i < 5; i++) { Vec3 d = Vec3((random->nextFloat() - 0.5) * 0.1, Math::random() * 0.1 + 0.1, 0); - d.xRot(-xRot * M_PI / 180); - d.yRot(-yRot * M_PI / 180); + d.xRot(-xRot * std::numbers::pi / 180); + d.yRot(-yRot * std::numbers::pi / 180); Vec3 p = Vec3((random->nextFloat() - 0.5) * 0.3, -random->nextFloat() * 0.6 - 0.3, 0.6); - p.xRot(-xRot * M_PI / 180); - p.yRot(-yRot * M_PI / 180); + p.xRot(-xRot * std::numbers::pi / 180); + p.yRot(-yRot * std::numbers::pi / 180); p = p.add(x, y + getHeadHeight(), z); level->addParticle(PARTICLE_ICONCRACK(itemInstance->getItem()->id, 0), p.x, p.y, p.z, d.x, d.y + 0.05, d.z); @@ -867,7 +867,7 @@ void LivingEntity::knockback(std::shared_ptr source, float dmg, } hasImpulse = true; - float dd = Mth::sqrt(xd * xd + zd * zd); + float dd = GameMath::sqrt(xd * xd + zd * zd); float pow = 0.4f; this->xd /= 2; @@ -897,9 +897,9 @@ void LivingEntity::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) { } bool LivingEntity::onLadder() { - int xt = Mth::floor(x); - int yt = Mth::floor(bb.y0); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(bb.y0); + int zt = GameMath::floor(z); // 4J-PB - TU9 - add climbable vines int iTile = level->getTile(xt, yt, zt); @@ -925,9 +925,9 @@ void LivingEntity::causeFallDamage(float distance) { } hurt(DamageSource::fall, dmg); - int t = level->getTile(Mth::floor(x), - Mth::floor(y - 0.2f - this->heightOffset), - Mth::floor(z)); + int t = level->getTile(GameMath::floor(x), + GameMath::floor(y - 0.2f - this->heightOffset), + GameMath::floor(z)); if (t > 0) { const Tile::SoundType* soundType = Tile::tiles[t]->soundType; MemSect(31); @@ -1214,10 +1214,10 @@ void LivingEntity::jumpFromGround() { yd += (getEffect(MobEffect::jump)->getAmplifier() + 1) * .1f; } if (isSprinting()) { - float rr = yRot * Mth::RAD_TO_GRAD; + float rr = yRot * GameMath::DEG_TO_RAD; - xd -= Mth::sin(rr) * 0.2f; - zd += Mth::cos(rr) * 0.2f; + xd -= sinf(rr) * 0.2f; + zd += cosf(rr) * 0.2f; } this->hasImpulse = true; } @@ -1254,8 +1254,8 @@ void LivingEntity::travel(float xa, float ya) { float friction = 0.91f; if (onGround) { friction = 0.6f * 0.91f; - int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1, - Mth::floor(z)); + int t = level->getTile(GameMath::floor(x), GameMath::floor(bb.y0) - 1, + GameMath::floor(z)); if (t > 0) { friction = Tile::tiles[t]->friction * 0.91f; } @@ -1276,8 +1276,8 @@ void LivingEntity::travel(float xa, float ya) { friction = 0.91f; if (onGround) { friction = 0.6f * 0.91f; - int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1, - Mth::floor(z)); + int t = level->getTile(GameMath::floor(x), GameMath::floor(bb.y0) - 1, + GameMath::floor(z)); if (t > 0) { friction = Tile::tiles[t]->friction * 0.91f; } @@ -1319,7 +1319,7 @@ void LivingEntity::travel(float xa, float ya) { walkAnimSpeedO = walkAnimSpeed; double xxd = x - xo; double zzd = z - zo; - float wst = Mth::sqrt(xxd * xxd + zzd * zzd) * 4; + float wst = GameMath::sqrt(xxd * xxd + zzd * zzd) * 4; if (wst > 1) wst = 1; walkAnimSpeed += (wst - walkAnimSpeed) * 0.4f; walkAnimPos += walkAnimSpeed; @@ -1333,12 +1333,12 @@ void LivingEntity::travel(float xa, float ya) { int LivingEntity::getLightColor(float a) { float accum[2] = {0, 0}; float totVol = (bb.x1 - bb.x0) * (bb.y1 - bb.y0) * (bb.z1 - bb.z0); - int xmin = Mth::floor(bb.x0); - int xmax = Mth::floor(bb.x1); - int ymin = Mth::floor(bb.y0); - int ymax = Mth::floor(bb.y1); - int zmin = Mth::floor(bb.z0); - int zmax = Mth::floor(bb.z1); + int xmin = GameMath::floor(bb.x0); + int xmax = GameMath::floor(bb.x1); + int ymin = GameMath::floor(bb.y0); + int ymax = GameMath::floor(bb.y1); + int zmin = GameMath::floor(bb.z0); + int zmax = GameMath::floor(bb.z1); for (int xt = xmin; xt <= xmax; xt++) for (int yt = ymin; yt <= ymax; yt++) for (int zt = zmin; zt <= zmax; zt++) { @@ -1438,7 +1438,7 @@ void LivingEntity::tick() { if (sideDist > 0.05f * 0.05f) { tRun = 1; walkSpeed = sqrt(sideDist) * 3; - yBodyRotT = ((float)atan2(zd, xd) * 180 / (float)M_PI - 90); + yBodyRotT = ((float)atan2(zd, xd) * 180 / (float)std::numbers::pi - 90); } if (attackAnim > 0) { yBodyRotT = yRot; @@ -1466,10 +1466,10 @@ void LivingEntity::tick() { } float LivingEntity::tickHeadTurn(float yBodyRotT, float walkSpeed) { - float yBodyRotD = Mth::wrapDegrees(yBodyRotT - yBodyRot); + float yBodyRotD = GameMath::wrapDegrees(yBodyRotT - yBodyRot); yBodyRot += yBodyRotD * 0.3f; - float headDiff = Mth::wrapDegrees(yRot - yBodyRot); + float headDiff = GameMath::wrapDegrees(yRot - yBodyRot); bool behind = headDiff < -90 || headDiff >= 90; if (headDiff < -75) headDiff = -75; if (headDiff >= 75) headDiff = +75; @@ -1492,8 +1492,8 @@ void LivingEntity::aiStep() { double yt = y + (ly - y) / lSteps; double zt = z + (lz - z) / lSteps; - double yrd = Mth::wrapDegrees(lyr - yRot); - double xrd = Mth::wrapDegrees(lxr - xRot); + double yrd = GameMath::wrapDegrees(lyr - yRot); + double xrd = GameMath::wrapDegrees(lxr - xRot); yRot += (float)((yrd) / lSteps); xRot += (float)((xrd) / lSteps); @@ -1652,20 +1652,20 @@ std::optional LivingEntity::getLookAngle() { return getViewVector(1); } Vec3 LivingEntity::getViewVector(float a) { if (a == 1) { - float yCos = Mth::cos(-yRot * Mth::RAD_TO_GRAD - M_PI); - float ySin = Mth::sin(-yRot * Mth::RAD_TO_GRAD - M_PI); - float xCos = -Mth::cos(-xRot * Mth::RAD_TO_GRAD); - float xSin = Mth::sin(-xRot * Mth::RAD_TO_GRAD); + float yCos = cosf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); + float ySin = sinf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); + float xCos = -cosf(-xRot * GameMath::DEG_TO_RAD); + float xSin = sinf(-xRot * GameMath::DEG_TO_RAD); return Vec3(ySin * xCos, xSin, yCos * xCos); } float xRot = xRotO + (this->xRot - xRotO) * a; float yRot = yRotO + (this->yRot - yRotO) * a; - float yCos = Mth::cos(-yRot * Mth::RAD_TO_GRAD - M_PI); - float ySin = Mth::sin(-yRot * Mth::RAD_TO_GRAD - M_PI); - float xCos = -Mth::cos(-xRot * Mth::RAD_TO_GRAD); - float xSin = Mth::sin(-xRot * Mth::RAD_TO_GRAD); + float yCos = cosf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); + float ySin = sinf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); + float xCos = -cosf(-xRot * GameMath::DEG_TO_RAD); + float xSin = sinf(-xRot * GameMath::DEG_TO_RAD); return Vec3(ySin * xCos, xSin, yCos * xCos); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/Mob.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/Mob.cpp index 77b8704d5..d8baa385d 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/Mob.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/Mob.cpp @@ -501,10 +501,10 @@ void Mob::lookAt(std::shared_ptr e, float yMax, float xMax) { yd = (e->bb.y0 + e->bb.y1) / 2 - (y + getHeadHeight()); } - double sd = Mth::sqrt(xd * xd + zd * zd); + double sd = GameMath::sqrt(xd * xd + zd * zd); - float yRotD = (float)(atan2(zd, xd) * 180 / M_PI) - 90; - float xRotD = (float)-(atan2(yd, sd) * 180 / M_PI); + float yRotD = (float)(atan2(zd, xd) * 180 / std::numbers::pi) - 90; + float xRotD = (float)-(atan2(yd, sd) * 180 / std::numbers::pi); xRot = rotlerp(xRot, xRotD, xMax); yRot = rotlerp(yRot, yRotD, yMax); } @@ -514,7 +514,7 @@ bool Mob::isLookingAtAnEntity() { return lookingAt != nullptr; } std::shared_ptr Mob::getLookingAt() { return lookingAt; } float Mob::rotlerp(float a, float b, float max) { - float diff = Mth::wrapDegrees(b - a); + float diff = GameMath::wrapDegrees(b - a); if (diff > max) { diff = max; } @@ -886,9 +886,9 @@ void Mob::restoreLeashFromSave() { // resolve bug 10327 :Gameplay: NPCs can spawn over chunks that have not yet // been streamed and display jitter. bool Mob::shouldRender(Vec3* c) { - if (!level->reallyHasChunksAt(Mth::floor(bb.x0), Mth::floor(bb.y0), - Mth::floor(bb.z0), Mth::floor(bb.x1), - Mth::floor(bb.y1), Mth::floor(bb.z1))) { + if (!level->reallyHasChunksAt(GameMath::floor(bb.x0), GameMath::floor(bb.y0), + GameMath::floor(bb.z0), GameMath::floor(bb.x1), + GameMath::floor(bb.y1), GameMath::floor(bb.z1))) { return false; } return Entity::shouldRender(c); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/PathfinderMob.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/PathfinderMob.cpp index 06a01510a..471f74690 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/PathfinderMob.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/PathfinderMob.cpp @@ -110,7 +110,7 @@ void PathfinderMob::serverAiStep() { // protected. considerForExtraWandering(isDespawnProtected()); - int yFloor = Mth::floor(bb.y0 + 0.5f); + int yFloor = GameMath::floor(bb.y0 + 0.5f); bool inWater = isInWater(); bool inLava = isInLava(); @@ -139,8 +139,8 @@ void PathfinderMob::serverAiStep() { double xd = target->x - x; double zd = target->z - z; double yd = target->y - yFloor; - float yRotD = (float)(atan2(zd, xd) * 180 / M_PI) - 90; - float rotDiff = Mth::wrapDegrees(yRotD - yRot); + float yRotD = (float)(atan2(zd, xd) * 180 / std::numbers::pi) - 90; + float rotDiff = GameMath::wrapDegrees(yRotD - yRot); yya = (float)getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED) ->getValue(); if (rotDiff > MAX_TURN) { @@ -157,11 +157,11 @@ void PathfinderMob::serverAiStep() { double zd2 = attackTarget->z - z; float oldyRot = yRot; - yRot = (float)(atan2(zd2, xd2) * 180 / M_PI) - 90; + yRot = (float)(atan2(zd2, xd2) * 180 / std::numbers::pi) - 90; - rotDiff = ((oldyRot - yRot) + 90) * M_PI / 180; - xxa = -Mth::sin(rotDiff) * yya * 1.0f; - yya = Mth::cos(rotDiff) * yya * 1.0f; + rotDiff = ((oldyRot - yRot) + 90) * std::numbers::pi / 180; + xxa = -sinf(rotDiff) * yya * 1.0f; + yya = cosf(rotDiff) * yya * 1.0f; } } if (yd > 0) { @@ -191,15 +191,15 @@ void PathfinderMob::findRandomStrollLocation( // request that only stroll locations in one quadrant be found. If -1 is // passed then behaviour is the same as the java game int xt, zt; - int yt = Mth::floor(y + random->nextInt(7) - 3); + int yt = GameMath::floor(y + random->nextInt(7) - 3); if (quadrant == -1) { - xt = Mth::floor(x + random->nextInt(13) - 6); - zt = Mth::floor(z + random->nextInt(13) - 6); + xt = GameMath::floor(x + random->nextInt(13) - 6); + zt = GameMath::floor(z + random->nextInt(13) - 6); } else { int sx = ((quadrant & 1) ? -1 : 1); int sz = ((quadrant & 2) ? -1 : 1); - xt = Mth::floor(x + random->nextInt(7) * sx); - zt = Mth::floor(z + random->nextInt(7) * sz); + xt = GameMath::floor(x + random->nextInt(7) * sx); + zt = GameMath::floor(z + random->nextInt(7) * sz); } float value = getWalkTargetValue(xt, yt, zt); if (value > best) { @@ -226,9 +226,9 @@ std::shared_ptr PathfinderMob::findAttackTarget() { } bool PathfinderMob::canSpawn() { - int xt = Mth::floor(x); - int yt = Mth::floor(bb.y0); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(bb.y0); + int zt = GameMath::floor(z); return this->Mob::canSpawn() && getWalkTargetValue(xt, yt, zt) >= 0; } @@ -249,7 +249,7 @@ void PathfinderMob::setAttackTarget(std::shared_ptr attacker) { // might move to navigation, might make area bool PathfinderMob::isWithinRestriction() { - return isWithinRestriction(Mth::floor(x), Mth::floor(y), Mth::floor(z)); + return isWithinRestriction(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); } bool PathfinderMob::isWithinRestriction(int x, int y, int z) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/BodyControl.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/BodyControl.cpp index db6da03a5..a1bb38d99 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/BodyControl.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/BodyControl.cpp @@ -43,7 +43,7 @@ void BodyControl::clientTick() { } float BodyControl::clamp(float clampTo, float clampFrom, float clampAngle) { - float headDiffBody = Mth::wrapDegrees(clampTo - clampFrom); + float headDiffBody = GameMath::wrapDegrees(clampTo - clampFrom); if (headDiffBody < -clampAngle) headDiffBody = -clampAngle; if (headDiffBody >= clampAngle) headDiffBody = +clampAngle; return clampTo - headDiffBody; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/LookControl.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/LookControl.cpp index 99123f10d..651c04241 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/LookControl.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/LookControl.cpp @@ -48,15 +48,15 @@ void LookControl::tick() { double zd = wantedZ - mob->z; double sd = sqrt(xd * xd + zd * zd); - float yRotD = (float)(atan2(zd, xd) * 180 / M_PI) - 90; - float xRotD = (float)-(atan2(yd, sd) * 180 / M_PI); + float yRotD = (float)(atan2(zd, xd) * 180 / std::numbers::pi) - 90; + float xRotD = (float)-(atan2(yd, sd) * 180 / std::numbers::pi); mob->xRot = rotlerp(mob->xRot, xRotD, xMax); mob->yHeadRot = rotlerp(mob->yHeadRot, yRotD, yMax); } else { mob->yHeadRot = rotlerp(mob->yHeadRot, mob->yBodyRot, 10); } - float headDiffBody = Mth::wrapDegrees(mob->yHeadRot - mob->yBodyRot); + float headDiffBody = GameMath::wrapDegrees(mob->yHeadRot - mob->yBodyRot); if (!mob->getNavigation()->isDone()) { // head clamped to body diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/MoveControl.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/MoveControl.cpp index 849b568fe..f5aed5cfd 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/MoveControl.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/MoveControl.cpp @@ -46,7 +46,7 @@ void MoveControl::tick() { double dd = xd * xd + yd * yd + zd * zd; if (dd < MIN_SPEED_SQR) return; - float yRotD = (float)(atan2(zd, xd) * 180 / M_PI) - 90; + float yRotD = (float)(atan2(zd, xd) * 180 / std::numbers::pi) - 90; mob->yRot = rotlerp(mob->yRot, yRotD, MAX_TURN); mob->setSpeed( @@ -58,7 +58,7 @@ void MoveControl::tick() { } float MoveControl::rotlerp(float a, float b, float max) { - float diff = Mth::wrapDegrees(b - a); + float diff = GameMath::wrapDegrees(b - a); if (diff > max) { diff = max; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/ControlledByPlayerGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/ControlledByPlayerGoal.cpp index bce5cc384..42f39152e 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/ControlledByPlayerGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/ControlledByPlayerGoal.cpp @@ -46,24 +46,24 @@ void ControlledByPlayerGoal::tick() { std::dynamic_pointer_cast(mob->rider.lock()); PathfinderMob* pig = (PathfinderMob*)mob; - float yrd = Mth::wrapDegrees(player->yRot - mob->yRot) * 0.5f; + float yrd = GameMath::wrapDegrees(player->yRot - mob->yRot) * 0.5f; if (yrd > 5) yrd = 5; if (yrd < -5) yrd = -5; - mob->yRot = Mth::wrapDegrees(mob->yRot + yrd); + mob->yRot = GameMath::wrapDegrees(mob->yRot + yrd); if (speed < maxSpeed) speed += (maxSpeed - speed) * 0.01f; if (speed > maxSpeed) speed = maxSpeed; - int x = Mth::floor(mob->x); - int y = Mth::floor(mob->y); - int z = Mth::floor(mob->z); + int x = GameMath::floor(mob->x); + int y = GameMath::floor(mob->y); + int z = GameMath::floor(mob->z); float moveSpeed = speed; if (boosting) { if (boostTime++ > boostTimeTotal) { boosting = false; } moveSpeed += moveSpeed * 1.15f * - Mth::sin((float)boostTime / boostTimeTotal * M_PI); + sinf((float)boostTime / boostTimeTotal * std::numbers::pi); } float friction = 0.91f; @@ -76,8 +76,8 @@ void ControlledByPlayerGoal::tick() { } float friction2 = (0.6f * 0.6f * 0.91f * 0.91f * 0.6f * 0.91f) / (friction * friction * friction); - float sin = Mth::sin(pig->yRot * M_PI / 180); - float cos = Mth::cos(pig->yRot * M_PI / 180); + float sin = sinf(pig->yRot * std::numbers::pi / 180); + float cos = cosf(pig->yRot * std::numbers::pi / 180); float aproxSpeed = pig->getSpeed() * friction2; float dist = std::max((int)moveSpeed, 1); dist = aproxSpeed / dist; @@ -85,7 +85,7 @@ void ControlledByPlayerGoal::tick() { float xa = -(normMoveSpeed * sin); float za = normMoveSpeed * cos; - if (Mth::abs(xa) > Mth::abs(za)) { + if (GameMath::abs(xa) > GameMath::abs(za)) { if (xa < 0) xa -= mob->bbWidth / 2.0f; if (xa > 0) xa += mob->bbWidth / 2.0f; za = 0; @@ -95,12 +95,12 @@ void ControlledByPlayerGoal::tick() { if (za > 0) za += mob->bbWidth / 2.0f; } - int xt = Mth::floor(mob->x + xa); - int zt = Mth::floor(mob->z + za); + int xt = GameMath::floor(mob->x + xa); + int zt = GameMath::floor(mob->z + za); - Node* size = new Node(Mth::floor(mob->bbWidth + 1), - Mth::floor(mob->bbHeight + player->bbHeight + 1), - Mth::floor(mob->bbWidth + 1)); + Node* size = new Node(GameMath::floor(mob->bbWidth + 1), + GameMath::floor(mob->bbHeight + player->bbHeight + 1), + GameMath::floor(mob->bbWidth + 1)); if (x != xt || z != zt) { if (PathFinder::isFree(mob, xt, y, zt, size, false, false, true) == diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/DoorInteractGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/DoorInteractGoal.cpp index c153f1af8..d179a4277 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/DoorInteractGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/DoorInteractGoal.cpp @@ -33,9 +33,9 @@ bool DoorInteractGoal::canUse() { return true; } - doorX = Mth::floor(mob->x); - doorY = Mth::floor(mob->y + 1); - doorZ = Mth::floor(mob->z); + doorX = GameMath::floor(mob->x); + doorY = GameMath::floor(mob->y + 1); + doorZ = GameMath::floor(mob->z); doorTile = getDoorTile(doorX, doorY, doorZ); return doorTile != nullptr; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/EatTileGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/EatTileGoal.cpp index 6b2782a26..186f83da8 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/EatTileGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/EatTileGoal.cpp @@ -19,9 +19,9 @@ EatTileGoal::EatTileGoal(Mob* mob) { bool EatTileGoal::canUse() { if (mob->getRandom()->nextInt(mob->isBaby() ? 50 : 1000) != 0) return false; - int xx = Mth::floor(mob->x); - int yy = Mth::floor(mob->y); - int zz = Mth::floor(mob->z); + int xx = GameMath::floor(mob->x); + int yy = GameMath::floor(mob->y); + int zz = GameMath::floor(mob->z); if (level->getTile(xx, yy, zz) == Tile::tallgrass_Id && level->getData(xx, yy, zz) == TallGrass::TALL_GRASS) return true; @@ -46,9 +46,9 @@ void EatTileGoal::tick() { eatAnimationTick = std::max(0, eatAnimationTick - 1); if (eatAnimationTick != 4) return; - int xx = Mth::floor(mob->x); - int yy = Mth::floor(mob->y); - int zz = Mth::floor(mob->z); + int xx = GameMath::floor(mob->x); + int yy = GameMath::floor(mob->y); + int zz = GameMath::floor(mob->z); if (level->getTile(xx, yy, zz) == Tile::tallgrass_Id) { level->destroyTile(xx, yy, zz, false); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FleeSunGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FleeSunGoal.cpp index 8c7a442b6..deb3291f8 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FleeSunGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FleeSunGoal.cpp @@ -17,8 +17,8 @@ FleeSunGoal::FleeSunGoal(PathfinderMob* mob, double speedModifier) { bool FleeSunGoal::canUse() { if (!level->isDay()) return false; if (!mob->isOnFire()) return false; - if (!level->canSeeSky(Mth::floor(mob->x), (int)mob->bb.y0, - Mth::floor(mob->z))) + if (!level->canSeeSky(GameMath::floor(mob->x), (int)mob->bb.y0, + GameMath::floor(mob->z))) return false; auto pos = getHidePos(); @@ -38,9 +38,9 @@ void FleeSunGoal::start() { std::optional FleeSunGoal::getHidePos() { Random* random = mob->getRandom(); for (int i = 0; i < 10; i++) { - int xt = Mth::floor(mob->x + random->nextInt(20) - 10); - int yt = Mth::floor(mob->bb.y0 + random->nextInt(6) - 3); - int zt = Mth::floor(mob->z + random->nextInt(20) - 10); + int xt = GameMath::floor(mob->x + random->nextInt(20) - 10); + int yt = GameMath::floor(mob->bb.y0 + random->nextInt(6) - 3); + int zt = GameMath::floor(mob->z + random->nextInt(20) - 10); if (!level->canSeeSky(xt, yt, zt) && mob->getWalkTargetValue(xt, yt, zt) < 0) return Vec3(xt, yt, zt); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.cpp index dfcc91b39..84e7e2cf6 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.cpp @@ -67,9 +67,9 @@ void FollowOwnerGoal::tick() { return; // find a good spawn position nearby the owner - int sx = Mth::floor(owner.lock()->x) - 2; - int sz = Mth::floor(owner.lock()->z) - 2; - int y = Mth::floor(owner.lock()->bb.y0); + int sx = GameMath::floor(owner.lock()->x) - 2; + int sz = GameMath::floor(owner.lock()->z) - 2; + int y = GameMath::floor(owner.lock()->bb.y0); for (int x = 0; x <= 4; x++) { for (int z = 0; z <= 4; z++) { if (x >= 1 && z >= 1 && x <= 3 && z <= 3) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MakeLoveGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MakeLoveGoal.cpp index 8b541e5bd..51f2126e7 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MakeLoveGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MakeLoveGoal.cpp @@ -23,9 +23,9 @@ bool MakeLoveGoal::canUse() { if (villager->getAge() != 0) return false; if (villager->getRandom()->nextInt(500) != 0) return false; - village = level->villages->getClosestVillage(Mth::floor(villager->x), - Mth::floor(villager->y), - Mth::floor(villager->z), 0); + village = level->villages->getClosestVillage(GameMath::floor(villager->x), + GameMath::floor(villager->y), + GameMath::floor(villager->z), 0); if (village.lock() == nullptr) return false; if (!villageNeedsMoreVillagers()) return false; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.cpp index 4aa25fadf..67854ba12 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.cpp @@ -52,8 +52,8 @@ bool MeleeAttackGoal::canContinueToUse() { if (target == nullptr) return false; if (!target->isAlive()) return false; if (!trackTarget) return !mob->getNavigation()->isDone(); - if (!mob->isWithinRestriction(Mth::floor(target->x), Mth::floor(target->y), - Mth::floor(target->z))) + if (!mob->isWithinRestriction(GameMath::floor(target->x), GameMath::floor(target->y), + GameMath::floor(target->z))) return false; return true; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveIndoorsGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveIndoorsGoal.cpp index 64967527c..ee1ade253 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveIndoorsGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveIndoorsGoal.cpp @@ -23,10 +23,10 @@ bool MoveIndoorsGoal::canUse() { if (insideX != -1 && mob->distanceToSqr(insideX, mob->y, insideZ) < 2 * 2) return false; std::shared_ptr village = mob->level->villages->getClosestVillage( - Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z), 14); + GameMath::floor(mob->x), GameMath::floor(mob->y), GameMath::floor(mob->z), 14); if (village == nullptr) return false; std::shared_ptr _doorInfo = village->getBestDoorInfo( - Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z)); + GameMath::floor(mob->x), GameMath::floor(mob->y), GameMath::floor(mob->z)); doorInfo = _doorInfo; return _doorInfo != nullptr; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveThroughVillageGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveThroughVillageGoal.cpp index 3a4be0632..f8f1e0125 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveThroughVillageGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveThroughVillageGoal.cpp @@ -31,7 +31,7 @@ bool MoveThroughVillageGoal::canUse() { if (onlyAtNight && mob->level->isDay()) return false; std::shared_ptr village = mob->level->villages->getClosestVillage( - Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z), 0); + GameMath::floor(mob->x), GameMath::floor(mob->y), GameMath::floor(mob->z), 0); if (village == nullptr) return false; std::shared_ptr _doorInfo = getNextDoorInfo(village); @@ -93,8 +93,8 @@ std::shared_ptr MoveThroughVillageGoal::getNextDoorInfo( // for (DoorInfo di : doorInfos) for (auto it = doorInfos->begin(); it != doorInfos->end(); ++it) { std::shared_ptr di = *it; - int distSqr = di->distanceToSqr(Mth::floor(mob->x), Mth::floor(mob->y), - Mth::floor(mob->z)); + int distSqr = di->distanceToSqr(GameMath::floor(mob->x), GameMath::floor(mob->y), + GameMath::floor(mob->z)); if (distSqr < closestDistSqr) { if (hasVisited(di)) continue; closest = di; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RandomLookAroundGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RandomLookAroundGoal.cpp index 96f40df55..9194e53db 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RandomLookAroundGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RandomLookAroundGoal.cpp @@ -19,7 +19,7 @@ bool RandomLookAroundGoal::canUse() { bool RandomLookAroundGoal::canContinueToUse() { return lookTime >= 0; } void RandomLookAroundGoal::start() { - double rnd = 2 * M_PI * mob->getRandom()->nextDouble(); + double rnd = 2 * std::numbers::pi * mob->getRandom()->nextDouble(); relX = cos(rnd); relZ = sin(rnd); lookTime = 20 + mob->getRandom()->nextInt(20); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RangedAttackGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RangedAttackGoal.cpp index 96e196c83..f1d8b886f 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RangedAttackGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RangedAttackGoal.cpp @@ -87,17 +87,17 @@ void RangedAttackGoal::tick() { if (--attackTime == 0) { if (targetDistSqr > attackRadiusSqr || !canSee) return; - float dist = Mth::sqrt(targetDistSqr) / attackRadius; + float dist = GameMath::sqrt(targetDistSqr) / attackRadius; float power = dist; if (power < 0.1f) power = 0.1f; if (power > 1) power = 1; rangedAttackMob->performRangedAttack(target.lock(), power); - attackTime = Mth::floor(dist * (attackIntervalMax - attackIntervalMin) + + attackTime = GameMath::floor(dist * (attackIntervalMax - attackIntervalMin) + attackIntervalMin); } else if (attackTime < 0) { - float dist = Mth::sqrt(targetDistSqr) / attackRadius; - attackTime = Mth::floor(dist * (attackIntervalMax - attackIntervalMin) + + float dist = GameMath::sqrt(targetDistSqr) / attackRadius; + attackTime = GameMath::floor(dist * (attackIntervalMax - attackIntervalMin) + attackIntervalMin); } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RestrictOpenDoorGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RestrictOpenDoorGoal.cpp index 939cb14e5..384aba37b 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RestrictOpenDoorGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RestrictOpenDoorGoal.cpp @@ -12,15 +12,15 @@ RestrictOpenDoorGoal::RestrictOpenDoorGoal(PathfinderMob* mob) { bool RestrictOpenDoorGoal::canUse() { if (mob->level->isDay()) return false; std::shared_ptr village = mob->level->villages->getClosestVillage( - Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z), 16); + GameMath::floor(mob->x), GameMath::floor(mob->y), GameMath::floor(mob->z), 16); if (village == nullptr) return false; std::shared_ptr _doorInfo = village->getClosestDoorInfo( - Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z)); + GameMath::floor(mob->x), GameMath::floor(mob->y), GameMath::floor(mob->z)); if (_doorInfo == nullptr) return false; doorInfo = _doorInfo; - return _doorInfo->distanceToInsideSqr(Mth::floor(mob->x), - Mth::floor(mob->y), - Mth::floor(mob->z)) < 1.5 * 1.5; + return _doorInfo->distanceToInsideSqr(GameMath::floor(mob->x), + GameMath::floor(mob->y), + GameMath::floor(mob->z)) < 1.5 * 1.5; } bool RestrictOpenDoorGoal::canContinueToUse() { @@ -28,7 +28,7 @@ bool RestrictOpenDoorGoal::canContinueToUse() { std::shared_ptr _doorInfo = doorInfo.lock(); if (_doorInfo == nullptr) return false; return !_doorInfo->removed && - _doorInfo->isInsideSide(Mth::floor(mob->x), Mth::floor(mob->z)); + _doorInfo->isInsideSide(GameMath::floor(mob->x), GameMath::floor(mob->z)); } void RestrictOpenDoorGoal::start() { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/target/TargetGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/target/TargetGoal.cpp index 7b98248fd..f43b19cef 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/target/TargetGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/target/TargetGoal.cpp @@ -87,8 +87,8 @@ bool TargetGoal::canAttack(std::shared_ptr target, return false; } - if (!mob->isWithinRestriction(Mth::floor(target->x), Mth::floor(target->y), - Mth::floor(target->z))) + if (!mob->isWithinRestriction(GameMath::floor(target->x), GameMath::floor(target->y), + GameMath::floor(target->z))) return false; if (mustSee && !mob->getSensing()->canSee(target)) return false; @@ -112,8 +112,8 @@ bool TargetGoal::canReach(std::shared_ptr target) { delete path; return false; } - int xx = last->x - Mth::floor(target->x); - int zz = last->z - Mth::floor(target->z); + int xx = last->x - GameMath::floor(target->x); + int zz = last->z - GameMath::floor(target->z); delete path; return xx * xx + zz * zz <= 1.5 * 1.5; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/navigation/PathNavigation.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/navigation/PathNavigation.cpp index 392b04618..d41fda994 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/navigation/PathNavigation.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/navigation/PathNavigation.cpp @@ -59,15 +59,15 @@ float PathNavigation::getMaxDist() { return (float)dist->getValue(); } Path* PathNavigation::createPath(double x, double y, double z) { if (!canUpdatePath()) return nullptr; - return level->findPath(mob->shared_from_this(), Mth::floor(x), (int)y, - Mth::floor(z), getMaxDist(), _canPassDoors, + return level->findPath(mob->shared_from_this(), GameMath::floor(x), (int)y, + GameMath::floor(z), getMaxDist(), _canPassDoors, _canOpenDoors, avoidWater, canFloat); } bool PathNavigation::moveTo(double x, double y, double z, double speedModifier) { MemSect(52); - Path* newPath = createPath(Mth::floor(x), (int)y, Mth::floor(z)); + Path* newPath = createPath(GameMath::floor(x), (int)y, GameMath::floor(z)); MemSect(0); // No need to delete newPath here as this will be copied into the member // variable path and the class can assume responsibility for it @@ -193,12 +193,12 @@ int PathNavigation::getSurfaceY() { int surface = (int)(mob->bb.y0); int tileId = - level->getTile(Mth::floor(mob->x), surface, Mth::floor(mob->z)); + level->getTile(GameMath::floor(mob->x), surface, GameMath::floor(mob->z)); int steps = 0; while (tileId == Tile::water_Id || tileId == Tile::calmWater_Id) { ++surface; tileId = - level->getTile(Mth::floor(mob->x), surface, Mth::floor(mob->z)); + level->getTile(GameMath::floor(mob->x), surface, GameMath::floor(mob->z)); if (++steps > 16) return (int)(mob->bb.y0); } return surface; @@ -213,8 +213,8 @@ bool PathNavigation::isInLiquid() { } void PathNavigation::trimPathFromSun() { - if (level->canSeeSky(Mth::floor(mob->x), (int)(mob->bb.y0 + 0.5), - Mth::floor(mob->z))) + if (level->canSeeSky(GameMath::floor(mob->x), (int)(mob->bb.y0 + 0.5), + GameMath::floor(mob->z))) return; for (int i = 0; i < path->getSize(); ++i) { @@ -228,8 +228,8 @@ void PathNavigation::trimPathFromSun() { bool PathNavigation::canMoveDirectly(Vec3* startPos, Vec3* stopPos, int sx, int sy, int sz) { - int gridPosX = Mth::floor(startPos->x); - int gridPosZ = Mth::floor(startPos->z); + int gridPosX = GameMath::floor(startPos->x); + int gridPosZ = GameMath::floor(startPos->z); double dirX = stopPos->x - startPos->x; double dirZ = stopPos->z - startPos->z; @@ -260,8 +260,8 @@ bool PathNavigation::canMoveDirectly(Vec3* startPos, Vec3* stopPos, int sx, int stepX = dirX < 0 ? -1 : 1; int stepZ = dirZ < 0 ? -1 : 1; - int gridGoalX = Mth::floor(stopPos->x); - int gridGoalZ = Mth::floor(stopPos->z); + int gridGoalX = GameMath::floor(stopPos->x); + int gridGoalZ = GameMath::floor(stopPos->z); int currentDirX = gridGoalX - gridPosX; int currentDirZ = gridGoalZ - gridPosZ; while (currentDirX * stepX > 0 || currentDirZ * stepZ > 0) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/util/RandomPos.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/util/RandomPos.cpp index a6476c848..033b7e938 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/util/RandomPos.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/util/RandomPos.cpp @@ -45,7 +45,7 @@ std::optional RandomPos::generateRandomPos( if (mob->hasRestriction()) { double restDist = mob->getRestrictCenter()->distSqr( - Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z)) + + GameMath::floor(mob->x), GameMath::floor(mob->y), GameMath::floor(mob->z)) + 4; double radius = mob->getRestrictRadius() + xzDist; bRestrict = restDist < radius * radius; @@ -70,9 +70,9 @@ std::optional RandomPos::generateRandomPos( if (dir != nullptr && xt * dir->x + zt * dir->z < 0) continue; - xt += Mth::floor(mob->x); - yt += Mth::floor(mob->y); - zt += Mth::floor(mob->z); + xt += GameMath::floor(mob->x); + yt += GameMath::floor(mob->y); + zt += GameMath::floor(mob->z); if (bRestrict && !mob->isWithinRestriction(xt, yt, zt)) continue; float value = mob->getWalkTargetValue(xt, yt, zt); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/village/Village.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/village/Village.cpp index b76565684..af59f7d5c 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/village/Village.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/village/Village.cpp @@ -345,7 +345,7 @@ int Village::getStanding(const std::wstring& playerName) { int Village::modifyStanding(const std::wstring& playerName, int delta) { int current = getStanding(playerName); - int newValue = Mth::clamp(current + delta, -30, 10); + int newValue = GameMath::clamp(current + delta, -30, 10); playerStanding.insert(std::pair(playerName, newValue)); return newValue; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/village/VillageSiege.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/village/VillageSiege.cpp index 4837279d5..61413bacb 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/village/VillageSiege.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/village/VillageSiege.cpp @@ -86,11 +86,11 @@ bool VillageSiege::tryToSetupSiege() { bool overlaps = false; for (int i = 0; i < 10; ++i) { spawnX = center->x + - (int)(Mth::cos(level->random->nextFloat() * M_PI * 2.f) * + (int)(cosf(level->random->nextFloat() * std::numbers::pi * 2.f) * radius * 0.9); spawnY = center->y; spawnZ = center->z + - (int)(Mth::sin(level->random->nextFloat() * M_PI * 2.f) * + (int)(sinf(level->random->nextFloat() * std::numbers::pi * 2.f) * radius * 0.9); overlaps = false; std::vector >* villages = diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ambient/Bat.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ambient/Bat.cpp index 7e8e9383f..e60eb35bb 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ambient/Bat.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ambient/Bat.cpp @@ -84,7 +84,7 @@ void Bat::tick() { if (isResting()) { xd = yd = zd = 0; - y = Mth::floor(y) + 1.0 - bbHeight; + y = GameMath::floor(y) + 1.0 - bbHeight; } else { yd *= .6f; } @@ -96,8 +96,8 @@ void Bat::newServerAiStep() { AmbientCreature::newServerAiStep(); if (isResting()) { - if (!level->isSolidBlockingTile(Mth::floor(x), (int)y + 1, - Mth::floor(z))) { + if (!level->isSolidBlockingTile(GameMath::floor(x), (int)y + 1, + GameMath::floor(z))) { setResting(false); level->levelEvent(nullptr, LevelEvent::SOUND_BAT_LIFTOFF, (int)x, (int)y, (int)z, 0); @@ -137,14 +137,14 @@ void Bat::newServerAiStep() { yd = yd + (signum(dy) * .7f - yd) * .1f; zd = zd + (signum(dz) * .5f - zd) * .1f; - float yRotD = (float)(atan2(zd, xd) * 180 / M_PI) - 90; - float rotDiff = Mth::wrapDegrees(yRotD - yRot); + float yRotD = (float)(atan2(zd, xd) * 180 / std::numbers::pi) - 90; + float rotDiff = GameMath::wrapDegrees(yRotD - yRot); yya = .5f; yRot += rotDiff; if (random->nextInt(100) == 0 && - level->isSolidBlockingTile(Mth::floor(x), (int)y + 1, - Mth::floor(z))) { + level->isSolidBlockingTile(GameMath::floor(x), (int)y + 1, + GameMath::floor(z))) { setResting(true); } } @@ -185,11 +185,11 @@ void Bat::addAdditonalSaveData(CompoundTag* entityTag) { } bool Bat::canSpawn() { - int yt = Mth::floor(bb.y0); + int yt = GameMath::floor(bb.y0); if (yt >= level->seaLevel) return false; - int xt = Mth::floor(x); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int zt = GameMath::floor(z); int br = level->getRawBrightness(xt, yt, zt); int maxLight = 4; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Animal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Animal.cpp index 8f14af3cb..1a549deb2 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Animal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Animal.cpp @@ -65,7 +65,7 @@ void Animal::checkHurtTarget(std::shared_ptr target, float d) { if (d < 3) { double xd = target->x - x; double zd = target->z - z; - yRot = (float)(atan2(zd, xd) * 180 / M_PI) - 90; + yRot = (float)(atan2(zd, xd) * 180 / std::numbers::pi) - 90; holdGround = true; } @@ -267,9 +267,9 @@ std::shared_ptr Animal::findAttackTarget() { } bool Animal::canSpawn() { - int xt = Mth::floor(x); - int yt = Mth::floor(bb.y0); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(bb.y0); + int zt = GameMath::floor(z); return level->getTile(xt, yt - 1, zt) == Tile::grass_Id && level->getDaytimeRawBrightness(xt, yt, zt) > 8 && AgableMob::canSpawn(); @@ -403,8 +403,8 @@ void Animal::updateDespawnProtectedState() { if (level->isClientSide) return; if (m_isDespawnProtected) { - int xt = Mth::floor(x); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int zt = GameMath::floor(z); if (xt > m_maxWanderX) m_maxWanderX = xt; if (xt < m_minWanderX) m_minWanderX = xt; @@ -433,8 +433,8 @@ bool Animal::isDespawnProtected() { return m_isDespawnProtected; } void Animal::setDespawnProtected() { if (level && level->isClientSide) return; - int xt = Mth::floor(x); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int zt = GameMath::floor(z); m_minWanderX = xt; m_maxWanderX = xt; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/EntityHorse.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/EntityHorse.cpp index a17f3ea77..9a5cd22c1 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/EntityHorse.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/EntityHorse.cpp @@ -265,7 +265,7 @@ int EntityHorse::getTemper() { return temper; } void EntityHorse::setTemper(int temper) { this->temper = temper; } int EntityHorse::modifyTemper(int amount) { - int temper = Mth::clamp(getTemper() + amount, 0, getMaxTemper()); + int temper = GameMath::clamp(getTemper() + amount, 0, getMaxTemper()); setTemper(temper); return temper; @@ -297,8 +297,8 @@ bool EntityHorse::isPushable() { return rider.lock() == nullptr; } // TODO: [EB]: Explain why this is being done - what side effect does getBiome // have? bool EntityHorse::checkSpawningBiome() { - int x = Mth::floor(this->x); - int z = Mth::floor(this->z); + int x = GameMath::floor(this->x); + int z = GameMath::floor(this->z); level->getBiome(x, z); return true; @@ -331,7 +331,7 @@ void EntityHorse::causeFallDamage(float fallDistance) { playSound(eSoundType_MOB_HORSE_LAND, .4f, 1); } - int dmg = Mth::ceil(fallDistance * .5f - 3.0f); + int dmg = GameMath::ceil(fallDistance * .5f - 3.0f); if (dmg <= 0) return; hurt(DamageSource::fall, dmg); @@ -340,8 +340,8 @@ void EntityHorse::causeFallDamage(float fallDistance) { rider.lock()->hurt(DamageSource::fall, dmg); } - int id = level->getTile(Mth::floor(x), Mth::floor(y - 0.2 - yRotO), - Mth::floor(z)); + int id = level->getTile(GameMath::floor(x), GameMath::floor(y - 0.2 - yRotO), + GameMath::floor(z)); if (id > 0) { const Tile::SoundType* stepsound = Tile::tiles[id]->soundType; level->playEntitySound(shared_from_this(), stepsound->getStepSound(), @@ -906,8 +906,8 @@ void EntityHorse::aiStep() { if (!isEating() && rider.lock() == nullptr && random->nextInt(300) == 0) { - if (level->getTile(Mth::floor(x), Mth::floor(y) - 1, - Mth::floor(z)) == Tile::grass_Id) { + if (level->getTile(GameMath::floor(x), GameMath::floor(y) - 1, + GameMath::floor(z)) == Tile::grass_Id) { setEating(true); } } @@ -1119,8 +1119,8 @@ void EntityHorse::travel(float xa, float ya) { hasImpulse = true; if (ya > 0) { - float sin = Mth::sin(yRot * M_PI / 180); - float cos = Mth::cos(yRot * M_PI / 180); + float sin = sinf(yRot * std::numbers::pi / 180); + float cos = cosf(yRot * std::numbers::pi / 180); xd += -0.4f * sin * playerJumpPendingScale; zd += 0.4f * cos * playerJumpPendingScale; @@ -1146,7 +1146,7 @@ void EntityHorse::travel(float xa, float ya) { walkAnimSpeedO = walkAnimSpeed; double dx = x - xo; double dz = z - zo; - float wst = Mth::sqrt(dx * dx + dz * dz) * 4.0f; + float wst = GameMath::sqrt(dx * dx + dz * dz) * 4.0f; if (wst > 1.0f) { wst = 1.0f; } @@ -1464,8 +1464,8 @@ void EntityHorse::positionRider() { Animal::positionRider(); if (standAnimO > 0) { - float sin = Mth::sin(yBodyRot * M_PI / 180); - float cos = Mth::cos(yBodyRot * M_PI / 180); + float sin = sinf(yBodyRot * std::numbers::pi / 180); + float cos = cosf(yBodyRot * std::numbers::pi / 180); float dist = .7f * standAnimO; float height = .15f * standAnimO; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/MushroomCow.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/MushroomCow.cpp index 26ef3fd2b..421cd5d99 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/MushroomCow.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/MushroomCow.cpp @@ -66,9 +66,9 @@ bool MushroomCow::mobInteract(std::shared_ptr player) { // now spawn on mycelium as well as grass - seems a bit odd that they don't // already really bool MushroomCow::canSpawn() { - int xt = Mth::floor(x); - int yt = Mth::floor(bb.y0); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(bb.y0); + int zt = GameMath::floor(z); return (level->getTile(xt, yt - 1, zt) == Tile::grass_Id || level->getTile(xt, yt - 1, zt) == Tile::mycel_Id) && level->getDaytimeRawBrightness(xt, yt, zt) > 8 && diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp index 9075ef905..7a6675e2f 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp @@ -243,9 +243,9 @@ bool Ocelot::canSpawn() { if (level->isUnobstructed(&bb) && level->getCubes(shared_from_this(), &bb)->empty() && !level->containsAnyLiquid(&bb)) { - int xt = Mth::floor(x); - int yt = Mth::floor(bb.y0); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(bb.y0); + int zt = GameMath::floor(z); if (yt < level->seaLevel) { return false; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Sheep.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Sheep.cpp index 041053a60..15baf8b3e 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Sheep.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Sheep.cpp @@ -135,12 +135,12 @@ float Sheep::getHeadEatAngleScale(float a) { if (eatAnimationTick > 4 && eatAnimationTick <= (EAT_ANIMATION_TICKS - 4)) { float scale = ((float)(eatAnimationTick - 4) - a) / (float)(EAT_ANIMATION_TICKS - 8); - return M_PI * .20f + M_PI * .07f * Mth::sin(scale * 28.7f); + return std::numbers::pi * .20f + std::numbers::pi * .07f * sinf(scale * 28.7f); } if (eatAnimationTick > 0) { - return M_PI * .20f; + return std::numbers::pi * .20f; } - return ((xRot / (180.0f / M_PI))); + return ((xRot / (180.0f / std::numbers::pi))); } bool Sheep::mobInteract(std::shared_ptr player) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/SnowMan.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/SnowMan.cpp index 7f8c74d98..7120eca24 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/SnowMan.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/SnowMan.cpp @@ -53,17 +53,17 @@ void SnowMan::aiStep() { if (isInWaterOrRain()) hurt(DamageSource::drown, 1); { - int xx = Mth::floor(x); - int zz = Mth::floor(z); + int xx = GameMath::floor(x); + int zz = GameMath::floor(z); if (level->getBiome(xx, zz)->getTemperature() > 1) { hurt(DamageSource::onFire, 1); } } for (int i = 0; i < 4; i++) { - int xx = Mth::floor(x + (i % 2 * 2 - 1) * 0.25f); - int yy = Mth::floor(y); - int zz = Mth::floor(z + ((i / 2) % 2 * 2 - 1) * 0.25f); + int xx = GameMath::floor(x + (i % 2 * 2 - 1) * 0.25f); + int yy = GameMath::floor(y); + int zz = GameMath::floor(z + ((i / 2) % 2 * 2 - 1) * 0.25f); if (level->getTile(xx, yy, zz) == 0) { if (level->getBiome(xx, zz)->getTemperature() < 0.8f) { if (Tile::topSnow->mayPlace(level, xx, yy, zz)) { @@ -91,7 +91,7 @@ void SnowMan::performRangedAttack(std::shared_ptr target, double xd = target->x - x; double yd = (target->y + target->getHeadHeight() - 1.1f) - snowball->y; double zd = target->z - z; - float yo = Mth::sqrt(xd * xd + zd * zd) * 0.2f; + float yo = GameMath::sqrt(xd * xd + zd * zd) * 0.2f; snowball->shoot(xd, yd + yo, zd, 1.60f, 12); playSound(eSoundType_RANDOM_BOW, 1.0f, diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Squid.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Squid.cpp index c6cbe59f5..8f667276f 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Squid.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Squid.cpp @@ -80,17 +80,17 @@ void Squid::aiStep() { oldTentacleAngle = tentacleAngle; tentacleMovement += tentacleSpeed; - if (tentacleMovement > (float)M_PI * 2.0f) { - tentacleMovement -= (float)M_PI * 2.0f; + if (tentacleMovement > (float)std::numbers::pi * 2.0f) { + tentacleMovement -= (float)std::numbers::pi * 2.0f; if (random->nextInt(10) == 0) tentacleSpeed = 1 / (random->nextFloat() + 1) * 0.2f; } if (isInWater()) { - if (tentacleMovement < M_PI) { - float tentacleScale = tentacleMovement / M_PI; + if (tentacleMovement < std::numbers::pi) { + float tentacleScale = tentacleMovement / std::numbers::pi; tentacleAngle = - Mth::sin(tentacleScale * tentacleScale * M_PI) * M_PI * 0.25f; + sinf(tentacleScale * tentacleScale * std::numbers::pi) * std::numbers::pi * 0.25f; if (tentacleScale > .75) { speed = 1.0f; @@ -112,14 +112,14 @@ void Squid::aiStep() { double horizontalMovement = sqrt(xd * xd + zd * zd); - yBodyRot += ((-(float)atan2(xd, zd) * 180 / M_PI) - yBodyRot) * 0.1f; + yBodyRot += ((-(float)atan2(xd, zd) * 180 / std::numbers::pi) - yBodyRot) * 0.1f; yRot = yBodyRot; - zBodyRot = zBodyRot + (float)M_PI * rotateSpeed * 1.5f; + zBodyRot = zBodyRot + (float)std::numbers::pi * rotateSpeed * 1.5f; xBodyRot += - ((-(float)atan2(horizontalMovement, yd) * 180 / M_PI) - xBodyRot) * + ((-(float)atan2(horizontalMovement, yd) * 180 / std::numbers::pi) - xBodyRot) * 0.1f; } else { - tentacleAngle = Mth::abs(Mth::sin(tentacleMovement)) * M_PI * 0.25f; + tentacleAngle = GameMath::abs(sinf(tentacleMovement)) * std::numbers::pi * 0.25f; if (!level->isClientSide) { // unable to move, apply gravity @@ -144,10 +144,10 @@ void Squid::serverAiStep() { tx = ty = tz = 0; } else if (random->nextInt(50) == 0 || !wasInWater || (tx == 0 && ty == 0 && tz == 0)) { - float angle = random->nextFloat() * M_PI * 2.0f; - tx = Mth::cos(angle) * 0.2f; + float angle = random->nextFloat() * std::numbers::pi * 2.0f; + tx = cosf(angle) * 0.2f; ty = -0.1f + random->nextFloat() * 0.2f; - tz = Mth::sin(angle) * 0.2f; + tz = sinf(angle) * 0.2f; } checkDespawn(); // 4J - 1.7.0 fix } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/VillagerGolem.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/VillagerGolem.cpp index 8445636ed..6c3131cb6 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/VillagerGolem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/VillagerGolem.cpp @@ -62,7 +62,7 @@ void VillagerGolem::serverAiMobStep() { if (--villageUpdateInterval <= 0) { villageUpdateInterval = 70 + random->nextInt(50); std::shared_ptr _village = level->villages->getClosestVillage( - Mth::floor(x), Mth::floor(y), Mth::floor(z), Villages::MaxDoorDist); + GameMath::floor(x), GameMath::floor(y), GameMath::floor(z), Villages::MaxDoorDist); village = _village; if (_village == nullptr) clearRestriction(); @@ -105,9 +105,9 @@ void VillagerGolem::aiStep() { if (xd * xd + zd * zd > MoveControl::MIN_SPEED_SQR && random->nextInt(5) == 0) { - int xt = Mth::floor(x); - int yt = Mth::floor(y - 0.2f - heightOffset); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(y - 0.2f - heightOffset); + int zt = GameMath::floor(z); int t = level->getTile(xt, yt, zt); int d = level->getData(xt, yt, zt); if (t > 0) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Wolf.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Wolf.cpp index fa944963b..e2223b184 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Wolf.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Wolf.cpp @@ -184,7 +184,7 @@ void Wolf::tick() { if (shakeAnim > 0.4f) { float yt = (float)bb.y0; int shakeCount = - (int)(Mth::sin((shakeAnim - 0.4f) * M_PI) * 7.0f); + (int)(sinf((shakeAnim - 0.4f) * std::numbers::pi) * 7.0f); for (int i = 0; i < shakeCount; i++) { float xo = (random->nextFloat() * 2 - 1) * bbWidth * 0.5f; float zo = (random->nextFloat() * 2 - 1) * bbWidth * 0.5f; @@ -210,13 +210,13 @@ float Wolf::getBodyRollAngle(float a, float offset) { } else if (progress > 1) { progress = 1; } - return Mth::sin(progress * M_PI) * Mth::sin(progress * M_PI * 11.0f) * 0.15f * - M_PI; + return sinf(progress * std::numbers::pi) * sinf(progress * std::numbers::pi * 11.0f) * 0.15f * + std::numbers::pi; } float Wolf::getHeadRollAngle(float a) { return (interestedAngleO + (interestedAngle - interestedAngleO) * a) * - 0.15f * M_PI; + 0.15f * std::numbers::pi; } float Wolf::getHeadHeight() { return bbHeight * 0.8f; } @@ -382,13 +382,13 @@ void Wolf::handleEntityEvent(uint8_t id) { float Wolf::getTailAngle() { if (isAngry()) { - return 0.49f * M_PI; + return 0.49f * std::numbers::pi; } else if (isTame()) { return (0.55f - (MAX_HEALTH - entityData->getFloat(DATA_HEALTH_ID)) * 0.02f) * - M_PI; + std::numbers::pi; } - return 0.20f * M_PI; + return 0.20f * std::numbers::pi; } bool Wolf::isFood(std::shared_ptr item) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderCrystal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderCrystal.cpp index 133520cf7..839307e03 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderCrystal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderCrystal.cpp @@ -46,9 +46,9 @@ void EnderCrystal::tick() { // removing/adding these fire tiles causing timing glitches from the // lighting changes requried. if (!level->isClientSide) { - int xt = Mth::floor(x); - int yt = Mth::floor(y); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(y); + int zt = GameMath::floor(z); if (level->getTile(xt, yt, zt) != Tile::fire_Id) { level->setTileAndUpdate(xt, yt, zt, Tile::fire_Id); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp index c5a87a915..28c435ac3 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp @@ -181,7 +181,7 @@ void EnderDragon::getLatencyPos(std::vector& result, int step, float a) // positions[i][2] is currently always 0 double yr0 = positions[p0][0]; - double yrd = Mth::wrapDegrees(positions[p1][0] - yr0); + double yrd = GameMath::wrapDegrees(positions[p1][0] - yr0); result[0] = yr0 + yrd * a; yr0 = positions[p0][1]; @@ -199,8 +199,8 @@ void EnderDragon::aiStep() { // previously saved at point of hes death setHealth(getHealth()); - float flap = Mth::cos(flapTime * M_PI * 2); - float oldFlap = Mth::cos(oFlapTime * M_PI * 2); + float flap = cosf(flapTime * std::numbers::pi * 2); + float oldFlap = cosf(oFlapTime * std::numbers::pi * 2); if (oldFlap <= -0.3f && flap >= -0.3f) { level->playLocalSound(x, y, z, eSoundType_MOB_ENDERDRAGON_MOVE, 1, @@ -251,7 +251,7 @@ void EnderDragon::aiStep() { flapTime += flapSpeed; } - yRot = Mth::wrapDegrees(yRot); + yRot = GameMath::wrapDegrees(yRot); if (posPointer < 0) { for (int i = 0; i < positionsLength; i++) { @@ -284,7 +284,7 @@ void EnderDragon::aiStep() { //} // else { - double yrd = Mth::wrapDegrees(lyr - yRot); + double yrd = GameMath::wrapDegrees(lyr - yRot); m_headYRot = 0.0; yRot += (yrd) / lSteps; @@ -316,7 +316,7 @@ void EnderDragon::aiStep() { // d < 3; ++d) { Vec3 vN = Vec3{v.x, v.y, v.z}.normalize(); - vN.yRot(-M_PI / 4); + vN.yRot(-std::numbers::pi / 4); for (unsigned int i = 0; i < 8; ++i) { if (getSynchedAction() == e_EnderdragonAction_Landing) { @@ -363,7 +363,7 @@ void EnderDragon::aiStep() { -vN.z * xzVelocity * j); } } - vN.yRot(M_PI / (2 * 8)); + vN.yRot(std::numbers::pi / (2 * 8)); } } } else if (getSynchedAction() == @@ -481,11 +481,11 @@ void EnderDragon::aiStep() { Vec3 aim = Vec3((attackTarget->x - x), 0, (attackTarget->z - z)) .normalize(); - Vec3 dir = Vec3(sin(yRot * M_PI / 180), 0, -cos(yRot * M_PI / 180)) + Vec3 dir = Vec3(sin(yRot * std::numbers::pi / 180), 0, -cos(yRot * std::numbers::pi / 180)) .normalize(); float dot = (float)dir.dot(aim); - float angleDegs = acos(dot) * 180 / M_PI; + float angleDegs = acos(dot) * 180 / std::numbers::pi; angleDegs = angleDegs + 0.5f; if (angleDegs < 0 || angleDegs > 10) { @@ -495,8 +495,8 @@ void EnderDragon::aiStep() { // 2); double zdd = attackTarget->z - head->z; - double yRotT = (180) - atan2(xdd, zdd) * 180 / M_PI; - double yRotD = Mth::wrapDegrees(yRotT - yRot); + double yRotT = (180) - atan2(xdd, zdd) * 180 / std::numbers::pi; + double yRotD = GameMath::wrapDegrees(yRotT - yRot); if (yRotD > 50) yRotD = 50; if (yRotD < -50) yRotD = -50; @@ -554,7 +554,7 @@ void EnderDragon::aiStep() { while (yRot < -180) yRot += 180 * 2; while (yRot >= 180) yRot -= 180 * 2; - double yRotT = (180) - atan2(xdd, zdd) * 180 / M_PI; + double yRotT = (180) - atan2(xdd, zdd) * 180 / std::numbers::pi; double yRotD = yRotT - yRot; while (yRotD < -180) yRotD += 180 * 2; while (yRotD >= 180) yRotD -= 180 * 2; @@ -565,7 +565,7 @@ void EnderDragon::aiStep() { Vec3 aim = Vec3((xTarget - x), (yTarget - y), (zTarget - z)).normalize(); - Vec3 dir = Vec3(sin(yRot * M_PI / 180), yd, -cos(yRot * M_PI / 180)) + Vec3 dir = Vec3(sin(yRot * std::numbers::pi / 180), yd, -cos(yRot * std::numbers::pi / 180)) .normalize(); float dot = (float)(dir.dot(aim) + 0.5f) / 1.5f; if (dot < 0) dot = 0; @@ -623,8 +623,8 @@ void EnderDragon::aiStep() { // getLatencyPos(latencyPosB, 10, 1); // float tilt = (float) (latencyPosA[1] - latencyPosB[1]) * 10 / 180.0f * - // M_PI; - float tilt = (float)getTilt(1) / 180.0f * M_PI; + // std::numbers::pi; + float tilt = (float)getTilt(1) / 180.0f * std::numbers::pi; float ccTilt = cos(tilt); // 4J Stu - ssTilt was negative sin(tilt), but this causes the bounding @@ -632,7 +632,7 @@ void EnderDragon::aiStep() { // when tilting forward, and down when tilting backwards float ssTilt = sin(tilt); - float rot1 = yRot * M_PI / 180; + float rot1 = yRot * std::numbers::pi / 180; float ss1 = sin(rot1); float cc1 = cos(rot1); @@ -667,8 +667,8 @@ void EnderDragon::aiStep() { double yRotDiff = getHeadYRotDiff(1); - float ss = sin((yRot + yRotDiff) * M_PI / 180 - yRotA * 0.01f); - float cc = cos((yRot + yRotDiff) * M_PI / 180 - yRotA * 0.01f); + float ss = sin((yRot + yRotDiff) * std::numbers::pi / 180 - yRotA * 0.01f); + float cc = cos((yRot + yRotDiff) * std::numbers::pi / 180 - yRotA * 0.01f); head->tick(); neck->tick(); double yOffset = getHeadYOffset(1); // (p0[1] - p1[1]) * 1 @@ -715,7 +715,7 @@ void EnderDragon::aiStep() { std::vector p0 = std::vector(p0components, p0components + 3); getLatencyPos(p0, 12 + i * 2, 1); - float rot = yRot * M_PI / 180 + rotWrap(p0[0] - p1[0]) * M_PI / 180 * (1); + float rot = yRot * std::numbers::pi / 180 + rotWrap(p0[0] - p1[0]) * std::numbers::pi / 180 * (1); float ss = sin(rot); float cc = cos(rot); @@ -739,11 +739,11 @@ void EnderDragon::aiStep() { Vec3 aim = Vec3((attackTarget->x - x), 0, (attackTarget->z - z)) .normalize(); - Vec3 dir = Vec3(sin(yRot * M_PI / 180), 0, -cos(yRot * M_PI / 180)) + Vec3 dir = Vec3(sin(yRot * std::numbers::pi / 180), 0, -cos(yRot * std::numbers::pi / 180)) .normalize(); float dot = (float)dir.dot(aim); - float angleDegs = acos(dot) * 180 / M_PI; + float angleDegs = acos(dot) * 180 / std::numbers::pi; angleDegs = angleDegs + 0.5f; if (m_fireballCharge >= 20 && @@ -1074,12 +1074,12 @@ float EnderDragon::rotWrap(double d) { } bool EnderDragon::checkWalls(AABB* bb) { - int x0 = Mth::floor(bb->x0); - int y0 = Mth::floor(bb->y0); - int z0 = Mth::floor(bb->z0); - int x1 = Mth::floor(bb->x1); - int y1 = Mth::floor(bb->y1); - int z1 = Mth::floor(bb->z1); + int x0 = GameMath::floor(bb->x0); + int y0 = GameMath::floor(bb->y0); + int z0 = GameMath::floor(bb->z0); + int x1 = GameMath::floor(bb->x1); + int y1 = GameMath::floor(bb->y1); + int z1 = GameMath::floor(bb->z1); bool hitWall = false; bool destroyedTile = false; for (int x = x0; x <= x1; x++) { @@ -1116,7 +1116,7 @@ bool EnderDragon::hurt(std::shared_ptr MultiEntityMobPart, damage = damage / 4 + 1; } - // float rot1 = yRot * M_PI / 180; + // float rot1 = yRot * std::numbers::pi / 180; // float ss1 = sin(rot1); // float cc1 = cos(rot1); @@ -1231,7 +1231,7 @@ void EnderDragon::tickDeath() { zo = 0; } // 4J-PB changed to center this between the pillars - spawnExitPortal(0, 0); // Mth::floor(x), Mth::floor(z)); + spawnExitPortal(0, 0); // GameMath::floor(x), GameMath::floor(z)); remove(); } } @@ -1529,18 +1529,18 @@ int EnderDragon::findClosestNode() { int yAdjustment = 5; multiplier = i; if (i < 12) { - nodeX = 60 * Mth::cos(2 * (-M_PI + (M_PI / 12) * multiplier)); - nodeZ = 60 * Mth::sin(2 * (-M_PI + (M_PI / 12) * multiplier)); + nodeX = 60 * cosf(2 * (-std::numbers::pi + (std::numbers::pi / 12) * multiplier)); + nodeZ = 60 * sinf(2 * (-std::numbers::pi + (std::numbers::pi / 12) * multiplier)); } else if (i < 20) { multiplier -= 12; - nodeX = 40 * Mth::cos(2 * (-M_PI + (M_PI / 8) * multiplier)); - nodeZ = 40 * Mth::sin(2 * (-M_PI + (M_PI / 8) * multiplier)); + nodeX = 40 * cosf(2 * (-std::numbers::pi + (std::numbers::pi / 8) * multiplier)); + nodeZ = 40 * sinf(2 * (-std::numbers::pi + (std::numbers::pi / 8) * multiplier)); yAdjustment += 10; // Make the target well above the top of the towers } else { multiplier -= 20; - nodeX = 20 * Mth::cos(2 * (-M_PI + (M_PI / 4) * multiplier)); - nodeZ = 20 * Mth::sin(2 * (-M_PI + (M_PI / 4) * multiplier)); + nodeX = 20 * cosf(2 * (-std::numbers::pi + (std::numbers::pi / 4) * multiplier)); + nodeZ = 20 * sinf(2 * (-std::numbers::pi + (std::numbers::pi / 4) * multiplier)); } // Fix for #77202 - TU9: Content: Gameplay: The Ender Dragon // sometimes flies through terrain Add minimum height diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/boss/wither/WitherBoss.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/boss/wither/WitherBoss.cpp index a2ed6baee..2fc7f707a 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/boss/wither/WitherBoss.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/boss/wither/WitherBoss.cpp @@ -12,7 +12,7 @@ #include "../../../level/net.minecraft.world.level.h" #include "../../../level/tile/net.minecraft.world.level.tile.h" #include "../../../phys/net.minecraft.world.phys.h" -#include "../../../../util/Mth.h" +#include "../../../../util/GameMath.h" #include "../../../../../../Header Files/SoundTypes.h" @@ -124,14 +124,14 @@ void WitherBoss::aiStep() { double zdist = e->z - z; double distSqr = xdist * xdist + zdist * zdist; if (distSqr > 9) { - double sd = Mth::sqrt(distSqr); + double sd = GameMath::sqrt(distSqr); xd += ((xdist / sd) * .5f - xd) * .6f; zd += ((zdist / sd) * .5f - zd) * .6f; } } } if ((xd * xd + zd * zd) > .05f) { - yRot = (float)atan2(zd, xd) * Mth::RADDEG - 90; + yRot = (float)atan2(zd, xd) * GameMath::RAD_TO_DEG - 90; } Monster::aiStep(); @@ -154,10 +154,10 @@ void WitherBoss::aiStep() { double xd = e->x - hx; double yd = e->y + e->getHeadHeight() - hy; double zd = e->z - hz; - double sd = Mth::sqrt(xd * xd + zd * zd); + double sd = GameMath::sqrt(xd * xd + zd * zd); - float yRotD = (float)(atan2(zd, xd) * 180 / M_PI) - 90; - float xRotD = (float)-(atan2(yd, sd) * 180 / M_PI); + float yRotD = (float)(atan2(zd, xd) * 180 / std::numbers::pi) - 90; + float xRotD = (float)-(atan2(yd, sd) * 180 / std::numbers::pi); xRotHeads[i] = rotlerp(xRotHeads[i], xRotD, 40); yRotHeads[i] = rotlerp(yRotHeads[i], yRotD, 10); @@ -224,9 +224,9 @@ void WitherBoss::newServerAiStep() { idleHeadUpdates[i - 1]++ > 15) { float hrange = 10; float vrange = 5; - double xt = Mth::nextDouble(random, x - hrange, x + hrange); - double yt = Mth::nextDouble(random, y - vrange, y + vrange); - double zt = Mth::nextDouble(random, z - hrange, z + hrange); + double xt = random->nextDouble(x - hrange, x + hrange); + double yt = random->nextDouble(y - vrange, y + vrange); + double zt = random->nextDouble(z - hrange, z + hrange); performRangedAttack(i + 1, xt, yt, zt, true); idleHeadUpdates[i - 1] = 0; } @@ -302,9 +302,9 @@ void WitherBoss::newServerAiStep() { // destroy all blocks that are within 1 range, counting from // feet and 3 blocks up - int feet = Mth::floor(y); - int ox = Mth::floor(x); - int oz = Mth::floor(z); + int feet = GameMath::floor(y); + int ox = GameMath::floor(x); + int oz = GameMath::floor(z); bool destroyed = false; for (int xStep = -1; xStep <= 1; xStep++) { @@ -348,8 +348,8 @@ double WitherBoss::getHeadX(int index) { if (index <= 0) { return x; } - float headAngle = (yBodyRot + 180 * (index - 1)) / 180.0f * M_PI; - float cos = Mth::cos(headAngle); + float headAngle = (yBodyRot + 180 * (index - 1)) / 180.0f * std::numbers::pi; + float cos = cosf(headAngle); return x + cos * 1.3; } @@ -365,13 +365,13 @@ double WitherBoss::getHeadZ(int index) { if (index <= 0) { return z; } - float headAngle = (yBodyRot + 180 * (index - 1)) / 180.0f * M_PI; - float sin = Mth::sin(headAngle); + float headAngle = (yBodyRot + 180 * (index - 1)) / 180.0f * std::numbers::pi; + float sin = sinf(headAngle); return z + sin * 1.3; } float WitherBoss::rotlerp(float a, float b, float max) { - float diff = Mth::wrapDegrees(b - a); + float diff = GameMath::wrapDegrees(b - a); if (diff > max) { diff = max; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/global/LightningBolt.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/global/LightningBolt.cpp index c37812e4f..5b39ce18e 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/global/LightningBolt.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/global/LightningBolt.cpp @@ -26,11 +26,11 @@ LightningBolt::LightningBolt(Level* level, double x, double y, double z) if (!level->isClientSide && level->getGameRules()->getBoolean(GameRules::RULE_DOFIRETICK) && level->difficulty >= 2 && - level->hasChunksAt(Mth::floor(x), Mth::floor(y), Mth::floor(z), 10)) { + level->hasChunksAt(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z), 10)) { { - int xt = Mth::floor(x); - int yt = Mth::floor(y); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(y); + int zt = GameMath::floor(z); // 4J added - don't go setting tiles if we aren't tracking them for // network synchronisation if (MinecraftServer::getInstance()->getPlayers()->isTrackingTile( @@ -42,9 +42,9 @@ LightningBolt::LightningBolt(Level* level, double x, double y, double z) } for (int i = 0; i < 4; i++) { - int xt = Mth::floor(x) + random->nextInt(3) - 1; - int yt = Mth::floor(y) + random->nextInt(3) - 1; - int zt = Mth::floor(z) + random->nextInt(3) - 1; + int xt = GameMath::floor(x) + random->nextInt(3) - 1; + int yt = GameMath::floor(y) + random->nextInt(3) - 1; + int zt = GameMath::floor(z) + random->nextInt(3) - 1; // 4J added - don't go setting tiles if we aren't tracking them for // network synchronisation if (MinecraftServer::getInstance()->getPlayers()->isTrackingTile( diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/item/Boat.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/item/Boat.cpp index 3a62b903a..c64ba6023 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/item/Boat.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/item/Boat.cpp @@ -175,8 +175,8 @@ void Boat::tick() { double lastSpeed = sqrt(xd * xd + zd * zd); if (lastSpeed > MAX_COLLISION_SPEED) { - double xa = cos(yRot * M_PI / 180); - double za = sin(yRot * M_PI / 180); + double xa = cos(yRot * std::numbers::pi / 180); + double za = sin(yRot * std::numbers::pi / 180); for (int i = 0; i < 1 + lastSpeed * 60; i++) { double side = (random->nextFloat() * 2 - 1); @@ -202,7 +202,7 @@ void Boat::tick() { double yt = y + (ly - y) / lSteps; double zt = z + (lz - z) / lSteps; - double yrd = Mth::wrapDegrees(lyr - yRot); + double yrd = GameMath::wrapDegrees(lyr - yRot); yRot += (float)((yrd) / lSteps); xRot += (float)((lxr - xRot) / lSteps); @@ -248,8 +248,8 @@ void Boat::tick() { double forward = livingRider->yya; if (forward > 0) { - double riderXd = -sin(livingRider->yRot * M_PI / 180); - double riderZd = cos(livingRider->yRot * M_PI / 180); + double riderXd = -sin(livingRider->yRot * std::numbers::pi / 180); + double riderZd = cos(livingRider->yRot * std::numbers::pi / 180); xd += riderXd * acceleration * 0.05f; zd += riderZd * acceleration * 0.05f; } @@ -301,10 +301,10 @@ void Boat::tick() { double xDiff = xo - x; double zDiff = zo - z; if (xDiff * xDiff + zDiff * zDiff > 0.001) { - yRotT = (float)(atan2(zDiff, xDiff) * 180 / M_PI); + yRotT = (float)(atan2(zDiff, xDiff) * 180 / std::numbers::pi); } - double rotDiff = Mth::wrapDegrees(yRotT - yRot); + double rotDiff = GameMath::wrapDegrees(yRotT - yRot); if (rotDiff > 20) rotDiff = 20; if (rotDiff < -20) rotDiff = -20; @@ -329,11 +329,11 @@ void Boat::tick() { } for (int i = 0; i < 4; i++) { - int xx = Mth::floor(x + ((i % 2) - 0.5) * 0.8); - int zz = Mth::floor(z + ((i / 2) - 0.5) * 0.8); + int xx = GameMath::floor(x + ((i % 2) - 0.5) * 0.8); + int zz = GameMath::floor(z + ((i / 2) - 0.5) * 0.8); for (int j = 0; j < 2; j++) { - int yy = Mth::floor(y) + j; + int yy = GameMath::floor(y) + j; int tile = level->getTile(xx, yy, zz); if (tile == Tile::topSnow_Id) { @@ -352,8 +352,8 @@ void Boat::tick() { void Boat::positionRider() { if (rider.lock() == nullptr) return; - double xa = cos(yRot * M_PI / 180) * 0.4; - double za = sin(yRot * M_PI / 180) * 0.4; + double xa = cos(yRot * std::numbers::pi / 180) * 0.4; + double za = sin(yRot * std::numbers::pi / 180) * 0.4; rider.lock()->setPos( x + xa, y + getRideHeight() + rider.lock()->getRidingHeight(), z + za); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/item/FallingTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/item/FallingTile.cpp index 8b226a6f6..aa088e0e8 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/item/FallingTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/item/FallingTile.cpp @@ -85,9 +85,9 @@ void FallingTile::tick() { zd *= 0.98f; if (!level->isClientSide) { - int xt = Mth::floor(x); - int yt = Mth::floor(y); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(y); + int zt = GameMath::floor(z); if (time == 1) { if (level->getTile(xt, yt, zt) == tile) { level->removeTile(xt, yt, zt); @@ -163,7 +163,7 @@ void FallingTile::tick() { void FallingTile::causeFallDamage(float distance) { if (hurtEntities) { - int dmg = Mth::ceil(distance - 1); + int dmg = GameMath::ceil(distance - 1); if (dmg > 0) { // 4J: Copy vector since it might be modified when we hurt the // entities (invalidating our iterator) @@ -175,7 +175,7 @@ void FallingTile::causeFallDamage(float distance) { : DamageSource::fallingBlock; // for (Entity entity : entities) for (auto it = entities->begin(); it != entities->end(); ++it) { - (*it)->hurt(source, std::min(Mth::floor(dmg * fallDamageAmount), + (*it)->hurt(source, std::min(GameMath::floor(dmg * fallDamageAmount), fallDamageMax)); } delete entities; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/item/ItemEntity.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/item/ItemEntity.cpp index 1a5de7665..95ba690e4 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/item/ItemEntity.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/item/ItemEntity.cpp @@ -17,7 +17,7 @@ void ItemEntity::_init() { age = 0; throwTime = 0; health = 5; - bobOffs = (float)(Math::random() * M_PI * 2); + bobOffs = (float)(Math::random() * std::numbers::pi * 2); // 4J Stu - This function call had to be moved here from the Entity ctor to // ensure that the derived version of the function is called @@ -77,7 +77,7 @@ void ItemEntity::tick() { bool moved = (int)xo != (int)x || (int)yo != (int)y || (int)zo != (int)z; if (moved || tickCount % 25 == 0) { - if (level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)) == + if (level->getMaterial(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)) == Material::lava) { yd = 0.2f; xd = (random->nextFloat() - random->nextFloat()) * 0.2f; @@ -97,7 +97,7 @@ void ItemEntity::tick() { if (onGround) { friction = 0.6f * 0.98f; int t = - level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1, Mth::floor(z)); + level->getTile(GameMath::floor(x), GameMath::floor(bb.y0) - 1, GameMath::floor(z)); if (t > 0) { friction = Tile::tiles[t]->friction * 0.98f; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/item/Minecart.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/item/Minecart.cpp index a6080f98d..caf9987a5 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/item/Minecart.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/item/Minecart.cpp @@ -244,7 +244,7 @@ void Minecart::tick() { double yt = y + (ly - y) / lSteps; double zt = z + (lz - z) / lSteps; - double yrd = Mth::wrapDegrees(lyr - yRot); + double yrd = GameMath::wrapDegrees(lyr - yRot); yRot += (float)((yrd) / lSteps); xRot += (float)((lxr - xRot) / lSteps); @@ -266,9 +266,9 @@ void Minecart::tick() { yd -= 0.04f; - int xt = Mth::floor(x); - int yt = Mth::floor(y); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(y); + int zt = GameMath::floor(z); if (BaseRailTile::isRail(level, xt, yt - 1, zt)) { yt--; } @@ -295,11 +295,11 @@ void Minecart::tick() { double xDiff = xo - x; double zDiff = zo - z; if (xDiff * xDiff + zDiff * zDiff > 0.001) { - yRot = (float)(atan2(zDiff, xDiff) * 180 / M_PI); + yRot = (float)(atan2(zDiff, xDiff) * 180 / std::numbers::pi); if (flipped) yRot += 180; } - double rotDiff = Mth::wrapDegrees(yRot - yRotO); + double rotDiff = GameMath::wrapDegrees(yRot - yRotO); if (rotDiff < -170 || rotDiff >= 170) { yRot += 180; @@ -417,8 +417,8 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double forward = living->yya; if (forward > 0) { - double riderXd = -sin(living->yRot * M_PI / 180); - double riderZd = cos(living->yRot * M_PI / 180); + double riderXd = -sin(living->yRot * std::numbers::pi / 180); + double riderZd = cos(living->yRot * std::numbers::pi / 180); double ownDist = xd * xd + zd * zd; @@ -485,11 +485,11 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, move(xdd, 0, zdd); - if (exits[0][1] != 0 && Mth::floor(x) - xt == exits[0][0] && - Mth::floor(z) - zt == exits[0][2]) { + if (exits[0][1] != 0 && GameMath::floor(x) - xt == exits[0][0] && + GameMath::floor(z) - zt == exits[0][2]) { setPos(x, y + exits[0][1], z); - } else if (exits[1][1] != 0 && Mth::floor(x) - xt == exits[1][0] && - Mth::floor(z) - zt == exits[1][2]) { + } else if (exits[1][1] != 0 && GameMath::floor(x) - xt == exits[1][0] && + GameMath::floor(z) - zt == exits[1][2]) { setPos(x, y + exits[1][1], z); } @@ -507,8 +507,8 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, setPos(x, newPos->y, z); } - int xn = Mth::floor(x); - int zn = Mth::floor(z); + int xn = GameMath::floor(x); + int zn = GameMath::floor(z); if (xn != xt || zn != zt) { pow = sqrt(xd * xd + zd * zd); @@ -557,9 +557,9 @@ void Minecart::applyNaturalSlowdown() { std::optional Minecart::getPosOffs(double x, double y, double z, double offs) { - int xt = Mth::floor(x); - int yt = Mth::floor(y); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(y); + int zt = GameMath::floor(z); if (BaseRailTile::isRail(level, xt, yt - 1, zt)) { yt--; } @@ -591,11 +591,11 @@ std::optional Minecart::getPosOffs(double x, double y, double z, x += xD * offs; z += zD * offs; - if (exits[0][1] != 0 && Mth::floor(x) - xt == exits[0][0] && - Mth::floor(z) - zt == exits[0][2]) { + if (exits[0][1] != 0 && GameMath::floor(x) - xt == exits[0][0] && + GameMath::floor(z) - zt == exits[0][2]) { y += exits[0][1]; - } else if (exits[1][1] != 0 && Mth::floor(x) - xt == exits[1][0] && - Mth::floor(z) - zt == exits[1][2]) { + } else if (exits[1][1] != 0 && GameMath::floor(x) - xt == exits[1][0] && + GameMath::floor(z) - zt == exits[1][2]) { y += exits[1][1]; } @@ -606,9 +606,9 @@ std::optional Minecart::getPosOffs(double x, double y, double z, } std::optional Minecart::getPos(double x, double y, double z) { - int xt = Mth::floor(x); - int yt = Mth::floor(y); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(y); + int zt = GameMath::floor(z); if (BaseRailTile::isRail(level, xt, yt - 1, zt)) { yt--; } @@ -736,7 +736,7 @@ void Minecart::push(std::shared_ptr e) { Vec3 dir(xo, 0, zo); dir = dir.normalize(); - Vec3 facing(cos(yRot * M_PI / 180), 0, sin(yRot * M_PI / 180)); + Vec3 facing(cos(yRot * std::numbers::pi / 180), 0, sin(yRot * std::numbers::pi / 180)); facing = facing.normalize(); double dot = abs(dir.dot(facing)); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartFurnace.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartFurnace.cpp index fff44c184..71c8cf4e0 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartFurnace.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartFurnace.cpp @@ -66,7 +66,7 @@ void MinecartFurnace::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double sd = xPush * xPush + zPush * zPush; if (sd > 0.01 * 0.01 && xd * xd + zd * zd > 0.001) { - sd = Mth::sqrt(sd); + sd = GameMath::sqrt(sd); xPush /= sd; zPush /= sd; @@ -84,7 +84,7 @@ void MinecartFurnace::applyNaturalSlowdown() { double sd = xPush * xPush + zPush * zPush; if (sd > 0.01 * 0.01) { - sd = Mth::sqrt(sd); + sd = GameMath::sqrt(sd); xPush /= sd; zPush /= sd; double speed = 0.05; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartSpawner.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartSpawner.cpp index 96f040ca4..2aecc6e66 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartSpawner.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartSpawner.cpp @@ -18,15 +18,15 @@ Level* MinecartSpawner::MinecartMobSpawner::getLevel() { } int MinecartSpawner::MinecartMobSpawner::getX() { - return Mth::floor(m_parent->x); + return GameMath::floor(m_parent->x); } int MinecartSpawner::MinecartMobSpawner::getY() { - return Mth::floor(m_parent->y); + return GameMath::floor(m_parent->y); } int MinecartSpawner::MinecartMobSpawner::getZ() { - return Mth::floor(m_parent->z); + return GameMath::floor(m_parent->z); } MinecartSpawner::MinecartSpawner(Level* level) : Minecart(level) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/item/PrimedTnt.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/item/PrimedTnt.cpp index c81ea76ee..989305fb0 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/item/PrimedTnt.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/item/PrimedTnt.cpp @@ -30,7 +30,7 @@ PrimedTnt::PrimedTnt(Level* level, double x, double y, double z, setPos(x, y, z); - float rot = (float)(Math::random() * M_PI * 2); + float rot = (float)(Math::random() * std::numbers::pi * 2); xd = -sin(rot) * 0.02f; yd = +0.2f; zd = -cos(rot) * 0.02f; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Blaze.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Blaze.cpp index e200beabe..eb259fa1d 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Blaze.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Blaze.cpp @@ -139,7 +139,7 @@ void Blaze::checkHurtTarget(std::shared_ptr target, float d) { } } } - yRot = (float)(atan2(zd, xd) * 180 / M_PI) - 90; + yRot = (float)(atan2(zd, xd) * 180 / std::numbers::pi) - 90; holdGround = true; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/EnderMan.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/EnderMan.cpp index 37462ceb7..174649fec 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/EnderMan.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/EnderMan.cpp @@ -149,9 +149,9 @@ void EnderMan::aiStep() { if (level->getGameRules()->getBoolean(GameRules::RULE_MOBGRIEFING)) { if (getCarryingTile() == 0) { if (random->nextInt(20) == 0) { - int xt = Mth::floor(x - 2 + random->nextDouble() * 4); - int yt = Mth::floor(y + random->nextDouble() * 3); - int zt = Mth::floor(z - 2 + random->nextDouble() * 4); + int xt = GameMath::floor(x - 2 + random->nextDouble() * 4); + int yt = GameMath::floor(y + random->nextDouble() * 3); + int zt = GameMath::floor(z - 2 + random->nextDouble() * 4); int t = level->getTile(xt, yt, zt); if (MAY_TAKE[t]) { setCarryingTile(level->getTile(xt, yt, zt)); @@ -161,9 +161,9 @@ void EnderMan::aiStep() { } } else { if (random->nextInt(2000) == 0) { - int xt = Mth::floor(x - 1 + random->nextDouble() * 2); - int yt = Mth::floor(y + random->nextDouble() * 2); - int zt = Mth::floor(z - 1 + random->nextDouble() * 2); + int xt = GameMath::floor(x - 1 + random->nextDouble() * 2); + int yt = GameMath::floor(y + random->nextDouble() * 2); + int zt = GameMath::floor(z - 1 + random->nextDouble() * 2); int t = level->getTile(xt, yt, zt); int bt = level->getTile(xt, yt - 1, zt); if (t == 0 && bt > 0 && Tile::tiles[bt]->isCubeShaped()) { @@ -189,8 +189,8 @@ void EnderMan::aiStep() { if (level->isDay() && !level->isClientSide) { float br = getBrightness(1); if (br > 0.5f) { - if (level->canSeeSky(Mth::floor(x), (int)floor(y + 0.5), - Mth::floor(z)) && + if (level->canSeeSky(GameMath::floor(x), (int)floor(y + 0.5), + GameMath::floor(z)) && random->nextFloat() * 30 < (br - 0.4f) * 2) { attackTarget = nullptr; setCreepy(false); @@ -269,9 +269,9 @@ bool EnderMan::teleport(double xx, double yy, double zz) { y = yy; z = zz; bool ok = false; - int xt = Mth::floor(x); - int yt = Mth::floor(y); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(y); + int zt = GameMath::floor(z); if (level->hasChunkAt(xt, yt, zt)) { bool landed = false; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Ghast.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Ghast.cpp index b301becd8..3d06b65f1 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Ghast.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Ghast.cpp @@ -121,7 +121,7 @@ void Ghast::serverAiStep() { double ydd = (target->bb.y0 + target->bbHeight / 2) - (y + bbHeight / 2); double zdd = target->z - z; - yBodyRot = yRot = -(float)atan2(xdd, zdd) * 180 / M_PI; + yBodyRot = yRot = -(float)atan2(xdd, zdd) * 180 / std::numbers::pi; if (canSee(target)) { if (charge == 10) { @@ -152,7 +152,7 @@ void Ghast::serverAiStep() { if (charge > 0) charge--; } } else { - yBodyRot = yRot = -(float)atan2(this->xd, this->zd) * 180 / M_PI; + yBodyRot = yRot = -(float)atan2(this->xd, this->zd) * 180 / std::numbers::pi; if (charge > 0) charge--; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Monster.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Monster.cpp index 2cbf8c183..7f014243b 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Monster.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Monster.cpp @@ -89,8 +89,8 @@ bool Monster::doHurtTarget(std::shared_ptr target) { if (wasHurt) { if (knockback > 0) { - target->push(-Mth::sin(yRot * M_PI / 180) * knockback * .5f, 0.1, - Mth::cos(yRot * M_PI / 180) * knockback * .5f); + target->push(-sinf(yRot * std::numbers::pi / 180) * knockback * .5f, 0.1, + cosf(yRot * std::numbers::pi / 180) * knockback * .5f); xd *= 0.6; zd *= 0.6; } @@ -125,9 +125,9 @@ float Monster::getWalkTargetValue(int x, int y, int z) { } bool Monster::isDarkEnoughToSpawn() { - int xt = Mth::floor(x); - int yt = Mth::floor(bb.y0); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(bb.y0); + int zt = GameMath::floor(z); if (level->getBrightness(LightLayer::Sky, xt, yt, zt) > random->nextInt(32)) return false; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Silverfish.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Silverfish.cpp index 74491d707..36b469530 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Silverfish.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Silverfish.cpp @@ -100,9 +100,9 @@ void Silverfish::serverAiStep() { lookForFriends--; if (lookForFriends == 0) { // see if there are any friendly monster eggs nearby - int baseX = Mth::floor(x); - int baseY = Mth::floor(y); - int baseZ = Mth::floor(z); + int baseX = GameMath::floor(x); + int baseY = GameMath::floor(y); + int baseZ = GameMath::floor(z); bool doBreak = false; for (int yOff = 0; !doBreak && yOff <= 5 && yOff >= -5; @@ -152,8 +152,8 @@ void Silverfish::serverAiStep() { if (attackTarget == nullptr && !isPathFinding()) { // if the silverfish isn't doing anything special, it will merge // with any rock tile it is nearby - int tileX = Mth::floor(x), tileY = Mth::floor(y + .5f), - tileZ = Mth::floor(z); + int tileX = GameMath::floor(x), tileY = GameMath::floor(y + .5f), + tileZ = GameMath::floor(z); int facing = random->nextInt(6); int tile = level->getTile(tileX + Facing::STEP_X[facing], diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Skeleton.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Skeleton.cpp index 8ae6c822d..5d982289f 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Skeleton.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Skeleton.cpp @@ -96,8 +96,8 @@ void Skeleton::aiStep() { if (level->isDay() && !level->isClientSide) { float br = getBrightness(1); if (br > 0.5f && random->nextFloat() * 30 < (br - 0.4f) * 2 && - level->canSeeSky(Mth::floor(x), (int)floor(y + 0.5), - Mth::floor(z))) { + level->canSeeSky(GameMath::floor(x), (int)floor(y + 0.5), + GameMath::floor(z))) { bool burn = true; std::shared_ptr helmet = getCarried(SLOT_HELM); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Slime.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Slime.cpp index 4f2420259..a5fb6c6e9 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Slime.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Slime.cpp @@ -87,10 +87,10 @@ void Slime::tick() { if (onGround && !wasOnGround) { int size = getSize(); for (int i = 0; i < size * 8; i++) { - float dir = random->nextFloat() * M_PI * 2; + float dir = random->nextFloat() * std::numbers::pi * 2; float d = random->nextFloat() * 0.5f + 0.5f; - float xd = Mth::sin(dir) * size * 0.5f * d; - float zd = Mth::cos(dir) * size * 0.5f * d; + float xd = sinf(dir) * size * 0.5f * d; + float zd = cosf(dir) * size * 0.5f * d; level->addParticle(getParticleName(), x + xd, bb.y0, z + zd, 0, 0, 0); } @@ -214,7 +214,7 @@ int Slime::getDeathLoot() { } bool Slime::canSpawn() { - LevelChunk* lc = level->getChunkAt(Mth::floor(x), Mth::floor(z)); + LevelChunk* lc = level->getChunkAt(GameMath::floor(x), GameMath::floor(z)); if (level->getLevelData()->getGenerator() == LevelType::lvl_flat && random->nextInt(4) != 1) { return false; @@ -223,13 +223,13 @@ bool Slime::canSpawn() { lc->getRandom(987234911l); // 4J - separated out so we can delete if ((getSize() == 1 || level->difficulty > Difficulty::PEACEFUL)) { // spawn slime in swamplands at night - Biome* biome = level->getBiome(Mth::floor(x), Mth::floor(z)); + Biome* biome = level->getBiome(GameMath::floor(x), GameMath::floor(z)); if (biome == Biome::swampland && y > 50 && y < 70 && random->nextFloat() < 0.5f) { if (random->nextFloat() < level->getMoonBrightness() && - level->getRawBrightness(Mth::floor(x), Mth::floor(y), - Mth::floor(z)) <= random->nextInt(8)) { + level->getRawBrightness(GameMath::floor(x), GameMath::floor(y), + GameMath::floor(z)) <= random->nextInt(8)) { return Mob::canSpawn(); } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Witch.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Witch.cpp index acec86850..7fa14afe6 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Witch.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Witch.cpp @@ -197,7 +197,7 @@ void Witch::performRangedAttack(std::shared_ptr target, double xd = (target->x + target->xd) - x; double yd = (target->y + target->getHeadHeight() - 1.1f) - y; double zd = (target->z + target->zd) - z; - float dist = Mth::sqrt(xd * xd + zd * zd); + float dist = GameMath::sqrt(xd * xd + zd * zd); if (dist >= 8 && !target->hasEffect(MobEffect::movementSlowdown)) { potion->setPotionValue(PotionBrewing::POTION_ID_SPLASH_SLOWNESS); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Zombie.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Zombie.cpp index 5cfac3cd4..10e40890a 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Zombie.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Zombie.cpp @@ -115,8 +115,8 @@ void Zombie::aiStep() { if (level->isDay() && !level->isClientSide && !isBaby()) { float br = getBrightness(1); if (br > 0.5f && random->nextFloat() * 30 < (br - 0.4f) * 2 && - level->canSeeSky(Mth::floor(x), (int)floor(y + 0.5), - Mth::floor(z))) { + level->canSeeSky(GameMath::floor(x), (int)floor(y + 0.5), + GameMath::floor(z))) { bool burn = true; std::shared_ptr helmet = getCarried(SLOT_HELM); @@ -155,22 +155,22 @@ bool Zombie::hurt(DamageSource* source, float dmg) { if ((target != nullptr) && level->difficulty >= Difficulty::HARD && random->nextFloat() < getAttribute(SPAWN_REINFORCEMENTS_CHANCE)->getValue()) { - int x = Mth::floor(this->x); - int y = Mth::floor(this->y); - int z = Mth::floor(this->z); + int x = GameMath::floor(this->x); + int y = GameMath::floor(this->y); + int z = GameMath::floor(this->z); std::shared_ptr reinforcement = std::shared_ptr(new Zombie(level)); for (int i = 0; i < REINFORCEMENT_ATTEMPTS; i++) { - int xt = x + Mth::nextInt(random, REINFORCEMENT_RANGE_MIN, + int xt = x + random->nextInt(REINFORCEMENT_RANGE_MIN, REINFORCEMENT_RANGE_MAX) * - Mth::nextInt(random, -1, 1); - int yt = y + Mth::nextInt(random, REINFORCEMENT_RANGE_MIN, + random->nextInt(-1, 1); + int yt = y + random->nextInt(REINFORCEMENT_RANGE_MIN, REINFORCEMENT_RANGE_MAX) * - Mth::nextInt(random, -1, 1); - int zt = z + Mth::nextInt(random, REINFORCEMENT_RANGE_MIN, + random->nextInt(-1, 1); + int zt = z + random->nextInt(REINFORCEMENT_RANGE_MIN, REINFORCEMENT_RANGE_MAX) * - Mth::nextInt(random, -1, 1); + random->nextInt(-1, 1); if (level->isTopSolidBlocking(xt, yt - 1, zt) && level->getRawBrightness(xt, yt, zt) < 10) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/npc/Villager.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/npc/Villager.cpp index 2cd1abf49..b635bc2d3 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/npc/Villager.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/npc/Villager.cpp @@ -100,12 +100,12 @@ bool Villager::useNewAi() { return true; } void Villager::serverAiMobStep() { if (--villageUpdateInterval <= 0) { - level->villages->queryUpdateAround(Mth::floor(x), Mth::floor(y), - Mth::floor(z)); + level->villages->queryUpdateAround(GameMath::floor(x), GameMath::floor(y), + GameMath::floor(z)); villageUpdateInterval = 70 + random->nextInt(50); std::shared_ptr _village = level->villages->getClosestVillage( - Mth::floor(x), Mth::floor(y), Mth::floor(z), Villages::MaxDoorDist); + GameMath::floor(x), GameMath::floor(y), GameMath::floor(z), Villages::MaxDoorDist); village = _village; if (_village == nullptr) clearRestriction(); @@ -471,7 +471,7 @@ void Villager::addOffers(int addCount) { Enchantment* enchantment = Enchantment::validEnchantments[random->nextInt( Enchantment::validEnchantments.size())]; - int level = Mth::nextInt(random, enchantment->getMinLevel(), + int level = random->nextInt(enchantment->getMinLevel(), enchantment->getMaxLevel()); std::shared_ptr book = Item::enchantedBook->createForEnchantment( diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/player/Player.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/player/Player.cpp index 87a75220f..938899a25 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/player/Player.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/player/Player.cpp @@ -425,13 +425,13 @@ void Player::spawnEatParticles(std::shared_ptr useItem, Vec3 d{(random->nextFloat() - 0.5) * 0.1, Math::random() * 0.1 + 0.1, 0}; - d.xRot(-xRot * M_PI / 180); - d.yRot(-yRot * M_PI / 180); + d.xRot(-xRot * std::numbers::pi / 180); + d.yRot(-yRot * std::numbers::pi / 180); Vec3 p{(random->nextFloat() - 0.5) * 0.3, -random->nextFloat() * 0.6 - 0.3, 0.6}; - p.xRot(-xRot * M_PI / 180); - p.yRot(-yRot * M_PI / 180); + p.xRot(-xRot * std::numbers::pi / 180); + p.yRot(-yRot * std::numbers::pi / 180); p = p.add(x, y + getHeadHeight(), z); level->addParticle(PARTICLE_ICONCRACK(useItem->getItem()->id, 0), @@ -899,8 +899,8 @@ void Player::die(DamageSource* source) { } if (source != nullptr) { - xd = -Mth::cos((hurtDir + yRot) * M_PI / 180) * 0.1f; - zd = -Mth::sin((hurtDir + yRot) * M_PI / 180) * 0.1f; + xd = -cosf((hurtDir + yRot) * std::numbers::pi / 180) * 0.1f; + zd = -sinf((hurtDir + yRot) * std::numbers::pi / 180) * 0.1f; } else { xd = zd = 0; } @@ -962,19 +962,19 @@ std::shared_ptr Player::drop(std::shared_ptr item, float pow = 0.1f; if (randomly) { float _pow = random->nextFloat() * 0.5f; - float dir = random->nextFloat() * M_PI * 2; + float dir = random->nextFloat() * std::numbers::pi * 2; thrownItem->xd = -sin(dir) * _pow; thrownItem->zd = cos(dir) * _pow; thrownItem->yd = 0.2f; } else { pow = 0.3f; - thrownItem->xd = -sin(yRot / 180 * M_PI) * cos(xRot / 180 * M_PI) * pow; - thrownItem->zd = cos(yRot / 180 * M_PI) * cos(xRot / 180 * M_PI) * pow; - thrownItem->yd = -sin(xRot / 180 * M_PI) * pow + 0.1f; + thrownItem->xd = -sin(yRot / 180 * std::numbers::pi) * cos(xRot / 180 * std::numbers::pi) * pow; + thrownItem->zd = cos(yRot / 180 * std::numbers::pi) * cos(xRot / 180 * std::numbers::pi) * pow; + thrownItem->yd = -sin(xRot / 180 * std::numbers::pi) * pow + 0.1f; pow = 0.02f; - float dir = random->nextFloat() * M_PI * 2; + float dir = random->nextFloat() * std::numbers::pi * 2; pow *= random->nextFloat(); thrownItem->xd += cos(dir) * pow; thrownItem->yd += (random->nextFloat() - random->nextFloat()) * 0.1f; @@ -1048,7 +1048,7 @@ void Player::readAdditionalSaveData(CompoundTag* entityTag) { setScore(entityTag->getInt(L"Score")); if (m_isSleeping) { - bedPosition = new Pos(Mth::floor(x), Mth::floor(y), Mth::floor(z)); + bedPosition = new Pos(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); stopSleepInBed(true, true, false); } @@ -1353,8 +1353,8 @@ void Player::attack(std::shared_ptr entity) { delete damageSource; if (wasHurt) { if (knockback > 0) { - entity->push(-Mth::sin(yRot * M_PI / 180) * knockback * .5f, 0.1, - Mth::cos(yRot * M_PI / 180) * knockback * .5f); + entity->push(-sinf(yRot * std::numbers::pi / 180) * knockback * .5f, 0.1, + cosf(yRot * std::numbers::pi / 180) * knockback * .5f); xd *= 0.6; zd *= 0.6; setSprinting(false); @@ -1429,9 +1429,9 @@ void Player::respawn() { deathFadeCounter = 0; } void Player::animateRespawn(std::shared_ptr player, Level* level) { for (int i = 0; i < 45; i++) { - float angle = i * M_PI * 4.0f / 25.0f; - float xo = Mth::cos(angle) * 0.7f; - float zo = Mth::sin(angle) * 0.7f; + float angle = i * std::numbers::pi * 4.0f / 25.0f; + float xo = cosf(angle) * 0.7f; + float zo = sinf(angle) * 0.7f; level->addParticle(eParticleType_netherportal, player->x + xo, player->y - player->heightOffset + 1.62f - i * .05f, @@ -1831,7 +1831,7 @@ void Player::checkRidingStatistiscs(double dx, double dy, double dz) { int dist = 0; if (minecartAchievementPos == nullptr) { minecartAchievementPos = - new Pos(Mth::floor(x), Mth::floor(y), Mth::floor(z)); + new Pos(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); } // 4J-PB - changed this because our world isn't big enough to go // 1000m @@ -1839,7 +1839,7 @@ void Player::checkRidingStatistiscs(double dx, double dy, double dz) { // 4-JEV, changed slightly to add extra parameters for event // on durango. int dist = minecartAchievementPos->dist( - Mth::floor(x), Mth::floor(y), Mth::floor(z)); + GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); if ((m_bAwardedOnARail == false) && (dist >= 500)) { awardStat(GenericStats::onARail(), GenericStats::param_onARail(dist)); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Arrow.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Arrow.cpp index d7efbb9c7..31f017d62 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Arrow.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Arrow.cpp @@ -69,8 +69,8 @@ Arrow::Arrow(Level* level, std::shared_ptr mob, double sd = sqrt(xd * xd + zd * zd); if (sd < 0.0000001) return; - float yRot = (float)(atan2(zd, xd) * 180 / M_PI) - 90; - float xRot = (float)-(atan2(yd, sd) * 180 / M_PI); + float yRot = (float)(atan2(zd, xd) * 180 / std::numbers::pi) - 90; + float xRot = (float)-(atan2(yd, sd) * 180 / std::numbers::pi); double xdn = xd / sd; double zdn = zd / sd; @@ -103,15 +103,15 @@ Arrow::Arrow(Level* level, std::shared_ptr mob, float power) moveTo(mob->x, mob->y + mob->getHeadHeight(), mob->z, mob->yRot, mob->xRot); - x -= Mth::cos(yRot / 180 * M_PI) * 0.16f; + x -= cosf(yRot / 180 * std::numbers::pi) * 0.16f; y -= 0.1f; - z -= Mth::sin(yRot / 180 * M_PI) * 0.16f; + z -= sinf(yRot / 180 * std::numbers::pi) * 0.16f; setPos(x, y, z); heightOffset = 0; - xd = -Mth::sin(yRot / 180 * M_PI) * Mth::cos(xRot / 180 * M_PI); - zd = Mth::cos(yRot / 180 * M_PI) * Mth::cos(xRot / 180 * M_PI); - yd = -Mth::sin(xRot / 180 * M_PI); + xd = -sinf(yRot / 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); shoot(xd, yd, zd, power * 1.5f, 1); } @@ -143,8 +143,8 @@ void Arrow::shoot(double xd, double yd, double zd, float pow, double sd = sqrt(xd * xd + zd * zd); - yRotO = yRot = (float)(atan2(xd, zd) * 180 / M_PI); - xRotO = xRot = (float)(atan2(yd, sd) * 180 / M_PI); + yRotO = yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); + xRotO = xRot = (float)(atan2(yd, sd) * 180 / std::numbers::pi); life = 0; } @@ -160,8 +160,8 @@ void Arrow::lerpMotion(double xd, double yd, double zd) { this->zd = zd; if (xRotO == 0 && yRotO == 0) { double sd = sqrt(xd * xd + zd * zd); - yRotO = yRot = (float)(atan2(xd, zd) * 180 / M_PI); - xRotO = xRot = (float)(atan2(yd, sd) * 180 / M_PI); + yRotO = yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); + xRotO = xRot = (float)(atan2(yd, sd) * 180 / std::numbers::pi); xRotO = xRot; yRotO = yRot; app.DebugPrintf("%f %f : 0x%x\n", xRot, yRot, &yRot); @@ -175,8 +175,8 @@ void Arrow::tick() { if (xRotO == 0 && yRotO == 0) { double sd = sqrt(xd * xd + zd * zd); - yRotO = yRot = (float)(atan2(xd, zd) * 180 / M_PI); - xRotO = xRot = (float)(atan2(yd, sd) * 180 / M_PI); + yRotO = yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); + xRotO = xRot = (float)(atan2(yd, sd) * 180 / std::numbers::pi); } { @@ -273,8 +273,8 @@ void Arrow::tick() { if (res != nullptr) { if (res->entity != nullptr) { - float pow = Mth::sqrt(xd * xd + yd * yd + zd * zd); - int dmg = (int)Mth::ceil((float)(pow * baseDamage)); + float pow = GameMath::sqrt(xd * xd + yd * yd + zd * zd); + int dmg = (int)GameMath::ceil((float)(pow * baseDamage)); if (isCritArrow()) dmg += random->nextInt(dmg / 2 + 2); @@ -401,8 +401,8 @@ void Arrow::tick() { z += zd; double sd = sqrt(xd * xd + zd * zd); - yRot = (float)(atan2(xd, zd) * 180 / M_PI); - xRot = (float)(atan2(yd, sd) * 180 / M_PI); + yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); + xRot = (float)(atan2(yd, sd) * 180 / std::numbers::pi); while (xRot - xRotO < -180) xRotO -= 360; while (xRot - xRotO >= 180) xRotO += 360; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/EyeOfEnderSignal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/EyeOfEnderSignal.cpp index 381b078be..ca48e20c8 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/EyeOfEnderSignal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/EyeOfEnderSignal.cpp @@ -68,8 +68,8 @@ void EyeOfEnderSignal::lerpMotion(double xd, double yd, double zd) { this->zd = zd; if (xRotO == 0 && yRotO == 0) { float sd = (float)sqrt(xd * xd + zd * zd); - yRotO = yRot = (float)(atan2(xd, zd) * 180 / M_PI); - xRotO = xRot = (float)(atan2(yd, (double)sd) * 180 / M_PI); + yRotO = yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); + xRotO = xRot = (float)(atan2(yd, (double)sd) * 180 / std::numbers::pi); } } @@ -84,8 +84,8 @@ void EyeOfEnderSignal::tick() { z += zd; float sd = (float)sqrt(xd * xd + zd * zd); - yRot = (float)(atan2(xd, zd) * 180 / M_PI); - xRot = (float)(atan2(yd, (double)sd) * 180 / M_PI); + yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); + xRot = (float)(atan2(yd, (double)sd) * 180 / std::numbers::pi); while (xRot - xRotO < -180) xRotO -= 360; while (xRot - xRotO >= 180) xRotO += 360; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Fireball.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Fireball.cpp index 90ec0240a..7654c010c 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Fireball.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Fireball.cpp @@ -215,8 +215,8 @@ void Fireball::tick() { z += zd; double sd = sqrt(xd * xd + zd * zd); - yRot = (float)(atan2(zd, xd) * 180 / M_PI) + 90; - xRot = (float)(atan2(sd, yd) * 180 / M_PI) - 90; + yRot = (float)(atan2(zd, xd) * 180 / std::numbers::pi) + 90; + xRot = (float)(atan2(sd, yd) * 180 / std::numbers::pi) - 90; while (xRot - xRotO < -180) xRotO -= 360; while (xRot - xRotO >= 180) xRotO += 360; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FireworksRocketEntity.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FireworksRocketEntity.cpp index 33d6b92d2..801b9cb0d 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FireworksRocketEntity.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FireworksRocketEntity.cpp @@ -56,9 +56,9 @@ void FireworksRocketEntity::lerpMotion(double xd, double yd, double zd) { yd = yd; zd = zd; if (xRotO == 0 && yRotO == 0) { - double sd = Mth::sqrt(xd * xd + zd * zd); - yRotO = yRot = (float)(atan2(xd, zd) * 180 / M_PI); - xRotO = xRot = (float)(atan2(yd, sd) * 180 / M_PI); + double sd = GameMath::sqrt(xd * xd + zd * zd); + yRotO = yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); + xRotO = xRot = (float)(atan2(yd, sd) * 180 / std::numbers::pi); } } @@ -73,9 +73,9 @@ void FireworksRocketEntity::tick() { yd += .04; move(xd, yd, zd); - double sd = Mth::sqrt(xd * xd + zd * zd); - yRot = (float)(atan2(xd, zd) * 180 / M_PI); - xRot = (float)(atan2(yd, sd) * 180 / M_PI); + double sd = GameMath::sqrt(xd * xd + zd * zd); + yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); + xRot = (float)(atan2(yd, sd) * 180 / std::numbers::pi); while (xRot - xRotO < -180) xRotO -= 360; while (xRot - xRotO >= 180) xRotO += 360; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FishingHook.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FishingHook.cpp index 2d500c14c..195076255 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FishingHook.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FishingHook.cpp @@ -71,16 +71,16 @@ FishingHook::FishingHook(Level* level, std::shared_ptr mob) moveTo(mob->x, mob->y + 1.62 - mob->heightOffset, mob->z, mob->yRot, mob->xRot); - x -= Mth::cos(yRot / 180 * M_PI) * 0.16f; + x -= cosf(yRot / 180 * std::numbers::pi) * 0.16f; y -= 0.1f; - z -= Mth::sin(yRot / 180 * M_PI) * 0.16f; + z -= sinf(yRot / 180 * std::numbers::pi) * 0.16f; setPos(x, y, z); heightOffset = 0; float speed = 0.4f; - xd = (-Mth::sin(yRot / 180 * M_PI) * Mth::cos(xRot / 180 * M_PI)) * speed; - zd = (Mth::cos(yRot / 180 * M_PI) * Mth::cos(xRot / 180 * M_PI)) * speed; - yd = (-Mth::sin(xRot / 180 * M_PI)) * speed; + xd = (-sinf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi)) * speed; + zd = (cosf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi)) * speed; + yd = (-sinf(xRot / 180 * std::numbers::pi)) * speed; shoot(xd, yd, zd, 1.5f, 1); } @@ -115,8 +115,8 @@ void FishingHook::shoot(double xd, double yd, double zd, float pow, double sd = sqrt(xd * xd + zd * zd); - yRotO = yRot = (float)(atan2(xd, zd) * 180 / M_PI); - xRotO = xRot = (float)(atan2(yd, sd) * 180 / M_PI); + yRotO = yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); + xRotO = xRot = (float)(atan2(yd, sd) * 180 / std::numbers::pi); life = 0; } @@ -149,7 +149,7 @@ void FishingHook::tick() { double yt = y + (ly - y) / lSteps; double zt = z + (lz - z) / lSteps; - double yrd = Mth::wrapDegrees(lyr - yRot); + double yrd = GameMath::wrapDegrees(lyr - yRot); yRot += (float)((yrd) / lSteps); xRot += (float)((lxr - xRot) / lSteps); @@ -263,8 +263,8 @@ void FishingHook::tick() { move(xd, yd, zd); double sd = sqrt(xd * xd + zd * zd); - yRot = (float)(atan2(xd, zd) * 180 / M_PI); - xRot = (float)(atan2(yd, sd) * 180 / M_PI); + yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); + xRot = (float)(atan2(yd, sd) * 180 / std::numbers::pi); while (xRot - xRotO < -180) xRotO -= 360; while (xRot - xRotO >= 180) xRotO += 360; @@ -299,8 +299,8 @@ void FishingHook::tick() { nibble--; } else { int nibbleOdds = 500; - if (level->isRainingAt(Mth::floor(x), Mth::floor(y) + 1, - Mth::floor(z))) + if (level->isRainingAt(GameMath::floor(x), GameMath::floor(y) + 1, + GameMath::floor(z))) nibbleOdds = 300; if (random->nextInt(nibbleOdds) == 0) { @@ -309,7 +309,7 @@ void FishingHook::tick() { playSound( eSoundType_RANDOM_SPLASH, 0.25f, 1 + (random->nextFloat() - random->nextFloat()) * 0.4f); - float yt = (float)Mth::floor(bb.y0); + float yt = (float)GameMath::floor(bb.y0); for (int i = 0; i < 1 + bbWidth * 20; i++) { float xo = (random->nextFloat() * 2 - 1) * bbWidth; float zo = (random->nextFloat() * 2 - 1) * bbWidth; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Throwable.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Throwable.cpp index 7f59dcdb4..628d8f2a1 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Throwable.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Throwable.cpp @@ -41,16 +41,16 @@ Throwable::Throwable(Level* level, std::shared_ptr mob) moveTo(mob->x, mob->y + mob->getHeadHeight(), mob->z, mob->yRot, mob->xRot); - x -= cos(yRot / 180 * M_PI) * 0.16f; + x -= cos(yRot / 180 * std::numbers::pi) * 0.16f; y -= 0.1f; - z -= sin(yRot / 180 * M_PI) * 0.16f; + z -= sin(yRot / 180 * std::numbers::pi) * 0.16f; setPos(x, y, z); heightOffset = 0; float speed = 0.4f; - xd = (-sin(yRot / 180 * M_PI) * cos(xRot / 180 * M_PI)) * speed; - zd = (cos(yRot / 180 * M_PI) * cos(xRot / 180 * M_PI)) * speed; - yd = (-sin((xRot + getThrowUpAngleOffset()) / 180 * M_PI)) * speed; + xd = (-sin(yRot / 180 * std::numbers::pi) * cos(xRot / 180 * std::numbers::pi)) * speed; + zd = (cos(yRot / 180 * std::numbers::pi) * cos(xRot / 180 * std::numbers::pi)) * speed; + yd = (-sin((xRot + getThrowUpAngleOffset()) / 180 * std::numbers::pi)) * speed; shoot(xd, yd, zd, getThrowPower(), 1); } @@ -92,8 +92,8 @@ void Throwable::shoot(double xd, double yd, double zd, float pow, float sd = (float)sqrt(xd * xd + zd * zd); - yRotO = yRot = (float)(atan2(xd, zd) * 180 / M_PI); - xRotO = xRot = (float)(atan2(yd, (double)sd) * 180 / M_PI); + yRotO = yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); + xRotO = xRot = (float)(atan2(yd, (double)sd) * 180 / std::numbers::pi); life = 0; } @@ -103,8 +103,8 @@ void Throwable::lerpMotion(double xd, double yd, double zd) { this->zd = zd; if (xRotO == 0 && yRotO == 0) { float sd = (float)sqrt(xd * xd + zd * zd); - yRotO = yRot = (float)(atan2(xd, zd) * 180 / M_PI); - xRotO = xRot = (float)(atan2(yd, (double)sd) * 180 / M_PI); + yRotO = yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); + xRotO = xRot = (float)(atan2(yd, (double)sd) * 180 / std::numbers::pi); } } @@ -189,8 +189,8 @@ void Throwable::tick() { z += zd; float sd = (float)sqrt(xd * xd + zd * zd); - yRot = (float)(atan2(xd, zd) * 180 / M_PI); - xRot = (float)(atan2(yd, (double)sd) * 180 / M_PI); + yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); + xRot = (float)(atan2(yd, (double)sd) * 180 / std::numbers::pi); while (xRot - xRotO < -180) xRotO -= 360; while (xRot - xRotO >= 180) xRotO += 360; diff --git a/minecraft/Minecraft.World/net/minecraft/world/inventory/AbstractContainerMenu.cpp b/minecraft/Minecraft.World/net/minecraft/world/inventory/AbstractContainerMenu.cpp index 44b620784..a9426a1cd 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/inventory/AbstractContainerMenu.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/inventory/AbstractContainerMenu.cpp @@ -647,7 +647,7 @@ void AbstractContainerMenu::getQuickCraftSlotCount( switch (quickCraftingType) { case QUICKCRAFT_TYPE_CHARITABLE: item->count = - Mth::floor(item->count / (float)quickCraftSlots->size()); + GameMath::floor(item->count / (float)quickCraftSlots->size()); break; case QUICKCRAFT_TYPE_GREEDY: item->count = 1; @@ -677,7 +677,7 @@ int AbstractContainerMenu::getRedstoneSignalFromContainer( } totalPct /= container->getContainerSize(); - return Mth::floor(totalPct * (Redstone::SIGNAL_MAX - 1)) + + return GameMath::floor(totalPct * (Redstone::SIGNAL_MAX - 1)) + (count > 0 ? 1 : 0); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/BedItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/BedItem.cpp index ed1e1f94c..8f0f66907 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/BedItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/BedItem.cpp @@ -25,7 +25,7 @@ bool BedItem::useOn(std::shared_ptr itemInstance, BedTile* tile = (BedTile*)Tile::bed; - int dir = (Mth::floor(player->yRot * 4 / (360) + 0.5f)) & 3; + int dir = (GameMath::floor(player->yRot * 4 / (360) + 0.5f)) & 3; int xra = 0; int zra = 0; diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/BoatItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/BoatItem.cpp index 1bb02698e..b4fffa8b3 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/BoatItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/BoatItem.cpp @@ -27,10 +27,10 @@ bool BoatItem::TestUse(std::shared_ptr itemInstance, Level* level, Vec3 from(x, y, z); - float yCos = Mth::cos(-yRot * Mth::RAD_TO_GRAD - M_PI); - float ySin = Mth::sin(-yRot * Mth::RAD_TO_GRAD - M_PI); - float xCos = -Mth::cos(-xRot * Mth::RAD_TO_GRAD); - float xSin = Mth::sin(-xRot * Mth::RAD_TO_GRAD); + float yCos = cosf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); + float ySin = sinf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); + float xCos = -cosf(-xRot * GameMath::DEG_TO_RAD); + float xSin = sinf(-xRot * GameMath::DEG_TO_RAD); float xa = ySin * xCos; float ya = xSin; @@ -64,10 +64,10 @@ std::shared_ptr BoatItem::use( Vec3 from(x, y, z); - float yCos = Mth::cos(-yRot * Mth::RAD_TO_GRAD - M_PI); - float ySin = Mth::sin(-yRot * Mth::RAD_TO_GRAD - M_PI); - float xCos = -Mth::cos(-xRot * Mth::RAD_TO_GRAD); - float xSin = Mth::sin(-xRot * Mth::RAD_TO_GRAD); + float yCos = cosf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); + float ySin = sinf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); + float xCos = -cosf(-xRot * GameMath::DEG_TO_RAD); + float xSin = sinf(-xRot * GameMath::DEG_TO_RAD); float xa = ySin * xCos; float ya = xSin; @@ -114,7 +114,7 @@ std::shared_ptr BoatItem::use( std::shared_ptr boat = std::shared_ptr( new Boat(level, xt + 0.5f, yt + 1.0f, zt + 0.5f)); boat->yRot = - ((Mth::floor(player->yRot * 4.0F / 360.0F + 0.5) & 0x3) - 1) * + ((GameMath::floor(player->yRot * 4.0F / 360.0F + 0.5) & 0x3) - 1) * 90; AABB grown = boat->bb.grow(-0.1, -0.1, -0.1); if (!level->getCubes(boat, &grown)->empty()) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/DoorItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/DoorItem.cpp index 5802e61f9..a52375730 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/DoorItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/DoorItem.cpp @@ -43,7 +43,7 @@ bool DoorItem::useOn(std::shared_ptr instance, GenericStats::blocksPlaced(tile->id), GenericStats::param_blocksPlaced(tile->id, instance->getAuxValue(), 1)); - int dir = Mth::floor(((player->yRot + 180) * 4) / 360 - 0.5) & 3; + int dir = GameMath::floor(((player->yRot + 180) * 4) / 360 - 0.5) & 3; place(level, x, y, z, dir, tile); instance->count--; diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/DyePowderItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/DyePowderItem.cpp index f485122b3..8e5fa1381 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/DyePowderItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/DyePowderItem.cpp @@ -65,13 +65,13 @@ const int DyePowderItem::ORANGE = 14; const int DyePowderItem::WHITE = 15; Icon* DyePowderItem::getIcon(int itemAuxValue) { - int colorValue = Mth::clamp(itemAuxValue, 0, 15); + int colorValue = GameMath::clamp(itemAuxValue, 0, 15); return icons[colorValue]; } unsigned int DyePowderItem::getDescriptionId( std::shared_ptr itemInstance) { - int colorValue = Mth::clamp(itemInstance->getAuxValue(), 0, 15); + int colorValue = GameMath::clamp(itemInstance->getAuxValue(), 0, 15); return COLOR_DESCS[colorValue]; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/EnchantedBookItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/EnchantedBookItem.cpp index f887a2fb4..7851022bc 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/EnchantedBookItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/EnchantedBookItem.cpp @@ -121,7 +121,7 @@ std::shared_ptr EnchantedBookItem::createForRandomLoot( Enchantment::validEnchantments.size())]; std::shared_ptr book = std::shared_ptr(new ItemInstance(id, 1, 0)); - int level = Mth::nextInt(random, enchantment->getMinLevel(), + int level = random->nextInt(enchantment->getMinLevel(), enchantment->getMaxLevel()); addEnchantment(book, new EnchantmentInstance(enchantment, level)); @@ -141,7 +141,7 @@ WeighedTreasure* EnchantedBookItem::createForRandomTreasure(Random* random, Enchantment::validEnchantments.size())]; std::shared_ptr book = std::shared_ptr(new ItemInstance(id, 1, 0)); - int level = Mth::nextInt(random, enchantment->getMinLevel(), + int level = random->nextInt(enchantment->getMinLevel(), enchantment->getMaxLevel()); addEnchantment(book, new EnchantmentInstance(enchantment, level)); diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/Item.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/Item.cpp index 4a39f4d70..2b54737c9 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/Item.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/Item.cpp @@ -1607,10 +1607,10 @@ HitResult* Item::getPlayerPOVHitResult(Level* level, Vec3 from(x, y, z); - float yCos = (float)cos(-yRot * Mth::RAD_TO_GRAD - M_PI); - float ySin = (float)sin(-yRot * Mth::RAD_TO_GRAD - M_PI); - float xCos = (float)-cos(-xRot * Mth::RAD_TO_GRAD); - float xSin = (float)sin(-xRot * Mth::RAD_TO_GRAD); + float yCos = (float)cos(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); + float ySin = (float)sin(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); + float xCos = (float)-cos(-xRot * GameMath::DEG_TO_RAD); + float xSin = (float)sin(-xRot * GameMath::DEG_TO_RAD); float xa = ySin * xCos; float ya = xSin; diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/MapItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/MapItem.cpp index 1b7190fa9..701ff776f 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/MapItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/MapItem.cpp @@ -108,8 +108,8 @@ void MapItem::update(Level* level, std::shared_ptr player, int xo = data->x; int zo = data->z; - int xp = Mth::floor(player->x - xo) / scale + w / 2; - int zp = Mth::floor(player->z - zo) / scale + h / 2; + int xp = GameMath::floor(player->x - xo) / scale + w / 2; + int zp = GameMath::floor(player->z - zo) / scale + h / 2; int rad = 128 / scale; if (level->dimension->hasCeiling) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/SignItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/SignItem.cpp index 0ec2e5de0..d28d0aceb 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/SignItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/SignItem.cpp @@ -36,7 +36,7 @@ bool SignItem::useOn(std::shared_ptr instance, if (!bTestUseOnOnly) { if (face == 1) { - int rot = Mth::floor(((player->yRot + 180) * 16) / 360 + 0.5) & 15; + int rot = GameMath::floor(((player->yRot + 180) * 16) / 360 + 0.5) & 15; level->setTileAndData(x, y, z, Tile::sign_Id, rot, Tile::UPDATE_ALL); } else { diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/SkullItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/SkullItem.cpp index 526ca07eb..5c9c87600 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/SkullItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/SkullItem.cpp @@ -47,7 +47,7 @@ bool SkullItem::useOn( int rot = 0; if (face == Facing::UP) { - rot = Mth::floor(((player->yRot) * 16) / 360 + 0.5) & 15; + rot = GameMath::floor(((player->yRot) * 16) / 360 + 0.5) & 15; } std::shared_ptr skullTE = level->getTileEntity(x, y, z); diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/SpawnEggItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/SpawnEggItem.cpp index aac3c6c25..c2778b6c8 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/SpawnEggItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/SpawnEggItem.cpp @@ -290,7 +290,7 @@ std::shared_ptr SpawnEggItem::spawnMobAt(Level* level, int auxVal, std::shared_ptr mob = std::dynamic_pointer_cast(newEntity); newEntity->moveTo( - x, y, z, Mth::wrapDegrees(level->random->nextFloat() * 360), 0); + x, y, z, GameMath::wrapDegrees(level->random->nextFloat() * 360), 0); newEntity->setDespawnProtected(); // 4J added, default to being // protected against despawning // (has to be done after initial diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/enchantment/ProtectionEnchantment.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/enchantment/ProtectionEnchantment.cpp index e3f0a58f6..46728c532 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/enchantment/ProtectionEnchantment.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/enchantment/ProtectionEnchantment.cpp @@ -35,14 +35,14 @@ int ProtectionEnchantment::getDamageProtection(int level, float protect = (6 + level * level) / 3.0f; - if (type == ALL) return Mth::floor(protect * 0.75f); - if (type == FIRE && source->isFire()) return Mth::floor(protect * 1.25f); + if (type == ALL) return GameMath::floor(protect * 0.75f); + if (type == FIRE && source->isFire()) return GameMath::floor(protect * 1.25f); if (type == FALL && source == DamageSource::fall) - return Mth::floor(protect * 2.5f); + return GameMath::floor(protect * 2.5f); if (type == EXPLOSION && source->isExplosion()) - return Mth::floor(protect * 1.5f); + return GameMath::floor(protect * 1.5f); if (type == PROJECTILE && source->isProjectile()) - return Mth::floor(protect * 1.5f); + return GameMath::floor(protect * 1.5f); return 0; } @@ -68,7 +68,7 @@ int ProtectionEnchantment::getFireAfterDampener(std::shared_ptr entity, Enchantment::fireProtection->id, entity->getEquipmentSlots()); if (level > 0) { - time -= Mth::floor(time * (level * 0.15f)); + time -= GameMath::floor(time * (level * 0.15f)); } return time; @@ -80,7 +80,7 @@ double ProtectionEnchantment::getExplosionKnockbackAfterDampener( Enchantment::explosionProtection->id, entity->getEquipmentSlots()); if (level > 0) { - power -= Mth::floor(power * (level * 0.15f)); + power -= GameMath::floor(power * (level * 0.15f)); } return power; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/Explosion.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/Explosion.cpp index 7af5a3dbc..7618264c3 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/Explosion.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/Explosion.cpp @@ -57,9 +57,9 @@ void Explosion::explode() { float stepSize = 0.3f; while (remainingPower > 0) { - int xt = Mth::floor(xp); - int yt = Mth::floor(yp); - int zt = Mth::floor(zp); + int xt = GameMath::floor(xp); + int yt = GameMath::floor(yp); + int zt = GameMath::floor(zp); int t = level->getTile(xt, yt, zt); if (t > 0) { Tile* tile = Tile::tiles[t]; @@ -88,12 +88,12 @@ void Explosion::explode() { } r *= 2.0f; - int x0 = Mth::floor(x - r - 1); - int x1 = Mth::floor(x + r + 1); - int y0 = Mth::floor(y - r - 1); - int y1 = Mth::floor(y + r + 1); - int z0 = Mth::floor(z - r - 1); - int z1 = Mth::floor(z + r + 1); + int x0 = GameMath::floor(x - r - 1); + int x1 = GameMath::floor(x + r + 1); + int y0 = GameMath::floor(y - r - 1); + int y1 = GameMath::floor(y + r + 1); + int z0 = GameMath::floor(z - r - 1); + int z1 = GameMath::floor(z + r + 1); // Fix for 360 #123866 - [CRASH] TU13: Code: Compliance: Placing the TNT // next to Ender Crystals will crash the title after a certain amount of diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp index 875ba4e21..fdfedfcaf 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp @@ -1372,13 +1372,13 @@ HitResult* Level::clip(Vec3* a, Vec3* b, bool liquid, bool solidOnly) { if (std::isnan(b->x) || std::isnan(b->y) || std::isnan(b->z)) return nullptr; - int xTile1 = Mth::floor(b->x); - int yTile1 = Mth::floor(b->y); - int zTile1 = Mth::floor(b->z); + int xTile1 = GameMath::floor(b->x); + int yTile1 = GameMath::floor(b->y); + int zTile1 = GameMath::floor(b->z); - int xTile0 = Mth::floor(a->x); - int yTile0 = Mth::floor(a->y); - int zTile0 = Mth::floor(a->z); + int xTile0 = GameMath::floor(a->x); + int yTile0 = GameMath::floor(a->y); + int zTile0 = GameMath::floor(a->z); { int t = getTile(xTile0, yTile0, zTile0); @@ -1586,8 +1586,8 @@ bool Level::addGlobalEntity(std::shared_ptr e) { #pragma optimize("", off) bool Level::addEntity(std::shared_ptr e) { - int xc = Mth::floor(e->x / 16); - int zc = Mth::floor(e->z / 16); + int xc = GameMath::floor(e->x / 16); + int zc = GameMath::floor(e->z / 16); if (e == nullptr) { return false; @@ -1730,12 +1730,12 @@ std::vector* Level::getCubes(std::shared_ptr source, AABB* box, bool noEntities /* = false*/, bool blockAtEdge /* = false*/) { boxes.clear(); - int x0 = Mth::floor(box->x0); - int x1 = Mth::floor(box->x1 + 1); - int y0 = Mth::floor(box->y0); - int y1 = Mth::floor(box->y1 + 1); - int z0 = Mth::floor(box->z0); - int z1 = Mth::floor(box->z1 + 1); + int x0 = GameMath::floor(box->x0); + int x1 = GameMath::floor(box->x1 + 1); + int y0 = GameMath::floor(box->y0); + int y1 = GameMath::floor(box->y1 + 1); + int z0 = GameMath::floor(box->z0); + int z1 = GameMath::floor(box->z1 + 1); int maxxz = (dimension->getXZSize() * 16) / 2; int minxz = -maxxz; @@ -1817,12 +1817,12 @@ std::vector* Level::getCubes(std::shared_ptr source, AABB* box, std::vector* Level::getTileCubes(AABB* box, bool blockAtEdge /* = false */) { return getCubes(nullptr, box, true, blockAtEdge); // boxes.clear(); - // int x0 = Mth::floor(box->x0); - // int x1 = Mth::floor(box->x1 + 1); - // int y0 = Mth::floor(box->y0); - // int y1 = Mth::floor(box->y1 + 1); - // int z0 = Mth::floor(box->z0); - // int z1 = Mth::floor(box->z1 + 1); + // int x0 = GameMath::floor(box->x0); + // int x1 = GameMath::floor(box->x1 + 1); + // int y0 = GameMath::floor(box->y0); + // int y1 = GameMath::floor(box->y1 + 1); + // int z0 = GameMath::floor(box->z0); + // int z1 = GameMath::floor(box->z1 + 1); // for (int x = x0; x < x1; x++) //{ @@ -1851,7 +1851,7 @@ std::vector* Level::getTileCubes(AABB* box, bool blockAtEdge /* = false */ int Level::getOldSkyDarken(float a) { float td = getTimeOfDay(a); - float br = 1 - (Mth::cos(td * M_PI * 2) * 2 + 0.5f); + float br = 1 - (cosf(td * std::numbers::pi * 2) * 2 + 0.5f); if (br < 0.0f) br = 0.0f; if (br > 1.0f) br = 1.0f; @@ -1867,7 +1867,7 @@ int Level::getOldSkyDarken(float a) { float Level::getSkyDarken(float a) { float td = getTimeOfDay(a); - float br = 1 - (Mth::cos(td * M_PI * 2) * 2 + 0.2f); + float br = 1 - (cosf(td * std::numbers::pi * 2) * 2 + 0.2f); if (br < 0.0f) br = 0.0f; if (br > 1.0f) br = 1.0f; @@ -1883,12 +1883,12 @@ float Level::getSkyDarken(float a) { Vec3 Level::getSkyColor(std::shared_ptr source, float a) { float td = getTimeOfDay(a); - float br = Mth::cos(td * M_PI * 2) * 2 + 0.5f; + float br = cosf(td * std::numbers::pi * 2) * 2 + 0.5f; if (br < 0.0f) br = 0.0f; if (br > 1.0f) br = 1.0f; - int xx = Mth::floor(source->x); - int zz = Mth::floor(source->z); + int xx = GameMath::floor(source->x); + int zz = GameMath::floor(source->z); Biome* biome = getBiome(xx, zz); float temp = biome->getTemperature(); int skyColor = biome->getSkyColor(temp); @@ -1956,13 +1956,13 @@ float Level::getMoonBrightness() { float Level::getSunAngle(float a) { float td = getTimeOfDay(a); - return td * M_PI * 2; + return td * std::numbers::pi * 2; } Vec3 Level::getCloudColor(float a) { float td = getTimeOfDay(a); - float br = Mth::cos(td * M_PI * 2) * 2.0f + 0.5f; + float br = cosf(td * std::numbers::pi * 2) * 2.0f + 0.5f; if (br < 0.0f) br = 0.0f; if (br > 1.0f) br = 1.0f; @@ -2048,7 +2048,7 @@ int Level::getLightDepth(int x, int z) { float Level::getStarBrightness(float a) { float td = getTimeOfDay(a); - float br = 1 - (Mth::cos(td * M_PI * 2) * 2 + 0.25f); + float br = 1 - (cosf(td * std::numbers::pi * 2) * 2 + 0.25f); if (br < 0.0f) br = 0.0f; if (br > 1.0f) br = 1.0f; @@ -2263,8 +2263,8 @@ void Level::addAllPendingTileEntities( void Level::tick(std::shared_ptr e) { tick(e, true); } void Level::tick(std::shared_ptr e, bool actual) { - int xc = Mth::floor(e->x); - int zc = Mth::floor(e->z); + int xc = GameMath::floor(e->x); + int zc = GameMath::floor(e->z); int r = 32; if (actual && !hasChunksAt(xc - r, 0, zc - r, xc + r, 0, zc + r)) { return; @@ -2293,9 +2293,9 @@ void Level::tick(std::shared_ptr e, bool actual) { if (!std::isfinite(e->xRot)) e->xRot = e->xRotO; if (!std::isfinite(e->yRot)) e->yRot = e->yRotO; - int xcn = Mth::floor(e->x / 16); - int ycn = Mth::floor(e->y / 16); - int zcn = Mth::floor(e->z / 16); + int xcn = GameMath::floor(e->x / 16); + int ycn = GameMath::floor(e->y / 16); + int zcn = GameMath::floor(e->z / 16); if (!e->inChunk || (e->xChunk != xcn || e->yChunk != ycn || e->zChunk != zcn)) { @@ -2339,12 +2339,12 @@ bool Level::isUnobstructed(AABB* aabb, std::shared_ptr ignore) { } bool Level::containsAnyBlocks(AABB* box) { - int x0 = Mth::floor(box->x0); - int x1 = Mth::floor(box->x1 + 1); - int y0 = Mth::floor(box->y0); - int y1 = Mth::floor(box->y1 + 1); - int z0 = Mth::floor(box->z0); - int z1 = Mth::floor(box->z1 + 1); + int x0 = GameMath::floor(box->x0); + int x1 = GameMath::floor(box->x1 + 1); + int y0 = GameMath::floor(box->y0); + int y1 = GameMath::floor(box->y1 + 1); + int z0 = GameMath::floor(box->z0); + int z1 = GameMath::floor(box->z1 + 1); if (box->x0 < 0) x0--; if (box->y0 < 0) y0--; @@ -2362,12 +2362,12 @@ bool Level::containsAnyBlocks(AABB* box) { } bool Level::containsAnyLiquid(AABB* box) { - int x0 = Mth::floor(box->x0); - int x1 = Mth::floor(box->x1 + 1); - int y0 = Mth::floor(box->y0); - int y1 = Mth::floor(box->y1 + 1); - int z0 = Mth::floor(box->z0); - int z1 = Mth::floor(box->z1 + 1); + int x0 = GameMath::floor(box->x0); + int x1 = GameMath::floor(box->x1 + 1); + int y0 = GameMath::floor(box->y0); + int y1 = GameMath::floor(box->y1 + 1); + int z0 = GameMath::floor(box->z0); + int z1 = GameMath::floor(box->z1 + 1); if (box->x0 < 0) x0--; if (box->y0 < 0) y0--; @@ -2390,12 +2390,12 @@ bool Level::containsAnyLiquid(AABB* box) { // aim is to not load or create any chunk we haven't already got, and be // cautious about placing the mob's. bool Level::containsAnyLiquid_NoLoad(AABB* box) { - int x0 = Mth::floor(box->x0); - int x1 = Mth::floor(box->x1 + 1); - int y0 = Mth::floor(box->y0); - int y1 = Mth::floor(box->y1 + 1); - int z0 = Mth::floor(box->z0); - int z1 = Mth::floor(box->z1 + 1); + int x0 = GameMath::floor(box->x0); + int x1 = GameMath::floor(box->x1 + 1); + int y0 = GameMath::floor(box->y0); + int y1 = GameMath::floor(box->y1 + 1); + int z0 = GameMath::floor(box->z0); + int z1 = GameMath::floor(box->z1 + 1); if (box->x0 < 0) x0--; if (box->y0 < 0) y0--; @@ -2415,12 +2415,12 @@ bool Level::containsAnyLiquid_NoLoad(AABB* box) { } bool Level::containsFireTile(AABB* box) { - int x0 = Mth::floor(box->x0); - int x1 = Mth::floor(box->x1 + 1); - int y0 = Mth::floor(box->y0); - int y1 = Mth::floor(box->y1 + 1); - int z0 = Mth::floor(box->z0); - int z1 = Mth::floor(box->z1 + 1); + int x0 = GameMath::floor(box->x0); + int x1 = GameMath::floor(box->x1 + 1); + int y0 = GameMath::floor(box->y0); + int y1 = GameMath::floor(box->y1 + 1); + int z0 = GameMath::floor(box->z0); + int z1 = GameMath::floor(box->z1 + 1); if (hasChunksAt(x0, y0, z0, x1, y1, z1)) { for (int x = x0; x < x1; x++) @@ -2438,14 +2438,14 @@ bool Level::containsFireTile(AABB* box) { bool Level::checkAndHandleWater(AABB* box, Material* material, std::shared_ptr e) { - int x0 = Mth::floor(box->x0); - int x1 = Mth::floor(box->x1 + 1); + int x0 = GameMath::floor(box->x0); + int x1 = GameMath::floor(box->x1 + 1); - int y0 = Mth::floor(box->y0); - int y1 = Mth::floor(box->y1 + 1); + int y0 = GameMath::floor(box->y0); + int y1 = GameMath::floor(box->y1 + 1); - int z0 = Mth::floor(box->z0); - int z1 = Mth::floor(box->z1 + 1); + int z0 = GameMath::floor(box->z0); + int z1 = GameMath::floor(box->z1 + 1); if (!hasChunksAt(x0, y0, z0, x1, y1, z1)) { return false; @@ -2479,12 +2479,12 @@ bool Level::checkAndHandleWater(AABB* box, Material* material, } bool Level::containsMaterial(AABB* box, Material* material) { - int x0 = Mth::floor(box->x0); - int x1 = Mth::floor(box->x1 + 1); - int y0 = Mth::floor(box->y0); - int y1 = Mth::floor(box->y1 + 1); - int z0 = Mth::floor(box->z0); - int z1 = Mth::floor(box->z1 + 1); + int x0 = GameMath::floor(box->x0); + int x1 = GameMath::floor(box->x1 + 1); + int y0 = GameMath::floor(box->y0); + int y1 = GameMath::floor(box->y1 + 1); + int z0 = GameMath::floor(box->z0); + int z1 = GameMath::floor(box->z1 + 1); for (int x = x0; x < x1; x++) { for (int y = y0; y < y1; y++) { @@ -2500,12 +2500,12 @@ bool Level::containsMaterial(AABB* box, Material* material) { } bool Level::containsLiquid(AABB* box, Material* material) { - int x0 = Mth::floor(box->x0); - int x1 = Mth::floor(box->x1 + 1); - int y0 = Mth::floor(box->y0); - int y1 = Mth::floor(box->y1 + 1); - int z0 = Mth::floor(box->z0); - int z1 = Mth::floor(box->z1 + 1); + int x0 = GameMath::floor(box->x0); + int x1 = GameMath::floor(box->x1 + 1); + int y0 = GameMath::floor(box->y0); + int y1 = GameMath::floor(box->y1 + 1); + int z0 = GameMath::floor(box->z0); + int z1 = GameMath::floor(box->z1 + 1); for (int x = x0; x < x1; x++) { for (int y = y0; y < y1; y++) { @@ -2928,8 +2928,8 @@ void Level::buildAndPrepareChunksToPoll() { int* zz = new int[playerCount]; for (int i = 0; i < playerCount; i++) { std::shared_ptr player = players[i]; - xx[i] = Mth::floor(player->x / 16); - zz[i] = Mth::floor(player->z / 16); + xx[i] = GameMath::floor(player->x / 16); + zz[i] = GameMath::floor(player->z / 16); chunksToPoll.insert(ChunkPos(xx[i], zz[i])); } @@ -3187,9 +3187,9 @@ void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, // cexp--; // 4J - removed, change // from 1.2.3 if (expected > 0) { - int xd = Mth::abs(x - xc); - int yd = Mth::abs(y - yc); - int zd = Mth::abs(z - zc); + int xd = GameMath::abs(x - xc); + int yd = GameMath::abs(y - yc); + int zd = GameMath::abs(z - zc); if (xd + yd + zd < 17) { bool edge = false; for (int face = 0; face < 6; face++) { @@ -3374,10 +3374,10 @@ std::vector >* Level::getEntities( std::shared_ptr except, AABB* bb, const EntitySelector* selector) { MemSect(40); es.clear(); - int xc0 = Mth::floor((bb->x0 - 2) / 16); - int xc1 = Mth::floor((bb->x1 + 2) / 16); - int zc0 = Mth::floor((bb->z0 - 2) / 16); - int zc1 = Mth::floor((bb->z1 + 2) / 16); + int xc0 = GameMath::floor((bb->x0 - 2) / 16); + int xc1 = GameMath::floor((bb->x1 + 2) / 16); + int zc0 = GameMath::floor((bb->z0 - 2) / 16); + int zc1 = GameMath::floor((bb->z1 + 2) / 16); for (int xc = xc0; xc <= xc1; xc++) for (int zc = zc0; zc <= zc1; zc++) { @@ -3397,10 +3397,10 @@ std::vector >* Level::getEntitiesOfClass( std::vector >* Level::getEntitiesOfClass( const std::type_info& baseClass, AABB* bb, const EntitySelector* selector) { - int xc0 = Mth::floor((bb->x0 - 2) / 16); - int xc1 = Mth::floor((bb->x1 + 2) / 16); - int zc0 = Mth::floor((bb->z0 - 2) / 16); - int zc1 = Mth::floor((bb->z1 + 2) / 16); + int xc0 = GameMath::floor((bb->x0 - 2) / 16); + int xc1 = GameMath::floor((bb->x1 + 2) / 16); + int zc0 = GameMath::floor((bb->z0 - 2) / 16); + int zc1 = GameMath::floor((bb->z1 + 2) / 16); std::vector >* es = new std::vector >(); @@ -3584,9 +3584,9 @@ int Level::getSeaLevel() { return seaLevel; } Path* Level::findPath(std::shared_ptr from, std::shared_ptr to, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat) { - int x = Mth::floor(from->x); - int y = Mth::floor(from->y + 1); - int z = Mth::floor(from->z); + int x = GameMath::floor(from->x); + int y = GameMath::floor(from->y + 1); + int z = GameMath::floor(from->z); int r = (int)(maxDist + 16); int x1 = x - r; @@ -3605,9 +3605,9 @@ Path* Level::findPath(std::shared_ptr from, std::shared_ptr to, Path* Level::findPath(std::shared_ptr from, int xBest, int yBest, int zBest, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat) { - int x = Mth::floor(from->x); - int y = Mth::floor(from->y); - int z = Mth::floor(from->z); + int x = GameMath::floor(from->x); + int y = GameMath::floor(from->y); + int z = GameMath::floor(from->z); int r = (int)(maxDist + 8); int x1 = x - r; @@ -3948,8 +3948,8 @@ void Level::setSpawnPos(Pos* spawnPos) { } void Level::ensureAdded(std::shared_ptr entity) { - int xc = Mth::floor(entity->x / 16); - int zc = Mth::floor(entity->z / 16); + int xc = GameMath::floor(entity->x / 16); + int zc = GameMath::floor(entity->z / 16); int r = 2; for (int x = xc - r; x <= xc + r; x++) { for (int z = zc - r; z <= zc + r; z++) { @@ -4129,7 +4129,7 @@ void Level::updateNeighbourForOutputSignal(int x, int y, int z, int source) { } float Level::getDifficulty(double x, double y, double z) { - return getDifficulty(Mth::floor(x), Mth::floor(y), Mth::floor(z)); + return getDifficulty(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); } /** @@ -4143,7 +4143,7 @@ float Level::getDifficulty(int x, int y, int z) { if (hasChunkAt(x, y, z)) { float moonBrightness = getMoonBrightness(); - result += Mth::clamp(getChunkAt(x, z)->inhabitedTime / + result += GameMath::clamp(getChunkAt(x, z)->inhabitedTime / (TICKS_PER_DAY * 150.0f), 0.0f, 1.0f) * (isHard ? 1.0f : 0.75f); @@ -4154,7 +4154,7 @@ float Level::getDifficulty(int x, int y, int z) { result *= difficulty / 2.0f; } - return Mth::clamp(result, 0.0f, isHard ? 1.5f : 1.0f); + return GameMath::clamp(result, 0.0f, isHard ? 1.5f : 1.0f); ; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/MobSpawner.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/MobSpawner.cpp index ff92a1281..90eb49782 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/MobSpawner.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/MobSpawner.cpp @@ -57,8 +57,8 @@ const int MobSpawner::tick(ServerLevel* level, bool spawnEnemies, int* zz = new int[playerCount]; for (int i = 0; i < playerCount; i++) { std::shared_ptr player = level->players[i]; - xx[i] = Mth::floor(player->x / 16); - zz[i] = Mth::floor(player->z / 16); + xx[i] = GameMath::floor(player->x / 16); + zz[i] = GameMath::floor(player->z / 16); chunksToPoll.insert( std::pair(ChunkPos(xx[i], zz[i]), false)); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/PortalForcer.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/PortalForcer.cpp index cf0b79721..335bfd116 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/PortalForcer.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/PortalForcer.cpp @@ -26,9 +26,9 @@ void PortalForcer::force(std::shared_ptr e, double xOriginal, double yOriginal, double zOriginal, float yRotOriginal) { if (level->dimension->id == 1) { - int x = Mth::floor(e->x); - int y = Mth::floor(e->y) - 1; - int z = Mth::floor(e->z); + int x = GameMath::floor(e->x); + int y = GameMath::floor(e->y) - 1; + int z = GameMath::floor(e->z); int xa = 1; int za = 0; @@ -77,8 +77,8 @@ bool PortalForcer::findPortal(std::shared_ptr e, double xOriginal, int yTarget = 0; int zTarget = 0; - int xc = Mth::floor(e->x); - int zc = Mth::floor(e->z); + int xc = GameMath::floor(e->x); + int zc = GameMath::floor(e->z); long hash = ChunkPos::hashCode(xc, zc); bool updateCache = true; @@ -238,9 +238,9 @@ bool PortalForcer::createPortal(std::shared_ptr e) { int r = 16 * 3; double closest = -1; - int xc = Mth::floor(e->x); - int yc = Mth::floor(e->y); - int zc = Mth::floor(e->z); + int xc = GameMath::floor(e->x); + int yc = GameMath::floor(e->y); + int zc = GameMath::floor(e->z); // 4J Stu - Changes to stop Portals being created at the border of the // nether inside the bedrock diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/TilePos.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/TilePos.cpp index 4fd621617..ddefe8e9d 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/TilePos.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/TilePos.cpp @@ -11,9 +11,9 @@ TilePos::TilePos(int x, int y, int z) { // 4J - brought forward from 1.2.3 TilePos::TilePos(Vec3* p) { - this->x = Mth::floor(p->x); - this->y = Mth::floor(p->y); - this->z = Mth::floor(p->z); + this->x = GameMath::floor(p->x); + this->y = GameMath::floor(p->y); + this->z = GameMath::floor(p->z); } int TilePos::hash_fnct(const TilePos& k) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/biome/Biome.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/biome/Biome.cpp index cbd7c8a9e..5694277de 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/biome/Biome.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/biome/Biome.cpp @@ -471,16 +471,16 @@ void Biome::decorate(Level* level, Random* random, int xo, int zo) { } int Biome::getGrassColor() { - // double temp = Mth::clamp(getTemperature(), 0.0f, 1.0f); - // double rain = Mth::clamp(getDownfall(), 0.0f, 1.0f); + // double temp = GameMath::clamp(getTemperature(), 0.0f, 1.0f); + // double rain = GameMath::clamp(getDownfall(), 0.0f, 1.0f); // return GrassColor::get(temp, rain); return Minecraft::GetInstance()->getColourTable()->getColor(m_grassColor); } int Biome::getFolageColor() { - // double temp = Mth::clamp(getTemperature(), 0.0f, 1.0f); - // double rain = Mth::clamp(getDownfall(), 0.0f, 1.0f); + // double temp = GameMath::clamp(getTemperature(), 0.0f, 1.0f); + // double rain = GameMath::clamp(getDownfall(), 0.0f, 1.0f); // return FoliageColor::get(temp, rain); return Minecraft::GetInstance()->getColourTable()->getColor(m_foliageColor); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/biome/TheEndBiomeDecorator.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/biome/TheEndBiomeDecorator.cpp index acb5cc4d1..f33f99c98 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/biome/TheEndBiomeDecorator.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/biome/TheEndBiomeDecorator.cpp @@ -8,8 +8,8 @@ // Spike centre positions, calculated using // for(int i=0;i<8;i++) // { -// int x=40 * Mth::cos(2*(-M_PI +(PI/8)*i)); -// int z=40* Mth::sin(2*(-M_PI +(PI/8)*i)); +// int x=40 * cosf(2*(-std::numbers::pi +(PI/8)*i)); +// int z=40* sinf(2*(-std::numbers::pi +(PI/8)*i)); // } TheEndBiomeDecorator::SPIKE TheEndBiomeDecorator::SpikeValA[8] = { diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/chunk/LevelChunk.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/chunk/LevelChunk.cpp index 324c19a66..0f4bed1d4 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/chunk/LevelChunk.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/chunk/LevelChunk.cpp @@ -1138,14 +1138,14 @@ int LevelChunk::getRawBrightness(int x, int y, int z, int skyDampen) { void LevelChunk::addEntity(std::shared_ptr e) { lastSaveHadEntities = true; - int xc = Mth::floor(e->x / 16); - int zc = Mth::floor(e->z / 16); + int xc = GameMath::floor(e->x / 16); + int zc = GameMath::floor(e->z / 16); if (xc != this->x || zc != this->z) { app.DebugPrintf("Wrong location!"); // System.out.println("Wrong location! " + e); // Thread.dumpStack(); } - int yc = Mth::floor(e->y / 16); + int yc = GameMath::floor(e->y / 16); if (yc < 0) yc = 0; if (yc >= ENTITY_BLOCKS_LENGTH) yc = ENTITY_BLOCKS_LENGTH - 1; e->inChunk = true; @@ -1506,8 +1506,8 @@ void LevelChunk::markUnsaved() { this->setUnsaved(true); } void LevelChunk::getEntities(std::shared_ptr except, AABB* bb, std::vector >& es, const EntitySelector* selector) { - int yc0 = Mth::floor((bb->y0 - 2) / 16); - int yc1 = Mth::floor((bb->y1 + 2) / 16); + int yc0 = GameMath::floor((bb->y0 - 2) / 16); + int yc1 = GameMath::floor((bb->y1 + 2) / 16); if (yc0 < 0) yc0 = 0; if (yc1 >= ENTITY_BLOCKS_LENGTH) yc1 = ENTITY_BLOCKS_LENGTH - 1; @@ -1544,8 +1544,8 @@ void LevelChunk::getEntities(std::shared_ptr except, AABB* bb, void LevelChunk::getEntitiesOfClass(const std::type_info& ec, AABB* bb, std::vector >& es, const EntitySelector* selector) { - int yc0 = Mth::floor((bb->y0 - 2) / 16); - int yc1 = Mth::floor((bb->y1 + 2) / 16); + int yc0 = GameMath::floor((bb->y0 - 2) / 16); + int yc1 = GameMath::floor((bb->y1 + 2) / 16); if (yc0 < 0) { yc0 = 0; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/dimension/Dimension.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/dimension/Dimension.cpp index e814e48f5..93eb1ee40 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/dimension/Dimension.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/dimension/Dimension.cpp @@ -115,7 +115,7 @@ float Dimension::getTimeOfDay(int64_t time, float a) const { if (td < 0) td += 1; if (td > 1) td -= 1; float tdo = td; - td = 1 - (float)((cos(td * M_PI) + 1) / 2); + td = 1 - (float)((cos(td * std::numbers::pi) + 1) / 2); td = tdo + (td - tdo) / 3.0f; return td; } @@ -138,11 +138,11 @@ float* Dimension::getSunriseColor(float td, float a) { g2 = ((clr2 >> 8) & 0xFF) / 255.0, b2 = (clr2 & 0xFF) / 255.0; float span = 0.4f; - float tt = Mth::cos(td * M_PI * 2) - 0.0f; + float tt = cosf(td * std::numbers::pi * 2) - 0.0f; float mid = -0.0f; if (tt >= mid - span && tt <= mid + span) { float aa = ((tt - mid) / span) * 0.5f + 0.5f; - float mix = 1 - (((1 - sin(aa * M_PI))) * 0.99f); + float mix = 1 - (((1 - sin(aa * std::numbers::pi))) * 0.99f); mix = mix * mix; // sunriseCol[0] = (aa * 0.3f + 0.7f); // sunriseCol[1] = (aa * aa * 0.7f + 0.2f); @@ -158,7 +158,7 @@ float* Dimension::getSunriseColor(float td, float a) { } Vec3 Dimension::getFogColor(float td, float a) const { - float br = Mth::cos(td * M_PI * 2) * 2 + 0.5f; + float br = cosf(td * std::numbers::pi * 2) * 2 + 0.5f; if (br < 0.0f) br = 0.0f; if (br > 1.0f) br = 1.0f; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/dimension/TheEndDimension.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/dimension/TheEndDimension.cpp index 295675fb8..16d5349b2 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/dimension/TheEndDimension.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/dimension/TheEndDimension.cpp @@ -26,7 +26,7 @@ float* TheEndDimension::getSunriseColor(float td, float a) { return nullptr; } Vec3 TheEndDimension::getFogColor(float td, float a) const { int fogColor = Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_End_Fog_Colour); // 0xa080a0; - float br = Mth::cos(td * M_PI * 2) * 2 + 0.5f; + float br = cosf(td * std::numbers::pi * 2) * 2 + 0.5f; if (br < 0.0f) br = 0.0f; if (br > 1.0f) br = 1.0f; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/CanyonFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/CanyonFeature.cpp index 5923adec5..eadd3b81f 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/CanyonFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/CanyonFeature.cpp @@ -39,17 +39,17 @@ void CanyonFeature::addTunnel(int64_t seed, int xOffs, int zOffs, } for (; step < dist; step++) { - double rad = 1.5 + (Mth::sin(step * M_PI / dist) * thickness) * 1; + double rad = 1.5 + (GameMath::sin(step * std::numbers::pi / dist) * thickness) * 1; double yRad = rad * yScale; rad *= (random->nextFloat() * 0.25 + 0.75); yRad *= (random->nextFloat() * 0.25 + 0.75); - float xc = Mth::cos(xRot); - float xs = Mth::sin(xRot); - xCave += Mth::cos(yRot) * xc; + float xc = GameMath::cos(xRot); + float xs = GameMath::sin(xRot); + xCave += GameMath::cos(yRot) * xc; yCave += xs; - zCave += Mth::sin(yRot) * xc; + zCave += GameMath::sin(yRot) * xc; xRot *= 0.7f; @@ -80,14 +80,14 @@ void CanyonFeature::addTunnel(int64_t seed, int xOffs, int zOffs, xCave > xMid + 16 + rad * 2 || zCave > zMid + 16 + rad * 2) continue; - int x0 = Mth::floor(xCave - rad) - xOffs * 16 - 1; - int x1 = Mth::floor(xCave + rad) - xOffs * 16 + 1; + int x0 = GameMath::floor(xCave - rad) - xOffs * 16 - 1; + int x1 = GameMath::floor(xCave + rad) - xOffs * 16 + 1; - int y0 = Mth::floor(yCave - yRad) - 1; - int y1 = Mth::floor(yCave + yRad) + 1; + int y0 = GameMath::floor(yCave - yRad) - 1; + int y1 = GameMath::floor(yCave + yRad) + 1; - int z0 = Mth::floor(zCave - rad) - zOffs * 16 - 1; - int z1 = Mth::floor(zCave + rad) - zOffs * 16 + 1; + int z0 = GameMath::floor(zCave - rad) - zOffs * 16 - 1; + int z1 = GameMath::floor(zCave + rad) - zOffs * 16 + 1; if (x0 < 0) x0 = 0; if (x1 > 16) x1 = 16; @@ -167,7 +167,7 @@ void CanyonFeature::addFeature(Level* level, int x, int z, int xOffs, int zOffs, int tunnels = 1; for (int i = 0; i < tunnels; i++) { - float yRot = random->nextFloat() * M_PI * 2; + float yRot = random->nextFloat() * std::numbers::pi * 2; float xRot = ((random->nextFloat() - 0.5f) * 2) / 8; float thickness = (random->nextFloat() * 2 + random->nextFloat()) * 2; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/DungeonFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/DungeonFeature.cpp index 8a32f1387..494d64f21 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/DungeonFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/DungeonFeature.cpp @@ -35,14 +35,14 @@ void DungeonFeature::addTunnel(int xOffs, int zOffs, std::vector& block bool steep = random->nextInt(6) == 0; for (; step < dist; step++) { - double rad = 1.5 + (Mth::sin(step * M_PI / dist) * thickness) * 1; + double rad = 1.5 + (GameMath::sin(step * std::numbers::pi / dist) * thickness) * 1; double yRad = rad * yScale; - float xc = Mth::cos(xRot); - float xs = Mth::sin(xRot); - xCave += Mth::cos(yRot) * xc; + float xc = GameMath::cos(xRot); + float xs = GameMath::sin(xRot); + xCave += GameMath::cos(yRot) * xc; yCave += xs; - zCave += Mth::sin(yRot) * xc; + zCave += GameMath::sin(yRot) * xc; if (steep) { xRot *= 0.92f; @@ -61,10 +61,10 @@ void DungeonFeature::addTunnel(int xOffs, int zOffs, std::vector& block if (!singleStep && step == splitPoint && thickness > 1) { addTunnel(xOffs, zOffs, blocks, xCave, yCave, zCave, - random->nextFloat() * 0.5f + 0.5f, yRot - M_PI / 2, + random->nextFloat() * 0.5f + 0.5f, yRot - std::numbers::pi / 2, xRot / 3, step, dist, 1.0); addTunnel(xOffs, zOffs, blocks, xCave, yCave, zCave, - random->nextFloat() * 0.5f + 0.5f, yRot + M_PI / 2, + random->nextFloat() * 0.5f + 0.5f, yRot + std::numbers::pi / 2, xRot / 3, step, dist, 1.0); return; } @@ -84,14 +84,14 @@ void DungeonFeature::addTunnel(int xOffs, int zOffs, std::vector& block xCave > xMid + 16 + rad * 2 || zCave > zMid + 16 + rad * 2) continue; - int x0 = Mth::floor(xCave - rad) - xOffs * 16 - 1; - int x1 = Mth::floor(xCave + rad) - xOffs * 16 + 1; + int x0 = GameMath::floor(xCave - rad) - xOffs * 16 - 1; + int x1 = GameMath::floor(xCave + rad) - xOffs * 16 + 1; - int y0 = Mth::floor(yCave - yRad) - 1; - int y1 = Mth::floor(yCave + yRad) + 1; + int y0 = GameMath::floor(yCave - yRad) - 1; + int y1 = GameMath::floor(yCave + yRad) + 1; - int z0 = Mth::floor(zCave - rad) - zOffs * 16 - 1; - int z1 = Mth::floor(zCave + rad) - zOffs * 16 + 1; + int z0 = GameMath::floor(zCave - rad) - zOffs * 16 - 1; + int z1 = GameMath::floor(zCave + rad) - zOffs * 16 + 1; if (x0 < 0) x0 = 0; if (x1 > 16) x1 = 16; @@ -169,7 +169,7 @@ void DungeonFeature::addFeature(Level* level, int x, int z, int xOffs, } for (int i = 0; i < tunnels; i++) { - float yRot = random->nextFloat() * M_PI * 2; + float yRot = random->nextFloat() * std::numbers::pi * 2; float xRot = ((random->nextFloat() - 0.5f) * 2) / 8; float thickness = random->nextFloat() * 2 + random->nextFloat(); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/HellRandomLevelSource.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/HellRandomLevelSource.cpp index b7d24852f..e903d77b3 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/HellRandomLevelSource.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/HellRandomLevelSource.cpp @@ -347,7 +347,7 @@ std::vector HellRandomLevelSource::getHeights(std::vector& buffe int pp = 0; std::vector yoffs = std::vector(ySize); for (int yy = 0; yy < ySize; yy++) { - yoffs[yy] = cos(yy * M_PI * 6 / (double)ySize) * 2; + yoffs[yy] = cos(yy * std::numbers::pi * 6 / (double)ySize) * 2; double dd = yy; if (yy > ySize / 2) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeCaveFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeCaveFeature.cpp index 753d6b4bd..e0339a729 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeCaveFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeCaveFeature.cpp @@ -38,14 +38,14 @@ void LargeCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, bool steep = random.nextInt(6) == 0; for (; step < dist; step++) { - double rad = 1.5 + (Mth::sin(step * M_PI / dist) * thickness) * 1; + double rad = 1.5 + (GameMath::sin(step * std::numbers::pi / dist) * thickness) * 1; double yRad = rad * yScale; - float xc = Mth::cos(xRot); - float xs = Mth::sin(xRot); - xCave += Mth::cos(yRot) * xc; + float xc = GameMath::cos(xRot); + float xs = GameMath::sin(xRot); + xCave += GameMath::cos(yRot) * xc; yCave += xs; - zCave += Mth::sin(yRot) * xc; + zCave += GameMath::sin(yRot) * xc; if (steep) { xRot *= 0.92f; @@ -64,10 +64,10 @@ void LargeCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, if (!singleStep && step == splitPoint && thickness > 1 && dist > 0) { addTunnel(random.nextLong(), xOffs, zOffs, blocks, xCave, yCave, - zCave, random.nextFloat() * 0.5f + 0.5f, yRot - M_PI / 2, + zCave, random.nextFloat() * 0.5f + 0.5f, yRot - std::numbers::pi / 2, xRot / 3, step, dist, 1.0); addTunnel(random.nextLong(), xOffs, zOffs, blocks, xCave, yCave, - zCave, random.nextFloat() * 0.5f + 0.5f, yRot + M_PI / 2, + zCave, random.nextFloat() * 0.5f + 0.5f, yRot + std::numbers::pi / 2, xRot / 3, step, dist, 1.0); return; } @@ -86,14 +86,14 @@ void LargeCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, xCave > xMid + 16 + rad * 2 || zCave > zMid + 16 + rad * 2) continue; - int x0 = Mth::floor(xCave - rad) - xOffs * 16 - 1; - int x1 = Mth::floor(xCave + rad) - xOffs * 16 + 1; + int x0 = GameMath::floor(xCave - rad) - xOffs * 16 - 1; + int x1 = GameMath::floor(xCave + rad) - xOffs * 16 + 1; - int y0 = Mth::floor(yCave - yRad) - 1; - int y1 = Mth::floor(yCave + yRad) + 1; + int y0 = GameMath::floor(yCave - yRad) - 1; + int y1 = GameMath::floor(yCave + yRad) + 1; - int z0 = Mth::floor(zCave - rad) - zOffs * 16 - 1; - int z1 = Mth::floor(zCave + rad) - zOffs * 16 + 1; + int z0 = GameMath::floor(zCave - rad) - zOffs * 16 - 1; + int z1 = GameMath::floor(zCave + rad) - zOffs * 16 + 1; if (x0 < 0) x0 = 0; if (x1 > 16) x1 = 16; @@ -180,7 +180,7 @@ void LargeCaveFeature::addFeature(Level* level, int x, int z, int xOffs, } for (int i = 0; i < tunnels; i++) { - float yRot = random->nextFloat() * M_PI * 2; + float yRot = random->nextFloat() * std::numbers::pi * 2; float xRot = ((random->nextFloat() - 0.5f) * 2) / 8; float thickness = random->nextFloat() * 2 + random->nextFloat(); if (random->nextInt(10) == 0) diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeHellCaveFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeHellCaveFeature.cpp index eebb98c77..6f464bd7e 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeHellCaveFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeHellCaveFeature.cpp @@ -37,14 +37,14 @@ void LargeHellCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, bool steep = random.nextInt(6) == 0; for (; step < dist; step++) { - double rad = 1.5 + (Mth::sin(step * M_PI / dist) * thickness) * 1; + double rad = 1.5 + (GameMath::sin(step * std::numbers::pi / dist) * thickness) * 1; double yRad = rad * yScale; - float xc = Mth::cos(xRot); - float xs = Mth::sin(xRot); - xCave += Mth::cos(yRot) * xc; + float xc = GameMath::cos(xRot); + float xs = GameMath::sin(xRot); + xCave += GameMath::cos(yRot) * xc; yCave += xs; - zCave += Mth::sin(yRot) * xc; + zCave += GameMath::sin(yRot) * xc; if (steep) { xRot *= 0.92f; @@ -63,10 +63,10 @@ void LargeHellCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, if (!singleStep && step == splitPoint && thickness > 1) { addTunnel(random.nextLong(), xOffs, zOffs, blocks, xCave, yCave, - zCave, random.nextFloat() * 0.5f + 0.5f, yRot - M_PI / 2, + zCave, random.nextFloat() * 0.5f + 0.5f, yRot - std::numbers::pi / 2, xRot / 3, step, dist, 1.0); addTunnel(random.nextLong(), xOffs, zOffs, blocks, xCave, yCave, - zCave, random.nextFloat() * 0.5f + 0.5f, yRot + M_PI / 2, + zCave, random.nextFloat() * 0.5f + 0.5f, yRot + std::numbers::pi / 2, xRot / 3, step, dist, 1.0); return; } @@ -86,14 +86,14 @@ void LargeHellCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, xCave > xMid + 16 + rad * 2 || zCave > zMid + 16 + rad * 2) continue; - int x0 = Mth::floor(xCave - rad) - xOffs * 16 - 1; - int x1 = Mth::floor(xCave + rad) - xOffs * 16 + 1; + int x0 = GameMath::floor(xCave - rad) - xOffs * 16 - 1; + int x1 = GameMath::floor(xCave + rad) - xOffs * 16 + 1; - int y0 = Mth::floor(yCave - yRad) - 1; - int y1 = Mth::floor(yCave + yRad) + 1; + int y0 = GameMath::floor(yCave - yRad) - 1; + int y1 = GameMath::floor(yCave + yRad) + 1; - int z0 = Mth::floor(zCave - rad) - zOffs * 16 - 1; - int z1 = Mth::floor(zCave + rad) - zOffs * 16 + 1; + int z0 = GameMath::floor(zCave - rad) - zOffs * 16 - 1; + int z1 = GameMath::floor(zCave + rad) - zOffs * 16 + 1; if (x0 < 0) x0 = 0; if (x1 > 16) x1 = 16; @@ -163,7 +163,7 @@ void LargeHellCaveFeature::addFeature(Level* level, int x, int z, int xOffs, } for (int i = 0; i < tunnels; i++) { - float yRot = random->nextFloat() * M_PI * 2; + float yRot = random->nextFloat() * std::numbers::pi * 2; float xRot = ((random->nextFloat() - 0.5f) * 2) / 8; float thickness = random->nextFloat() * 2 + random->nextFloat(); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/RandomLevelSource.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/RandomLevelSource.cpp index 60d0cd8ff..945d67b66 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/RandomLevelSource.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/RandomLevelSource.cpp @@ -531,7 +531,7 @@ std::vector RandomLevelSource::getHeights(std::vector& buffer, i pows = std::vector(5 * 5); for (int xb = -2; xb <= 2; xb++) { for (int zb = -2; zb <= 2; zb++) { - float ppp = 10.0f / Mth::sqrt(xb * xb + zb * zb + 0.2f); + float ppp = 10.0f / GameMath::sqrt(xb * xb + zb * zb + 0.2f); pows[xb + 2 + (zb + 2) * 5] = ppp; } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp index 59e988dbb..13a50813a 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp @@ -77,8 +77,8 @@ void BasicTree::prepare() { double radius = widthScale * (shapefac * (rnd->nextFloat() + 0.328)); double angle = rnd->nextFloat() * 2.0 * 3.14159; - int x = Mth::floor(radius * sin(angle) + origin[0] + originOffset); - int z = Mth::floor(radius * cos(angle) + origin[2] + originOffset); + int x = GameMath::floor(radius * sin(angle) + origin[0] + originOffset); + int z = GameMath::floor(radius * cos(angle) + origin[2] + originOffset); int checkStart[] = {x, y, z}; int checkEnd[] = {x, y + foliageHeight, z}; // check the center column of the cluster for obstructions. @@ -272,11 +272,11 @@ void BasicTree::limb(int* start, int* end, int material) { int primoffset = 0; int endoffset = delta[primidx] + primsign; while (primoffset != endoffset) { - coordinate[primidx] = Mth::floor(start[primidx] + primoffset + 0.5); + coordinate[primidx] = GameMath::floor(start[primidx] + primoffset + 0.5); coordinate[secidx1] = - Mth::floor(start[secidx1] + (primoffset * secfac1) + 0.5); + GameMath::floor(start[secidx1] + (primoffset * secfac1) + 0.5); coordinate[secidx2] = - Mth::floor(start[secidx2] + (primoffset * secfac2) + 0.5); + GameMath::floor(start[secidx2] + (primoffset * secfac2) + 0.5); int dir = TreeTile::FACING_Y; int xdiff = abs(coordinate[0] - start[0]); @@ -408,9 +408,9 @@ int BasicTree::checkLine(int* start, int* end) { while (primoffset != endoffset) { coordinate[primidx] = start[primidx] + primoffset; coordinate[secidx1] = - Mth::floor(start[secidx1] + (primoffset * secfac1)); + GameMath::floor(start[secidx1] + (primoffset * secfac1)); coordinate[secidx2] = - Mth::floor(start[secidx2] + (primoffset * secfac2)); + GameMath::floor(start[secidx2] + (primoffset * secfac2)); thismat = thisLevel->getTile(coordinate[0], coordinate[1], coordinate[2]); if (!((thismat == 0) || (thismat == Tile::leaves_Id))) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/CaveFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/CaveFeature.cpp index 0b4b9cf1a..a8d428cce 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/CaveFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/CaveFeature.cpp @@ -4,13 +4,13 @@ #include "../../tile/net.minecraft.world.level.tile.h" bool CaveFeature::place(Level* level, Random* random, int x, int y, int z) { - float dir = random->nextFloat() * M_PI; + float dir = random->nextFloat() * std::numbers::pi; double rd = 8; - double x0 = x + 8 + Mth::sin(dir) * rd; - double x1 = x + 8 - Mth::sin(dir) * rd; - double z0 = z + 8 + Mth::cos(dir) * rd; - double z1 = z + 8 - Mth::cos(dir) * rd; + double x0 = x + 8 + GameMath::sin(dir) * rd; + double x1 = x + 8 - GameMath::sin(dir) * rd; + double z0 = z + 8 + GameMath::cos(dir) * rd; + double z1 = z + 8 - GameMath::cos(dir) * rd; double y0 = y + random->nextInt(8) + 2; double y1 = y + random->nextInt(8) + 2; @@ -28,8 +28,8 @@ bool CaveFeature::place(Level* level, Random* random, int x, int y, int z) { double zz = z0 + (z1 - z0) * d / 16; double ss = random->nextDouble(); - double r = (Mth::sin(d / 16.0f * M_PI) * radius + 1) * ss + 1; - double hr = (Mth::sin(d / 16.0f * M_PI) * radius + 1) * ss + 1; + double r = (GameMath::sin(d / 16.0f * std::numbers::pi) * radius + 1) * ss + 1; + double hr = (GameMath::sin(d / 16.0f * std::numbers::pi) * radius + 1) * ss + 1; // 4J Stu Added to stop cave features generating areas previously place // by game rule generation diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/MegaTreeFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/MegaTreeFeature.cpp index 8a7a7d495..76b49c7e9 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/MegaTreeFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/MegaTreeFeature.cpp @@ -74,14 +74,14 @@ bool MegaTreeFeature::place(Level* level, Random* random, int x, int y, int z) { PIXBeginNamedEvent(0, "MegaTree placing branches"); int branchHeight = y + treeHeight - 2 - random->nextInt(4); while (branchHeight > y + treeHeight / 2) { - float angle = random->nextFloat() * M_PI * 2.0f; - int bx = x + (int)(0.5f + Mth::cos(angle) * 4.0f); - int bz = z + (int)(0.5f + Mth::sin(angle) * 4.0f); + float angle = random->nextFloat() * std::numbers::pi * 2.0f; + int bx = x + (int)(0.5f + GameMath::cos(angle) * 4.0f); + int bz = z + (int)(0.5f + GameMath::sin(angle) * 4.0f); placeLeaves(level, bx, bz, branchHeight, 0, random); for (int b = 0; b < 5; b++) { - bx = x + (int)(1.5f + Mth::cos(angle) * b); - bz = z + (int)(1.5f + Mth::sin(angle) * b); + bx = x + (int)(1.5f + GameMath::cos(angle) * b); + bz = z + (int)(1.5f + GameMath::sin(angle) * b); placeBlock(level, bx, branchHeight - 3 + b / 2, bz, Tile::treeTrunk_Id, trunkType); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/OreFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/OreFeature.cpp index 251ee4791..da1a314e9 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/OreFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/OreFeature.cpp @@ -19,12 +19,12 @@ OreFeature::OreFeature(int tile, int count, int targetTile) { bool OreFeature::place(Level* level, Random* random, int x, int y, int z) { PIXBeginNamedEvent(0, "Place Ore Feature"); - float dir = random->nextFloat() * M_PI; + float dir = random->nextFloat() * std::numbers::pi; - double x0 = x + 8 + Mth::sin(dir) * count / 8; - double x1 = x + 8 - Mth::sin(dir) * count / 8; - double z0 = z + 8 + Mth::cos(dir) * count / 8; - double z1 = z + 8 - Mth::cos(dir) * count / 8; + double x0 = x + 8 + GameMath::sin(dir) * count / 8; + double x1 = x + 8 - GameMath::sin(dir) * count / 8; + double z0 = z + 8 + GameMath::cos(dir) * count / 8; + double z1 = z + 8 - GameMath::cos(dir) * count / 8; double y0 = y + random->nextInt(3) - 2; double y1 = y + random->nextInt(3) - 2; @@ -42,11 +42,11 @@ bool OreFeature::place(Level* level, Random* random, int x, int y, int z) { int minZ = z0 - 1; double maxss = count / 16; - double maxr = (Mth::sin(M_PI) + 1) * maxss + 1; - double maxhr = (Mth::sin(M_PI) + 1) * maxss + 1; - int maxX = Mth::floor(x1 + maxr / 2); - int maxY = Mth::floor(y1 + maxhr / 2); - int maxZ = Mth::floor(z1 + maxr / 2); + double maxr = (GameMath::sin(std::numbers::pi) + 1) * maxss + 1; + double maxhr = (GameMath::sin(std::numbers::pi) + 1) * maxss + 1; + int maxX = GameMath::floor(x1 + maxr / 2); + int maxY = GameMath::floor(y1 + maxhr / 2); + int maxZ = GameMath::floor(z1 + maxr / 2); collisionsExpected = levelGenOptions->checkIntersects(minX, minY, minZ, maxX, maxY, maxZ); @@ -63,19 +63,19 @@ bool OreFeature::place(Level* level, Random* random, int x, int y, int z) { double zz = z0 + (z1 - z0) * d / count; double ss = random->nextDouble() * count / 16; - double r = (Mth::sin(d * M_PI / count) + 1) * ss + 1; - double hr = r; //(Mth::sin(d * M_PI / count) + 1) * ss + 1; + double r = (GameMath::sin(d * std::numbers::pi / count) + 1) * ss + 1; + double hr = r; //(GameMath::sin(d * std::numbers::pi / count) + 1) * ss + 1; double halfR = r / 2; double halfHR = halfR; // hr/2; - int xt0 = Mth::floor(xx - halfR); - int yt0 = Mth::floor(yy - halfHR); - int zt0 = Mth::floor(zz - halfR); + int xt0 = GameMath::floor(xx - halfR); + int yt0 = GameMath::floor(yy - halfHR); + int zt0 = GameMath::floor(zz - halfR); - int xt1 = Mth::floor(xx + halfR); - int yt1 = Mth::floor(yy + halfHR); - int zt1 = Mth::floor(zz + halfR); + int xt1 = GameMath::floor(xx + halfR); + int yt1 = GameMath::floor(yy + halfHR); + int zt1 = GameMath::floor(zz + halfR); // 4J Stu Added to stop ore features generating areas previously place // by game rule generation diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/BlockGenMethods.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/BlockGenMethods.cpp index 2a3e15912..d137074f3 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/BlockGenMethods.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/BlockGenMethods.cpp @@ -6,12 +6,12 @@ void BlockGenMethods::generateBox(Level* level, std::vector& blocks, int sx, int sy, int sz, int ex, int ey, int ez, std::uint8_t edge, std::uint8_t filling) { - sx = Mth::clamp(sx, 0, 15); - sy = Mth::clamp(sy, 0, Level::genDepthMinusOne); - sz = Mth::clamp(sz, 0, 15); - ex = Mth::clamp(ex, 0, 15); - ey = Mth::clamp(ey, 0, Level::genDepthMinusOne); - ez = Mth::clamp(ez, 0, 15); + sx = GameMath::clamp(sx, 0, 15); + sy = GameMath::clamp(sy, 0, Level::genDepthMinusOne); + sz = GameMath::clamp(sz, 0, 15); + ex = GameMath::clamp(ex, 0, 15); + ey = GameMath::clamp(ey, 0, Level::genDepthMinusOne); + ez = GameMath::clamp(ez, 0, 15); for (int x = sx; x <= ex; x++) { for (int y = sy; y <= ey; y++) { @@ -33,11 +33,11 @@ void BlockGenMethods::generateFrame(Level* level, std::vector& blocks, int sy, int ex, int ey, int flatZ, int direction, std::uint8_t edge, std::uint8_t filling) { - sx = Mth::clamp(sx, 0, 15); - sy = Mth::clamp(sy, 0, Level::genDepthMinusOne); - ex = Mth::clamp(ex, 0, 15); - ey = Mth::clamp(ey, 0, Level::genDepthMinusOne); - int sz = Mth::clamp(flatZ, 0, 15); + sx = GameMath::clamp(sx, 0, 15); + sy = GameMath::clamp(sy, 0, Level::genDepthMinusOne); + ex = GameMath::clamp(ex, 0, 15); + ey = GameMath::clamp(ey, 0, Level::genDepthMinusOne); + int sz = GameMath::clamp(flatZ, 0, 15); int ez = sz; bool alongX = true; @@ -89,12 +89,12 @@ void BlockGenMethods::generateDirectionLine(Level* level, std::vector& int ey, int ez, int startDirection, int endDirection, std::uint8_t block) { - sx = Mth::clamp(sx, 0, 15); - sy = Mth::clamp(sy, 0, Level::genDepthMinusOne); - sz = Mth::clamp(sz, 0, 15); - ex = Mth::clamp(ex, 0, 15); - ey = Mth::clamp(ey, 0, Level::genDepthMinusOne); - ez = Mth::clamp(ez, 0, 15); + sx = GameMath::clamp(sx, 0, 15); + sy = GameMath::clamp(sy, 0, Level::genDepthMinusOne); + sz = GameMath::clamp(sz, 0, 15); + ex = GameMath::clamp(ex, 0, 15); + ey = GameMath::clamp(ey, 0, Level::genDepthMinusOne); + ez = GameMath::clamp(ez, 0, 15); switch (startDirection) { case Direction::WEST: { @@ -136,9 +136,9 @@ void BlockGenMethods::generateDirectionLine(Level* level, std::vector& } break; } - int dx = Mth::abs(ex - sx); - int dz = Mth::abs(ez - sz); - int dy = Mth::abs(ey - sy); + int dx = GameMath::abs(ex - sx); + int dz = GameMath::abs(ez - sz); + int dy = GameMath::abs(ey - sy); int slopeX = sx < ex ? 1 : -1; int slopeZ = sz < ez ? 1 : -1; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/MineShaftFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/MineShaftFeature.cpp index aa922aa05..59ab78b12 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/MineShaftFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/MineShaftFeature.cpp @@ -1,7 +1,7 @@ #include "../../../../../../Header Files/stdafx.h" #include "net.minecraft.world.level.levelgen.structure.h" #include "java/JavaMath.h" -#include "../../../../util/Mth.h" +#include "../../../../util/GameMath.h" const std::wstring MineShaftFeature::OPTION_CHANCE = L"chance"; @@ -15,7 +15,7 @@ MineShaftFeature::MineShaftFeature( for (auto it = options.begin(); it != options.end(); ++it) { if (it->first.compare(OPTION_CHANCE) == 0) { - chance = Mth::getDouble(it->second, chance); + chance = GameMath::getDouble(it->second, chance); } } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/RandomScatteredLargeFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/RandomScatteredLargeFeature.cpp index 2cd240be8..5f0917622 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/RandomScatteredLargeFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/RandomScatteredLargeFeature.cpp @@ -31,7 +31,7 @@ RandomScatteredLargeFeature::RandomScatteredLargeFeature( for (auto it = options.begin(); it != options.end(); ++it) { if (it->first.compare(OPTION_SPACING) == 0) { - spacing = Mth::getInt(it->second, spacing, minSeparation + 1); + spacing = GameMath::getInt(it->second, spacing, minSeparation + 1); } } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/SkyIslandDimension.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/SkyIslandDimension.cpp index cf0639a8f..29d251a71 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/SkyIslandDimension.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/SkyIslandDimension.cpp @@ -24,7 +24,7 @@ float* SkyIslandDimension::getSunriseColor(float td, float a) { Vec3 SkyIslandDimension::getFogColor(float td, float a) const { int fogColor = 0x8080a0; - float br = Mth::cos(td * M_PI * 2) * 2 + 0.5f; + float br = cosf(td * std::numbers::pi * 2) * 2 + 0.5f; if (br < 0.0f) br = 0.0f; if (br > 1.0f) br = 1.0f; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp index ec14668d4..7156a7f3b 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp @@ -4,7 +4,7 @@ #include "../../net.minecraft.world.level.h" #include "../../biome/net.minecraft.world.level.biome.h" #include "../../dimension/net.minecraft.world.level.dimension.h" -#include "../../../../util/Mth.h" +#include "../../../../util/GameMath.h" #include "../../../../../../ConsoleHelpers/ConsoleSaveFileIO/FileHeader.h" #include "java/JavaMath.h" @@ -49,14 +49,14 @@ StrongholdFeature::StrongholdFeature( for (auto it = options.begin(); it != options.end(); ++it) { if (it->first.compare(OPTION_DISTANCE) == 0) { - distance = Mth::getDouble(it->second, distance, 1); + distance = GameMath::getDouble(it->second, distance, 1); } else if (it->first.compare(OPTION_COUNT) == 0) { // 4J-JEV: Removed, we only have the one stronghold. - // strongholdPos = new ChunkPos[ Mth::getInt(it->second, + // strongholdPos = new ChunkPos[ GameMath::getInt(it->second, // strongholdPos_length, 1) ]; assert(false); } else if (it->first.compare(OPTION_SPREAD) == 0) { - spread = Mth::getInt(it->second, spread, 1); + spread = GameMath::getInt(it->second, spread, 1); } } } @@ -76,7 +76,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) { Random random; random.setSeed(level->getSeed()); - double angle = random.nextDouble() * M_PI * 2.0; + double angle = random.nextDouble() * std::numbers::pi * 2.0; int circle = 1; // 4J Stu - Changed so that we keep trying more until we have found @@ -158,7 +158,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) { delete strongholdPos[i]; strongholdPos[i] = new ChunkPos(selectedX, selectedZ); - angle += M_PI * 2.0 / (double)strongholdPos_length; + angle += std::numbers::pi * 2.0 / (double)strongholdPos_length; } // 4J Stu - We want to make sure that we have at least one @@ -167,7 +167,7 @@ bool StrongholdFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) { // 4J Stu - Randomise the angles for retries as well #ifdef _LARGE_WORLDS - angle = random.nextDouble() * M_PI * 2.0 * circle / (double)spread; + angle = random.nextDouble() * std::numbers::pi * 2.0 * circle / (double)spread; #endif } while (!hasFoundValidPos && findAttempts < MAX_STRONGHOLD_ATTEMPTS); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/VillageFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/VillageFeature.cpp index 18303d3a7..309d2345d 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/VillageFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/VillageFeature.cpp @@ -32,10 +32,10 @@ VillageFeature::VillageFeature( for (auto it = options.begin(); it != options.end(); ++it) { if (it->first.compare(OPTION_SIZE_MODIFIER) == 0) { villageSizeModifier = - Mth::getInt(it->second, villageSizeModifier, 0); + GameMath::getInt(it->second, villageSizeModifier, 0); } else if (it->first.compare(OPTION_SPACING) == 0) { townSpacing = - Mth::getInt(it->second, townSpacing, minTownSeparation + 1); + GameMath::getInt(it->second, townSpacing, minTownSeparation + 1); } } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/VillagePieces.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/VillagePieces.cpp index c9745141f..b9a0dc586 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/VillagePieces.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/VillagePieces.cpp @@ -67,31 +67,31 @@ std::list* VillagePieces::createPieceSet( newPieces->push_back(new PieceWeight( VillagePieces::EPieceClass_SimpleHouse, 4, - Mth::nextInt(random, 2 + villageSize, 4 + villageSize * 2))); + random->nextInt(2 + villageSize, 4 + villageSize * 2))); newPieces->push_back(new PieceWeight( VillagePieces::EPieceClass_SmallTemple, 20, - Mth::nextInt(random, 0 + villageSize, 1 + villageSize))); + random->nextInt(0 + villageSize, 1 + villageSize))); newPieces->push_back(new PieceWeight( VillagePieces::EPieceClass_BookHouse, 20, - Mth::nextInt(random, 0 + villageSize, 2 + villageSize))); + random->nextInt(0 + villageSize, 2 + villageSize))); newPieces->push_back(new PieceWeight( VillagePieces::EPieceClass_SmallHut, 3, - Mth::nextInt(random, 2 + villageSize, 5 + villageSize * 3))); + random->nextInt(2 + villageSize, 5 + villageSize * 3))); newPieces->push_back(new PieceWeight( VillagePieces::EPieceClass_PigHouse, 15, - Mth::nextInt(random, 0 + villageSize, 2 + villageSize))); + random->nextInt(0 + villageSize, 2 + villageSize))); newPieces->push_back(new PieceWeight( VillagePieces::EPieceClass_DoubleFarmland, 3, - Mth::nextInt(random, 1 + villageSize, 4 + villageSize))); + random->nextInt(1 + villageSize, 4 + villageSize))); newPieces->push_back(new PieceWeight( VillagePieces::EPieceClass_Farmland, 3, - Mth::nextInt(random, 2 + villageSize, 4 + villageSize * 2))); + random->nextInt(2 + villageSize, 4 + villageSize * 2))); newPieces->push_back( new PieceWeight(VillagePieces::EPieceClass_Smithy, 15, - Mth::nextInt(random, 0, 1 + villageSize))); + random->nextInt(0, 1 + villageSize))); newPieces->push_back(new PieceWeight( VillagePieces::EPieceClass_TwoRoomHouse, 8, - Mth::nextInt(random, 0 + villageSize, 3 + villageSize * 2))); + random->nextInt(0 + villageSize, 3 + villageSize * 2))); // silly way of filtering "infinite" buildings auto it = newPieces->begin(); @@ -733,7 +733,7 @@ void VillagePieces::StraightRoad::addChildren( BoundingBox* VillagePieces::StraightRoad::findPieceBox( StartPiece* startPiece, std::list* pieces, Random* random, int footX, int footY, int footZ, int direction) { - int length = 7 * (Mth::nextInt(random, 3, 5)); + int length = 7 * (random->nextInt(3, 5)); while (length >= 7) { BoundingBox* box = BoundingBox::orientBox(footX, footY, footZ, 0, 0, 0, @@ -1970,10 +1970,10 @@ bool VillagePieces::Farmland::postProcess(Level* level, Random* random, Tile::water_Id, false); // crops for (int d = 1; d <= 7; d++) { - placeBlock(level, cropsA, Mth::nextInt(random, 2, 7), 1, 1, d, chunkBB); - placeBlock(level, cropsA, Mth::nextInt(random, 2, 7), 2, 1, d, chunkBB); - placeBlock(level, cropsB, Mth::nextInt(random, 2, 7), 4, 1, d, chunkBB); - placeBlock(level, cropsB, Mth::nextInt(random, 2, 7), 5, 1, d, chunkBB); + placeBlock(level, cropsA, random->nextInt(2, 7), 1, 1, d, chunkBB); + placeBlock(level, cropsA, random->nextInt(2, 7), 2, 1, d, chunkBB); + placeBlock(level, cropsB, random->nextInt(2, 7), 4, 1, d, chunkBB); + placeBlock(level, cropsB, random->nextInt(2, 7), 5, 1, d, chunkBB); } for (int z = 0; z < depth; z++) { @@ -2091,15 +2091,15 @@ bool VillagePieces::DoubleFarmland::postProcess(Level* level, Random* random, Tile::water_Id, false); // crops for (int d = 1; d <= 7; d++) { - placeBlock(level, cropsA, Mth::nextInt(random, 2, 7), 1, 1, d, chunkBB); - placeBlock(level, cropsA, Mth::nextInt(random, 2, 7), 2, 1, d, chunkBB); - placeBlock(level, cropsB, Mth::nextInt(random, 2, 7), 4, 1, d, chunkBB); - placeBlock(level, cropsB, Mth::nextInt(random, 2, 7), 5, 1, d, chunkBB); - placeBlock(level, cropsC, Mth::nextInt(random, 2, 7), 7, 1, d, chunkBB); - placeBlock(level, cropsC, Mth::nextInt(random, 2, 7), 8, 1, d, chunkBB); - placeBlock(level, cropsD, Mth::nextInt(random, 2, 7), 10, 1, d, + placeBlock(level, cropsA, random->nextInt(2, 7), 1, 1, d, chunkBB); + placeBlock(level, cropsA, random->nextInt(2, 7), 2, 1, d, chunkBB); + placeBlock(level, cropsB, random->nextInt(2, 7), 4, 1, d, chunkBB); + placeBlock(level, cropsB, random->nextInt(2, 7), 5, 1, d, chunkBB); + placeBlock(level, cropsC, random->nextInt(2, 7), 7, 1, d, chunkBB); + placeBlock(level, cropsC, random->nextInt(2, 7), 8, 1, d, chunkBB); + placeBlock(level, cropsD, random->nextInt(2, 7), 10, 1, d, chunkBB); - placeBlock(level, cropsD, Mth::nextInt(random, 2, 7), 11, 1, d, + placeBlock(level, cropsD, random->nextInt(2, 7), 11, 1, d, chunkBB); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/synth/PerlinNoise.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/synth/PerlinNoise.cpp index 7b06a1858..155a6d3e4 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/synth/PerlinNoise.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/synth/PerlinNoise.cpp @@ -1,6 +1,6 @@ #include "../../../../../../Header Files/stdafx.h" #include "PerlinNoise.h" -#include "../../../../util/Mth.h" +#include "../../../../util/GameMath.h" PerlinNoise::PerlinNoise(int levels) { Random random; @@ -67,8 +67,8 @@ std::vector PerlinNoise::getRegion(std::vector& buffer, int x, i double xx = x * pow * xScale; double yy = y * pow * yScale; double zz = z * pow * zScale; - int64_t xb = Mth::lfloor(xx); - int64_t zb = Mth::lfloor(zz); + int64_t xb = GameMath::lfloor(xx); + int64_t zb = GameMath::lfloor(zz); xx -= xb; zz -= zb; xb %= 16777216; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/Node.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/Node.cpp index a7f5f643f..65afb2908 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/Node.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/Node.cpp @@ -34,7 +34,7 @@ float Node::distanceTo(Node* to) { float xd = (float)(to->x - x); float yd = (float)(to->y - y); float zd = (float)(to->z - z); - return Mth::sqrt(xd * xd + yd * yd + zd * zd); + return GameMath::sqrt(xd * xd + yd * yd + zd * zd); } float Node::distanceToSqr(Node* to) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/PathFinder.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/PathFinder.cpp index 0c2a6220f..1d8345832 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/PathFinder.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/PathFinder.cpp @@ -45,20 +45,20 @@ Path* PathFinder::findPath(Entity* e, double xt, double yt, double zt, nodes.clear(); bool resetAvoidWater = avoidWater; - int startY = Mth::floor(e->bb.y0 + 0.5f); + int startY = GameMath::floor(e->bb.y0 + 0.5f); if (canFloat && e->isInWater()) { startY = (int)(e->bb.y0); - int tileId = level->getTile((int)Mth::floor(e->x), startY, - (int)Mth::floor(e->z)); + int tileId = level->getTile((int)GameMath::floor(e->x), startY, + (int)GameMath::floor(e->z)); while (tileId == Tile::water_Id || tileId == Tile::calmWater_Id) { ++startY; - tileId = level->getTile((int)Mth::floor(e->x), startY, - (int)Mth::floor(e->z)); + tileId = level->getTile((int)GameMath::floor(e->x), startY, + (int)GameMath::floor(e->z)); } resetAvoidWater = avoidWater; avoidWater = false; } else - startY = Mth::floor(e->bb.y0 + 0.5f); + startY = GameMath::floor(e->bb.y0 + 0.5f); Node* from = getNode((int)floor(e->bb.x0), startY, (int)floor(e->bb.z0)); Node* to = getNode((int)floor(xt - e->bbWidth / 2), (int)floor(yt), @@ -231,9 +231,9 @@ int PathFinder::isFree(Entity* entity, int x, int y, int z, Node* size, // have already got if (entity->level->getTileRenderShape(tileId) == Tile::SHAPE_RAIL) { - int xt = Mth::floor(entity->x); - int yt = Mth::floor(entity->y); - int zt = Mth::floor(entity->z); + int xt = GameMath::floor(entity->x); + int yt = GameMath::floor(entity->y); + int zt = GameMath::floor(entity->z); if (entity->level->getTileRenderShape(xt, yt, zt) == Tile::SHAPE_RAIL || entity->level->getTileRenderShape(xt, yt - 1, zt) == diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/AnvilTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/AnvilTile.cpp index 04dd3d24b..31333e456 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/AnvilTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/AnvilTile.cpp @@ -46,7 +46,7 @@ void AnvilTile::registerIcons(IconRegister* iconRegister) { void AnvilTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = (Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3; + int dir = (GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3; int dmg = level->getData(x, y, z) >> 2; dir = ++dir % 4; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/ChestTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/ChestTile.cpp index ae213494c..ad06375ac 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/ChestTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/ChestTile.cpp @@ -66,7 +66,7 @@ void ChestTile::setPlacedBy(Level* level, int x, int y, int z, int e = level->getTile(x + 1, y, z); // face = 5 int facing = 0; - int dir = (Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3; + int dir = (GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3; if (dir == 0) facing = Facing::NORTH; if (dir == 1) facing = Facing::EAST; @@ -332,7 +332,7 @@ int ChestTile::getSignal(LevelSource* level, int x, int y, int z, int dir) { int openCount = std::dynamic_pointer_cast( level->getTileEntity(x, y, z)) ->openCount; - return Mth::clamp(openCount, Redstone::SIGNAL_NONE, Redstone::SIGNAL_MAX); + return GameMath::clamp(openCount, Redstone::SIGNAL_NONE, Redstone::SIGNAL_MAX); } int ChestTile::getDirectSignal(LevelSource* level, int x, int y, int z, diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/CocoaTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/CocoaTile.cpp index 2ab3a4081..12353ca7b 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/CocoaTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/CocoaTile.cpp @@ -105,7 +105,7 @@ void CocoaTile::updateShape(LevelSource* level, int x, int y, int z, void CocoaTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = (((Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3) + 0) % 4; + int dir = (((GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3) + 0) % 4; level->setData(x, y, z, dir, Tile::UPDATE_CLIENTS); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/CropTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/CropTile.cpp index e38d3f4a9..727dffc13 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/CropTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/CropTile.cpp @@ -40,7 +40,7 @@ void CropTile::tick(Level* level, int x, int y, int z, Random* random) { } void CropTile::growCrops(Level* level, int x, int y, int z) { - int stage = level->getData(x, y, z) + Mth::nextInt(level->random, 2, 5); + int stage = level->getData(x, y, z) + level->random->nextInt(2, 5); if (stage > 7) stage = 7; level->setData(x, y, z, stage, Tile::UPDATE_CLIENTS); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/DaylightDetectorTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/DaylightDetectorTile.cpp index a3daa3390..f46f97053 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/DaylightDetectorTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/DaylightDetectorTile.cpp @@ -53,13 +53,13 @@ void DaylightDetectorTile::updateSignalStrength(Level* level, int x, int y, // tilt sunAngle towards zenith (to make the transition to night // smoother) - if (sunAngle < M_PI) { + if (sunAngle < std::numbers::pi) { sunAngle = sunAngle + (0 - sunAngle) * .2f; } else { - sunAngle = sunAngle + (M_PI * 2.0f - sunAngle) * .2f; + sunAngle = sunAngle + (std::numbers::pi * 2.0f - sunAngle) * .2f; } - target = Math::round((float)target * Mth::cos(sunAngle)); + target = Math::round((float)target * cosf(sunAngle)); if (target < 0) { target = 0; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/DiodeTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/DiodeTile.cpp index 474608bdf..a1f5fe0df 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/DiodeTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/DiodeTile.cpp @@ -205,7 +205,7 @@ bool DiodeTile::isSignalSource() { return true; } void DiodeTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = (((Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3) + 2) % 4; + int dir = (((GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3) + 2) % 4; level->setData(x, y, z, dir, Tile::UPDATE_ALL); bool sourceOn = shouldTurnOn(level, x, y, z, dir); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/EnderChestTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/EnderChestTile.cpp index 39e4f2b04..237f06b17 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/EnderChestTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/EnderChestTile.cpp @@ -36,7 +36,7 @@ void EnderChestTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { int facing = 0; - int dir = (Mth::floor(by->yRot * 4 / (360) + 0.5f)) & 3; + int dir = (GameMath::floor(by->yRot * 4 / (360) + 0.5f)) & 3; if (dir == 0) facing = Facing::NORTH; if (dir == 1) facing = Facing::EAST; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/FenceGateTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/FenceGateTile.cpp index 5cc32d7af..6c38bcb93 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/FenceGateTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/FenceGateTile.cpp @@ -72,7 +72,7 @@ int FenceGateTile::getRenderShape() { return Tile::SHAPE_FENCE_GATE; } void FenceGateTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = (((Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3)) % 4; + int dir = (((GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3)) % 4; level->setData(x, y, z, dir, Tile::UPDATE_CLIENTS); } @@ -95,7 +95,7 @@ bool FenceGateTile::use(Level* level, int x, int y, int z, level->setData(x, y, z, data & ~OPEN_BIT, Tile::UPDATE_CLIENTS); } else { // open the door from the player - int dir = (((Mth::floor(player->yRot * 4 / (360) + 0.5)) & 3)) % 4; + int dir = (((GameMath::floor(player->yRot * 4 / (360) + 0.5)) & 3)) % 4; int current = getDirection(data); if (current == ((dir + 2) % 4)) { data = dir; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/FurnaceTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/FurnaceTile.cpp index f44e4460b..203e4f6e4 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/FurnaceTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/FurnaceTile.cpp @@ -135,7 +135,7 @@ std::shared_ptr FurnaceTile::newTileEntity(Level* level) { void FurnaceTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = (Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3; + int dir = (GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3; if (dir == 0) level->setData(x, y, z, Facing::NORTH, Tile::UPDATE_CLIENTS); if (dir == 1) level->setData(x, y, z, Facing::EAST, Tile::UPDATE_CLIENTS); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/GlowstoneTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/GlowstoneTile.cpp index 6c30adfb3..0eda5c16f 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/GlowstoneTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/GlowstoneTile.cpp @@ -6,7 +6,7 @@ Glowstonetile::Glowstonetile(int id, Material* material) : Tile(id, material) {} int Glowstonetile::getResourceCountForLootBonus(int bonusLevel, Random* random) { - return Mth::clamp( + return GameMath::clamp( getResourceCount(random) + random->nextInt(bonusLevel + 1), 1, 4); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/LeverTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/LeverTile.cpp index 0f1deb65e..4bc31c3ee 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/LeverTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/LeverTile.cpp @@ -85,13 +85,13 @@ void LeverTile::setPlacedBy(Level* level, int x, int y, int z, int flip = data & 8; if (dir == getLeverFacing(Facing::UP)) { - if ((Mth::floor(by->yRot * 4 / (360) + 0.5) & 1) == 0) { + if ((GameMath::floor(by->yRot * 4 / (360) + 0.5) & 1) == 0) { level->setData(x, y, z, 5 | flip, Tile::UPDATE_CLIENTS); } else { level->setData(x, y, z, 6 | flip, Tile::UPDATE_CLIENTS); } } else if (dir == getLeverFacing(Facing::DOWN)) { - if ((Mth::floor(by->yRot * 4 / (360) + 0.5) & 1) == 0) { + if ((GameMath::floor(by->yRot * 4 / (360) + 0.5) & 1) == 0) { level->setData(x, y, z, 7 | flip, Tile::UPDATE_CLIENTS); } else { level->setData(x, y, z, 0 | flip, Tile::UPDATE_CLIENTS); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/LiquidTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/LiquidTile.cpp index df401c0b5..fdffce1ed 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/LiquidTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/LiquidTile.cpp @@ -314,7 +314,7 @@ double LiquidTile::getSlopeAngle(LevelSource* level, int x, int y, int z, if (m == Material::water) flow = Tile::water->getFlow(level, x, y, z); if (m == Material::lava) flow = Tile::lava->getFlow(level, x, y, z); if (flow.x == 0 && flow.z == 0) return -1000; - return atan2(flow.z, flow.x) - M_PI / 2; + return atan2(flow.z, flow.x) - std::numbers::pi / 2; } void LiquidTile::onPlace(Level* level, int x, int y, int z) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/OreTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/OreTile.cpp index 0282275ac..ba7983c50 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/OreTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/OreTile.cpp @@ -38,15 +38,15 @@ void OreTile::spawnResources(Level* level, int x, int y, int z, int data, if (getResource(data, level->random, playerBonusLevel) != id) { int magicCount = 0; if (id == Tile::coalOre_Id) { - magicCount = Mth::nextInt(level->random, 0, 2); + magicCount = level->random->nextInt(0, 2); } else if (id == Tile::diamondOre_Id) { - magicCount = Mth::nextInt(level->random, 3, 7); + magicCount = level->random->nextInt(3, 7); } else if (id == Tile::emeraldOre_Id) { - magicCount = Mth::nextInt(level->random, 3, 7); + magicCount = level->random->nextInt(3, 7); } else if (id == Tile::lapisOre_Id) { - magicCount = Mth::nextInt(level->random, 2, 5); + magicCount = level->random->nextInt(2, 5); } else if (id == Tile::netherQuartz_Id) { - magicCount = Mth::nextInt(level->random, 2, 5); + magicCount = level->random->nextInt(2, 5); } popExperience(level, x, y, z, magicCount); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/PumpkinTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/PumpkinTile.cpp index 8c7809d88..721c6591f 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/PumpkinTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/PumpkinTile.cpp @@ -175,7 +175,7 @@ bool PumpkinTile::mayPlace(Level* level, int x, int y, int z) { void PumpkinTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = Mth::floor(by->yRot * 4 / (360) + 2.5) & 3; + int dir = GameMath::floor(by->yRot * 4 / (360) + 2.5) & 3; level->setData(x, y, z, dir, Tile::UPDATE_CLIENTS); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/SkullTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/SkullTile.cpp index fc1864c5d..3a9f9eef7 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/SkullTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/SkullTile.cpp @@ -55,7 +55,7 @@ std::optional SkullTile::getAABB(Level* level, int x, int y, int z) { void SkullTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by) { - int dir = Mth::floor(by->yRot * 4 / (360) + 2.5) & 3; + int dir = GameMath::floor(by->yRot * 4 / (360) + 2.5) & 3; level->setData(x, y, z, dir, Tile::UPDATE_CLIENTS); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/StairTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/StairTile.cpp index 646ecc310..049d5aafb 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/StairTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/StairTile.cpp @@ -391,7 +391,7 @@ void StairTile::wasExploded(Level* level, int x, int y, int z, void StairTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = (Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3; + int dir = (GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3; int usd = level->getData(x, y, z) & UPSIDEDOWN_BIT; if (dir == 0) diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/StemTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/StemTile.cpp index d612643e4..9681d316a 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/StemTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/StemTile.cpp @@ -60,7 +60,7 @@ void StemTile::tick(Level* level, int x, int y, int z, Random* random) { } void StemTile::growCrops(Level* level, int x, int y, int z) { - int stage = level->getData(x, y, z) + Mth::nextInt(level->random, 2, 5); + int stage = level->getData(x, y, z) + level->random->nextInt(2, 5); if (stage > 7) stage = 7; level->setData(x, y, z, stage, Tile::UPDATE_CLIENTS); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/TheEndPortalFrameTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/TheEndPortalFrameTile.cpp index e75e7a0fb..2b2740cba 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/TheEndPortalFrameTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/TheEndPortalFrameTile.cpp @@ -64,7 +64,7 @@ int TheEndPortalFrameTile::getResource(int data, Random* random, void TheEndPortalFrameTile::setPlacedBy( Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = (((Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3) + 2) % 4; + int dir = (((GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3) + 2) % 4; level->setData(x, y, z, dir, Tile::UPDATE_CLIENTS); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/WeightedPressurePlateTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/WeightedPressurePlateTile.cpp index 18a429aec..9bfe01a3e 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/WeightedPressurePlateTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/WeightedPressurePlateTile.cpp @@ -29,7 +29,7 @@ int WeightedPressurePlateTile::getSignalStrength(Level* level, int x, int y, return 0; } else { float pct = std::min(maxWeight, count) / (float)maxWeight; - return Mth::ceil(pct * Redstone::SIGNAL_MAX); + return GameMath::ceil(pct * Redstone::SIGNAL_MAX); } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/EnchantmentTableTileEntity.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/EnchantmentTableTileEntity.cpp index 9f706511b..2fb3fd423 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/EnchantmentTableTileEntity.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/EnchantmentTableTileEntity.cpp @@ -58,13 +58,13 @@ void EnchantmentTableEntity::tick() { open -= 0.1f; } - while (rot >= M_PI) rot -= M_PI * 2; - while (rot < -M_PI ) rot += M_PI * 2; - while (tRot >= M_PI) tRot -= M_PI * 2; - while (tRot < -M_PI ) tRot += M_PI * 2; + while (rot >= std::numbers::pi) rot -= std::numbers::pi * 2; + while (rot < -std::numbers::pi ) rot += std::numbers::pi * 2; + while (tRot >= std::numbers::pi) tRot -= std::numbers::pi * 2; + while (tRot < -std::numbers::pi ) tRot += std::numbers::pi * 2; float rotDir = tRot - rot; - while (rotDir >= M_PI) rotDir -= M_PI * 2; - while (rotDir < -M_PI ) rotDir += M_PI * 2; + while (rotDir >= std::numbers::pi) rotDir -= std::numbers::pi * 2; + while (rotDir < -std::numbers::pi ) rotDir += std::numbers::pi * 2; rot += rotDir * 0.4f; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/HopperTileEntity.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/HopperTileEntity.cpp index 62456fbe4..b14be4e42 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/HopperTileEntity.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/HopperTileEntity.cpp @@ -366,9 +366,9 @@ std::shared_ptr HopperTileEntity::getContainerAt(Level* level, double z) { std::shared_ptr result = nullptr; - int xt = Mth::floor(x); - int yt = Mth::floor(y); - int zt = Mth::floor(z); + int xt = GameMath::floor(x); + int yt = GameMath::floor(y); + int zt = GameMath::floor(z); std::shared_ptr entity = level->getTileEntity(xt, yt, zt); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/piston/PistonBaseTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/piston/PistonBaseTile.cpp index 0c039c1c2..1c3500e5c 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/piston/PistonBaseTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/piston/PistonBaseTile.cpp @@ -414,8 +414,8 @@ bool PistonBaseTile::isExtended(int data) { return (data & EXTENDED_BIT) != 0; } int PistonBaseTile::getNewFacing(Level* level, int x, int y, int z, std::shared_ptr player) { - if (Mth::abs((float)player->x - x) < 2 && - Mth::abs((float)player->z - z) < 2) { + if (GameMath::abs((float)player->x - x) < 2 && + GameMath::abs((float)player->z - z) < 2) { // If the player is above the block, the slot is on the top double py = player->y + 1.82 - player->heightOffset; if (py - y > 2) { @@ -427,7 +427,7 @@ int PistonBaseTile::getNewFacing(Level* level, int x, int y, int z, } } // The slot is on the side - int i = Mth::floor(player->yRot * 4.0f / 360.0f + 0.5) & 0x3; + int i = GameMath::floor(player->yRot * 4.0f / 360.0f + 0.5) & 0x3; if (i == 0) return Facing::NORTH; if (i == 1) return Facing::EAST; if (i == 2) return Facing::SOUTH; diff --git a/minecraft/Minecraft.World/net/minecraft/world/scores/criteria/HealthCriteria.cpp b/minecraft/Minecraft.World/net/minecraft/world/scores/criteria/HealthCriteria.cpp index bfb427622..0c4838487 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/scores/criteria/HealthCriteria.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/scores/criteria/HealthCriteria.cpp @@ -15,7 +15,7 @@ int HealthCriteria::getScoreModifier( if (players->size() > 0) health /= players->size(); - return Mth::ceil(health); + return GameMath::ceil(health); } bool HealthCriteria::isReadOnly() { return true; } \ No newline at end of file diff --git a/minecraft/java/include/java/Random.h b/minecraft/java/include/java/Random.h index 40b3e45d2..8269c2421 100644 --- a/minecraft/java/include/java/Random.h +++ b/minecraft/java/include/java/Random.h @@ -18,7 +18,10 @@ public: double nextGaussian(); int nextInt(); int nextInt(int to); + int nextInt(int minInclusive, int maxInclusive); float nextFloat(); + float nextFloat(float min, float max); + double nextDouble(double min, double max); int64_t nextLong(); bool nextBoolean(); }; \ No newline at end of file diff --git a/minecraft/java/src/Random.cpp b/minecraft/java/src/Random.cpp index b16a2e628..2e8f25b4f 100644 --- a/minecraft/java/src/Random.cpp +++ b/minecraft/java/src/Random.cpp @@ -82,6 +82,21 @@ int Random::nextInt(int n) { float Random::nextFloat() { return next(24) / ((float)(1 << 24)); } +float Random::nextFloat(float min, float max) { + if (min >= max) return min; + return (nextFloat() * (max - min)) + min; +} + +int Random::nextInt(int minInclusive, int maxInclusive) { + if (minInclusive >= maxInclusive) return minInclusive; + return nextInt(maxInclusive - minInclusive + 1) + minInclusive; +} + +double Random::nextDouble(double min, double max) { + if (min >= max) return min; + return (nextDouble() * (max - min)) + min; +} + int64_t Random::nextLong() { // 4jcraft added casts to unsigned return (int64_t)((uint64_t)next(32) << 32) + next(32);