Slowly porting to 1.18

This commit is contained in:
Etil
2021-12-09 16:10:30 +01:00
parent 5c8b50e2af
commit 7e86b28719
18 changed files with 833 additions and 9 deletions

View File

@@ -2,7 +2,7 @@ group=wtf.etil.mirai
version=1.18-R0.1-SNAPSHOT
mcVersion=1.18
pufferfishRef=caa7c232ca111706730b5e7ff645fb984b1e74df
pufferfishRef=7fba909e4a82eee168a39646222d816e36759072
org.gradle.caching=true
org.gradle.caching.debug=false

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Mirai Configuration
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 395b0706bfbf03741df6ca1ff084618b91140acc..4db14d1d0df5d8fac850ae3a769b8a18eed54ebd 100644
index 6996a61534bbdd34729f1dcd988ae2666bfad2c4..b3b0cea3ed790599b90b98a24aa142875efa1f7b 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -1727,6 +1727,18 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -1743,6 +1743,18 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
}
// Paper end

View File

@@ -3,6 +3,8 @@ From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Thu, 2 Dec 2021 16:22:24 +0100
Subject: [PATCH] Avoid double I/O operation on load player file
Original code by Akarin-project, licensed under GNU General Public License v3.0
You can find the original code on https://github.com/Akarin-project/Akarin
diff --git a/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java b/src/main/java/net/minecraft/world/level/storage/PlayerDataStorage.java
index 35c39aed9583275ef25d32c783715798b52bdb63..331ed6aa983714d6fc3596526fc7df0ab993062c 100644

View File

@@ -3,12 +3,14 @@ From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Thu, 2 Dec 2021 16:25:37 +0100
Subject: [PATCH] Swaps the predicate order of collision
Original code by Akarin-project, licensed under GNU General Public License v3.0
You can find the original code on https://github.com/Akarin-project/Akarin
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 2bbb547e9f96984b50554e5783fc9ad2601eb52b..6513716ba8eef2c586a8af54ce9d314bf23c7ed4 100644
index 3d973c5a62a2985a472c89c0a64aa7edc395aba2..ed2a684deccedf85ffbee01baeaa922c71bfb435 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -1769,37 +1769,35 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
@@ -1850,37 +1850,35 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
public void playerTouch(Player player) {}
public void push(Entity entity) {

View File

@@ -3,6 +3,8 @@ From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Thu, 2 Dec 2021 16:28:51 +0100
Subject: [PATCH] Don't trigger Lootable Refresh for non player interaction
Original code by Akarin-project, licensed under GNU General Public License v3.0
You can find the original code on https://github.com/Akarin-project/Akarin
diff --git a/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/RandomizableContainerBlockEntity.java
index da00f75ccc9f8c2e2174d4450479202a50844245..9168e4981692e20def127deec9cbf21767588507 100644

View File

@@ -3,6 +3,8 @@ From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Thu, 2 Dec 2021 16:55:37 +0100
Subject: [PATCH] lithium: reduce allocs
Original code by CaffeineMC, licensed under GNU Lesser General Public License v3.0
You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings)
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/ArrayConstants.java b/src/main/java/me/jellysquid/mods/lithium/common/util/ArrayConstants.java
new file mode 100644
@@ -18,10 +20,10 @@ index 0000000000000000000000000000000000000000..d341fcb89c8744aa1bd8cb3ef6af93e7
+}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 0c9169423f9093594ea6d242ed5492ffc22c241f..489d60f34af09b2b7fe8d0cc0cc3fc820886d3a6 100644
index af9c58944b38e8aeeca5dca75c9f97e49f2895f2..a1550515a34ea448f7246d3f90c746bf22acc608 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3005,10 +3005,12 @@ public abstract class LivingEntity extends Entity {
@@ -3019,10 +3019,12 @@ public abstract class LivingEntity extends Entity {
}

View File

@@ -3,6 +3,8 @@ From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Thu, 2 Dec 2021 17:00:23 +0100
Subject: [PATCH] lithium: MixinDirection
Original code by CaffeineMC, licensed under GNU Lesser General Public License v3.0
You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings)
diff --git a/src/main/java/net/minecraft/core/Direction.java b/src/main/java/net/minecraft/core/Direction.java
index 6d883db5c04cbcf454952c0f361029ecbfe4f037..53d853a4e9d8e3de4747a75f08f42545b048bbbb 100644

View File

@@ -3,6 +3,8 @@ From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Thu, 2 Dec 2021 17:09:27 +0100
Subject: [PATCH] lithium: HashedList
Original code by CaffeineMC, licensed under GNU Lesser General Public License v3.0
You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings)
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/collections/HashedList.java b/src/main/java/me/jellysquid/mods/lithium/common/util/collections/HashedList.java
new file mode 100644

View File

@@ -3,6 +3,8 @@ From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Fri, 3 Dec 2021 21:55:11 +0100
Subject: [PATCH] lithium: CompactSineLUT
Original code by CaffeineMC, licensed under GNU Lesser General Public License v3.0
You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings)
diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/math/CompactSineLUT.java b/src/main/java/me/jellysquid/mods/lithium/common/util/math/CompactSineLUT.java
new file mode 100644

View File

