nuke Minecraft.World stdafx.h

This commit is contained in:
Tropical
2026-03-31 17:58:27 -05:00
parent 70e93e57c3
commit 1ce8413cfa
108 changed files with 318 additions and 291 deletions
@@ -48,6 +48,8 @@
#include "Minecraft.Client/Common/Source Files/Localisation/StringTable.h"
#include "Minecraft.Client/Common/Source Files/UI/All Platforms/ArchiveFile.h"
#include "Minecraft.Client/net/minecraft/client/Minecraft.h"
#include "Minecraft.Client/Common/Source Files/Leaderboards/LeaderboardManager.h"
#include "Minecraft.Client/Common/Source Files/Colours/ColourTable.h"
#include "4J_Input.h"
#include "Minecraft.Client/net/minecraft/client/gui/Gui.h"
@@ -63,7 +65,6 @@
#include <thread>
#include <chrono>
#include "Minecraft.Client/Common/Source Files/Leaderboards/LeaderboardManager.h"
// CMinecraftApp app;
unsigned int CMinecraftApp::m_uiLastSignInData = 0;
@@ -23,6 +23,7 @@
#include "Minecraft.World/net/minecraft/world/entity/Mob.h"
#include "java/Random.h"
#include "Minecraft.Client/net/minecraft/client/Minecraft.h"
#include "Minecraft.World/net/minecraft/util/Mth.h"
#if defined(__linux__)
#define STB_VORBIS_HEADER_ONLY
@@ -82,18 +82,18 @@ void ApplySchematicRuleDefinition::addAttribute(
}
} else if (attributeName.compare(L"x") == 0) {
m_location.x = _fromString<int>(attributeValue);
if (((int)abs(m_location.x)) % 2 != 0) m_location.x -= 1;
if (((int)std::abs(m_location.x)) % 2 != 0) m_location.x -= 1;
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// x=%f\n",m_location->x);
} else if (attributeName.compare(L"y") == 0) {
m_location.y = _fromString<int>(attributeValue);
if (((int)abs(m_location.y)) % 2 != 0) m_location.y -= 1;
if (((int)std::abs(m_location.y)) % 2 != 0) m_location.y -= 1;
if (m_location.y < 0) m_location.y = 0;
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// y=%f\n",m_location->y);
} else if (attributeName.compare(L"z") == 0) {
m_location.z = _fromString<int>(attributeValue);
if (((int)abs(m_location.z)) % 2 != 0) m_location.z -= 1;
if (((int)std::abs(m_location.z)) % 2 != 0) m_location.z -= 1;
// app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter
// z=%f\n",m_location->z);
} else if (attributeName.compare(L"rot") == 0) {
@@ -5,9 +5,12 @@
#include <cstdint>
#include "Minecraft.Client/Common/Source Files/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "Minecraft.World/net/minecraft/world/level/levelgen/structure/StructureFeature.h"
#include "Minecraft.Client/Common/Source Files/GameRules/LevelRules/RuleDefinitions/GameRuleDefinition.h"
#include "Minecraft.Client/Common/Source Files/Localisation/StringTable.h"
#include "Minecraft.Client/Common/Source Files/DLC/DLCPack.h"
class ApplySchematicRuleDefinition;
class LevelChunk;
class ConsoleGenerateStructure;
@@ -10,6 +10,7 @@
#include "Minecraft.Client/Common/Source Files/Tutorial/Hints/AreaHint.h"
#include "FullTutorial.h"
#include "Minecraft.Client/Common/Source Files/Tutorial/Constraints/TutorialConstraints.h"
#include "Minecraft.Client/Common/Potion_Macros.h"
FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/)
: Tutorial(iPad, true) {
@@ -18,6 +18,7 @@
#include "Minecraft.Client/Common/Source Files/Tutorial/Tasks/TutorialTasks.h"
#include "Minecraft.Client/Common/Source Files/Tutorial/Constraints/TutorialConstraints.h"
#include "Minecraft.Client/Common/Source Files/Tutorial/Hints/TutorialHints.h"
#include "Minecraft.World/ConsoleHelpers/StringHelpers.h"
std::vector<int> Tutorial::s_completableTasks;
@@ -5,6 +5,7 @@
#include "Minecraft.World/net/minecraft/stats/net.minecraft.stats.h"
#include "Minecraft.Client/net/minecraft/client/player/LocalPlayer.h"
#include "IUIScene_CraftingMenu.h"
#include "Minecraft.Client/Common/Source Files/Console_Debug_enum.h"
Recipy::_eGroupType IUIScene_CraftingMenu::m_GroupTypeMapping4GridA
[IUIScene_CraftingMenu::m_iMaxGroup2x2] = {
@@ -10,6 +10,7 @@
#include "Minecraft.World/net/minecraft/world/item/enchantment/net.minecraft.world.item.enchantment.h"
#include "Minecraft.World/net/minecraft/world/entity/net.minecraft.world.entity.h"
#include "Minecraft.World/net/minecraft/world/entity/animal/net.minecraft.world.entity.animal.h"
#include "Minecraft.Client/Common/Potion_Macros.h"
#include "java/JavaMath.h"
// 4J JEV - Images for each tab.
@@ -340,7 +340,7 @@ void UIScene_MainMenu::customDrawSplash(IggyCustomDrawCallbackRegion* region) {
glTranslatef(xo, yo, 0);
glRotatef(-17, 0, 0, 1);
float sss = 1.8f - Mth::abs(sinf(System::currentTimeMillis() % 1000 /
float sss = 1.8f - std::abs(sinf(System::currentTimeMillis() % 1000 /
1000.0f * std::numbers::pi * 2) *
0.1f);
sss *= (m_fScreenWidth / m_fRawWidth);
@@ -12,6 +12,7 @@
#include "Minecraft.Client/net/minecraft/client/renderer/entity/EnderDragonRenderer.h"
#include "Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerLocalPlayer.h"
#include "Minecraft.Client/net/minecraft/client/title/TitleScreen.h"
#include "Minecraft.World/ConsoleHelpers/PerformanceTimer.h"
#include "UIFontData.h"
#include "4J_Input.h"
@@ -83,6 +83,10 @@
#include "Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerGameMode.h"
#include "Minecraft.Client/Common/Source Files/DLC/DLCPack.h"
#include "Minecraft.Client/Common/Source Files/ConsoleGameMode.h"
#include "Minecraft.World/ConsoleHelpers/StringHelpers.h"
#include "Minecraft.Client/Common/Potion_Macros.h"
#include "Minecraft.Client/Common/Minecraft_Macros.h"
#include "Minecraft.Client/Common/Source Files/Colours/ColourTable.h"
#include "4J_Input.h"
// #define DISABLE_SPU_CODE
@@ -3557,9 +3561,9 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
// Level::animateTickDoWork() so we can take into account multiple
// players in the one level.
if (!pause && levels[i] != nullptr)
levels[i]->animateTick(Mth::floor(player->x),
Mth::floor(player->y),
Mth::floor(player->z));
levels[i]->animateTick(std::floor(player->x),
std::floor(player->y),
std::floor(player->z));
if (levelsTickedFlags & (1 << i))
continue; // Don't tick further if we've already ticked this
@@ -34,6 +34,7 @@
#include "Minecraft.Client/net/minecraft/client/gui/ScreenSizeCalculator.h"
#include "Minecraft.Client/net/minecraft/client/ClientConstants.h"
#include "Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerGameMode.h"
#include "Minecraft.World/net/minecraft/util/Mth.h"
ResourceLocation Gui::PUMPKIN_BLUR_LOCATION =
ResourceLocation(TN__BLUR__MISC_PUMPKINBLUR);
@@ -331,7 +331,7 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot,
is = is * is * is;
is = is * is * is;
float iss = 1 - is;
arm0->xRot = -Mth::abs(cosf(eating_t / 4.0f * std::numbers::pi) * 0.1f) *
arm0->xRot = -std::abs(cosf(eating_t / 4.0f * std::numbers::pi) * 0.1f) *
(eating_swing > 0.2 ? 1.0f : 0.0f) *
2.0f; // This factor is the chomping bit (conditional
// factor is so that he doesn't eat whilst the
@@ -11,6 +11,7 @@
#include "Minecraft.World/net/minecraft/world/entity/LivingEntity.h"
#include "Minecraft.World/net/minecraft/world/entity/animal/EntityHorse.h"
#include "Minecraft.Client/net/minecraft/client/model/geom/Model.h"
#include "Minecraft.World/net/minecraft/util/Mth.h"
ModelHorse::ModelHorse() {
texWidth = 128;
@@ -7,6 +7,7 @@
#include "VillagerModel.h"
#include "Minecraft.World/net/minecraft/util/Mth.h"
#include "Minecraft.World/net/minecraft/world/entity/Entity.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);
@@ -55,6 +55,7 @@
#include "Minecraft.Client/Common/Source Files/Tutorial/TutorialMode.h"
#include "Minecraft.Client/Common/Source Files/Tutorial/FullTutorialMode.h"
#include "Minecraft.Client/Common/Source Files/DLC/DLCPack.h"
#include "Minecraft.World/ConsoleHelpers/StringHelpers.h"
#include "4J_Input.h"
ClientConnection::ClientConnection(Minecraft* minecraft, const std::wstring& ip,
@@ -2579,9 +2580,9 @@ void ClientConnection::handleContainerOpen(
}
} break;
case ContainerOpenPacket::WORKBENCH: {
if (player->startCrafting(Mth::floor(player->x),
Mth::floor(player->y),
Mth::floor(player->z))) {
if (player->startCrafting(std::floor(player->x),
std::floor(player->y),
std::floor(player->z))) {
player->containerMenu->containerId = packet->containerId;
} else {
failed = true;
@@ -2589,8 +2590,8 @@ void ClientConnection::handleContainerOpen(
} break;
case ContainerOpenPacket::ENCHANTMENT: {
if (player->startEnchanting(
Mth::floor(player->x), Mth::floor(player->y),
Mth::floor(player->z),
std::floor(player->x), std::floor(player->y),
std::floor(player->z),
packet->customName ? packet->title : L"")) {
player->containerMenu->containerId = packet->containerId;
} else {
@@ -2621,9 +2622,9 @@ void ClientConnection::handleContainerOpen(
}
} break;
case ContainerOpenPacket::REPAIR_TABLE: {
if (player->startRepairing(Mth::floor(player->x),
Mth::floor(player->y),
Mth::floor(player->z))) {
if (player->startRepairing(std::floor(player->x),
std::floor(player->y),
std::floor(player->z))) {
player->containerMenu->containerId = packet->containerId;
} else {
failed = true;
@@ -2655,9 +2656,9 @@ void ClientConnection::handleContainerOpen(
}
} break;
case ContainerOpenPacket::FIREWORKS: {
if (player->openFireworks(Mth::floor(player->x),
Mth::floor(player->y),
Mth::floor(player->z))) {
if (player->openFireworks(std::floor(player->x),
std::floor(player->y),
std::floor(player->z))) {
player->containerMenu->containerId = packet->containerId;
} else {
failed = true;
@@ -80,7 +80,7 @@ void MultiplayerLocalPlayer::tick() {
);
}*/
if (!level->hasChunkAt(Mth::floor(x), 0, Mth::floor(z))) return;
if (!level->hasChunkAt(std::floor(x), 0, std::floor(z))) return;
double tempX = x, tempY = y, tempZ = z;
@@ -35,7 +35,7 @@ void BubbleParticle::tick() {
yd *= 0.85f;
zd *= 0.85f;
if (level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)) !=
if (level->getMaterial(std::floor(x), std::floor(y), std::floor(z)) !=
Material::water)
remove();
@@ -123,11 +123,11 @@ void DripParticle::tick() {
}
Material* m =
level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z));
level->getMaterial(std::floor(x), std::floor(y), std::floor(z));
if (m->isLiquid() || m->isSolid()) {
double y0 = Mth::floor(y) + 1 -
double y0 = std::floor(y) + 1 -
LiquidTile::getHeight(level->getData(
Mth::floor(x), Mth::floor(y), Mth::floor(z)));
std::floor(x), std::floor(y), std::floor(z)));
if (y < y0) {
remove();
}
@@ -42,7 +42,7 @@ void FootstepParticle::render(Tesselator* t, float a, float xa, float ya,
float zz = (float)(z - zOff);
float br =
level->getBrightness(Mth::floor(x), Mth::floor(y), Mth::floor(z));
level->getBrightness(std::floor(x), std::floor(y), std::floor(z));
textures->bindTexture(&FOOTPRINT_LOCATION);
glEnable(GL_BLEND);
@@ -64,7 +64,7 @@ Particle::Particle(Level* level, double x, double y, double z, double xa,
zd = za + (float)(Math::random() * 2 - 1) * 0.4f;
float speed = (float)(Math::random() + Math::random() + 1) * 0.15f;
float dd = (float)(Mth::sqrt(xd * xd + yd * yd + zd * zd));
float dd = (float)(std::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;
@@ -41,7 +41,7 @@ void SuspendedParticle::tick() {
move(xd, yd, zd);
if (level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z)) !=
if (level->getMaterial(std::floor(x), std::floor(y), std::floor(z)) !=
Material::water)
remove();
@@ -45,9 +45,9 @@ void TakeAnimationParticle::render(Tesselator* t, float a, float xa, float ya,
double yy = yo + (yt - yo) * time;
double zz = zo + (zt - zo) * time;
int xTile = Mth::floor(xx);
int yTile = Mth::floor(yy + heightOffset / 2.0f);
int zTile = Mth::floor(zz);
int xTile = std::floor(xx);
int yTile = std::floor(yy + heightOffset / 2.0f);
int zTile = std::floor(zz);
// 4J - change brought forward from 1.8.2
if (SharedConstants::TEXTURE_LIGHTING) {
@@ -45,11 +45,11 @@ void WaterDropParticle::tick() {
}
Material* m =
level->getMaterial(Mth::floor(x), Mth::floor(y), Mth::floor(z));
level->getMaterial(std::floor(x), std::floor(y), std::floor(z));
if (m->isLiquid() || m->isSolid()) {
double y0 = Mth::floor(y) + 1 -
double y0 = std::floor(y) + 1 -
LiquidTile::getHeight(level->getData(
Mth::floor(x), Mth::floor(y), Mth::floor(z)));
std::floor(x), std::floor(y), std::floor(z)));
if (y < y0) {
remove();
}
@@ -1097,9 +1097,9 @@ bool LocalPlayer::isSolidBlock(int x, int y, int z) {
}
bool LocalPlayer::checkInTile(double x, double y, double z) {
int xTile = Mth::floor(x);
int yTile = Mth::floor(y);
int zTile = Mth::floor(z);
int xTile = std::floor(x);
int yTile = std::floor(y);
int zTile = std::floor(z);
double xd = x - xTile;
double zd = z - zTile;
@@ -54,7 +54,7 @@ void RemotePlayer::tick() {
walkAnimSpeedO = walkAnimSpeed;
double xxd = x - xo;
double zzd = z - zo;
float wst = Mth::sqrt(xxd * xxd + zzd * zzd) * 4;
float wst = std::sqrt(xxd * xxd + zzd * zzd) * 4;
if (wst > 1) wst = 1;
walkAnimSpeed += (wst - walkAnimSpeed) * 0.4f;
walkAnimPos += walkAnimSpeed;
@@ -106,7 +106,7 @@ void RemotePlayer::aiStep() {
}
oBob = bob;
float tBob = (float)Mth::sqrt(xd * xd + zd * zd);
float tBob = (float)std::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;
@@ -243,9 +243,9 @@ void GameRenderer::tick(bool first) // 4J - add bFirst
mc->cameraTargetPlayer = std::dynamic_pointer_cast<Mob>(mc->player);
}
float brr = mc->level->getBrightness(Mth::floor(mc->cameraTargetPlayer->x),
Mth::floor(mc->cameraTargetPlayer->y),
Mth::floor(mc->cameraTargetPlayer->z));
float brr = mc->level->getBrightness(std::floor(mc->cameraTargetPlayer->x),
std::floor(mc->cameraTargetPlayer->y),
std::floor(mc->cameraTargetPlayer->z));
float whiteness = (3 - mc->options->viewDistance) / 3.0f;
float fogBrT = brr * (1 - whiteness) + whiteness;
fogBr += (fogBrT - fogBr) * 0.1f;
@@ -479,12 +479,12 @@ void GameRenderer::moveCameraToPlayer(float a) {
glTranslatef(0.0f, 0.3f, 0);
if (!mc->options->fixedCamera) {
int t =
mc->level->getTile(Mth::floor(player->x), Mth::floor(player->y),
Mth::floor(player->z));
mc->level->getTile(std::floor(player->x), std::floor(player->y),
std::floor(player->z));
if (t == Tile::bed_Id) {
int data = mc->level->getData(Mth::floor(player->x),
Mth::floor(player->y),
Mth::floor(player->z));
int data = mc->level->getData(std::floor(player->x),
std::floor(player->y),
std::floor(player->z));
int direction = data & 3;
glRotatef((float)direction * 90, 0.0f, 1.0f, 0.0f);
@@ -1545,9 +1545,9 @@ void GameRenderer::tickRain() {
std::shared_ptr<LivingEntity> player = mc->cameraTargetPlayer;
Level* level = mc->level;
int x0 = Mth::floor(player->x);
int y0 = Mth::floor(player->y);
int z0 = Mth::floor(player->z);
int x0 = std::floor(player->x);
int y0 = std::floor(player->y);
int z0 = std::floor(player->z);
int r = 10;
@@ -1597,9 +1597,9 @@ void GameRenderer::tickRain() {
if (rainPosSamples > 0 && random->nextInt(3) < rainSoundTime++) {
rainSoundTime = 0;
if (rainPosY > player->y + 1 &&
level->getTopRainBlock(Mth::floor(player->x),
Mth::floor(player->z)) >
Mth::floor(player->y)) {
level->getTopRainBlock(std::floor(player->x),
std::floor(player->z)) >
std::floor(player->y)) {
mc->level->playLocalSound(rainPosX, rainPosY, rainPosZ,
eSoundType_AMBIENT_WEATHER_RAIN, 0.1f,
0.5f);
@@ -1629,7 +1629,7 @@ void GameRenderer::renderSnowAndRain(float a) {
for (int x = 0; x < 32; x++) {
float xa = x - 16;
float za = z - 16;
float d = Mth::sqrt(xa * xa + za * za);
float d = std::sqrt(xa * xa + za * za);
rainXa[z << 5 | x] = -za / d;
rainZa[z << 5 | x] = xa / d;
}
@@ -1639,9 +1639,9 @@ void GameRenderer::renderSnowAndRain(float a) {
std::shared_ptr<LivingEntity> player = mc->cameraTargetPlayer;
Level* level = mc->level;
int x0 = Mth::floor(player->x);
int y0 = Mth::floor(player->y);
int z0 = Mth::floor(player->z);
int x0 = std::floor(player->x);
int y0 = std::floor(player->y);
int z0 = std::floor(player->z);
Tesselator* t = Tesselator::getInstance();
glDisable(GL_CULL_FACE);
@@ -1657,7 +1657,7 @@ void GameRenderer::renderSnowAndRain(float a) {
double yo = player->yOld + (player->y - player->yOld) * a;
double zo = player->zOld + (player->z - player->zOld) * a;
int yMin = Mth::floor(yo);
int yMin = std::floor(yo);
int r = 5;
// 4J - was if(mc.options.fancyGraphics) r = 10;
@@ -1722,7 +1722,7 @@ void GameRenderer::renderSnowAndRain(float a) {
double xd = (x + 0.5f) - player->x;
double zd = (z + 0.5f) - player->z;
float dd = (float)Mth::sqrt(xd * xd + zd * zd) / r;
float dd = (float)std::sqrt(xd * xd + zd * zd) / r;
float br = 1.0f;
float s = 1.0f;
@@ -452,13 +452,13 @@ void ItemInHandRenderer::render(float a) {
std::shared_ptr<ItemInstance> item = selectedItem;
float br = minecraft->level->getBrightness(
Mth::floor(player->x), Mth::floor(player->y), Mth::floor(player->z));
std::floor(player->x), std::floor(player->y), std::floor(player->z));
// 4J - change brought forward from 1.8.2
if (SharedConstants::TEXTURE_LIGHTING) {
br = 1;
int col = minecraft->level->getLightColor(Mth::floor(player->x),
Mth::floor(player->y),
Mth::floor(player->z), 0);
int col = minecraft->level->getLightColor(std::floor(player->x),
std::floor(player->y),
std::floor(player->z), 0);
int u = col % 65536;
int v = col / 65536;
#if defined(__linux__)
@@ -621,7 +621,7 @@ void ItemInHandRenderer::render(float a) {
is = is * is * is;
float iss = 1 - is;
glTranslatef(0,
Mth::abs(cosf(t / 4 * std::numbers::pi) * 0.1f) *
std::abs(cosf(t / 4 * std::numbers::pi) * 0.1f) *
(swing > 0.2 ? 1 : 0),
0);
glTranslatef(iss * 0.6f, -iss * 0.5f, 0);
@@ -783,9 +783,9 @@ void ItemInHandRenderer::renderScreenEffect(float a) {
if (minecraft->player->isInWall()) // Inside a tile
{
int x = Mth::floor(minecraft->player->x);
int y = Mth::floor(minecraft->player->y);
int z = Mth::floor(minecraft->player->z);
int x = std::floor(minecraft->player->x);
int y = std::floor(minecraft->player->y);
int z = std::floor(minecraft->player->z);
int tile = minecraft->level->getTile(x, y, z);
if (minecraft->level->isSolidBlockingTile(x, y, z)) {
@@ -798,9 +798,9 @@ void ItemInHandRenderer::renderScreenEffect(float a) {
((i >> 1) % 2 - 0.5f) * minecraft->player->bbHeight * 0.2f;
float zo =
((i >> 2) % 2 - 0.5f) * minecraft->player->bbWidth * 0.9f;
int xt = Mth::floor(x + xo);
int yt = Mth::floor(y + yo);
int zt = Mth::floor(z + zo);
int xt = std::floor(x + xo);
int yt = std::floor(y + yo);
int zt = std::floor(z + zo);
if (minecraft->level->isSolidBlockingTile(xt, yt, zt)) {
tile = minecraft->level->getTile(xt, yt, zt);
}
@@ -104,6 +104,7 @@
#include "Minecraft.Client/net/minecraft/client/resources/ResourceLocation.h"
#include "Minecraft.Client/Header Files/stubs.h"
#include "4J_Input.h"
#include "Minecraft.World/net/minecraft/util/Mth.h"
class Icon;
class ItemInstance;
@@ -540,8 +541,8 @@ void LevelRenderer::allChanged(int playerIndex) {
if (level[playerIndex] != nullptr) {
std::shared_ptr<Entity> player = mc->cameraTargetPlayer;
if (player != nullptr) {
this->resortChunks(Mth::floor(player->x), Mth::floor(player->y),
Mth::floor(player->z));
this->resortChunks(std::floor(player->x), std::floor(player->y),
std::floor(player->z));
// sort(sortedChunks[playerIndex]->begin(),sortedChunks[playerIndex]->end(),
// DistanceChunkSorter(player)); // 4J - removed - not sorting
// our chunks anymore
@@ -638,8 +639,8 @@ void LevelRenderer::renderEntities(Vec3* cam, Culler* culler, float a) {
!mc->cameraTargetPlayer->isSleeping())
continue;
if (!level[playerIndex]->hasChunkAt(Mth::floor(entity->x), 0,
Mth::floor(entity->z))) {
if (!level[playerIndex]->hasChunkAt(std::floor(entity->x), 0,
std::floor(entity->z))) {
continue;
}
renderedEntities++;
@@ -772,8 +773,8 @@ int LevelRenderer::render(std::shared_ptr<LivingEntity> player, int layer,
yOld[playerIndex] = player->y;
zOld[playerIndex] = player->z;
resortChunks(Mth::floor(player->x), Mth::floor(player->y),
Mth::floor(player->z));
resortChunks(std::floor(player->x), std::floor(player->y),
std::floor(player->z));
// sort(sortedChunks[playerIndex]->begin(),sortedChunks[playerIndex]->end(),
// DistanceChunkSorter(player)); // 4J - removed - not sorting
// our chunks anymore
@@ -1215,8 +1216,8 @@ void LevelRenderer::renderClouds(float alpha) {
double zo =
mc->cameraTargetPlayer->zo +
(mc->cameraTargetPlayer->z - mc->cameraTargetPlayer->zo) * alpha;
int xOffs = Mth::floor(xo / 2048);
int zOffs = Mth::floor(zo / 2048);
int xOffs = std::floor(xo / 2048);
int zOffs = std::floor(zo / 2048);
xo -= xOffs * 2048;
zo -= zOffs * 2048;
@@ -1458,8 +1459,8 @@ void LevelRenderer::renderAdvancedClouds(float alpha) {
0.33f;
float yy = (float)(level[playerIndex]->dimension->getCloudHeight() - yOffs +
0.33f);
int xOffs = Mth::floor(xo / 2048);
int zOffs = Mth::floor(zo / 2048);
int xOffs = std::floor(xo / 2048);
int zOffs = std::floor(zo / 2048);
xo -= xOffs * 2048;
zo -= zOffs * 2048;
@@ -1505,16 +1506,16 @@ void LevelRenderer::renderAdvancedClouds(float alpha) {
float scale = 1 / 256.0f;
uo = (float)(Mth::floor(xo)) * scale;
vo = (float)(Mth::floor(zo)) * scale;
uo = (float)(std::floor(xo)) * scale;
vo = (float)(std::floor(zo)) * scale;
// 4J - keep our UVs +ve - there's a small bug in the xbox GPU that
// incorrectly rounds small -ve UVs (between -1/(64*size) and 0) up to 0,
// which leaves gaps in our clouds...
while (uo < 1.0f) uo += 1.0f;
while (vo < 1.0f) vo += 1.0f;
float xoffs = (float)(xo - Mth::floor(xo));
float zoffs = (float)(zo - Mth::floor(zo));
float xoffs = (float)(xo - std::floor(xo));
float zoffs = (float)(zo - std::floor(zo));
int D = 8;
@@ -224,12 +224,12 @@ void EntityRenderDispatcher::prepare(
this->crosshairPickMob = crosshairPickMob;
if (player->isSleeping()) {
int t = level->getTile(Mth::floor(player->x), Mth::floor(player->y),
Mth::floor(player->z));
int t = level->getTile(std::floor(player->x), std::floor(player->y),
std::floor(player->z));
if (t == Tile::bed_Id) {
int data =
level->getData(Mth::floor(player->x), Mth::floor(player->y),
Mth::floor(player->z));
level->getData(std::floor(player->x), std::floor(player->y),
std::floor(player->z));
int direction = data & 3;
playerRotY = (float)(direction * 90 + 180);
@@ -178,12 +178,12 @@ void EntityRenderer::renderShadow(std::shared_ptr<Entity> e, double x, double y,
}
double ez = e->zOld + (e->z - e->zOld) * a;
int x0 = Mth::floor(ex - r);
int x1 = Mth::floor(ex + r);
int y0 = Mth::floor(ey - r);
int y1 = Mth::floor(ey);
int z0 = Mth::floor(ez - r);
int z1 = Mth::floor(ez + r);
int x0 = std::floor(ex - r);
int x1 = std::floor(ex + r);
int y0 = std::floor(ey - r);
int y1 = std::floor(ey);
int z0 = std::floor(ez - r);
int z1 = std::floor(ez + r);
double xo = x - ex;
double yo = y - ey;
@@ -47,28 +47,28 @@ void FallingTileRenderer::render(std::shared_ptr<Entity> _tile, double x,
tileRenderer->level = level;
Tesselator* t = Tesselator::getInstance();
t->begin();
t->offset(-Mth::floor(tile->x) - 0.5f, -Mth::floor(tile->y) - 0.5f,
-Mth::floor(tile->z) - 0.5f);
t->offset(-std::floor(tile->x) - 0.5f, -std::floor(tile->y) - 0.5f,
-std::floor(tile->z) - 0.5f);
tileRenderer->tesselateAnvilInWorld(
(AnvilTile*)tt, Mth::floor(tile->x), Mth::floor(tile->y),
Mth::floor(tile->z), tile->data);
(AnvilTile*)tt, std::floor(tile->x), std::floor(tile->y),
std::floor(tile->z), tile->data);
t->offset(0, 0, 0);
t->end();
} else if (tt == Tile::dragonEgg) {
tileRenderer->level = level;
Tesselator* t = Tesselator::getInstance();
t->begin();
t->offset(-Mth::floor(tile->x) - 0.5f, -Mth::floor(tile->y) - 0.5f,
-Mth::floor(tile->z) - 0.5f);
tileRenderer->tesselateInWorld(tt, Mth::floor(tile->x),
Mth::floor(tile->y),
Mth::floor(tile->z));
t->offset(-std::floor(tile->x) - 0.5f, -std::floor(tile->y) - 0.5f,
-std::floor(tile->z) - 0.5f);
tileRenderer->tesselateInWorld(tt, std::floor(tile->x),
std::floor(tile->y),
std::floor(tile->z));
t->offset(0, 0, 0);
t->end();
} else if (tt != nullptr) {
tileRenderer->setShape(tt);
tileRenderer->renderBlock(tt, level, Mth::floor(tile->x),
Mth::floor(tile->y), Mth::floor(tile->z),
tileRenderer->renderBlock(tt, level, std::floor(tile->x),
std::floor(tile->y), std::floor(tile->z),
tile->data);
}
glEnable(GL_LIGHTING);
@@ -26,6 +26,7 @@
#include "Minecraft.Client/net/minecraft/client/renderer/Tesselator.h"
#include "Minecraft.Client/net/minecraft/client/renderer/Textures.h"
#include "Minecraft.Client/net/minecraft/client/resources/ResourceLocation.h"
#include "Minecraft.World/net/minecraft/util/Mth.h"
class MapItemSavedData;
@@ -29,6 +29,7 @@
#include "Minecraft.Client/net/minecraft/client/renderer/Tesselator.h"
#include "Minecraft.Client/net/minecraft/client/renderer/Textures.h"
#include "Minecraft.Client/net/minecraft/client/renderer/entity/EntityRenderer.h"
#include "Minecraft.World/net/minecraft/util/Mth.h"
class ResourceLocation;
@@ -25,6 +25,7 @@
#include "Minecraft.Client/net/minecraft/client/renderer/Tesselator.h"
#include "Minecraft.Client/net/minecraft/client/renderer/Textures.h"
#include "Minecraft.Client/net/minecraft/client/resources/ResourceLocation.h"
#include "Minecraft.World/net/minecraft/util/Mth.h"
ResourceLocation LivingEntityRenderer::ENCHANT_GLINT_LOCATION =
ResourceLocation(TN__BLUR__MISC_GLINT);
@@ -15,6 +15,7 @@
#include "java/Class.h"
#include "Minecraft.Client/net/minecraft/client/Minecraft.h"
#include "Minecraft.Client/net/minecraft/client/renderer/Tesselator.h"
#include "Minecraft.World/net/minecraft/util/Mth.h"
class Model;
@@ -124,13 +124,13 @@ void PaintingRenderer::renderPainting(std::shared_ptr<Painting> painting, int w,
void PaintingRenderer::setBrightness(std::shared_ptr<Painting> painting,
float ss, float ya) {
int x = Mth::floor(painting->x);
int y = Mth::floor(painting->y + ya / 16.0f);
int z = Mth::floor(painting->z);
if (painting->dir == 0) x = Mth::floor(painting->x + ss / 16.0f);
if (painting->dir == 1) z = Mth::floor(painting->z - ss / 16.0f);
if (painting->dir == 2) x = Mth::floor(painting->x - ss / 16.0f);
if (painting->dir == 3) z = Mth::floor(painting->z + ss / 16.0f);
int x = std::floor(painting->x);
int y = std::floor(painting->y + ya / 16.0f);
int z = std::floor(painting->z);
if (painting->dir == 0) x = std::floor(painting->x + ss / 16.0f);
if (painting->dir == 1) z = std::floor(painting->z - ss / 16.0f);
if (painting->dir == 2) x = std::floor(painting->x - ss / 16.0f);
if (painting->dir == 3) z = std::floor(painting->z + ss / 16.0f);
int col = this->entityRenderDispatcher->level->getLightColor(x, y, z, 0);
int u = col % 65536;
@@ -11,6 +11,7 @@
#include "Minecraft.World/net/minecraft/world/level/tile/entity/TileEntity.h"
#include "Minecraft.Client/net/minecraft/client/renderer/Textures.h"
#include "Minecraft.Client/net/minecraft/client/resources/ResourceLocation.h"
#include "Minecraft.World/net/minecraft/util/Mth.h"
ResourceLocation EnchantTableRenderer::BOOK_LOCATION =
ResourceLocation(TN_ITEM_BOOK);
@@ -11,7 +11,7 @@
#include "Minecraft.World/net/minecraft/world/level/tile/net.minecraft.world.level.tile.h"
#include "Minecraft.World/net/minecraft/world/entity/Entity.h"
#include "Minecraft.World/net/minecraft/world/level/Level.h"
#include "Minecraft.Client/Common/Source Files/Colours/ColourTable.h"
ResourceLocation SignRenderer::SIGN_LOCATION = ResourceLocation(TN_ITEM_SIGN);
@@ -396,7 +396,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 - Mth::abs(sinf(System::currentTimeMillis() % 1000 /
float sss = 1.8f - std::abs(sinf(System::currentTimeMillis() % 1000 /
1000.0f * std::numbers::pi * 2) *
0.1f);
@@ -44,12 +44,14 @@
#include "Minecraft.World/net/minecraft/world/level/chunk/SparseLightStorage.h"
#include "Minecraft.World/net/minecraft/world/level/chunk/SparseDataStorage.h"
#include "Minecraft.World/Header Files/compression.h"
#include "Minecraft.World/net/minecraft/world/level/biome/BiomeSource.h"
#include "Minecraft.Client/Common/ShutdownManager.h"
#include "Minecraft.Client/Common/Source Files/UI/All Platforms/UIStructs.h"
#include "Minecraft.Client/net/minecraft/server/commands/ServerCommandDispatcher.h"
#include "Minecraft.World/net/minecraft/world/level/biome/BiomeSource.h"
#include "Minecraft.Client/net/minecraft/server/level/PlayerChunkMap.h"
#include "Minecraft.Client/Common/Source Files/GameRules/LevelGeneration/ConsoleSchematicFile.h"
#include "4J_Input.h"
#include "Minecraft.World/net/minecraft/world/level/Level.h"
#define DEBUG_SERVER_DONT_SPAWN_MOBS 0
@@ -208,7 +210,7 @@ bool MinecraftServer::initServer(int64_t seed, NetworkGameInitData* initData,
settings->getInt(L"max-build-height", Level::maxBuildHeight));
setMaxBuildHeight(((getMaxBuildHeight() + 8) / 16) * 16);
setMaxBuildHeight(
Mth::clamp(getMaxBuildHeight(), 64, Level::maxBuildHeight));
std::clamp(getMaxBuildHeight(), 64, Level::maxBuildHeight));
// settings->setProperty(L"max-build-height", maxBuildHeight);
// logger.info("Preparing level \"" + levelName + "\"");
@@ -1012,8 +1014,8 @@ bool MinecraftServer::isUnderSpawnProtection(Level* level, int x, int y, int z,
if (getSpawnProtectionRadius() <= 0) return false;
Pos* spawnPos = level->getSharedSpawnPos();
int xd = Mth::abs(x - spawnPos->x);
int zd = Mth::abs(z - spawnPos->z);
int xd = std::abs(x - spawnPos->x);
int zd = std::abs(z - spawnPos->z);
int dist = std::max(xd, zd);
return dist <= getSpawnProtectionRadius();
@@ -27,6 +27,7 @@
#include "java/JavaMath.h"
#include "Minecraft.World/net/minecraft/world/entity/EntityIO.h"
#include "Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerGameMode.h"
#include "Minecraft.Client/Common/Source Files/GameRules/LevelRules/RuleDefinitions/LevelRuleset.h"
#include "Minecraft.Client/Common/Source Files/Tutorial/Tutorial.h"
// 4J - this class is fairly substantially altered as there didn't seem any
@@ -374,17 +375,17 @@ void PlayerList::validatePlayerSpawnPosition(
double targetX = 0;
if (player->x < 0)
targetX = Mth::ceil(player->x) - 0.5;
targetX = std::ceil(player->x) - 0.5;
else
targetX = Mth::floor(player->x) + 0.5;
targetX = std::floor(player->x) + 0.5;
double targetY = floor(player->y);
double targetZ = 0;
if (player->z < 0)
targetZ = Mth::ceil(player->z) - 0.5;
targetZ = std::ceil(player->z) - 0.5;
else
targetZ = Mth::floor(player->z) + 0.5;
targetZ = std::floor(player->z) + 0.5;
player->setPos(targetX, targetY, targetZ);
@@ -957,9 +958,9 @@ void PlayerList::repositionAcrossDimension(std::shared_ptr<Entity> entity,
}
if (lastDimension != 1) {
xt = (double)Mth::clamp((int)xt, -Level::MAX_LEVEL_SIZE + 128,
xt = (double)std::clamp((int)xt, -Level::MAX_LEVEL_SIZE + 128,
Level::MAX_LEVEL_SIZE - 128);
zt = (double)Mth::clamp((int)zt, -Level::MAX_LEVEL_SIZE + 128,
zt = (double)std::clamp((int)zt, -Level::MAX_LEVEL_SIZE + 128,
Level::MAX_LEVEL_SIZE - 128);
if (entity->isAlive()) {
newLevel->addEntity(entity);
@@ -15,6 +15,7 @@ class TileEntity;
class ProgressListener;
class GameType;
class LoginPacket;
class Connection;
class ServerScoreboard;
class PlayerList {
@@ -43,6 +43,7 @@
#include "Minecraft.Client/net/minecraft/client/Minecraft.h"
#include "PlayerChunkMap.h"
#include "Minecraft.Client/Common/Source Files/DLC/DLCPack.h"
#include "Minecraft.Client/Common/Source Files/Console_Debug_enum.h"
#include "4J_Input.h"
std::vector<WeighedTreasure*> ServerLevel::RANDOM_BONUS_ITEMS;
@@ -1,14 +1,17 @@
#pragma once
#include <list>
#include <set>
#include <mutex>
#include "Minecraft.World/net/minecraft/world/level/net.minecraft.world.level.h"
#include "java/JavaIntHash.h"
class ServerChunkCache;
class MinecraftServer;
class Node;
class EntityTracker;
class PlayerChunkMap;
class WeighedTreasure;
class ServerLevel : public Level {
private:
@@ -8,6 +8,7 @@
#include "Minecraft.Client/net/minecraft/server/Settings.h"
#include "Minecraft.Client/net/minecraft/server/PlayerList.h"
#include "Minecraft.Client/net/minecraft/client/multiplayer/MultiPlayerLevel.h"
#include "Minecraft.Client/Common/Source Files/Console_Debug_enum.h"
#include "Minecraft.World/net/minecraft/network/packet/net.minecraft.network.packet.h"
#include "Minecraft.World/net/minecraft/world/damageSource/net.minecraft.world.damagesource.h"
@@ -1663,7 +1664,7 @@ int ServerPlayer::getViewDistance() { return viewDistance; }
// }
Pos* ServerPlayer::getCommandSenderWorldPosition() {
return new Pos(Mth::floor(x), Mth::floor(y + .5), Mth::floor(z));
return new Pos(std::floor(x), std::floor(y + .5), std::floor(z));
}
void ServerPlayer::resetLastActionTime() {
@@ -78,13 +78,13 @@ TrackedEntity::TrackedEntity(std::shared_ptr<Entity> e, int range,
this->updateInterval = updateInterval;
this->trackDelta = trackDelta;
xp = Mth::floor(e->x * 32);
yp = Mth::floor(e->y * 32);
zp = Mth::floor(e->z * 32);
xp = std::floor(e->x * 32);
yp = std::floor(e->y * 32);
zp = std::floor(e->z * 32);
yRotp = Mth::floor(e->yRot * 256 / 360);
xRotp = Mth::floor(e->xRot * 256 / 360);
yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360);
yRotp = std::floor(e->yRot * 256 / 360);
xRotp = std::floor(e->xRot * 256 / 360);
yHeadRotp = std::floor(e->getYHeadRot() * 256 / 360);
}
int c0a = 0, c0b = 0, c1a = 0, c1b = 0, c1c = 0, c2a = 0, c2b = 0;
@@ -141,8 +141,8 @@ void TrackedEntity::tick(EntityTracker* tracker,
} else if (tickCount % updateInterval == 0 || e->hasImpulse ||
e->getEntityData()->isDirty()) {
// 4J: Moved this as it's shared
int yRotn = Mth::floor(e->yRot * 256 / 360);
int xRotn = Mth::floor(e->xRot * 256 / 360);
int yRotn = std::floor(e->yRot * 256 / 360);
int xRotn = std::floor(e->xRot * 256 / 360);
// 4J: Changed rotation to be generally sent as a delta as well as
// position
@@ -152,9 +152,9 @@ void TrackedEntity::tick(EntityTracker* tracker,
if (e->riding == nullptr) {
teleportDelay++;
int xn = Mth::floor(e->x * 32.0);
int yn = Mth::floor(e->y * 32.0);
int zn = Mth::floor(e->z * 32.0);
int xn = std::floor(e->x * 32.0);
int yn = std::floor(e->y * 32.0);
int zn = std::floor(e->z * 32.0);
int xa = xn - xp;
int ya = yn - yp;
@@ -349,16 +349,16 @@ void TrackedEntity::tick(EntityTracker* tracker,
xRotp = xRotn;
}
xp = Mth::floor(e->x * 32.0);
yp = Mth::floor(e->y * 32.0);
zp = Mth::floor(e->z * 32.0);
xp = std::floor(e->x * 32.0);
yp = std::floor(e->y * 32.0);
zp = std::floor(e->z * 32.0);
sendDirtyEntityData();
wasRiding = true;
}
int yHeadRot = Mth::floor(e->getYHeadRot() * 256 / 360);
int yHeadRot = std::floor(e->getYHeadRot() * 256 / 360);
if (abs(yHeadRot - yHeadRotp) >= TOLERANCE_LEVEL) {
broadcast(std::shared_ptr<RotateHeadPacket>(
new RotateHeadPacket(e->entityId, (uint8_t)yHeadRot)));
@@ -664,8 +664,8 @@ void TrackedEntity::updatePlayer(EntityTracker* tracker,
std::shared_ptr<EntityActionAtPositionPacket>(
new EntityActionAtPositionPacket(
e, EntityActionAtPositionPacket::START_SLEEP,
Mth::floor(e->x), Mth::floor(e->y),
Mth::floor(e->z))));
std::floor(e->x), std::floor(e->y),
std::floor(e->z))));
}
}
@@ -720,7 +720,7 @@ std::shared_ptr<Packet> TrackedEntity::getAddEntityPacket() {
// 4J-PB - replacing with a switch, rather than tons of ifs
if (std::dynamic_pointer_cast<Creature>(e) != nullptr) {
yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360);
yHeadRotp = std::floor(e->getYHeadRot() * 256 / 360);
return std::shared_ptr<AddMobPacket>(
new AddMobPacket(std::dynamic_pointer_cast<Mob>(e), yRotp, xRotp,
xp, yp, zp, yHeadRotp));
@@ -756,7 +756,7 @@ std::shared_ptr<Packet> TrackedEntity::getAddEntityPacket() {
return std::make_shared<AddEntityPacket>(
e, AddEntityPacket::BOAT, yRotp, xRotp, xp, yp, zp);
} else if (e->instanceof(eTYPE_ENDERDRAGON)) {
yHeadRotp = Mth::floor(e->getYHeadRot() * 256 / 360);
yHeadRotp = std::floor(e->getYHeadRot() * 256 / 360);
return std::shared_ptr<AddMobPacket>(
new AddMobPacket(std::dynamic_pointer_cast<LivingEntity>(e), yRotp,
xRotp, xp, yp, zp, yHeadRotp));
@@ -851,9 +851,9 @@ std::shared_ptr<Packet> TrackedEntity::getAddEntityPacket() {
std::shared_ptr<AddEntityPacket>(
new AddEntityPacket(e, AddEntityPacket::ITEM_FRAME, frame->dir,
yRotp, xRotp, xp, yp, zp));
packet->x = Mth::floor(frame->xTile * 32.0f);
packet->y = Mth::floor(frame->yTile * 32.0f);
packet->z = Mth::floor(frame->zTile * 32.0f);
packet->x = std::floor(frame->xTile * 32.0f);
packet->y = std::floor(frame->yTile * 32.0f);
packet->z = std::floor(frame->zTile * 32.0f);
return packet;
} else if (e->instanceof(eTYPE_LEASHFENCEKNOT)) {
std::shared_ptr<LeashFenceKnotEntity> knot =
@@ -861,9 +861,9 @@ std::shared_ptr<Packet> TrackedEntity::getAddEntityPacket() {
std::shared_ptr<AddEntityPacket> packet =
std::make_shared<AddEntityPacket>(
e, AddEntityPacket::LEASH_KNOT, yRotp, xRotp, xp, yp, zp);
packet->x = Mth::floor((float)knot->xTile * 32);
packet->y = Mth::floor((float)knot->yTile * 32);
packet->z = Mth::floor((float)knot->zTile * 32);
packet->x = std::floor((float)knot->xTile * 32);
packet->y = std::floor((float)knot->yTile * 32);
packet->z = std::floor((float)knot->zTile * 32);
return packet;
} else if (e->instanceof(eTYPE_EXPERIENCEORB)) {
return std::shared_ptr<AddExperienceOrbPacket>(
@@ -19,6 +19,7 @@
#include "Minecraft.World/net/minecraft/network/packet/LoginPacket.h"
#include "Minecraft.World/net/minecraft/network/packet/PreLoginPacket.h"
#include "Minecraft.World/x64headers/extraX64.h"
#include "Minecraft.Client/Common/Source Files/BuildVer/BuildVer.h"
#include "java/Random.h"
class Packet;
@@ -292,7 +292,7 @@ void PlayerConnection::handleMovePlayer(
// stance: " + yd);
return;
}
if (abs(packet->x) > 32000000 || abs(packet->z) > 32000000) {
if (std::abs(packet->x) > 32000000 || std::abs(packet->z) > 32000000) {
disconnect(DisconnectPacket::eDisconnect_IllegalPosition);
return;
}