Merge branch 'rubicon' of https://github.com/4jcraft/4jcraft into rubicon

This commit is contained in:
Tropical 2026-03-30 21:17:57 -05:00
commit 07861307a2
233 changed files with 1662 additions and 1778 deletions

View file

@ -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<Mob>* 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<Mob>* 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;

View file

@ -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;

View file

@ -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);

View file

@ -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(); }

View file

@ -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<LivingEntity> player,

View file

@ -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

View file

@ -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<double>(
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<double>(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);

View file

@ -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,

View file

@ -61,25 +61,25 @@ void BatModel::render(std::shared_ptr<Entity> entity, float time, float r,
bool usecompiled) {
std::shared_ptr<Bat> bat = std::dynamic_pointer_cast<Bat>(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> 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;

View file

@ -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> 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);
}

View file

@ -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

View file

@ -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> 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);
}

View file

@ -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> 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;
}

View file

@ -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> 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;
}

View file

@ -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;
}
}

View file

@ -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);
}
}
}

View file

@ -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"

View file

@ -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);
}

View file

@ -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

View file

@ -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<LivingEntity> 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<LivingEntity> 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<LivingEntity> 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<LivingEntity> 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<LivingEntity> 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;

View file

@ -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> 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<LivingEntity> 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<LivingEntity> 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;

View file

@ -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> 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,

View file

@ -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> 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;

View file

@ -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);
}

View file

@ -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"

View file

@ -36,10 +36,10 @@ void SkiModel::render(std::shared_ptr<Entity> entity, float time, float r,
void SkiModel::setupAnim(float time, float r, float bob, float yRot, float xRot,
float scale, std::shared_ptr<Entity> 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;

View file

@ -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> 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;

View file

@ -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> 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;

View file

@ -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

View file

@ -52,8 +52,8 @@ void VillagerGolemModel::setupAnim(float time, float r, float bob, float yRot,
float xRot, float scale,
std::shared_ptr<Entity> 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;

View file

@ -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> 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;
}

View file

@ -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);
}

View file

@ -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;

View file

@ -56,14 +56,14 @@ void WitherBossModel::setupAnim(float time, float r, float bob, float yRot,
std::shared_ptr<Entity> 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<LivingEntity> mob,
@ -73,7 +73,7 @@ void WitherBossModel::prepareMobModel(std::shared_ptr<LivingEntity> 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);
}
}

View file

@ -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<LivingEntity> 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<LivingEntity> 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> 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;
}

View file

@ -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);
}

View file

@ -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> entity, float time, float r,
std::dynamic_pointer_cast<EnderDragon>(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> 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> 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> 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> 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> 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();

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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();

View file

@ -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();
}

View file

@ -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);

View file

@ -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);

View file

@ -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,

View file

@ -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;

View file

@ -155,13 +155,13 @@ void ParticleEngine::renderLit(std::shared_ptr<Entity> 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);

View file

@ -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();

View file

@ -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<Entity> 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) {

View file

@ -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();
}

View file

@ -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;

View file

@ -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;

View file

@ -212,9 +212,9 @@ void GameRenderer::tick(bool first) // 4J - add bFirst
mc->cameraTargetPlayer = std::dynamic_pointer_cast<Mob>(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> 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<LivingEntity> 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<LivingEntity> 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;

View file

@ -432,13 +432,13 @@ void ItemInHandRenderer::render(float a) {
std::shared_ptr<ItemInstance> 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);
}

View file

@ -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<Entity> 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<LivingEntity> 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> 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<Player> 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<Player> 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<Player> 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;

View file

@ -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);

View file

@ -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<LivingEntity> 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;

View file

@ -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<Entity> _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);

View file

@ -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<Entity> _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);
}

View file

@ -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<LivingEntity> _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(

View file

@ -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<LivingEntity> 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;

View file

@ -123,8 +123,8 @@ void EnderDragonRenderer::render(std::shared_ptr<Entity> _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<Entity> _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);

View file

@ -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);

View file

@ -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<Entity> 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;

View file

@ -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<Entity> _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);

View file

@ -39,28 +39,28 @@ void FallingTileRenderer::render(std::shared_ptr<Entity> _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);

View file

@ -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<Entity> _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<Entity> _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 +

View file

@ -179,7 +179,7 @@ void ItemFrameRenderer::drawItem(std::shared_ptr<ItemFrame> 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;
}

View file

@ -55,10 +55,10 @@ void ItemRenderer::render(std::shared_ptr<Entity> _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<ItemEntity> 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);
}

View file

@ -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<Entity> _mob, double x,
std::dynamic_pointer_cast<LivingEntity>(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<LivingEntity> 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;

View file

@ -60,7 +60,7 @@ void MinecartRenderer::render(std::shared_ptr<Entity> _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<Entity> _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);
}

View file

@ -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<Mob> 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<Mob> 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;

View file