@@ -3,9 +3,11 @@ From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Fri, 3 Dec 2021 22:28:16 +0100
Subject: [PATCH] lithium: entity.fast_retrieval
Original code by CaffeineMC, licensed under GNU Lesser General Public License v3.0
You can find the original code on https://github.com/CaffeineMC/lithium-fabric (Yarn mappings)
diff --git a/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java b/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java
index 984e940a1d8060e5945a6efd10c9f81bed2bf057..32f738cb7df36e66cd22ad604f648d20e6db08b7 100644
index 74210dc2eef63da7360b1f833bb59b278419fb2b..18b96bac2382084f1c8f77fe610ff5c9f3b0ed36 100644
--- a/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java
+++ b/src/main/java/net/minecraft/world/level/entity/EntitySectionStorage.java
@@ -33,33 +33,56 @@ public class EntitySectionStorage<T extends EntityAccess> {

View File

@@ -3,9 +3,11 @@ From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Sat, 4 Dec 2021 22:52:50 +0100
Subject: [PATCH] Utilities
Original code by YatopiaMC, licensed under MIT
You can find the original code on https://github.com/YatopiaMC/Yatopia
diff --git a/build.gradle.kts b/build.gradle.kts
index d3fdca4fe0de48446987f8fae650daab6665ae17..20b4c362d0ea1f6396df51423ce654a4f66959fe 100644
index 6a16c5843bc2c585dde268b6dacef7f54a13d4fb..2e69e4875f22b2cb695ebfa851ae545e580c8b9c 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -39,6 +39,7 @@ dependencies {

View File

@@ -0,0 +1,73 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Thu, 9 Dec 2021 13:52:16 +0100
Subject: [PATCH] Preload ProtocolLib EnumWrappers
Original code by YatopiaMC, licensed under MIT
You can find the original code on https://github.com/YatopiaMC/Yatopia
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 819fc4b53b5f2f9dc9c25641be644218d3d4f460..40fe4111a52ab754094d462b0d1889e740797d4d 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1219,6 +1219,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
LOGGER.info("Done ({})! For help, type \"help\"", doneTime);
// Paper end
+ if (wtf.etil.mirai.MiraiConfig.fixProtocolLib) org.yatopiamc.yatopia.server.util.YatopiaPreloadProtocolLib.run(); // Yatopia - Preload ProtocolLib's Enum Wrappers
org.spigotmc.WatchdogThread.tick(); // Paper
org.spigotmc.WatchdogThread.hasStarted = true; // Paper
Arrays.fill( recentTps, 20 );
diff --git a/src/main/java/org/yatopiamc/yatopia/server/util/YatopiaPreloadProtocolLib.java b/src/main/java/org/yatopiamc/yatopia/server/util/YatopiaPreloadProtocolLib.java
new file mode 100644
index 0000000000000000000000000000000000000000..663017bc4645b87897c82cb858e1e7d761858868
--- /dev/null
+++ b/src/main/java/org/yatopiamc/yatopia/server/util/YatopiaPreloadProtocolLib.java
@@ -0,0 +1,28 @@
+package org.yatopiamc.yatopia.server.util;
+
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.Bukkit;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.SimplePluginManager;
+
+import java.lang.reflect.Method;
+
+public class YatopiaPreloadProtocolLib {
+
+ public synchronized static void run() {
+ try {
+ final SimplePluginManager pluginManager = (SimplePluginManager) Bukkit.getPluginManager();
+ final Plugin protocolLib = pluginManager.getPlugin("ProtocolLib");
+ if(protocolLib != null && protocolLib.isEnabled()) {
+ MinecraftServer.LOGGER.info("Mirai: Attempting to preload ProtocolLib's EnumWrappers");
+ final Method initialize = Class.forName("com.comphenix.protocol.wrappers.EnumWrappers", true, protocolLib.getClass().getClassLoader()).getDeclaredMethod("initialize");
+ initialize.setAccessible(true);
+ initialize.invoke(null);
+ synchronized (YatopiaPreloadProtocolLib.class) {
+ }
+ }
+ } catch (Throwable t) {
+ MinecraftServer.LOGGER.warn("Mirai: Failed to preload ProtocolLib's EnumWrappers", t);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/wtf/etil/mirai/MiraiConfig.java b/src/main/java/wtf/etil/mirai/MiraiConfig.java
index 5b30b329959811f99f13f32166574f90e765bcb1..8f07fceba57bf49d8a2e0d9c1dedf91d23bb3932 100644
--- a/src/main/java/wtf/etil/mirai/MiraiConfig.java
+++ b/src/main/java/wtf/etil/mirai/MiraiConfig.java
@@ -184,6 +184,11 @@ public class MiraiConfig {
// Mirai - settings below
-
+ public static boolean fixProtocolLib = true;
+ private static void protocolLib() {
+ fixProtocolLib = getBoolean("fix-protocollib", fixProtocolLib);
+ }
+
+
}
\ No newline at end of file

View File

@@ -0,0 +1,44 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Thu, 9 Dec 2021 14:08:05 +0100
Subject: [PATCH] Add config for logging login location
Original code by YatopiaMC, licensed under MIT
You can find the original code on https://github.com/YatopiaMC/Yatopia
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 042be2cf60a9d01698808d84f2e537a5eb952079..456bfb666238c9384b1fd70f85c4467449fc214a 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -483,7 +483,13 @@ public abstract class PlayerList {
}
// Paper end
// CraftBukkit - Moved from above, added world
- PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), s1, player.getId(), worldserver1.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ());
+ // Yatopia start - configurable logging of player login location
+ if (wtf.etil.mirai.MiraiConfig.logPlayerLoginLoc) {
+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), s1, player.getId(), worldserver1.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ());
+ } else {
+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {}", player.getName().getString(), s1, player.getId());
+ }
+ // Yatopia end - configurable logging of player login location
}
public void updateEntireScoreboard(ServerScoreboard scoreboard, ServerPlayer player) {
diff --git a/src/main/java/wtf/etil/mirai/MiraiConfig.java b/src/main/java/wtf/etil/mirai/MiraiConfig.java
index 8f07fceba57bf49d8a2e0d9c1dedf91d23bb3932..9f775115d5120d3fc514d9c0cea98272feecbb49 100644
--- a/src/main/java/wtf/etil/mirai/MiraiConfig.java
+++ b/src/main/java/wtf/etil/mirai/MiraiConfig.java
@@ -189,6 +189,11 @@ public class MiraiConfig {
fixProtocolLib = getBoolean("fix-protocollib", fixProtocolLib);
}
+ public static boolean logPlayerLoginLoc = true;
+ private static void logPlayerLoc() {
+ logPlayerLoginLoc = getBoolean("log-player-login-location", logPlayerLoginLoc);
+ }
+
}
\ No newline at end of file

