mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2025-12-21 07:49:22 +00:00
Use platform math functions
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
||||
Date: Wed, 23 Nov 2022 22:49:59 +0100
|
||||
Subject: [PATCH] Use ThreadUnsafeRandom for mob spawning
|
||||
|
||||
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
Gale - https://galemc.org
|
||||
|
||||
This patch is based on the following patch:
|
||||
"Use thread unsafe random for mob spawning"
|
||||
By: Paul Sauve <paul@technove.co>
|
||||
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
|
||||
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
|
||||
|
||||
* Airplane copyright *
|
||||
|
||||
Airplane
|
||||
Copyright (C) 2020 Technove LLC
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/world/level/NaturalSpawner.java b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
index 599efa2ed24e0d4944324c86ca23c38d8b111277..135c62a90b1cf924812fa4c8c224057eed67a109 100644
|
||||
--- a/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
+++ b/src/main/java/net/minecraft/world/level/NaturalSpawner.java
|
||||
@@ -415,13 +415,14 @@ public final class NaturalSpawner {
|
||||
}
|
||||
}
|
||||
|
||||
- private static BlockPos getRandomPosWithin(Level world, LevelChunk chunk) {
|
||||
+ private static BlockPos getRandomPosWithin(ServerLevel world, LevelChunk chunk) { // Gale - Airplane - Use ThreadUnsafeRandom for mob spawning - accept ServerLevel
|
||||
ChunkPos chunkcoordintpair = chunk.getPos();
|
||||
- int i = chunkcoordintpair.getMinBlockX() + world.random.nextInt(16);
|
||||
- int j = chunkcoordintpair.getMinBlockZ() + world.random.nextInt(16);
|
||||
+ // Gale start - Airplane - Use ThreadUnsafeRandom for mob spawning - use ThreadUnsafeRandom
|
||||
+ int i = chunkcoordintpair.getMinBlockX() + world.randomTickRandom.nextInt(16);
|
||||
+ int j = chunkcoordintpair.getMinBlockZ() + world.randomTickRandom.nextInt(16);
|
||||
+ // Gale end - Airplane - Use ThreadUnsafeRandom for mob spawning - use ThreadUnsafeRandom
|
||||
int k = chunk.getHeight(Heightmap.Types.WORLD_SURFACE, i, j) + 1;
|
||||
- int l = Mth.randomBetweenInclusive(world.random, world.getMinBuildHeight(), k);
|
||||
-
|
||||
+ int l = Mth.randomBetweenInclusive(world.randomTickRandom, world.getMinBuildHeight(), k); // Gale - Airplane - Use ThreadUnsafeRandom for mob spawning - use ThreadUnsafeRandom
|
||||
return new BlockPos(i, l, j);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user