@ -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> painting, int w,
void PaintingRenderer::setBrightness(std::shared_ptr<Painting> 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;

View file

@ -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;

View file

@ -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;

View file

@ -99,7 +99,7 @@ void ZombieRenderer::setupRotations(std::shared_ptr<LivingEntity> _mob,
float bob, float bodyRot, float a) {
std::shared_ptr<Zombie> mob = std::dynamic_pointer_cast<Zombie>(_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);
}

View file

@ -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();
}

View file

@ -44,15 +44,15 @@ void BeaconRenderer::render(std::shared_ptr<TileEntity> _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;

View file

@ -128,7 +128,7 @@ void ChestRenderer::render(std::shared_ptr<TileEntity> _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();

View file

@ -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<TileEntity> _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;

View file

@ -42,7 +42,7 @@ void EnderChestRenderer::render(std::shared_ptr<TileEntity> _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();

View file

@ -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);

View file

@ -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();

View file

@ -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> 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);

View file

@ -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"

View file

@ -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"

View file

@ -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() {

View file

@ -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<Entity> 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<RotateHeadPacket>(
new RotateHeadPacket(e->entityId, (uint8_t)yHeadRot)));
@ -625,8 +625,8 @@ void TrackedEntity::updatePlayer(EntityTracker* tracker,
std::shared_ptr<EntityActionAtPositionPacket>(
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<Packet> TrackedEntity::getAddEntityPacket() {
// 4J-PB - replacing with a switch, rather than tons of ifs
if (std::dynamic_pointer_cast<Creature>(e) != nullptr) {
yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360);
yHeadRotp = GameMath::floor(e->getYHeadRot() * 256 / 360);
return std::shared_ptr<AddMobPacket>(
new AddMobPacket(std::dynamic_pointer_cast<Mob>(e), yRotp, xRotp,
xp, yp, zp, yHeadRotp));
@ -717,7 +717,7 @@ std::shared_ptr<Packet> TrackedEntity::getAddEntityPacket() {
return std::shared_ptr<AddEntityPacket>(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<AddMobPacket>(
new AddMobPacket(std::dynamic_pointer_cast<LivingEntity>(e), yRotp,
xRotp, xp, yp, zp, yHeadRotp));
@ -812,9 +812,9 @@ std::shared_ptr<Packet> TrackedEntity::getAddEntityPacket() {
std::shared_ptr<AddEntityPacket>(
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<LeashFenceKnotEntity> knot =
@ -822,9 +822,9 @@ std::shared_ptr<Packet> TrackedEntity::getAddEntityPacket() {
std::shared_ptr<AddEntityPacket> packet =
std::shared_ptr<AddEntityPacket>(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<AddExperienceOrbPacket>(

View file

@ -35,6 +35,7 @@
#include <deque>
#include <algorithm>
#include <math.h>
#include <numbers>
#include <limits>
#include <string>
#include <sstream>
@ -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"

View file

@ -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 {

View file

@ -13,9 +13,9 @@ AddExperienceOrbPacket::AddExperienceOrbPacket() {
AddExperienceOrbPacket::AddExperienceOrbPacket(
std::shared_ptr<ExperienceOrb> 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();
}

View file

@ -19,9 +19,9 @@ AddGlobalEntityPacket::AddGlobalEntityPacket() {
AddGlobalEntityPacket::AddGlobalEntityPacket(std::shared_ptr<Entity> 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 {

View file

@ -26,9 +26,9 @@ AddMobPacket::AddMobPacket(std::shared_ptr<LivingEntity> 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<uint8_t>(yRotp);

View file

@ -36,9 +36,9 @@ AddPlayerPacket::AddPlayerPacket(std::shared_ptr<Player> 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;

View file

@ -16,9 +16,9 @@ TeleportEntityPacket::TeleportEntityPacket() {
TeleportEntityPacket::TeleportEntityPacket(std::shared_ptr<Entity> 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);
}

View file

@ -0,0 +1,73 @@
#include "../../../Header Files/stdafx.h"
#include "GameMath.h"
#include "java/Random.h"
#include "../../../ConsoleHelpers/StringHelpers.h"
#include <array>
#include <numbers>
constexpr size_t SIN_TAB_CNT = 65536;
constexpr float SIN_SCALE = SIN_TAB_CNT / (std::numbers::pi_v<float> * 2.0f);
static std::array<float, SIN_TAB_CNT> makeSinTable() {
std::array<float, SIN_TAB_CNT> 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<float, SIN_TAB_CNT> 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;
}

View file

@ -0,0 +1,59 @@
#pragma once
class Random;
class GameMath {
public:
static constexpr float DEG_TO_RAD = std::numbers::pi_v<float> / 180.0f;
static constexpr float RAD_TO_DEG = 180.0f / std::numbers::pi_v<float>;
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);
};

View file

@ -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<int>(input);
return result;
}
int Mth::getInt(const std::wstring& input, int def, int min) {
int result = def;
result = _fromString<int>(input);
if (result < min) result = min;
return result;
}
double Mth::getDouble(const std::wstring& input, double def) {
double result = def;
result = _fromString<double>(input);
return result;
}
double Mth::getDouble(const std::wstring& input, double def, double min) {
double result = def;
result = _fromString<double>(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);
}

View file

@ -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);
};

View file

@ -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;

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