View File

@@ -0,0 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Thu, 9 Dec 2021 14:16:06 +0100
Subject: [PATCH] Optimize TileEntity load unload
Original code by YatopiaMC, licensed under MIT
You can find the original code on https://github.com/YatopiaMC/Yatopia
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 90aa1d75b5c23e5ee27ceae9f6ef90de913a6601..a7262d842ff1684346302e10b08b1e7bc98f47a5 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -116,8 +116,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public static final int TICKS_PER_DAY = 24000;
public static final int MAX_ENTITY_SPAWN_Y = 20000000;
public static final int MIN_ENTITY_SPAWN_Y = -20000000;
- protected final List<TickingBlockEntity> blockEntityTickers = Lists.newArrayList(); public final int getTotalTileEntityTickers() { return this.blockEntityTickers.size(); } // Paper
- private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList();
+ //protected final List<TickingBlockEntity> blockEntityTickers = Lists.newArrayList(); public final int getTotalTileEntityTickers() { return this.blockEntityTickers.size(); } // Paper
+ //private final List<TickingBlockEntity> pendingBlockEntityTickers = Lists.newArrayList();
+ public final List<TickingBlockEntity> blockEntityTickers = me.jellysquid.mods.lithium.common.util.collections.HashedList.wrapper(Lists.newArrayList()); public final int getTotalTileEntityTickers() { return this.blockEntityTickers.size(); } // Paper // Yatopia
+ private final List<TickingBlockEntity> pendingBlockEntityTickers = me.jellysquid.mods.lithium.common.util.collections.HashedList.wrapper(Lists.newArrayList()); // Yatopia
private boolean tickingBlockEntities;
public final Thread thread;
private final boolean isDebug;

View File

