Merge pull request #311 from Merc6/refactor/remove-BasicTypeContainers
Some checks failed
Publish Documentation / build (push) Has been cancelled
Build (Linux, x86_64) / build-linux (push) Has been cancelled
Build (Linux, x86_64) / build-linux-debug (push) Has been cancelled
Clang Format / clang-format (push) Has been cancelled

refactor: remove basic type containers
This commit is contained in:
Tropical 2026-03-25 19:36:36 -05:00 committed by GitHub
commit c18e86944f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 687 additions and 799 deletions

View file

@ -1,5 +1,7 @@
#include "../Platform/stdafx.h"
#include "ClientConnection.h"
#include <cfloat>
#include <limits>
#include "../Level/MultiPlayerLevel.h"
#include "../Player/MultiPlayerLocalPlayer.h"
#include "../GameState/StatsCounter.h"
@ -43,7 +45,6 @@
#include "../MinecraftServer.h"
#include "../ClientConstants.h"
#include "../../Minecraft.World/Util/SoundTypes.h"
#include "../../Minecraft.World/Util/BasicTypeContainers.h"
#include "../Textures/Packs/TexturePackRepository.h"
#ifdef _XBOX
#include "../Platform/Common/XUI/XUI_Scene_Trading.h"
@ -2171,12 +2172,11 @@ void ClientConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet) {
// Check this friend against each player, if we find them we
// have at least one friend
for (int j = 0; j < g_NetworkManager.GetPlayerCount(); j++) {
Platform::String ^ xboxUserId =
ref new Platform::String(
g_NetworkManager.GetPlayerByIndex(j)
->GetUID()
.toString()
.data());
Platform::String ^ xboxUserId = ref new Platform::String(
g_NetworkManager.GetPlayerByIndex(j)
->GetUID()
.toString()
.data());
if (friendsXuid == xboxUserId) {
isAtLeastOneFriend = true;
break;
@ -2279,8 +2279,8 @@ void ClientConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet) {
// down, because they are trying to lock the incoming critsec when
// it's already locked by this thread
// Minecraft::GetInstance()->connectionDisconnected(
// m_userIndex , reason ); done = true; connection->flush();
// connection->close(reason);
// m_userIndex , reason ); done = true;
// connection->flush(); connection->close(reason);
// app.SetAction(m_userIndex,eAppAction_ExitPlayer);
// 4J-PB - doing this instead
@ -4050,7 +4050,8 @@ void ClientConnection::handleUpdateAttributes(
// are we passing in MIN_NORMAL (Java's smallest non-zero value
// conforming to IEEE Standard 754 (?)) and MAX_VALUE
instance = attributes->registerAttribute(new RangedAttribute(
attribute->getId(), 0, Double::MIN_NORMAL, Double::MAX_VALUE));
attribute->getId(), 0, std::numeric_limits<double>::min(),
std::numeric_limits<double>::max()));
}
instance->setBaseValue(attribute->getBase());
@ -4105,4 +4106,4 @@ ClientConnection::DeferredEntityLinkPacket::DeferredEntityLinkPacket(
std::shared_ptr<SetEntityLinkPacket> packet) {
m_recievedTick = GetTickCount();
m_packet = packet;
}
}

View file

@ -17,7 +17,6 @@
#include "../../Minecraft.World/Headers/net.minecraft.network.packet.h"
#include "../../Minecraft.World/Headers/net.minecraft.network.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.level.dimension.h"
#include "../../Minecraft.World/Util/BasicTypeContainers.h"
#include "../../Minecraft.World/Headers/net.minecraft.world.level.chunk.h"
#include "../Network/PlayerConnection.h"
@ -250,4 +249,4 @@ std::shared_ptr<TrackedEntity> EntityTracker::getTracker(
return it->second;
}
return nullptr;
}
}

View file

