From e942d0d47254ce5fea136903399db562842fc81f Mon Sep 17 00:00:00 2001 From: MatthewBeshay <92357869+MatthewBeshay@users.noreply.github.com> Date: Tue, 31 Mar 2026 13:38:41 +1100 Subject: [PATCH] refactor: revert GameMath rename back to Mth --- .../Common/Source Files/Audio/SoundEngine.cpp | 10 +- .../UIScene_MainMenu.cpp | 4 +- .../net/minecraft/client/Minecraft.cpp | 6 +- .../net/minecraft/client/gui/Gui.cpp | 14 +- .../net/minecraft/client/model/BlazeModel.cpp | 2 +- .../net/minecraft/client/model/BookModel.cpp | 2 +- .../minecraft/client/model/ChickenModel.cpp | 2 +- .../minecraft/client/model/CreeperModel.cpp | 2 +- .../net/minecraft/client/model/GhastModel.cpp | 2 +- .../minecraft/client/model/HumanoidModel.cpp | 4 +- .../minecraft/client/model/LavaSlimeModel.cpp | 2 +- .../net/minecraft/client/model/ModelHorse.cpp | 12 +- .../minecraft/client/model/OcelotModel.cpp | 2 +- .../minecraft/client/model/QuadrupedModel.cpp | 2 +- .../client/model/SilverfishModel.cpp | 2 +- .../minecraft/client/model/SkeletonModel.cpp | 2 +- .../minecraft/client/model/SnowManModel.cpp | 2 +- .../minecraft/client/model/SpiderModel.cpp | 2 +- .../net/minecraft/client/model/SquidModel.cpp | 2 +- .../minecraft/client/model/VillagerModel.cpp | 2 +- .../client/model/VillagerZombieModel.cpp | 2 +- .../net/minecraft/client/model/WitchModel.cpp | 14 +- .../net/minecraft/client/model/WolfModel.cpp | 2 +- .../minecraft/client/model/ZombieModel.cpp | 2 +- .../client/model/dragon/DragonModel.cpp | 2 +- .../client/multiplayer/ClientConnection.cpp | 22 +-- .../multiplayer/MultiPlayerLocalPlayer.cpp | 4 +- .../client/particle/BubbleParticle.cpp | 4 +- .../client/particle/DripParticle.cpp | 8 +- .../client/particle/FootstepParticle.cpp | 4 +- .../client/particle/NoteParticle.cpp | 2 +- .../minecraft/client/particle/Particle.cpp | 4 +- .../client/particle/SuspendedParticle.cpp | 4 +- .../client/particle/TakeAnimationParticle.cpp | 8 +- .../client/particle/WaterDropParticle.cpp | 6 +- .../minecraft/client/player/LocalPlayer.cpp | 8 +- .../minecraft/client/player/RemotePlayer.cpp | 6 +- .../client/renderer/GameRenderer.cpp | 40 ++-- .../client/renderer/ItemInHandRenderer.cpp | 22 +-- .../client/renderer/LevelRenderer.cpp | 46 ++--- .../renderer/culling/ViewportCuller.cpp | 2 +- .../client/renderer/entity/ArrowRenderer.cpp | 2 +- .../client/renderer/entity/BoatRenderer.cpp | 2 +- .../renderer/entity/ChickenRenderer.cpp | 2 +- .../renderer/entity/CreeperRenderer.cpp | 2 +- .../entity/EntityRenderDispatcher.cpp | 8 +- .../client/renderer/entity/EntityRenderer.cpp | 14 +- .../renderer/entity/ExperienceOrbRenderer.cpp | 2 +- .../renderer/entity/FallingTileRenderer.cpp | 22 +-- .../renderer/entity/FishingHookRenderer.cpp | 2 +- .../renderer/entity/ItemFrameRenderer.cpp | 2 +- .../client/renderer/entity/ItemRenderer.cpp | 4 +- .../renderer/entity/LivingEntityRenderer.cpp | 4 +- .../client/renderer/entity/MobRenderer.cpp | 8 +- .../renderer/entity/PaintingRenderer.cpp | 16 +- .../tileentity/EnchantTableRenderer.cpp | 6 +- .../minecraft/client/title/TitleScreen.cpp | 2 +- .../net/minecraft/server/MinecraftServer.cpp | 6 +- .../net/minecraft/server/PlayerList.cpp | 12 +- .../minecraft/server/level/EntityTracker.cpp | 2 +- .../minecraft/server/level/ServerLevel.cpp | 2 +- .../minecraft/server/level/ServerPlayer.cpp | 2 +- .../minecraft/server/level/TrackedEntity.cpp | 52 ++--- .../Minecraft.World/Header Files/stdafx.h | 2 +- .../net/minecraft/Direction.cpp | 2 +- .../network/packet/AddExperienceOrbPacket.cpp | 6 +- .../network/packet/AddGlobalEntityPacket.cpp | 6 +- .../minecraft/network/packet/AddMobPacket.cpp | 6 +- .../network/packet/AddPlayerPacket.cpp | 6 +- .../network/packet/TeleportEntityPacket.cpp | 6 +- .../minecraft/util/{GameMath.cpp => Mth.cpp} | 16 +- .../net/minecraft/util/{GameMath.h => Mth.h} | 2 +- .../world/damageSource/CombatTracker.cpp | 2 +- .../net/minecraft/world/entity/Entity.cpp | 76 +++---- .../net/minecraft/world/entity/EntityPos.cpp | 8 +- .../minecraft/world/entity/ExperienceOrb.cpp | 4 +- .../net/minecraft/world/entity/FlyingMob.cpp | 8 +- .../minecraft/world/entity/HangingEntity.cpp | 10 +- .../minecraft/world/entity/LivingEntity.cpp | 72 +++---- .../net/minecraft/world/entity/Mob.cpp | 10 +- .../minecraft/world/entity/PathfinderMob.cpp | 22 +-- .../world/entity/ai/control/BodyControl.cpp | 2 +- .../world/entity/ai/control/LookControl.cpp | 2 +- .../world/entity/ai/control/MoveControl.cpp | 2 +- .../entity/ai/goal/ControlledByPlayerGoal.cpp | 22 +-- .../world/entity/ai/goal/DoorInteractGoal.cpp | 6 +- .../world/entity/ai/goal/EatTileGoal.cpp | 12 +- .../world/entity/ai/goal/FleeSunGoal.cpp | 10 +- .../world/entity/ai/goal/FollowOwnerGoal.cpp | 6 +- .../world/entity/ai/goal/MakeLoveGoal.cpp | 6 +- .../world/entity/ai/goal/MeleeAttackGoal.cpp | 4 +- .../world/entity/ai/goal/MoveIndoorsGoal.cpp | 4 +- .../entity/ai/goal/MoveThroughVillageGoal.cpp | 6 +- .../world/entity/ai/goal/RangedAttackGoal.cpp | 8 +- .../entity/ai/goal/RestrictOpenDoorGoal.cpp | 12 +- .../entity/ai/goal/target/TargetGoal.cpp | 8 +- .../entity/ai/navigation/PathNavigation.cpp | 22 +-- .../world/entity/ai/util/RandomPos.cpp | 8 +- .../world/entity/ai/village/Village.cpp | 2 +- .../minecraft/world/entity/ambient/Bat.cpp | 18 +- .../minecraft/world/entity/animal/Animal.cpp | 14 +- .../world/entity/animal/EntityHorse.cpp | 18 +- .../world/entity/animal/MushroomCow.cpp | 6 +- .../minecraft/world/entity/animal/Ocelot.cpp | 6 +- .../minecraft/world/entity/animal/SnowMan.cpp | 12 +- .../minecraft/world/entity/animal/Squid.cpp | 2 +- .../world/entity/animal/VillagerGolem.cpp | 8 +- .../entity/boss/enderdragon/EnderCrystal.cpp | 6 +- .../entity/boss/enderdragon/EnderDragon.cpp | 22 +-- .../world/entity/boss/wither/WitherBoss.cpp | 16 +- .../world/entity/global/LightningBolt.cpp | 14 +- .../net/minecraft/world/entity/item/Boat.cpp | 10 +- .../world/entity/item/FallingTile.cpp | 10 +- .../world/entity/item/ItemEntity.cpp | 4 +- .../minecraft/world/entity/item/Minecart.cpp | 42 ++-- .../world/entity/item/MinecartFurnace.cpp | 4 +- .../world/entity/item/MinecartSpawner.cpp | 6 +- .../world/entity/monster/EnderMan.cpp | 22 +-- .../world/entity/monster/Monster.cpp | 6 +- .../world/entity/monster/Silverfish.cpp | 10 +- .../world/entity/monster/Skeleton.cpp | 4 +- .../minecraft/world/entity/monster/Slime.cpp | 8 +- .../minecraft/world/entity/monster/Witch.cpp | 2 +- .../minecraft/world/entity/monster/Zombie.cpp | 10 +- .../minecraft/world/entity/npc/Villager.cpp | 6 +- .../minecraft/world/entity/player/Player.cpp | 6 +- .../world/entity/projectile/Arrow.cpp | 4 +- .../projectile/FireworksRocketEntity.cpp | 4 +- .../world/entity/projectile/FishingHook.cpp | 8 +- .../world/inventory/AbstractContainerMenu.cpp | 4 +- .../net/minecraft/world/item/BedItem.cpp | 2 +- .../net/minecraft/world/item/BoatItem.cpp | 18 +- .../net/minecraft/world/item/DoorItem.cpp | 2 +- .../minecraft/world/item/DyePowderItem.cpp | 4 +- .../net/minecraft/world/item/Item.cpp | 8 +- .../net/minecraft/world/item/MapItem.cpp | 4 +- .../net/minecraft/world/item/SignItem.cpp | 2 +- .../net/minecraft/world/item/SkullItem.cpp | 2 +- .../net/minecraft/world/item/SpawnEggItem.cpp | 2 +- .../enchantment/ProtectionEnchantment.cpp | 14 +- .../net/minecraft/world/level/Explosion.cpp | 18 +- .../net/minecraft/world/level/Level.cpp | 186 +++++++++--------- .../net/minecraft/world/level/MobSpawner.cpp | 4 +- .../minecraft/world/level/PortalForcer.cpp | 16 +- .../net/minecraft/world/level/TilePos.cpp | 6 +- .../net/minecraft/world/level/biome/Biome.cpp | 8 +- .../world/level/chunk/LevelChunk.cpp | 14 +- .../world/level/levelgen/CanyonFeature.cpp | 22 +-- .../world/level/levelgen/DungeonFeature.cpp | 22 +-- .../world/level/levelgen/LargeCaveFeature.cpp | 22 +-- .../level/levelgen/LargeHellCaveFeature.cpp | 22 +-- .../level/levelgen/RandomLevelSource.cpp | 2 +- .../levelgen/feature/BasicTreeFeature.cpp | 14 +- .../level/levelgen/feature/CaveFeature.cpp | 12 +- .../levelgen/feature/MegaTreeFeature.cpp | 8 +- .../level/levelgen/feature/OreFeature.cpp | 34 ++-- .../levelgen/structure/BlockGenMethods.cpp | 40 ++-- .../levelgen/structure/MineShaftFeature.cpp | 4 +- .../structure/RandomScatteredLargeFeature.cpp | 2 +- .../levelgen/structure/StrongholdFeature.cpp | 8 +- .../levelgen/structure/VillageFeature.cpp | 4 +- .../level/levelgen/synth/PerlinNoise.cpp | 6 +- .../minecraft/world/level/pathfinder/Node.cpp | 2 +- .../world/level/pathfinder/PathFinder.cpp | 18 +- .../minecraft/world/level/tile/AnvilTile.cpp | 2 +- .../minecraft/world/level/tile/ChestTile.cpp | 4 +- .../minecraft/world/level/tile/CocoaTile.cpp | 2 +- .../minecraft/world/level/tile/DiodeTile.cpp | 2 +- .../world/level/tile/EnderChestTile.cpp | 2 +- .../world/level/tile/FenceGateTile.cpp | 4 +- .../world/level/tile/FurnaceTile.cpp | 2 +- .../world/level/tile/GlowstoneTile.cpp | 2 +- .../minecraft/world/level/tile/LeverTile.cpp | 4 +- .../world/level/tile/PumpkinTile.cpp | 2 +- .../minecraft/world/level/tile/SkullTile.cpp | 2 +- .../minecraft/world/level/tile/StairTile.cpp | 2 +- .../level/tile/TheEndPortalFrameTile.cpp | 2 +- .../level/tile/WeightedPressurePlateTile.cpp | 2 +- .../level/tile/entity/HopperTileEntity.cpp | 6 +- .../level/tile/piston/PistonBaseTile.cpp | 6 +- .../world/scores/criteria/HealthCriteria.cpp | 2 +- 181 files changed, 891 insertions(+), 891 deletions(-) rename minecraft/Minecraft.World/net/minecraft/util/{GameMath.cpp => Mth.cpp} (82%) rename minecraft/Minecraft.World/net/minecraft/util/{GameMath.h => Mth.h} (99%) diff --git a/minecraft/Minecraft.Client/Common/Source Files/Audio/SoundEngine.cpp b/minecraft/Minecraft.Client/Common/Source Files/Audio/SoundEngine.cpp index e60952c88..21ba0f52c 100644 --- a/minecraft/Minecraft.Client/Common/Source Files/Audio/SoundEngine.cpp +++ b/minecraft/Minecraft.Client/Common/Source Files/Audio/SoundEngine.cpp @@ -5,7 +5,7 @@ #include "../../../net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.h" #include "Minecraft.World/net/minecraft/world/level/net.minecraft.world.level.h" #include "Minecraft.World/net/minecraft/world/level/storage/LevelData.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "../../../net/minecraft/client/skins/TexturePackRepository.h" #include "../../../net/minecraft/client/skins/DLCTexturePack.h" #include "../DLC/DLCAudioFile.h" @@ -733,8 +733,8 @@ void SoundEngine::tick(shared_ptr* players, float a) { float yRot = players[i]->yRotO + (players[i]->yRot - players[i]->yRotO) * a; - float yCos = (float)cos(yRot * GameMath::DEG_TO_RAD); - float ySin = (float)sin(yRot * GameMath::DEG_TO_RAD); + float yCos = (float)cos(yRot * Mth::DEG_TO_RAD); + float ySin = (float)sin(yRot * Mth::DEG_TO_RAD); // store the listener positions for splitscreen m_ListenerA[i].vPosition.x = x; @@ -1111,8 +1111,8 @@ void SoundEngine::tick(std::shared_ptr* players, float a) { float yRot = players[i]->yRotO + (players[i]->yRot - players[i]->yRotO) * a; - float yCos = (float)cos(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); - float ySin = (float)sin(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); + float yCos = (float)cos(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); + float ySin = (float)sin(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); // store the listener positions for splitscreen m_ListenerA[i].vPosition.x = x; diff --git a/minecraft/Minecraft.Client/Common/Source Files/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp b/minecraft/Minecraft.Client/Common/Source Files/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp index 5d7207626..e96d19b5c 100644 --- a/minecraft/Minecraft.Client/Common/Source Files/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp +++ b/minecraft/Minecraft.Client/Common/Source Files/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "Minecraft.World/ConsoleHelpers/StringHelpers.h" #include "java/Random.h" #include "../../../../../net/minecraft/client/User.h" @@ -347,7 +347,7 @@ void UIScene_MainMenu::customDrawSplash(IggyCustomDrawCallbackRegion* region) { glTranslatef(xo, yo, 0); glRotatef(-17, 0, 0, 1); - float sss = 1.8f - GameMath::abs(sinf(System::currentTimeMillis() % 1000 / + float sss = 1.8f - Mth::abs(sinf(System::currentTimeMillis() % 1000 / 1000.0f * std::numbers::pi * 2) * 0.1f); sss *= (m_fScreenWidth / m_fRawWidth); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/Minecraft.cpp b/minecraft/Minecraft.Client/net/minecraft/client/Minecraft.cpp index 623874bcf..5a07931b2 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/Minecraft.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/Minecraft.cpp @@ -3559,9 +3559,9 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { // Level::animateTickDoWork() so we can take into account multiple // players in the one level. if (!pause && levels[i] != nullptr) - levels[i]->animateTick(GameMath::floor(player->x), - GameMath::floor(player->y), - GameMath::floor(player->z)); + levels[i]->animateTick(Mth::floor(player->x), + Mth::floor(player->y), + Mth::floor(player->z)); if (levelsTickedFlags & (1 << i)) continue; // Don't tick further if we've already ticked this diff --git a/minecraft/Minecraft.Client/net/minecraft/client/gui/Gui.cpp b/minecraft/Minecraft.Client/net/minecraft/client/gui/Gui.cpp index 78415e6d8..ed85f4abe 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/gui/Gui.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/gui/Gui.cpp @@ -489,7 +489,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse) { double totalAbsorption = minecraft->localplayers[iPad]->getAbsorptionAmount(); int NUM_HEARTS_PER_ROW = 10; // 4jcraft: missing definition - int numHealthRows = GameMath::ceil((maxHealth + totalAbsorption) / + int numHealthRows = Mth::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 = GameMath::ceil((maxHealth + totalAbsorption) / 2) - 1; + for (int i = Mth::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 = - GameMath::ceil((i + 1) / (float)NUM_HEARTS_PER_ROW) - 1; + Mth::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( - GameMath::floor(minecraft->player->yRot * 4.0f / 360.0f + 0.5) & + Mth::floor(minecraft->player->yRot * 4.0f / 360.0f + 0.5) & 0x3) + L"/ yRot: " + _toString(minecraft->player->yRot), iSafezoneXHalf + 2, iYPos + 8 * 3, 0xe0e0e0); iYPos += 8 * 4; - int px = GameMath::floor(minecraft->player->x); - int py = GameMath::floor(minecraft->player->y); - int pz = GameMath::floor(minecraft->player->z); + int px = Mth::floor(minecraft->player->x); + int py = Mth::floor(minecraft->player->y); + int pz = Mth::floor(minecraft->player->z); if (minecraft->level != nullptr && minecraft->level->hasChunkAt(px, py, pz)) { LevelChunk* chunkAt = minecraft->level->getChunkAt(px, pz); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/BlazeModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/BlazeModel.cpp index 27138d2fc..1f758bf79 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/BlazeModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/BlazeModel.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "BlazeModel.h" #include "geom/ModelPart.h" diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/BookModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/BookModel.cpp index c28b07971..2cd32730a 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/BookModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/BookModel.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "BookModel.h" #include "geom/ModelPart.h" diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/ChickenModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/ChickenModel.cpp index 987576c8c..3d34ab139 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/ChickenModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/ChickenModel.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "ChickenModel.h" #include "geom/ModelPart.h" diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/CreeperModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/CreeperModel.cpp index 3e02a17ff..1451b9d69 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/CreeperModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/CreeperModel.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "CreeperModel.h" #include "geom/ModelPart.h" diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/GhastModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/GhastModel.cpp index bc99db9c4..1668368b5 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/GhastModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/GhastModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "java/Random.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "GhastModel.h" #include "geom/ModelPart.h" diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/HumanoidModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/HumanoidModel.cpp index 301b4b477..2cc16c302 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/HumanoidModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/HumanoidModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "HumanoidModel.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "Minecraft.World/net/minecraft/world/entity/Entity.h" #include "geom/ModelPart.h" @@ -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 = -GameMath::abs(cosf(eating_t / 4.0f * std::numbers::pi) * 0.1f) * + arm0->xRot = -Mth::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 diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/LavaSlimeModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/LavaSlimeModel.cpp index 9fc6c140f..9a8d6c0d9 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/LavaSlimeModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/LavaSlimeModel.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "LavaSlimeModel.h" #include "geom/ModelPart.h" #include "Minecraft.World/net/minecraft/world/entity/monster/LavaSlime.h" diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/ModelHorse.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/ModelHorse.cpp index c1ebd5d01..fe4bb5d98 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/ModelHorse.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/ModelHorse.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "Minecraft.World/net/minecraft/world/entity/animal/net.minecraft.world.entity.animal.h" #include "ModelHorse.h" #include "geom/ModelPart.h" @@ -450,7 +450,7 @@ void ModelHorse::prepareMobModel(std::shared_ptr mob, float wp, // animations { // TODO: Magic numbers - Head->xRot = standing * ((15 * GameMath::DEG_TO_RAD) + (HeadXRot)) + + Head->xRot = standing * ((15 * Mth::DEG_TO_RAD) + (HeadXRot)) + eating * 2.18166f + (1.0f - std::max(standing, eating)) * Head->xRot; Head->yRot = standing * (headRotMinusBodyRot / 57.29578f) + @@ -515,8 +515,8 @@ void ModelHorse::prepareMobModel(std::shared_ptr mob, float wp, { 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 r300 = -60 * Mth::DEG_TO_RAD; + float standAngle = 15 * Mth::DEG_TO_RAD * standing; float bobValue = cosf((bob * 0.6f) + 3.141593f); Leg3A->y = -2.f * standing + 9.f * iStanding; @@ -553,14 +553,14 @@ void ModelHorse::prepareMobModel(std::shared_ptr mob, float wp, Leg1A->xRot = standAngle + (-legAnim1 * 0.5f * ws) * iStanding; Leg1B->xRot = - (-5 * GameMath::DEG_TO_RAD) * standing + + (-5 * Mth::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 * GameMath::DEG_TO_RAD) * standing + + (-5 * Mth::DEG_TO_RAD) * standing + ((legAnim1 * 0.5f * ws) - std::max(0.0f, -legAnim1 * .5f * ws)) * iStanding; Leg2C->xRot = Leg2B->xRot; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/OcelotModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/OcelotModel.cpp index 1fd47b162..c0ee84ba8 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/OcelotModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/OcelotModel.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "geom/ModelPart.h" #include "Minecraft.World/net/minecraft/world/entity/animal/net.minecraft.world.entity.animal.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "OcelotModel.h" const float OcelotModel::xo = 0; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/QuadrupedModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/QuadrupedModel.cpp index 325e89fe2..3c9f8398a 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/QuadrupedModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/QuadrupedModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "QuadrupedModel.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "geom/ModelPart.h" QuadrupedModel::QuadrupedModel(int legSize, float g) : Model() { diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/SilverfishModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/SilverfishModel.cpp index f3740510b..3bc6def33 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/SilverfishModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/SilverfishModel.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "SilverfishModel.h" #include "geom/Cube.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "geom/ModelPart.h" const int SilverfishModel::BODY_SIZES[BODY_COUNT][3] = { diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/SkeletonModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/SkeletonModel.cpp index 09a0af1cb..e82f6a3f4 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/SkeletonModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/SkeletonModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "SkeletonModel.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "Minecraft.World/net/minecraft/world/entity/monster/net.minecraft.world.entity.monster.h" #include "geom/ModelPart.h" diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/SnowManModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/SnowManModel.cpp index 523d8a051..837a2b5f9 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/SnowManModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/SnowManModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "SnowManModel.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "geom/ModelPart.h" SnowManModel::SnowManModel() : Model() { diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/SpiderModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/SpiderModel.cpp index bca55bc95..7abedce76 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/SpiderModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/SpiderModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "SpiderModel.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "geom/ModelPart.h" SpiderModel::SpiderModel() : Model() { diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/SquidModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/SquidModel.cpp index d4488645e..7bd4d0ced 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/SquidModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/SquidModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "SquidModel.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "geom/ModelPart.h" SquidModel::SquidModel() : Model() { diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerModel.cpp index 00895c0cf..0795f82f6 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "VillagerModel.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "geom/ModelPart.h" void VillagerModel::_init(float g, float yOffset, int xTexSize, int yTexSize) { diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerZombieModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerZombieModel.cpp index 84e986f2e..9c3a3856d 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerZombieModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/VillagerZombieModel.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "geom/ModelPart.h" #include "VillagerZombieModel.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" void VillagerZombieModel::_init(float g, float yOffset, bool isArmor) { delete head; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/WitchModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/WitchModel.cpp index 291526a65..5de0201f1 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/WitchModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/WitchModel.cpp @@ -2,7 +2,7 @@ #include "geom/ModelPart.h" #include "WitchModel.h" #include "VillagerModel.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.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 * GameMath::DEG_TO_RAD; - hat2->zRot = 1.5f * GameMath::DEG_TO_RAD; + hat2->xRot = -3.f * Mth::DEG_TO_RAD; + hat2->zRot = 1.5f * Mth::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 * GameMath::DEG_TO_RAD; - hat3->zRot = 3.f * GameMath::DEG_TO_RAD; + hat3->xRot = -6.f * Mth::DEG_TO_RAD; + hat3->zRot = 3.f * Mth::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 * GameMath::DEG_TO_RAD; - hat4->zRot = 6.f * GameMath::DEG_TO_RAD; + hat4->xRot = -12.f * Mth::DEG_TO_RAD; + hat4->zRot = 6.f * Mth::DEG_TO_RAD; hat3->addChild(hat4); // 4J added - compile now to avoid random performance hit first time cubes diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/WolfModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/WolfModel.cpp index fbd6c5586..c4749a515 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/WolfModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/WolfModel.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "WolfModel.h" #include "Minecraft.World/net/minecraft/world/entity/animal/Wolf.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "geom/ModelPart.h" WolfModel::WolfModel() { diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/ZombieModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/ZombieModel.cpp index a0fcf35c2..deee14dba 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/ZombieModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/ZombieModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "ZombieModel.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "geom/ModelPart.h" ZombieModel::ZombieModel() : HumanoidModel(0, 0, 64, 32) {} diff --git a/minecraft/Minecraft.Client/net/minecraft/client/model/dragon/DragonModel.cpp b/minecraft/Minecraft.Client/net/minecraft/client/model/dragon/DragonModel.cpp index 59ffff7dd..1dfbceb7b 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/model/dragon/DragonModel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/model/dragon/DragonModel.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "DragonModel.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderDragon.h" DragonModel::DragonModel(float g) : Model() { diff --git a/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/ClientConnection.cpp b/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/ClientConnection.cpp index 914d65732..78477c82d 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/ClientConnection.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/ClientConnection.cpp @@ -2579,9 +2579,9 @@ void ClientConnection::handleContainerOpen( } } break; case ContainerOpenPacket::WORKBENCH: { - if (player->startCrafting(GameMath::floor(player->x), - GameMath::floor(player->y), - GameMath::floor(player->z))) { + if (player->startCrafting(Mth::floor(player->x), + Mth::floor(player->y), + Mth::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( - GameMath::floor(player->x), GameMath::floor(player->y), - GameMath::floor(player->z), + Mth::floor(player->x), Mth::floor(player->y), + Mth::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(GameMath::floor(player->x), - GameMath::floor(player->y), - GameMath::floor(player->z))) { + if (player->startRepairing(Mth::floor(player->x), + Mth::floor(player->y), + Mth::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(GameMath::floor(player->x), - GameMath::floor(player->y), - GameMath::floor(player->z))) { + if (player->openFireworks(Mth::floor(player->x), + Mth::floor(player->y), + Mth::floor(player->z))) { player->containerMenu->containerId = packet->containerId; } else { failed = true; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp index 635b7ed9b..ae6f1142b 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp @@ -4,7 +4,7 @@ #include "ClientConnection.h" #include "Minecraft.World/net/minecraft/world/level/net.minecraft.world.level.h" #include "Minecraft.World/net/minecraft/network/net.minecraft.network.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.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(GameMath::floor(x), 0, GameMath::floor(z))) return; + if (!level->hasChunkAt(Mth::floor(x), 0, Mth::floor(z))) return; double tempX = x, tempY = y, tempZ = z; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/BubbleParticle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/BubbleParticle.cpp index e75bf5ff1..f0c45e2b5 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/BubbleParticle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/BubbleParticle.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "BubbleParticle.h" #include "java/Random.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.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(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)) != + if (level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)) != Material::water) remove(); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/DripParticle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/DripParticle.cpp index 55114059e..ad70defba 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/DripParticle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/DripParticle.cpp @@ -3,7 +3,7 @@ #include "Minecraft.World/net/minecraft/world/level/material/net.minecraft.world.level.material.h" #include "Minecraft.World/net/minecraft/world/level/tile/net.minecraft.world.level.tile.h" #include "java/JavaMath.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.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(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); + level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)); if (m->isLiquid() || m->isSolid()) { - double y0 = GameMath::floor(y) + 1 - + double y0 = Mth::floor(y) + 1 - LiquidTile::getHeight(level->getData( - GameMath::floor(x), GameMath::floor(y), GameMath::floor(z))); + Mth::floor(x), Mth::floor(y), Mth::floor(z))); if (y < y0) { remove(); } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/FootstepParticle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/FootstepParticle.cpp index 2eec5f086..6d73fc6af 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/FootstepParticle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/FootstepParticle.cpp @@ -2,7 +2,7 @@ #include "FootstepParticle.h" #include "../renderer/Textures.h" #include "../renderer/Tesselator.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.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(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); + level->getBrightness(Mth::floor(x), Mth::floor(y), Mth::floor(z)); textures->bindTexture(&FOOTPRINT_LOCATION); glEnable(GL_BLEND); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/NoteParticle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/NoteParticle.cpp index dc071eb9d..1385de622 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/NoteParticle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/NoteParticle.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "NoteParticle.h" void NoteParticle::init(Level* level, double x, double y, double z, double xa, diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/Particle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/Particle.cpp index 909d374ea..bf96905d3 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/Particle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/Particle.cpp @@ -2,7 +2,7 @@ #include "Particle.h" #include "../renderer/Tesselator.h" #include "java/Random.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.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)(GameMath::sqrt(xd * xd + yd * yd + zd * zd)); + float dd = (float)(Mth::sqrt(xd * xd + yd * yd + zd * zd)); xd = xd / dd * speed * 0.4f; yd = yd / dd * speed * 0.4f + 0.1f; zd = zd / dd * speed * 0.4f; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/SuspendedParticle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/SuspendedParticle.cpp index 95e80ca57..e866c214b 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/SuspendedParticle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/SuspendedParticle.cpp @@ -3,7 +3,7 @@ #include "java/Random.h" #include "Minecraft.World/net/minecraft/world/level/net.minecraft.world.level.h" #include "java/JavaMath.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.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(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)) != + if (level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)) != Material::water) remove(); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/TakeAnimationParticle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/TakeAnimationParticle.cpp index 2b201d8a5..910ab54d0 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/TakeAnimationParticle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/TakeAnimationParticle.cpp @@ -3,7 +3,7 @@ #include "../renderer/entity/EntityRenderDispatcher.h" #include "Minecraft.World/net/minecraft/world/item/net.minecraft.world.item.h" #include "Minecraft.World/net/minecraft/world/level/net.minecraft.world.level.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" TakeAnimationParticle::TakeAnimationParticle(Level* level, std::shared_ptr item, @@ -40,9 +40,9 @@ void TakeAnimationParticle::render(Tesselator* t, float a, float xa, float ya, double yy = yo + (yt - yo) * time; double zz = zo + (zt - zo) * time; - int xTile = GameMath::floor(xx); - int yTile = GameMath::floor(yy + heightOffset / 2.0f); - int zTile = GameMath::floor(zz); + int xTile = Mth::floor(xx); + int yTile = Mth::floor(yy + heightOffset / 2.0f); + int zTile = Mth::floor(zz); // 4J - change brought forward from 1.8.2 if (SharedConstants::TEXTURE_LIGHTING) { diff --git a/minecraft/Minecraft.Client/net/minecraft/client/particle/WaterDropParticle.cpp b/minecraft/Minecraft.Client/net/minecraft/client/particle/WaterDropParticle.cpp index dfda8fadd..93aa00677 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/particle/WaterDropParticle.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/particle/WaterDropParticle.cpp @@ -43,11 +43,11 @@ void WaterDropParticle::tick() { } Material* m = - level->getMaterial(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); + level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)); if (m->isLiquid() || m->isSolid()) { - double y0 = GameMath::floor(y) + 1 - + double y0 = Mth::floor(y) + 1 - LiquidTile::getHeight(level->getData( - GameMath::floor(x), GameMath::floor(y), GameMath::floor(z))); + Mth::floor(x), Mth::floor(y), Mth::floor(z))); if (y < y0) { remove(); } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/player/LocalPlayer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/player/LocalPlayer.cpp index 9daa9a502..136b707e5 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/player/LocalPlayer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/player/LocalPlayer.cpp @@ -39,7 +39,7 @@ #include "nbt/com.mojang.nbt.h" #include "java/Random.h" #include "Minecraft.World/net/minecraft/world/level/tile/entity/TileEntity.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "../gui/achievement/AchievementPopup.h" #include "../particle/CritParticle.h" @@ -1094,9 +1094,9 @@ bool LocalPlayer::isSolidBlock(int x, int y, int z) { } bool LocalPlayer::checkInTile(double x, double y, double z) { - int xTile = GameMath::floor(x); - int yTile = GameMath::floor(y); - int zTile = GameMath::floor(z); + int xTile = Mth::floor(x); + int yTile = Mth::floor(y); + int zTile = Mth::floor(z); double xd = x - xTile; double zd = z - zTile; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/player/RemotePlayer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/player/RemotePlayer.cpp index 2c500ba55..6d5ffbcb2 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/player/RemotePlayer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/player/RemotePlayer.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "RemotePlayer.h" #include "Minecraft.World/net/minecraft/world/item/net.minecraft.world.item.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.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 = GameMath::sqrt(xxd * xxd + zzd * zzd) * 4; + float wst = Mth::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)GameMath::sqrt(xd * xd + zd * zd); + float tBob = (float)Mth::sqrt(xd * xd + zd * zd); float tTilt = (float)atan(-yd * 0.2f) * 15.0f; if (tBob > 0.1f) tBob = 0.1f; if (!onGround || getHealth() <= 0) tBob = 0; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/GameRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/GameRenderer.cpp index 6712eb6a7..efba87130 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/GameRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/GameRenderer.cpp @@ -212,9 +212,9 @@ void GameRenderer::tick(bool first) // 4J - add bFirst mc->cameraTargetPlayer = std::dynamic_pointer_cast(mc->player); } - float brr = mc->level->getBrightness(GameMath::floor(mc->cameraTargetPlayer->x), - GameMath::floor(mc->cameraTargetPlayer->y), - GameMath::floor(mc->cameraTargetPlayer->z)); + float brr = mc->level->getBrightness(Mth::floor(mc->cameraTargetPlayer->x), + Mth::floor(mc->cameraTargetPlayer->y), + Mth::floor(mc->cameraTargetPlayer->z)); float whiteness = (3 - mc->options->viewDistance) / 3.0f; float fogBrT = brr * (1 - whiteness) + whiteness; fogBr += (fogBrT - fogBr) * 0.1f; @@ -450,12 +450,12 @@ void GameRenderer::moveCameraToPlayer(float a) { glTranslatef(0.0f, 0.3f, 0); if (!mc->options->fixedCamera) { int t = - mc->level->getTile(GameMath::floor(player->x), GameMath::floor(player->y), - GameMath::floor(player->z)); + mc->level->getTile(Mth::floor(player->x), Mth::floor(player->y), + Mth::floor(player->z)); if (t == Tile::bed_Id) { - int data = mc->level->getData(GameMath::floor(player->x), - GameMath::floor(player->y), - GameMath::floor(player->z)); + int data = mc->level->getData(Mth::floor(player->x), + Mth::floor(player->y), + Mth::floor(player->z)); int direction = data & 3; glRotatef((float)direction * 90, 0.0f, 1.0f, 0.0f); @@ -1522,9 +1522,9 @@ void GameRenderer::tickRain() { std::shared_ptr player = mc->cameraTargetPlayer; Level* level = mc->level; - int x0 = GameMath::floor(player->x); - int y0 = GameMath::floor(player->y); - int z0 = GameMath::floor(player->z); + int x0 = Mth::floor(player->x); + int y0 = Mth::floor(player->y); + int z0 = Mth::floor(player->z); int r = 10; @@ -1575,9 +1575,9 @@ void GameRenderer::tickRain() { rainSoundTime = 0; MemSect(24); if (rainPosY > player->y + 1 && - level->getTopRainBlock(GameMath::floor(player->x), - GameMath::floor(player->z)) > - GameMath::floor(player->y)) { + level->getTopRainBlock(Mth::floor(player->x), + Mth::floor(player->z)) > + Mth::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 = GameMath::sqrt(xa * xa + za * za); + float d = Mth::sqrt(xa * xa + za * za); rainXa[z << 5 | x] = -za / d; rainZa[z << 5 | x] = xa / d; } @@ -1618,9 +1618,9 @@ void GameRenderer::renderSnowAndRain(float a) { std::shared_ptr player = mc->cameraTargetPlayer; Level* level = mc->level; - int x0 = GameMath::floor(player->x); - int y0 = GameMath::floor(player->y); - int z0 = GameMath::floor(player->z); + int x0 = Mth::floor(player->x); + int y0 = Mth::floor(player->y); + int z0 = Mth::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 = GameMath::floor(yo); + int yMin = Mth::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)GameMath::sqrt(xd * xd + zd * zd) / r; + float dd = (float)Mth::sqrt(xd * xd + zd * zd) / r; float br = 1.0f; float s = 1.0f; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/ItemInHandRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/ItemInHandRenderer.cpp index 2c6d8ac40..356fd14c0 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/ItemInHandRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/ItemInHandRenderer.cpp @@ -432,13 +432,13 @@ void ItemInHandRenderer::render(float a) { std::shared_ptr item = selectedItem; float br = minecraft->level->getBrightness( - GameMath::floor(player->x), GameMath::floor(player->y), GameMath::floor(player->z)); + Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z)); // 4J - change brought forward from 1.8.2 if (SharedConstants::TEXTURE_LIGHTING) { br = 1; - int col = minecraft->level->getLightColor(GameMath::floor(player->x), - GameMath::floor(player->y), - GameMath::floor(player->z), 0); + int col = minecraft->level->getLightColor(Mth::floor(player->x), + Mth::floor(player->y), + Mth::floor(player->z), 0); int u = col % 65536; int v = col / 65536; #if defined(__linux__) @@ -603,7 +603,7 @@ void ItemInHandRenderer::render(float a) { is = is * is * is; float iss = 1 - is; glTranslatef(0, - GameMath::abs(cosf(t / 4 * std::numbers::pi) * 0.1f) * + Mth::abs(cosf(t / 4 * std::numbers::pi) * 0.1f) * (swing > 0.2 ? 1 : 0), 0); glTranslatef(iss * 0.6f, -iss * 0.5f, 0); @@ -769,9 +769,9 @@ void ItemInHandRenderer::renderScreenEffect(float a) { if (minecraft->player->isInWall()) // Inside a tile { - int x = GameMath::floor(minecraft->player->x); - int y = GameMath::floor(minecraft->player->y); - int z = GameMath::floor(minecraft->player->z); + int x = Mth::floor(minecraft->player->x); + int y = Mth::floor(minecraft->player->y); + int z = Mth::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 = GameMath::floor(x + xo); - int yt = GameMath::floor(y + yo); - int zt = GameMath::floor(z + zo); + int xt = Mth::floor(x + xo); + int yt = Mth::floor(y + yo); + int zt = Mth::floor(z + zo); if (minecraft->level->isSolidBlockingTile(xt, yt, zt)) { tile = minecraft->level->getTile(xt, yt, zt); } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/LevelRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/LevelRenderer.cpp index 735cf1eff..7cda3c9dc 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/LevelRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/LevelRenderer.cpp @@ -499,8 +499,8 @@ void LevelRenderer::allChanged(int playerIndex) { if (level[playerIndex] != nullptr) { std::shared_ptr player = mc->cameraTargetPlayer; if (player != nullptr) { - this->resortChunks(GameMath::floor(player->x), GameMath::floor(player->y), - GameMath::floor(player->z)); + this->resortChunks(Mth::floor(player->x), Mth::floor(player->y), + Mth::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(GameMath::floor(entity->x), 0, - GameMath::floor(entity->z))) { + if (!level[playerIndex]->hasChunkAt(Mth::floor(entity->x), 0, + Mth::floor(entity->z))) { continue; } renderedEntities++; @@ -731,8 +731,8 @@ int LevelRenderer::render(std::shared_ptr player, int layer, yOld[playerIndex] = player->y; zOld[playerIndex] = player->z; - resortChunks(GameMath::floor(player->x), GameMath::floor(player->y), - GameMath::floor(player->z)); + resortChunks(Mth::floor(player->x), Mth::floor(player->y), + Mth::floor(player->z)); // sort(sortedChunks[playerIndex]->begin(),sortedChunks[playerIndex]->end(), // DistanceChunkSorter(player)); // 4J - removed - not sorting // our chunks anymore @@ -1176,8 +1176,8 @@ void LevelRenderer::renderClouds(float alpha) { double zo = mc->cameraTargetPlayer->zo + (mc->cameraTargetPlayer->z - mc->cameraTargetPlayer->zo) * alpha; - int xOffs = GameMath::floor(xo / 2048); - int zOffs = GameMath::floor(zo / 2048); + int xOffs = Mth::floor(xo / 2048); + int zOffs = Mth::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 = GameMath::floor(xo / 2048); - int zOffs = GameMath::floor(zo / 2048); + int xOffs = Mth::floor(xo / 2048); + int zOffs = Mth::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)(GameMath::floor(xo)) * scale; - vo = (float)(GameMath::floor(zo)) * scale; + uo = (float)(Mth::floor(xo)) * scale; + vo = (float)(Mth::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 - GameMath::floor(xo)); - float zoffs = (float)(zo - GameMath::floor(zo)); + float xoffs = (float)(xo - Mth::floor(xo)); + float zoffs = (float)(zo - Mth::floor(zo)); int D = 8; @@ -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 = 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); + 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); for (int x = _x0; x <= _x1; x++) { for (int y = _y0; y <= _y1; y++) { @@ -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 = (GameMath::intFloorDiv(x, CHUNK_XZSIZE)) + + int xx = (Mth::intFloorDiv(x, CHUNK_XZSIZE)) + (MAX_LEVEL_RENDER_SIZE[dimIdx] / 2); - int yy = GameMath::intFloorDiv(y, CHUNK_SIZE); - int zz = (GameMath::intFloorDiv(z, CHUNK_XZSIZE)) + + int yy = Mth::intFloorDiv(y, CHUNK_SIZE); + int zz = (Mth::intFloorDiv(z, CHUNK_XZSIZE)) + (MAX_LEVEL_RENDER_SIZE[dimIdx] / 2); if ((xx < 0) || (xx >= MAX_LEVEL_RENDER_SIZE[dimIdx])) return -1; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/culling/ViewportCuller.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/culling/ViewportCuller.cpp index 10883f5e3..dea9e9be3 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/culling/ViewportCuller.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/culling/ViewportCuller.cpp @@ -1,6 +1,6 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "ViewportCuller.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" ViewportCuller::Face::Face(double x, double y, double z, float yRot, float xRot) { diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ArrowRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ArrowRenderer.cpp index 3f457e390..3a01c3651 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ArrowRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ArrowRenderer.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "ArrowRenderer.h" #include "Minecraft.World/net/minecraft/world/entity/projectile/net.minecraft.world.entity.projectile.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" ResourceLocation ArrowRenderer::ARROW_LOCATION = ResourceLocation(TN_ITEM_ARROWS); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/BoatRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/BoatRenderer.cpp index fc4721e00..f61779792 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/BoatRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/BoatRenderer.cpp @@ -2,7 +2,7 @@ #include "BoatRenderer.h" #include "../../model/BoatModel.h" #include "Minecraft.World/net/minecraft/world/entity/item/net.minecraft.world.entity.item.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" ResourceLocation BoatRenderer::BOAT_LOCATION = ResourceLocation(TN_ITEM_BOAT); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ChickenRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ChickenRenderer.cpp index 926b05eb2..cf9b9bcb7 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ChickenRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ChickenRenderer.cpp @@ -1,5 +1,5 @@ #include "Minecraft.World/Header Files/stdafx.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "ChickenRenderer.h" #include "Minecraft.World/net/minecraft/world/entity/animal/net.minecraft.world.entity.animal.h" diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/CreeperRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/CreeperRenderer.cpp index 88260a71c..073e71522 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/CreeperRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/CreeperRenderer.cpp @@ -2,7 +2,7 @@ #include "CreeperRenderer.h" #include "../../model/CreeperModel.h" #include "Minecraft.World/net/minecraft/world/entity/monster/net.minecraft.world.entity.monster.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" ResourceLocation CreeperRenderer::POWER_LOCATION = ResourceLocation(TN_POWERED_CREEPER); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderDispatcher.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderDispatcher.cpp index f87ad696d..b7009bca6 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderDispatcher.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderDispatcher.cpp @@ -224,12 +224,12 @@ void EntityRenderDispatcher::prepare( this->crosshairPickMob = crosshairPickMob; if (player->isSleeping()) { - int t = level->getTile(GameMath::floor(player->x), GameMath::floor(player->y), - GameMath::floor(player->z)); + int t = level->getTile(Mth::floor(player->x), Mth::floor(player->y), + Mth::floor(player->z)); if (t == Tile::bed_Id) { int data = - level->getData(GameMath::floor(player->x), GameMath::floor(player->y), - GameMath::floor(player->z)); + level->getData(Mth::floor(player->x), Mth::floor(player->y), + Mth::floor(player->z)); int direction = data & 3; playerRotY = (float)(direction * 90 + 180); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderer.cpp index c9cd09ac0..b83161cef 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderer.cpp @@ -10,7 +10,7 @@ #include "Minecraft.World/net/minecraft/world/entity/net.minecraft.world.entity.h" #include "Minecraft.World/net/minecraft/world/level/Level.h" #include "Minecraft.World/net/minecraft/world/phys/AABB.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "Minecraft.World/net/minecraft/world/entity/animal/net.minecraft.world.entity.animal.h" ResourceLocation EntityRenderer::SHADOW_LOCATION = @@ -175,12 +175,12 @@ void EntityRenderer::renderShadow(std::shared_ptr e, double x, double y, } double ez = e->zOld + (e->z - e->zOld) * a; - int x0 = 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); + 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); double xo = x - ex; double yo = y - ey; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ExperienceOrbRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ExperienceOrbRenderer.cpp index 69fd7e7c3..eaf3a0093 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ExperienceOrbRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ExperienceOrbRenderer.cpp @@ -5,7 +5,7 @@ #include "Minecraft.World/net/minecraft/world/item/net.minecraft.world.item.h" #include "../Tesselator.h" #include "EntityRenderDispatcher.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "java/JavaMath.h" ResourceLocation ExperienceOrbRenderer::XP_ORB_LOCATION = diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FallingTileRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FallingTileRenderer.cpp index fe26c90f6..00999b033 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FallingTileRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FallingTileRenderer.cpp @@ -39,28 +39,28 @@ void FallingTileRenderer::render(std::shared_ptr _tile, double x, tileRenderer->level = level; Tesselator* t = Tesselator::getInstance(); t->begin(); - t->offset(-GameMath::floor(tile->x) - 0.5f, -GameMath::floor(tile->y) - 0.5f, - -GameMath::floor(tile->z) - 0.5f); + t->offset(-Mth::floor(tile->x) - 0.5f, -Mth::floor(tile->y) - 0.5f, + -Mth::floor(tile->z) - 0.5f); tileRenderer->tesselateAnvilInWorld( - (AnvilTile*)tt, GameMath::floor(tile->x), GameMath::floor(tile->y), - GameMath::floor(tile->z), tile->data); + (AnvilTile*)tt, Mth::floor(tile->x), Mth::floor(tile->y), + Mth::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(-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(-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(0, 0, 0); t->end(); } else if (tt != nullptr) { tileRenderer->setShape(tt); - tileRenderer->renderBlock(tt, level, GameMath::floor(tile->x), - GameMath::floor(tile->y), GameMath::floor(tile->z), + tileRenderer->renderBlock(tt, level, Mth::floor(tile->x), + Mth::floor(tile->y), Mth::floor(tile->z), tile->data); } glEnable(GL_LIGHTING); diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FishingHookRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FishingHookRenderer.cpp index 237e50309..ff3ff64b3 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FishingHookRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/FishingHookRenderer.cpp @@ -5,7 +5,7 @@ #include "Minecraft.World/net/minecraft/world/entity/projectile/net.minecraft.world.entity.projectile.h" #include "Minecraft.World/net/minecraft/world/entity/player/net.minecraft.world.entity.player.h" #include "Minecraft.World/net/minecraft/world/phys/Vec3.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "../../multiplayer/MultiPlayerLocalPlayer.h" ResourceLocation FishingHookRenderer::PARTICLE_LOCATION = diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemFrameRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemFrameRenderer.cpp index 193910be0..681d634bc 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemFrameRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemFrameRenderer.cpp @@ -179,7 +179,7 @@ void ItemFrameRenderer::drawItem(std::shared_ptr entity) { ct->rota = 0; ct->updateFromPosition( entity->level, entity->x, entity->z, - GameMath::wrapDegrees((float)(180 + entity->dir * 90)), false, true); + Mth::wrapDegrees((float)(180 + entity->dir * 90)), false, true); ct->rot = compassRot; ct->rota = compassRotA; } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemRenderer.cpp index 57525026c..e538ae4d2 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/ItemRenderer.cpp @@ -58,7 +58,7 @@ void ItemRenderer::render(std::shared_ptr _itemEntity, double x, sinf((itemEntity->age + a) / 10.0f + itemEntity->bobOffs) * 0.1f + 0.1f; float spin = - ((itemEntity->age + a) / 20.0f + itemEntity->bobOffs) * GameMath::RAD_TO_DEG; + ((itemEntity->age + a) / 20.0f + itemEntity->bobOffs) * Mth::RAD_TO_DEG; int count = 1; if (itemEntity->getItem()->count > 1) count = 2; @@ -211,7 +211,7 @@ void ItemRenderer::renderItemBillboard(std::shared_ptr entity, glRotatef(180, 0, 1, 0); } else { glRotatef( - ((entity->age + a) / 20.0f + entity->bobOffs) * GameMath::RAD_TO_DEG, 0, + ((entity->age + a) / 20.0f + entity->bobOffs) * Mth::RAD_TO_DEG, 0, 1, 0); } diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/LivingEntityRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/LivingEntityRenderer.cpp index 08a1a1daa..782056a4d 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/LivingEntityRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/LivingEntityRenderer.cpp @@ -6,7 +6,7 @@ #include "EntityRenderDispatcher.h" #include "../../multiplayer/MultiPlayerLocalPlayer.h" #include "Minecraft.World/net/minecraft/world/entity/projectile/Arrow.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "Minecraft.World/net/minecraft/world/entity/player/Player.h" ResourceLocation LivingEntityRenderer::ENCHANT_GLINT_LOCATION = @@ -53,7 +53,7 @@ void LivingEntityRenderer::render(std::shared_ptr _mob, double x, std::dynamic_pointer_cast(mob->riding); bodyRot = rotlerp(riding->yBodyRotO, riding->yBodyRot, a); - float headDiff = GameMath::wrapDegrees(headRot - bodyRot); + float headDiff = Mth::wrapDegrees(headRot - bodyRot); if (headDiff < -85) headDiff = -85; if (headDiff >= 85) headDiff = +85; bodyRot = headRot - headDiff; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/MobRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/MobRenderer.cpp index a1102ce57..d13a11c0d 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/MobRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/MobRenderer.cpp @@ -6,7 +6,7 @@ #include "Minecraft.World/net/minecraft/world/entity/player/net.minecraft.world.entity.player.h" #include "Minecraft.World/net/minecraft/world/entity/projectile/net.minecraft.world.entity.projectile.h" #include "Minecraft.World/ConsoleHelpers/StringHelpers.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "EntityRenderDispatcher.h" MobRenderer::MobRenderer(Model* model, float shadow) @@ -37,9 +37,9 @@ void MobRenderer::renderLeash(std::shared_ptr entity, double x, double y, y -= (1.6 - entity->bbHeight) * .5; Tesselator* tessellator = Tesselator::getInstance(); double roperYRot = - lerp(roper->yRotO, roper->yRot, a * .5f) * GameMath::DEG_TO_RAD; + lerp(roper->yRotO, roper->yRot, a * .5f) * Mth::DEG_TO_RAD; double roperXRot = - lerp(roper->xRotO, roper->xRot, a * .5f) * GameMath::DEG_TO_RAD; + lerp(roper->xRotO, roper->xRot, a * .5f) * Mth::DEG_TO_RAD; double rotOffCos = cos(roperYRot); double rotOffSin = sin(roperYRot); double yOff = sin(roperXRot); @@ -58,7 +58,7 @@ void MobRenderer::renderLeash(std::shared_ptr entity, double x, double y, (rotOffCos * 0.5 * swingOff); double entityYRot = - lerp(entity->yBodyRotO, entity->yBodyRot, a) * GameMath::DEG_TO_RAD + + lerp(entity->yBodyRotO, entity->yBodyRot, a) * Mth::DEG_TO_RAD + std::numbers::pi * .5; rotOffCos = cos(entityYRot) * entity->bbWidth * .4; rotOffSin = sin(entityYRot) * entity->bbWidth * .4; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/PaintingRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/PaintingRenderer.cpp index 9bd21b7ec..3445354f8 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/PaintingRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/entity/PaintingRenderer.cpp @@ -4,7 +4,7 @@ #include "Minecraft.World/net/minecraft/world/entity/net.minecraft.world.entity.h" #include "Minecraft.World/net/minecraft/world/level/net.minecraft.world.level.h" #include "java/Random.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" ResourceLocation PaintingRenderer::PAINTING_LOCATION(TN_ART_KZ); @@ -118,13 +118,13 @@ void PaintingRenderer::renderPainting(std::shared_ptr painting, int w, void PaintingRenderer::setBrightness(std::shared_ptr painting, float ss, float ya) { - int x = 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 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 col = this->entityRenderDispatcher->level->getLightColor(x, y, z, 0); int u = col % 65536; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/EnchantTableRenderer.cpp b/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/EnchantTableRenderer.cpp index 03b5cce9b..289e613a2 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/EnchantTableRenderer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/renderer/tileentity/EnchantTableRenderer.cpp @@ -1,7 +1,7 @@ #include "Minecraft.World/Header Files/stdafx.h" #include "../../model/BookModel.h" #include "Minecraft.World/net/minecraft/world/level/tile/entity/net.minecraft.world.level.tile.entity.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "EnchantTableRenderer.h" ResourceLocation EnchantTableRenderer::BOOK_LOCATION = @@ -36,8 +36,8 @@ void EnchantTableRenderer::render(std::shared_ptr _table, double x, float ff1 = table->oFlip + (table->flip - table->oFlip) * a + 0.25f; float ff2 = table->oFlip + (table->flip - table->oFlip) * a + 0.75f; - ff1 = (ff1 - GameMath::fastFloor(ff1)) * 1.6f - 0.3f; - ff2 = (ff2 - GameMath::fastFloor(ff2)) * 1.6f - 0.3f; + ff1 = (ff1 - Mth::fastFloor(ff1)) * 1.6f - 0.3f; + ff2 = (ff2 - Mth::fastFloor(ff2)) * 1.6f - 0.3f; if (ff1 < 0) ff1 = 0; if (ff2 < 0) ff2 = 0; diff --git a/minecraft/Minecraft.Client/net/minecraft/client/title/TitleScreen.cpp b/minecraft/Minecraft.Client/net/minecraft/client/title/TitleScreen.cpp index dcb5551dc..58d88a949 100644 --- a/minecraft/Minecraft.Client/net/minecraft/client/title/TitleScreen.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/client/title/TitleScreen.cpp @@ -391,7 +391,7 @@ 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 - GameMath::abs(sinf(System::currentTimeMillis() % 1000 / + float sss = 1.8f - Mth::abs(sinf(System::currentTimeMillis() % 1000 / 1000.0f * std::numbers::pi * 2) * 0.1f); diff --git a/minecraft/Minecraft.Client/net/minecraft/server/MinecraftServer.cpp b/minecraft/Minecraft.Client/net/minecraft/server/MinecraftServer.cpp index 30900ffd7..5c2a6113c 100644 --- a/minecraft/Minecraft.Client/net/minecraft/server/MinecraftServer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/server/MinecraftServer.cpp @@ -206,7 +206,7 @@ bool MinecraftServer::initServer(int64_t seed, NetworkGameInitData* initData, settings->getInt(L"max-build-height", Level::maxBuildHeight)); setMaxBuildHeight(((getMaxBuildHeight() + 8) / 16) * 16); setMaxBuildHeight( - GameMath::clamp(getMaxBuildHeight(), 64, Level::maxBuildHeight)); + Mth::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 = GameMath::abs(x - spawnPos->x); - int zd = GameMath::abs(z - spawnPos->z); + int xd = Mth::abs(x - spawnPos->x); + int zd = Mth::abs(z - spawnPos->z); int dist = std::max(xd, zd); return dist <= getSpawnProtectionRadius(); diff --git a/minecraft/Minecraft.Client/net/minecraft/server/PlayerList.cpp b/minecraft/Minecraft.Client/net/minecraft/server/PlayerList.cpp index 96709c756..250b3e538 100644 --- a/minecraft/Minecraft.Client/net/minecraft/server/PlayerList.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/server/PlayerList.cpp @@ -373,17 +373,17 @@ void PlayerList::validatePlayerSpawnPosition( double targetX = 0; if (player->x < 0) - targetX = GameMath::ceil(player->x) - 0.5; + targetX = Mth::ceil(player->x) - 0.5; else - targetX = GameMath::floor(player->x) + 0.5; + targetX = Mth::floor(player->x) + 0.5; double targetY = floor(player->y); double targetZ = 0; if (player->z < 0) - targetZ = GameMath::ceil(player->z) - 0.5; + targetZ = Mth::ceil(player->z) - 0.5; else - targetZ = GameMath::floor(player->z) + 0.5; + targetZ = Mth::floor(player->z) + 0.5; player->setPos(targetX, targetY, targetZ); @@ -956,9 +956,9 @@ void PlayerList::repositionAcrossDimension(std::shared_ptr entity, } if (lastDimension != 1) { - xt = (double)GameMath::clamp((int)xt, -Level::MAX_LEVEL_SIZE + 128, + xt = (double)Mth::clamp((int)xt, -Level::MAX_LEVEL_SIZE + 128, Level::MAX_LEVEL_SIZE - 128); - zt = (double)GameMath::clamp((int)zt, -Level::MAX_LEVEL_SIZE + 128, + zt = (double)Mth::clamp((int)zt, -Level::MAX_LEVEL_SIZE + 128, Level::MAX_LEVEL_SIZE - 128); if (entity->isAlive()) { newLevel->addEntity(entity); diff --git a/minecraft/Minecraft.Client/net/minecraft/server/level/EntityTracker.cpp b/minecraft/Minecraft.Client/net/minecraft/server/level/EntityTracker.cpp index f07f00515..83aec65e8 100644 --- a/minecraft/Minecraft.Client/net/minecraft/server/level/EntityTracker.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/server/level/EntityTracker.cpp @@ -5,7 +5,7 @@ #include "TrackedEntity.h" #include "ServerPlayer.h" #include "ServerLevel.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "Minecraft.World/net/minecraft/world/entity/net.minecraft.world.entity.h" #include "Minecraft.World/net/minecraft/world/entity/item/net.minecraft.world.entity.item.h" #include "Minecraft.World/net/minecraft/world/entity/monster/net.minecraft.world.entity.monster.h" diff --git a/minecraft/Minecraft.Client/net/minecraft/server/level/ServerLevel.cpp b/minecraft/Minecraft.Client/net/minecraft/server/level/ServerLevel.cpp index 66369b919..f6bbd39f5 100644 --- a/minecraft/Minecraft.Client/net/minecraft/server/level/ServerLevel.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/server/level/ServerLevel.cpp @@ -32,7 +32,7 @@ #include "Minecraft.World/net/minecraft/world/entity/item/PrimedTnt.h" #include "Minecraft.World/net/minecraft/world/entity/item/FallingTile.h" #include "Minecraft.World/net/minecraft/network/packet/net.minecraft.network.packet.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "Minecraft.World/net/minecraft/world/level/levelgen/structure/StructurePiece.h" #include "ServerLevelListener.h" #include "Minecraft.World/net/minecraft/util/WeighedTreasure.h" diff --git a/minecraft/Minecraft.Client/net/minecraft/server/level/ServerPlayer.cpp b/minecraft/Minecraft.Client/net/minecraft/server/level/ServerPlayer.cpp index a3cfdec00..46ffb7d08 100644 --- a/minecraft/Minecraft.Client/net/minecraft/server/level/ServerPlayer.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/server/level/ServerPlayer.cpp @@ -1663,7 +1663,7 @@ int ServerPlayer::getViewDistance() { return viewDistance; } // } Pos* ServerPlayer::getCommandSenderWorldPosition() { - return new Pos(GameMath::floor(x), GameMath::floor(y + .5), GameMath::floor(z)); + return new Pos(Mth::floor(x), Mth::floor(y + .5), Mth::floor(z)); } void ServerPlayer::resetLastActionTime() { diff --git a/minecraft/Minecraft.Client/net/minecraft/server/level/TrackedEntity.cpp b/minecraft/Minecraft.Client/net/minecraft/server/level/TrackedEntity.cpp index 750fb95c7..272d03c00 100644 --- a/minecraft/Minecraft.Client/net/minecraft/server/level/TrackedEntity.cpp +++ b/minecraft/Minecraft.Client/net/minecraft/server/level/TrackedEntity.cpp @@ -2,7 +2,7 @@ #include "TrackedEntity.h" #include "ServerPlayer.h" #include "../network/PlayerConnection.h" -#include "Minecraft.World/net/minecraft/util/GameMath.h" +#include "Minecraft.World/net/minecraft/util/Mth.h" #include "Minecraft.World/net/minecraft/world/entity/net.minecraft.world.entity.h" #include "Minecraft.World/net/minecraft/world/entity/item/net.minecraft.world.entity.item.h" #include "Minecraft.World/net/minecraft/world/entity/monster/net.minecraft.world.entity.monster.h" @@ -39,13 +39,13 @@ TrackedEntity::TrackedEntity(std::shared_ptr e, int range, this->updateInterval = updateInterval; this->trackDelta = trackDelta; - xp = GameMath::floor(e->x * 32); - yp = GameMath::floor(e->y * 32); - zp = GameMath::floor(e->z * 32); + xp = Mth::floor(e->x * 32); + yp = Mth::floor(e->y * 32); + zp = Mth::floor(e->z * 32); - yRotp = GameMath::floor(e->yRot * 256 / 360); - xRotp = GameMath::floor(e->xRot * 256 / 360); - yHeadRotp = GameMath::floor(e->getYHeadRot() * 256 / 360); + yRotp = Mth::floor(e->yRot * 256 / 360); + xRotp = Mth::floor(e->xRot * 256 / 360); + yHeadRotp = Mth::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 = GameMath::floor(e->yRot * 256 / 360); - int xRotn = GameMath::floor(e->xRot * 256 / 360); + int yRotn = Mth::floor(e->yRot * 256 / 360); + int xRotn = Mth::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 = GameMath::floor(e->x * 32.0); - int yn = GameMath::floor(e->y * 32.0); - int zn = GameMath::floor(e->z * 32.0); + 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 xa = xn - xp; int ya = yn - yp; @@ -310,16 +310,16 @@ void TrackedEntity::tick(EntityTracker* tracker, xRotp = xRotn; } - xp = GameMath::floor(e->x * 32.0); - yp = GameMath::floor(e->y * 32.0); - zp = GameMath::floor(e->z * 32.0); + xp = Mth::floor(e->x * 32.0); + yp = Mth::floor(e->y * 32.0); + zp = Mth::floor(e->z * 32.0); sendDirtyEntityData(); wasRiding = true; } - int yHeadRot = GameMath::floor(e->getYHeadRot() * 256 / 360); + int yHeadRot = Mth::floor(e->getYHeadRot() * 256 / 360); if (abs(yHeadRot - yHeadRotp) >= TOLERANCE_LEVEL) { broadcast(std::shared_ptr( new RotateHeadPacket(e->entityId, (uint8_t)yHeadRot))); @@ -625,8 +625,8 @@ void TrackedEntity::updatePlayer(EntityTracker* tracker, std::shared_ptr( new EntityActionAtPositionPacket( e, EntityActionAtPositionPacket::START_SLEEP, - GameMath::floor(e->x), GameMath::floor(e->y), - GameMath::floor(e->z)))); + Mth::floor(e->x), Mth::floor(e->y), + Mth::floor(e->z)))); } } @@ -681,7 +681,7 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { // 4J-PB - replacing with a switch, rather than tons of ifs if (std::dynamic_pointer_cast(e) != nullptr) { - yHeadRotp = GameMath::floor(e->getYHeadRot() * 256 / 360); + yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360); return std::shared_ptr( new AddMobPacket(std::dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp)); @@ -717,7 +717,7 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { return std::shared_ptr(new AddEntityPacket( e, AddEntityPacket::BOAT, yRotp, xRotp, xp, yp, zp)); } else if (e->instanceof(eTYPE_ENDERDRAGON)) { - yHeadRotp = GameMath::floor(e->getYHeadRot() * 256 / 360); + yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360); return std::shared_ptr( new AddMobPacket(std::dynamic_pointer_cast(e), yRotp, xRotp, xp, yp, zp, yHeadRotp)); @@ -812,9 +812,9 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { std::shared_ptr( new AddEntityPacket(e, AddEntityPacket::ITEM_FRAME, frame->dir, yRotp, xRotp, xp, yp, zp)); - packet->x = GameMath::floor(frame->xTile * 32.0f); - packet->y = GameMath::floor(frame->yTile * 32.0f); - packet->z = GameMath::floor(frame->zTile * 32.0f); + packet->x = Mth::floor(frame->xTile * 32.0f); + packet->y = Mth::floor(frame->yTile * 32.0f); + packet->z = Mth::floor(frame->zTile * 32.0f); return packet; } else if (e->instanceof(eTYPE_LEASHFENCEKNOT)) { std::shared_ptr knot = @@ -822,9 +822,9 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { std::shared_ptr packet = std::shared_ptr(new AddEntityPacket( e, AddEntityPacket::LEASH_KNOT, yRotp, xRotp, xp, yp, zp)); - packet->x = GameMath::floor((float)knot->xTile * 32); - packet->y = GameMath::floor((float)knot->yTile * 32); - packet->z = GameMath::floor((float)knot->zTile * 32); + packet->x = Mth::floor((float)knot->xTile * 32); + packet->y = Mth::floor((float)knot->yTile * 32); + packet->z = Mth::floor((float)knot->zTile * 32); return packet; } else if (e->instanceof(eTYPE_EXPERIENCEORB)) { return std::shared_ptr( diff --git a/minecraft/Minecraft.World/Header Files/stdafx.h b/minecraft/Minecraft.World/Header Files/stdafx.h index 97b9a99cc..a1e4bb5e2 100644 --- a/minecraft/Minecraft.World/Header Files/stdafx.h +++ b/minecraft/Minecraft.World/Header Files/stdafx.h @@ -47,7 +47,7 @@ #include "../ConsoleHelpers/Definitions.h" #include "java/Class.h" #include "java/Exceptions.h" -#include "../net/minecraft/util/GameMath.h" +#include "../net/minecraft/util/Mth.h" #include "../ConsoleHelpers/StringHelpers.h" #include "../ConsoleHelpers/ArrayWithLength.h" #include "java/Random.h" diff --git a/minecraft/Minecraft.World/net/minecraft/Direction.cpp b/minecraft/Minecraft.World/net/minecraft/Direction.cpp index 5131c4c0b..ca3ece296 100644 --- a/minecraft/Minecraft.World/net/minecraft/Direction.cpp +++ b/minecraft/Minecraft.World/net/minecraft/Direction.cpp @@ -39,7 +39,7 @@ int Direction::RELATIVE_DIRECTION_FACING[4][6] = { Facing::NORTH}}; int Direction::getDirection(double xd, double zd) { - if (GameMath::abs((float)xd) > GameMath::abs((float)zd)) { + if (Mth::abs((float)xd) > Mth::abs((float)zd)) { if (xd > 0) { return WEST; } else { diff --git a/minecraft/Minecraft.World/net/minecraft/network/packet/AddExperienceOrbPacket.cpp b/minecraft/Minecraft.World/net/minecraft/network/packet/AddExperienceOrbPacket.cpp index 1de478c29..60e2b762b 100644 --- a/minecraft/Minecraft.World/net/minecraft/network/packet/AddExperienceOrbPacket.cpp +++ b/minecraft/Minecraft.World/net/minecraft/network/packet/AddExperienceOrbPacket.cpp @@ -13,9 +13,9 @@ AddExperienceOrbPacket::AddExperienceOrbPacket() { AddExperienceOrbPacket::AddExperienceOrbPacket( std::shared_ptr e) { id = e->entityId; - x = GameMath::floor(e->x * 32); - y = GameMath::floor(e->y * 32); - z = GameMath::floor(e->z * 32); + x = Mth::floor(e->x * 32); + y = Mth::floor(e->y * 32); + z = Mth::floor(e->z * 32); value = e->getValue(); } diff --git a/minecraft/Minecraft.World/net/minecraft/network/packet/AddGlobalEntityPacket.cpp b/minecraft/Minecraft.World/net/minecraft/network/packet/AddGlobalEntityPacket.cpp index 287a20712..680715f55 100644 --- a/minecraft/Minecraft.World/net/minecraft/network/packet/AddGlobalEntityPacket.cpp +++ b/minecraft/Minecraft.World/net/minecraft/network/packet/AddGlobalEntityPacket.cpp @@ -19,9 +19,9 @@ AddGlobalEntityPacket::AddGlobalEntityPacket() { AddGlobalEntityPacket::AddGlobalEntityPacket(std::shared_ptr e) { id = e->entityId; - x = GameMath::floor(e->x * 32); - y = GameMath::floor(e->y * 32); - z = GameMath::floor(e->z * 32); + x = Mth::floor(e->x * 32); + y = Mth::floor(e->y * 32); + z = Mth::floor(e->z * 32); if (e->instanceof(eTYPE_LIGHTNINGBOLT)) { type = LIGHTNING; } else { diff --git a/minecraft/Minecraft.World/net/minecraft/network/packet/AddMobPacket.cpp b/minecraft/Minecraft.World/net/minecraft/network/packet/AddMobPacket.cpp index 71e2e024d..f75dcb52e 100644 --- a/minecraft/Minecraft.World/net/minecraft/network/packet/AddMobPacket.cpp +++ b/minecraft/Minecraft.World/net/minecraft/network/packet/AddMobPacket.cpp @@ -26,9 +26,9 @@ AddMobPacket::AddMobPacket(std::shared_ptr mob, int yRotp, type = EntityIO::getId(mob); // 4J Stu - We should add entities at their "last sent" position so that the // relative update packets put them in the correct place - x = xp; // GameMath::floor(mob->x * 32); - y = yp; // GameMath::floor(mob->y * 32); - z = zp; // GameMath::floor(mob->z * 32); + x = xp; // Mth::floor(mob->x * 32); + y = yp; // Mth::floor(mob->y * 32); + z = zp; // Mth::floor(mob->z * 32); // 4J - changed - send current "previously sent" value of rotations to put // this in sync with other clients yRot = static_cast(yRotp); diff --git a/minecraft/Minecraft.World/net/minecraft/network/packet/AddPlayerPacket.cpp b/minecraft/Minecraft.World/net/minecraft/network/packet/AddPlayerPacket.cpp index c0e8e3739..b35dafa55 100644 --- a/minecraft/Minecraft.World/net/minecraft/network/packet/AddPlayerPacket.cpp +++ b/minecraft/Minecraft.World/net/minecraft/network/packet/AddPlayerPacket.cpp @@ -36,9 +36,9 @@ AddPlayerPacket::AddPlayerPacket(std::shared_ptr player, PlayerUID xuid, // 4J Stu - Send "previously sent" value of position as well so that we stay // in sync - x = xp; // GameMath::floor(player->x * 32); - y = yp; // GameMath::floor(player->y * 32); - z = zp; // GameMath::floor(player->z * 32); + x = xp; // Mth::floor(player->x * 32); + y = yp; // Mth::floor(player->y * 32); + z = zp; // Mth::floor(player->z * 32); // 4J - changed - send current "previously sent" value of rotations to put // this in sync with other clients yRot = yRotp; diff --git a/minecraft/Minecraft.World/net/minecraft/network/packet/TeleportEntityPacket.cpp b/minecraft/Minecraft.World/net/minecraft/network/packet/TeleportEntityPacket.cpp index 67399c60e..6e1bdc75f 100644 --- a/minecraft/Minecraft.World/net/minecraft/network/packet/TeleportEntityPacket.cpp +++ b/minecraft/Minecraft.World/net/minecraft/network/packet/TeleportEntityPacket.cpp @@ -16,9 +16,9 @@ TeleportEntityPacket::TeleportEntityPacket() { TeleportEntityPacket::TeleportEntityPacket(std::shared_ptr e) { id = e->entityId; - x = GameMath::floor(e->x * 32); - y = GameMath::floor(e->y * 32); - z = GameMath::floor(e->z * 32); + x = Mth::floor(e->x * 32); + y = Mth::floor(e->y * 32); + z = Mth::floor(e->z * 32); yRot = (uint8_t)(e->yRot * 256 / 360); xRot = (uint8_t)(e->xRot * 256 / 360); } diff --git a/minecraft/Minecraft.World/net/minecraft/util/GameMath.cpp b/minecraft/Minecraft.World/net/minecraft/util/Mth.cpp similarity index 82% rename from minecraft/Minecraft.World/net/minecraft/util/GameMath.cpp rename to minecraft/Minecraft.World/net/minecraft/util/Mth.cpp index 720d636ec..12be62186 100644 --- a/minecraft/Minecraft.World/net/minecraft/util/GameMath.cpp +++ b/minecraft/Minecraft.World/net/minecraft/util/Mth.cpp @@ -1,5 +1,5 @@ #include "../../../Header Files/stdafx.h" -#include "GameMath.h" +#include "Mth.h" #include "java/Random.h" #include "../../../ConsoleHelpers/StringHelpers.h" @@ -18,19 +18,19 @@ static std::array makeSinTable() { static const std::array sinTable = makeSinTable(); -float GameMath::sin(float i) { +float Mth::sin(float i) { return sinTable[(int32_t)::fmodf(i * SIN_SCALE, (float)SIN_TAB_CNT) & (SIN_TAB_CNT - 1)]; } -float GameMath::cos(float i) { +float Mth::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) { +std::wstring Mth::createInsecureUUID(Random* random) { wchar_t output[33]; output[32] = 0; int64_t high = (random->nextLong() & ~UUID_VERSION) | UUID_VERSION_TYPE_4; @@ -50,24 +50,24 @@ std::wstring GameMath::createInsecureUUID(Random* random) { return std::wstring(output); } -int GameMath::getInt(const std::wstring& input, int def) { +int Mth::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 Mth::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) { +double Mth::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 Mth::getDouble(const std::wstring& input, double def, double min) { double result = getDouble(input, def); return result < min ? min : result; } diff --git a/minecraft/Minecraft.World/net/minecraft/util/GameMath.h b/minecraft/Minecraft.World/net/minecraft/util/Mth.h similarity index 99% rename from minecraft/Minecraft.World/net/minecraft/util/GameMath.h rename to minecraft/Minecraft.World/net/minecraft/util/Mth.h index 9b7f773b5..014160203 100644 --- a/minecraft/Minecraft.World/net/minecraft/util/GameMath.h +++ b/minecraft/Minecraft.World/net/minecraft/util/Mth.h @@ -2,7 +2,7 @@ class Random; -class GameMath { +class Mth { public: static constexpr float DEG_TO_RAD = std::numbers::pi_v / 180.0f; static constexpr float RAD_TO_DEG = 180.0f / std::numbers::pi_v; diff --git a/minecraft/Minecraft.World/net/minecraft/world/damageSource/CombatTracker.cpp b/minecraft/Minecraft.World/net/minecraft/world/damageSource/CombatTracker.cpp index 7b09def9d..00591cc99 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/damageSource/CombatTracker.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/damageSource/CombatTracker.cpp @@ -19,7 +19,7 @@ void CombatTracker::prepareForDamage() { if (mob->onLadder()) { int type = mob->level->getTile( - GameMath::floor(mob->x), GameMath::floor(mob->bb.y0), GameMath::floor(mob->z)); + Mth::floor(mob->x), Mth::floor(mob->bb.y0), Mth::floor(mob->z)); if (type == Tile::ladder->id) { nextLocation = eLocation_LADDER; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/Entity.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/Entity.cpp index bfc7c5edb..188b23579 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/Entity.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/Entity.cpp @@ -334,7 +334,7 @@ void Entity::_init(bool useSmallId, Level* level) { portalEntranceDir = 0; invulnerable = false; if (useSmallId) { - uuid = L"ent" + GameMath::createInsecureUUID(random); + uuid = L"ent" + Mth::createInsecureUUID(random); } // 4J Added @@ -542,9 +542,9 @@ void Entity::baseTick() { } if (isSprinting() && !isInWater() && canCreateParticles()) { - int xt = GameMath::floor(x); - int yt = GameMath::floor(y - 0.2f - heightOffset); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(y - 0.2f - heightOffset); + int zt = Mth::floor(z); int t = level->getTile(xt, yt, zt); int d = level->getData(xt, yt, zt); if (t > 0) { @@ -725,8 +725,8 @@ void Entity::move(double xa, double ya, double za, // 4J Stu - Particles (and possibly other entities) don't have xChunk and // zChunk set, so calculate the chunk instead - int xc = GameMath::floor(x / 16); - int zc = GameMath::floor(z / 16); + int xc = Mth::floor(x / 16); + int zc = Mth::floor(z / 16); if (!level->isClientSide || level->reallyHasChunk(xc, zc)) { // 4J Stu - It's horrible that the client is doing any movement at all! // But if we don't have the chunk data then all the collision info will @@ -853,9 +853,9 @@ void Entity::move(double xa, double ya, double za, double zm = z - zo; if (makeStepSound() && !isPlayerSneaking && riding == nullptr) { - int xt = GameMath::floor(x); - int yt = GameMath::floor(y - 0.2f - heightOffset); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(y - 0.2f - heightOffset); + int zt = Mth::floor(z); int t = level->getTile(xt, yt, zt); if (t == 0) { int renderShape = level->getTileRenderShape(xt, yt - 1, zt); @@ -869,14 +869,14 @@ void Entity::move(double xa, double ya, double za, ym = 0; } - walkDist += GameMath::sqrt(xm * xm + zm * zm) * 0.6; - moveDist += GameMath::sqrt(xm * xm + ym * ym + zm * zm) * 0.6; + walkDist += Mth::sqrt(xm * xm + zm * zm) * 0.6; + moveDist += Mth::sqrt(xm * xm + ym * ym + zm * zm) * 0.6; if (moveDist > nextStep && t > 0) { nextStep = (int)moveDist + 1; if (isInWater()) { float speed = - GameMath::sqrt(xd * xd * 0.2f + yd * yd + zd * zd * 0.2f) * + Mth::sqrt(xd * xd * 0.2f + yd * yd + zd * zd * 0.2f) * 0.35f; if (speed > 1) speed = 1; playSound( @@ -912,12 +912,12 @@ void Entity::move(double xa, double ya, double za, } void Entity::checkInsideTiles() { - int x0 = GameMath::floor(bb.x0 + 0.001); - int y0 = GameMath::floor(bb.y0 + 0.001); - int z0 = GameMath::floor(bb.z0 + 0.001); - int x1 = GameMath::floor(bb.x1 - 0.001); - int y1 = GameMath::floor(bb.y1 - 0.001); - int z1 = GameMath::floor(bb.z1 - 0.001); + int x0 = Mth::floor(bb.x0 + 0.001); + int y0 = Mth::floor(bb.y0 + 0.001); + int z0 = Mth::floor(bb.z0 + 0.001); + int x1 = Mth::floor(bb.x1 - 0.001); + int y1 = Mth::floor(bb.y1 - 0.001); + int z1 = Mth::floor(bb.z1 - 0.001); if (level->hasChunksAt(x0, y0, z0, x1, y1, z1)) { for (int x = x0; x <= x1; x++) @@ -992,9 +992,9 @@ void Entity::causeFallDamage(float distance) { bool Entity::isInWaterOrRain() { return wasInWater || - (level->isRainingAt(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)) || - level->isRainingAt(GameMath::floor(x), GameMath::floor(y + bbHeight), - GameMath::floor(z))); + (level->isRainingAt(Mth::floor(x), Mth::floor(y), Mth::floor(z)) || + level->isRainingAt(Mth::floor(x), Mth::floor(y + bbHeight), + Mth::floor(z))); } bool Entity::isInWater() { return wasInWater; } @@ -1005,13 +1005,13 @@ bool Entity::updateInWaterState() { shared_from_this())) { if (!wasInWater && !firstTick && canCreateParticles()) { float speed = - GameMath::sqrt(xd * xd * 0.2f + yd * yd + zd * zd * 0.2f) * 0.2f; + Mth::sqrt(xd * xd * 0.2f + yd * yd + zd * zd * 0.2f) * 0.2f; if (speed > 1) speed = 1; MemSect(31); playSound(eSoundType_RANDOM_SPLASH, speed, 1 + (random->nextFloat() - random->nextFloat()) * 0.4f); MemSect(0); - float yt = (float)GameMath::floor(bb.y0); + float yt = (float)Mth::floor(bb.y0); for (int i = 0; i < 1 + bbWidth * 20; i++) { float xo = (random->nextFloat() * 2 - 1) * bbWidth; float zo = (random->nextFloat() * 2 - 1) * bbWidth; @@ -1036,10 +1036,10 @@ bool Entity::updateInWaterState() { bool Entity::isUnderLiquid(Material* material) { double yp = y + getHeadHeight(); - int xt = GameMath::floor(x); - int yt = GameMath::floor( + int xt = Mth::floor(x); + int yt = Mth::floor( yp); // 4J - this used to be a nested pair of floors for some reason - int zt = GameMath::floor(z); + int zt = Mth::floor(z); int t = level->getTile(xt, yt, zt); if (t != 0 && Tile::tiles[t]->material == material) { float hh = LiquidTile::getHeight(level->getData(xt, yt, zt)) - 1 / 9.0f; @@ -1075,12 +1075,12 @@ void Entity::moveRelative(float xa, float za, float speed) { // 4J - change brought forward from 1.8.2 int Entity::getLightColor(float a) { - int xTile = GameMath::floor(x); - int zTile = GameMath::floor(z); + int xTile = Mth::floor(x); + int zTile = Mth::floor(z); if (level->hasChunkAt(xTile, 0, zTile)) { double hh = (bb.y1 - bb.y0) * 0.66; - int yTile = GameMath::floor(y - heightOffset + hh); + int yTile = Mth::floor(y - heightOffset + hh); return level->getLightColor(xTile, yTile, zTile, 0); } return 0; @@ -1088,11 +1088,11 @@ int Entity::getLightColor(float a) { // 4J - changes brought forward from 1.8.2 float Entity::getBrightness(float a) { - int xTile = GameMath::floor(x); - int zTile = GameMath::floor(z); + int xTile = Mth::floor(x); + int zTile = Mth::floor(z); if (level->hasChunkAt(xTile, 0, zTile)) { double hh = (bb.y1 - bb.y0) * 0.66; - int yTile = GameMath::floor(y - heightOffset + hh); + int yTile = Mth::floor(y - heightOffset + hh); return level->getBrightness(xTile, yTile, zTile); } return 0; @@ -1415,9 +1415,9 @@ bool Entity::isInWall() { float xo = ((i >> 0) % 2 - 0.5f) * bbWidth * 0.8f; float yo = ((i >> 1) % 2 - 0.5f) * 0.1f; float zo = ((i >> 2) % 2 - 0.5f) * bbWidth * 0.8f; - int xt = GameMath::floor(x + xo); - int yt = GameMath::floor(y + getHeadHeight() + yo); - int zt = GameMath::floor(z + zo); + int xt = Mth::floor(x + xo); + int yt = Mth::floor(y + getHeadHeight() + yo); + int zt = Mth::floor(z + zo); if (level->isSolidBlockingTile(xt, yt, zt)) { return true; } @@ -1659,9 +1659,9 @@ void Entity::thunderHit(const LightningBolt* lightningBolt) { void Entity::killed(std::shared_ptr mob) {} bool Entity::checkInTile(double x, double y, double z) { - int xTile = GameMath::floor(x); - int yTile = GameMath::floor(y); - int zTile = GameMath::floor(z); + int xTile = Mth::floor(x); + int yTile = Mth::floor(y); + int zTile = Mth::floor(z); double xd = x - (xTile); double yd = y - (yTile); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/EntityPos.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/EntityPos.cpp index 7e5468659..72981740f 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/EntityPos.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/EntityPos.cpp @@ -36,11 +36,11 @@ EntityPos* EntityPos::lerp(std::shared_ptr e, float f) { double yd = e->y + (y - e->y) * f; double zd = e->z + (z - e->z) * f; - float yrdd = GameMath::wrapDegrees(yRot - e->yRot); - float xrdd = GameMath::wrapDegrees(xRot - e->xRot); + float yrdd = Mth::wrapDegrees(yRot - e->yRot); + float xrdd = Mth::wrapDegrees(xRot - e->xRot); - float yrd = GameMath::wrapDegrees(e->yRot + yrdd * f); - float xrd = GameMath::wrapDegrees(e->xRot + xrdd * f); + float yrd = Mth::wrapDegrees(e->yRot + yrdd * f); + float xrd = Mth::wrapDegrees(e->xRot + xrdd * f); if (rot && move) { return new EntityPos(xd, yd, zd, yrd, xrd); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ExperienceOrb.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ExperienceOrb.cpp index a996b68e9..240928c49 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ExperienceOrb.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ExperienceOrb.cpp @@ -76,7 +76,7 @@ void ExperienceOrb::tick() { zo = z; yd -= 0.03f; - if (level->getMaterial(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)) == + if (level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)) == Material::lava) { yd = 0.2f; xd = (random->nextFloat() - random->nextFloat()) * 0.2f; @@ -122,7 +122,7 @@ void ExperienceOrb::tick() { if (onGround) { friction = 0.6f * 0.98f; int t = - level->getTile(GameMath::floor(x), GameMath::floor(bb.y0) - 1, GameMath::floor(z)); + level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1, Mth::floor(z)); if (t > 0) { friction = Tile::tiles[t]->friction * 0.98f; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/FlyingMob.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/FlyingMob.cpp index 7d24d1fc2..8d3213217 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/FlyingMob.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/FlyingMob.cpp @@ -34,8 +34,8 @@ void FlyingMob::travel(float xa, float ya) { float friction = 0.91f; if (onGround) { friction = 0.6f * 0.91f; - int t = level->getTile(GameMath::floor(x), GameMath::floor(bb.y0) - 1, - GameMath::floor(z)); + int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1, + Mth::floor(z)); if (t > 0) { friction = Tile::tiles[t]->friction * 0.91f; } @@ -48,8 +48,8 @@ void FlyingMob::travel(float xa, float ya) { friction = 0.91f; if (onGround) { friction = 0.6f * 0.91f; - int t = level->getTile(GameMath::floor(x), GameMath::floor(bb.y0) - 1, - GameMath::floor(z)); + int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1, + Mth::floor(z)); if (t > 0) { friction = Tile::tiles[t]->friction * 0.91f; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/HangingEntity.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/HangingEntity.cpp index 8e900f597..3ed12ec66 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/HangingEntity.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/HangingEntity.cpp @@ -108,11 +108,11 @@ bool HangingEntity::survives() { int xt = xTile; int yt = yTile; int zt = zTile; - if (dir == Direction::NORTH) xt = GameMath::floor(x - getWidth() / 32.0f); - if (dir == Direction::WEST) zt = GameMath::floor(z - getWidth() / 32.0f); - if (dir == Direction::SOUTH) xt = GameMath::floor(x - getWidth() / 32.0f); - if (dir == Direction::EAST) zt = GameMath::floor(z - getWidth() / 32.0f); - yt = GameMath::floor(y - getHeight() / 32.0f); + if (dir == Direction::NORTH) xt = Mth::floor(x - getWidth() / 32.0f); + if (dir == Direction::WEST) zt = Mth::floor(z - getWidth() / 32.0f); + if (dir == Direction::SOUTH) xt = Mth::floor(x - getWidth() / 32.0f); + if (dir == Direction::EAST) zt = Mth::floor(z - getWidth() / 32.0f); + yt = Mth::floor(y - getHeight() / 32.0f); for (int ss = 0; ss < ws; ss++) { for (int yy = 0; yy < hs; yy++) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/LivingEntity.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/LivingEntity.cpp index b322c4636..33a77ad5f 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/LivingEntity.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/LivingEntity.cpp @@ -1,6 +1,6 @@ #include "../../../../Header Files/stdafx.h" #include "java/JavaMath.h" -#include "../../util/GameMath.h" +#include "../../util/Mth.h" #include "../../network/packet/net.minecraft.network.packet.h" #include "../level/net.minecraft.world.level.h" #include "../level/tile/net.minecraft.world.level.tile.h" @@ -155,9 +155,9 @@ void LivingEntity::checkFallDamage(double ya, bool onGround) { } if (onGround && fallDistance > 0) { - int xt = GameMath::floor(x); - int yt = GameMath::floor(y - 0.2f - heightOffset); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(y - 0.2f - heightOffset); + int zt = Mth::floor(z); int t = level->getTile(xt, yt, zt); if (t == 0) { int renderShape = level->getTileRenderShape(xt, yt - 1, zt); @@ -671,7 +671,7 @@ void LivingEntity::heal(float heal) { float LivingEntity::getHealth() { return entityData->getFloat(DATA_HEALTH_ID); } void LivingEntity::setHealth(float health) { - entityData->set(DATA_HEALTH_ID, GameMath::clamp(health, 0.0f, getMaxHealth())); + entityData->set(DATA_HEALTH_ID, Mth::clamp(health, 0.0f, getMaxHealth())); } bool LivingEntity::hurt(DamageSource* source, float dmg) { @@ -867,7 +867,7 @@ void LivingEntity::knockback(std::shared_ptr source, float dmg, } hasImpulse = true; - float dd = GameMath::sqrt(xd * xd + zd * zd); + float dd = Mth::sqrt(xd * xd + zd * zd); float pow = 0.4f; this->xd /= 2; @@ -897,9 +897,9 @@ void LivingEntity::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) { } bool LivingEntity::onLadder() { - int xt = GameMath::floor(x); - int yt = GameMath::floor(bb.y0); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(bb.y0); + int zt = Mth::floor(z); // 4J-PB - TU9 - add climbable vines int iTile = level->getTile(xt, yt, zt); @@ -925,9 +925,9 @@ void LivingEntity::causeFallDamage(float distance) { } hurt(DamageSource::fall, dmg); - int t = level->getTile(GameMath::floor(x), - GameMath::floor(y - 0.2f - this->heightOffset), - GameMath::floor(z)); + int t = level->getTile(Mth::floor(x), + Mth::floor(y - 0.2f - this->heightOffset), + Mth::floor(z)); if (t > 0) { const Tile::SoundType* soundType = Tile::tiles[t]->soundType; MemSect(31); @@ -1214,7 +1214,7 @@ void LivingEntity::jumpFromGround() { yd += (getEffect(MobEffect::jump)->getAmplifier() + 1) * .1f; } if (isSprinting()) { - float rr = yRot * GameMath::DEG_TO_RAD; + float rr = yRot * Mth::DEG_TO_RAD; xd -= sinf(rr) * 0.2f; zd += cosf(rr) * 0.2f; @@ -1254,8 +1254,8 @@ void LivingEntity::travel(float xa, float ya) { float friction = 0.91f; if (onGround) { friction = 0.6f * 0.91f; - int t = level->getTile(GameMath::floor(x), GameMath::floor(bb.y0) - 1, - GameMath::floor(z)); + int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1, + Mth::floor(z)); if (t > 0) { friction = Tile::tiles[t]->friction * 0.91f; } @@ -1276,8 +1276,8 @@ void LivingEntity::travel(float xa, float ya) { friction = 0.91f; if (onGround) { friction = 0.6f * 0.91f; - int t = level->getTile(GameMath::floor(x), GameMath::floor(bb.y0) - 1, - GameMath::floor(z)); + int t = level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1, + Mth::floor(z)); if (t > 0) { friction = Tile::tiles[t]->friction * 0.91f; } @@ -1319,7 +1319,7 @@ void LivingEntity::travel(float xa, float ya) { walkAnimSpeedO = walkAnimSpeed; double xxd = x - xo; double zzd = z - zo; - float wst = GameMath::sqrt(xxd * xxd + zzd * zzd) * 4; + float wst = Mth::sqrt(xxd * xxd + zzd * zzd) * 4; if (wst > 1) wst = 1; walkAnimSpeed += (wst - walkAnimSpeed) * 0.4f; walkAnimPos += walkAnimSpeed; @@ -1333,12 +1333,12 @@ void LivingEntity::travel(float xa, float ya) { int LivingEntity::getLightColor(float a) { float accum[2] = {0, 0}; float totVol = (bb.x1 - bb.x0) * (bb.y1 - bb.y0) * (bb.z1 - bb.z0); - int xmin = GameMath::floor(bb.x0); - int xmax = GameMath::floor(bb.x1); - int ymin = GameMath::floor(bb.y0); - int ymax = GameMath::floor(bb.y1); - int zmin = GameMath::floor(bb.z0); - int zmax = GameMath::floor(bb.z1); + int xmin = Mth::floor(bb.x0); + int xmax = Mth::floor(bb.x1); + int ymin = Mth::floor(bb.y0); + int ymax = Mth::floor(bb.y1); + int zmin = Mth::floor(bb.z0); + int zmax = Mth::floor(bb.z1); for (int xt = xmin; xt <= xmax; xt++) for (int yt = ymin; yt <= ymax; yt++) for (int zt = zmin; zt <= zmax; zt++) { @@ -1466,10 +1466,10 @@ void LivingEntity::tick() { } float LivingEntity::tickHeadTurn(float yBodyRotT, float walkSpeed) { - float yBodyRotD = GameMath::wrapDegrees(yBodyRotT - yBodyRot); + float yBodyRotD = Mth::wrapDegrees(yBodyRotT - yBodyRot); yBodyRot += yBodyRotD * 0.3f; - float headDiff = GameMath::wrapDegrees(yRot - yBodyRot); + float headDiff = Mth::wrapDegrees(yRot - yBodyRot); bool behind = headDiff < -90 || headDiff >= 90; if (headDiff < -75) headDiff = -75; if (headDiff >= 75) headDiff = +75; @@ -1492,8 +1492,8 @@ void LivingEntity::aiStep() { double yt = y + (ly - y) / lSteps; double zt = z + (lz - z) / lSteps; - double yrd = GameMath::wrapDegrees(lyr - yRot); - double xrd = GameMath::wrapDegrees(lxr - xRot); + double yrd = Mth::wrapDegrees(lyr - yRot); + double xrd = Mth::wrapDegrees(lxr - xRot); yRot += (float)((yrd) / lSteps); xRot += (float)((xrd) / lSteps); @@ -1652,20 +1652,20 @@ std::optional LivingEntity::getLookAngle() { return getViewVector(1); } Vec3 LivingEntity::getViewVector(float a) { if (a == 1) { - float yCos = cosf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); - float ySin = sinf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); - float xCos = -cosf(-xRot * GameMath::DEG_TO_RAD); - float xSin = sinf(-xRot * GameMath::DEG_TO_RAD); + float yCos = cosf(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); + float ySin = sinf(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); + float xCos = -cosf(-xRot * Mth::DEG_TO_RAD); + float xSin = sinf(-xRot * Mth::DEG_TO_RAD); return Vec3(ySin * xCos, xSin, yCos * xCos); } float xRot = xRotO + (this->xRot - xRotO) * a; float yRot = yRotO + (this->yRot - yRotO) * a; - float yCos = cosf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); - float ySin = sinf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); - float xCos = -cosf(-xRot * GameMath::DEG_TO_RAD); - float xSin = sinf(-xRot * GameMath::DEG_TO_RAD); + float yCos = cosf(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); + float ySin = sinf(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); + float xCos = -cosf(-xRot * Mth::DEG_TO_RAD); + float xSin = sinf(-xRot * Mth::DEG_TO_RAD); return Vec3(ySin * xCos, xSin, yCos * xCos); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/Mob.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/Mob.cpp index d8baa385d..4b54f72b1 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/Mob.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/Mob.cpp @@ -501,7 +501,7 @@ void Mob::lookAt(std::shared_ptr e, float yMax, float xMax) { yd = (e->bb.y0 + e->bb.y1) / 2 - (y + getHeadHeight()); } - double sd = GameMath::sqrt(xd * xd + zd * zd); + double sd = Mth::sqrt(xd * xd + zd * zd); float yRotD = (float)(atan2(zd, xd) * 180 / std::numbers::pi) - 90; float xRotD = (float)-(atan2(yd, sd) * 180 / std::numbers::pi); @@ -514,7 +514,7 @@ bool Mob::isLookingAtAnEntity() { return lookingAt != nullptr; } std::shared_ptr Mob::getLookingAt() { return lookingAt; } float Mob::rotlerp(float a, float b, float max) { - float diff = GameMath::wrapDegrees(b - a); + float diff = Mth::wrapDegrees(b - a); if (diff > max) { diff = max; } @@ -886,9 +886,9 @@ void Mob::restoreLeashFromSave() { // resolve bug 10327 :Gameplay: NPCs can spawn over chunks that have not yet // been streamed and display jitter. bool Mob::shouldRender(Vec3* c) { - if (!level->reallyHasChunksAt(GameMath::floor(bb.x0), GameMath::floor(bb.y0), - GameMath::floor(bb.z0), GameMath::floor(bb.x1), - GameMath::floor(bb.y1), GameMath::floor(bb.z1))) { + if (!level->reallyHasChunksAt(Mth::floor(bb.x0), Mth::floor(bb.y0), + Mth::floor(bb.z0), Mth::floor(bb.x1), + Mth::floor(bb.y1), Mth::floor(bb.z1))) { return false; } return Entity::shouldRender(c); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/PathfinderMob.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/PathfinderMob.cpp index 471f74690..f7f2809bc 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/PathfinderMob.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/PathfinderMob.cpp @@ -110,7 +110,7 @@ void PathfinderMob::serverAiStep() { // protected. considerForExtraWandering(isDespawnProtected()); - int yFloor = GameMath::floor(bb.y0 + 0.5f); + int yFloor = Mth::floor(bb.y0 + 0.5f); bool inWater = isInWater(); bool inLava = isInLava(); @@ -140,7 +140,7 @@ void PathfinderMob::serverAiStep() { double zd = target->z - z; double yd = target->y - yFloor; float yRotD = (float)(atan2(zd, xd) * 180 / std::numbers::pi) - 90; - float rotDiff = GameMath::wrapDegrees(yRotD - yRot); + float rotDiff = Mth::wrapDegrees(yRotD - yRot); yya = (float)getAttribute(SharedMonsterAttributes::MOVEMENT_SPEED) ->getValue(); if (rotDiff > MAX_TURN) { @@ -191,15 +191,15 @@ void PathfinderMob::findRandomStrollLocation( // request that only stroll locations in one quadrant be found. If -1 is // passed then behaviour is the same as the java game int xt, zt; - int yt = GameMath::floor(y + random->nextInt(7) - 3); + int yt = Mth::floor(y + random->nextInt(7) - 3); if (quadrant == -1) { - xt = GameMath::floor(x + random->nextInt(13) - 6); - zt = GameMath::floor(z + random->nextInt(13) - 6); + xt = Mth::floor(x + random->nextInt(13) - 6); + zt = Mth::floor(z + random->nextInt(13) - 6); } else { int sx = ((quadrant & 1) ? -1 : 1); int sz = ((quadrant & 2) ? -1 : 1); - xt = GameMath::floor(x + random->nextInt(7) * sx); - zt = GameMath::floor(z + random->nextInt(7) * sz); + xt = Mth::floor(x + random->nextInt(7) * sx); + zt = Mth::floor(z + random->nextInt(7) * sz); } float value = getWalkTargetValue(xt, yt, zt); if (value > best) { @@ -226,9 +226,9 @@ std::shared_ptr PathfinderMob::findAttackTarget() { } bool PathfinderMob::canSpawn() { - int xt = GameMath::floor(x); - int yt = GameMath::floor(bb.y0); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(bb.y0); + int zt = Mth::floor(z); return this->Mob::canSpawn() && getWalkTargetValue(xt, yt, zt) >= 0; } @@ -249,7 +249,7 @@ void PathfinderMob::setAttackTarget(std::shared_ptr attacker) { // might move to navigation, might make area bool PathfinderMob::isWithinRestriction() { - return isWithinRestriction(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); + return isWithinRestriction(Mth::floor(x), Mth::floor(y), Mth::floor(z)); } bool PathfinderMob::isWithinRestriction(int x, int y, int z) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/BodyControl.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/BodyControl.cpp index a1bb38d99..db6da03a5 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/BodyControl.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/BodyControl.cpp @@ -43,7 +43,7 @@ void BodyControl::clientTick() { } float BodyControl::clamp(float clampTo, float clampFrom, float clampAngle) { - float headDiffBody = GameMath::wrapDegrees(clampTo - clampFrom); + float headDiffBody = Mth::wrapDegrees(clampTo - clampFrom); if (headDiffBody < -clampAngle) headDiffBody = -clampAngle; if (headDiffBody >= clampAngle) headDiffBody = +clampAngle; return clampTo - headDiffBody; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/LookControl.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/LookControl.cpp index 651c04241..da6984ef2 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/LookControl.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/LookControl.cpp @@ -56,7 +56,7 @@ void LookControl::tick() { mob->yHeadRot = rotlerp(mob->yHeadRot, mob->yBodyRot, 10); } - float headDiffBody = GameMath::wrapDegrees(mob->yHeadRot - mob->yBodyRot); + float headDiffBody = Mth::wrapDegrees(mob->yHeadRot - mob->yBodyRot); if (!mob->getNavigation()->isDone()) { // head clamped to body diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/MoveControl.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/MoveControl.cpp index f5aed5cfd..98f408804 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/MoveControl.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/control/MoveControl.cpp @@ -58,7 +58,7 @@ void MoveControl::tick() { } float MoveControl::rotlerp(float a, float b, float max) { - float diff = GameMath::wrapDegrees(b - a); + float diff = Mth::wrapDegrees(b - a); if (diff > max) { diff = max; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/ControlledByPlayerGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/ControlledByPlayerGoal.cpp index 42f39152e..326819505 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/ControlledByPlayerGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/ControlledByPlayerGoal.cpp @@ -46,17 +46,17 @@ void ControlledByPlayerGoal::tick() { std::dynamic_pointer_cast(mob->rider.lock()); PathfinderMob* pig = (PathfinderMob*)mob; - float yrd = GameMath::wrapDegrees(player->yRot - mob->yRot) * 0.5f; + float yrd = Mth::wrapDegrees(player->yRot - mob->yRot) * 0.5f; if (yrd > 5) yrd = 5; if (yrd < -5) yrd = -5; - mob->yRot = GameMath::wrapDegrees(mob->yRot + yrd); + mob->yRot = Mth::wrapDegrees(mob->yRot + yrd); if (speed < maxSpeed) speed += (maxSpeed - speed) * 0.01f; if (speed > maxSpeed) speed = maxSpeed; - int x = GameMath::floor(mob->x); - int y = GameMath::floor(mob->y); - int z = GameMath::floor(mob->z); + int x = Mth::floor(mob->x); + int y = Mth::floor(mob->y); + int z = Mth::floor(mob->z); float moveSpeed = speed; if (boosting) { if (boostTime++ > boostTimeTotal) { @@ -85,7 +85,7 @@ void ControlledByPlayerGoal::tick() { float xa = -(normMoveSpeed * sin); float za = normMoveSpeed * cos; - if (GameMath::abs(xa) > GameMath::abs(za)) { + if (Mth::abs(xa) > Mth::abs(za)) { if (xa < 0) xa -= mob->bbWidth / 2.0f; if (xa > 0) xa += mob->bbWidth / 2.0f; za = 0; @@ -95,12 +95,12 @@ void ControlledByPlayerGoal::tick() { if (za > 0) za += mob->bbWidth / 2.0f; } - int xt = GameMath::floor(mob->x + xa); - int zt = GameMath::floor(mob->z + za); + int xt = Mth::floor(mob->x + xa); + int zt = Mth::floor(mob->z + za); - Node* size = new Node(GameMath::floor(mob->bbWidth + 1), - GameMath::floor(mob->bbHeight + player->bbHeight + 1), - GameMath::floor(mob->bbWidth + 1)); + Node* size = new Node(Mth::floor(mob->bbWidth + 1), + Mth::floor(mob->bbHeight + player->bbHeight + 1), + Mth::floor(mob->bbWidth + 1)); if (x != xt || z != zt) { if (PathFinder::isFree(mob, xt, y, zt, size, false, false, true) == diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/DoorInteractGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/DoorInteractGoal.cpp index d179a4277..c153f1af8 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/DoorInteractGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/DoorInteractGoal.cpp @@ -33,9 +33,9 @@ bool DoorInteractGoal::canUse() { return true; } - doorX = GameMath::floor(mob->x); - doorY = GameMath::floor(mob->y + 1); - doorZ = GameMath::floor(mob->z); + doorX = Mth::floor(mob->x); + doorY = Mth::floor(mob->y + 1); + doorZ = Mth::floor(mob->z); doorTile = getDoorTile(doorX, doorY, doorZ); return doorTile != nullptr; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/EatTileGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/EatTileGoal.cpp index 186f83da8..6b2782a26 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/EatTileGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/EatTileGoal.cpp @@ -19,9 +19,9 @@ EatTileGoal::EatTileGoal(Mob* mob) { bool EatTileGoal::canUse() { if (mob->getRandom()->nextInt(mob->isBaby() ? 50 : 1000) != 0) return false; - int xx = GameMath::floor(mob->x); - int yy = GameMath::floor(mob->y); - int zz = GameMath::floor(mob->z); + int xx = Mth::floor(mob->x); + int yy = Mth::floor(mob->y); + int zz = Mth::floor(mob->z); if (level->getTile(xx, yy, zz) == Tile::tallgrass_Id && level->getData(xx, yy, zz) == TallGrass::TALL_GRASS) return true; @@ -46,9 +46,9 @@ void EatTileGoal::tick() { eatAnimationTick = std::max(0, eatAnimationTick - 1); if (eatAnimationTick != 4) return; - int xx = GameMath::floor(mob->x); - int yy = GameMath::floor(mob->y); - int zz = GameMath::floor(mob->z); + int xx = Mth::floor(mob->x); + int yy = Mth::floor(mob->y); + int zz = Mth::floor(mob->z); if (level->getTile(xx, yy, zz) == Tile::tallgrass_Id) { level->destroyTile(xx, yy, zz, false); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FleeSunGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FleeSunGoal.cpp index deb3291f8..8c7a442b6 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FleeSunGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FleeSunGoal.cpp @@ -17,8 +17,8 @@ FleeSunGoal::FleeSunGoal(PathfinderMob* mob, double speedModifier) { bool FleeSunGoal::canUse() { if (!level->isDay()) return false; if (!mob->isOnFire()) return false; - if (!level->canSeeSky(GameMath::floor(mob->x), (int)mob->bb.y0, - GameMath::floor(mob->z))) + if (!level->canSeeSky(Mth::floor(mob->x), (int)mob->bb.y0, + Mth::floor(mob->z))) return false; auto pos = getHidePos(); @@ -38,9 +38,9 @@ void FleeSunGoal::start() { std::optional FleeSunGoal::getHidePos() { Random* random = mob->getRandom(); for (int i = 0; i < 10; i++) { - int xt = GameMath::floor(mob->x + random->nextInt(20) - 10); - int yt = GameMath::floor(mob->bb.y0 + random->nextInt(6) - 3); - int zt = GameMath::floor(mob->z + random->nextInt(20) - 10); + int xt = Mth::floor(mob->x + random->nextInt(20) - 10); + int yt = Mth::floor(mob->bb.y0 + random->nextInt(6) - 3); + int zt = Mth::floor(mob->z + random->nextInt(20) - 10); if (!level->canSeeSky(xt, yt, zt) && mob->getWalkTargetValue(xt, yt, zt) < 0) return Vec3(xt, yt, zt); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.cpp index 84e7e2cf6..dfcc91b39 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/FollowOwnerGoal.cpp @@ -67,9 +67,9 @@ void FollowOwnerGoal::tick() { return; // find a good spawn position nearby the owner - int sx = GameMath::floor(owner.lock()->x) - 2; - int sz = GameMath::floor(owner.lock()->z) - 2; - int y = GameMath::floor(owner.lock()->bb.y0); + int sx = Mth::floor(owner.lock()->x) - 2; + int sz = Mth::floor(owner.lock()->z) - 2; + int y = Mth::floor(owner.lock()->bb.y0); for (int x = 0; x <= 4; x++) { for (int z = 0; z <= 4; z++) { if (x >= 1 && z >= 1 && x <= 3 && z <= 3) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MakeLoveGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MakeLoveGoal.cpp index 51f2126e7..8b541e5bd 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MakeLoveGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MakeLoveGoal.cpp @@ -23,9 +23,9 @@ bool MakeLoveGoal::canUse() { if (villager->getAge() != 0) return false; if (villager->getRandom()->nextInt(500) != 0) return false; - village = level->villages->getClosestVillage(GameMath::floor(villager->x), - GameMath::floor(villager->y), - GameMath::floor(villager->z), 0); + village = level->villages->getClosestVillage(Mth::floor(villager->x), + Mth::floor(villager->y), + Mth::floor(villager->z), 0); if (village.lock() == nullptr) return false; if (!villageNeedsMoreVillagers()) return false; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.cpp index 67854ba12..4aa25fadf 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MeleeAttackGoal.cpp @@ -52,8 +52,8 @@ bool MeleeAttackGoal::canContinueToUse() { if (target == nullptr) return false; if (!target->isAlive()) return false; if (!trackTarget) return !mob->getNavigation()->isDone(); - if (!mob->isWithinRestriction(GameMath::floor(target->x), GameMath::floor(target->y), - GameMath::floor(target->z))) + if (!mob->isWithinRestriction(Mth::floor(target->x), Mth::floor(target->y), + Mth::floor(target->z))) return false; return true; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveIndoorsGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveIndoorsGoal.cpp index ee1ade253..64967527c 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveIndoorsGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveIndoorsGoal.cpp @@ -23,10 +23,10 @@ bool MoveIndoorsGoal::canUse() { if (insideX != -1 && mob->distanceToSqr(insideX, mob->y, insideZ) < 2 * 2) return false; std::shared_ptr village = mob->level->villages->getClosestVillage( - GameMath::floor(mob->x), GameMath::floor(mob->y), GameMath::floor(mob->z), 14); + Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z), 14); if (village == nullptr) return false; std::shared_ptr _doorInfo = village->getBestDoorInfo( - GameMath::floor(mob->x), GameMath::floor(mob->y), GameMath::floor(mob->z)); + Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z)); doorInfo = _doorInfo; return _doorInfo != nullptr; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveThroughVillageGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveThroughVillageGoal.cpp index f8f1e0125..3a4be0632 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveThroughVillageGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/MoveThroughVillageGoal.cpp @@ -31,7 +31,7 @@ bool MoveThroughVillageGoal::canUse() { if (onlyAtNight && mob->level->isDay()) return false; std::shared_ptr village = mob->level->villages->getClosestVillage( - GameMath::floor(mob->x), GameMath::floor(mob->y), GameMath::floor(mob->z), 0); + Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z), 0); if (village == nullptr) return false; std::shared_ptr _doorInfo = getNextDoorInfo(village); @@ -93,8 +93,8 @@ std::shared_ptr MoveThroughVillageGoal::getNextDoorInfo( // for (DoorInfo di : doorInfos) for (auto it = doorInfos->begin(); it != doorInfos->end(); ++it) { std::shared_ptr di = *it; - int distSqr = di->distanceToSqr(GameMath::floor(mob->x), GameMath::floor(mob->y), - GameMath::floor(mob->z)); + int distSqr = di->distanceToSqr(Mth::floor(mob->x), Mth::floor(mob->y), + Mth::floor(mob->z)); if (distSqr < closestDistSqr) { if (hasVisited(di)) continue; closest = di; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RangedAttackGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RangedAttackGoal.cpp index f1d8b886f..96e196c83 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RangedAttackGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RangedAttackGoal.cpp @@ -87,17 +87,17 @@ void RangedAttackGoal::tick() { if (--attackTime == 0) { if (targetDistSqr > attackRadiusSqr || !canSee) return; - float dist = GameMath::sqrt(targetDistSqr) / attackRadius; + float dist = Mth::sqrt(targetDistSqr) / attackRadius; float power = dist; if (power < 0.1f) power = 0.1f; if (power > 1) power = 1; rangedAttackMob->performRangedAttack(target.lock(), power); - attackTime = GameMath::floor(dist * (attackIntervalMax - attackIntervalMin) + + attackTime = Mth::floor(dist * (attackIntervalMax - attackIntervalMin) + attackIntervalMin); } else if (attackTime < 0) { - float dist = GameMath::sqrt(targetDistSqr) / attackRadius; - attackTime = GameMath::floor(dist * (attackIntervalMax - attackIntervalMin) + + float dist = Mth::sqrt(targetDistSqr) / attackRadius; + attackTime = Mth::floor(dist * (attackIntervalMax - attackIntervalMin) + attackIntervalMin); } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RestrictOpenDoorGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RestrictOpenDoorGoal.cpp index 384aba37b..939cb14e5 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RestrictOpenDoorGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/RestrictOpenDoorGoal.cpp @@ -12,15 +12,15 @@ RestrictOpenDoorGoal::RestrictOpenDoorGoal(PathfinderMob* mob) { bool RestrictOpenDoorGoal::canUse() { if (mob->level->isDay()) return false; std::shared_ptr village = mob->level->villages->getClosestVillage( - GameMath::floor(mob->x), GameMath::floor(mob->y), GameMath::floor(mob->z), 16); + Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z), 16); if (village == nullptr) return false; std::shared_ptr _doorInfo = village->getClosestDoorInfo( - GameMath::floor(mob->x), GameMath::floor(mob->y), GameMath::floor(mob->z)); + Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z)); if (_doorInfo == nullptr) return false; doorInfo = _doorInfo; - return _doorInfo->distanceToInsideSqr(GameMath::floor(mob->x), - GameMath::floor(mob->y), - GameMath::floor(mob->z)) < 1.5 * 1.5; + return _doorInfo->distanceToInsideSqr(Mth::floor(mob->x), + Mth::floor(mob->y), + Mth::floor(mob->z)) < 1.5 * 1.5; } bool RestrictOpenDoorGoal::canContinueToUse() { @@ -28,7 +28,7 @@ bool RestrictOpenDoorGoal::canContinueToUse() { std::shared_ptr _doorInfo = doorInfo.lock(); if (_doorInfo == nullptr) return false; return !_doorInfo->removed && - _doorInfo->isInsideSide(GameMath::floor(mob->x), GameMath::floor(mob->z)); + _doorInfo->isInsideSide(Mth::floor(mob->x), Mth::floor(mob->z)); } void RestrictOpenDoorGoal::start() { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/target/TargetGoal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/target/TargetGoal.cpp index f43b19cef..7b98248fd 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/target/TargetGoal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/goal/target/TargetGoal.cpp @@ -87,8 +87,8 @@ bool TargetGoal::canAttack(std::shared_ptr target, return false; } - if (!mob->isWithinRestriction(GameMath::floor(target->x), GameMath::floor(target->y), - GameMath::floor(target->z))) + if (!mob->isWithinRestriction(Mth::floor(target->x), Mth::floor(target->y), + Mth::floor(target->z))) return false; if (mustSee && !mob->getSensing()->canSee(target)) return false; @@ -112,8 +112,8 @@ bool TargetGoal::canReach(std::shared_ptr target) { delete path; return false; } - int xx = last->x - GameMath::floor(target->x); - int zz = last->z - GameMath::floor(target->z); + int xx = last->x - Mth::floor(target->x); + int zz = last->z - Mth::floor(target->z); delete path; return xx * xx + zz * zz <= 1.5 * 1.5; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/navigation/PathNavigation.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/navigation/PathNavigation.cpp index d41fda994..392b04618 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/navigation/PathNavigation.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/navigation/PathNavigation.cpp @@ -59,15 +59,15 @@ float PathNavigation::getMaxDist() { return (float)dist->getValue(); } Path* PathNavigation::createPath(double x, double y, double z) { if (!canUpdatePath()) return nullptr; - return level->findPath(mob->shared_from_this(), GameMath::floor(x), (int)y, - GameMath::floor(z), getMaxDist(), _canPassDoors, + return level->findPath(mob->shared_from_this(), Mth::floor(x), (int)y, + Mth::floor(z), getMaxDist(), _canPassDoors, _canOpenDoors, avoidWater, canFloat); } bool PathNavigation::moveTo(double x, double y, double z, double speedModifier) { MemSect(52); - Path* newPath = createPath(GameMath::floor(x), (int)y, GameMath::floor(z)); + Path* newPath = createPath(Mth::floor(x), (int)y, Mth::floor(z)); MemSect(0); // No need to delete newPath here as this will be copied into the member // variable path and the class can assume responsibility for it @@ -193,12 +193,12 @@ int PathNavigation::getSurfaceY() { int surface = (int)(mob->bb.y0); int tileId = - level->getTile(GameMath::floor(mob->x), surface, GameMath::floor(mob->z)); + level->getTile(Mth::floor(mob->x), surface, Mth::floor(mob->z)); int steps = 0; while (tileId == Tile::water_Id || tileId == Tile::calmWater_Id) { ++surface; tileId = - level->getTile(GameMath::floor(mob->x), surface, GameMath::floor(mob->z)); + level->getTile(Mth::floor(mob->x), surface, Mth::floor(mob->z)); if (++steps > 16) return (int)(mob->bb.y0); } return surface; @@ -213,8 +213,8 @@ bool PathNavigation::isInLiquid() { } void PathNavigation::trimPathFromSun() { - if (level->canSeeSky(GameMath::floor(mob->x), (int)(mob->bb.y0 + 0.5), - GameMath::floor(mob->z))) + if (level->canSeeSky(Mth::floor(mob->x), (int)(mob->bb.y0 + 0.5), + Mth::floor(mob->z))) return; for (int i = 0; i < path->getSize(); ++i) { @@ -228,8 +228,8 @@ void PathNavigation::trimPathFromSun() { bool PathNavigation::canMoveDirectly(Vec3* startPos, Vec3* stopPos, int sx, int sy, int sz) { - int gridPosX = GameMath::floor(startPos->x); - int gridPosZ = GameMath::floor(startPos->z); + int gridPosX = Mth::floor(startPos->x); + int gridPosZ = Mth::floor(startPos->z); double dirX = stopPos->x - startPos->x; double dirZ = stopPos->z - startPos->z; @@ -260,8 +260,8 @@ bool PathNavigation::canMoveDirectly(Vec3* startPos, Vec3* stopPos, int sx, int stepX = dirX < 0 ? -1 : 1; int stepZ = dirZ < 0 ? -1 : 1; - int gridGoalX = GameMath::floor(stopPos->x); - int gridGoalZ = GameMath::floor(stopPos->z); + int gridGoalX = Mth::floor(stopPos->x); + int gridGoalZ = Mth::floor(stopPos->z); int currentDirX = gridGoalX - gridPosX; int currentDirZ = gridGoalZ - gridPosZ; while (currentDirX * stepX > 0 || currentDirZ * stepZ > 0) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/util/RandomPos.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/util/RandomPos.cpp index 033b7e938..a6476c848 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/util/RandomPos.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/util/RandomPos.cpp @@ -45,7 +45,7 @@ std::optional RandomPos::generateRandomPos( if (mob->hasRestriction()) { double restDist = mob->getRestrictCenter()->distSqr( - GameMath::floor(mob->x), GameMath::floor(mob->y), GameMath::floor(mob->z)) + + Mth::floor(mob->x), Mth::floor(mob->y), Mth::floor(mob->z)) + 4; double radius = mob->getRestrictRadius() + xzDist; bRestrict = restDist < radius * radius; @@ -70,9 +70,9 @@ std::optional RandomPos::generateRandomPos( if (dir != nullptr && xt * dir->x + zt * dir->z < 0) continue; - xt += GameMath::floor(mob->x); - yt += GameMath::floor(mob->y); - zt += GameMath::floor(mob->z); + xt += Mth::floor(mob->x); + yt += Mth::floor(mob->y); + zt += Mth::floor(mob->z); if (bRestrict && !mob->isWithinRestriction(xt, yt, zt)) continue; float value = mob->getWalkTargetValue(xt, yt, zt); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/village/Village.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/village/Village.cpp index af59f7d5c..b76565684 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ai/village/Village.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ai/village/Village.cpp @@ -345,7 +345,7 @@ int Village::getStanding(const std::wstring& playerName) { int Village::modifyStanding(const std::wstring& playerName, int delta) { int current = getStanding(playerName); - int newValue = GameMath::clamp(current + delta, -30, 10); + int newValue = Mth::clamp(current + delta, -30, 10); playerStanding.insert(std::pair(playerName, newValue)); return newValue; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/ambient/Bat.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/ambient/Bat.cpp index e60eb35bb..e38ba3315 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/ambient/Bat.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/ambient/Bat.cpp @@ -84,7 +84,7 @@ void Bat::tick() { if (isResting()) { xd = yd = zd = 0; - y = GameMath::floor(y) + 1.0 - bbHeight; + y = Mth::floor(y) + 1.0 - bbHeight; } else { yd *= .6f; } @@ -96,8 +96,8 @@ void Bat::newServerAiStep() { AmbientCreature::newServerAiStep(); if (isResting()) { - if (!level->isSolidBlockingTile(GameMath::floor(x), (int)y + 1, - GameMath::floor(z))) { + if (!level->isSolidBlockingTile(Mth::floor(x), (int)y + 1, + Mth::floor(z))) { setResting(false); level->levelEvent(nullptr, LevelEvent::SOUND_BAT_LIFTOFF, (int)x, (int)y, (int)z, 0); @@ -138,13 +138,13 @@ void Bat::newServerAiStep() { zd = zd + (signum(dz) * .5f - zd) * .1f; float yRotD = (float)(atan2(zd, xd) * 180 / std::numbers::pi) - 90; - float rotDiff = GameMath::wrapDegrees(yRotD - yRot); + float rotDiff = Mth::wrapDegrees(yRotD - yRot); yya = .5f; yRot += rotDiff; if (random->nextInt(100) == 0 && - level->isSolidBlockingTile(GameMath::floor(x), (int)y + 1, - GameMath::floor(z))) { + level->isSolidBlockingTile(Mth::floor(x), (int)y + 1, + Mth::floor(z))) { setResting(true); } } @@ -185,11 +185,11 @@ void Bat::addAdditonalSaveData(CompoundTag* entityTag) { } bool Bat::canSpawn() { - int yt = GameMath::floor(bb.y0); + int yt = Mth::floor(bb.y0); if (yt >= level->seaLevel) return false; - int xt = GameMath::floor(x); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int zt = Mth::floor(z); int br = level->getRawBrightness(xt, yt, zt); int maxLight = 4; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Animal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Animal.cpp index 1a549deb2..e8dae6994 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Animal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Animal.cpp @@ -267,9 +267,9 @@ std::shared_ptr Animal::findAttackTarget() { } bool Animal::canSpawn() { - int xt = GameMath::floor(x); - int yt = GameMath::floor(bb.y0); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(bb.y0); + int zt = Mth::floor(z); return level->getTile(xt, yt - 1, zt) == Tile::grass_Id && level->getDaytimeRawBrightness(xt, yt, zt) > 8 && AgableMob::canSpawn(); @@ -403,8 +403,8 @@ void Animal::updateDespawnProtectedState() { if (level->isClientSide) return; if (m_isDespawnProtected) { - int xt = GameMath::floor(x); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int zt = Mth::floor(z); if (xt > m_maxWanderX) m_maxWanderX = xt; if (xt < m_minWanderX) m_minWanderX = xt; @@ -433,8 +433,8 @@ bool Animal::isDespawnProtected() { return m_isDespawnProtected; } void Animal::setDespawnProtected() { if (level && level->isClientSide) return; - int xt = GameMath::floor(x); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int zt = Mth::floor(z); m_minWanderX = xt; m_maxWanderX = xt; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/EntityHorse.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/EntityHorse.cpp index 9a5cd22c1..bdbde7abe 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/EntityHorse.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/EntityHorse.cpp @@ -265,7 +265,7 @@ int EntityHorse::getTemper() { return temper; } void EntityHorse::setTemper(int temper) { this->temper = temper; } int EntityHorse::modifyTemper(int amount) { - int temper = GameMath::clamp(getTemper() + amount, 0, getMaxTemper()); + int temper = Mth::clamp(getTemper() + amount, 0, getMaxTemper()); setTemper(temper); return temper; @@ -297,8 +297,8 @@ bool EntityHorse::isPushable() { return rider.lock() == nullptr; } // TODO: [EB]: Explain why this is being done - what side effect does getBiome // have? bool EntityHorse::checkSpawningBiome() { - int x = GameMath::floor(this->x); - int z = GameMath::floor(this->z); + int x = Mth::floor(this->x); + int z = Mth::floor(this->z); level->getBiome(x, z); return true; @@ -331,7 +331,7 @@ void EntityHorse::causeFallDamage(float fallDistance) { playSound(eSoundType_MOB_HORSE_LAND, .4f, 1); } - int dmg = GameMath::ceil(fallDistance * .5f - 3.0f); + int dmg = Mth::ceil(fallDistance * .5f - 3.0f); if (dmg <= 0) return; hurt(DamageSource::fall, dmg); @@ -340,8 +340,8 @@ void EntityHorse::causeFallDamage(float fallDistance) { rider.lock()->hurt(DamageSource::fall, dmg); } - int id = level->getTile(GameMath::floor(x), GameMath::floor(y - 0.2 - yRotO), - GameMath::floor(z)); + int id = level->getTile(Mth::floor(x), Mth::floor(y - 0.2 - yRotO), + Mth::floor(z)); if (id > 0) { const Tile::SoundType* stepsound = Tile::tiles[id]->soundType; level->playEntitySound(shared_from_this(), stepsound->getStepSound(), @@ -906,8 +906,8 @@ void EntityHorse::aiStep() { if (!isEating() && rider.lock() == nullptr && random->nextInt(300) == 0) { - if (level->getTile(GameMath::floor(x), GameMath::floor(y) - 1, - GameMath::floor(z)) == Tile::grass_Id) { + if (level->getTile(Mth::floor(x), Mth::floor(y) - 1, + Mth::floor(z)) == Tile::grass_Id) { setEating(true); } } @@ -1146,7 +1146,7 @@ void EntityHorse::travel(float xa, float ya) { walkAnimSpeedO = walkAnimSpeed; double dx = x - xo; double dz = z - zo; - float wst = GameMath::sqrt(dx * dx + dz * dz) * 4.0f; + float wst = Mth::sqrt(dx * dx + dz * dz) * 4.0f; if (wst > 1.0f) { wst = 1.0f; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/MushroomCow.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/MushroomCow.cpp index 421cd5d99..26ef3fd2b 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/MushroomCow.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/MushroomCow.cpp @@ -66,9 +66,9 @@ bool MushroomCow::mobInteract(std::shared_ptr player) { // now spawn on mycelium as well as grass - seems a bit odd that they don't // already really bool MushroomCow::canSpawn() { - int xt = GameMath::floor(x); - int yt = GameMath::floor(bb.y0); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(bb.y0); + int zt = Mth::floor(z); return (level->getTile(xt, yt - 1, zt) == Tile::grass_Id || level->getTile(xt, yt - 1, zt) == Tile::mycel_Id) && level->getDaytimeRawBrightness(xt, yt, zt) > 8 && diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp index 7a6675e2f..9075ef905 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Ocelot.cpp @@ -243,9 +243,9 @@ bool Ocelot::canSpawn() { if (level->isUnobstructed(&bb) && level->getCubes(shared_from_this(), &bb)->empty() && !level->containsAnyLiquid(&bb)) { - int xt = GameMath::floor(x); - int yt = GameMath::floor(bb.y0); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(bb.y0); + int zt = Mth::floor(z); if (yt < level->seaLevel) { return false; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/SnowMan.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/SnowMan.cpp index 7120eca24..7f8c74d98 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/SnowMan.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/SnowMan.cpp @@ -53,17 +53,17 @@ void SnowMan::aiStep() { if (isInWaterOrRain()) hurt(DamageSource::drown, 1); { - int xx = GameMath::floor(x); - int zz = GameMath::floor(z); + int xx = Mth::floor(x); + int zz = Mth::floor(z); if (level->getBiome(xx, zz)->getTemperature() > 1) { hurt(DamageSource::onFire, 1); } } for (int i = 0; i < 4; i++) { - int xx = GameMath::floor(x + (i % 2 * 2 - 1) * 0.25f); - int yy = GameMath::floor(y); - int zz = GameMath::floor(z + ((i / 2) % 2 * 2 - 1) * 0.25f); + int xx = Mth::floor(x + (i % 2 * 2 - 1) * 0.25f); + int yy = Mth::floor(y); + int zz = Mth::floor(z + ((i / 2) % 2 * 2 - 1) * 0.25f); if (level->getTile(xx, yy, zz) == 0) { if (level->getBiome(xx, zz)->getTemperature() < 0.8f) { if (Tile::topSnow->mayPlace(level, xx, yy, zz)) { @@ -91,7 +91,7 @@ void SnowMan::performRangedAttack(std::shared_ptr target, double xd = target->x - x; double yd = (target->y + target->getHeadHeight() - 1.1f) - snowball->y; double zd = target->z - z; - float yo = GameMath::sqrt(xd * xd + zd * zd) * 0.2f; + float yo = Mth::sqrt(xd * xd + zd * zd) * 0.2f; snowball->shoot(xd, yd + yo, zd, 1.60f, 12); playSound(eSoundType_RANDOM_BOW, 1.0f, diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Squid.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Squid.cpp index 8f667276f..36db47333 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Squid.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/Squid.cpp @@ -119,7 +119,7 @@ void Squid::aiStep() { ((-(float)atan2(horizontalMovement, yd) * 180 / std::numbers::pi) - xBodyRot) * 0.1f; } else { - tentacleAngle = GameMath::abs(sinf(tentacleMovement)) * std::numbers::pi * 0.25f; + tentacleAngle = Mth::abs(sinf(tentacleMovement)) * std::numbers::pi * 0.25f; if (!level->isClientSide) { // unable to move, apply gravity diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/VillagerGolem.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/VillagerGolem.cpp index 6c3131cb6..8445636ed 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/animal/VillagerGolem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/animal/VillagerGolem.cpp @@ -62,7 +62,7 @@ void VillagerGolem::serverAiMobStep() { if (--villageUpdateInterval <= 0) { villageUpdateInterval = 70 + random->nextInt(50); std::shared_ptr _village = level->villages->getClosestVillage( - GameMath::floor(x), GameMath::floor(y), GameMath::floor(z), Villages::MaxDoorDist); + Mth::floor(x), Mth::floor(y), Mth::floor(z), Villages::MaxDoorDist); village = _village; if (_village == nullptr) clearRestriction(); @@ -105,9 +105,9 @@ void VillagerGolem::aiStep() { if (xd * xd + zd * zd > MoveControl::MIN_SPEED_SQR && random->nextInt(5) == 0) { - int xt = GameMath::floor(x); - int yt = GameMath::floor(y - 0.2f - heightOffset); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(y - 0.2f - heightOffset); + int zt = Mth::floor(z); int t = level->getTile(xt, yt, zt); int d = level->getData(xt, yt, zt); if (t > 0) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderCrystal.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderCrystal.cpp index 839307e03..133520cf7 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderCrystal.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderCrystal.cpp @@ -46,9 +46,9 @@ void EnderCrystal::tick() { // removing/adding these fire tiles causing timing glitches from the // lighting changes requried. if (!level->isClientSide) { - int xt = GameMath::floor(x); - int yt = GameMath::floor(y); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(y); + int zt = Mth::floor(z); if (level->getTile(xt, yt, zt) != Tile::fire_Id) { level->setTileAndUpdate(xt, yt, zt, Tile::fire_Id); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp index 28c435ac3..9eca5109c 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp @@ -181,7 +181,7 @@ void EnderDragon::getLatencyPos(std::vector& result, int step, float a) // positions[i][2] is currently always 0 double yr0 = positions[p0][0]; - double yrd = GameMath::wrapDegrees(positions[p1][0] - yr0); + double yrd = Mth::wrapDegrees(positions[p1][0] - yr0); result[0] = yr0 + yrd * a; yr0 = positions[p0][1]; @@ -251,7 +251,7 @@ void EnderDragon::aiStep() { flapTime += flapSpeed; } - yRot = GameMath::wrapDegrees(yRot); + yRot = Mth::wrapDegrees(yRot); if (posPointer < 0) { for (int i = 0; i < positionsLength; i++) { @@ -284,7 +284,7 @@ void EnderDragon::aiStep() { //} // else { - double yrd = GameMath::wrapDegrees(lyr - yRot); + double yrd = Mth::wrapDegrees(lyr - yRot); m_headYRot = 0.0; yRot += (yrd) / lSteps; @@ -496,7 +496,7 @@ void EnderDragon::aiStep() { double zdd = attackTarget->z - head->z; double yRotT = (180) - atan2(xdd, zdd) * 180 / std::numbers::pi; - double yRotD = GameMath::wrapDegrees(yRotT - yRot); + double yRotD = Mth::wrapDegrees(yRotT - yRot); if (yRotD > 50) yRotD = 50; if (yRotD < -50) yRotD = -50; @@ -1074,12 +1074,12 @@ float EnderDragon::rotWrap(double d) { } bool EnderDragon::checkWalls(AABB* bb) { - int x0 = GameMath::floor(bb->x0); - int y0 = GameMath::floor(bb->y0); - int z0 = GameMath::floor(bb->z0); - int x1 = GameMath::floor(bb->x1); - int y1 = GameMath::floor(bb->y1); - int z1 = GameMath::floor(bb->z1); + int x0 = Mth::floor(bb->x0); + int y0 = Mth::floor(bb->y0); + int z0 = Mth::floor(bb->z0); + int x1 = Mth::floor(bb->x1); + int y1 = Mth::floor(bb->y1); + int z1 = Mth::floor(bb->z1); bool hitWall = false; bool destroyedTile = false; for (int x = x0; x <= x1; x++) { @@ -1231,7 +1231,7 @@ void EnderDragon::tickDeath() { zo = 0; } // 4J-PB changed to center this between the pillars - spawnExitPortal(0, 0); // GameMath::floor(x), GameMath::floor(z)); + spawnExitPortal(0, 0); // Mth::floor(x), Mth::floor(z)); remove(); } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/boss/wither/WitherBoss.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/boss/wither/WitherBoss.cpp index 2fc7f707a..87a795e03 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/boss/wither/WitherBoss.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/boss/wither/WitherBoss.cpp @@ -12,7 +12,7 @@ #include "../../../level/net.minecraft.world.level.h" #include "../../../level/tile/net.minecraft.world.level.tile.h" #include "../../../phys/net.minecraft.world.phys.h" -#include "../../../../util/GameMath.h" +#include "../../../../util/Mth.h" #include "../../../../../../Header Files/SoundTypes.h" @@ -124,14 +124,14 @@ void WitherBoss::aiStep() { double zdist = e->z - z; double distSqr = xdist * xdist + zdist * zdist; if (distSqr > 9) { - double sd = GameMath::sqrt(distSqr); + double sd = Mth::sqrt(distSqr); xd += ((xdist / sd) * .5f - xd) * .6f; zd += ((zdist / sd) * .5f - zd) * .6f; } } } if ((xd * xd + zd * zd) > .05f) { - yRot = (float)atan2(zd, xd) * GameMath::RAD_TO_DEG - 90; + yRot = (float)atan2(zd, xd) * Mth::RAD_TO_DEG - 90; } Monster::aiStep(); @@ -154,7 +154,7 @@ void WitherBoss::aiStep() { double xd = e->x - hx; double yd = e->y + e->getHeadHeight() - hy; double zd = e->z - hz; - double sd = GameMath::sqrt(xd * xd + zd * zd); + double sd = Mth::sqrt(xd * xd + zd * zd); float yRotD = (float)(atan2(zd, xd) * 180 / std::numbers::pi) - 90; float xRotD = (float)-(atan2(yd, sd) * 180 / std::numbers::pi); @@ -302,9 +302,9 @@ void WitherBoss::newServerAiStep() { // destroy all blocks that are within 1 range, counting from // feet and 3 blocks up - int feet = GameMath::floor(y); - int ox = GameMath::floor(x); - int oz = GameMath::floor(z); + int feet = Mth::floor(y); + int ox = Mth::floor(x); + int oz = Mth::floor(z); bool destroyed = false; for (int xStep = -1; xStep <= 1; xStep++) { @@ -371,7 +371,7 @@ double WitherBoss::getHeadZ(int index) { } float WitherBoss::rotlerp(float a, float b, float max) { - float diff = GameMath::wrapDegrees(b - a); + float diff = Mth::wrapDegrees(b - a); if (diff > max) { diff = max; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/global/LightningBolt.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/global/LightningBolt.cpp index 5b39ce18e..c37812e4f 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/global/LightningBolt.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/global/LightningBolt.cpp @@ -26,11 +26,11 @@ LightningBolt::LightningBolt(Level* level, double x, double y, double z) if (!level->isClientSide && level->getGameRules()->getBoolean(GameRules::RULE_DOFIRETICK) && level->difficulty >= 2 && - level->hasChunksAt(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z), 10)) { + level->hasChunksAt(Mth::floor(x), Mth::floor(y), Mth::floor(z), 10)) { { - int xt = GameMath::floor(x); - int yt = GameMath::floor(y); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(y); + int zt = Mth::floor(z); // 4J added - don't go setting tiles if we aren't tracking them for // network synchronisation if (MinecraftServer::getInstance()->getPlayers()->isTrackingTile( @@ -42,9 +42,9 @@ LightningBolt::LightningBolt(Level* level, double x, double y, double z) } for (int i = 0; i < 4; i++) { - int xt = GameMath::floor(x) + random->nextInt(3) - 1; - int yt = GameMath::floor(y) + random->nextInt(3) - 1; - int zt = GameMath::floor(z) + random->nextInt(3) - 1; + int xt = Mth::floor(x) + random->nextInt(3) - 1; + int yt = Mth::floor(y) + random->nextInt(3) - 1; + int zt = Mth::floor(z) + random->nextInt(3) - 1; // 4J added - don't go setting tiles if we aren't tracking them for // network synchronisation if (MinecraftServer::getInstance()->getPlayers()->isTrackingTile( diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/item/Boat.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/item/Boat.cpp index c64ba6023..b17e24ee1 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/item/Boat.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/item/Boat.cpp @@ -202,7 +202,7 @@ void Boat::tick() { double yt = y + (ly - y) / lSteps; double zt = z + (lz - z) / lSteps; - double yrd = GameMath::wrapDegrees(lyr - yRot); + double yrd = Mth::wrapDegrees(lyr - yRot); yRot += (float)((yrd) / lSteps); xRot += (float)((lxr - xRot) / lSteps); @@ -304,7 +304,7 @@ void Boat::tick() { yRotT = (float)(atan2(zDiff, xDiff) * 180 / std::numbers::pi); } - double rotDiff = GameMath::wrapDegrees(yRotT - yRot); + double rotDiff = Mth::wrapDegrees(yRotT - yRot); if (rotDiff > 20) rotDiff = 20; if (rotDiff < -20) rotDiff = -20; @@ -329,11 +329,11 @@ void Boat::tick() { } for (int i = 0; i < 4; i++) { - int xx = GameMath::floor(x + ((i % 2) - 0.5) * 0.8); - int zz = GameMath::floor(z + ((i / 2) - 0.5) * 0.8); + int xx = Mth::floor(x + ((i % 2) - 0.5) * 0.8); + int zz = Mth::floor(z + ((i / 2) - 0.5) * 0.8); for (int j = 0; j < 2; j++) { - int yy = GameMath::floor(y) + j; + int yy = Mth::floor(y) + j; int tile = level->getTile(xx, yy, zz); if (tile == Tile::topSnow_Id) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/item/FallingTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/item/FallingTile.cpp index 12414a0b6..5a2f7efe7 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/item/FallingTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/item/FallingTile.cpp @@ -85,9 +85,9 @@ void FallingTile::tick() { zd *= 0.98f; if (!level->isClientSide) { - int xt = GameMath::floor(x); - int yt = GameMath::floor(y); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(y); + int zt = Mth::floor(z); if (time == 1) { if (level->getTile(xt, yt, zt) == tile) { level->removeTile(xt, yt, zt); @@ -162,7 +162,7 @@ void FallingTile::tick() { void FallingTile::causeFallDamage(float distance) { if (hurtEntities) { - int dmg = GameMath::ceil(distance - 1); + int dmg = Mth::ceil(distance - 1); if (dmg > 0) { // 4J: Copy vector since it might be modified when we hurt the // entities (invalidating our iterator) @@ -174,7 +174,7 @@ void FallingTile::causeFallDamage(float distance) { : DamageSource::fallingBlock; // for (Entity entity : entities) for (auto it = entities->begin(); it != entities->end(); ++it) { - (*it)->hurt(source, std::min(GameMath::floor(dmg * fallDamageAmount), + (*it)->hurt(source, std::min(Mth::floor(dmg * fallDamageAmount), fallDamageMax)); } delete entities; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/item/ItemEntity.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/item/ItemEntity.cpp index 95ba690e4..69b0256b0 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/item/ItemEntity.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/item/ItemEntity.cpp @@ -77,7 +77,7 @@ void ItemEntity::tick() { bool moved = (int)xo != (int)x || (int)yo != (int)y || (int)zo != (int)z; if (moved || tickCount % 25 == 0) { - if (level->getMaterial(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)) == + if (level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)) == Material::lava) { yd = 0.2f; xd = (random->nextFloat() - random->nextFloat()) * 0.2f; @@ -97,7 +97,7 @@ void ItemEntity::tick() { if (onGround) { friction = 0.6f * 0.98f; int t = - level->getTile(GameMath::floor(x), GameMath::floor(bb.y0) - 1, GameMath::floor(z)); + level->getTile(Mth::floor(x), Mth::floor(bb.y0) - 1, Mth::floor(z)); if (t > 0) { friction = Tile::tiles[t]->friction * 0.98f; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/item/Minecart.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/item/Minecart.cpp index caf9987a5..c2dcf48f8 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/item/Minecart.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/item/Minecart.cpp @@ -244,7 +244,7 @@ void Minecart::tick() { double yt = y + (ly - y) / lSteps; double zt = z + (lz - z) / lSteps; - double yrd = GameMath::wrapDegrees(lyr - yRot); + double yrd = Mth::wrapDegrees(lyr - yRot); yRot += (float)((yrd) / lSteps); xRot += (float)((lxr - xRot) / lSteps); @@ -266,9 +266,9 @@ void Minecart::tick() { yd -= 0.04f; - int xt = GameMath::floor(x); - int yt = GameMath::floor(y); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(y); + int zt = Mth::floor(z); if (BaseRailTile::isRail(level, xt, yt - 1, zt)) { yt--; } @@ -299,7 +299,7 @@ void Minecart::tick() { if (flipped) yRot += 180; } - double rotDiff = GameMath::wrapDegrees(yRot - yRotO); + double rotDiff = Mth::wrapDegrees(yRot - yRotO); if (rotDiff < -170 || rotDiff >= 170) { yRot += 180; @@ -485,11 +485,11 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, move(xdd, 0, zdd); - if (exits[0][1] != 0 && GameMath::floor(x) - xt == exits[0][0] && - GameMath::floor(z) - zt == exits[0][2]) { + if (exits[0][1] != 0 && Mth::floor(x) - xt == exits[0][0] && + Mth::floor(z) - zt == exits[0][2]) { setPos(x, y + exits[0][1], z); - } else if (exits[1][1] != 0 && GameMath::floor(x) - xt == exits[1][0] && - GameMath::floor(z) - zt == exits[1][2]) { + } else if (exits[1][1] != 0 && Mth::floor(x) - xt == exits[1][0] && + Mth::floor(z) - zt == exits[1][2]) { setPos(x, y + exits[1][1], z); } @@ -507,8 +507,8 @@ void Minecart::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, setPos(x, newPos->y, z); } - int xn = GameMath::floor(x); - int zn = GameMath::floor(z); + int xn = Mth::floor(x); + int zn = Mth::floor(z); if (xn != xt || zn != zt) { pow = sqrt(xd * xd + zd * zd); @@ -557,9 +557,9 @@ void Minecart::applyNaturalSlowdown() { std::optional Minecart::getPosOffs(double x, double y, double z, double offs) { - int xt = GameMath::floor(x); - int yt = GameMath::floor(y); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(y); + int zt = Mth::floor(z); if (BaseRailTile::isRail(level, xt, yt - 1, zt)) { yt--; } @@ -591,11 +591,11 @@ std::optional Minecart::getPosOffs(double x, double y, double z, x += xD * offs; z += zD * offs; - if (exits[0][1] != 0 && GameMath::floor(x) - xt == exits[0][0] && - GameMath::floor(z) - zt == exits[0][2]) { + if (exits[0][1] != 0 && Mth::floor(x) - xt == exits[0][0] && + Mth::floor(z) - zt == exits[0][2]) { y += exits[0][1]; - } else if (exits[1][1] != 0 && GameMath::floor(x) - xt == exits[1][0] && - GameMath::floor(z) - zt == exits[1][2]) { + } else if (exits[1][1] != 0 && Mth::floor(x) - xt == exits[1][0] && + Mth::floor(z) - zt == exits[1][2]) { y += exits[1][1]; } @@ -606,9 +606,9 @@ std::optional Minecart::getPosOffs(double x, double y, double z, } std::optional Minecart::getPos(double x, double y, double z) { - int xt = GameMath::floor(x); - int yt = GameMath::floor(y); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(y); + int zt = Mth::floor(z); if (BaseRailTile::isRail(level, xt, yt - 1, zt)) { yt--; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartFurnace.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartFurnace.cpp index 71c8cf4e0..fff44c184 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartFurnace.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartFurnace.cpp @@ -66,7 +66,7 @@ void MinecartFurnace::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double sd = xPush * xPush + zPush * zPush; if (sd > 0.01 * 0.01 && xd * xd + zd * zd > 0.001) { - sd = GameMath::sqrt(sd); + sd = Mth::sqrt(sd); xPush /= sd; zPush /= sd; @@ -84,7 +84,7 @@ void MinecartFurnace::applyNaturalSlowdown() { double sd = xPush * xPush + zPush * zPush; if (sd > 0.01 * 0.01) { - sd = GameMath::sqrt(sd); + sd = Mth::sqrt(sd); xPush /= sd; zPush /= sd; double speed = 0.05; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartSpawner.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartSpawner.cpp index 2aecc6e66..96f040ca4 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartSpawner.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/item/MinecartSpawner.cpp @@ -18,15 +18,15 @@ Level* MinecartSpawner::MinecartMobSpawner::getLevel() { } int MinecartSpawner::MinecartMobSpawner::getX() { - return GameMath::floor(m_parent->x); + return Mth::floor(m_parent->x); } int MinecartSpawner::MinecartMobSpawner::getY() { - return GameMath::floor(m_parent->y); + return Mth::floor(m_parent->y); } int MinecartSpawner::MinecartMobSpawner::getZ() { - return GameMath::floor(m_parent->z); + return Mth::floor(m_parent->z); } MinecartSpawner::MinecartSpawner(Level* level) : Minecart(level) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/EnderMan.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/EnderMan.cpp index 174649fec..37462ceb7 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/EnderMan.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/EnderMan.cpp @@ -149,9 +149,9 @@ void EnderMan::aiStep() { if (level->getGameRules()->getBoolean(GameRules::RULE_MOBGRIEFING)) { if (getCarryingTile() == 0) { if (random->nextInt(20) == 0) { - int xt = GameMath::floor(x - 2 + random->nextDouble() * 4); - int yt = GameMath::floor(y + random->nextDouble() * 3); - int zt = GameMath::floor(z - 2 + random->nextDouble() * 4); + int xt = Mth::floor(x - 2 + random->nextDouble() * 4); + int yt = Mth::floor(y + random->nextDouble() * 3); + int zt = Mth::floor(z - 2 + random->nextDouble() * 4); int t = level->getTile(xt, yt, zt); if (MAY_TAKE[t]) { setCarryingTile(level->getTile(xt, yt, zt)); @@ -161,9 +161,9 @@ void EnderMan::aiStep() { } } else { if (random->nextInt(2000) == 0) { - int xt = GameMath::floor(x - 1 + random->nextDouble() * 2); - int yt = GameMath::floor(y + random->nextDouble() * 2); - int zt = GameMath::floor(z - 1 + random->nextDouble() * 2); + int xt = Mth::floor(x - 1 + random->nextDouble() * 2); + int yt = Mth::floor(y + random->nextDouble() * 2); + int zt = Mth::floor(z - 1 + random->nextDouble() * 2); int t = level->getTile(xt, yt, zt); int bt = level->getTile(xt, yt - 1, zt); if (t == 0 && bt > 0 && Tile::tiles[bt]->isCubeShaped()) { @@ -189,8 +189,8 @@ void EnderMan::aiStep() { if (level->isDay() && !level->isClientSide) { float br = getBrightness(1); if (br > 0.5f) { - if (level->canSeeSky(GameMath::floor(x), (int)floor(y + 0.5), - GameMath::floor(z)) && + if (level->canSeeSky(Mth::floor(x), (int)floor(y + 0.5), + Mth::floor(z)) && random->nextFloat() * 30 < (br - 0.4f) * 2) { attackTarget = nullptr; setCreepy(false); @@ -269,9 +269,9 @@ bool EnderMan::teleport(double xx, double yy, double zz) { y = yy; z = zz; bool ok = false; - int xt = GameMath::floor(x); - int yt = GameMath::floor(y); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(y); + int zt = Mth::floor(z); if (level->hasChunkAt(xt, yt, zt)) { bool landed = false; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Monster.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Monster.cpp index 7f014243b..f3d9e8a12 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Monster.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Monster.cpp @@ -125,9 +125,9 @@ float Monster::getWalkTargetValue(int x, int y, int z) { } bool Monster::isDarkEnoughToSpawn() { - int xt = GameMath::floor(x); - int yt = GameMath::floor(bb.y0); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(bb.y0); + int zt = Mth::floor(z); if (level->getBrightness(LightLayer::Sky, xt, yt, zt) > random->nextInt(32)) return false; diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Silverfish.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Silverfish.cpp index 36b469530..74491d707 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Silverfish.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Silverfish.cpp @@ -100,9 +100,9 @@ void Silverfish::serverAiStep() { lookForFriends--; if (lookForFriends == 0) { // see if there are any friendly monster eggs nearby - int baseX = GameMath::floor(x); - int baseY = GameMath::floor(y); - int baseZ = GameMath::floor(z); + int baseX = Mth::floor(x); + int baseY = Mth::floor(y); + int baseZ = Mth::floor(z); bool doBreak = false; for (int yOff = 0; !doBreak && yOff <= 5 && yOff >= -5; @@ -152,8 +152,8 @@ void Silverfish::serverAiStep() { if (attackTarget == nullptr && !isPathFinding()) { // if the silverfish isn't doing anything special, it will merge // with any rock tile it is nearby - int tileX = GameMath::floor(x), tileY = GameMath::floor(y + .5f), - tileZ = GameMath::floor(z); + int tileX = Mth::floor(x), tileY = Mth::floor(y + .5f), + tileZ = Mth::floor(z); int facing = random->nextInt(6); int tile = level->getTile(tileX + Facing::STEP_X[facing], diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Skeleton.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Skeleton.cpp index 5d982289f..8ae6c822d 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Skeleton.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Skeleton.cpp @@ -96,8 +96,8 @@ void Skeleton::aiStep() { if (level->isDay() && !level->isClientSide) { float br = getBrightness(1); if (br > 0.5f && random->nextFloat() * 30 < (br - 0.4f) * 2 && - level->canSeeSky(GameMath::floor(x), (int)floor(y + 0.5), - GameMath::floor(z))) { + level->canSeeSky(Mth::floor(x), (int)floor(y + 0.5), + Mth::floor(z))) { bool burn = true; std::shared_ptr helmet = getCarried(SLOT_HELM); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Slime.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Slime.cpp index a5fb6c6e9..8ebf9df81 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Slime.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Slime.cpp @@ -214,7 +214,7 @@ int Slime::getDeathLoot() { } bool Slime::canSpawn() { - LevelChunk* lc = level->getChunkAt(GameMath::floor(x), GameMath::floor(z)); + LevelChunk* lc = level->getChunkAt(Mth::floor(x), Mth::floor(z)); if (level->getLevelData()->getGenerator() == LevelType::lvl_flat && random->nextInt(4) != 1) { return false; @@ -223,13 +223,13 @@ bool Slime::canSpawn() { lc->getRandom(987234911l); // 4J - separated out so we can delete if ((getSize() == 1 || level->difficulty > Difficulty::PEACEFUL)) { // spawn slime in swamplands at night - Biome* biome = level->getBiome(GameMath::floor(x), GameMath::floor(z)); + Biome* biome = level->getBiome(Mth::floor(x), Mth::floor(z)); if (biome == Biome::swampland && y > 50 && y < 70 && random->nextFloat() < 0.5f) { if (random->nextFloat() < level->getMoonBrightness() && - level->getRawBrightness(GameMath::floor(x), GameMath::floor(y), - GameMath::floor(z)) <= random->nextInt(8)) { + level->getRawBrightness(Mth::floor(x), Mth::floor(y), + Mth::floor(z)) <= random->nextInt(8)) { return Mob::canSpawn(); } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Witch.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Witch.cpp index 7fa14afe6..acec86850 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Witch.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Witch.cpp @@ -197,7 +197,7 @@ void Witch::performRangedAttack(std::shared_ptr target, double xd = (target->x + target->xd) - x; double yd = (target->y + target->getHeadHeight() - 1.1f) - y; double zd = (target->z + target->zd) - z; - float dist = GameMath::sqrt(xd * xd + zd * zd); + float dist = Mth::sqrt(xd * xd + zd * zd); if (dist >= 8 && !target->hasEffect(MobEffect::movementSlowdown)) { potion->setPotionValue(PotionBrewing::POTION_ID_SPLASH_SLOWNESS); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Zombie.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Zombie.cpp index 10e40890a..a316c8586 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Zombie.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/monster/Zombie.cpp @@ -115,8 +115,8 @@ void Zombie::aiStep() { if (level->isDay() && !level->isClientSide && !isBaby()) { float br = getBrightness(1); if (br > 0.5f && random->nextFloat() * 30 < (br - 0.4f) * 2 && - level->canSeeSky(GameMath::floor(x), (int)floor(y + 0.5), - GameMath::floor(z))) { + level->canSeeSky(Mth::floor(x), (int)floor(y + 0.5), + Mth::floor(z))) { bool burn = true; std::shared_ptr helmet = getCarried(SLOT_HELM); @@ -155,9 +155,9 @@ bool Zombie::hurt(DamageSource* source, float dmg) { if ((target != nullptr) && level->difficulty >= Difficulty::HARD && random->nextFloat() < getAttribute(SPAWN_REINFORCEMENTS_CHANCE)->getValue()) { - int x = GameMath::floor(this->x); - int y = GameMath::floor(this->y); - int z = GameMath::floor(this->z); + int x = Mth::floor(this->x); + int y = Mth::floor(this->y); + int z = Mth::floor(this->z); std::shared_ptr reinforcement = std::shared_ptr(new Zombie(level)); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/npc/Villager.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/npc/Villager.cpp index b635bc2d3..2b061ccf7 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/npc/Villager.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/npc/Villager.cpp @@ -100,12 +100,12 @@ bool Villager::useNewAi() { return true; } void Villager::serverAiMobStep() { if (--villageUpdateInterval <= 0) { - level->villages->queryUpdateAround(GameMath::floor(x), GameMath::floor(y), - GameMath::floor(z)); + level->villages->queryUpdateAround(Mth::floor(x), Mth::floor(y), + Mth::floor(z)); villageUpdateInterval = 70 + random->nextInt(50); std::shared_ptr _village = level->villages->getClosestVillage( - GameMath::floor(x), GameMath::floor(y), GameMath::floor(z), Villages::MaxDoorDist); + Mth::floor(x), Mth::floor(y), Mth::floor(z), Villages::MaxDoorDist); village = _village; if (_village == nullptr) clearRestriction(); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/player/Player.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/player/Player.cpp index 938899a25..e920d8508 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/player/Player.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/player/Player.cpp @@ -1048,7 +1048,7 @@ void Player::readAdditionalSaveData(CompoundTag* entityTag) { setScore(entityTag->getInt(L"Score")); if (m_isSleeping) { - bedPosition = new Pos(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); + bedPosition = new Pos(Mth::floor(x), Mth::floor(y), Mth::floor(z)); stopSleepInBed(true, true, false); } @@ -1831,7 +1831,7 @@ void Player::checkRidingStatistiscs(double dx, double dy, double dz) { int dist = 0; if (minecartAchievementPos == nullptr) { minecartAchievementPos = - new Pos(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); + new Pos(Mth::floor(x), Mth::floor(y), Mth::floor(z)); } // 4J-PB - changed this because our world isn't big enough to go // 1000m @@ -1839,7 +1839,7 @@ void Player::checkRidingStatistiscs(double dx, double dy, double dz) { // 4-JEV, changed slightly to add extra parameters for event // on durango. int dist = minecartAchievementPos->dist( - GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); + Mth::floor(x), Mth::floor(y), Mth::floor(z)); if ((m_bAwardedOnARail == false) && (dist >= 500)) { awardStat(GenericStats::onARail(), GenericStats::param_onARail(dist)); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Arrow.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Arrow.cpp index 31f017d62..7c4892f2c 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Arrow.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/Arrow.cpp @@ -273,8 +273,8 @@ void Arrow::tick() { if (res != nullptr) { if (res->entity != nullptr) { - float pow = GameMath::sqrt(xd * xd + yd * yd + zd * zd); - int dmg = (int)GameMath::ceil((float)(pow * baseDamage)); + float pow = Mth::sqrt(xd * xd + yd * yd + zd * zd); + int dmg = (int)Mth::ceil((float)(pow * baseDamage)); if (isCritArrow()) dmg += random->nextInt(dmg / 2 + 2); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FireworksRocketEntity.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FireworksRocketEntity.cpp index 801b9cb0d..3a1458d79 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FireworksRocketEntity.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FireworksRocketEntity.cpp @@ -56,7 +56,7 @@ void FireworksRocketEntity::lerpMotion(double xd, double yd, double zd) { yd = yd; zd = zd; if (xRotO == 0 && yRotO == 0) { - double sd = GameMath::sqrt(xd * xd + zd * zd); + double sd = Mth::sqrt(xd * xd + zd * zd); yRotO = yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); xRotO = xRot = (float)(atan2(yd, sd) * 180 / std::numbers::pi); } @@ -73,7 +73,7 @@ void FireworksRocketEntity::tick() { yd += .04; move(xd, yd, zd); - double sd = GameMath::sqrt(xd * xd + zd * zd); + double sd = Mth::sqrt(xd * xd + zd * zd); yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); xRot = (float)(atan2(yd, sd) * 180 / std::numbers::pi); diff --git a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FishingHook.cpp b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FishingHook.cpp index 195076255..f1b85c879 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FishingHook.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/entity/projectile/FishingHook.cpp @@ -149,7 +149,7 @@ void FishingHook::tick() { double yt = y + (ly - y) / lSteps; double zt = z + (lz - z) / lSteps; - double yrd = GameMath::wrapDegrees(lyr - yRot); + double yrd = Mth::wrapDegrees(lyr - yRot); yRot += (float)((yrd) / lSteps); xRot += (float)((lxr - xRot) / lSteps); @@ -299,8 +299,8 @@ void FishingHook::tick() { nibble--; } else { int nibbleOdds = 500; - if (level->isRainingAt(GameMath::floor(x), GameMath::floor(y) + 1, - GameMath::floor(z))) + if (level->isRainingAt(Mth::floor(x), Mth::floor(y) + 1, + Mth::floor(z))) nibbleOdds = 300; if (random->nextInt(nibbleOdds) == 0) { @@ -309,7 +309,7 @@ void FishingHook::tick() { playSound( eSoundType_RANDOM_SPLASH, 0.25f, 1 + (random->nextFloat() - random->nextFloat()) * 0.4f); - float yt = (float)GameMath::floor(bb.y0); + float yt = (float)Mth::floor(bb.y0); for (int i = 0; i < 1 + bbWidth * 20; i++) { float xo = (random->nextFloat() * 2 - 1) * bbWidth; float zo = (random->nextFloat() * 2 - 1) * bbWidth; diff --git a/minecraft/Minecraft.World/net/minecraft/world/inventory/AbstractContainerMenu.cpp b/minecraft/Minecraft.World/net/minecraft/world/inventory/AbstractContainerMenu.cpp index a9426a1cd..44b620784 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/inventory/AbstractContainerMenu.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/inventory/AbstractContainerMenu.cpp @@ -647,7 +647,7 @@ void AbstractContainerMenu::getQuickCraftSlotCount( switch (quickCraftingType) { case QUICKCRAFT_TYPE_CHARITABLE: item->count = - GameMath::floor(item->count / (float)quickCraftSlots->size()); + Mth::floor(item->count / (float)quickCraftSlots->size()); break; case QUICKCRAFT_TYPE_GREEDY: item->count = 1; @@ -677,7 +677,7 @@ int AbstractContainerMenu::getRedstoneSignalFromContainer( } totalPct /= container->getContainerSize(); - return GameMath::floor(totalPct * (Redstone::SIGNAL_MAX - 1)) + + return Mth::floor(totalPct * (Redstone::SIGNAL_MAX - 1)) + (count > 0 ? 1 : 0); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/BedItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/BedItem.cpp index 8f0f66907..ed1e1f94c 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/BedItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/BedItem.cpp @@ -25,7 +25,7 @@ bool BedItem::useOn(std::shared_ptr itemInstance, BedTile* tile = (BedTile*)Tile::bed; - int dir = (GameMath::floor(player->yRot * 4 / (360) + 0.5f)) & 3; + int dir = (Mth::floor(player->yRot * 4 / (360) + 0.5f)) & 3; int xra = 0; int zra = 0; diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/BoatItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/BoatItem.cpp index b4fffa8b3..fe46bc6af 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/BoatItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/BoatItem.cpp @@ -27,10 +27,10 @@ bool BoatItem::TestUse(std::shared_ptr itemInstance, Level* level, Vec3 from(x, y, z); - float yCos = cosf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); - float ySin = sinf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); - float xCos = -cosf(-xRot * GameMath::DEG_TO_RAD); - float xSin = sinf(-xRot * GameMath::DEG_TO_RAD); + float yCos = cosf(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); + float ySin = sinf(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); + float xCos = -cosf(-xRot * Mth::DEG_TO_RAD); + float xSin = sinf(-xRot * Mth::DEG_TO_RAD); float xa = ySin * xCos; float ya = xSin; @@ -64,10 +64,10 @@ std::shared_ptr BoatItem::use( Vec3 from(x, y, z); - float yCos = cosf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); - float ySin = sinf(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); - float xCos = -cosf(-xRot * GameMath::DEG_TO_RAD); - float xSin = sinf(-xRot * GameMath::DEG_TO_RAD); + float yCos = cosf(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); + float ySin = sinf(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); + float xCos = -cosf(-xRot * Mth::DEG_TO_RAD); + float xSin = sinf(-xRot * Mth::DEG_TO_RAD); float xa = ySin * xCos; float ya = xSin; @@ -114,7 +114,7 @@ std::shared_ptr BoatItem::use( std::shared_ptr boat = std::shared_ptr( new Boat(level, xt + 0.5f, yt + 1.0f, zt + 0.5f)); boat->yRot = - ((GameMath::floor(player->yRot * 4.0F / 360.0F + 0.5) & 0x3) - 1) * + ((Mth::floor(player->yRot * 4.0F / 360.0F + 0.5) & 0x3) - 1) * 90; AABB grown = boat->bb.grow(-0.1, -0.1, -0.1); if (!level->getCubes(boat, &grown)->empty()) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/DoorItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/DoorItem.cpp index a52375730..5802e61f9 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/DoorItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/DoorItem.cpp @@ -43,7 +43,7 @@ bool DoorItem::useOn(std::shared_ptr instance, GenericStats::blocksPlaced(tile->id), GenericStats::param_blocksPlaced(tile->id, instance->getAuxValue(), 1)); - int dir = GameMath::floor(((player->yRot + 180) * 4) / 360 - 0.5) & 3; + int dir = Mth::floor(((player->yRot + 180) * 4) / 360 - 0.5) & 3; place(level, x, y, z, dir, tile); instance->count--; diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/DyePowderItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/DyePowderItem.cpp index 8e5fa1381..f485122b3 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/DyePowderItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/DyePowderItem.cpp @@ -65,13 +65,13 @@ const int DyePowderItem::ORANGE = 14; const int DyePowderItem::WHITE = 15; Icon* DyePowderItem::getIcon(int itemAuxValue) { - int colorValue = GameMath::clamp(itemAuxValue, 0, 15); + int colorValue = Mth::clamp(itemAuxValue, 0, 15); return icons[colorValue]; } unsigned int DyePowderItem::getDescriptionId( std::shared_ptr itemInstance) { - int colorValue = GameMath::clamp(itemInstance->getAuxValue(), 0, 15); + int colorValue = Mth::clamp(itemInstance->getAuxValue(), 0, 15); return COLOR_DESCS[colorValue]; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/Item.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/Item.cpp index 2b54737c9..cfa9bf91e 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/Item.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/Item.cpp @@ -1607,10 +1607,10 @@ HitResult* Item::getPlayerPOVHitResult(Level* level, Vec3 from(x, y, z); - float yCos = (float)cos(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); - float ySin = (float)sin(-yRot * GameMath::DEG_TO_RAD - std::numbers::pi); - float xCos = (float)-cos(-xRot * GameMath::DEG_TO_RAD); - float xSin = (float)sin(-xRot * GameMath::DEG_TO_RAD); + float yCos = (float)cos(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); + float ySin = (float)sin(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); + float xCos = (float)-cos(-xRot * Mth::DEG_TO_RAD); + float xSin = (float)sin(-xRot * Mth::DEG_TO_RAD); float xa = ySin * xCos; float ya = xSin; diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/MapItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/MapItem.cpp index 701ff776f..1b7190fa9 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/MapItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/MapItem.cpp @@ -108,8 +108,8 @@ void MapItem::update(Level* level, std::shared_ptr player, int xo = data->x; int zo = data->z; - int xp = GameMath::floor(player->x - xo) / scale + w / 2; - int zp = GameMath::floor(player->z - zo) / scale + h / 2; + int xp = Mth::floor(player->x - xo) / scale + w / 2; + int zp = Mth::floor(player->z - zo) / scale + h / 2; int rad = 128 / scale; if (level->dimension->hasCeiling) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/SignItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/SignItem.cpp index d28d0aceb..0ec2e5de0 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/SignItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/SignItem.cpp @@ -36,7 +36,7 @@ bool SignItem::useOn(std::shared_ptr instance, if (!bTestUseOnOnly) { if (face == 1) { - int rot = GameMath::floor(((player->yRot + 180) * 16) / 360 + 0.5) & 15; + int rot = Mth::floor(((player->yRot + 180) * 16) / 360 + 0.5) & 15; level->setTileAndData(x, y, z, Tile::sign_Id, rot, Tile::UPDATE_ALL); } else { diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/SkullItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/SkullItem.cpp index 5c9c87600..526ca07eb 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/SkullItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/SkullItem.cpp @@ -47,7 +47,7 @@ bool SkullItem::useOn( int rot = 0; if (face == Facing::UP) { - rot = GameMath::floor(((player->yRot) * 16) / 360 + 0.5) & 15; + rot = Mth::floor(((player->yRot) * 16) / 360 + 0.5) & 15; } std::shared_ptr skullTE = level->getTileEntity(x, y, z); diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/SpawnEggItem.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/SpawnEggItem.cpp index c2778b6c8..aac3c6c25 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/SpawnEggItem.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/SpawnEggItem.cpp @@ -290,7 +290,7 @@ std::shared_ptr SpawnEggItem::spawnMobAt(Level* level, int auxVal, std::shared_ptr mob = std::dynamic_pointer_cast(newEntity); newEntity->moveTo( - x, y, z, GameMath::wrapDegrees(level->random->nextFloat() * 360), 0); + x, y, z, Mth::wrapDegrees(level->random->nextFloat() * 360), 0); newEntity->setDespawnProtected(); // 4J added, default to being // protected against despawning // (has to be done after initial diff --git a/minecraft/Minecraft.World/net/minecraft/world/item/enchantment/ProtectionEnchantment.cpp b/minecraft/Minecraft.World/net/minecraft/world/item/enchantment/ProtectionEnchantment.cpp index 46728c532..e3f0a58f6 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/item/enchantment/ProtectionEnchantment.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/item/enchantment/ProtectionEnchantment.cpp @@ -35,14 +35,14 @@ int ProtectionEnchantment::getDamageProtection(int level, float protect = (6 + level * level) / 3.0f; - if (type == ALL) return GameMath::floor(protect * 0.75f); - if (type == FIRE && source->isFire()) return GameMath::floor(protect * 1.25f); + if (type == ALL) return Mth::floor(protect * 0.75f); + if (type == FIRE && source->isFire()) return Mth::floor(protect * 1.25f); if (type == FALL && source == DamageSource::fall) - return GameMath::floor(protect * 2.5f); + return Mth::floor(protect * 2.5f); if (type == EXPLOSION && source->isExplosion()) - return GameMath::floor(protect * 1.5f); + return Mth::floor(protect * 1.5f); if (type == PROJECTILE && source->isProjectile()) - return GameMath::floor(protect * 1.5f); + return Mth::floor(protect * 1.5f); return 0; } @@ -68,7 +68,7 @@ int ProtectionEnchantment::getFireAfterDampener(std::shared_ptr entity, Enchantment::fireProtection->id, entity->getEquipmentSlots()); if (level > 0) { - time -= GameMath::floor(time * (level * 0.15f)); + time -= Mth::floor(time * (level * 0.15f)); } return time; @@ -80,7 +80,7 @@ double ProtectionEnchantment::getExplosionKnockbackAfterDampener( Enchantment::explosionProtection->id, entity->getEquipmentSlots()); if (level > 0) { - power -= GameMath::floor(power * (level * 0.15f)); + power -= Mth::floor(power * (level * 0.15f)); } return power; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/Explosion.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/Explosion.cpp index 7618264c3..7af5a3dbc 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/Explosion.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/Explosion.cpp @@ -57,9 +57,9 @@ void Explosion::explode() { float stepSize = 0.3f; while (remainingPower > 0) { - int xt = GameMath::floor(xp); - int yt = GameMath::floor(yp); - int zt = GameMath::floor(zp); + int xt = Mth::floor(xp); + int yt = Mth::floor(yp); + int zt = Mth::floor(zp); int t = level->getTile(xt, yt, zt); if (t > 0) { Tile* tile = Tile::tiles[t]; @@ -88,12 +88,12 @@ void Explosion::explode() { } r *= 2.0f; - int x0 = GameMath::floor(x - r - 1); - int x1 = GameMath::floor(x + r + 1); - int y0 = GameMath::floor(y - r - 1); - int y1 = GameMath::floor(y + r + 1); - int z0 = GameMath::floor(z - r - 1); - int z1 = GameMath::floor(z + r + 1); + int x0 = Mth::floor(x - r - 1); + int x1 = Mth::floor(x + r + 1); + int y0 = Mth::floor(y - r - 1); + int y1 = Mth::floor(y + r + 1); + int z0 = Mth::floor(z - r - 1); + int z1 = Mth::floor(z + r + 1); // Fix for 360 #123866 - [CRASH] TU13: Code: Compliance: Placing the TNT // next to Ender Crystals will crash the title after a certain amount of diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp index fdfedfcaf..f54affbb0 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/Level.cpp @@ -1372,13 +1372,13 @@ HitResult* Level::clip(Vec3* a, Vec3* b, bool liquid, bool solidOnly) { if (std::isnan(b->x) || std::isnan(b->y) || std::isnan(b->z)) return nullptr; - int xTile1 = GameMath::floor(b->x); - int yTile1 = GameMath::floor(b->y); - int zTile1 = GameMath::floor(b->z); + int xTile1 = Mth::floor(b->x); + int yTile1 = Mth::floor(b->y); + int zTile1 = Mth::floor(b->z); - int xTile0 = GameMath::floor(a->x); - int yTile0 = GameMath::floor(a->y); - int zTile0 = GameMath::floor(a->z); + int xTile0 = Mth::floor(a->x); + int yTile0 = Mth::floor(a->y); + int zTile0 = Mth::floor(a->z); { int t = getTile(xTile0, yTile0, zTile0); @@ -1586,8 +1586,8 @@ bool Level::addGlobalEntity(std::shared_ptr e) { #pragma optimize("", off) bool Level::addEntity(std::shared_ptr e) { - int xc = GameMath::floor(e->x / 16); - int zc = GameMath::floor(e->z / 16); + int xc = Mth::floor(e->x / 16); + int zc = Mth::floor(e->z / 16); if (e == nullptr) { return false; @@ -1730,12 +1730,12 @@ std::vector* Level::getCubes(std::shared_ptr source, AABB* box, bool noEntities /* = false*/, bool blockAtEdge /* = false*/) { boxes.clear(); - int x0 = GameMath::floor(box->x0); - int x1 = GameMath::floor(box->x1 + 1); - int y0 = GameMath::floor(box->y0); - int y1 = GameMath::floor(box->y1 + 1); - int z0 = GameMath::floor(box->z0); - int z1 = GameMath::floor(box->z1 + 1); + int x0 = Mth::floor(box->x0); + int x1 = Mth::floor(box->x1 + 1); + int y0 = Mth::floor(box->y0); + int y1 = Mth::floor(box->y1 + 1); + int z0 = Mth::floor(box->z0); + int z1 = Mth::floor(box->z1 + 1); int maxxz = (dimension->getXZSize() * 16) / 2; int minxz = -maxxz; @@ -1817,12 +1817,12 @@ std::vector* Level::getCubes(std::shared_ptr source, AABB* box, std::vector* Level::getTileCubes(AABB* box, bool blockAtEdge /* = false */) { return getCubes(nullptr, box, true, blockAtEdge); // boxes.clear(); - // int x0 = GameMath::floor(box->x0); - // int x1 = GameMath::floor(box->x1 + 1); - // int y0 = GameMath::floor(box->y0); - // int y1 = GameMath::floor(box->y1 + 1); - // int z0 = GameMath::floor(box->z0); - // int z1 = GameMath::floor(box->z1 + 1); + // int x0 = Mth::floor(box->x0); + // int x1 = Mth::floor(box->x1 + 1); + // int y0 = Mth::floor(box->y0); + // int y1 = Mth::floor(box->y1 + 1); + // int z0 = Mth::floor(box->z0); + // int z1 = Mth::floor(box->z1 + 1); // for (int x = x0; x < x1; x++) //{ @@ -1887,8 +1887,8 @@ Vec3 Level::getSkyColor(std::shared_ptr source, float a) { if (br < 0.0f) br = 0.0f; if (br > 1.0f) br = 1.0f; - int xx = GameMath::floor(source->x); - int zz = GameMath::floor(source->z); + int xx = Mth::floor(source->x); + int zz = Mth::floor(source->z); Biome* biome = getBiome(xx, zz); float temp = biome->getTemperature(); int skyColor = biome->getSkyColor(temp); @@ -2263,8 +2263,8 @@ void Level::addAllPendingTileEntities( void Level::tick(std::shared_ptr e) { tick(e, true); } void Level::tick(std::shared_ptr e, bool actual) { - int xc = GameMath::floor(e->x); - int zc = GameMath::floor(e->z); + int xc = Mth::floor(e->x); + int zc = Mth::floor(e->z); int r = 32; if (actual && !hasChunksAt(xc - r, 0, zc - r, xc + r, 0, zc + r)) { return; @@ -2293,9 +2293,9 @@ void Level::tick(std::shared_ptr e, bool actual) { if (!std::isfinite(e->xRot)) e->xRot = e->xRotO; if (!std::isfinite(e->yRot)) e->yRot = e->yRotO; - int xcn = GameMath::floor(e->x / 16); - int ycn = GameMath::floor(e->y / 16); - int zcn = GameMath::floor(e->z / 16); + int xcn = Mth::floor(e->x / 16); + int ycn = Mth::floor(e->y / 16); + int zcn = Mth::floor(e->z / 16); if (!e->inChunk || (e->xChunk != xcn || e->yChunk != ycn || e->zChunk != zcn)) { @@ -2339,12 +2339,12 @@ bool Level::isUnobstructed(AABB* aabb, std::shared_ptr ignore) { } bool Level::containsAnyBlocks(AABB* box) { - int x0 = GameMath::floor(box->x0); - int x1 = GameMath::floor(box->x1 + 1); - int y0 = GameMath::floor(box->y0); - int y1 = GameMath::floor(box->y1 + 1); - int z0 = GameMath::floor(box->z0); - int z1 = GameMath::floor(box->z1 + 1); + int x0 = Mth::floor(box->x0); + int x1 = Mth::floor(box->x1 + 1); + int y0 = Mth::floor(box->y0); + int y1 = Mth::floor(box->y1 + 1); + int z0 = Mth::floor(box->z0); + int z1 = Mth::floor(box->z1 + 1); if (box->x0 < 0) x0--; if (box->y0 < 0) y0--; @@ -2362,12 +2362,12 @@ bool Level::containsAnyBlocks(AABB* box) { } bool Level::containsAnyLiquid(AABB* box) { - int x0 = GameMath::floor(box->x0); - int x1 = GameMath::floor(box->x1 + 1); - int y0 = GameMath::floor(box->y0); - int y1 = GameMath::floor(box->y1 + 1); - int z0 = GameMath::floor(box->z0); - int z1 = GameMath::floor(box->z1 + 1); + int x0 = Mth::floor(box->x0); + int x1 = Mth::floor(box->x1 + 1); + int y0 = Mth::floor(box->y0); + int y1 = Mth::floor(box->y1 + 1); + int z0 = Mth::floor(box->z0); + int z1 = Mth::floor(box->z1 + 1); if (box->x0 < 0) x0--; if (box->y0 < 0) y0--; @@ -2390,12 +2390,12 @@ bool Level::containsAnyLiquid(AABB* box) { // aim is to not load or create any chunk we haven't already got, and be // cautious about placing the mob's. bool Level::containsAnyLiquid_NoLoad(AABB* box) { - int x0 = GameMath::floor(box->x0); - int x1 = GameMath::floor(box->x1 + 1); - int y0 = GameMath::floor(box->y0); - int y1 = GameMath::floor(box->y1 + 1); - int z0 = GameMath::floor(box->z0); - int z1 = GameMath::floor(box->z1 + 1); + int x0 = Mth::floor(box->x0); + int x1 = Mth::floor(box->x1 + 1); + int y0 = Mth::floor(box->y0); + int y1 = Mth::floor(box->y1 + 1); + int z0 = Mth::floor(box->z0); + int z1 = Mth::floor(box->z1 + 1); if (box->x0 < 0) x0--; if (box->y0 < 0) y0--; @@ -2415,12 +2415,12 @@ bool Level::containsAnyLiquid_NoLoad(AABB* box) { } bool Level::containsFireTile(AABB* box) { - int x0 = GameMath::floor(box->x0); - int x1 = GameMath::floor(box->x1 + 1); - int y0 = GameMath::floor(box->y0); - int y1 = GameMath::floor(box->y1 + 1); - int z0 = GameMath::floor(box->z0); - int z1 = GameMath::floor(box->z1 + 1); + int x0 = Mth::floor(box->x0); + int x1 = Mth::floor(box->x1 + 1); + int y0 = Mth::floor(box->y0); + int y1 = Mth::floor(box->y1 + 1); + int z0 = Mth::floor(box->z0); + int z1 = Mth::floor(box->z1 + 1); if (hasChunksAt(x0, y0, z0, x1, y1, z1)) { for (int x = x0; x < x1; x++) @@ -2438,14 +2438,14 @@ bool Level::containsFireTile(AABB* box) { bool Level::checkAndHandleWater(AABB* box, Material* material, std::shared_ptr e) { - int x0 = GameMath::floor(box->x0); - int x1 = GameMath::floor(box->x1 + 1); + int x0 = Mth::floor(box->x0); + int x1 = Mth::floor(box->x1 + 1); - int y0 = GameMath::floor(box->y0); - int y1 = GameMath::floor(box->y1 + 1); + int y0 = Mth::floor(box->y0); + int y1 = Mth::floor(box->y1 + 1); - int z0 = GameMath::floor(box->z0); - int z1 = GameMath::floor(box->z1 + 1); + int z0 = Mth::floor(box->z0); + int z1 = Mth::floor(box->z1 + 1); if (!hasChunksAt(x0, y0, z0, x1, y1, z1)) { return false; @@ -2479,12 +2479,12 @@ bool Level::checkAndHandleWater(AABB* box, Material* material, } bool Level::containsMaterial(AABB* box, Material* material) { - int x0 = GameMath::floor(box->x0); - int x1 = GameMath::floor(box->x1 + 1); - int y0 = GameMath::floor(box->y0); - int y1 = GameMath::floor(box->y1 + 1); - int z0 = GameMath::floor(box->z0); - int z1 = GameMath::floor(box->z1 + 1); + int x0 = Mth::floor(box->x0); + int x1 = Mth::floor(box->x1 + 1); + int y0 = Mth::floor(box->y0); + int y1 = Mth::floor(box->y1 + 1); + int z0 = Mth::floor(box->z0); + int z1 = Mth::floor(box->z1 + 1); for (int x = x0; x < x1; x++) { for (int y = y0; y < y1; y++) { @@ -2500,12 +2500,12 @@ bool Level::containsMaterial(AABB* box, Material* material) { } bool Level::containsLiquid(AABB* box, Material* material) { - int x0 = GameMath::floor(box->x0); - int x1 = GameMath::floor(box->x1 + 1); - int y0 = GameMath::floor(box->y0); - int y1 = GameMath::floor(box->y1 + 1); - int z0 = GameMath::floor(box->z0); - int z1 = GameMath::floor(box->z1 + 1); + int x0 = Mth::floor(box->x0); + int x1 = Mth::floor(box->x1 + 1); + int y0 = Mth::floor(box->y0); + int y1 = Mth::floor(box->y1 + 1); + int z0 = Mth::floor(box->z0); + int z1 = Mth::floor(box->z1 + 1); for (int x = x0; x < x1; x++) { for (int y = y0; y < y1; y++) { @@ -2928,8 +2928,8 @@ void Level::buildAndPrepareChunksToPoll() { int* zz = new int[playerCount]; for (int i = 0; i < playerCount; i++) { std::shared_ptr player = players[i]; - xx[i] = GameMath::floor(player->x / 16); - zz[i] = GameMath::floor(player->z / 16); + xx[i] = Mth::floor(player->x / 16); + zz[i] = Mth::floor(player->z / 16); chunksToPoll.insert(ChunkPos(xx[i], zz[i])); } @@ -3187,9 +3187,9 @@ void Level::checkLight(LightLayer::variety layer, int xc, int yc, int zc, // cexp--; // 4J - removed, change // from 1.2.3 if (expected > 0) { - int xd = GameMath::abs(x - xc); - int yd = GameMath::abs(y - yc); - int zd = GameMath::abs(z - zc); + int xd = Mth::abs(x - xc); + int yd = Mth::abs(y - yc); + int zd = Mth::abs(z - zc); if (xd + yd + zd < 17) { bool edge = false; for (int face = 0; face < 6; face++) { @@ -3374,10 +3374,10 @@ std::vector >* Level::getEntities( std::shared_ptr except, AABB* bb, const EntitySelector* selector) { MemSect(40); es.clear(); - int xc0 = GameMath::floor((bb->x0 - 2) / 16); - int xc1 = GameMath::floor((bb->x1 + 2) / 16); - int zc0 = GameMath::floor((bb->z0 - 2) / 16); - int zc1 = GameMath::floor((bb->z1 + 2) / 16); + int xc0 = Mth::floor((bb->x0 - 2) / 16); + int xc1 = Mth::floor((bb->x1 + 2) / 16); + int zc0 = Mth::floor((bb->z0 - 2) / 16); + int zc1 = Mth::floor((bb->z1 + 2) / 16); for (int xc = xc0; xc <= xc1; xc++) for (int zc = zc0; zc <= zc1; zc++) { @@ -3397,10 +3397,10 @@ std::vector >* Level::getEntitiesOfClass( std::vector >* Level::getEntitiesOfClass( const std::type_info& baseClass, AABB* bb, const EntitySelector* selector) { - int xc0 = GameMath::floor((bb->x0 - 2) / 16); - int xc1 = GameMath::floor((bb->x1 + 2) / 16); - int zc0 = GameMath::floor((bb->z0 - 2) / 16); - int zc1 = GameMath::floor((bb->z1 + 2) / 16); + int xc0 = Mth::floor((bb->x0 - 2) / 16); + int xc1 = Mth::floor((bb->x1 + 2) / 16); + int zc0 = Mth::floor((bb->z0 - 2) / 16); + int zc1 = Mth::floor((bb->z1 + 2) / 16); std::vector >* es = new std::vector >(); @@ -3584,9 +3584,9 @@ int Level::getSeaLevel() { return seaLevel; } Path* Level::findPath(std::shared_ptr from, std::shared_ptr to, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat) { - int x = GameMath::floor(from->x); - int y = GameMath::floor(from->y + 1); - int z = GameMath::floor(from->z); + int x = Mth::floor(from->x); + int y = Mth::floor(from->y + 1); + int z = Mth::floor(from->z); int r = (int)(maxDist + 16); int x1 = x - r; @@ -3605,9 +3605,9 @@ Path* Level::findPath(std::shared_ptr from, std::shared_ptr to, Path* Level::findPath(std::shared_ptr from, int xBest, int yBest, int zBest, float maxDist, bool canPassDoors, bool canOpenDoors, bool avoidWater, bool canFloat) { - int x = GameMath::floor(from->x); - int y = GameMath::floor(from->y); - int z = GameMath::floor(from->z); + int x = Mth::floor(from->x); + int y = Mth::floor(from->y); + int z = Mth::floor(from->z); int r = (int)(maxDist + 8); int x1 = x - r; @@ -3948,8 +3948,8 @@ void Level::setSpawnPos(Pos* spawnPos) { } void Level::ensureAdded(std::shared_ptr entity) { - int xc = GameMath::floor(entity->x / 16); - int zc = GameMath::floor(entity->z / 16); + int xc = Mth::floor(entity->x / 16); + int zc = Mth::floor(entity->z / 16); int r = 2; for (int x = xc - r; x <= xc + r; x++) { for (int z = zc - r; z <= zc + r; z++) { @@ -4129,7 +4129,7 @@ void Level::updateNeighbourForOutputSignal(int x, int y, int z, int source) { } float Level::getDifficulty(double x, double y, double z) { - return getDifficulty(GameMath::floor(x), GameMath::floor(y), GameMath::floor(z)); + return getDifficulty(Mth::floor(x), Mth::floor(y), Mth::floor(z)); } /** @@ -4143,7 +4143,7 @@ float Level::getDifficulty(int x, int y, int z) { if (hasChunkAt(x, y, z)) { float moonBrightness = getMoonBrightness(); - result += GameMath::clamp(getChunkAt(x, z)->inhabitedTime / + result += Mth::clamp(getChunkAt(x, z)->inhabitedTime / (TICKS_PER_DAY * 150.0f), 0.0f, 1.0f) * (isHard ? 1.0f : 0.75f); @@ -4154,7 +4154,7 @@ float Level::getDifficulty(int x, int y, int z) { result *= difficulty / 2.0f; } - return GameMath::clamp(result, 0.0f, isHard ? 1.5f : 1.0f); + return Mth::clamp(result, 0.0f, isHard ? 1.5f : 1.0f); ; } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/MobSpawner.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/MobSpawner.cpp index 90eb49782..ff92a1281 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/MobSpawner.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/MobSpawner.cpp @@ -57,8 +57,8 @@ const int MobSpawner::tick(ServerLevel* level, bool spawnEnemies, int* zz = new int[playerCount]; for (int i = 0; i < playerCount; i++) { std::shared_ptr player = level->players[i]; - xx[i] = GameMath::floor(player->x / 16); - zz[i] = GameMath::floor(player->z / 16); + xx[i] = Mth::floor(player->x / 16); + zz[i] = Mth::floor(player->z / 16); chunksToPoll.insert( std::pair(ChunkPos(xx[i], zz[i]), false)); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/PortalForcer.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/PortalForcer.cpp index 335bfd116..cf0b79721 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/PortalForcer.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/PortalForcer.cpp @@ -26,9 +26,9 @@ void PortalForcer::force(std::shared_ptr e, double xOriginal, double yOriginal, double zOriginal, float yRotOriginal) { if (level->dimension->id == 1) { - int x = GameMath::floor(e->x); - int y = GameMath::floor(e->y) - 1; - int z = GameMath::floor(e->z); + int x = Mth::floor(e->x); + int y = Mth::floor(e->y) - 1; + int z = Mth::floor(e->z); int xa = 1; int za = 0; @@ -77,8 +77,8 @@ bool PortalForcer::findPortal(std::shared_ptr e, double xOriginal, int yTarget = 0; int zTarget = 0; - int xc = GameMath::floor(e->x); - int zc = GameMath::floor(e->z); + int xc = Mth::floor(e->x); + int zc = Mth::floor(e->z); long hash = ChunkPos::hashCode(xc, zc); bool updateCache = true; @@ -238,9 +238,9 @@ bool PortalForcer::createPortal(std::shared_ptr e) { int r = 16 * 3; double closest = -1; - int xc = GameMath::floor(e->x); - int yc = GameMath::floor(e->y); - int zc = GameMath::floor(e->z); + int xc = Mth::floor(e->x); + int yc = Mth::floor(e->y); + int zc = Mth::floor(e->z); // 4J Stu - Changes to stop Portals being created at the border of the // nether inside the bedrock diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/TilePos.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/TilePos.cpp index ddefe8e9d..4fd621617 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/TilePos.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/TilePos.cpp @@ -11,9 +11,9 @@ TilePos::TilePos(int x, int y, int z) { // 4J - brought forward from 1.2.3 TilePos::TilePos(Vec3* p) { - this->x = GameMath::floor(p->x); - this->y = GameMath::floor(p->y); - this->z = GameMath::floor(p->z); + this->x = Mth::floor(p->x); + this->y = Mth::floor(p->y); + this->z = Mth::floor(p->z); } int TilePos::hash_fnct(const TilePos& k) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/biome/Biome.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/biome/Biome.cpp index 5694277de..cbd7c8a9e 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/biome/Biome.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/biome/Biome.cpp @@ -471,16 +471,16 @@ void Biome::decorate(Level* level, Random* random, int xo, int zo) { } int Biome::getGrassColor() { - // double temp = GameMath::clamp(getTemperature(), 0.0f, 1.0f); - // double rain = GameMath::clamp(getDownfall(), 0.0f, 1.0f); + // double temp = Mth::clamp(getTemperature(), 0.0f, 1.0f); + // double rain = Mth::clamp(getDownfall(), 0.0f, 1.0f); // return GrassColor::get(temp, rain); return Minecraft::GetInstance()->getColourTable()->getColor(m_grassColor); } int Biome::getFolageColor() { - // double temp = GameMath::clamp(getTemperature(), 0.0f, 1.0f); - // double rain = GameMath::clamp(getDownfall(), 0.0f, 1.0f); + // double temp = Mth::clamp(getTemperature(), 0.0f, 1.0f); + // double rain = Mth::clamp(getDownfall(), 0.0f, 1.0f); // return FoliageColor::get(temp, rain); return Minecraft::GetInstance()->getColourTable()->getColor(m_foliageColor); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/chunk/LevelChunk.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/chunk/LevelChunk.cpp index 0f4bed1d4..324c19a66 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/chunk/LevelChunk.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/chunk/LevelChunk.cpp @@ -1138,14 +1138,14 @@ int LevelChunk::getRawBrightness(int x, int y, int z, int skyDampen) { void LevelChunk::addEntity(std::shared_ptr e) { lastSaveHadEntities = true; - int xc = GameMath::floor(e->x / 16); - int zc = GameMath::floor(e->z / 16); + int xc = Mth::floor(e->x / 16); + int zc = Mth::floor(e->z / 16); if (xc != this->x || zc != this->z) { app.DebugPrintf("Wrong location!"); // System.out.println("Wrong location! " + e); // Thread.dumpStack(); } - int yc = GameMath::floor(e->y / 16); + int yc = Mth::floor(e->y / 16); if (yc < 0) yc = 0; if (yc >= ENTITY_BLOCKS_LENGTH) yc = ENTITY_BLOCKS_LENGTH - 1; e->inChunk = true; @@ -1506,8 +1506,8 @@ void LevelChunk::markUnsaved() { this->setUnsaved(true); } void LevelChunk::getEntities(std::shared_ptr except, AABB* bb, std::vector >& es, const EntitySelector* selector) { - int yc0 = GameMath::floor((bb->y0 - 2) / 16); - int yc1 = GameMath::floor((bb->y1 + 2) / 16); + int yc0 = Mth::floor((bb->y0 - 2) / 16); + int yc1 = Mth::floor((bb->y1 + 2) / 16); if (yc0 < 0) yc0 = 0; if (yc1 >= ENTITY_BLOCKS_LENGTH) yc1 = ENTITY_BLOCKS_LENGTH - 1; @@ -1544,8 +1544,8 @@ void LevelChunk::getEntities(std::shared_ptr except, AABB* bb, void LevelChunk::getEntitiesOfClass(const std::type_info& ec, AABB* bb, std::vector >& es, const EntitySelector* selector) { - int yc0 = GameMath::floor((bb->y0 - 2) / 16); - int yc1 = GameMath::floor((bb->y1 + 2) / 16); + int yc0 = Mth::floor((bb->y0 - 2) / 16); + int yc1 = Mth::floor((bb->y1 + 2) / 16); if (yc0 < 0) { yc0 = 0; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/CanyonFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/CanyonFeature.cpp index eadd3b81f..b635a7fd9 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/CanyonFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/CanyonFeature.cpp @@ -39,17 +39,17 @@ void CanyonFeature::addTunnel(int64_t seed, int xOffs, int zOffs, } for (; step < dist; step++) { - double rad = 1.5 + (GameMath::sin(step * std::numbers::pi / dist) * thickness) * 1; + double rad = 1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1; double yRad = rad * yScale; rad *= (random->nextFloat() * 0.25 + 0.75); yRad *= (random->nextFloat() * 0.25 + 0.75); - float xc = GameMath::cos(xRot); - float xs = GameMath::sin(xRot); - xCave += GameMath::cos(yRot) * xc; + float xc = Mth::cos(xRot); + float xs = Mth::sin(xRot); + xCave += Mth::cos(yRot) * xc; yCave += xs; - zCave += GameMath::sin(yRot) * xc; + zCave += Mth::sin(yRot) * xc; xRot *= 0.7f; @@ -80,14 +80,14 @@ void CanyonFeature::addTunnel(int64_t seed, int xOffs, int zOffs, xCave > xMid + 16 + rad * 2 || zCave > zMid + 16 + rad * 2) continue; - int x0 = GameMath::floor(xCave - rad) - xOffs * 16 - 1; - int x1 = GameMath::floor(xCave + rad) - xOffs * 16 + 1; + int x0 = Mth::floor(xCave - rad) - xOffs * 16 - 1; + int x1 = Mth::floor(xCave + rad) - xOffs * 16 + 1; - int y0 = GameMath::floor(yCave - yRad) - 1; - int y1 = GameMath::floor(yCave + yRad) + 1; + int y0 = Mth::floor(yCave - yRad) - 1; + int y1 = Mth::floor(yCave + yRad) + 1; - int z0 = GameMath::floor(zCave - rad) - zOffs * 16 - 1; - int z1 = GameMath::floor(zCave + rad) - zOffs * 16 + 1; + int z0 = Mth::floor(zCave - rad) - zOffs * 16 - 1; + int z1 = Mth::floor(zCave + rad) - zOffs * 16 + 1; if (x0 < 0) x0 = 0; if (x1 > 16) x1 = 16; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/DungeonFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/DungeonFeature.cpp index 494d64f21..fae7bbb13 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/DungeonFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/DungeonFeature.cpp @@ -35,14 +35,14 @@ void DungeonFeature::addTunnel(int xOffs, int zOffs, std::vector& block bool steep = random->nextInt(6) == 0; for (; step < dist; step++) { - double rad = 1.5 + (GameMath::sin(step * std::numbers::pi / dist) * thickness) * 1; + double rad = 1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1; double yRad = rad * yScale; - float xc = GameMath::cos(xRot); - float xs = GameMath::sin(xRot); - xCave += GameMath::cos(yRot) * xc; + float xc = Mth::cos(xRot); + float xs = Mth::sin(xRot); + xCave += Mth::cos(yRot) * xc; yCave += xs; - zCave += GameMath::sin(yRot) * xc; + zCave += Mth::sin(yRot) * xc; if (steep) { xRot *= 0.92f; @@ -84,14 +84,14 @@ void DungeonFeature::addTunnel(int xOffs, int zOffs, std::vector& block xCave > xMid + 16 + rad * 2 || zCave > zMid + 16 + rad * 2) continue; - int x0 = GameMath::floor(xCave - rad) - xOffs * 16 - 1; - int x1 = GameMath::floor(xCave + rad) - xOffs * 16 + 1; + int x0 = Mth::floor(xCave - rad) - xOffs * 16 - 1; + int x1 = Mth::floor(xCave + rad) - xOffs * 16 + 1; - int y0 = GameMath::floor(yCave - yRad) - 1; - int y1 = GameMath::floor(yCave + yRad) + 1; + int y0 = Mth::floor(yCave - yRad) - 1; + int y1 = Mth::floor(yCave + yRad) + 1; - int z0 = GameMath::floor(zCave - rad) - zOffs * 16 - 1; - int z1 = GameMath::floor(zCave + rad) - zOffs * 16 + 1; + int z0 = Mth::floor(zCave - rad) - zOffs * 16 - 1; + int z1 = Mth::floor(zCave + rad) - zOffs * 16 + 1; if (x0 < 0) x0 = 0; if (x1 > 16) x1 = 16; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeCaveFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeCaveFeature.cpp index e0339a729..3a4b4a452 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeCaveFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeCaveFeature.cpp @@ -38,14 +38,14 @@ void LargeCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, bool steep = random.nextInt(6) == 0; for (; step < dist; step++) { - double rad = 1.5 + (GameMath::sin(step * std::numbers::pi / dist) * thickness) * 1; + double rad = 1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1; double yRad = rad * yScale; - float xc = GameMath::cos(xRot); - float xs = GameMath::sin(xRot); - xCave += GameMath::cos(yRot) * xc; + float xc = Mth::cos(xRot); + float xs = Mth::sin(xRot); + xCave += Mth::cos(yRot) * xc; yCave += xs; - zCave += GameMath::sin(yRot) * xc; + zCave += Mth::sin(yRot) * xc; if (steep) { xRot *= 0.92f; @@ -86,14 +86,14 @@ void LargeCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, xCave > xMid + 16 + rad * 2 || zCave > zMid + 16 + rad * 2) continue; - int x0 = GameMath::floor(xCave - rad) - xOffs * 16 - 1; - int x1 = GameMath::floor(xCave + rad) - xOffs * 16 + 1; + int x0 = Mth::floor(xCave - rad) - xOffs * 16 - 1; + int x1 = Mth::floor(xCave + rad) - xOffs * 16 + 1; - int y0 = GameMath::floor(yCave - yRad) - 1; - int y1 = GameMath::floor(yCave + yRad) + 1; + int y0 = Mth::floor(yCave - yRad) - 1; + int y1 = Mth::floor(yCave + yRad) + 1; - int z0 = GameMath::floor(zCave - rad) - zOffs * 16 - 1; - int z1 = GameMath::floor(zCave + rad) - zOffs * 16 + 1; + int z0 = Mth::floor(zCave - rad) - zOffs * 16 - 1; + int z1 = Mth::floor(zCave + rad) - zOffs * 16 + 1; if (x0 < 0) x0 = 0; if (x1 > 16) x1 = 16; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeHellCaveFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeHellCaveFeature.cpp index 6f464bd7e..975a6ef64 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeHellCaveFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/LargeHellCaveFeature.cpp @@ -37,14 +37,14 @@ void LargeHellCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, bool steep = random.nextInt(6) == 0; for (; step < dist; step++) { - double rad = 1.5 + (GameMath::sin(step * std::numbers::pi / dist) * thickness) * 1; + double rad = 1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1; double yRad = rad * yScale; - float xc = GameMath::cos(xRot); - float xs = GameMath::sin(xRot); - xCave += GameMath::cos(yRot) * xc; + float xc = Mth::cos(xRot); + float xs = Mth::sin(xRot); + xCave += Mth::cos(yRot) * xc; yCave += xs; - zCave += GameMath::sin(yRot) * xc; + zCave += Mth::sin(yRot) * xc; if (steep) { xRot *= 0.92f; @@ -86,14 +86,14 @@ void LargeHellCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, xCave > xMid + 16 + rad * 2 || zCave > zMid + 16 + rad * 2) continue; - int x0 = GameMath::floor(xCave - rad) - xOffs * 16 - 1; - int x1 = GameMath::floor(xCave + rad) - xOffs * 16 + 1; + int x0 = Mth::floor(xCave - rad) - xOffs * 16 - 1; + int x1 = Mth::floor(xCave + rad) - xOffs * 16 + 1; - int y0 = GameMath::floor(yCave - yRad) - 1; - int y1 = GameMath::floor(yCave + yRad) + 1; + int y0 = Mth::floor(yCave - yRad) - 1; + int y1 = Mth::floor(yCave + yRad) + 1; - int z0 = GameMath::floor(zCave - rad) - zOffs * 16 - 1; - int z1 = GameMath::floor(zCave + rad) - zOffs * 16 + 1; + int z0 = Mth::floor(zCave - rad) - zOffs * 16 - 1; + int z1 = Mth::floor(zCave + rad) - zOffs * 16 + 1; if (x0 < 0) x0 = 0; if (x1 > 16) x1 = 16; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/RandomLevelSource.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/RandomLevelSource.cpp index 945d67b66..60d0cd8ff 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/RandomLevelSource.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/RandomLevelSource.cpp @@ -531,7 +531,7 @@ std::vector RandomLevelSource::getHeights(std::vector& buffer, i pows = std::vector(5 * 5); for (int xb = -2; xb <= 2; xb++) { for (int zb = -2; zb <= 2; zb++) { - float ppp = 10.0f / GameMath::sqrt(xb * xb + zb * zb + 0.2f); + float ppp = 10.0f / Mth::sqrt(xb * xb + zb * zb + 0.2f); pows[xb + 2 + (zb + 2) * 5] = ppp; } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp index 13a50813a..59e988dbb 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp @@ -77,8 +77,8 @@ void BasicTree::prepare() { double radius = widthScale * (shapefac * (rnd->nextFloat() + 0.328)); double angle = rnd->nextFloat() * 2.0 * 3.14159; - int x = GameMath::floor(radius * sin(angle) + origin[0] + originOffset); - int z = GameMath::floor(radius * cos(angle) + origin[2] + originOffset); + int x = Mth::floor(radius * sin(angle) + origin[0] + originOffset); + int z = Mth::floor(radius * cos(angle) + origin[2] + originOffset); int checkStart[] = {x, y, z}; int checkEnd[] = {x, y + foliageHeight, z}; // check the center column of the cluster for obstructions. @@ -272,11 +272,11 @@ void BasicTree::limb(int* start, int* end, int material) { int primoffset = 0; int endoffset = delta[primidx] + primsign; while (primoffset != endoffset) { - coordinate[primidx] = GameMath::floor(start[primidx] + primoffset + 0.5); + coordinate[primidx] = Mth::floor(start[primidx] + primoffset + 0.5); coordinate[secidx1] = - GameMath::floor(start[secidx1] + (primoffset * secfac1) + 0.5); + Mth::floor(start[secidx1] + (primoffset * secfac1) + 0.5); coordinate[secidx2] = - GameMath::floor(start[secidx2] + (primoffset * secfac2) + 0.5); + Mth::floor(start[secidx2] + (primoffset * secfac2) + 0.5); int dir = TreeTile::FACING_Y; int xdiff = abs(coordinate[0] - start[0]); @@ -408,9 +408,9 @@ int BasicTree::checkLine(int* start, int* end) { while (primoffset != endoffset) { coordinate[primidx] = start[primidx] + primoffset; coordinate[secidx1] = - GameMath::floor(start[secidx1] + (primoffset * secfac1)); + Mth::floor(start[secidx1] + (primoffset * secfac1)); coordinate[secidx2] = - GameMath::floor(start[secidx2] + (primoffset * secfac2)); + Mth::floor(start[secidx2] + (primoffset * secfac2)); thismat = thisLevel->getTile(coordinate[0], coordinate[1], coordinate[2]); if (!((thismat == 0) || (thismat == Tile::leaves_Id))) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/CaveFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/CaveFeature.cpp index a8d428cce..4605f4c1c 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/CaveFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/CaveFeature.cpp @@ -7,10 +7,10 @@ bool CaveFeature::place(Level* level, Random* random, int x, int y, int z) { float dir = random->nextFloat() * std::numbers::pi; double rd = 8; - double x0 = x + 8 + GameMath::sin(dir) * rd; - double x1 = x + 8 - GameMath::sin(dir) * rd; - double z0 = z + 8 + GameMath::cos(dir) * rd; - double z1 = z + 8 - GameMath::cos(dir) * rd; + double x0 = x + 8 + Mth::sin(dir) * rd; + double x1 = x + 8 - Mth::sin(dir) * rd; + double z0 = z + 8 + Mth::cos(dir) * rd; + double z1 = z + 8 - Mth::cos(dir) * rd; double y0 = y + random->nextInt(8) + 2; double y1 = y + random->nextInt(8) + 2; @@ -28,8 +28,8 @@ bool CaveFeature::place(Level* level, Random* random, int x, int y, int z) { double zz = z0 + (z1 - z0) * d / 16; double ss = random->nextDouble(); - double r = (GameMath::sin(d / 16.0f * std::numbers::pi) * radius + 1) * ss + 1; - double hr = (GameMath::sin(d / 16.0f * std::numbers::pi) * radius + 1) * ss + 1; + double r = (Mth::sin(d / 16.0f * std::numbers::pi) * radius + 1) * ss + 1; + double hr = (Mth::sin(d / 16.0f * std::numbers::pi) * radius + 1) * ss + 1; // 4J Stu Added to stop cave features generating areas previously place // by game rule generation diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/MegaTreeFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/MegaTreeFeature.cpp index 76b49c7e9..f5a670074 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/MegaTreeFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/MegaTreeFeature.cpp @@ -75,13 +75,13 @@ bool MegaTreeFeature::place(Level* level, Random* random, int x, int y, int z) { int branchHeight = y + treeHeight - 2 - random->nextInt(4); while (branchHeight > y + treeHeight / 2) { float angle = random->nextFloat() * std::numbers::pi * 2.0f; - int bx = x + (int)(0.5f + GameMath::cos(angle) * 4.0f); - int bz = z + (int)(0.5f + GameMath::sin(angle) * 4.0f); + int bx = x + (int)(0.5f + Mth::cos(angle) * 4.0f); + int bz = z + (int)(0.5f + Mth::sin(angle) * 4.0f); placeLeaves(level, bx, bz, branchHeight, 0, random); for (int b = 0; b < 5; b++) { - bx = x + (int)(1.5f + GameMath::cos(angle) * b); - bz = z + (int)(1.5f + GameMath::sin(angle) * b); + bx = x + (int)(1.5f + Mth::cos(angle) * b); + bz = z + (int)(1.5f + Mth::sin(angle) * b); placeBlock(level, bx, branchHeight - 3 + b / 2, bz, Tile::treeTrunk_Id, trunkType); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/OreFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/OreFeature.cpp index da1a314e9..59c7af7b9 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/OreFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/feature/OreFeature.cpp @@ -21,10 +21,10 @@ bool OreFeature::place(Level* level, Random* random, int x, int y, int z) { PIXBeginNamedEvent(0, "Place Ore Feature"); float dir = random->nextFloat() * std::numbers::pi; - double x0 = x + 8 + GameMath::sin(dir) * count / 8; - double x1 = x + 8 - GameMath::sin(dir) * count / 8; - double z0 = z + 8 + GameMath::cos(dir) * count / 8; - double z1 = z + 8 - GameMath::cos(dir) * count / 8; + double x0 = x + 8 + Mth::sin(dir) * count / 8; + double x1 = x + 8 - Mth::sin(dir) * count / 8; + double z0 = z + 8 + Mth::cos(dir) * count / 8; + double z1 = z + 8 - Mth::cos(dir) * count / 8; double y0 = y + random->nextInt(3) - 2; double y1 = y + random->nextInt(3) - 2; @@ -42,11 +42,11 @@ bool OreFeature::place(Level* level, Random* random, int x, int y, int z) { int minZ = z0 - 1; double maxss = count / 16; - double maxr = (GameMath::sin(std::numbers::pi) + 1) * maxss + 1; - double maxhr = (GameMath::sin(std::numbers::pi) + 1) * maxss + 1; - int maxX = GameMath::floor(x1 + maxr / 2); - int maxY = GameMath::floor(y1 + maxhr / 2); - int maxZ = GameMath::floor(z1 + maxr / 2); + double maxr = (Mth::sin(std::numbers::pi) + 1) * maxss + 1; + double maxhr = (Mth::sin(std::numbers::pi) + 1) * maxss + 1; + int maxX = Mth::floor(x1 + maxr / 2); + int maxY = Mth::floor(y1 + maxhr / 2); + int maxZ = Mth::floor(z1 + maxr / 2); collisionsExpected = levelGenOptions->checkIntersects(minX, minY, minZ, maxX, maxY, maxZ); @@ -63,19 +63,19 @@ bool OreFeature::place(Level* level, Random* random, int x, int y, int z) { double zz = z0 + (z1 - z0) * d / count; double ss = random->nextDouble() * count / 16; - double r = (GameMath::sin(d * std::numbers::pi / count) + 1) * ss + 1; - double hr = r; //(GameMath::sin(d * std::numbers::pi / count) + 1) * ss + 1; + double r = (Mth::sin(d * std::numbers::pi / count) + 1) * ss + 1; + double hr = r; //(Mth::sin(d * std::numbers::pi / count) + 1) * ss + 1; double halfR = r / 2; double halfHR = halfR; // hr/2; - int xt0 = GameMath::floor(xx - halfR); - int yt0 = GameMath::floor(yy - halfHR); - int zt0 = GameMath::floor(zz - halfR); + int xt0 = Mth::floor(xx - halfR); + int yt0 = Mth::floor(yy - halfHR); + int zt0 = Mth::floor(zz - halfR); - int xt1 = GameMath::floor(xx + halfR); - int yt1 = GameMath::floor(yy + halfHR); - int zt1 = GameMath::floor(zz + halfR); + int xt1 = Mth::floor(xx + halfR); + int yt1 = Mth::floor(yy + halfHR); + int zt1 = Mth::floor(zz + halfR); // 4J Stu Added to stop ore features generating areas previously place // by game rule generation diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/BlockGenMethods.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/BlockGenMethods.cpp index d137074f3..2a3e15912 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/BlockGenMethods.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/BlockGenMethods.cpp @@ -6,12 +6,12 @@ void BlockGenMethods::generateBox(Level* level, std::vector& blocks, int sx, int sy, int sz, int ex, int ey, int ez, std::uint8_t edge, std::uint8_t filling) { - sx = GameMath::clamp(sx, 0, 15); - sy = GameMath::clamp(sy, 0, Level::genDepthMinusOne); - sz = GameMath::clamp(sz, 0, 15); - ex = GameMath::clamp(ex, 0, 15); - ey = GameMath::clamp(ey, 0, Level::genDepthMinusOne); - ez = GameMath::clamp(ez, 0, 15); + sx = Mth::clamp(sx, 0, 15); + sy = Mth::clamp(sy, 0, Level::genDepthMinusOne); + sz = Mth::clamp(sz, 0, 15); + ex = Mth::clamp(ex, 0, 15); + ey = Mth::clamp(ey, 0, Level::genDepthMinusOne); + ez = Mth::clamp(ez, 0, 15); for (int x = sx; x <= ex; x++) { for (int y = sy; y <= ey; y++) { @@ -33,11 +33,11 @@ void BlockGenMethods::generateFrame(Level* level, std::vector& blocks, int sy, int ex, int ey, int flatZ, int direction, std::uint8_t edge, std::uint8_t filling) { - sx = GameMath::clamp(sx, 0, 15); - sy = GameMath::clamp(sy, 0, Level::genDepthMinusOne); - ex = GameMath::clamp(ex, 0, 15); - ey = GameMath::clamp(ey, 0, Level::genDepthMinusOne); - int sz = GameMath::clamp(flatZ, 0, 15); + sx = Mth::clamp(sx, 0, 15); + sy = Mth::clamp(sy, 0, Level::genDepthMinusOne); + ex = Mth::clamp(ex, 0, 15); + ey = Mth::clamp(ey, 0, Level::genDepthMinusOne); + int sz = Mth::clamp(flatZ, 0, 15); int ez = sz; bool alongX = true; @@ -89,12 +89,12 @@ void BlockGenMethods::generateDirectionLine(Level* level, std::vector& int ey, int ez, int startDirection, int endDirection, std::uint8_t block) { - sx = GameMath::clamp(sx, 0, 15); - sy = GameMath::clamp(sy, 0, Level::genDepthMinusOne); - sz = GameMath::clamp(sz, 0, 15); - ex = GameMath::clamp(ex, 0, 15); - ey = GameMath::clamp(ey, 0, Level::genDepthMinusOne); - ez = GameMath::clamp(ez, 0, 15); + sx = Mth::clamp(sx, 0, 15); + sy = Mth::clamp(sy, 0, Level::genDepthMinusOne); + sz = Mth::clamp(sz, 0, 15); + ex = Mth::clamp(ex, 0, 15); + ey = Mth::clamp(ey, 0, Level::genDepthMinusOne); + ez = Mth::clamp(ez, 0, 15); switch (startDirection) { case Direction::WEST: { @@ -136,9 +136,9 @@ void BlockGenMethods::generateDirectionLine(Level* level, std::vector& } break; } - int dx = GameMath::abs(ex - sx); - int dz = GameMath::abs(ez - sz); - int dy = GameMath::abs(ey - sy); + int dx = Mth::abs(ex - sx); + int dz = Mth::abs(ez - sz); + int dy = Mth::abs(ey - sy); int slopeX = sx < ex ? 1 : -1; int slopeZ = sz < ez ? 1 : -1; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/MineShaftFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/MineShaftFeature.cpp index 59ab78b12..aa922aa05 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/MineShaftFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/MineShaftFeature.cpp @@ -1,7 +1,7 @@ #include "../../../../../../Header Files/stdafx.h" #include "net.minecraft.world.level.levelgen.structure.h" #include "java/JavaMath.h" -#include "../../../../util/GameMath.h" +#include "../../../../util/Mth.h" const std::wstring MineShaftFeature::OPTION_CHANCE = L"chance"; @@ -15,7 +15,7 @@ MineShaftFeature::MineShaftFeature( for (auto it = options.begin(); it != options.end(); ++it) { if (it->first.compare(OPTION_CHANCE) == 0) { - chance = GameMath::getDouble(it->second, chance); + chance = Mth::getDouble(it->second, chance); } } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/RandomScatteredLargeFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/RandomScatteredLargeFeature.cpp index 5f0917622..2cd240be8 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/RandomScatteredLargeFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/RandomScatteredLargeFeature.cpp @@ -31,7 +31,7 @@ RandomScatteredLargeFeature::RandomScatteredLargeFeature( for (auto it = options.begin(); it != options.end(); ++it) { if (it->first.compare(OPTION_SPACING) == 0) { - spacing = GameMath::getInt(it->second, spacing, minSeparation + 1); + spacing = Mth::getInt(it->second, spacing, minSeparation + 1); } } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp index 7156a7f3b..eff320037 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp @@ -4,7 +4,7 @@ #include "../../net.minecraft.world.level.h" #include "../../biome/net.minecraft.world.level.biome.h" #include "../../dimension/net.minecraft.world.level.dimension.h" -#include "../../../../util/GameMath.h" +#include "../../../../util/Mth.h" #include "../../../../../../ConsoleHelpers/ConsoleSaveFileIO/FileHeader.h" #include "java/JavaMath.h" @@ -49,14 +49,14 @@ StrongholdFeature::StrongholdFeature( for (auto it = options.begin(); it != options.end(); ++it) { if (it->first.compare(OPTION_DISTANCE) == 0) { - distance = GameMath::getDouble(it->second, distance, 1); + distance = Mth::getDouble(it->second, distance, 1); } else if (it->first.compare(OPTION_COUNT) == 0) { // 4J-JEV: Removed, we only have the one stronghold. - // strongholdPos = new ChunkPos[ GameMath::getInt(it->second, + // strongholdPos = new ChunkPos[ Mth::getInt(it->second, // strongholdPos_length, 1) ]; assert(false); } else if (it->first.compare(OPTION_SPREAD) == 0) { - spread = GameMath::getInt(it->second, spread, 1); + spread = Mth::getInt(it->second, spread, 1); } } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/VillageFeature.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/VillageFeature.cpp index 309d2345d..18303d3a7 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/VillageFeature.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/structure/VillageFeature.cpp @@ -32,10 +32,10 @@ VillageFeature::VillageFeature( for (auto it = options.begin(); it != options.end(); ++it) { if (it->first.compare(OPTION_SIZE_MODIFIER) == 0) { villageSizeModifier = - GameMath::getInt(it->second, villageSizeModifier, 0); + Mth::getInt(it->second, villageSizeModifier, 0); } else if (it->first.compare(OPTION_SPACING) == 0) { townSpacing = - GameMath::getInt(it->second, townSpacing, minTownSeparation + 1); + Mth::getInt(it->second, townSpacing, minTownSeparation + 1); } } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/synth/PerlinNoise.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/synth/PerlinNoise.cpp index 155a6d3e4..7b06a1858 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/synth/PerlinNoise.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/levelgen/synth/PerlinNoise.cpp @@ -1,6 +1,6 @@ #include "../../../../../../Header Files/stdafx.h" #include "PerlinNoise.h" -#include "../../../../util/GameMath.h" +#include "../../../../util/Mth.h" PerlinNoise::PerlinNoise(int levels) { Random random; @@ -67,8 +67,8 @@ std::vector PerlinNoise::getRegion(std::vector& buffer, int x, i double xx = x * pow * xScale; double yy = y * pow * yScale; double zz = z * pow * zScale; - int64_t xb = GameMath::lfloor(xx); - int64_t zb = GameMath::lfloor(zz); + int64_t xb = Mth::lfloor(xx); + int64_t zb = Mth::lfloor(zz); xx -= xb; zz -= zb; xb %= 16777216; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/Node.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/Node.cpp index 65afb2908..a7f5f643f 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/Node.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/Node.cpp @@ -34,7 +34,7 @@ float Node::distanceTo(Node* to) { float xd = (float)(to->x - x); float yd = (float)(to->y - y); float zd = (float)(to->z - z); - return GameMath::sqrt(xd * xd + yd * yd + zd * zd); + return Mth::sqrt(xd * xd + yd * yd + zd * zd); } float Node::distanceToSqr(Node* to) { diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/PathFinder.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/PathFinder.cpp index 1d8345832..0c2a6220f 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/PathFinder.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/pathfinder/PathFinder.cpp @@ -45,20 +45,20 @@ Path* PathFinder::findPath(Entity* e, double xt, double yt, double zt, nodes.clear(); bool resetAvoidWater = avoidWater; - int startY = GameMath::floor(e->bb.y0 + 0.5f); + int startY = Mth::floor(e->bb.y0 + 0.5f); if (canFloat && e->isInWater()) { startY = (int)(e->bb.y0); - int tileId = level->getTile((int)GameMath::floor(e->x), startY, - (int)GameMath::floor(e->z)); + int tileId = level->getTile((int)Mth::floor(e->x), startY, + (int)Mth::floor(e->z)); while (tileId == Tile::water_Id || tileId == Tile::calmWater_Id) { ++startY; - tileId = level->getTile((int)GameMath::floor(e->x), startY, - (int)GameMath::floor(e->z)); + tileId = level->getTile((int)Mth::floor(e->x), startY, + (int)Mth::floor(e->z)); } resetAvoidWater = avoidWater; avoidWater = false; } else - startY = GameMath::floor(e->bb.y0 + 0.5f); + startY = Mth::floor(e->bb.y0 + 0.5f); Node* from = getNode((int)floor(e->bb.x0), startY, (int)floor(e->bb.z0)); Node* to = getNode((int)floor(xt - e->bbWidth / 2), (int)floor(yt), @@ -231,9 +231,9 @@ int PathFinder::isFree(Entity* entity, int x, int y, int z, Node* size, // have already got if (entity->level->getTileRenderShape(tileId) == Tile::SHAPE_RAIL) { - int xt = GameMath::floor(entity->x); - int yt = GameMath::floor(entity->y); - int zt = GameMath::floor(entity->z); + int xt = Mth::floor(entity->x); + int yt = Mth::floor(entity->y); + int zt = Mth::floor(entity->z); if (entity->level->getTileRenderShape(xt, yt, zt) == Tile::SHAPE_RAIL || entity->level->getTileRenderShape(xt, yt - 1, zt) == diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/AnvilTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/AnvilTile.cpp index 31333e456..04dd3d24b 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/AnvilTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/AnvilTile.cpp @@ -46,7 +46,7 @@ void AnvilTile::registerIcons(IconRegister* iconRegister) { void AnvilTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = (GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3; + int dir = (Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3; int dmg = level->getData(x, y, z) >> 2; dir = ++dir % 4; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/ChestTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/ChestTile.cpp index ad06375ac..ae213494c 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/ChestTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/ChestTile.cpp @@ -66,7 +66,7 @@ void ChestTile::setPlacedBy(Level* level, int x, int y, int z, int e = level->getTile(x + 1, y, z); // face = 5 int facing = 0; - int dir = (GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3; + int dir = (Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3; if (dir == 0) facing = Facing::NORTH; if (dir == 1) facing = Facing::EAST; @@ -332,7 +332,7 @@ int ChestTile::getSignal(LevelSource* level, int x, int y, int z, int dir) { int openCount = std::dynamic_pointer_cast( level->getTileEntity(x, y, z)) ->openCount; - return GameMath::clamp(openCount, Redstone::SIGNAL_NONE, Redstone::SIGNAL_MAX); + return Mth::clamp(openCount, Redstone::SIGNAL_NONE, Redstone::SIGNAL_MAX); } int ChestTile::getDirectSignal(LevelSource* level, int x, int y, int z, diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/CocoaTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/CocoaTile.cpp index 12353ca7b..2ab3a4081 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/CocoaTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/CocoaTile.cpp @@ -105,7 +105,7 @@ void CocoaTile::updateShape(LevelSource* level, int x, int y, int z, void CocoaTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = (((GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3) + 0) % 4; + int dir = (((Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3) + 0) % 4; level->setData(x, y, z, dir, Tile::UPDATE_CLIENTS); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/DiodeTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/DiodeTile.cpp index a1f5fe0df..474608bdf 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/DiodeTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/DiodeTile.cpp @@ -205,7 +205,7 @@ bool DiodeTile::isSignalSource() { return true; } void DiodeTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = (((GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3) + 2) % 4; + int dir = (((Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3) + 2) % 4; level->setData(x, y, z, dir, Tile::UPDATE_ALL); bool sourceOn = shouldTurnOn(level, x, y, z, dir); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/EnderChestTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/EnderChestTile.cpp index 237f06b17..39e4f2b04 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/EnderChestTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/EnderChestTile.cpp @@ -36,7 +36,7 @@ void EnderChestTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { int facing = 0; - int dir = (GameMath::floor(by->yRot * 4 / (360) + 0.5f)) & 3; + int dir = (Mth::floor(by->yRot * 4 / (360) + 0.5f)) & 3; if (dir == 0) facing = Facing::NORTH; if (dir == 1) facing = Facing::EAST; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/FenceGateTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/FenceGateTile.cpp index 6c38bcb93..5cc32d7af 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/FenceGateTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/FenceGateTile.cpp @@ -72,7 +72,7 @@ int FenceGateTile::getRenderShape() { return Tile::SHAPE_FENCE_GATE; } void FenceGateTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = (((GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3)) % 4; + int dir = (((Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3)) % 4; level->setData(x, y, z, dir, Tile::UPDATE_CLIENTS); } @@ -95,7 +95,7 @@ bool FenceGateTile::use(Level* level, int x, int y, int z, level->setData(x, y, z, data & ~OPEN_BIT, Tile::UPDATE_CLIENTS); } else { // open the door from the player - int dir = (((GameMath::floor(player->yRot * 4 / (360) + 0.5)) & 3)) % 4; + int dir = (((Mth::floor(player->yRot * 4 / (360) + 0.5)) & 3)) % 4; int current = getDirection(data); if (current == ((dir + 2) % 4)) { data = dir; diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/FurnaceTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/FurnaceTile.cpp index 203e4f6e4..f44e4460b 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/FurnaceTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/FurnaceTile.cpp @@ -135,7 +135,7 @@ std::shared_ptr FurnaceTile::newTileEntity(Level* level) { void FurnaceTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = (GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3; + int dir = (Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3; if (dir == 0) level->setData(x, y, z, Facing::NORTH, Tile::UPDATE_CLIENTS); if (dir == 1) level->setData(x, y, z, Facing::EAST, Tile::UPDATE_CLIENTS); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/GlowstoneTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/GlowstoneTile.cpp index 0eda5c16f..6c30adfb3 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/GlowstoneTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/GlowstoneTile.cpp @@ -6,7 +6,7 @@ Glowstonetile::Glowstonetile(int id, Material* material) : Tile(id, material) {} int Glowstonetile::getResourceCountForLootBonus(int bonusLevel, Random* random) { - return GameMath::clamp( + return Mth::clamp( getResourceCount(random) + random->nextInt(bonusLevel + 1), 1, 4); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/LeverTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/LeverTile.cpp index 4bc31c3ee..0f1deb65e 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/LeverTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/LeverTile.cpp @@ -85,13 +85,13 @@ void LeverTile::setPlacedBy(Level* level, int x, int y, int z, int flip = data & 8; if (dir == getLeverFacing(Facing::UP)) { - if ((GameMath::floor(by->yRot * 4 / (360) + 0.5) & 1) == 0) { + if ((Mth::floor(by->yRot * 4 / (360) + 0.5) & 1) == 0) { level->setData(x, y, z, 5 | flip, Tile::UPDATE_CLIENTS); } else { level->setData(x, y, z, 6 | flip, Tile::UPDATE_CLIENTS); } } else if (dir == getLeverFacing(Facing::DOWN)) { - if ((GameMath::floor(by->yRot * 4 / (360) + 0.5) & 1) == 0) { + if ((Mth::floor(by->yRot * 4 / (360) + 0.5) & 1) == 0) { level->setData(x, y, z, 7 | flip, Tile::UPDATE_CLIENTS); } else { level->setData(x, y, z, 0 | flip, Tile::UPDATE_CLIENTS); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/PumpkinTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/PumpkinTile.cpp index 721c6591f..8c7809d88 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/PumpkinTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/PumpkinTile.cpp @@ -175,7 +175,7 @@ bool PumpkinTile::mayPlace(Level* level, int x, int y, int z) { void PumpkinTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = GameMath::floor(by->yRot * 4 / (360) + 2.5) & 3; + int dir = Mth::floor(by->yRot * 4 / (360) + 2.5) & 3; level->setData(x, y, z, dir, Tile::UPDATE_CLIENTS); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/SkullTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/SkullTile.cpp index 3a9f9eef7..fc1864c5d 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/SkullTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/SkullTile.cpp @@ -55,7 +55,7 @@ std::optional SkullTile::getAABB(Level* level, int x, int y, int z) { void SkullTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by) { - int dir = GameMath::floor(by->yRot * 4 / (360) + 2.5) & 3; + int dir = Mth::floor(by->yRot * 4 / (360) + 2.5) & 3; level->setData(x, y, z, dir, Tile::UPDATE_CLIENTS); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/StairTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/StairTile.cpp index 049d5aafb..646ecc310 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/StairTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/StairTile.cpp @@ -391,7 +391,7 @@ void StairTile::wasExploded(Level* level, int x, int y, int z, void StairTile::setPlacedBy(Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = (GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3; + int dir = (Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3; int usd = level->getData(x, y, z) & UPSIDEDOWN_BIT; if (dir == 0) diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/TheEndPortalFrameTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/TheEndPortalFrameTile.cpp index 2b2740cba..e75e7a0fb 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/TheEndPortalFrameTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/TheEndPortalFrameTile.cpp @@ -64,7 +64,7 @@ int TheEndPortalFrameTile::getResource(int data, Random* random, void TheEndPortalFrameTile::setPlacedBy( Level* level, int x, int y, int z, std::shared_ptr by, std::shared_ptr itemInstance) { - int dir = (((GameMath::floor(by->yRot * 4 / (360) + 0.5)) & 3) + 2) % 4; + int dir = (((Mth::floor(by->yRot * 4 / (360) + 0.5)) & 3) + 2) % 4; level->setData(x, y, z, dir, Tile::UPDATE_CLIENTS); } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/WeightedPressurePlateTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/WeightedPressurePlateTile.cpp index 9bfe01a3e..18a429aec 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/WeightedPressurePlateTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/WeightedPressurePlateTile.cpp @@ -29,7 +29,7 @@ int WeightedPressurePlateTile::getSignalStrength(Level* level, int x, int y, return 0; } else { float pct = std::min(maxWeight, count) / (float)maxWeight; - return GameMath::ceil(pct * Redstone::SIGNAL_MAX); + return Mth::ceil(pct * Redstone::SIGNAL_MAX); } } diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/HopperTileEntity.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/HopperTileEntity.cpp index b14be4e42..62456fbe4 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/HopperTileEntity.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/entity/HopperTileEntity.cpp @@ -366,9 +366,9 @@ std::shared_ptr HopperTileEntity::getContainerAt(Level* level, double z) { std::shared_ptr result = nullptr; - int xt = GameMath::floor(x); - int yt = GameMath::floor(y); - int zt = GameMath::floor(z); + int xt = Mth::floor(x); + int yt = Mth::floor(y); + int zt = Mth::floor(z); std::shared_ptr entity = level->getTileEntity(xt, yt, zt); diff --git a/minecraft/Minecraft.World/net/minecraft/world/level/tile/piston/PistonBaseTile.cpp b/minecraft/Minecraft.World/net/minecraft/world/level/tile/piston/PistonBaseTile.cpp index 1c3500e5c..0c039c1c2 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/level/tile/piston/PistonBaseTile.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/level/tile/piston/PistonBaseTile.cpp @@ -414,8 +414,8 @@ bool PistonBaseTile::isExtended(int data) { return (data & EXTENDED_BIT) != 0; } int PistonBaseTile::getNewFacing(Level* level, int x, int y, int z, std::shared_ptr player) { - if (GameMath::abs((float)player->x - x) < 2 && - GameMath::abs((float)player->z - z) < 2) { + if (Mth::abs((float)player->x - x) < 2 && + Mth::abs((float)player->z - z) < 2) { // If the player is above the block, the slot is on the top double py = player->y + 1.82 - player->heightOffset; if (py - y > 2) { @@ -427,7 +427,7 @@ int PistonBaseTile::getNewFacing(Level* level, int x, int y, int z, } } // The slot is on the side - int i = GameMath::floor(player->yRot * 4.0f / 360.0f + 0.5) & 0x3; + int i = Mth::floor(player->yRot * 4.0f / 360.0f + 0.5) & 0x3; if (i == 0) return Facing::NORTH; if (i == 1) return Facing::EAST; if (i == 2) return Facing::SOUTH; diff --git a/minecraft/Minecraft.World/net/minecraft/world/scores/criteria/HealthCriteria.cpp b/minecraft/Minecraft.World/net/minecraft/world/scores/criteria/HealthCriteria.cpp index 0c4838487..bfb427622 100644 --- a/minecraft/Minecraft.World/net/minecraft/world/scores/criteria/HealthCriteria.cpp +++ b/minecraft/Minecraft.World/net/minecraft/world/scores/criteria/HealthCriteria.cpp @@ -15,7 +15,7 @@ int HealthCriteria::getScoreModifier( if (players->size() > 0) health /= players->size(); - return GameMath::ceil(health); + return Mth::ceil(health); } bool HealthCriteria::isReadOnly() { return true; } \ No newline at end of file