@@ -0,0 +1,42 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Thu, 9 Dec 2021 14:25:18 +0100
Subject: [PATCH] Global Eula file
Original code by YatopiaMC, licensed under MIT
You can find the original code on https://github.com/YatopiaMC/Yatopia
diff --git a/src/main/java/net/minecraft/server/Eula.java b/src/main/java/net/minecraft/server/Eula.java
index a1d5c0f8fe2adb2ee56f3217e089211ec7c61eb0..a4eb2860367d1f4cf128637b6e9c6325be659dd4 100644
--- a/src/main/java/net/minecraft/server/Eula.java
+++ b/src/main/java/net/minecraft/server/Eula.java
@@ -16,12 +16,26 @@ public class Eula {
public Eula(Path eulaFile) {
this.file = eulaFile;
- this.agreed = SharedConstants.IS_RUNNING_IN_IDE || this.readFile();
+ this.agreed = SharedConstants.IS_RUNNING_IN_IDE || globalEula() || this.readFile(eulaFile);
}
- private boolean readFile() {
+ // Yatopia start - global eula file
+ private boolean globalEula() {
+ java.io.File globalEula = new java.io.File(System.getProperty("user.home"), "eula.txt");
+
+ if (globalEula.exists()) {
+ System.out.println("Loaded global eula file from " + globalEula.getAbsolutePath());
+ return readFile(globalEula.toPath());
+ } else {
+ System.out.println("No global eula file found at " + globalEula.getAbsolutePath());
+ }
+ return false;
+ }
+ // Yatopia end
+
+ private boolean readFile(java.nio.file.Path path) {
try {
- InputStream inputStream = Files.newInputStream(this.file);
+ InputStream inputStream = Files.newInputStream(path);
boolean var3;
try {

View File

@@ -0,0 +1,74 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Thu, 9 Dec 2021 15:07:13 +0100
Subject: [PATCH] Stop wasting resources on JsonList#get
Original code by YatopiaMC, licensed under MIT
You can find the original code on https://github.com/YatopiaMC/Yatopia
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 456bfb666238c9384b1fd70f85c4467449fc214a..dc53441ce82240f8cf7bb35afe01b40743777cd5 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -743,13 +743,19 @@ public abstract class PlayerList {
if (getBans().isBanned(gameprofile) && (gameprofilebanentry = getBans().get(gameprofile)) != null) {
// Paper end
+ if (!gameprofilebanentry.hasExpired()) { // Yatopia
chatmessage = new TranslatableComponent("multiplayer.disconnect.banned.reason", new Object[]{gameprofilebanentry.getReason()});
if (gameprofilebanentry.getExpires() != null) {
chatmessage.append((Component) (new TranslatableComponent("multiplayer.disconnect.banned.expiration", new Object[]{PlayerList.BAN_DATE_FORMAT.format(gameprofilebanentry.getExpires())})));
}
// return chatmessage;
+ // Yatopia start - Stop wasting resources on JsonList#get
event.disallow(PlayerLoginEvent.Result.KICK_BANNED, PaperAdventure.asAdventure(chatmessage)); // Paper - Adventure
+ } else {
+ getBans().remove(gameprofile);
+ }
+ // Yatopia end
} else if (!this.isWhitelisted(gameprofile, event)) { // Paper
//chatmessage = new ChatMessage("multiplayer.disconnect.not_whitelisted"); // Paper
//event.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, org.spigotmc.SpigotConfig.whitelistMessage); // Spigot // Paper - moved to isWhitelisted
diff --git a/src/main/java/net/minecraft/server/players/StoredUserList.java b/src/main/java/net/minecraft/server/players/StoredUserList.java
index 8982562721c3a5a5a3305e90bd8b5bc21585a425..db22fc485e6091bd81c0c369f302c6ffb4157448 100644
--- a/src/main/java/net/minecraft/server/players/StoredUserList.java
+++ b/src/main/java/net/minecraft/server/players/StoredUserList.java
@@ -73,9 +73,14 @@ public abstract class StoredUserList<K, V extends StoredUserEntry<K>> {
// Paper start
// this.g();
// return (V) this.d.get(this.a(k0)); // CraftBukkit - fix decompile error
+ // Yatopia start - only remove if it expires and has been requested (Stop wasting resources on JsonList#get)
+ return this.map.get(this.getKeyForUser(key));
+ /*
return (V) this.map.computeIfPresent(this.getKeyForUser(key), (k, v) -> {
return v.hasExpired() ? null : v;
});
+ */
+ // Sugarcane end
// Paper end
}
@@ -150,6 +155,8 @@ public abstract class StoredUserList<K, V extends StoredUserEntry<K>> {
public void save() throws IOException {
this.removeExpired(); // Paper - remove expired values before saving
JsonArray jsonarray = new JsonArray();
+ // Yatopia start - we're nuking streams wherever possible (Stop wasting resources on JsonList#get)
+ /*
Stream<JsonObject> stream = this.map.values().stream().map((jsonlistentry) -> { // CraftBukkit - decompile error
JsonObject jsonobject = new JsonObject();
@@ -159,6 +166,13 @@ public abstract class StoredUserList<K, V extends StoredUserEntry<K>> {
Objects.requireNonNull(jsonarray);
stream.forEach(jsonarray::add);
+ */
+ for (V value : this.map.values()) {
+ JsonObject obj = new JsonObject();
+ value.serialize(obj);
+ jsonarray.add(obj);
+ }
+ // Yatopia end
BufferedWriter bufferedwriter = Files.newWriter(this.file, StandardCharsets.UTF_8);
try {

View File

@@ -0,0 +1,513 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Thu, 9 Dec 2021 15:25:14 +0100
Subject: [PATCH] Use faster random implementation
Original code by YatopiaMC, licensed under MIT
You can find the original code on https://github.com/YatopiaMC/Yatopia
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java
index 20cfe7b9b7127ddeb97aa91d759fc17b4a548eaf..5cadd485b3987eec21743f3315cd226930646eac 100644
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperLootableInventoryData.java
@@ -13,7 +13,7 @@ import java.util.UUID;
public class PaperLootableInventoryData {
- private static final Random RANDOM = new Random();
+ private static final Random RANDOM = new org.yatopiamc.yatopia.server.util.FastRandom();
private long lastFill = -1;
private long nextRefill = -1;
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 40fe4111a52ab754094d462b0d1889e740797d4d..c691ee6208521b1570f0f25c8bbfd05146bd155c 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -415,7 +415,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
this.onMetricsRecordingFinished = (path) -> {
};
this.status = new ServerStatus();
- this.random = new Random();
+ this.random = new org.yatopiamc.yatopia.server.util.FastRandom();
this.port = -1;
this.levels = Maps.newLinkedHashMap(); // CraftBukkit - keep order, k+v already use identity methods
this.running = true;
@@ -650,7 +650,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
if (worlddimension == null) {
dimensionmanager = (DimensionType) this.registryHolder.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY).getOrThrow(DimensionType.OVERWORLD_LOCATION);
- chunkgenerator = WorldGenSettings.makeDefaultOverworld(this.registryHolder, (new Random()).nextLong());
+ chunkgenerator = WorldGenSettings.makeDefaultOverworld(this.registryHolder, (new org.yatopiamc.yatopia.server.util.FastRandom()).nextLong());
} else {
dimensionmanager = worlddimension.type();
chunkgenerator = worlddimension.generator();
@@ -778,7 +778,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
ChunkPos chunkcoordintpair = new ChunkPos(chunkgenerator.climateSampler().findSpawnPosition());
// CraftBukkit start
if (world.generator != null) {
- Random rand = new Random(world.getSeed());
+ Random rand = new org.yatopiamc.yatopia.server.util.FastRandom(world.getSeed());
org.bukkit.Location spawn = world.generator.getFixedSpawnLocation(world.getWorld(), rand);
if (spawn != null) {
diff --git a/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java b/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java
index 62f26f5d3ef5546f26424185e378fea64c08ce2f..832b87d7a42d6e8b38e2e7746ef8fea42fd46307 100644
--- a/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java
+++ b/src/main/java/net/minecraft/server/commands/SpreadPlayersCommand.java
@@ -55,7 +55,7 @@ public class SpreadPlayersCommand {
}
private static int spreadPlayers(CommandSourceStack source, Vec2 center, float spreadDistance, float maxRange, int maxY, boolean respectTeams, Collection<? extends Entity> players) throws CommandSyntaxException {
- Random random = new Random();
+ Random random = new org.yatopiamc.yatopia.server.util.FastRandom();
double d0 = (double) (center.x - maxRange);
double d1 = (double) (center.y - maxRange);
double d2 = (double) (center.x + maxRange);
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 7b23535a680d2a8534dcb8dd87770f66fb982c13..ab06dd398bdf52656123eecdfe4daebe2a3b07e6 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -368,7 +368,7 @@ public class ServerPlayer extends Player {
long l = k * k;
int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l;
int j1 = this.getCoprime(i1);
- int k1 = (new Random()).nextInt(i1);
+ int k1 = (new org.yatopiamc.yatopia.server.util.FastRandom()).nextInt(i1);
for (int l1 = 0; l1 < i1; ++l1) {
int i2 = (k1 + j1 * l1) % i1;
@@ -405,7 +405,7 @@ public class ServerPlayer extends Player {
long l = k * k;
int i1 = l > 2147483647L ? Integer.MAX_VALUE : (int) l;
int j1 = this.getCoprime(i1);
- int k1 = (new Random()).nextInt(i1);
+ int k1 = (new org.yatopiamc.yatopia.server.util.FastRandom()).nextInt(i1);
for (int l1 = 0; l1 < i1; ++l1) {
int i2 = (k1 + j1 * l1) % i1;
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 33a29890435d6065a2cc4f8e8bf8209c01d5d114..f1c865c415243f50a9c82b96cca023274897193e 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -52,7 +52,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0);
static final Logger LOGGER = LogManager.getLogger();
private static final int MAX_TICKS_BEFORE_LOGIN = 600;
- private static final Random RANDOM = new Random();
+ private static final Random RANDOM = new org.yatopiamc.yatopia.server.util.FastRandom();
private final byte[] nonce = new byte[4];
final MinecraftServer server;
public final Connection connection;
diff --git a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java
index 25ae440839f1d286550a77d0a4c61e1dc02b369d..b0cbe7d42eef1865e84211844b351027a26a5956 100644
--- a/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java
+++ b/src/main/java/net/minecraft/server/rcon/thread/QueryThreadGs4.java
@@ -348,7 +348,7 @@ public class QueryThreadGs4 extends GenericThread {
this.identBytes[2] = bs[5];
this.identBytes[3] = bs[6];
this.ident = new String(this.identBytes, StandardCharsets.UTF_8);
- this.challenge = (new Random()).nextInt(16777216);
+ this.challenge = (new org.yatopiamc.yatopia.server.util.FastRandom()).nextInt(16777216);
this.challengeBytes = String.format("\t%s%d\u0000", this.ident, this.challenge).getBytes(StandardCharsets.UTF_8);
}
diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java
index 19f77e377342ee461f0da8bc5378f2002fb9e94a..e6799eb40ec5e8c9f58aaafb7841a9066ac299c8 100644
--- a/src/main/java/net/minecraft/util/Mth.java
+++ b/src/main/java/net/minecraft/util/Mth.java
@@ -31,7 +31,7 @@ public class Mth {
}
});
- private static final Random RANDOM = new Random();
+ private static final Random RANDOM = new org.yatopiamc.yatopia.server.util.FastRandom();
public static float[] getSinTable() { return SIN; }
private static final int[] MULTIPLY_DE_BRUIJN_BIT_POSITION = new int[]{0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, 31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9};
private static final double ONE_SIXTH = 0.16666666666666666D;
@@ -758,7 +758,7 @@ public class Mth {
}
public static double wobble(double d) {
- return d + (2.0D * (new Random((long)floor(d * 3000.0D))).nextDouble() - 1.0D) * 1.0E-7D / 2.0D;
+ return d + (2.0D * (new org.yatopiamc.yatopia.server.util.FastRandom((long)floor(d * 3000.0D))).nextDouble() - 1.0D) * 1.0E-7D / 2.0D;
}
public static int roundToward(int value, int divisor) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index ed2a684deccedf85ffbee01baeaa922c71bfb435..762927080ac2201fd74519d24989092902d4c78d 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -158,7 +158,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, i
}
// Paper start
- public static Random SHARED_RANDOM = new Random() {
+ public static Random SHARED_RANDOM = new org.yatopiamc.yatopia.server.util.FastRandom() {
private boolean locked = false;
@Override
public synchronized void setSeed(long seed) {
diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
index 204ca4fbd89bdadd902529f1f191df46fce3cace..2b8cf6819c4a76fb558607f8d111f27e01781a15 100644
--- a/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
+++ b/src/main/java/net/minecraft/world/entity/ai/behavior/ShufflingList.java
@@ -13,7 +13,7 @@ import java.util.stream.Stream;
public class ShufflingList<U> {
public final List<ShufflingList.WeightedEntry<U>> entries; // Paper - public
- private final Random random = new Random();
+ private final Random random = new org.yatopiamc.yatopia.server.util.FastRandom();
private final boolean isUnsafe; // Paper
public ShufflingList() {
diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java
index f3b8e253a5bfc3f68121dbe656ae7e2ac0f0eb1c..325e7725f0105076c7f865db550cfd4e2866b8d2 100644
--- a/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java
+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/Sensor.java
@@ -8,7 +8,7 @@ import net.minecraft.world.entity.ai.memory.MemoryModuleType;
import net.minecraft.world.entity.ai.targeting.TargetingConditions;
public abstract class Sensor<E extends LivingEntity> {
- private static final Random RANDOM = new Random();
+ private static final Random RANDOM = new org.yatopiamc.yatopia.server.util.FastRandom();
private static final int DEFAULT_SCAN_RATE = 20;
protected static final int TARGETING_RANGE = 16;
private static final TargetingConditions TARGET_CONDITIONS = TargetingConditions.forNonCombat().range(16.0D);
diff --git a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
index f362e007aece208036a37d9bda8bb481a78eeaff..ae4e5258b92ff480f9c098a561160fe0595a7bbf 100644
--- a/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
+++ b/src/main/java/net/minecraft/world/entity/monster/piglin/PiglinAi.java
@@ -374,7 +374,7 @@ public class PiglinAi {
}
private static boolean wantsToDance(LivingEntity piglin, LivingEntity target) {
- return target.getType() != EntityType.HOGLIN ? false : (new Random(piglin.level.getGameTime())).nextFloat() < 0.1F;
+ return target.getType() != EntityType.HOGLIN ? false : (new org.yatopiamc.yatopia.server.util.FastRandom(piglin.level.getGameTime())).nextFloat() < 0.1F;
}
protected static boolean wantsToPickup(Piglin piglin, ItemStack stack) {
diff --git a/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java b/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
index 323eea2bccacfcc85849b5d82c2b30d991e0c0d8..78104373a57616fd38d96c727a4ee3b79d874316 100644
--- a/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
+++ b/src/main/java/net/minecraft/world/entity/npc/WanderingTraderSpawner.java
@@ -35,7 +35,7 @@ public class WanderingTraderSpawner implements CustomSpawner {
private static final int SPAWN_CHANCE_INCREASE = 25;
private static final int SPAWN_ONE_IN_X_CHANCE = 10;
private static final int NUMBER_OF_SPAWN_ATTEMPTS = 10;
- private final Random random = new Random();
+ private final Random random = new org.yatopiamc.yatopia.server.util.FastRandom();
private final ServerLevelData serverLevelData;
private int tickDelay;
private int spawnDelay;
diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
index 1037d0a0cdd4fd7aa99a958ee969759c5883fdc0..99ab7bf2829b1355de452a368ac9971dec04064c 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java
@@ -76,7 +76,7 @@ public class FishingHook extends Projectile {
private FishingHook(EntityType<? extends FishingHook> type, Level world, int lureLevel, int luckOfTheSeaLevel) {
super(type, world);
- this.syncronizedRandom = new Random();
+ this.syncronizedRandom = new org.yatopiamc.yatopia.server.util.FastRandom();
this.openWater = true;
this.currentState = FishingHook.FishHookState.FLYING;
this.noCulling = true;
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java
index 7131226de05bc57830f7a68ba545ebfd19d33a59..d41bdd71ae1f722b5f108bed9282bf5bde348e90 100644
--- a/src/main/java/net/minecraft/world/entity/raid/Raid.java
+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java
@@ -110,7 +110,7 @@ public class Raid {
public Raid(int id, ServerLevel world, BlockPos pos) {
this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10);
- this.random = new Random();
+ this.random = new org.yatopiamc.yatopia.server.util.FastRandom();
this.waveSpawnPos = Optional.empty();
this.id = id;
this.level = world;
@@ -124,7 +124,7 @@ public class Raid {
public Raid(ServerLevel world, CompoundTag nbt) {
this.raidEvent = new ServerBossEvent(Raid.RAID_NAME_COMPONENT, BossEvent.BossBarColor.RED, BossEvent.BossBarOverlay.NOTCHED_10);
- this.random = new Random();
+ this.random = new org.yatopiamc.yatopia.server.util.FastRandom();
this.waveSpawnPos = Optional.empty();
this.level = world;
this.id = nbt.getInt("Id");
diff --git a/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java b/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java
index d75f14e23d94deee2b6af20c8af3bcd42c1fbbc3..cac4584ea634e0461d05908cbfd88ef66ea75c4e 100644
--- a/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java
+++ b/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java
@@ -68,7 +68,7 @@ public class EnchantmentMenu extends AbstractContainerMenu {
}
// CraftBukkit end
};
- this.random = new Random();
+ this.random = new org.yatopiamc.yatopia.server.util.FastRandom();
this.enchantmentSeed = DataSlot.standalone();
this.costs = new int[3];
this.enchantClue = new int[]{-1, -1, -1};
diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java
index 03726227fdd60e9cf77213d50184abff438e01ef..2f38fd48dd3798b25758028c04e4ec9546166108 100644
--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java
+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java
@@ -41,7 +41,7 @@ public abstract class BaseSpawner {
public int maxNearbyEntities = 6;
public int requiredPlayerRange = 16;
public int spawnRange = 4;
- private final Random random = new Random();
+ private final Random random = new org.yatopiamc.yatopia.server.util.FastRandom();
private int tickDelay = 0; // Paper
public BaseSpawner() {}
diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java
index 6795132318a4e8b4c7a33b6f4b89a730ea66b97f..eebbf0b9d646ee5ae1bd48c821f122a7c4f4a0c6 100644
--- a/src/main/java/net/minecraft/world/level/Explosion.java
+++ b/src/main/java/net/minecraft/world/level/Explosion.java
@@ -88,7 +88,7 @@ public class Explosion {
}
public Explosion(Level world, @Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType) {
- this.random = new Random();
+ this.random = new org.yatopiamc.yatopia.server.util.FastRandom();
this.toBlow = Lists.newArrayList();
this.hitPlayers = Maps.newHashMap();
this.level = world;
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index a7262d842ff1684346302e10b08b1e7bc98f47a5..21e478f81401649a170bfd20505f8094aa97b591 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -124,13 +124,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
public final Thread thread;
private final boolean isDebug;
private int skyDarken;
- protected int randValue = (new Random()).nextInt();
+ protected int randValue = (new org.yatopiamc.yatopia.server.util.FastRandom()).nextInt();
protected final int addend = 1013904223;
protected float oRainLevel;
public float rainLevel;
protected float oThunderLevel;
public float thunderLevel;
- public final Random random = new Random();
+ public final Random random = new org.yatopiamc.yatopia.server.util.FastRandom();
private final DimensionType dimensionType;
public final WritableLevelData levelData;
private final Supplier<ProfilerFiller> profiler;
diff --git a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
index f74c5bb8e1ba42c77c59d481b871fd992483b128..610e2ec624516684007fb53bf084b95b4fcadc1d 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
@@ -21,7 +21,7 @@ import org.bukkit.entity.HumanEntity;
public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
- private static final Random RANDOM = new Random();
+ private static final Random RANDOM = new org.yatopiamc.yatopia.server.util.FastRandom();
public static final int CONTAINER_SIZE = 9;
private NonNullList<ItemStack> items;
diff --git a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
index bc028de0ac71e69e8d714db5f65286f306544bf1..6e911b9a2fbdb4495605f68bc465b1f9e2d80ea1 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/TheEndGatewayBlockEntity.java
@@ -265,7 +265,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity {
if (blockposition1 == null) {
blockposition1 = new BlockPos(vec3d.x + 0.5D, 75.0D, vec3d.z + 0.5D);
TheEndGatewayBlockEntity.LOGGER.debug("Failed to find a suitable block to teleport to, spawning an island on {}", blockposition1);
- EndFeatures.END_ISLAND.place(world, world.getChunkSource().getGenerator(), new Random(blockposition1.asLong()), blockposition1);
+ EndFeatures.END_ISLAND.place(world, world.getChunkSource().getGenerator(), new org.yatopiamc.yatopia.server.util.FastRandom(blockposition1.asLong()), blockposition1);
} else {
TheEndGatewayBlockEntity.LOGGER.debug("Found suitable block to teleport to: {}", blockposition1);
}
@@ -353,7 +353,7 @@ public class TheEndGatewayBlockEntity extends TheEndPortalBlockEntity {
}
private static void spawnGatewayPortal(ServerLevel world, BlockPos pos, EndGatewayConfiguration config) {
- Feature.END_GATEWAY.configured(config).place(world, world.getChunkSource().getGenerator(), new Random(), pos);
+ Feature.END_GATEWAY.configured(config).place(world, world.getChunkSource().getGenerator(), new org.yatopiamc.yatopia.server.util.FastRandom(), pos);
}
@Override
diff --git a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
index e4591c0b3c8547cc6f4e2a0891fc378ee4334d9e..f4f964a2ef28840944b11404cdc6e41684e46af3 100644
--- a/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
+++ b/src/main/java/net/minecraft/world/level/chunk/ChunkGenerator.java
@@ -109,7 +109,7 @@ public abstract class ChunkGenerator implements BiomeManager.NoiseBiomeSource {
int i = structuresettingsstronghold.distance();
int j = structuresettingsstronghold.count();
int k = structuresettingsstronghold.spread();
- Random random = new Random();
+ Random random = new org.yatopiamc.yatopia.server.util.FastRandom();
random.setSeed(this.strongholdSeed);
double d0 = random.nextDouble() * 3.141592653589793D * 2.0D;
diff --git a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
index be5952133720bf0ac3483cc2fed334967e6fc0c4..037b091bafd378493e35d2a816cfc59318362b4e 100644
--- a/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
+++ b/src/main/java/net/minecraft/world/level/dimension/end/EndDragonFight.java
@@ -124,7 +124,7 @@ public class EndDragonFight {
}
} else {
this.gateways.addAll(ContiguousSet.create(Range.closedOpen(0, 20), DiscreteDomain.integers()));
- Collections.shuffle(this.gateways, new Random(gatewaysSeed));
+ Collections.shuffle(this.gateways, new org.yatopiamc.yatopia.server.util.FastRandom(gatewaysSeed));
}
this.exitPortalPattern = BlockPatternBuilder.start().aisle(" ", " ", " ", " # ", " ", " ", " ").aisle(" ", " ", " ", " # ", " ", " ", " ").aisle(" ", " ", " ", " # ", " ", " ", " ").aisle(" ### ", " # # ", "# #", "# # #", "# #", " # # ", " ### ").aisle(" ", " ### ", " ##### ", " ##### ", " ##### ", " ### ", " ").where('#', BlockInWorld.hasState(BlockPredicate.forBlock(Blocks.BEDROCK))).build();
@@ -402,7 +402,7 @@ public class EndDragonFight {
private void spawnNewGateway(BlockPos pos) {
this.level.levelEvent(3000, pos, 0);
- EndFeatures.END_GATEWAY_DELAYED.place(this.level, this.level.getChunkSource().getGenerator(), new Random(), pos);
+ EndFeatures.END_GATEWAY_DELAYED.place(this.level, this.level.getChunkSource().getGenerator(), new org.yatopiamc.yatopia.server.util.FastRandom(), pos);
}
public void spawnExitPortal(boolean previouslyKilled) {
@@ -418,7 +418,7 @@ public class EndDragonFight {
}
// Paper end
- endPodiumFeature.configured(FeatureConfiguration.NONE).place(this.level, this.level.getChunkSource().getGenerator(), new Random(), this.portalLocation);
+ endPodiumFeature.configured(FeatureConfiguration.NONE).place(this.level, this.level.getChunkSource().getGenerator(), new org.yatopiamc.yatopia.server.util.FastRandom(), this.portalLocation);
}
private EnderDragon createNewDragon() {
diff --git a/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java b/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java
index 286c75989282c6d370ca64ac714ab15d784210ab..e3a2919e214c63aa8cc2334d30dade3daf39b92d 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/WorldGenSettings.java
@@ -86,7 +86,7 @@ public class WorldGenSettings {
}
public static WorldGenSettings makeDefault(RegistryAccess registryManager) {
- long i = (new Random()).nextLong();
+ long i = (new org.yatopiamc.yatopia.server.util.FastRandom()).nextLong();
return new WorldGenSettings(i, true, false, WorldGenSettings.withOverworld(registryManager.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY), DimensionType.defaultDimensions(registryManager, i), WorldGenSettings.makeDefaultOverworld(registryManager, i)));
}
@@ -215,7 +215,7 @@ public class WorldGenSettings {
}).orElse("default");
properties.put("level-type", s4);
- long i = (new Random()).nextLong();
+ long i = (new org.yatopiamc.yatopia.server.util.FastRandom()).nextLong();
if (!s1.isEmpty()) {
try {
diff --git a/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java b/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
index c03bf5bdb67b00c75f9fcfead882c4d944282244..300c994cd3cc0995eeb4914590afce8b6ad1d92b 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/feature/SpikeFeature.java
@@ -36,7 +36,7 @@ public class SpikeFeature extends Feature<SpikeConfiguration> {
}
public static List<SpikeFeature.EndSpike> getSpikesForLevel(WorldGenLevel world) {
- Random random = new Random(world.getSeed());
+ Random random = new org.yatopiamc.yatopia.server.util.FastRandom(world.getSeed());
long l = random.nextLong() & 65535L;
return SPIKE_CACHE.getUnchecked(l);
}
@@ -167,7 +167,7 @@ public class SpikeFeature extends Feature<SpikeConfiguration> {
@Override
public List<SpikeFeature.EndSpike> load(Long long_) {
List<Integer> list = IntStream.range(0, 10).boxed().collect(Collectors.toList());
- Collections.shuffle(list, new Random(long_));
+ Collections.shuffle(list, new org.yatopiamc.yatopia.server.util.FastRandom(long_));
List<SpikeFeature.EndSpike> list2 = Lists.newArrayList();
for(int i = 0; i < 10; ++i) {
diff --git a/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java b/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java
index c75141f96bdbee9ec070e81bd4f1ce0e7f1054fa..dbd46f0467f402fdde61831b49b4b7c1ba2d3af1 100644
--- a/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java
+++ b/src/main/java/net/minecraft/world/level/levelgen/structure/templatesystem/StructurePlaceSettings.java
@@ -120,7 +120,7 @@ public class StructurePlaceSettings {
}
public Random getRandom(@Nullable BlockPos pos) {
- return this.random != null ? this.random : (pos == null ? new Random(Util.getMillis()) : new Random(Mth.getSeed(pos)));
+ return this.random != null ? this.random : (pos == null ? new org.yatopiamc.yatopia.server.util.FastRandom(Util.getMillis()) : new org.yatopiamc.yatopia.server.util.FastRandom(Mth.getSeed(pos)));
}
public boolean isIgnoreEntities() {
diff --git a/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java b/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java
index d33af84300db18ea2b71dba2c9ed43390a293500..14ef922c3f8d8f0867614fb0fd1faee73319a993 100644
--- a/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java
+++ b/src/main/java/net/minecraft/world/level/storage/loot/LootContext.java
@@ -127,7 +127,7 @@ public class LootContext {
public LootContext.Builder withOptionalRandomSeed(long seed) {
if (seed != 0L) {
- this.random = new Random(seed);
+ this.random = new org.yatopiamc.yatopia.server.util.FastRandom(seed);
}
return this;
@@ -137,7 +137,7 @@ public class LootContext {
if (seed == 0L) {
this.random = random;
} else {
- this.random = new Random(seed);
+ this.random = new org.yatopiamc.yatopia.server.util.FastRandom(seed);
}
return this;
@@ -201,7 +201,7 @@ public class LootContext {
} else {
Random random = this.random;
if (random == null) {
- random = new Random();
+ random = new org.yatopiamc.yatopia.server.util.FastRandom();
}
MinecraftServer minecraftServer = this.level.getServer();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index e8b256c947f7638496fdc8dd29b88298e3e003eb..5ac260b44c97e82f4cd0436750fb5ff19d32a128 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -1216,7 +1216,7 @@ public final class CraftServer implements Server {
if (worlddimension == null) {
dimensionmanager = (DimensionType) console.registryHolder.registryOrThrow(Registry.DIMENSION_TYPE_REGISTRY).getOrThrow(DimensionType.OVERWORLD_LOCATION);
- chunkgenerator = WorldGenSettings.makeDefaultOverworld(console.registryHolder, (new Random()).nextLong());
+ chunkgenerator = WorldGenSettings.makeDefaultOverworld(console.registryHolder, (new org.yatopiamc.yatopia.server.util.FastRandom()).nextLong());
} else {
dimensionmanager = worlddimension.type();
chunkgenerator = worlddimension.generator();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
index ac41bc23d2f7e16bbacdc9b33fcf6c0d706fa023..5520b78f182e9e3281b12d6a2f93ce171e4b1151 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java
@@ -204,7 +204,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
}
// Paper end
- private static final Random rand = new Random();
+ private static final Random rand = new org.yatopiamc.yatopia.server.util.FastRandom();
public CraftWorld(ServerLevel world, ChunkGenerator gen, BiomeProvider biomeProvider, Environment env) {
this.world = world;
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
index be86114eac3975b82ca74d4d6ed3f0402a642e8a..e369d3a67c375e39c9ca58b44b71ab3963943c1f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFirework.java
@@ -13,7 +13,7 @@ import org.bukkit.inventory.meta.FireworkMeta;
public class CraftFirework extends CraftProjectile implements Firework {
- private final Random random = new Random();
+ private final Random random = new org.yatopiamc.yatopia.server.util.FastRandom();
private final CraftItemStack item;
public CraftFirework(CraftServer server, FireworkRocketEntity entity) {
diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
index 1209e99bf297ba15e2022635a538d441a2be3fe4..faa63c302d41dd4759c991995e0e75b86501181e 100644
--- a/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
+++ b/src/main/java/org/bukkit/craftbukkit/generator/CustomChunkGenerator.java
@@ -44,7 +44,7 @@ public class CustomChunkGenerator extends InternalChunkGenerator {
public final net.minecraft.world.level.chunk.ChunkGenerator delegate;
private final ChunkGenerator generator;
private final ServerLevel world;
- private final Random random = new Random();
+ private final Random random = new org.yatopiamc.yatopia.server.util.FastRandom();
private boolean newApi;
private boolean implementBaseHeight = true;

View File

@@ -0,0 +1,35 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Etil <81570777+etil2jz@users.noreply.github.com>
Date: Thu, 9 Dec 2021 15:39:29 +0100
Subject: [PATCH] Configurable max bees in hive
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
index 9fcd835d219aafbe113ebb1b796052e07bf2b046..5d04fedb428d5bfd59bfc47ace42006be3f58737 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java
@@ -43,7 +43,7 @@ public class BeehiveBlockEntity extends BlockEntity {
private final List<BeehiveBlockEntity.BeeData> stored = Lists.newArrayList();
@Nullable
public BlockPos savedFlowerPos;
- public int maxBees = 3; // CraftBukkit - allow setting max amount of bees a hive can hold
+ public int maxBees = wtf.etil.mirai.MiraiConfig.maxBees; // CraftBukkit - allow setting max amount of bees a hive can hold // Mirai - configurable max bees in hive
public BeehiveBlockEntity(BlockPos pos, BlockState state) {
super(BlockEntityType.BEEHIVE, pos, state);
diff --git a/src/main/java/wtf/etil/mirai/MiraiConfig.java b/src/main/java/wtf/etil/mirai/MiraiConfig.java
index 9f775115d5120d3fc514d9c0cea98272feecbb49..458d7aedfd8279f0e581415f350e867672718027 100644
--- a/src/main/java/wtf/etil/mirai/MiraiConfig.java
+++ b/src/main/java/wtf/etil/mirai/MiraiConfig.java
@@ -194,6 +194,9 @@ public class MiraiConfig {
logPlayerLoginLoc = getBoolean("log-player-login-location", logPlayerLoginLoc);
}
-
+ public static int maxBees = 3;
+ private static void maximumBees() {
+ maxBees = getInt("max-bees-in-hive", maxBees);
+ }
}
\ No newline at end of file