diff options
| author | ModMaker101 <119018978+ModMaker101@users.noreply.github.com> | 2026-03-07 21:56:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-08 09:56:03 +0700 |
| commit | a9be52c41a02d207233199e98898fe7483d7e817 (patch) | |
| tree | 71dfaec3a86b05e9ca409b97d8eb9d7f993bfdd0 /Minecraft.World/Random.cpp | |
| parent | 1be5faaea781402e7de06b263eeca4c688b7712c (diff) | |
Project modernization (#630)
* Fixed boats falling and a TP glitch #266
* Replaced every C-style cast with C++ ones
* Replaced every C-style cast with C++ ones
* Fixed boats falling and a TP glitch #266
* Updated NULL to nullptr and fixing some type issues
* Modernized and fixed a few bugs
- Replaced most instances of `NULL` with `nullptr`.
- Replaced most `shared_ptr(new ...)` with `make_shared`.
- Removed the `nullptr` macro as it was interfering with the actual nullptr keyword in some instances.
* Fixing more conflicts
* Replace int loops with size_t and start work on overrides
Diffstat (limited to 'Minecraft.World/Random.cpp')
| -rw-r--r-- | Minecraft.World/Random.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Minecraft.World/Random.cpp b/Minecraft.World/Random.cpp index d4e3a545..89903da8 100644 --- a/Minecraft.World/Random.cpp +++ b/Minecraft.World/Random.cpp @@ -27,22 +27,22 @@ void Random::setSeed(int64_t s) int Random::next(int bits) { seed = (seed * 0x5DEECE66DLL + 0xBLL) & ((1LL << 48) - 1); - return (int)(seed >> (48 - bits)); + return static_cast<int>(seed >> (48 - bits)); } void Random::nextBytes(byte *bytes, unsigned int count) { for(unsigned int i = 0; i < count; i++ ) { - bytes[i] = (byte)next(8); + bytes[i] = static_cast<byte>(next(8)); } } double Random::nextDouble() { - return (((int64_t)next(26) << 27) + next(27)) - / (double)(1LL << 53); + return ((static_cast<int64_t>(next(26)) << 27) + next(27)) + / static_cast<double>(1LL << 53); } double Random::nextGaussian() @@ -79,7 +79,7 @@ int Random::nextInt(int n) if ((n & -n) == n) // i.e., n is a power of 2 - return (int)(((int64_t)next(31) * n) >> 31); // 4J Stu - Made int64_t instead of long + return static_cast<int>((static_cast<int64_t>(next(31)) * n) >> 31); // 4J Stu - Made int64_t instead of long int bits, val; do @@ -92,12 +92,12 @@ int Random::nextInt(int n) float Random::nextFloat() { - return next(24) / ((float)(1 << 24)); + return next(24) / static_cast<float>(1 << 24); } int64_t Random::nextLong() { - return ((int64_t)next(32) << 32) + next(32); + return (static_cast<int64_t>(next(32)) << 32) + next(32); } bool Random::nextBoolean() |