@ -1,5 +1,6 @@
#include "../Platform/stdafx.h"
#include "LevelRenderer.h"
#include <cmath>
#include "../Textures/Textures.h"
#include "../Textures/TextureAtlas.h"
#include "Tesselator.h"
@ -59,7 +60,6 @@
#include "../Level/MultiPlayerLevel.h"
#include "../../Minecraft.World/Util/SoundTypes.h"
#include "FrustumCuller.h"
#include "../../Minecraft.World/Util/BasicTypeContainers.h"
// #define DISABLE_SPU_CODE
@ -2920,9 +2920,9 @@ std::shared_ptr<Particle> LevelRenderer::addParticleInternal(
// optimised PS3 code which reverses the logic on the comparison with
// particleDistanceSquared and gets the opposite result to what you might
// expect.
if (Double::isNaN(x)) return nullptr;
if (Double::isNaN(y)) return nullptr;
if (Double::isNaN(z)) return nullptr;
if (std::isnan(x)) return nullptr;
if (std::isnan(y)) return nullptr;
if (std::isnan(z)) return nullptr;
int particleLevel = mc->options->particles;

View file

@ -1,6 +1,5 @@
#include "../Platform/stdafx.h"
#include "Tesselator.h"
#include "../../Minecraft.World/Util/BasicTypeContainers.h"
#include "../../Minecraft.World/IO/Streams/FloatBuffer.h"
#include "../../Minecraft.World/IO/Streams/IntBuffer.h"
#include "../../Minecraft.World/IO/Streams/ByteBuffer.h"

View file

@ -4,8 +4,8 @@
#include "../../Headers/net.minecraft.world.entity.animal.h"
#include "../../Headers/net.minecraft.world.level.h"
#include "../../Headers/net.minecraft.world.phys.h"
#include "../../Util/BasicTypeContainers.h"
#include "BreedGoal.h"
#include <limits>
#include "../../Entities/Mobs/ExperienceOrb.h"
#include "../../Stats/GenericStats.h"
@ -50,7 +50,7 @@ std::shared_ptr<Animal> BreedGoal::getFreePartner() {
float r = 8;
std::vector<std::shared_ptr<Entity> >* others =
level->getEntitiesOfClass(typeid(*animal), animal->bb->grow(r, r, r));
double dist = Double::MAX_VALUE;
double dist = std::numeric_limits<double>::max();
std::shared_ptr<Animal> partner = nullptr;
for (AUTO_VAR(it, others->begin()); it != others->end(); ++it) {
std::shared_ptr<Animal> p = std::dynamic_pointer_cast<Animal>(*it);

View file

@ -3,8 +3,8 @@
#include "../../Headers/net.minecraft.world.entity.ai.navigation.h"
#include "../../Headers/net.minecraft.world.level.h"
#include "../../Headers/net.minecraft.world.phys.h"
#include "../../Util/BasicTypeContainers.h"
#include "FollowParentGoal.h"
#include <limits>
FollowParentGoal::FollowParentGoal(Animal* animal, double speedModifier) {
timeToRecalcPath = 0;
@ -21,7 +21,7 @@ bool FollowParentGoal::canUse() {
animal->bb->grow(8, 4, 8));
std::shared_ptr<Animal> closest = nullptr;
double closestDistSqr = Double::MAX_VALUE;
double closestDistSqr = std::numeric_limits<double>::max();
for (AUTO_VAR(it, parents->begin()); it != parents->end(); ++it) {
std::shared_ptr<Animal> parent = std::dynamic_pointer_cast<Animal>(*it);
if (parent->getAge() < 0) continue;
@ -53,4 +53,4 @@ void FollowParentGoal::tick() {
if (--timeToRecalcPath > 0) return;
timeToRecalcPath = 10;
animal->getNavigation()->moveTo(parent.lock(), speedModifier);
}
}

View file

@ -5,8 +5,8 @@
#include "../../Headers/net.minecraft.world.entity.ai.village.h"
#include "../../Headers/net.minecraft.world.entity.h"
#include "../../Headers/net.minecraft.world.level.h"
#include "../../Util/BasicTypeContainers.h"
#include "MoveThroughVillageGoal.h"
#include <limits>
#include "../Navigation/Path.h"
MoveThroughVillageGoal::MoveThroughVillageGoal(PathfinderMob* mob,
@ -86,7 +86,7 @@ void MoveThroughVillageGoal::stop() {
std::shared_ptr<DoorInfo> MoveThroughVillageGoal::getNextDoorInfo(
std::shared_ptr<Village> village) {
std::shared_ptr<DoorInfo> closest = nullptr;
int closestDistSqr = Integer::MAX_VALUE;
int closestDistSqr = std::numeric_limits<int>::max();
std::vector<std::shared_ptr<DoorInfo> >* doorInfos =
village->getDoorInfos();
// for (DoorInfo di : doorInfos)
@ -120,4 +120,4 @@ bool MoveThroughVillageGoal::hasVisited(std::shared_ptr<DoorInfo> di) {
void MoveThroughVillageGoal::updateVisited() {
if (visited.size() > 15) visited.erase(visited.begin());
}
}

View file

@ -6,9 +6,9 @@
#include "../../Headers/net.minecraft.world.level.h"
#include "../../Headers/net.minecraft.world.level.tile.h"
#include "../../Headers/net.minecraft.world.level.tile.entity.h"
#include "../../Util/BasicTypeContainers.h"
#include "../../Util/Arrays.h"
#include "OcelotSitOnTileGoal.h"
#include <limits>
const int OcelotSitOnTileGoal::GIVE_UP_TICKS =
3 * SharedConstants::TICKS_PER_SECOND;
@ -77,7 +77,7 @@ void OcelotSitOnTileGoal::tick() {
bool OcelotSitOnTileGoal::findNearestTile() {
int y = (int)ocelot->y;
double distSqr = Integer::MAX_VALUE;
double distSqr = std::numeric_limits<int>::max();
for (int x = (int)ocelot->x - SEARCH_RANGE; x < ocelot->x + SEARCH_RANGE;
x++) {
@ -97,7 +97,7 @@ bool OcelotSitOnTileGoal::findNearestTile() {
}
}
return distSqr < Integer::MAX_VALUE;
return distSqr < std::numeric_limits<int>::max();
}
bool OcelotSitOnTileGoal::isValidTarget(Level* level, int x, int y, int z) {
@ -119,4 +119,4 @@ bool OcelotSitOnTileGoal::isValidTarget(Level* level, int x, int y, int z) {
}
return false;
}
}

View file

@ -6,8 +6,8 @@
#include "../../Headers/net.minecraft.world.entity.h"
#include "../../Headers/net.minecraft.world.level.h"
#include "../../Headers/net.minecraft.world.phys.h"
#include "../../Util/BasicTypeContainers.h"
#include "PlayGoal.h"
#include <limits>
PlayGoal::PlayGoal(Villager* mob, double speedModifier) {
followFriend = std::weak_ptr<LivingEntity>();
@ -26,7 +26,7 @@ bool PlayGoal::canUse() {
std::vector<std::shared_ptr<Entity> >* children =
mob->level->getEntitiesOfClass(typeid(Villager),
mob->bb->grow(6, 3, 6));
double closestDistSqr = Double::MAX_VALUE;
double closestDistSqr = std::numeric_limits<double>::max();
// for (Entity c : children)
for (AUTO_VAR(it, children->begin()); it != children->end(); ++it) {
std::shared_ptr<Entity> c = *it;
@ -80,4 +80,4 @@ void PlayGoal::tick() {
mob->getNavigation()->moveTo(pos->x, pos->y, pos->z, speedModifier);
}
}
}
}

View file

@ -2,8 +2,8 @@
#include "../Headers/net.minecraft.commands.h"
#include "../Headers/net.minecraft.world.entity.player.h"
#include "../Headers/net.minecraft.world.damagesource.h"
#include "../Util/BasicTypeContainers.h"
#include "KillCommand.h"
#include <limits>
EGameCommand KillCommand::getId() { return eGameCommand_Kill; }
@ -13,8 +13,8 @@ void KillCommand::execute(std::shared_ptr<CommandSender> source,
byteArray commandData) {
std::shared_ptr<Player> player = std::dynamic_pointer_cast<Player>(source);
player->hurt(DamageSource::outOfWorld, Float::MAX_VALUE);
player->hurt(DamageSource::outOfWorld, std::numeric_limits<float>::max());
source->sendMessage(L"Ouch. That look like it hurt.");
// source.sendMessage(ChatMessageComponent.forTranslation("commands.kill.success"));
}
}

View file

@ -28,7 +28,6 @@
#include "../../Minecraft.Client/Level/ServerLevel.h"
#include "../../Minecraft.Client/Player/EntityTracker.h"
#include "../Util/SoundTypes.h"
#include "../Util/BasicTypeContainers.h"
#include "../Util/ParticleTypes.h"
#include "../Stats/GenericStats.h"
#include "ItemEntity.h"
@ -1732,4 +1731,4 @@ bool LivingEntity::isAlliedTo(Team* other) {
return getTeam()->isAlliedTo(other);
}
return false;
}
}

View file

@ -25,7 +25,6 @@
#include "Mob.h"
#include "../../Minecraft.Client/Textures/Textures.h"
#include "../Util/SoundTypes.h"
#include "../Util/BasicTypeContainers.h"
#include "../Util/ParticleTypes.h"
#include "../Stats/GenericStats.h"
#include "ItemEntity.h"
@ -901,4 +900,4 @@ void Mob::setLevel(Level* level) {
navigation->setLevel(level);
goalSelector.setLevel(level);
targetSelector.setLevel(level);
}
}

View file

@ -8,12 +8,12 @@
#include "../../Headers/net.minecraft.world.entity.projectile.h"
#include "../../Headers/net.minecraft.world.phys.h"
#include "../../Headers/net.minecraft.world.damagesource.h"
#include "../../Util/BasicTypeContainers.h"
#include "../../../Minecraft.Client/Textures/Textures.h"
#include "../../Headers/net.minecraft.world.entity.boss.enderdragon.h"
#include "../../Headers/net.minecraft.world.level.pathfinder.h"
#include "../../Util/SharedConstants.h"
#include "EnderDragon.h"
#include <limits>
#define PRINT_DRAGON_STATE_CHANGE_MESSAGES 1
@ -815,7 +815,7 @@ void EnderDragon::checkCrystals() {
bb->grow(maxDist, maxDist, maxDist));
std::shared_ptr<EnderCrystal> crystal = nullptr;
double nearest = Double::MAX_VALUE;
double nearest = std::numeric_limits<double>::max();
// for (Entity ec : crystals)
for (AUTO_VAR(it, crystals->begin()); it != crystals->end(); ++it) {
std::shared_ptr<EnderCrystal> ec =

View file

@ -15,8 +15,8 @@
#include "../../Headers/net.minecraft.world.phys.h"
#include "../../../Minecraft.Client/Textures/Textures.h"
#include "../../../Minecraft.Client/Minecraft.h"
#include "../../Util/BasicTypeContainers.h"
#include "EntityHorse.h"
#include <limits>
const std::wstring EntityHorse::TEX_FOLDER = L"mob/horse/";
@ -417,7 +417,7 @@ bool EntityHorse::canSpawn() {
std::shared_ptr<EntityHorse> EntityHorse::getClosestMommy(
std::shared_ptr<Entity> baby, double searchRadius) {
double closestDistance = Double::MAX_VALUE;
double closestDistance = std::numeric_limits<double>::max();
std::shared_ptr<Entity> mommy = nullptr;
std::vector<std::shared_ptr<Entity> >* list = level->getEntities(
@ -1517,4 +1517,4 @@ bool EntityHorse::onLadder() {
std::shared_ptr<Player> EntityHorse::getOwner() {
return level->getPlayerByUUID(getOwnerName());
}
}

View file

@ -1,11 +1,11 @@
#include "../../Platform/stdafx.h"
#include "../../Headers/net.minecraft.world.entity.ai.attributes.h"
#include "../../Util/BasicTypeContainers.h"
#include "SharedMonsterAttributes.h"
#include <limits>
Attribute* SharedMonsterAttributes::MAX_HEALTH =
(new RangedAttribute(eAttributeId_GENERIC_MAXHEALTH, 20, 0,
Double::MAX_VALUE))
std::numeric_limits<double>::max()))
->setSyncable(true);
Attribute* SharedMonsterAttributes::FOLLOW_RANGE =
(new RangedAttribute(eAttributeId_GENERIC_FOLLOWRANGE, 32, 0, 2048));
@ -13,10 +13,11 @@ Attribute* SharedMonsterAttributes::KNOCKBACK_RESISTANCE =
(new RangedAttribute(eAttributeId_GENERIC_KNOCKBACKRESISTANCE, 0, 0, 1));
Attribute* SharedMonsterAttributes::MOVEMENT_SPEED =
(new RangedAttribute(eAttributeId_GENERIC_MOVEMENTSPEED, 0.7f, 0,
Double::MAX_VALUE))
std::numeric_limits<double>::max()))
->setSyncable(true);
Attribute* SharedMonsterAttributes::ATTACK_DAMAGE = new RangedAttribute(
eAttributeId_GENERIC_ATTACKDAMAGE, 2, 0, Double::MAX_VALUE);
Attribute* SharedMonsterAttributes::ATTACK_DAMAGE =
new RangedAttribute(eAttributeId_GENERIC_ATTACKDAMAGE, 2, 0,
std::numeric_limits<double>::max());
ListTag<CompoundTag>* SharedMonsterAttributes::saveAttributes(
BaseAttributeMap* attributes) {
@ -108,4 +109,4 @@ AttributeModifier* SharedMonsterAttributes::loadAttributeModifier(
eMODIFIER_ID id = (eMODIFIER_ID)tag->getInt(L"UUID");
return new AttributeModifier(id, tag->getDouble(L"Amount"),
tag->getInt(L"Operation"));
}
}

View file

@ -9,8 +9,8 @@
#include "../../Headers/net.minecraft.world.entity.h"
#include "../../Headers/net.minecraft.world.entity.monster.h"
#include "../../Headers/com.mojang.nbt.h"
#include "../../Util/BasicTypeContainers.h"
#include "Spider.h"
#include <limits>
#include "../../../Minecraft.Client/Textures/Textures.h"
#include "../../Util/SoundTypes.h"
@ -173,7 +173,8 @@ MobGroupData* Spider::finalizeMobSpawn(
if (dynamic_cast<SpiderEffectsGroupData*>(groupData) != NULL) {
int effect = ((SpiderEffectsGroupData*)groupData)->effectId;
if (effect > 0 && MobEffect::effects[effect] != NULL) {
addEffect(new MobEffectInstance(effect, Integer::MAX_VALUE));
addEffect(
new MobEffectInstance(effect, std::numeric_limits<int>::max()));
}
}
@ -195,4 +196,4 @@ void Spider::SpiderEffectsGroupData::setRandomEffect(Random* random) {
} else if (selection <= 4) {
effectId = MobEffect::invisibility->id;
}
}
}

View file

@ -1,6 +1,5 @@
#include "../Platform/stdafx.h"
#include "../Util/Class.h"
#include "../Util/BasicTypeContainers.h"
#include "../IO/Streams/InputOutputStream.h"
#include "../Headers/net.minecraft.h"
#include "../Headers/net.minecraft.network.packet.h"
@ -542,4 +541,4 @@ int SynchedEntityData::DataItem::getType() { return type; }
bool SynchedEntityData::DataItem::isDirty() { return dirty; }
void SynchedEntityData::DataItem::setDirty(bool dirty) { this->dirty = dirty; }
void SynchedEntityData::DataItem::setDirty(bool dirty) { this->dirty = dirty; }

View file

@ -1,7 +1,8 @@
#include "../../Platform/stdafx.h"
#include "../../Util/BasicTypeContainers.h"
#include "DataInputStream.h"
#include <bit>
#include <cstdint>
// Creates a DataInputStream that uses the specified underlying InputStream.
// Parameters:
@ -146,7 +147,7 @@ unsigned char DataInputStream::readUnsignedByte() {
// Reads two input bytes and returns a char value. Let a be the first byte read
// and b be the second byte. The value returned is: (char)((a << 8) | (b &
//0xff))
// 0xff))
//
// This method is suitable for reading bytes written by the writeChar method of
// interface DataOutput. Returns: the char value read.
@ -229,7 +230,7 @@ bool DataInputStream::readFully(charArray b) {
double DataInputStream::readDouble() {
int64_t bits = readLong();
return Double::longBitsToDouble(bits);
return std::bit_cast<double>(bits);
}
// Reads four input bytes and returns a float value. It does this by first
@ -240,7 +241,7 @@ double DataInputStream::readDouble() {
float DataInputStream::readFloat() {
int bits = readInt();
return Float::intBitsToFloat(bits);
return std::bit_cast<float>(bits);
}
// Reads four input bytes and returns an int value. Let a-d be the first through
@ -308,7 +309,7 @@ int64_t DataInputStream::readLong() {
// Reads two input bytes and returns a short value. Let a be the first byte read
// and b be the second byte. The value returned is: (short)((a << 8) | (b &
//0xff))
// 0xff))
//
// This method is suitable for reading the bytes written by the writeShort
// method of interface DataOutput. Returns: the 16-bit value read.
@ -326,7 +327,8 @@ short DataInputStream::readShort() {
unsigned short DataInputStream::readUnsignedShort() {
if (stream == NULL) {
app.DebugPrintf(
"DataInputStream::readUnsignedShort() but underlying stream is NULL\n");
"DataInputStream::readUnsignedShort() but underlying stream is "
"NULL\n");
return 0;
}
int a = stream->read();
@ -392,8 +394,8 @@ std::wstring DataInputStream::readUTF() {
unsigned short UTFLength = (unsigned short)(((a & 0xff) << 8) | (b & 0xff));
//// 4J Stu - I decided while writing DataOutputStream that we didn't need
///to bother using the UTF8 format / used in the java libs, and just write
///in/out as wchar_t all the time
/// to bother using the UTF8 format / used in the java libs, and just write
/// in/out as wchar_t all the time
/*for( unsigned short i = 0; i < UTFLength; i++)
{

View file

@ -1,7 +1,8 @@
#include "../../Platform/stdafx.h"
#include "../../Util/BasicTypeContainers.h"
#include "DataOutputStream.h"
#include <bit>
#include <cstdint>
// Creates a new data output stream to write data to the specified underlying
// output stream. The counter written is set to zero. Parameters: out - the
@ -86,7 +87,7 @@ void DataOutputStream::writeByte(uint8_t a) {
// counter written is incremented by 8. Parameters: v - a double value to be
// written.
void DataOutputStream::writeDouble(double a) {
int64_t bits = Double::doubleToLongBits(a);
int64_t bits = std::bit_cast<int64_t>(a);
writeLong(bits);
// TODO 4J Stu - Error handling?
@ -98,7 +99,7 @@ void DataOutputStream::writeDouble(double a) {
// as a 4-byte quantity, high byte first. If no exception is thrown, the counter
// written is incremented by 4. Parameters: v - a float value to be written.
void DataOutputStream::writeFloat(float a) {
int bits = Float::floatToIntBits(a);
int bits = std::bit_cast<int>(a);
writeInt(bits);
// TODO 4J Stu - Error handling?
@ -149,7 +150,8 @@ void DataOutputStream::writeShort(short a) {
void DataOutputStream::writeUnsignedShort(unsigned short a) {
if (stream == NULL) {
app.DebugPrintf(
"DataOutputStream::writeUnsignedShort() but underlying stream is NULL\n");
"DataOutputStream::writeUnsignedShort() but underlying stream is "
"NULL\n");
return;
}
stream->write(static_cast<unsigned int>((a >> 8) & 0xff));

View file

@ -1,6 +1,5 @@
#include "../Platform/stdafx.h"
#include "../Platform/System.h"
#include "../Util/BasicTypeContainers.h"
#include "../IO/Files/File.h"
#include "../Util/ProgressListener.h"
#include "../Headers/net.minecraft.h"
@ -39,7 +38,9 @@
#include "../../Minecraft.Client/Platform/Common/DLC/DLCPack.h"
#include "../../Minecraft.Client/Platform/PS3/PS3Extras/ShutdownManager.h"
#include "../../Minecraft.Client/MinecraftServer.h"
#include <cmath>
#include <cstdint>
#include <limits>
// 4J : WESTY : Added for time played stats.
#include "../Headers/net.minecraft.stats.h"
@ -1374,10 +1375,8 @@ HitResult* Level::clip(Vec3* a, Vec3* b, bool liquid) {
}
HitResult* Level::clip(Vec3* a, Vec3* b, bool liquid, bool solidOnly) {
if (Double::isNaN(a->x) || Double::isNaN(a->y) || Double::isNaN(a->z))
return NULL;
if (Double::isNaN(b->x) || Double::isNaN(b->y) || Double::isNaN(b->z))
return NULL;
if (std::isnan(a->x) || std::isnan(a->y) || std::isnan(a->z)) return NULL;
if (std::isnan(b->x) || std::isnan(b->y) || std::isnan(b->z)) return NULL;
int xTile1 = Mth::floor(b->x);
int yTile1 = Mth::floor(b->y);
@ -1403,7 +1402,7 @@ HitResult* Level::clip(Vec3* a, Vec3* b, bool liquid, bool solidOnly) {
int maxIterations = 200;
while (maxIterations-- >= 0) {
if (Double::isNaN(a->x) || Double::isNaN(a->y) || Double::isNaN(a->z))
if (std::isnan(a->x) || std::isnan(a->y) || std::isnan(a->z))
return NULL;
if (xTile0 == xTile1 && yTile0 == yTile1 && zTile0 == zTile1)
return NULL;
@ -2308,13 +2307,12 @@ void Level::tick(std::shared_ptr<Entity> e, bool actual) {
}
// SANTITY!!
if (Double::isNaN(e->x) || Double::isInfinite(e->x)) e->x = e->xOld;
if (Double::isNaN(e->y) || Double::isInfinite(e->y)) e->y = e->yOld;
if (Double::isNaN(e->z) || Double::isInfinite(e->z)) e->z = e->zOld;
if (Double::isNaN(e->xRot) || Double::isInfinite(e->xRot))
e->xRot = e->xRotO;
if (Double::isNaN(e->yRot) || Double::isInfinite(e->yRot))
e->yRot = e->yRotO;
if (!std::isfinite(e->x)) e->x = e->xOld;
if (!std::isfinite(e->y)) e->y = e->yOld;
if (!std::isfinite(e->z)) e->z = e->zOld;
if (!std::isfinite(e->xRot)) e->xRot = e->xRotO;
if (!std::isfinite(e->yRot)) e->yRot = e->yRotO;
int xcn = Mth::floor(e->x / 16);
int ycn = Mth::floor(e->y / 16);
@ -2931,7 +2929,7 @@ void Level::toggleDownfall() {
}
void Level::buildAndPrepareChunksToPoll() {
#if 0
#if 0
AUTO_VAR(itEnd, players.end());
for (AUTO_VAR(it, players.begin()); it != itEnd; it++)
{
@ -3512,7 +3510,7 @@ std::shared_ptr<Entity> Level::getClosestEntityOfClass(
std::vector<std::shared_ptr<Entity> >* entities =
getEntitiesOfClass(baseClass, bb);
std::shared_ptr<Entity> closest = nullptr;
double closestDistSqr = Double::MAX_VALUE;
double closestDistSqr = std::numeric_limits<double>::max();
// for (Entity entity : entities)
for (AUTO_VAR(it, entities->begin()); it != entities->end(); ++it) {
std::shared_ptr<Entity> entity = *it;
@ -4411,4 +4409,4 @@ bool Level::canCreateMore(eINSTANCEOF type, ESPAWN_TYPE spawnType) {
}
// 4J: Interpret 0 as no limit
return max == 0 || count < max;
}
}

View file

@ -11,7 +11,7 @@
#include "Storage/SparseLightStorage.h"
#include "BlockReplacements.h"
#include "LevelChunk.h"
#include "../Util/BasicTypeContainers.h"
#include <limits>
#include "../../Minecraft.Client/MinecraftServer.h"
#include "../../Minecraft.Client/Level/ServerLevel.h"
#include "../../Minecraft.Client/Network/ServerChunkCache.h"
@ -499,8 +499,8 @@ void LevelChunk::recalcHeightmapOnly() {
// value changed from -999 to 255
int y = Level::maxBuildHeight - 1;
// int p = x << level->depthBitsPlusFour | z <<
// level->depthBits; // 4J - removed
// int p = x << level->depthBitsPlusFour | z <<
// level->depthBits; // 4J - removed
#ifdef __PSVITA__
int Index = ((unsigned)x << 11) + ((unsigned)z << 7);
int offset = Level::COMPRESSED_CHUNK_SECTION_TILES;
@ -561,14 +561,14 @@ void LevelChunk::recalcHeightmap() {
byteArray blockData = byteArray(Level::CHUNK_TILE_COUNT);
getBlockData(blockData);
#endif
lowestHeightmap = Integer::MAX_VALUE;
lowestHeightmap = std::numeric_limits<int>::max();
int min = Level::maxBuildHeight - 1;
for (int x = 0; x < 16; x++)
for (int z = 0; z < 16; z++) {
int y = Level::maxBuildHeight - 1;
// int p = x << level->depthBitsPlusFour | z <<
// level->depthBits; // 4J - removed
// int p = x << level->depthBitsPlusFour | z <<
// level->depthBits; // 4J - removed
#ifdef __PSVITA__
int Index = ((unsigned)x << 11) + ((unsigned)z << 7);
@ -1747,21 +1747,21 @@ void LevelChunk::getEntitiesOfClass(const std::type_info& ec, AABB* bb,
// our class may be derived from, otherwise do a direct comparison
// of type_info
if (ec == typeid(Player))
isAssignableFrom = e->instanceof (eTYPE_PLAYER);
isAssignableFrom = e->instanceof(eTYPE_PLAYER);
else if (ec == typeid(Entity))
isAssignableFrom = e->instanceof (eTYPE_ENTITY);
isAssignableFrom = e->instanceof(eTYPE_ENTITY);
else if (ec == typeid(Mob))
isAssignableFrom = e->instanceof (eTYPE_MOB);
isAssignableFrom = e->instanceof(eTYPE_MOB);
else if (ec == typeid(LivingEntity))
isAssignableFrom = e->instanceof (eTYPE_LIVINGENTITY);
isAssignableFrom = e->instanceof(eTYPE_LIVINGENTITY);
else if (ec == typeid(ItemEntity))
isAssignableFrom = e->instanceof (eTYPE_ITEMENTITY);
isAssignableFrom = e->instanceof(eTYPE_ITEMENTITY);
else if (ec == typeid(Minecart))
isAssignableFrom = e->instanceof (eTYPE_MINECART);
isAssignableFrom = e->instanceof(eTYPE_MINECART);
else if (ec == typeid(Monster))
isAssignableFrom = e->instanceof (eTYPE_MONSTER);
isAssignableFrom = e->instanceof(eTYPE_MONSTER);
else if (ec == typeid(Zombie))
isAssignableFrom = e->instanceof (eTYPE_ZOMBIE);
isAssignableFrom = e->instanceof(eTYPE_ZOMBIE);
else if (Entity* entity = e.get();
entity != NULL && ec == typeid(*entity))
isAssignableFrom = true;

View file

@ -1,6 +1,5 @@
#include "../../Platform/stdafx.h"
#include "../../Util/JavaMath.h"
#include "../../Util/BasicTypeContainers.h"
#if 0
// 4J - not required anymore
#include "Matcher.h"
@ -41,7 +40,7 @@ std::vector<LevelSummary*>* McRegionLevelStorageSource::getLevelList() {
{
file = *it; //subFolders->at(i);
if (file->isDirectory())
if (file->isDirectory())
{
continue;
}
@ -142,7 +141,7 @@ bool McRegionLevelStorageSource::convertLevel(ConsoleSaveFile* saveFile,
}
int totalCount = normalRegions->size() + netherRegions->size() + enderRegions.size() + normalBaseFolders->size() + netherBaseFolders->size() + enderBaseFolders.size();
// System.out.println("Total conversion count is " + totalCount); 4J Jev, TODO
// convert normal world
@ -170,7 +169,7 @@ bool McRegionLevelStorageSource::convertLevel(ConsoleSaveFile* saveFile,
#if 0
// 4J - not required anymore
void McRegionLevelStorageSource::addRegions(File &baseFolder, std::vector<ChunkFile *> *dest, std::vector<File *> *firstLevelFolders)
void McRegionLevelStorageSource::addRegions(File &baseFolder, std::vector<ChunkFile *> *dest, std::vector<File *> *firstLevelFolders)
{
FolderFilter folderFilter;
ChunkFilter chunkFilter;
@ -236,7 +235,7 @@ void McRegionLevelStorageSource::convertRegions(
int z = chunkFile->getZ();
RegionFile *region = RegionFileCache::getRegionFile(baseFolder, x, z);
if (!region->hasChunk(x & 31, z & 31))
if (!region->hasChunk(x & 31, z & 31))
{
FileInputStream fis = new BufferedInputStream(FileInputStream(*chunkFile->getFile()));
DataInputStream istream = DataInputStream(&fis); // 4J - was new GZIPInputStream as well
@ -287,7 +286,7 @@ void McRegionLevelStorageSource::eraseFolders(std::vector<File*>* folders,
#if 0
// 4J - not required anymore
bool McRegionLevelStorageSource::FolderFilter::accept(File *file)
bool McRegionLevelStorageSource::FolderFilter::accept(File *file)
{
if (file->isDirectory())
{
@ -298,23 +297,23 @@ bool McRegionLevelStorageSource::FolderFilter::accept(File *file)
}
bool McRegionLevelStorageSource::ChunkFilter::accept(File *dir, const std::wstring& name)
bool McRegionLevelStorageSource::ChunkFilter::accept(File *dir, const std::wstring& name)
{
Matcher matcher( chunkFilePattern, name );
return matcher.matches();
}
McRegionLevelStorageSource::ChunkFile::ChunkFile(File *file)
McRegionLevelStorageSource::ChunkFile::ChunkFile(File *file)
{
this->file = file;
Matcher matcher( ChunkFilter::chunkFilePattern, file->getName() );
if (matcher.matches())
if (matcher.matches())
{
x = Integer::parseInt(matcher.group(1), 36);
z = Integer::parseInt(matcher.group(2), 36);
}
}
else
{
x = 0;
@ -346,18 +345,18 @@ bool McRegionLevelStorageSource::ChunkFile::operator<( ChunkFile *b )
return compareTo( b ) < 0;
}
File *McRegionLevelStorageSource::ChunkFile::getFile()
File *McRegionLevelStorageSource::ChunkFile::getFile()
{
return (File *) file;
}
int McRegionLevelStorageSource::ChunkFile::getX()
int McRegionLevelStorageSource::ChunkFile::getX()
{
return x;
}
int McRegionLevelStorageSource::ChunkFile::getZ()
int McRegionLevelStorageSource::ChunkFile::getZ()
{
return z;
}
#endif
#endif

View file

@ -1,8 +1,8 @@
#include "../../Platform/stdafx.h"
#include "../../IO/Streams/InputOutputStream.h"
#include "PacketListener.h"
#include "../../Util/BasicTypeContainers.h"
#include "CustomPayloadPacket.h"
#include <limits>
// Mojang-defined custom packets
const std::wstring CustomPayloadPacket::CUSTOM_BOOK_PACKET = L"MC|BEdit";
@ -25,7 +25,7 @@ CustomPayloadPacket::CustomPayloadPacket(const std::wstring& identifier,
if (data.data != NULL) {
length = data.length;
if (length > Short::MAX_VALUE) {
if (length > std::numeric_limits<short>::max()) {
app.DebugPrintf("Payload may not be larger than 32K\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
@ -40,7 +40,7 @@ void CustomPayloadPacket::read(DataInputStream* dis) {
identifier = readUtf(dis, 20);
length = dis->readShort();
if (length > 0 && length < Short::MAX_VALUE) {
if (length > 0 && length < std::numeric_limits<short>::max()) {
if (data.data != NULL) {
delete[] data.data;
}
@ -63,4 +63,4 @@ void CustomPayloadPacket::handle(PacketListener* listener) {
int CustomPayloadPacket::getEstimatedSize() {
return 2 + identifier.length() * 2 + 2 + length;
}
}

View file

@ -1,8 +1,8 @@
#include "../../Platform/stdafx.h"
#include "../../IO/Streams/InputOutputStream.h"
#include "PacketListener.h"
#include "../../Util/BasicTypeContainers.h"
#include "GameCommandPacket.h"
#include <limits>
GameCommandPacket::GameCommandPacket() { length = 0; }
@ -14,7 +14,7 @@ GameCommandPacket::GameCommandPacket(EGameCommand command, byteArray data) {
if (data.data != NULL) {
length = data.length;
if (length > Short::MAX_VALUE) {
if (length > std::numeric_limits<short>::max()) {
app.DebugPrintf("Payload may not be larger than 32K\n");
#ifndef _CONTENT_PACKAGE
__debugbreak();
@ -31,7 +31,7 @@ void GameCommandPacket::read(DataInputStream* dis) {
command = (EGameCommand)dis->readInt();
length = dis->readShort();
if (length > 0 && length < Short::MAX_VALUE) {
if (length > 0 && length < std::numeric_limits<short>::max()) {
if (data.data != NULL) {
delete[] data.data;
}
@ -52,4 +52,4 @@ void GameCommandPacket::handle(PacketListener* listener) {
listener->handleGameCommand(shared_from_this());
}
int GameCommandPacket::getEstimatedSize() { return 2 + 2 + length; }
int GameCommandPacket::getEstimatedSize() { return 2 + 2 + length; }

View file

@ -1,16 +1,17 @@
#include "../../Platform/stdafx.h"
#include "../../Util/BasicTypeContainers.h"
#include "../../IO/Streams/InputOutputStream.h"
#include "../../Headers/net.minecraft.network.packet.h"
#include "LevelSoundPacket.h"
#include <limits>
const float LevelSoundPacket::PITCH_ACCURACY = Byte::MAX_VALUE / 2.0f;
const float LevelSoundPacket::PITCH_ACCURACY =
std::numeric_limits<char>::max() / 2.0;
const float LevelSoundPacket::LOCATION_ACCURACY = 8.0f;
LevelSoundPacket::LevelSoundPacket() {
sound = 0;
x = 0;
y = Integer::MAX_VALUE;
y = std::numeric_limits<int>::max();
z = 0;
volume = 0.0f;
pitch = 0;

View file

@ -1,6 +1,5 @@
#include "../../Platform/stdafx.h"
#include "../../Platform/System.h"
#include "../../Util/BasicTypeContainers.h"
#include "../../IO/Streams/InputOutputStream.h"
#include "../../Headers/net.minecraft.network.packet.h"
#include "PacketListener.h"
@ -483,7 +482,8 @@ void Packet::writeUtf(const std::wstring& value,
// should this declare a throws?
{
#if 0
if (value.length() > Short::MAX_VALUE)
#include <limits>
if (value.length() > std::numeric_limits<short>::max())
{
throw new IOException(L"String too big");
}

View file

@ -1,13 +1,13 @@
#pragma once
#include "../../Util/BasicTypeContainers.h"
#include <limits>
#include "Packet.h"
class RemoveEntitiesPacket
: public Packet,
public std::enable_shared_from_this<RemoveEntitiesPacket> {
public:
static const int MAX_PER_PACKET = Byte::MAX_VALUE;
static const int MAX_PER_PACKET = std::numeric_limits<char>::max();
intArray ids;

View file

@ -3,8 +3,8 @@
#include "../../IO/Streams/InputOutputStream.h"
#include "PacketListener.h"
#include "../../WorldGen/Features/BasicTreeFeature.h"
#include "../../Util/BasicTypeContainers.h"
#include "UpdateMobEffectPacket.h"
#include <limits>
UpdateMobEffectPacket::UpdateMobEffectPacket() {
entityId = 0;
@ -19,8 +19,8 @@ UpdateMobEffectPacket::UpdateMobEffectPacket(int entityId,
effectId = (BYTE)(effect->getId() & 0xff);
effectAmplifier = (char)(effect->getAmplifier() & 0xff);
if (effect->getDuration() > Short::MAX_VALUE) {
effectDurationTicks = Short::MAX_VALUE;
if (effect->getDuration() > std::numeric_limits<short>::max()) {
effectDurationTicks = std::numeric_limits<short>::max();
} else {
effectDurationTicks = (short)effect->getDuration();
}
@ -41,7 +41,7 @@ void UpdateMobEffectPacket::write(DataOutputStream* dos) {
}
bool UpdateMobEffectPacket::isSuperLongDuration() {
return effectDurationTicks == Short::MAX_VALUE;
return effectDurationTicks == std::numeric_limits<short>::max();
}
void UpdateMobEffectPacket::handle(PacketListener* listener) {
@ -56,4 +56,4 @@ bool UpdateMobEffectPacket::isInvalidatedBy(std::shared_ptr<Packet> packet) {
std::shared_ptr<UpdateMobEffectPacket> target =
std::dynamic_pointer_cast<UpdateMobEffectPacket>(packet);
return target->entityId == entityId && target->effectId == effectId;
}
}

View file

@ -1,21 +0,0 @@
#include "../Platform/stdafx.h"
#include "BasicTypeContainers.h"
#include <limits>
/* 4J Jev TODO,
this is different to Float::MAX_VALUE, javas floats
seem to actually allow values of infinity which c++ does not.
*/
// A constant holding the positive infinity of type float. It is equal to the
// value returned by Float.intBitsToFloat(0x7f800000).
const float Float::POSITIVE_INFINITY = 0x7f800000;
const float Float::MAX_VALUE = FLT_MAX;
const double Double::MAX_VALUE = DBL_MAX;
const double Double::MIN_NORMAL = DBL_MIN;
int Integer::parseInt(std::wstring& str, int radix /* = 10*/) {
return wcstol(str.c_str(), NULL, radix);
}

View file

@ -1,57 +0,0 @@
#pragma once
#include <climits>
#include <cfloat>
class Byte {
public:
static const char MAX_VALUE = CHAR_MAX;
static const char MIN_VALUE = CHAR_MIN;
};
class Short {
public:
static const short MAX_VALUE = SHRT_MAX;
static const short MIN_VALUE = SHRT_MIN;
};
class Integer {
public:
static const int MAX_VALUE = INT_MAX;
static int parseInt(std::wstring& str, int radix = 10);
};
class Float {
public:
static const float MAX_VALUE;
static int floatToIntBits(float value) { return *(int*)&value; }
static int floatToRawIntBits(float value) { return *(int*)&value; }
static float intBitsToFloat(int bits) { return *(float*)&bits; }
static const float POSITIVE_INFINITY;
};
class Double {
public:
static const double MAX_VALUE;
static const double MIN_NORMAL;
static bool isNaN(double a) {
#ifdef __PS3__
return isnan(a);
#else
return (a != a);
#endif
}
static bool isInfinite(double a) { return false; /*4J TODO*/ }
static double longBitsToDouble(int64_t bits) { return *(double*)&bits; }
static int64_t doubleToLongBits(double d) { return *(int64_t*)&d; }
};
// 4J Stu - The String class should only be used if we need to use the
// BaseClass::class type As such I have renamed it so that we don't confuse it
// with places where we should use std::string
class _String {};

View file

@ -1,9 +1,10 @@
#include "../Platform/stdafx.h"
#include "../AI/Navigation/Node.h"
#include "../Platform/System.h"
#include "BasicTypeContainers.h"
#include "BinaryHeap.h"
#include <limits>
// 4J Jev, add common ctor code.
void BinaryHeap::_init() {
heap = NodeArray(1024);
@ -113,7 +114,7 @@ void BinaryHeap::downHeap(int idx) {
if (rightIdx >= sizeVar) {
// Only need to compare with left.
rightNode = NULL;
rightCost = Float::POSITIVE_INFINITY;
rightCost = std::numeric_limits<float>::infinity();
} else {
rightNode = heap[rightIdx];
rightCost = rightNode->f;
@ -142,4 +143,4 @@ void BinaryHeap::downHeap(int idx) {
node->heapIdx = idx;
}
bool BinaryHeap::isEmpty() { return sizeVar == 0; }
bool BinaryHeap::isEmpty() { return sizeVar == 0; }

View file

@ -3,7 +3,6 @@
#include "../Platform/stdafx.h"
#include "../AI/Navigation/Node.h"
#include "../Platform/System.h"
#include "BasicTypeContainers.h"
class BinaryHeap {
private:
@ -31,4 +30,4 @@ private:
public:
bool isEmpty();
};
};

View file

@ -1,8 +1,8 @@
#include "../Platform/stdafx.h"
#include "../Headers/net.minecraft.world.damagesource.h"
#include "../Headers/net.minecraft.world.entity.h"
#include "BasicTypeContainers.h"
#include "CombatEntry.h"
#include <limits>
CombatEntry::CombatEntry(DamageSource* source, int time, float health,
float damage, CombatTracker::eLOCATION location,
@ -45,6 +45,7 @@ std::wstring CombatEntry::getAttackerName() {
}
float CombatEntry::getFallDistance() {
if (source == DamageSource::outOfWorld) return Float::MAX_VALUE;
if (source == DamageSource::outOfWorld)
return std::numeric_limits<float>::max();
return fallDistance;
}
}

View file

@ -5,8 +5,8 @@
#include "../../Headers/net.minecraft.world.level.h"
#include "../../Headers/net.minecraft.world.level.tile.h"
#include "../../Headers/net.minecraft.world.phys.h"
#include "../../Util/BasicTypeContainers.h"
#include "Village.h"
#include <limits>
Village::Aggressor::Aggressor(std::shared_ptr<LivingEntity> mob,
int timeStamp) {
@ -159,7 +159,7 @@ std::vector<std::shared_ptr<DoorInfo> >* Village::getDoorInfos() {
std::shared_ptr<DoorInfo> Village::getClosestDoorInfo(int x, int y, int z) {
std::shared_ptr<DoorInfo> closest = nullptr;
int closestDistSqr = Integer::MAX_VALUE;
int closestDistSqr = std::numeric_limits<int>::max();
// for (DoorInfo dm : doorInfos)
for (AUTO_VAR(it, doorInfos.begin()); it != doorInfos.end(); ++it) {
std::shared_ptr<DoorInfo> dm = *it;
@ -174,7 +174,7 @@ std::shared_ptr<DoorInfo> Village::getClosestDoorInfo(int x, int y, int z) {
std::shared_ptr<DoorInfo> Village::getBestDoorInfo(int x, int y, int z) {
std::shared_ptr<DoorInfo> closest = nullptr;
int closestDist = Integer::MAX_VALUE;
int closestDist = std::numeric_limits<int>::max();
// for (DoorInfo dm : doorInfos)
for (AUTO_VAR(it, doorInfos.begin()); it != doorInfos.end(); ++it) {
std::shared_ptr<DoorInfo> dm = *it;
@ -232,7 +232,7 @@ void Village::addAggressor(std::shared_ptr<LivingEntity> mob) {
std::shared_ptr<LivingEntity> Village::getClosestAggressor(
std::shared_ptr<LivingEntity> from) {
double closestSqr = Double::MAX_VALUE;
double closestSqr = std::numeric_limits<double>::max();
Aggressor* closest = NULL;
// for (int i = 0; i < aggressors.size(); ++i)
for (AUTO_VAR(it, aggressors.begin()); it != aggressors.end(); ++it) {
@ -247,7 +247,7 @@ std::shared_ptr<LivingEntity> Village::getClosestAggressor(
std::shared_ptr<Player> Village::getClosestBadStandingPlayer(
std::shared_ptr<LivingEntity> from) {
double closestSqr = Double::MAX_VALUE;
double closestSqr = std::numeric_limits<double>::max();
std::shared_ptr<Player> closest = nullptr;
// for (String player : playerStanding.keySet())
@ -453,4 +453,4 @@ void Village::rewardAllPlayers(int amount) {
++it) {
modifyStanding(it->first, amount);
}
}
}

View file

@ -3,8 +3,8 @@
#include "../../Headers/net.minecraft.world.level.h"
#include "../../Headers/net.minecraft.world.level.tile.h"
#include "../../Headers/net.minecraft.world.phys.h"
#include "../../Util/BasicTypeContainers.h"
#include "Villages.h"
#include <limits>
const std::wstring Villages::VILLAGE_FILE_ID = L"villages";
@ -74,7 +74,7 @@ std::vector<std::shared_ptr<Village> >* Villages::getVillages() {
std::shared_ptr<Village> Villages::getClosestVillage(int x, int y, int z,
int maxDist) {
std::shared_ptr<Village> closest = nullptr;
float closestDistSqr = Float::MAX_VALUE;
float closestDistSqr = std::numeric_limits<float>::max();
// for (Village village : villages)
for (AUTO_VAR(it, villages.begin()); it != villages.end(); ++it) {
std::shared_ptr<Village> village = *it;
@ -221,4 +221,4 @@ void Villages::save(CompoundTag* tag) {
villageTags->add(villageTag);
}
tag->put(L"Villages", villageTags);
}
}