mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-19 15:09:25 +00:00
Some work
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Blast-MC <cjblanton2@gmail.com>
|
||||
Date: Thu, 25 Aug 2022 20:32:01 -0400
|
||||
Subject: [PATCH] Parchment: Make FixLight use action bar
|
||||
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/ProjectEdenGG/Parchment
|
||||
|
||||
diff --git a/io/papermc/paper/command/subcommands/FixLightCommand.java b/io/papermc/paper/command/subcommands/FixLightCommand.java
|
||||
index 85950a1aa732ab8c01ad28bec9e0de140e1a172e..8e8d1a38290c2dc3f88deda64d050e89273a5b89 100644
|
||||
--- a/io/papermc/paper/command/subcommands/FixLightCommand.java
|
||||
+++ b/io/papermc/paper/command/subcommands/FixLightCommand.java
|
||||
@@ -95,17 +95,20 @@ public final class FixLightCommand implements PaperSubcommand {
|
||||
((StarLightLightingProvider)lightengine).starlight$serverRelightChunks(chunks,
|
||||
(final ChunkPos chunkPos) -> {
|
||||
++relitChunks[0];
|
||||
- sender.getBukkitEntity().sendMessage(text().color(DARK_AQUA).append(
|
||||
- text("Relit chunk ", BLUE), text(chunkPos.toString()),
|
||||
- text(", progress: ", BLUE), text(ONE_DECIMAL_PLACES.get().format(100.0 * (double) (relitChunks[0]) / (double) pending[0]) + "%")
|
||||
- ));
|
||||
+ sender.getBukkitEntity().sendActionBar(text().color(DARK_AQUA).append(
|
||||
+ text("Relighting Chunks: ", DARK_AQUA), text(chunkPos.toString()),
|
||||
+ text(" " + relitChunks[0], net.kyori.adventure.text.format.NamedTextColor.YELLOW),
|
||||
+ text("/", DARK_AQUA),
|
||||
+ text(pending[0] + " ", net.kyori.adventure.text.format.NamedTextColor.YELLOW),
|
||||
+ text("(" + ONE_DECIMAL_PLACES.get().format(100.0 * (double) (relitChunks[0]) / (double) pending[0]) + "%)", net.kyori.adventure.text.format.NamedTextColor.YELLOW)
|
||||
+ )); // Leaf - Parchment - Make FixLight use action bar
|
||||
},
|
||||
(final int totalRelit) -> {
|
||||
final long end = System.nanoTime();
|
||||
sender.getBukkitEntity().sendMessage(text().color(DARK_AQUA).append(
|
||||
- text("Relit ", BLUE), text(totalRelit),
|
||||
- text(" chunks. Took ", BLUE), text(ONE_DECIMAL_PLACES.get().format(1.0e-6 * (end - start)) + "ms")
|
||||
- ));
|
||||
+ text("Relit ", DARK_AQUA), text(totalRelit, net.kyori.adventure.text.format.NamedTextColor.YELLOW),
|
||||
+ text(" chunks. Took ", DARK_AQUA), text(ONE_DECIMAL_PLACES.get().format(1.0e-6 * (end - start)) + "ms", net.kyori.adventure.text.format.NamedTextColor.YELLOW)
|
||||
+ )); // Leaf - Parchment - Make FixLight use action bar
|
||||
if (done != null) {
|
||||
done.run();
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||
Date: Wed, 15 Nov 2023 23:39:36 -0300
|
||||
Subject: [PATCH] SparklyPaper: Skip "distanceToSqr" call in
|
||||
"ServerEntity#sendChanges" if the delta movement hasn't changed
|
||||
|
||||
Original project: https://github.com/SparklyPower/SparklyPaper
|
||||
|
||||
The "distanceToSqr" call is a bit expensive, so avoiding it is pretty nice, around ~15% calls are skipped with this check
|
||||
|
||||
We could also check if the x,y,z coordinates are equal, but for now, let's just keep the identity check, which also helps us since Minecraft's code does reuse the original delta movement Vec3 object
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java
|
||||
index d985555a029d06ffc73dd10115df47b83c9afafd..ddf2a5e2cfeaa666a081dd857d6a6003d65d0e00 100644
|
||||
--- a/net/minecraft/server/level/ServerEntity.java
|
||||
+++ b/net/minecraft/server/level/ServerEntity.java
|
||||
@@ -201,6 +201,7 @@ public class ServerEntity {
|
||||
|
||||
if (this.entity.hasImpulse || this.trackDelta || this.entity instanceof LivingEntity && ((LivingEntity)this.entity).isFallFlying()) {
|
||||
Vec3 deltaMovement = this.entity.getDeltaMovement();
|
||||
+ if (deltaMovement != this.lastSentMovement) { // SparklyPaper start - skip distanceToSqr call in ServerEntity#sendChanges if the delta movement hasn't changed
|
||||
double d = deltaMovement.distanceToSqr(this.lastSentMovement);
|
||||
if (d > 1.0E-7 || d > 0.0 && deltaMovement.lengthSqr() == 0.0) {
|
||||
this.lastSentMovement = deltaMovement;
|
||||
@@ -218,6 +219,7 @@ public class ServerEntity {
|
||||
this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement));
|
||||
}
|
||||
}
|
||||
+ } // SparklyPaper end
|
||||
}
|
||||
|
||||
if (packet != null) {
|
||||
@@ -1,25 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||
Date: Fri, 17 Nov 2023 14:22:41 -0300
|
||||
Subject: [PATCH] SparklyPaper: Skip "MapItem#update()" if the map does not
|
||||
have the CraftMapRenderer present
|
||||
|
||||
Original project: https://github.com/SparklyPower/SparklyPaper
|
||||
|
||||
Optimizes "image in map" maps, without requiring the map to be locked, which some old map plugins may not do
|
||||
|
||||
This has the disadvantage that the vanilla map data will never be updated while the CraftMapRenderer is not present, but that's not a huuuge problem for u
|
||||
|
||||
diff --git a/net/minecraft/world/item/MapItem.java b/net/minecraft/world/item/MapItem.java
|
||||
index 309392d414ecbe60474abd0af534184740951707..fd8418fc1487b0669907569142955887257f81c0 100644
|
||||
--- a/net/minecraft/world/item/MapItem.java
|
||||
+++ b/net/minecraft/world/item/MapItem.java
|
||||
@@ -278,7 +278,7 @@ public class MapItem extends Item {
|
||||
savedData.tickCarriedBy(player, stack);
|
||||
}
|
||||
|
||||
- if (!savedData.locked && (isSelected || entity instanceof Player && ((Player)entity).getOffhandItem() == stack)) {
|
||||
+ if (!savedData.locked && (!org.dreeam.leaf.config.modules.opt.SkipMapItemDataUpdates.enabled || savedData.mapView.getRenderers().stream().anyMatch(mapRenderer -> mapRenderer.getClass() == org.bukkit.craftbukkit.map.CraftMapRenderer.class)) && (isSelected || entity instanceof Player && ((Player)entity).getOffhandItem() == stack)) { // SparklyPaper - don't update maps if they don't have the CraftMapRenderer in the render list
|
||||
this.update(level, entity, savedData);
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||
Date: Sun, 19 Nov 2023 12:35:16 -0300
|
||||
Subject: [PATCH] SparklyPaper: Skip EntityScheduler's executeTick checks if
|
||||
there isn't any tasks to be run
|
||||
|
||||
Original project: https://github.com/SparklyPower/SparklyPaper
|
||||
|
||||
On each tick, Paper runs EntityScheduler's executeTick of each entity. This is a bit expensive, due to ArrayDeque's size() call because it ain't a simple "get the current queue size" function, due to the thread checks, and because it needs to iterate all entities in all worlds.
|
||||
|
||||
To avoid the hefty ArrayDeque's size() call, we check if we *really* need to execute the executeTick, by adding all entities with scheduled tasks to a global set.
|
||||
|
||||
Most entities won't have any scheduled tasks, so this is a nice performance bonus. These optimizations, however, wouldn't work in a Folia environment, but because in SparklyPaper executeTick is always executed on the main thread, it ain't an issue for us (yay).
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 30747b30596208bc02dfb4a6c31f8afb5c1aba8e..ed8d4f54ea49123cd60eda4fec4d0612e1478c38 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -290,6 +290,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
|
||||
protected boolean upnp = false; // Purpur - UPnP Port Forwarding
|
||||
public gg.pufferfish.pufferfish.util.AsyncExecutor mobSpawnExecutor = new gg.pufferfish.pufferfish.util.AsyncExecutor("Leaf Async Mob Spawn Thread"); // Pufferfish - optimize mob spawning // Leaf - Fix Pufferfish and Purpur patches - Unify thread name
|
||||
+ public final Set<net.minecraft.world.entity.Entity> entitiesWithScheduledTasks = java.util.concurrent.ConcurrentHashMap.newKeySet(); // SparklyPaper - skip EntityScheduler's executeTick checks if there isn't any tasks to be run (concurrent because plugins may schedule tasks async)
|
||||
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) {
|
||||
ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system
|
||||
@@ -1674,6 +1675,22 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
this.server.getScheduler().mainThreadHeartbeat(); // CraftBukkit
|
||||
// Paper start - Folia scheduler API
|
||||
((io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler) org.bukkit.Bukkit.getGlobalRegionScheduler()).tick();
|
||||
+ // SparklyPaper - skip EntityScheduler's executeTick checks if there isn't any tasks to be run
|
||||
+ for (final net.minecraft.world.entity.Entity entity : entitiesWithScheduledTasks) {
|
||||
+ if (entity.isRemoved()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ final org.bukkit.craftbukkit.entity.CraftEntity bukkit = entity.getBukkitEntityRaw();
|
||||
+ if (bukkit != null) {
|
||||
+ io.papermc.paper.threadedregions.EntityScheduler scheduler = bukkit.taskScheduler;
|
||||
+ scheduler.executeTick();
|
||||
+ if (!scheduler.hasTasks()) {
|
||||
+ this.entitiesWithScheduledTasks.remove(entity);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ /*
|
||||
getAllLevels().forEach(level -> {
|
||||
for (final net.minecraft.world.entity.Entity entity : level.getEntities().getAll()) {
|
||||
if (entity.isRemoved()) {
|
||||
@@ -1685,6 +1702,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
}
|
||||
});
|
||||
+ */
|
||||
+ // SparklyPaper end
|
||||
// Paper end - Folia scheduler API
|
||||
io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.CALLBACK_MANAGER.handleQueue(this.tickCount); // Paper
|
||||
this.getFunctions().tick();
|
||||
@@ -1,30 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||
Date: Thu, 23 Nov 2023 14:36:47 -0300
|
||||
Subject: [PATCH] SparklyPaper: Optimize "canSee" checks
|
||||
|
||||
Original project: https://github.com/SparklyPower/SparklyPaper
|
||||
|
||||
The "canSee" checks is in a hot path, invoked by each entity for each player on the server if they are in tracking range, so optimizing it is pretty nice
|
||||
|
||||
First, we change the original "HashMap" to fastutil's "Object2ObjectOpenHashMap", because the containsKey throughput is better
|
||||
|
||||
Then, we add a "isEmpty()" check before attempting to check if the map contains something
|
||||
|
||||
This seems stupid, but it does seem that it improves the performance a bit, and it makes sense, "containsKey(...)" does not attempt to check the map size before attempting to check if the map contains the key
|
||||
|
||||
We also create a "canSee" method tailored for "ChunkMap#updatePlayer()", a method without the equals check (the "updatePlayer()" already checks if the entity is the same entity) because the CraftPlayer's `equals()` check is a *bit* expensive compared to only checking the object's identity, and because the identity has already been check, we don't need to check it twice.
|
||||
|
||||
diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java
|
||||
index 6a9fdb6329f177aca1274336a8e5be70ca3ce931..5d9d233e3a568aa6297ed9c703fa450f98158602 100644
|
||||
--- a/net/minecraft/server/level/ChunkMap.java
|
||||
+++ b/net/minecraft/server/level/ChunkMap.java
|
||||
@@ -1225,7 +1225,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider
|
||||
flag = flag && this.entity.broadcastToPlayer(player) && ChunkMap.this.isChunkTracked(player, this.entity.chunkPosition().x, this.entity.chunkPosition().z);
|
||||
// Paper end - Configurable entity tracking range by Y
|
||||
// CraftBukkit start - respect vanish API
|
||||
- if (flag && !player.getBukkitEntity().canSee(this.entity.getBukkitEntity())) { // Paper - only consider hits
|
||||
+ if (flag && !player.getBukkitEntity().canSeeChunkMapUpdatePlayer(this.entity.getBukkitEntity())) { // Paper - only consider hits // SparklyPaper - optimize canSee checks
|
||||
flag = false;
|
||||
}
|
||||
// CraftBukkit end
|
||||
@@ -1,24 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: MrPowerGamerBR <git@mrpowergamerbr.com>
|
||||
Date: Fri, 23 Aug 2024 16:20:45 -0300
|
||||
Subject: [PATCH] SparklyPaper: Allow throttling hopper checks if the target
|
||||
container is full
|
||||
|
||||
Original project: https://github.com/SparklyPower/SparklyPaper
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
index 2549dd08b60cd81dcbf3412ed71cfc40729ae468..fe1dba198fced6f23556d95ba2f8fbc9200d878a 100644
|
||||
--- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
+++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java
|
||||
@@ -419,6 +419,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen
|
||||
} else {
|
||||
Direction opposite = blockEntity.facing.getOpposite();
|
||||
if (isFullContainer(attachedContainer, opposite)) {
|
||||
+ // Leaf start - SparklyPaper - Throttle hopper when full
|
||||
+ if (org.dreeam.leaf.config.modules.opt.ThrottleHopperWhenFull.enabled && org.dreeam.leaf.config.modules.opt.ThrottleHopperWhenFull.skipTicks > 0) {
|
||||
+ blockEntity.setCooldown(org.dreeam.leaf.config.modules.opt.ThrottleHopperWhenFull.skipTicks);
|
||||
+ }
|
||||
+ // Leaf end - SparklyPaper - Throttle hopper when full
|
||||
return false;
|
||||
} else {
|
||||
// Paper start - Perf: Optimize Hoppers
|
||||
@@ -1,43 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: lilingfengdev <145678359+lilingfengdev@users.noreply.github.com>
|
||||
Date: Thu, 18 Jan 2024 13:30:02 +0800
|
||||
Subject: [PATCH] Polpot: Make egg and snowball can knockback player
|
||||
|
||||
Original project: https://github.com/HaHaWTH/Polpot
|
||||
|
||||
diff --git a/net/minecraft/world/entity/projectile/Snowball.java b/net/minecraft/world/entity/projectile/Snowball.java
|
||||
index 1d399532c67c213c95c06837b0c7855384f1a25c..16fc473415872a626c130c90b1fc76c41a6b2856 100644
|
||||
--- a/net/minecraft/world/entity/projectile/Snowball.java
|
||||
+++ b/net/minecraft/world/entity/projectile/Snowball.java
|
||||
@@ -54,6 +54,12 @@ public class Snowball extends ThrowableItemProjectile {
|
||||
Entity entity = result.getEntity();
|
||||
int i = entity.level().purpurConfig.snowballDamage >= 0 ? entity.level().purpurConfig.snowballDamage : entity instanceof Blaze ? 3 : 0; // Purpur - Add configurable snowball damage
|
||||
entity.hurt(this.damageSources().thrown(this, this.getOwner()), i);
|
||||
+ // Leaf start - Polpot - Make snowball can knockback player
|
||||
+ if (org.dreeam.leaf.config.modules.gameplay.Knockback.snowballCanKnockback && entity instanceof net.minecraft.server.level.ServerPlayer serverPlayer) {
|
||||
+ entity.hurt(this.damageSources().thrown(this, this.getOwner()), 0.0000001F);
|
||||
+ serverPlayer.knockback(0.4000000059604645D, this.getX() - entity.getX(), this.getZ() - entity.getZ());
|
||||
+ }
|
||||
+ // Leaf end - Polpot - Make snowball can knockback player
|
||||
}
|
||||
|
||||
// Purpur start - options to extinguish fire blocks with snowballs - borrowed and modified code from ThrownPotion#onHitBlock and ThrownPotion#dowseFire
|
||||
diff --git a/net/minecraft/world/entity/projectile/ThrownEgg.java b/net/minecraft/world/entity/projectile/ThrownEgg.java
|
||||
index 76481c0e77fc3a2e4be8eeb9de8d1e6de5507c64..46628c2cc23488b921f5ce1fa787712c996d9e21 100644
|
||||
--- a/net/minecraft/world/entity/projectile/ThrownEgg.java
|
||||
+++ b/net/minecraft/world/entity/projectile/ThrownEgg.java
|
||||
@@ -52,7 +52,14 @@ public class ThrownEgg extends ThrowableItemProjectile {
|
||||
@Override
|
||||
protected void onHitEntity(EntityHitResult result) {
|
||||
super.onHitEntity(result);
|
||||
+ net.minecraft.world.entity.Entity entity = result.getEntity(); // Polpot - make egg can knockback player
|
||||
result.getEntity().hurt(this.damageSources().thrown(this, this.getOwner()), 0.0F);
|
||||
+ // Leaf start - Polpot - Make egg can knockback player
|
||||
+ if (org.dreeam.leaf.config.modules.gameplay.Knockback.eggCanKnockback && entity instanceof net.minecraft.server.level.ServerPlayer serverPlayer) {
|
||||
+ entity.hurt(this.damageSources().thrown(this, this.getOwner()), 0.0000001F);
|
||||
+ serverPlayer.knockback(0.4000000059604645D, this.getX() - entity.getX(), this.getZ() - entity.getZ());
|
||||
+ }
|
||||
+ // Leaf end - Polpot - Make egg can knockback player
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,23 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Mon, 19 Feb 2024 13:10:16 -0500
|
||||
Subject: [PATCH] Redirect vanilla getProfiler to inactive in
|
||||
PathNavigationRegion
|
||||
|
||||
To fix compatibility with some plugins, e.g. Citizens, ModelEngine, etc.
|
||||
|
||||
diff --git a/net/minecraft/world/level/PathNavigationRegion.java b/net/minecraft/world/level/PathNavigationRegion.java
|
||||
index 97a1cb8f30eb1668b1054912789bd100b96bee18..89b293acd22c3f9b324b30d9b1919a8765b11fe7 100644
|
||||
--- a/net/minecraft/world/level/PathNavigationRegion.java
|
||||
+++ b/net/minecraft/world/level/PathNavigationRegion.java
|
||||
@@ -150,4 +150,10 @@ public class PathNavigationRegion implements CollisionGetter {
|
||||
public int getHeight() {
|
||||
return this.level.getHeight();
|
||||
}
|
||||
+
|
||||
+ // Leaf start - Redirect vanilla getProfiler to inactive in PathNavigationRegion
|
||||
+ public net.minecraft.util.profiling.ProfilerFiller getProfiler() {
|
||||
+ return net.minecraft.util.profiling.InactiveProfiler.INSTANCE; // Gale - Purpur - remove vanilla profiler
|
||||
+ }
|
||||
+ // Leaf end - Redirect vanilla getProfiler to inactive in PathNavigationRegion
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Tue, 27 Feb 2024 03:17:10 -0500
|
||||
Subject: [PATCH] Remove useless creating stats json bases on player name logic
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||
index 4c172e2aee3e48d42009cd39b28f694aa71e20e3..386423589443051b8c461926c570352dd612a051 100644
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -1561,6 +1561,8 @@ public abstract class PlayerList {
|
||||
if (serverStatsCounter == null) {
|
||||
File file = this.server.getWorldPath(LevelResource.PLAYER_STATS_DIR).toFile();
|
||||
File file1 = new File(file, uuid + ".json");
|
||||
+ // Leaf start - Remove useless creating stats json bases on player name logic
|
||||
+ /*
|
||||
if (!file1.exists()) {
|
||||
File file2 = new File(file, displayName + ".json"); // CraftBukkit
|
||||
Path path = file2.toPath();
|
||||
@@ -1568,6 +1570,8 @@ public abstract class PlayerList {
|
||||
file2.renameTo(file1);
|
||||
}
|
||||
}
|
||||
+ */
|
||||
+ // Leaf end - Remove useless creating stats json bases on player name logic
|
||||
|
||||
serverStatsCounter = new ServerStatsCounter(this.server, file1);
|
||||
// this.stats.put(uuid, serverStatsCounter); // CraftBukkit
|
||||
@@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Fri, 25 Oct 2024 02:27:21 +0800
|
||||
Subject: [PATCH] Virtual thread for chat executor
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index ed8d4f54ea49123cd60eda4fec4d0612e1478c38..5a0d30b8ff5e377224de67c9f464bd1c694a4397 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -2678,7 +2678,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
}
|
||||
|
||||
public final java.util.concurrent.ExecutorService chatExecutor = java.util.concurrent.Executors.newCachedThreadPool(
|
||||
- new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build()); // Paper
|
||||
+ new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").setThreadFactory(org.dreeam.leaf.config.modules.opt.VT4ChatExecutor.enabled ? Thread.ofVirtual().factory() : java.util.concurrent.Executors.defaultThreadFactory()).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build()); // Paper // Leaf - Virtual thread for chat executor
|
||||
public final ChatDecorator improvedChatDecorator = new io.papermc.paper.adventure.ImprovedChatDecorator(this); // Paper - adventure
|
||||
|
||||
public ChatDecorator getChatDecorator() {
|
||||
@@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Tue, 31 Dec 2024 00:00:00 -0800
|
||||
Subject: [PATCH] Virtual thread for user authenticator
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
index 4567067bd91000bb98052cd5a139292e4615b13f..069477e524a28b20a0289221858bdc802704a890 100644
|
||||
--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -55,7 +55,7 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
// CraftBukkit end
|
||||
private static final AtomicInteger UNIQUE_THREAD_ID = new AtomicInteger(0);
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
- private static final java.util.concurrent.ExecutorService authenticatorPool = java.util.concurrent.Executors.newCachedThreadPool(new com.google.common.util.concurrent.ThreadFactoryBuilder().setNameFormat("User Authenticator #%d").setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)).build()); // Paper - Cache authenticator threads
|
||||
+ private static final java.util.concurrent.ExecutorService authenticatorPool = java.util.concurrent.Executors.newCachedThreadPool(new com.google.common.util.concurrent.ThreadFactoryBuilder().setNameFormat("User Authenticator #%d").setThreadFactory(org.dreeam.leaf.config.modules.opt.VT4UserAuthenticator.enabled ? Thread.ofVirtual().factory() : java.util.concurrent.Executors.defaultThreadFactory()).setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER)).build()); // Paper - Cache authenticator threads // Leaf - Virtual thread for user authenticator
|
||||
private static final int MAX_TICKS_BEFORE_LOGIN = 600;
|
||||
private final byte[] challenge;
|
||||
final MinecraftServer server;
|
||||
@@ -1,160 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: etil2jz <81570777+etil2jz@users.noreply.github.com>
|
||||
Date: Tue, 2 Aug 2022 14:48:12 +0200
|
||||
Subject: [PATCH] Mirai: Configurable chat message signatures
|
||||
|
||||
Fixed & Updated by Dreeam-qwq
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/Dreeam-qwq/Mirai
|
||||
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/etil2jz/Mirai
|
||||
|
||||
diff --git a/net/minecraft/network/FriendlyByteBuf.java b/net/minecraft/network/FriendlyByteBuf.java
|
||||
index d1daa3443446f47e2215f0c7c5823da58e053bab..abb0141426fd716e79a947b9498a8351daa342fc 100644
|
||||
--- a/net/minecraft/network/FriendlyByteBuf.java
|
||||
+++ b/net/minecraft/network/FriendlyByteBuf.java
|
||||
@@ -118,6 +118,17 @@ public class FriendlyByteBuf extends ByteBuf {
|
||||
public <T> void writeJsonWithCodec(Codec<T> codec, T value, int maxLength) {
|
||||
// Paper end - Adventure; add max length parameter
|
||||
DataResult<JsonElement> dataResult = codec.encodeStart(JsonOps.INSTANCE, value);
|
||||
+ // Leaf start - Configurable chat message signatures
|
||||
+ if (!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled && codec == net.minecraft.network.protocol.status.ServerStatus.CODEC) {
|
||||
+ JsonElement element = dataResult.getOrThrow(string -> new EncoderException("Failed to encode: " + string + " " + value));
|
||||
+
|
||||
+ element.getAsJsonObject().addProperty("preventsChatReports", true);
|
||||
+ this.writeUtf(GSON.toJson(element));
|
||||
+
|
||||
+ return;
|
||||
+ }
|
||||
+ // Leaf end - Configurable chat message signatures
|
||||
+
|
||||
this.writeUtf(GSON.toJson(dataResult.getOrThrow(exception -> new EncoderException("Failed to encode: " + exception + " " + value))), maxLength); // Paper - Adventure; add max length parameter
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/network/protocol/game/ClientboundLoginPacket.java b/net/minecraft/network/protocol/game/ClientboundLoginPacket.java
|
||||
index 89f06581e2b1f9f0240e7841db2f57dedc5d81b7..ba4ec05a9c9dfa958fdfa4a68ee85bcd9c379883 100644
|
||||
--- a/net/minecraft/network/protocol/game/ClientboundLoginPacket.java
|
||||
+++ b/net/minecraft/network/protocol/game/ClientboundLoginPacket.java
|
||||
@@ -55,7 +55,7 @@ public record ClientboundLoginPacket(
|
||||
buffer.writeBoolean(this.showDeathScreen);
|
||||
buffer.writeBoolean(this.doLimitedCrafting);
|
||||
this.commonPlayerSpawnInfo.write(buffer);
|
||||
- buffer.writeBoolean(this.enforcesSecureChat);
|
||||
+ buffer.writeBoolean(!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled || this.enforcesSecureChat); // Leaf - Mirai - Configurable chat message signatures
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/net/minecraft/network/protocol/game/ServerboundChatPacket.java b/net/minecraft/network/protocol/game/ServerboundChatPacket.java
|
||||
index b5afc05924ae899e020c303c8b86398e1d4ab8a0..73c2ed488c34cddbafdcbb6f2636264ebcc7286b 100644
|
||||
--- a/net/minecraft/network/protocol/game/ServerboundChatPacket.java
|
||||
+++ b/net/minecraft/network/protocol/game/ServerboundChatPacket.java
|
||||
@@ -23,7 +23,7 @@ public record ServerboundChatPacket(String message, Instant timeStamp, long salt
|
||||
buffer.writeUtf(this.message, 256);
|
||||
buffer.writeInstant(this.timeStamp);
|
||||
buffer.writeLong(this.salt);
|
||||
- buffer.writeNullable(this.signature, MessageSignature::write);
|
||||
+ if (org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled) buffer.writeNullable(this.signature, MessageSignature::write); // Leaf - Mirai - Configurable chat message signatures
|
||||
this.lastSeenMessages.write(buffer);
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/network/protocol/status/ServerStatus.java b/net/minecraft/network/protocol/status/ServerStatus.java
|
||||
index 30bd254542d631676494f349ff3f44f52d54ab2f..63e6411d8bac1629e143cc620fe35dbac39346e9 100644
|
||||
--- a/net/minecraft/network/protocol/status/ServerStatus.java
|
||||
+++ b/net/minecraft/network/protocol/status/ServerStatus.java
|
||||
@@ -23,7 +23,10 @@ public record ServerStatus(
|
||||
boolean enforcesSecureChat
|
||||
) {
|
||||
public static final Codec<ServerStatus> CODEC = RecordCodecBuilder.create(
|
||||
- instance -> instance.group(
|
||||
+ // Leaf start - Mirai - Configurable chat message signatures
|
||||
+ instance ->
|
||||
+ org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled
|
||||
+ ? instance.group(
|
||||
ComponentSerialization.CODEC.lenientOptionalFieldOf("description", CommonComponents.EMPTY).forGetter(ServerStatus::description),
|
||||
ServerStatus.Players.CODEC.lenientOptionalFieldOf("players").forGetter(ServerStatus::players),
|
||||
ServerStatus.Version.CODEC.lenientOptionalFieldOf("version").forGetter(ServerStatus::version),
|
||||
@@ -31,6 +34,15 @@ public record ServerStatus(
|
||||
Codec.BOOL.lenientOptionalFieldOf("enforcesSecureChat", Boolean.valueOf(false)).forGetter(ServerStatus::enforcesSecureChat)
|
||||
)
|
||||
.apply(instance, ServerStatus::new)
|
||||
+ : instance.group(
|
||||
+ ComponentSerialization.CODEC.lenientOptionalFieldOf("description", CommonComponents.EMPTY).forGetter(ServerStatus::description),
|
||||
+ ServerStatus.Players.CODEC.lenientOptionalFieldOf("players").forGetter(ServerStatus::players),
|
||||
+ ServerStatus.Version.CODEC.lenientOptionalFieldOf("version").forGetter(ServerStatus::version),
|
||||
+ ServerStatus.Favicon.CODEC.lenientOptionalFieldOf("favicon").forGetter(ServerStatus::favicon),
|
||||
+ Codec.BOOL.lenientOptionalFieldOf("enforcesSecureChat", Boolean.FALSE).forGetter(x -> true)
|
||||
+ )
|
||||
+ .apply(instance, ServerStatus::new)
|
||||
+ // Leaf end- Mirai - Configurable chat message signatures
|
||||
);
|
||||
|
||||
public record Favicon(byte[] iconBytes) {
|
||||
diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index 5151c24697ceb01b4728d7d3fda5fee31db682d7..d4048661575ebfaf128ba25da365843774364e0e 100644
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -668,6 +668,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
|
||||
@Override
|
||||
public boolean enforceSecureProfile() {
|
||||
+ if (!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled) return false; // Leaf - Mirai - Configurable chat message signatures
|
||||
DedicatedServerProperties properties = this.getProperties();
|
||||
// Paper start - Add setting for proxy online mode status
|
||||
return properties.enforceSecureProfile
|
||||
diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
index 285af1576d6bef09f094b7e990b5bcd6eafda71f..96b70c1384834a8e22925c8e2af85ab7606dde20 100644
|
||||
--- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
|
||||
@@ -321,10 +321,30 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet) {
|
||||
+ // Leaf start - Mirai - Configurable chat message signatures
|
||||
+ if (!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled) {
|
||||
+ if (packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket chat) {
|
||||
+ packet = new net.minecraft.network.protocol.game.ClientboundSystemChatPacket(
|
||||
+ chat.chatType().decorate(chat.unsignedContent() != null ? chat.unsignedContent() : Component.literal(chat.body().content())),
|
||||
+ false
|
||||
+ );
|
||||
+ this.send(packet);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Mirai - Configurable chat message signatures
|
||||
this.send(packet, null);
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet, @Nullable PacketSendListener listener) {
|
||||
+ // Leaf start - Mirai - Configurable chat message signatures
|
||||
+ if (!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled) {
|
||||
+ if (packet instanceof net.minecraft.network.protocol.game.ClientboundPlayerChatPacket chat && listener != null) {
|
||||
+ this.send(chat);
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Mirai - Configurable chat message signatures
|
||||
// CraftBukkit start
|
||||
if (packet == null || this.processedDisconnect) { // Spigot
|
||||
return;
|
||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||
index 84f9a8a606ede4ef8361a2683d775121e57b6d9b..e8683f45823cac55e3e68ccc500f10f0632e72fd 100644
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -1521,7 +1521,7 @@ public abstract class PlayerList {
|
||||
public void broadcastChatMessage(PlayerChatMessage message, Predicate<ServerPlayer> shouldFilterMessageTo, @Nullable ServerPlayer sender, ChatType.Bound boundChatType, @Nullable Function<net.kyori.adventure.audience.Audience, Component> unsignedFunction) {
|
||||
// Paper end
|
||||
boolean flag = this.verifyChatTrusted(message);
|
||||
- this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), boundChatType, flag || !org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.notSecureMarker ? null : "Not Secure"); // Paper // Gale - do not log Not Secure marker
|
||||
+ this.server.logChatMessage((unsignedFunction == null ? message.decoratedContent() : unsignedFunction.apply(this.server.console)), boundChatType, !org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled || flag || !org.galemc.gale.configuration.GaleGlobalConfiguration.get().logToConsole.chat.notSecureMarker ? null : "Not Secure"); // Paper // Gale - do not log Not Secure marker // Leaf - Mirai - Configurable chat message signatures
|
||||
OutgoingChatMessage outgoingChatMessage = OutgoingChatMessage.create(message);
|
||||
boolean flag1 = false;
|
||||
|
||||
@@ -1546,6 +1546,7 @@ public abstract class PlayerList {
|
||||
}
|
||||
|
||||
public boolean verifyChatTrusted(PlayerChatMessage message) { // Paper - private -> public
|
||||
+ if (!org.dreeam.leaf.config.modules.network.ChatMessageSignature.enabled) return true; // Leaf - Mirai - Configurable chat message signatures
|
||||
return message.hasSignature() && !message.hasExpiredServer(Instant.now());
|
||||
}
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Thu, 28 Mar 2024 13:36:09 -0400
|
||||
Subject: [PATCH] Cache player profileResult
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
index 069477e524a28b20a0289221858bdc802704a890..21ecbbdd97204477dadd2ade1d93f64cf91c7dfe 100644
|
||||
--- a/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -71,6 +71,11 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
private net.minecraft.server.level.ServerPlayer player; // CraftBukkit
|
||||
public boolean iKnowThisMayNotBeTheBestIdeaButPleaseDisableUsernameValidation = false; // Paper - username validation overriding
|
||||
private int velocityLoginMessageId = -1; // Paper - Add Velocity IP Forwarding Support
|
||||
+ // Leaf start - Cache player profileResult
|
||||
+ private static final com.github.benmanes.caffeine.cache.Cache<String, ProfileResult> playerProfileResultCache = com.github.benmanes.caffeine.cache.Caffeine.newBuilder()
|
||||
+ .expireAfterWrite(org.dreeam.leaf.config.modules.misc.Cache.cachePlayerProfileResultTimeout, java.util.concurrent.TimeUnit.MINUTES)
|
||||
+ .build();
|
||||
+ // Leaf end - Cache player profileResult
|
||||
|
||||
public ServerLoginPacketListenerImpl(MinecraftServer server, Connection connection, boolean transferred) {
|
||||
this.server = server;
|
||||
@@ -304,9 +309,23 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener,
|
||||
String string1 = Objects.requireNonNull(ServerLoginPacketListenerImpl.this.requestedUsername, "Player name not initialized");
|
||||
|
||||
try {
|
||||
- ProfileResult profileResult = ServerLoginPacketListenerImpl.this.server
|
||||
- .getSessionService()
|
||||
- .hasJoinedServer(string1, string, this.getAddress());
|
||||
+ // Leaf start - Cache player profileResult
|
||||
+ ProfileResult profileResult;
|
||||
+ if (org.dreeam.leaf.config.modules.misc.Cache.cachePlayerProfileResult) {
|
||||
+ profileResult = playerProfileResultCache.getIfPresent(string1);
|
||||
+
|
||||
+ if (profileResult == null) {
|
||||
+ profileResult = ServerLoginPacketListenerImpl.this.server
|
||||
+ .getSessionService()
|
||||
+ .hasJoinedServer(string1, string, this.getAddress());
|
||||
+ playerProfileResultCache.put(string1, profileResult);
|
||||
+ }
|
||||
+ } else {
|
||||
+ profileResult = ServerLoginPacketListenerImpl.this.server
|
||||
+ .getSessionService()
|
||||
+ .hasJoinedServer(string1, string, this.getAddress());
|
||||
+ }
|
||||
+ // Leaf end - Cache player profileResult
|
||||
if (profileResult != null) {
|
||||
GameProfile gameProfile = profileResult.profile();
|
||||
// CraftBukkit start - fire PlayerPreLoginEvent
|
||||
@@ -1,429 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Apehum <apehumchik@gmail.com>
|
||||
Date: Thu, 9 Dec 2021 02:18:17 +0800
|
||||
Subject: [PATCH] Matter: Secure Seed
|
||||
|
||||
TODO - Dreeam:
|
||||
Update to BLAKE3
|
||||
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/plasmoapp/matter
|
||||
|
||||
Co-authored-by: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Co-authored-by: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
|
||||
diff --git a/net/minecraft/server/dedicated/DedicatedServerProperties.java b/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||
index 5748658abf0b90812005ae9d426df92daf5532f0..4a0eed7d7645ed539857592d233214e9a74499f1 100644
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServerProperties.java
|
||||
@@ -114,7 +114,17 @@ public class DedicatedServerProperties extends Settings<DedicatedServerPropertie
|
||||
String string = this.get("level-seed", "");
|
||||
boolean flag = this.get("generate-structures", true);
|
||||
long l = WorldOptions.parseSeed(string).orElse(WorldOptions.randomSeed());
|
||||
- this.worldOptions = new WorldOptions(l, flag, false);
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
+ String featureSeedStr = this.get("feature-level-seed", "");
|
||||
+ long[] featureSeed = su.plo.matter.Globals.parseSeed(featureSeedStr)
|
||||
+ .orElse(su.plo.matter.Globals.createRandomWorldSeed());
|
||||
+
|
||||
+ this.worldOptions = new WorldOptions(l, featureSeed, flag, false);
|
||||
+ } else {
|
||||
+ this.worldOptions = new WorldOptions(l, flag, false);
|
||||
+ }
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
this.worldDimensionData = new DedicatedServerProperties.WorldDimensionData(
|
||||
this.get("generator-settings", property -> GsonHelper.parse(!property.isEmpty() ? property : "{}"), new JsonObject()),
|
||||
this.get("level-type", property -> property.toLowerCase(Locale.ROOT), WorldPresets.NORMAL.location().toString())
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 54895ed9ad9b9b2c4c12cfcce89af453c430e3e6..721d89144074c5749642feb0a08d21fbcce4b2fe 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -710,6 +710,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
}
|
||||
|
||||
public ChunkGenerator getGenerator() {
|
||||
+ su.plo.matter.Globals.setupGlobals(level); // Leaf - Matter - Secure Seed
|
||||
return this.chunkMap.generator();
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index f8bd39ddd7b6948734254acfb8b0235eff774133..3c92508724bd2c8244ee4591c6b00b01657216f2 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -633,6 +633,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
chunkGenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkGenerator, gen);
|
||||
}
|
||||
// CraftBukkit end
|
||||
+ su.plo.matter.Globals.setupGlobals(this); // Leaf - Matter - Secure Seed
|
||||
boolean flag = server.forceSynchronousWrites();
|
||||
DataFixer fixerUpper = server.getFixerUpper();
|
||||
// Paper - rewrite chunk system
|
||||
diff --git a/net/minecraft/world/entity/monster/Slime.java b/net/minecraft/world/entity/monster/Slime.java
|
||||
index 240a54b210e23d5b79e6bcaf3806aa454668135d..c562af16e20c2127482ea1f769ad042d36dbb1f6 100644
|
||||
--- a/net/minecraft/world/entity/monster/Slime.java
|
||||
+++ b/net/minecraft/world/entity/monster/Slime.java
|
||||
@@ -424,7 +424,12 @@ public class Slime extends Mob implements Enemy {
|
||||
}
|
||||
|
||||
ChunkPos chunkPos = new ChunkPos(pos);
|
||||
- boolean flag = level.getMinecraftWorld().paperConfig().entities.spawning.allChunksAreSlimeChunks || WorldgenRandom.seedSlimeChunk(chunkPos.x, chunkPos.z, ((WorldGenLevel) level).getSeed(), level.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot // Paper
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ boolean isSlimeChunk = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
||||
+ ? level.getChunk(chunkPos.x, chunkPos.z).isSlimeChunk()
|
||||
+ : WorldgenRandom.seedSlimeChunk(chunkPos.x, chunkPos.z, ((WorldGenLevel) level).getSeed(), level.getMinecraftWorld().spigotConfig.slimeSeed).nextInt(10) == 0; // Spigot // Paper
|
||||
+ boolean flag = level.getMinecraftWorld().paperConfig().entities.spawning.allChunksAreSlimeChunks || isSlimeChunk;
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
// Paper start - Replace rules for Height in Slime Chunks
|
||||
final double maxHeightSlimeChunk = level.getMinecraftWorld().paperConfig().entities.spawning.slimeSpawnHeight.slimeChunk.maximum;
|
||||
if (random.nextInt(10) == 0 && flag && pos.getY() < maxHeightSlimeChunk) {
|
||||
diff --git a/net/minecraft/world/level/chunk/ChunkAccess.java b/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
index 6d565b52552534ce9cacfc35ad1bf4adcb69eac3..3a6db5bc0c8be7d68e15317a621c1965fdc3a9bd 100644
|
||||
--- a/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
+++ b/net/minecraft/world/level/chunk/ChunkAccess.java
|
||||
@@ -87,6 +87,10 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh
|
||||
public org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer persistentDataContainer = new org.bukkit.craftbukkit.persistence.DirtyCraftPersistentDataContainer(ChunkAccess.DATA_TYPE_REGISTRY);
|
||||
// CraftBukkit end
|
||||
public final Registry<Biome> biomeRegistry; // CraftBukkit
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ private boolean slimeChunk;
|
||||
+ private boolean hasComputedSlimeChunk;
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
|
||||
// Paper start - rewrite chunk system
|
||||
private volatile ca.spottedleaf.moonrise.patches.starlight.light.SWMRNibbleArray[] blockNibbles;
|
||||
@@ -191,6 +195,17 @@ public abstract class ChunkAccess implements BiomeManager.NoiseBiomeSource, Ligh
|
||||
return GameEventListenerRegistry.NOOP;
|
||||
}
|
||||
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ public boolean isSlimeChunk() {
|
||||
+ if (!hasComputedSlimeChunk) {
|
||||
+ hasComputedSlimeChunk = true;
|
||||
+ slimeChunk = su.plo.matter.WorldgenCryptoRandom.seedSlimeChunk(chunkPos.x, chunkPos.z).nextInt(10) == 0;
|
||||
+ }
|
||||
+
|
||||
+ return slimeChunk;
|
||||
+ }
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
+
|
||||
public abstract BlockState getBlockState(final int x, final int y, final int z); // Paper
|
||||
@Nullable
|
||||
public abstract BlockState setBlockState(BlockPos pos, BlockState state, boolean isMoving);
|
||||
diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
index 6ed51cf42b5864194d671b5b56f5b9bdf0291dc0..8a4ce8b3b050ad9fb7de007129f5f460110d0b09 100644
|
||||
--- a/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
+++ b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
@@ -343,7 +343,11 @@ public abstract class ChunkGenerator {
|
||||
Registry<Structure> registry = level.registryAccess().lookupOrThrow(Registries.STRUCTURE);
|
||||
Map<Integer, List<Structure>> map = registry.stream().collect(Collectors.groupingBy(structure1 -> structure1.step().ordinal()));
|
||||
List<FeatureSorter.StepFeatureData> list = this.featuresPerStep.get();
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.generateUniqueSeed()));
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
||||
+ ? new su.plo.matter.WorldgenCryptoRandom(blockPos.getX(), blockPos.getZ(), su.plo.matter.Globals.Salt.UNDEFINED, 0)
|
||||
+ : new WorldgenRandom(new XoroshiroRandomSource(RandomSupport.generateUniqueSeed()));
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
long l = worldgenRandom.setDecorationSeed(level.getSeed(), blockPos.getX(), blockPos.getZ());
|
||||
Set<Holder<Biome>> set = new ObjectArraySet<>();
|
||||
ChunkPos.rangeClosed(sectionPos.chunk(), 1).forEach(chunkPos -> {
|
||||
@@ -556,8 +560,15 @@ public abstract class ChunkGenerator {
|
||||
} else {
|
||||
ArrayList<StructureSet.StructureSelectionEntry> list1 = new ArrayList<>(list.size());
|
||||
list1.addAll(list);
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
- worldgenRandom.setLargeFeatureSeed(structureState.getLevelSeed(), pos.x, pos.z);
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ WorldgenRandom worldgenRandom;
|
||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
+ worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(pos.x, pos.z, su.plo.matter.Globals.Salt.GENERATE_FEATURE, 0);
|
||||
+ } else {
|
||||
+ worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ worldgenRandom.setLargeFeatureSeed(structureState.getLevelSeed(), pos.x, pos.z);
|
||||
+ }
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
int i = 0;
|
||||
|
||||
for (StructureSet.StructureSelectionEntry structureSelectionEntry1 : list1) {
|
||||
diff --git a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||
index f07a5416e5dc7e9a798a78ce9573a0c42bc59d04..426692d9627f46d708f551bd22ce3c52b2a23b37 100644
|
||||
--- a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||
+++ b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||
@@ -205,7 +205,12 @@ public class ChunkGeneratorStructureState {
|
||||
List<CompletableFuture<ChunkPos>> list = new ArrayList<>(count);
|
||||
int spread = placement.spread();
|
||||
HolderSet<Biome> holderSet = placement.preferredBiomes();
|
||||
- RandomSource randomSource = RandomSource.create();
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ RandomSource randomSource = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
||||
+ ? new su.plo.matter.WorldgenCryptoRandom(0, 0, su.plo.matter.Globals.Salt.STRONGHOLDS, 0)
|
||||
+ : RandomSource.create();
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
+ if (!org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
// Paper start - Add missing structure set seed configs
|
||||
if (this.conf.strongholdSeed != null && structureSet.is(net.minecraft.world.level.levelgen.structure.BuiltinStructureSets.STRONGHOLDS)) {
|
||||
randomSource.setSeed(this.conf.strongholdSeed);
|
||||
@@ -213,6 +218,7 @@ public class ChunkGeneratorStructureState {
|
||||
// Paper end - Add missing structure set seed configs
|
||||
randomSource.setSeed(this.concentricRingsSeed);
|
||||
} // Paper - Add missing structure set seed configs
|
||||
+ } // Leaf - Matter - Secure Seed
|
||||
double d = randomSource.nextDouble() * Math.PI * 2.0;
|
||||
int i = 0;
|
||||
int i1 = 0;
|
||||
diff --git a/net/minecraft/world/level/chunk/status/ChunkStep.java b/net/minecraft/world/level/chunk/status/ChunkStep.java
|
||||
index b8348976e80578d9eff64eea68c04c603fed49ad..bc5c6ea1f1e4f1608a70116f03fb2a58ca3252c3 100644
|
||||
--- a/net/minecraft/world/level/chunk/status/ChunkStep.java
|
||||
+++ b/net/minecraft/world/level/chunk/status/ChunkStep.java
|
||||
@@ -60,6 +60,7 @@ public final class ChunkStep implements ca.spottedleaf.moonrise.patches.chunk_sy
|
||||
}
|
||||
|
||||
public CompletableFuture<ChunkAccess> apply(WorldGenContext worldGenContext, StaticCache2D<GenerationChunkHolder> cache, ChunkAccess chunk) {
|
||||
+ su.plo.matter.Globals.setupGlobals(worldGenContext.level()); // Leaf - Matter - Secure Seed
|
||||
if (chunk.getPersistedStatus().isBefore(this.targetStatus)) {
|
||||
ProfiledDuration profiledDuration = JvmProfiler.INSTANCE
|
||||
.onChunkGenerate(chunk.getPos(), worldGenContext.level().dimension(), this.targetStatus.getName());
|
||||
diff --git a/net/minecraft/world/level/levelgen/WorldOptions.java b/net/minecraft/world/level/levelgen/WorldOptions.java
|
||||
index c92508741439a8d0d833ea02d0104416adb83c92..c05da7cfcd3d97a1716cb305be36ba9c94217b6f 100644
|
||||
--- a/net/minecraft/world/level/levelgen/WorldOptions.java
|
||||
+++ b/net/minecraft/world/level/levelgen/WorldOptions.java
|
||||
@@ -9,8 +9,20 @@ import net.minecraft.util.RandomSource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
public class WorldOptions {
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ private static final com.google.gson.Gson gson = new com.google.gson.Gson();
|
||||
+ private static final boolean isSecureSeedEnabled = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled;
|
||||
public static final MapCodec<WorldOptions> CODEC = RecordCodecBuilder.mapCodec(
|
||||
- instance -> instance.group(
|
||||
+ instance -> isSecureSeedEnabled
|
||||
+ ? instance.group(
|
||||
+ Codec.LONG.fieldOf("seed").stable().forGetter(WorldOptions::seed),
|
||||
+ Codec.STRING.fieldOf("feature_seed").orElse(gson.toJson(su.plo.matter.Globals.createRandomWorldSeed())).stable().forGetter(WorldOptions::featureSeedSerialize),
|
||||
+ Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(WorldOptions::generateStructures),
|
||||
+ Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(WorldOptions::generateBonusChest),
|
||||
+ Codec.STRING.lenientOptionalFieldOf("legacy_custom_options").stable().forGetter(worldOptions -> worldOptions.legacyCustomOptions)
|
||||
+ )
|
||||
+ .apply(instance, instance.stable(WorldOptions::new))
|
||||
+ : instance.group(
|
||||
Codec.LONG.fieldOf("seed").stable().forGetter(WorldOptions::seed),
|
||||
Codec.BOOL.fieldOf("generate_features").orElse(true).stable().forGetter(WorldOptions::generateStructures),
|
||||
Codec.BOOL.fieldOf("bonus_chest").orElse(false).stable().forGetter(WorldOptions::generateBonusChest),
|
||||
@@ -18,8 +30,14 @@ public class WorldOptions {
|
||||
)
|
||||
.apply(instance, instance.stable(WorldOptions::new))
|
||||
);
|
||||
- public static final WorldOptions DEMO_OPTIONS = new WorldOptions("North Carolina".hashCode(), true, true);
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ public static final WorldOptions DEMO_OPTIONS = isSecureSeedEnabled
|
||||
+ ? new WorldOptions((long) "North Carolina".hashCode(), su.plo.matter.Globals.createRandomWorldSeed(), true, true)
|
||||
+ : new WorldOptions("North Carolina".hashCode(), true, true);
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
private final long seed;
|
||||
+ private long[] featureSeed = su.plo.matter.Globals.createRandomWorldSeed(); // Leaf - Matter - Secure Seed
|
||||
private final boolean generateStructures;
|
||||
private final boolean generateBonusChest;
|
||||
private final Optional<String> legacyCustomOptions;
|
||||
@@ -28,14 +46,35 @@ public class WorldOptions {
|
||||
this(seed, generateStructures, generateBonusChest, Optional.empty());
|
||||
}
|
||||
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ public WorldOptions(long seed, long[] featureSeed, boolean generateStructures, boolean bonusChest) {
|
||||
+ this(seed, featureSeed, generateStructures, bonusChest, Optional.empty());
|
||||
+ }
|
||||
+
|
||||
+ private WorldOptions(long seed, String featureSeedJson, boolean generateStructures, boolean bonusChest, Optional<String> legacyCustomOptions) {
|
||||
+ this(seed, gson.fromJson(featureSeedJson, long[].class), generateStructures, bonusChest, legacyCustomOptions);
|
||||
+ }
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
+
|
||||
public static WorldOptions defaultWithRandomSeed() {
|
||||
- return new WorldOptions(randomSeed(), true, false);
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ return isSecureSeedEnabled
|
||||
+ ? new WorldOptions(randomSeed(), su.plo.matter.Globals.createRandomWorldSeed(), true, false)
|
||||
+ : new WorldOptions(randomSeed(), true, false);
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
}
|
||||
|
||||
public static WorldOptions testWorldWithRandomSeed() {
|
||||
return new WorldOptions(randomSeed(), false, false);
|
||||
}
|
||||
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ private WorldOptions(long seed, long[] featureSeed, boolean generateStructures, boolean bonusChest, Optional<String> legacyCustomOptions) {
|
||||
+ this(seed, generateStructures, bonusChest, legacyCustomOptions);
|
||||
+ this.featureSeed = featureSeed;
|
||||
+ }
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
+
|
||||
private WorldOptions(long seed, boolean generateStructures, boolean generateBonusChest, Optional<String> legacyCustomOptions) {
|
||||
this.seed = seed;
|
||||
this.generateStructures = generateStructures;
|
||||
@@ -47,6 +86,16 @@ public class WorldOptions {
|
||||
return this.seed;
|
||||
}
|
||||
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ public long[] featureSeed() {
|
||||
+ return this.featureSeed;
|
||||
+ }
|
||||
+
|
||||
+ private String featureSeedSerialize() {
|
||||
+ return gson.toJson(this.featureSeed);
|
||||
+ }
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
+
|
||||
public boolean generateStructures() {
|
||||
return this.generateStructures;
|
||||
}
|
||||
@@ -59,17 +108,25 @@ public class WorldOptions {
|
||||
return this.legacyCustomOptions.isPresent();
|
||||
}
|
||||
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
public WorldOptions withBonusChest(boolean generateBonusChest) {
|
||||
- return new WorldOptions(this.seed, this.generateStructures, generateBonusChest, this.legacyCustomOptions);
|
||||
+ return isSecureSeedEnabled
|
||||
+ ? new WorldOptions(this.seed, this.featureSeed, this.generateStructures, generateBonusChest, this.legacyCustomOptions)
|
||||
+ : new WorldOptions(this.seed, this.generateStructures, generateBonusChest, this.legacyCustomOptions);
|
||||
}
|
||||
|
||||
public WorldOptions withStructures(boolean generateStructures) {
|
||||
- return new WorldOptions(this.seed, generateStructures, this.generateBonusChest, this.legacyCustomOptions);
|
||||
+ return isSecureSeedEnabled
|
||||
+ ? new WorldOptions(this.seed, this.featureSeed, generateStructures, this.generateBonusChest, this.legacyCustomOptions)
|
||||
+ : new WorldOptions(this.seed, generateStructures, this.generateBonusChest, this.legacyCustomOptions);
|
||||
}
|
||||
|
||||
public WorldOptions withSeed(OptionalLong seed) {
|
||||
- return new WorldOptions(seed.orElse(randomSeed()), this.generateStructures, this.generateBonusChest, this.legacyCustomOptions);
|
||||
+ return isSecureSeedEnabled
|
||||
+ ? new WorldOptions(seed.orElse(randomSeed()), su.plo.matter.Globals.createRandomWorldSeed(), this.generateStructures, this.generateBonusChest, this.legacyCustomOptions)
|
||||
+ : new WorldOptions(seed.orElse(randomSeed()), this.generateStructures, this.generateBonusChest, this.legacyCustomOptions);
|
||||
}
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
|
||||
public static OptionalLong parseSeed(String seed) {
|
||||
seed = seed.trim();
|
||||
diff --git a/net/minecraft/world/level/levelgen/feature/GeodeFeature.java b/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
||||
index 38475f6975533909924c8d54f438cf43cdfe31a3..f73bd2d86b2fcffa55cd8cc82aa1febe3467c87a 100644
|
||||
--- a/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
||||
+++ b/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
||||
@@ -41,7 +41,11 @@ public class GeodeFeature extends Feature<GeodeConfiguration> {
|
||||
int i1 = geodeConfiguration.maxGenOffset;
|
||||
List<Pair<BlockPos, Integer>> list = Lists.newLinkedList();
|
||||
int i2 = geodeConfiguration.distributionPoints.sample(randomSource);
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(worldGenLevel.getSeed()));
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
||||
+ ? new su.plo.matter.WorldgenCryptoRandom(0, 0, su.plo.matter.Globals.Salt.GEODE_FEATURE, 0)
|
||||
+ : new WorldgenRandom(new LegacyRandomSource(worldGenLevel.getSeed()));
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
NormalNoise normalNoise = NormalNoise.create(worldgenRandom, -4, 1.0);
|
||||
List<BlockPos> list1 = Lists.newLinkedList();
|
||||
double d = (double)i2 / geodeConfiguration.outerWallDistance.getMaxValue();
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/Structure.java b/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
index 8328e864c72b7a358d6bb1f33459b8c4df2ecb1a..28281491be6b54de18c49ff0d52e302575d3ad38 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
@@ -249,6 +249,11 @@ public abstract class Structure {
|
||||
}
|
||||
|
||||
private static WorldgenRandom makeRandom(long seed, ChunkPos chunkPos) {
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
+ return new su.plo.matter.WorldgenCryptoRandom(chunkPos.x, chunkPos.z, su.plo.matter.Globals.Salt.GENERATE_FEATURE, seed);
|
||||
+ }
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
worldgenRandom.setLargeFeatureSeed(seed, chunkPos.x, chunkPos.z);
|
||||
return worldgenRandom;
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java b/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
||||
index ee0d9dddb36b6879fa113299e24f1aa3b2b151cc..6584c9320361dbbdea1899ab9e43b444de5006a6 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
||||
@@ -67,8 +67,15 @@ public class RandomSpreadStructurePlacement extends StructurePlacement {
|
||||
public ChunkPos getPotentialStructureChunk(long seed, int regionX, int regionZ) {
|
||||
int i = Math.floorDiv(regionX, this.spacing);
|
||||
int i1 = Math.floorDiv(regionZ, this.spacing);
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
- worldgenRandom.setLargeFeatureWithSalt(seed, i, i1, this.salt());
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ WorldgenRandom worldgenRandom;
|
||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
+ worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(i, i1, su.plo.matter.Globals.Salt.POTENTIONAL_FEATURE, this.salt);
|
||||
+ } else {
|
||||
+ worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ worldgenRandom.setLargeFeatureWithSalt(seed, i, i1, this.salt());
|
||||
+ }
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
int i2 = this.spacing - this.separation;
|
||||
int i3 = this.spreadType.evaluate(worldgenRandom, i2);
|
||||
int i4 = this.spreadType.evaluate(worldgenRandom, i2);
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java b/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
||||
index 670335a7bbfbc9da64c389977498c22dfcd03251..aaf80406af22af288b1b2e36a7a5d00c26c5afa5 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
||||
@@ -118,8 +118,16 @@ public abstract class StructurePlacement {
|
||||
public abstract StructurePlacementType<?> type();
|
||||
|
||||
private static boolean probabilityReducer(long levelSeed, int regionX, int regionZ, int salt, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs; ignore here
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
- worldgenRandom.setLargeFeatureWithSalt(levelSeed, regionX, regionZ, salt);
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ WorldgenRandom worldgenRandom;
|
||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
+ worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(regionX, regionZ, su.plo.matter.Globals.Salt.UNDEFINED, salt);
|
||||
+ } else {
|
||||
+ worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ worldgenRandom.setLargeFeatureWithSalt(levelSeed, salt, regionX, regionZ);
|
||||
+ }
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
+
|
||||
return worldgenRandom.nextFloat() < probability;
|
||||
}
|
||||
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java b/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java
|
||||
index eb85edaa3b7fab4f11545b0fa8bfea882dedb67d..4a5012400cd23590bd8e64670222995a200c93ea 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/pools/JigsawPlacement.java
|
||||
@@ -64,7 +64,11 @@ public class JigsawPlacement {
|
||||
ChunkGenerator chunkGenerator = context.chunkGenerator();
|
||||
StructureTemplateManager structureTemplateManager = context.structureTemplateManager();
|
||||
LevelHeightAccessor levelHeightAccessor = context.heightAccessor();
|
||||
- WorldgenRandom worldgenRandom = context.random();
|
||||
+ // Leaf start - Matter - Secure Seed
|
||||
+ WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
||||
+ ? new su.plo.matter.WorldgenCryptoRandom(context.chunkPos().x, context.chunkPos().z, su.plo.matter.Globals.Salt.JIGSAW_PLACEMENT, 0)
|
||||
+ : context.random();
|
||||
+ // Leaf end - Matter - Secure Seed
|
||||
Registry<StructureTemplatePool> registry = registryAccess.lookupOrThrow(Registries.TEMPLATE_POOL);
|
||||
Rotation random = Rotation.getRandom(worldgenRandom);
|
||||
StructureTemplatePool structureTemplatePool = startPool.unwrapKey()
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/structures/EndCityStructure.java b/net/minecraft/world/level/levelgen/structure/structures/EndCityStructure.java
|
||||
index 653c03d214d2e690852adc4d697e2b24c39ea3d0..807881ab3b647bff515df627543b8a2e1cad3c3f 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/structures/EndCityStructure.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/structures/EndCityStructure.java
|
||||
@@ -10,6 +10,7 @@ import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructurePiece;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureType;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePiecesBuilder;
|
||||
+//import su.plo.matter.WorldgenCryptoRandom; // Leaf - Matter - Secure Seed
|
||||
|
||||
public class EndCityStructure extends Structure {
|
||||
public static final MapCodec<EndCityStructure> CODEC = simpleCodec(EndCityStructure::new);
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/structures/MineshaftStructure.java b/net/minecraft/world/level/levelgen/structure/structures/MineshaftStructure.java
|
||||
index 5f2118f664c1013b99137c6d34a11c40c2559156..2acee0e8b5b80f7a40346befcafcd011edd37cf9 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/structures/MineshaftStructure.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/structures/MineshaftStructure.java
|
||||
@@ -20,6 +20,7 @@ import net.minecraft.world.level.levelgen.WorldgenRandom;
|
||||
import net.minecraft.world.level.levelgen.structure.Structure;
|
||||
import net.minecraft.world.level.levelgen.structure.StructureType;
|
||||
import net.minecraft.world.level.levelgen.structure.pieces.StructurePiecesBuilder;
|
||||
+//import su.plo.matter.WorldgenCryptoRandom; // Leaf - Matter - Secure Seed
|
||||
|
||||
public class MineshaftStructure extends Structure {
|
||||
public static final MapCodec<MineshaftStructure> CODEC = RecordCodecBuilder.mapCodec(
|
||||
@@ -1,30 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Apehum <apehumchik@gmail.com>
|
||||
Date: Thu, 16 Dec 2021 04:23:40 +0800
|
||||
Subject: [PATCH] Matter: Secure Seed command
|
||||
|
||||
Original license: GPLv3
|
||||
Original project: https://github.com/plasmoapp/matter
|
||||
|
||||
diff --git a/net/minecraft/server/commands/SeedCommand.java b/net/minecraft/server/commands/SeedCommand.java
|
||||
index a65affc41a4fc299bc2281f0f53f2e075633899d..18dd6fa908104ea9fbb32faaca0725d4d6849b09 100644
|
||||
--- a/net/minecraft/server/commands/SeedCommand.java
|
||||
+++ b/net/minecraft/server/commands/SeedCommand.java
|
||||
@@ -12,6 +12,17 @@ public class SeedCommand {
|
||||
long seed = context.getSource().getLevel().getSeed();
|
||||
Component component = ComponentUtils.copyOnClickText(String.valueOf(seed));
|
||||
context.getSource().sendSuccess(() -> Component.translatable("commands.seed.success", component), false);
|
||||
+
|
||||
+ // Leaf start - Matter - Secure Seed command
|
||||
+ if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
+ su.plo.matter.Globals.setupGlobals(context.getSource().getLevel());
|
||||
+ String seedStr = su.plo.matter.Globals.seedToString(su.plo.matter.Globals.worldSeed);
|
||||
+ Component featureSeedComponent = ComponentUtils.copyOnClickText(seedStr);
|
||||
+
|
||||
+ context.getSource().sendSuccess(() -> Component.translatable(("Feature seed: %s"), featureSeedComponent), false);
|
||||
+ }
|
||||
+ // Leaf end - Matter - Secure Seed command
|
||||
+
|
||||
return (int)seed;
|
||||
}));
|
||||
}
|
||||
@@ -1,369 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Tue, 9 Nov 2077 00:00:00 +0800
|
||||
Subject: [PATCH] Faster random generator
|
||||
|
||||
This patch replaces LegacyRandomSource with FasterRandomSource by default,
|
||||
which is faster in general.
|
||||
|
||||
Benchmark results (10,000,000 iterations) (Azul Zulu 23.0.1)
|
||||
|
||||
FasterRandomSource (Leaf) (Backed by Xoroshiro128PlusPlus): 51,633,700 ns
|
||||
LegacyRandomSource (Vanilla): 254,857,500 ns
|
||||
ThreadUnsafeRandom (Moonrise): 102,265,100 ns
|
||||
SimpleThreadUnsafeRandom (Moonrise): 97,054,600 ns
|
||||
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 4070a6eb52f6097e38c2d85c231d39ea3785cf46..bb76dbf98979fdc725676c98dafe64ea941cb290 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -150,7 +150,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
}
|
||||
// Paper end - rewrite chunk system
|
||||
// Paper start - chunk tick iteration optimisations
|
||||
- private final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom shuffleRandom = new ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom(0L);
|
||||
+ private final net.minecraft.world.level.levelgen.BitRandomSource shuffleRandom = org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom(0L); // Leaf - Faster random generator
|
||||
private boolean isChunkNearPlayer(final ChunkMap chunkMap, final ChunkPos chunkPos, final LevelChunk levelChunk) {
|
||||
final ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkData chunkData = ((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemChunkHolder)((ca.spottedleaf.moonrise.patches.chunk_system.level.chunk.ChunkSystemLevelChunk)levelChunk).moonrise$getChunkAndHolder().holder())
|
||||
.moonrise$getRealChunkHolder().holderData;
|
||||
diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java
|
||||
index 3c92508724bd2c8244ee4591c6b00b01657216f2..0290e1f0c45677d337f77a0c8269894b32a43ca9 100644
|
||||
--- a/net/minecraft/server/level/ServerLevel.java
|
||||
+++ b/net/minecraft/server/level/ServerLevel.java
|
||||
@@ -902,7 +902,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
private void optimiseRandomTick(final LevelChunk chunk, final int tickSpeed) {
|
||||
final LevelChunkSection[] sections = chunk.getSections();
|
||||
final int minSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinSection((ServerLevel)(Object)this);
|
||||
- final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom simpleRandom = this.simpleRandom;
|
||||
+ final net.minecraft.world.level.levelgen.BitRandomSource simpleRandom = this.simpleRandom; // Leaf - Faster random generator - upcasting
|
||||
final boolean doubleTickFluids = !ca.spottedleaf.moonrise.common.PlatformHooks.get().configFixMC224294();
|
||||
|
||||
final ChunkPos cpos = chunk.getPos();
|
||||
@@ -951,7 +951,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe
|
||||
private int currentIceAndSnowTick = 0; protected void resetIceAndSnowTick() { this.currentIceAndSnowTick = this.simpleRandom.nextInt(16); } // Gale - Airplane - optimize random calls in chunk ticking
|
||||
|
||||
public void tickChunk(LevelChunk chunk, int randomTickSpeed) {
|
||||
- final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom simpleRandom = this.simpleRandom; // Paper - optimise random ticking
|
||||
+ final net.minecraft.world.level.levelgen.BitRandomSource simpleRandom = this.simpleRandom; // Paper - optimise random ticking // Leaf - Faster random generator - upcasting
|
||||
ChunkPos pos = chunk.getPos();
|
||||
boolean isRaining = this.isRaining();
|
||||
int minBlockX = pos.getMinBlockX();
|
||||
diff --git a/net/minecraft/util/RandomSource.java b/net/minecraft/util/RandomSource.java
|
||||
index 98a54bc4de251014342cda6d0951b7fea79ce553..d6e86369689e5651698a569ef32d6e4cf4bb6229 100644
|
||||
--- a/net/minecraft/util/RandomSource.java
|
||||
+++ b/net/minecraft/util/RandomSource.java
|
||||
@@ -15,18 +15,40 @@ public interface RandomSource {
|
||||
return create(RandomSupport.generateUniqueSeed());
|
||||
}
|
||||
|
||||
+ // Leaf start - Faster random generator
|
||||
@Deprecated
|
||||
static RandomSource createThreadSafe() {
|
||||
- return new ThreadSafeLegacyRandomSource(RandomSupport.generateUniqueSeed());
|
||||
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled
|
||||
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateUniqueSeed())
|
||||
+ : new ThreadSafeLegacyRandomSource(RandomSupport.generateUniqueSeed());
|
||||
}
|
||||
|
||||
static RandomSource create(long seed) {
|
||||
- return new LegacyRandomSource(seed);
|
||||
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled
|
||||
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed)
|
||||
+ : new LegacyRandomSource(seed);
|
||||
+ }
|
||||
+
|
||||
+ static RandomSource createForSlimeChunk(long seed) {
|
||||
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled && !org.dreeam.leaf.config.modules.opt.FastRNG.useLegacyForSlimeChunk
|
||||
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed)
|
||||
+ : new LegacyRandomSource(seed);
|
||||
}
|
||||
|
||||
static RandomSource createNewThreadLocalInstance() {
|
||||
- return new SingleThreadedRandomSource(ThreadLocalRandom.current().nextLong());
|
||||
+ return org.dreeam.leaf.config.modules.opt.FastRNG.enabled
|
||||
+ ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateUniqueSeed())
|
||||
+ : new SingleThreadedRandomSource(ThreadLocalRandom.current().nextLong());
|
||||
+ }
|
||||
+
|
||||
+ static RandomSource createLegacy() {
|
||||
+ return new LegacyRandomSource(RandomSupport.generateUniqueSeed());
|
||||
+ }
|
||||
+
|
||||
+ static RandomSource createLegacy(long seed) {
|
||||
+ return new LegacyRandomSource(seed);
|
||||
}
|
||||
+ // Leaf end - Faster random generator
|
||||
|
||||
RandomSource fork();
|
||||
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index f500f4e32e676712fcd0c877498acc2722baae98..18dfaa60da8de12aea95cda21ee55636bf66f487 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -143,7 +143,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
}
|
||||
|
||||
// Paper start - Share random for entities to make them more random
|
||||
- public static RandomSource SHARED_RANDOM = new RandomRandomSource();
|
||||
+ public static RandomSource SHARED_RANDOM = org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? org.dreeam.leaf.util.math.random.FasterRandomSource.SHARED_INSTANCE : new RandomRandomSource(); // Leaf - Faster random generator
|
||||
// Paper start - replace random
|
||||
private static final class RandomRandomSource extends ca.spottedleaf.moonrise.common.util.ThreadUnsafeRandom {
|
||||
public RandomRandomSource() {
|
||||
diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java
|
||||
index b39d67ab9ed446885111a5387d3332c36b4f3cc9..53cabe7dabc83618c8941c95e95c5b7e23ee694e 100644
|
||||
--- a/net/minecraft/world/level/Level.java
|
||||
+++ b/net/minecraft/world/level/Level.java
|
||||
@@ -126,7 +126,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
public float rainLevel;
|
||||
protected float oThunderLevel;
|
||||
public float thunderLevel;
|
||||
- public final RandomSource random = new ca.spottedleaf.moonrise.common.util.ThreadUnsafeRandom(net.minecraft.world.level.levelgen.RandomSupport.generateUniqueSeed()); // Paper - replace random
|
||||
+ public final RandomSource random = org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? new org.dreeam.leaf.util.math.random.FasterRandomSource(net.minecraft.world.level.levelgen.RandomSupport.generateUniqueSeed()) : new ca.spottedleaf.moonrise.common.util.ThreadUnsafeRandom(net.minecraft.world.level.levelgen.RandomSupport.generateUniqueSeed()); // Paper - replace random // Leaf - Faster random generator
|
||||
@Deprecated
|
||||
private final RandomSource threadSafeRandom = RandomSource.createThreadSafe();
|
||||
private final Holder<DimensionType> dimensionTypeRegistration;
|
||||
@@ -182,7 +182,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl
|
||||
public final Map<ServerExplosion.CacheKey, Float> explosionDensityCache = new HashMap<>(); // Paper - Optimize explosions
|
||||
public java.util.ArrayDeque<net.minecraft.world.level.block.RedstoneTorchBlock.Toggle> redstoneUpdateInfos; // Paper - Faster redstone torch rapid clock removal; Move from Map in BlockRedstoneTorch to here
|
||||
|
||||
- public final ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom simpleRandom = new ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom(net.minecraft.world.level.levelgen.RandomSupport.generateUniqueSeed()); // Gale - Pufferfish - move random tick random
|
||||
+ public final net.minecraft.world.level.levelgen.BitRandomSource simpleRandom = org.dreeam.leaf.config.modules.opt.FastRNG.enabled ? new org.dreeam.leaf.util.math.random.FasterRandomSource(net.minecraft.world.level.levelgen.RandomSupport.generateUniqueSeed()) : new ca.spottedleaf.moonrise.common.util.SimpleThreadUnsafeRandom(net.minecraft.world.level.levelgen.RandomSupport.generateUniqueSeed()); // Gale - Pufferfish - move random tick random // Leaf - Faster random generator
|
||||
|
||||
// Purpur start - Add adjustable breeding cooldown to config
|
||||
private com.google.common.cache.Cache<BreedingCooldownPair, Object> playerBreedingCooldowns;
|
||||
diff --git a/net/minecraft/world/level/biome/Biome.java b/net/minecraft/world/level/biome/Biome.java
|
||||
index f44461f92a10cbfdb8fcdbc3a2442e526b9d3d33..b4c5eea26e87ee6f466c53a6dd0867909df7e848 100644
|
||||
--- a/net/minecraft/world/level/biome/Biome.java
|
||||
+++ b/net/minecraft/world/level/biome/Biome.java
|
||||
@@ -54,14 +54,14 @@ public final class Biome {
|
||||
);
|
||||
public static final Codec<Holder<Biome>> CODEC = RegistryFileCodec.create(Registries.BIOME, DIRECT_CODEC);
|
||||
public static final Codec<HolderSet<Biome>> LIST_CODEC = RegistryCodecs.homogeneousList(Registries.BIOME, DIRECT_CODEC);
|
||||
- private static final PerlinSimplexNoise TEMPERATURE_NOISE = new PerlinSimplexNoise(new WorldgenRandom(new LegacyRandomSource(1234L)), ImmutableList.of(0));
|
||||
+ private static final PerlinSimplexNoise TEMPERATURE_NOISE = new PerlinSimplexNoise(new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(1234L) : new LegacyRandomSource(1234L)), ImmutableList.of(0)); // Leaf - Faster random generator
|
||||
static final PerlinSimplexNoise FROZEN_TEMPERATURE_NOISE = new PerlinSimplexNoise(
|
||||
- new WorldgenRandom(new LegacyRandomSource(3456L)), ImmutableList.of(-2, -1, 0)
|
||||
+ new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(3456L) : new LegacyRandomSource(3456L)), ImmutableList.of(-2, -1, 0) // Leaf - Faster random generator
|
||||
);
|
||||
@Deprecated(
|
||||
forRemoval = true
|
||||
)
|
||||
- public static final PerlinSimplexNoise BIOME_INFO_NOISE = new PerlinSimplexNoise(new WorldgenRandom(new LegacyRandomSource(2345L)), ImmutableList.of(0));
|
||||
+ public static final PerlinSimplexNoise BIOME_INFO_NOISE = new PerlinSimplexNoise(new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(2345L) : new LegacyRandomSource(2345L)), ImmutableList.of(0)); // Leaf - Faster random generator
|
||||
private static final int TEMPERATURE_CACHE_SIZE = 1024;
|
||||
public final Biome.ClimateSettings climateSettings;
|
||||
private final BiomeGenerationSettings generationSettings;
|
||||
diff --git a/net/minecraft/world/level/chunk/ChunkGenerator.java b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
index 8a4ce8b3b050ad9fb7de007129f5f460110d0b09..176adfcaa0fc458043d4bc05ead1861864b63606 100644
|
||||
--- a/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
+++ b/net/minecraft/world/level/chunk/ChunkGenerator.java
|
||||
@@ -458,7 +458,7 @@ public abstract class ChunkGenerator {
|
||||
int x = chunk.getPos().x;
|
||||
int z = chunk.getPos().z;
|
||||
for (org.bukkit.generator.BlockPopulator populator : world.getPopulators()) {
|
||||
- WorldgenRandom seededrandom = new WorldgenRandom(new net.minecraft.world.level.levelgen.LegacyRandomSource(level.getSeed()));
|
||||
+ WorldgenRandom seededrandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(level.getSeed()) : new net.minecraft.world.level.levelgen.LegacyRandomSource(level.getSeed())); // Leaf - Faster random generator
|
||||
seededrandom.setDecorationSeed(level.getSeed(), x, z);
|
||||
populator.populate(world, new org.bukkit.craftbukkit.util.RandomSourceWrapper.RandomWrapper(seededrandom), x, z, limitedRegion);
|
||||
}
|
||||
@@ -565,7 +565,7 @@ public abstract class ChunkGenerator {
|
||||
if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(pos.x, pos.z, su.plo.matter.Globals.Salt.GENERATE_FEATURE, 0);
|
||||
} else {
|
||||
- worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
||||
worldgenRandom.setLargeFeatureSeed(structureState.getLevelSeed(), pos.x, pos.z);
|
||||
}
|
||||
// Leaf end - Matter - Secure Seed
|
||||
diff --git a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||
index 426692d9627f46d708f551bd22ce3c52b2a23b37..8a19fd2b816b07a7374cb9dc96896a122f95db20 100644
|
||||
--- a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||
+++ b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||
@@ -208,7 +208,7 @@ public class ChunkGeneratorStructureState {
|
||||
// Leaf start - Matter - Secure Seed
|
||||
RandomSource randomSource = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
||||
? new su.plo.matter.WorldgenCryptoRandom(0, 0, su.plo.matter.Globals.Salt.STRONGHOLDS, 0)
|
||||
- : RandomSource.create();
|
||||
+ : RandomSource.createLegacy(); // Leaf - Faster random generator
|
||||
// Leaf end - Matter - Secure Seed
|
||||
if (!org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
// Paper start - Add missing structure set seed configs
|
||||
diff --git a/net/minecraft/world/level/levelgen/DensityFunctions.java b/net/minecraft/world/level/levelgen/DensityFunctions.java
|
||||
index 04527a5c65ad630f794fed9071d485aedd02257a..15fc39f9c77fdd03a0ca4a39d173c851b9454f08 100644
|
||||
--- a/net/minecraft/world/level/levelgen/DensityFunctions.java
|
||||
+++ b/net/minecraft/world/level/levelgen/DensityFunctions.java
|
||||
@@ -518,7 +518,7 @@ public final class DensityFunctions {
|
||||
// Paper end - Perf: Optimize end generation
|
||||
|
||||
public EndIslandDensityFunction(long seed) {
|
||||
- RandomSource randomSource = new LegacyRandomSource(seed);
|
||||
+ RandomSource randomSource = org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed) : new LegacyRandomSource(seed); // Leaf - Faster random generator
|
||||
randomSource.consumeCount(17292);
|
||||
this.islandNoise = new SimplexNoise(randomSource);
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||
index 65728ef17e63d71833677fdcbd5bb90794b4822b..57ae4aaf1431021daf77c5638038d4910a358155 100644
|
||||
--- a/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||
+++ b/net/minecraft/world/level/levelgen/NoiseBasedChunkGenerator.java
|
||||
@@ -254,7 +254,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
||||
WorldGenRegion level, long seed, RandomState random, BiomeManager biomeManager, StructureManager structureManager, ChunkAccess chunk
|
||||
) {
|
||||
BiomeManager biomeManager1 = biomeManager.withDifferentSource((x, y, z) -> this.biomeSource.getNoiseBiome(x, y, z, random.sampler()));
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(RandomSupport.generateUniqueSeed()));
|
||||
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateUniqueSeed()) : new LegacyRandomSource(RandomSupport.generateUniqueSeed())); // Leaf - Faster random generator
|
||||
int i = 8;
|
||||
ChunkPos pos = chunk.getPos();
|
||||
NoiseChunk noiseChunk = chunk.getOrCreateNoiseChunk(chunkAccess -> this.createNoiseChunk(chunkAccess, structureManager, Blender.of(level), random));
|
||||
@@ -420,7 +420,7 @@ public final class NoiseBasedChunkGenerator extends ChunkGenerator {
|
||||
if (!this.settings.value().disableMobGeneration()) {
|
||||
ChunkPos center = level.getCenter();
|
||||
Holder<Biome> biome = level.getBiome(center.getWorldPosition().atY(level.getMaxY()));
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(RandomSupport.generateUniqueSeed()));
|
||||
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateUniqueSeed()) : new LegacyRandomSource(RandomSupport.generateUniqueSeed())); // Leaf - Faster random generator
|
||||
worldgenRandom.setDecorationSeed(level.getSeed(), center.getMinBlockX(), center.getMinBlockZ());
|
||||
NaturalSpawner.spawnMobsForChunkGeneration(level, biome, center, worldgenRandom);
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/levelgen/WorldgenRandom.java b/net/minecraft/world/level/levelgen/WorldgenRandom.java
|
||||
index c2d7cd788071e25b8ba2503c30ae80c7a9f353ed..a22508c50b34ca48328595cc7b69e008bf17d370 100644
|
||||
--- a/net/minecraft/world/level/levelgen/WorldgenRandom.java
|
||||
+++ b/net/minecraft/world/level/levelgen/WorldgenRandom.java
|
||||
@@ -69,7 +69,7 @@ public class WorldgenRandom extends LegacyRandomSource {
|
||||
}
|
||||
|
||||
public static RandomSource seedSlimeChunk(int chunkX, int chunkZ, long levelSeed, long salt) {
|
||||
- return RandomSource.create(levelSeed + chunkX * chunkX * 4987142 + chunkX * 5947611 + chunkZ * chunkZ * 4392871L + chunkZ * 389711 ^ salt);
|
||||
+ return RandomSource.createForSlimeChunk(levelSeed + chunkX * chunkX * 4987142 + chunkX * 5947611 + chunkZ * chunkZ * 4392871L + chunkZ * 389711 ^ salt); // Leaf - Faster random generator
|
||||
}
|
||||
|
||||
public static enum Algorithm {
|
||||
diff --git a/net/minecraft/world/level/levelgen/feature/GeodeFeature.java b/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
||||
index f73bd2d86b2fcffa55cd8cc82aa1febe3467c87a..0ebdc328a6884ab5898681c7d74714bd137d1351 100644
|
||||
--- a/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
||||
+++ b/net/minecraft/world/level/levelgen/feature/GeodeFeature.java
|
||||
@@ -44,7 +44,7 @@ public class GeodeFeature extends Feature<GeodeConfiguration> {
|
||||
// Leaf start - Matter - Secure Seed
|
||||
WorldgenRandom worldgenRandom = org.dreeam.leaf.config.modules.misc.SecureSeed.enabled
|
||||
? new su.plo.matter.WorldgenCryptoRandom(0, 0, su.plo.matter.Globals.Salt.GEODE_FEATURE, 0)
|
||||
- : new WorldgenRandom(new LegacyRandomSource(worldGenLevel.getSeed()));
|
||||
+ : new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(worldGenLevel.getSeed()) : new LegacyRandomSource(worldGenLevel.getSeed())); // Leaf - Faster random generator
|
||||
// Leaf end - Matter - Secure Seed
|
||||
NormalNoise normalNoise = NormalNoise.create(worldgenRandom, -4, 1.0);
|
||||
List<BlockPos> list1 = Lists.newLinkedList();
|
||||
diff --git a/net/minecraft/world/level/levelgen/feature/stateproviders/DualNoiseProvider.java b/net/minecraft/world/level/levelgen/feature/stateproviders/DualNoiseProvider.java
|
||||
index 48ab8a568d97052fe205e6a1f89862ee23d65abb..a190b5e890cf34dd1aa46cb9e283f05154fbe3e5 100644
|
||||
--- a/net/minecraft/world/level/levelgen/feature/stateproviders/DualNoiseProvider.java
|
||||
+++ b/net/minecraft/world/level/levelgen/feature/stateproviders/DualNoiseProvider.java
|
||||
@@ -43,7 +43,7 @@ public class DualNoiseProvider extends NoiseProvider {
|
||||
this.variety = variety;
|
||||
this.slowNoiseParameters = slowNoiseParameters;
|
||||
this.slowScale = slowScale;
|
||||
- this.slowNoise = NormalNoise.create(new WorldgenRandom(new LegacyRandomSource(seed)), slowNoiseParameters);
|
||||
+ this.slowNoise = NormalNoise.create(new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed) : new LegacyRandomSource(seed)), slowNoiseParameters); // Leaf - Faster random generator
|
||||
}
|
||||
|
||||
@Override
|
||||
diff --git a/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java b/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java
|
||||
index f685372a39976f823202f2d9015c14f835b94a0c..bdd1b4ab758fc653df4adad7633ef430ebb89dbe 100644
|
||||
--- a/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java
|
||||
+++ b/net/minecraft/world/level/levelgen/feature/stateproviders/NoiseBasedStateProvider.java
|
||||
@@ -28,7 +28,7 @@ public abstract class NoiseBasedStateProvider extends BlockStateProvider {
|
||||
this.seed = seed;
|
||||
this.parameters = parameters;
|
||||
this.scale = scale;
|
||||
- this.noise = NormalNoise.create(new WorldgenRandom(new LegacyRandomSource(seed)), parameters);
|
||||
+ this.noise = NormalNoise.create(new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(seed) : new LegacyRandomSource(seed)), parameters); // Leaf - Faster random generator
|
||||
}
|
||||
|
||||
protected double getNoiseValue(BlockPos pos, double delta) {
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/Structure.java b/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
index 28281491be6b54de18c49ff0d52e302575d3ad38..3aa35d67df8f9118c944cebfcb675cccd9d99be2 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/Structure.java
|
||||
@@ -254,7 +254,7 @@ public abstract class Structure {
|
||||
return new su.plo.matter.WorldgenCryptoRandom(chunkPos.x, chunkPos.z, su.plo.matter.Globals.Salt.GENERATE_FEATURE, seed);
|
||||
}
|
||||
// Leaf end - Matter - Secure Seed
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
||||
worldgenRandom.setLargeFeatureSeed(seed, chunkPos.x, chunkPos.z);
|
||||
return worldgenRandom;
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java b/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
||||
index 6584c9320361dbbdea1899ab9e43b444de5006a6..06083cc7612ef28bcd9264bb21ab0bbbe0837589 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/placement/RandomSpreadStructurePlacement.java
|
||||
@@ -72,7 +72,7 @@ public class RandomSpreadStructurePlacement extends StructurePlacement {
|
||||
if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(i, i1, su.plo.matter.Globals.Salt.POTENTIONAL_FEATURE, this.salt);
|
||||
} else {
|
||||
- worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
||||
worldgenRandom.setLargeFeatureWithSalt(seed, i, i1, this.salt());
|
||||
}
|
||||
// Leaf end - Matter - Secure Seed
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java b/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
||||
index aaf80406af22af288b1b2e36a7a5d00c26c5afa5..c74313a305fffadb85c84d8746e9d338ce55ea80 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/placement/StructurePlacement.java
|
||||
@@ -123,7 +123,7 @@ public abstract class StructurePlacement {
|
||||
if (org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) {
|
||||
worldgenRandom = new su.plo.matter.WorldgenCryptoRandom(regionX, regionZ, su.plo.matter.Globals.Salt.UNDEFINED, salt);
|
||||
} else {
|
||||
- worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
||||
worldgenRandom.setLargeFeatureWithSalt(levelSeed, salt, regionX, regionZ);
|
||||
}
|
||||
// Leaf end - Matter - Secure Seed
|
||||
@@ -132,7 +132,7 @@ public abstract class StructurePlacement {
|
||||
}
|
||||
|
||||
private static boolean legacyProbabilityReducerWithDouble(long baseSeed, int salt, int chunkX, int chunkZ, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
||||
if (saltOverride == null) { // Paper - Add missing structure set seed configs
|
||||
worldgenRandom.setLargeFeatureSeed(baseSeed, chunkX, chunkZ);
|
||||
// Paper start - Add missing structure set seed configs
|
||||
@@ -144,7 +144,7 @@ public abstract class StructurePlacement {
|
||||
}
|
||||
|
||||
private static boolean legacyArbitrarySaltProbabilityReducer(long levelSeed, int salt, int regionX, int regionZ, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
||||
worldgenRandom.setLargeFeatureWithSalt(levelSeed, regionX, regionZ, saltOverride != null ? saltOverride : HIGHLY_ARBITRARY_RANDOM_SALT); // Paper - Add missing structure set seed configs
|
||||
return worldgenRandom.nextFloat() < probability;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public abstract class StructurePlacement {
|
||||
private static boolean legacyPillagerOutpostReducer(long levelSeed, int salt, int regionX, int regionZ, float probability, @org.jetbrains.annotations.Nullable Integer saltOverride) { // Paper - Add missing structure set seed configs; ignore here
|
||||
int i = regionX >> 4;
|
||||
int i1 = regionZ >> 4;
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(0L));
|
||||
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(0L) : new LegacyRandomSource(0L)); // Leaf - Faster random generator
|
||||
worldgenRandom.setSeed(i ^ i1 << 4 ^ levelSeed);
|
||||
worldgenRandom.nextInt();
|
||||
return worldgenRandom.nextInt((int)(1.0F / probability)) == 0;
|
||||
diff --git a/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java b/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java
|
||||
index 6941b2c89df8a7c77166e3fb76150cbc852371d9..661c26c4b981d504988c7498be45a5ddacaf90d8 100644
|
||||
--- a/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java
|
||||
+++ b/net/minecraft/world/level/levelgen/structure/structures/OceanMonumentStructure.java
|
||||
@@ -56,7 +56,7 @@ public class OceanMonumentStructure extends Structure {
|
||||
if (piecesContainer.isEmpty()) {
|
||||
return piecesContainer;
|
||||
} else {
|
||||
- WorldgenRandom worldgenRandom = new WorldgenRandom(new LegacyRandomSource(RandomSupport.generateUniqueSeed()));
|
||||
+ WorldgenRandom worldgenRandom = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(RandomSupport.generateUniqueSeed()) : new LegacyRandomSource(RandomSupport.generateUniqueSeed())); // Leaf - Faster random generator
|
||||
worldgenRandom.setLargeFeatureSeed(seed, chunkPos.x, chunkPos.z);
|
||||
StructurePiece structurePiece = piecesContainer.pieces().get(0);
|
||||
BoundingBox boundingBox = structurePiece.getBoundingBox();
|
||||
diff --git a/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java b/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java
|
||||
index 434e72fd770a259d67e5e7f110f49b09bab6c54e..720098d50ecefeff25e8f032e33742ad6bd6ab21 100644
|
||||
--- a/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java
|
||||
+++ b/net/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.java
|
||||
@@ -43,7 +43,7 @@ public class PerlinSimplexNoise {
|
||||
|
||||
if (i1 > 0) {
|
||||
long l = (long)(simplexNoise.getValue(simplexNoise.xo, simplexNoise.yo, simplexNoise.zo) * 9.223372E18F);
|
||||
- RandomSource randomSource = new WorldgenRandom(new LegacyRandomSource(l));
|
||||
+ RandomSource randomSource = new WorldgenRandom(org.dreeam.leaf.config.modules.opt.FastRNG.worldgenEnabled() ? new org.dreeam.leaf.util.math.random.FasterRandomSource(l) : new LegacyRandomSource(l)); // Leaf - Faster random generator
|
||||
|
||||
for (int i5 = i3 - 1; i5 >= 0; i5--) {
|
||||
if (i5 < i2 && octaves.contains(i3 - i5)) {
|
||||
@@ -1,22 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: nostalfinals <yuu8583@proton.me>
|
||||
Date: Mon, 29 Apr 2024 23:30:21 +0800
|
||||
Subject: [PATCH] Don't save primed tnt entity
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
index 40f5534b425ef57c435b365f156d3b988b74f911..c96f458994818392857642282ec3d492124885da 100644
|
||||
--- a/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
+++ b/net/minecraft/world/entity/item/PrimedTnt.java
|
||||
@@ -279,4 +279,11 @@ public class PrimedTnt extends Entity implements TraceableEntity {
|
||||
return super.interact(player, hand);
|
||||
}
|
||||
// Purpur end - Shears can defuse TNT
|
||||
+
|
||||
+ // Leaf start - PMC - Don't save primed tnt entity
|
||||
+ @Override
|
||||
+ public boolean shouldBeSaved() {
|
||||
+ return !org.dreeam.leaf.config.modules.opt.DontSaveEntity.dontSavePrimedTNT && super.shouldBeSaved();
|
||||
+ }
|
||||
+ // Leaf - PMC - Don't save primed tnt entity
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: nostalfinals <yuu8583@proton.me>
|
||||
Date: Mon, 29 Apr 2024 23:31:25 +0800
|
||||
Subject: [PATCH] Don't save falling block entity
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
index 5746587666c7cb788764aab2f6ccf0f3ac5c282f..fd2f93b070f96d28a8c694a6d943d92d257d0c9e 100644
|
||||
--- a/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
+++ b/net/minecraft/world/entity/item/FallingBlockEntity.java
|
||||
@@ -404,4 +404,11 @@ public class FallingBlockEntity extends Entity {
|
||||
this.forceTickAfterTeleportToDuplicate = entity != null && flag && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation; // Paper
|
||||
return entity;
|
||||
}
|
||||
+
|
||||
+ // Leaf start - PMC - Don't save falling block entity
|
||||
+ @Override
|
||||
+ public boolean shouldBeSaved() {
|
||||
+ return !org.dreeam.leaf.config.modules.opt.DontSaveEntity.dontSaveFallingBlock && super.shouldBeSaved();
|
||||
+ }
|
||||
+ // Leaf end - PMC - Don't save falling block entity
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Sun, 2 Jun 2024 01:21:36 +0800
|
||||
Subject: [PATCH] Configurable connection message
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java
|
||||
index e8683f45823cac55e3e68ccc500f10f0632e72fd..c9a3dd3e2b17ef8d5457766bdc2bea19a1948426 100644
|
||||
--- a/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/net/minecraft/server/players/PlayerList.java
|
||||
@@ -434,7 +434,7 @@ public abstract class PlayerList {
|
||||
// Ensure that player inventory is populated with its viewer
|
||||
player.containerMenu.transferTo(player.containerMenu, bukkitPlayer);
|
||||
|
||||
- org.bukkit.event.player.PlayerJoinEvent playerJoinEvent = new org.bukkit.event.player.PlayerJoinEvent(bukkitPlayer, io.papermc.paper.adventure.PaperAdventure.asAdventure(mutableComponent)); // Paper - Adventure
|
||||
+ org.bukkit.event.player.PlayerJoinEvent playerJoinEvent = new org.bukkit.event.player.PlayerJoinEvent(bukkitPlayer, getJoinMsg(mutableComponent, bukkitPlayer)); // Paper - Adventure // Leaf - Configurable connection message - join message
|
||||
this.cserver.getPluginManager().callEvent(playerJoinEvent);
|
||||
|
||||
if (!player.connection.isAcceptingMessages()) {
|
||||
@@ -447,7 +447,7 @@ public abstract class PlayerList {
|
||||
|
||||
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();
|
||||
|
||||
- if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure
|
||||
+ if (org.dreeam.leaf.config.modules.misc.ConnectionMessage.joinEnabled && jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure // Leaf - Configurable connection message - join message
|
||||
joinMessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(jm); // Paper - Adventure
|
||||
this.server.getPlayerList().broadcastSystemMessage(joinMessage, false); // Paper - Adventure
|
||||
}
|
||||
@@ -677,7 +677,7 @@ public abstract class PlayerList {
|
||||
player.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper - Inventory close reason
|
||||
}
|
||||
|
||||
- org.bukkit.event.player.PlayerQuitEvent playerQuitEvent = new org.bukkit.event.player.PlayerQuitEvent(player.getBukkitEntity(), leaveMessage, player.quitReason); // Paper - Adventure & Add API for quit reason
|
||||
+ org.bukkit.event.player.PlayerQuitEvent playerQuitEvent = new org.bukkit.event.player.PlayerQuitEvent(player.getBukkitEntity(), getQuitMsg(leaveMessage, player.getBukkitEntity()), player.quitReason); // Paper - Adventure & Add API for quit reason // Leaf - Configurable connection message - quit message
|
||||
this.cserver.getPluginManager().callEvent(playerQuitEvent);
|
||||
player.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage());
|
||||
|
||||
@@ -1673,4 +1673,34 @@ public abstract class PlayerList {
|
||||
public boolean isAllowCommandsForAllPlayers() {
|
||||
return this.allowCommandsForAllPlayers;
|
||||
}
|
||||
+
|
||||
+ // Leaf start - Configurable connection message
|
||||
+ private net.kyori.adventure.text.Component getJoinMsg(MutableComponent defaultJoinMsg, org.bukkit.craftbukkit.entity.CraftPlayer craftPlayer) {
|
||||
+ if (org.dreeam.leaf.config.modules.misc.ConnectionMessage.joinEnabled) {
|
||||
+ if ("default".equals(org.dreeam.leaf.config.modules.misc.ConnectionMessage.joinMessage)) {
|
||||
+ return io.papermc.paper.adventure.PaperAdventure.asAdventure(defaultJoinMsg);
|
||||
+ }
|
||||
+
|
||||
+ return net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.dreeam.leaf.config.modules.misc.ConnectionMessage.joinMessage)
|
||||
+ .replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("<player_name>").replacement(craftPlayer.getName()).build())
|
||||
+ .replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("<player_displayname>").replacement(craftPlayer.displayName()).build());
|
||||
+ }
|
||||
+
|
||||
+ return net.kyori.adventure.text.Component.empty();
|
||||
+ }
|
||||
+
|
||||
+ private net.kyori.adventure.text.Component getQuitMsg(net.kyori.adventure.text.Component defaultJoinMsg, org.bukkit.craftbukkit.entity.CraftPlayer craftPlayer) {
|
||||
+ if (org.dreeam.leaf.config.modules.misc.ConnectionMessage.quitEnabled) {
|
||||
+ if ("default".equals(org.dreeam.leaf.config.modules.misc.ConnectionMessage.quitMessage)) {
|
||||
+ return defaultJoinMsg;
|
||||
+ }
|
||||
+
|
||||
+ return net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.dreeam.leaf.config.modules.misc.ConnectionMessage.quitMessage)
|
||||
+ .replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("<player_name>").replacement(craftPlayer.getName()).build())
|
||||
+ .replaceText(net.kyori.adventure.text.TextReplacementConfig.builder().matchLiteral("<player_displayname>").replacement(craftPlayer.displayName()).build());
|
||||
+ }
|
||||
+
|
||||
+ return net.kyori.adventure.text.Component.empty();
|
||||
+ }
|
||||
+ // Leaf end - Configurable connection message
|
||||
}
|
||||
@@ -1,131 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Wed, 7 Aug 2024 18:54:01 +0800
|
||||
Subject: [PATCH] Configurable unknown command message
|
||||
|
||||
|
||||
diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java
|
||||
index fb18f69cb26132fc8c53b185454c6aadb8a5f7e5..eff6d524c8acfc62d1fcf6b5552754e794a22735 100644
|
||||
--- a/net/minecraft/commands/Commands.java
|
||||
+++ b/net/minecraft/commands/Commands.java
|
||||
@@ -404,31 +404,9 @@ public class Commands {
|
||||
// Paper start - Add UnknownCommandEvent
|
||||
final net.kyori.adventure.text.TextComponent.Builder builder = net.kyori.adventure.text.Component.text();
|
||||
// source.sendFailure(ComponentUtils.fromMessage(var7.getRawMessage()));
|
||||
- builder.color(net.kyori.adventure.text.format.NamedTextColor.RED).append(io.papermc.paper.command.brigadier.MessageComponentSerializer.message().deserialize(var7.getRawMessage()));
|
||||
+ final net.kyori.adventure.text.TextComponent message = getUnknownCommandMessage(builder, var7, label); // Leaf - Configurable unknown command message
|
||||
// Paper end - Add UnknownCommandEvent
|
||||
- if (var7.getInput() != null && var7.getCursor() >= 0) {
|
||||
- int min = Math.min(var7.getInput().length(), var7.getCursor());
|
||||
- MutableComponent mutableComponent = Component.empty()
|
||||
- .withStyle(ChatFormatting.GRAY)
|
||||
- .withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + label))); // CraftBukkit // Paper
|
||||
- if (min > 10) {
|
||||
- mutableComponent.append(CommonComponents.ELLIPSIS);
|
||||
- }
|
||||
-
|
||||
- mutableComponent.append(var7.getInput().substring(Math.max(0, min - 10), min));
|
||||
- if (min < var7.getInput().length()) {
|
||||
- Component component = Component.literal(var7.getInput().substring(min)).withStyle(ChatFormatting.RED, ChatFormatting.UNDERLINE);
|
||||
- mutableComponent.append(component);
|
||||
- }
|
||||
-
|
||||
- mutableComponent.append(Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC));
|
||||
- // Paper start - Add UnknownCommandEvent
|
||||
- // source.sendFailure(mutableComponent);
|
||||
- builder
|
||||
- .append(net.kyori.adventure.text.Component.newline())
|
||||
- .append(io.papermc.paper.adventure.PaperAdventure.asAdventure(mutableComponent));
|
||||
- }
|
||||
- org.bukkit.event.command.UnknownCommandEvent event = new org.bukkit.event.command.UnknownCommandEvent(source.getBukkitSender(), command, org.spigotmc.SpigotConfig.unknownCommandMessage.isEmpty() ? null : builder.build());
|
||||
+ org.bukkit.event.command.UnknownCommandEvent event = new org.bukkit.event.command.UnknownCommandEvent(source.getBukkitSender(), command, message); // Leaf - Configurable unknown command message
|
||||
org.bukkit.Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.message() != null) {
|
||||
source.sendFailure(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.message()), false);
|
||||
@@ -680,6 +658,86 @@ public class Commands {
|
||||
};
|
||||
}
|
||||
|
||||
+ // Leaf start - Configurable unknown command message
|
||||
+ private static net.kyori.adventure.text.TextComponent getUnknownCommandMessage(
|
||||
+ net.kyori.adventure.text.TextComponent.Builder builder, CommandSyntaxException commandSyntaxException, String label
|
||||
+ ) {
|
||||
+ String rawMessage = org.dreeam.leaf.config.modules.misc.UnknownCommandMessage.unknownCommandMessage;
|
||||
+
|
||||
+ if (!"default".equals(rawMessage)) {
|
||||
+ final String input = commandSyntaxException.getInput();
|
||||
+ final int cursor = commandSyntaxException.getCursor();
|
||||
+
|
||||
+ if (rawMessage.contains("<detail>") && input != null && cursor >= 0) {
|
||||
+ final int min = Math.min(input.length(), cursor);
|
||||
+ final net.kyori.adventure.text.TextComponent.Builder detail = net.kyori.adventure.text.Component.text();
|
||||
+ final net.kyori.adventure.text.Component context = net.kyori.adventure.text.Component.translatable("command.context.here")
|
||||
+ .color(net.kyori.adventure.text.format.NamedTextColor.RED)
|
||||
+ .decorate(net.kyori.adventure.text.format.TextDecoration.ITALIC);
|
||||
+ final net.kyori.adventure.text.event.ClickEvent event = net.kyori.adventure.text.event.ClickEvent.suggestCommand("/" + label);
|
||||
+
|
||||
+ detail.color(net.kyori.adventure.text.format.NamedTextColor.GRAY);
|
||||
+
|
||||
+ if (min > 10) {
|
||||
+ detail.append(net.kyori.adventure.text.Component.text("..."));
|
||||
+ }
|
||||
+
|
||||
+ detail.append(net.kyori.adventure.text.Component.text(input.substring(Math.max(0, min - 10), min)));
|
||||
+ if (min < input.length()) {
|
||||
+ net.kyori.adventure.text.Component commandInput = net.kyori.adventure.text.Component.text(input.substring(min))
|
||||
+ .color(net.kyori.adventure.text.format.NamedTextColor.RED)
|
||||
+ .decorate(net.kyori.adventure.text.format.TextDecoration.UNDERLINED);
|
||||
+
|
||||
+ detail.append(commandInput);
|
||||
+ }
|
||||
+
|
||||
+ detail.append(context);
|
||||
+ detail.clickEvent(event);
|
||||
+
|
||||
+ builder.append(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(rawMessage, net.kyori.adventure.text.minimessage.tag.resolver.Placeholder.component("detail", detail.build())));
|
||||
+ } else {
|
||||
+ rawMessage = rawMessage.replace("<detail>", "");
|
||||
+ builder.append(net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(rawMessage));
|
||||
+ }
|
||||
+
|
||||
+ return builder.build();
|
||||
+ }
|
||||
+
|
||||
+ return getVanillaUnknownCommandMessage(builder, commandSyntaxException, label);
|
||||
+ }
|
||||
+
|
||||
+ private static net.kyori.adventure.text.TextComponent getVanillaUnknownCommandMessage(
|
||||
+ net.kyori.adventure.text.TextComponent.Builder builder, CommandSyntaxException var7, String label
|
||||
+ ) {
|
||||
+ builder.color(net.kyori.adventure.text.format.NamedTextColor.RED).append(io.papermc.paper.command.brigadier.MessageComponentSerializer.message().deserialize(var7.getRawMessage()));
|
||||
+
|
||||
+ if (var7.getInput() != null && var7.getCursor() >= 0) {
|
||||
+ int min = Math.min(var7.getInput().length(), var7.getCursor());
|
||||
+ MutableComponent mutableComponent = Component.empty()
|
||||
+ .withStyle(ChatFormatting.GRAY)
|
||||
+ .withStyle(style -> style.withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/" + label))); // CraftBukkit // Paper
|
||||
+ if (min > 10) {
|
||||
+ mutableComponent.append(CommonComponents.ELLIPSIS);
|
||||
+ }
|
||||
+
|
||||
+ mutableComponent.append(var7.getInput().substring(Math.max(0, min - 10), min));
|
||||
+ if (min < var7.getInput().length()) {
|
||||
+ Component component = Component.literal(var7.getInput().substring(min)).withStyle(ChatFormatting.RED, ChatFormatting.UNDERLINE);
|
||||
+ mutableComponent.append(component);
|
||||
+ }
|
||||
+
|
||||
+ mutableComponent.append(Component.translatable("command.context.here").withStyle(ChatFormatting.RED, ChatFormatting.ITALIC));
|
||||
+ // Paper start - Add UnknownCommandEvent
|
||||
+ // source.sendFailure(mutableComponent);
|
||||
+ builder
|
||||
+ .append(net.kyori.adventure.text.Component.newline())
|
||||
+ .append(io.papermc.paper.adventure.PaperAdventure.asAdventure(mutableComponent));
|
||||
+ }
|
||||
+
|
||||
+ return builder.build();
|
||||
+ }
|
||||
+ // Leaf end - Configurable unknown command message
|
||||
+
|
||||
public static void validate() {
|
||||
CommandBuildContext commandBuildContext = createValidationContext(VanillaRegistries.createLookup());
|
||||
CommandDispatcher<CommandSourceStack> dispatcher = new Commands(Commands.CommandSelection.ALL, commandBuildContext).getDispatcher();
|
||||
@@ -1,27 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Fri, 7 Jun 2024 17:43:43 +0800
|
||||
Subject: [PATCH] Remove stream in BlockBehaviour cache blockstate
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
index bf77d02d8fc58b5a16c67a305fe0991ad08a795c..117c7cedb9f355b5139b9aa9b15f4459453e3675 100644
|
||||
--- a/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
+++ b/net/minecraft/world/level/block/state/BlockBehaviour.java
|
||||
@@ -1067,8 +1067,14 @@ public abstract class BlockBehaviour implements FeatureElement {
|
||||
)
|
||||
);
|
||||
} else {
|
||||
- this.largeCollisionShape = Arrays.stream(Direction.Axis.values())
|
||||
- .anyMatch(dir -> this.collisionShape.min(dir) < 0.0 || this.collisionShape.max(dir) > 1.0);
|
||||
+ // Leaf start - Remove stream in BlockBehaviour cache blockstate
|
||||
+ for (Direction.Axis axis : Direction.Axis.values()) {
|
||||
+ if (this.collisionShape.min(axis) < 0.0 || this.collisionShape.max(axis) > 1.0) {
|
||||
+ this.largeCollisionShape = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in BlockBehaviour cache blockstate
|
||||
this.faceSturdy = new boolean[DIRECTIONS.length * SUPPORT_TYPE_COUNT];
|
||||
|
||||
for (Direction direction : DIRECTIONS) {
|
||||
@@ -1,32 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Tue, 17 Sep 2024 02:26:44 -0400
|
||||
Subject: [PATCH] Remove stream in entity visible effects filter
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index ca1d8c9ea018368cc85da46185aee71df8d48ce0..a307ee08f12cb21d17cfbaf969db7c46f10040fb 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -988,12 +988,15 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
}
|
||||
|
||||
private void updateSynchronizedMobEffectParticles() {
|
||||
- List<ParticleOptions> list = this.activeEffects
|
||||
- .values()
|
||||
- .stream()
|
||||
- .filter(MobEffectInstance::isVisible)
|
||||
- .map(MobEffectInstance::getParticleOptions)
|
||||
- .toList();
|
||||
+ // Leaf start - Remove stream in entity visible effects filter
|
||||
+ List<ParticleOptions> list = new ArrayList<>();
|
||||
+
|
||||
+ for (MobEffectInstance effect : this.activeEffects.values()) {
|
||||
+ if (effect.isVisible()) {
|
||||
+ list.add(effect.getParticleOptions());
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in entity visible effects filter
|
||||
this.entityData.set(DATA_EFFECT_PARTICLES, list);
|
||||
this.entityData.set(DATA_EFFECT_AMBIENCE_ID, areAllEffectsAmbient(this.activeEffects.values()));
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Thu, 17 Oct 2024 01:51:38 -0400
|
||||
Subject: [PATCH] Remove stream and double iteration in enough deep sleeping
|
||||
player check
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/players/SleepStatus.java b/net/minecraft/server/players/SleepStatus.java
|
||||
index 3a3e6992563236141db687084aeec9684437a7db..e6827e90b685f88d945010f2c8c5aead52b0856e 100644
|
||||
--- a/net/minecraft/server/players/SleepStatus.java
|
||||
+++ b/net/minecraft/server/players/SleepStatus.java
|
||||
@@ -15,9 +15,24 @@ public class SleepStatus {
|
||||
|
||||
public boolean areEnoughDeepSleeping(int requiredSleepPercentage, List<ServerPlayer> sleepingPlayers) {
|
||||
// CraftBukkit start
|
||||
- int i = (int) sleepingPlayers.stream().filter(player -> player.isSleepingLongEnough() || player.fauxSleeping || (player.level().purpurConfig.idleTimeoutCountAsSleeping && player.isAfk())).count(); // Purpur - AFK API
|
||||
- boolean anyDeepSleep = sleepingPlayers.stream().anyMatch(Player::isSleepingLongEnough);
|
||||
- return anyDeepSleep && i >= this.sleepersNeeded(requiredSleepPercentage);
|
||||
+ // Leaf start - Remove stream and double iteration in enough deep sleeping player check
|
||||
+ int count = 0;
|
||||
+ boolean anyPlayerSleeping = false;
|
||||
+
|
||||
+ for (ServerPlayer player : sleepingPlayers) {
|
||||
+ final boolean isSleepingLongEnough = player.isSleepingLongEnough();
|
||||
+
|
||||
+ if (isSleepingLongEnough) {
|
||||
+ anyPlayerSleeping = true;
|
||||
+ }
|
||||
+
|
||||
+ if (isSleepingLongEnough || player.fauxSleeping || (player.level().purpurConfig.idleTimeoutCountAsSleeping && player.isAfk())) { // Purpur - AFK API
|
||||
+ count++;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return anyPlayerSleeping && count >= this.sleepersNeeded(requiredSleepPercentage);
|
||||
+ // Leaf end - Remove stream and double iteration in enough deep sleeping player check
|
||||
// CraftBukkit end
|
||||
}
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Sat, 5 Oct 2024 15:39:15 -0400
|
||||
Subject: [PATCH] Remove stream in trial spawner ticking
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerState.java b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerState.java
|
||||
index 3e8d0c8d8409b6ba2e2846d7d64cdcc8fc6094a4..2f8324ce552f982f6b3388d9fa5a63fb9bee625b 100644
|
||||
--- a/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerState.java
|
||||
+++ b/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerState.java
|
||||
@@ -173,17 +173,21 @@ public enum TrialSpawnerState implements StringRepresentable {
|
||||
}
|
||||
|
||||
private static Optional<Vec3> calculatePositionToSpawnSpawner(ServerLevel level, BlockPos pos, TrialSpawner spawner, TrialSpawnerData spawnerData) {
|
||||
- List<Player> list = spawnerData.detectedPlayers
|
||||
- .stream()
|
||||
- .map(level::getPlayerByUUID)
|
||||
- .filter(Objects::nonNull)
|
||||
- .filter(
|
||||
- player -> !player.isCreative()
|
||||
- && !player.isSpectator()
|
||||
- && player.isAlive()
|
||||
- && player.distanceToSqr(pos.getCenter()) <= Mth.square(spawner.getRequiredPlayerRange())
|
||||
- )
|
||||
- .toList();
|
||||
+ // Leaf start - Remove stream in trial spawner ticking
|
||||
+ List<Player> list = new java.util.ArrayList<>();
|
||||
+
|
||||
+ for (UUID uuid : spawnerData.detectedPlayers) {
|
||||
+ Player player = level.getPlayerByUUID(uuid);
|
||||
+
|
||||
+ if (player != null
|
||||
+ && !player.isCreative()
|
||||
+ && !player.isSpectator()
|
||||
+ && player.isAlive()
|
||||
+ && player.distanceToSqr(pos.getCenter()) <= Mth.square(spawner.getRequiredPlayerRange())) {
|
||||
+ list.add(player);
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in trial spawner ticking
|
||||
if (list.isEmpty()) {
|
||||
return Optional.empty();
|
||||
} else {
|
||||
@@ -203,16 +207,29 @@ public enum TrialSpawnerState implements StringRepresentable {
|
||||
|
||||
@Nullable
|
||||
private static Entity selectEntityToSpawnItemAbove(List<Player> player, Set<UUID> currentMobs, TrialSpawner spawner, BlockPos pos, ServerLevel level) {
|
||||
- Stream<Entity> stream = currentMobs.stream()
|
||||
- .map(level::getEntity)
|
||||
- .filter(Objects::nonNull)
|
||||
- .filter(entity -> entity.isAlive() && entity.distanceToSqr(pos.getCenter()) <= Mth.square(spawner.getRequiredPlayerRange()));
|
||||
- List<? extends Entity> list = level.random.nextBoolean() ? stream.toList() : player;
|
||||
- if (list.isEmpty()) {
|
||||
- return null;
|
||||
+ // Leaf start - Remove stream in trial spawner ticking
|
||||
+ if (level.random.nextBoolean()) {
|
||||
+ List<Entity> list = new java.util.ArrayList<>();
|
||||
+ for (UUID uuid : currentMobs) {
|
||||
+ Entity entity = level.getEntity(uuid);
|
||||
+ if (entity != null && entity.isAlive() && entity.distanceToSqr(pos.getCenter()) <= Mth.square(spawner.getRequiredPlayerRange())) {
|
||||
+ list.add(entity);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (list.isEmpty()) {
|
||||
+ return null;
|
||||
+ } else {
|
||||
+ return list.size() == 1 ? list.getFirst() : Util.getRandom(list, level.random);
|
||||
+ }
|
||||
} else {
|
||||
- return list.size() == 1 ? list.getFirst() : Util.getRandom(list, level.random);
|
||||
+ if (player.isEmpty()) {
|
||||
+ return null;
|
||||
+ } else {
|
||||
+ return player.size() == 1 ? player.getFirst() : Util.getRandom(player, level.random);
|
||||
+ }
|
||||
}
|
||||
+ // Leaf end - Remove stream in trial spawner ticking
|
||||
}
|
||||
|
||||
private boolean timeToSpawnItemSpawner(ServerLevel level, TrialSpawnerData spawnerData) {
|
||||
@@ -1,65 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Sat, 26 Oct 2024 00:06:04 +0800
|
||||
Subject: [PATCH] Remove stream in Brain
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java
|
||||
index 450396468b23fd90cb8036dbbdd0927051f907af..083eb9a7a0bc14d30db944f356d98ca552fa1784 100644
|
||||
--- a/net/minecraft/world/entity/ai/Brain.java
|
||||
+++ b/net/minecraft/world/entity/ai/Brain.java
|
||||
@@ -70,13 +70,22 @@ public class Brain<E extends LivingEntity> {
|
||||
(new MapCodec<Brain<E>>() {
|
||||
@Override
|
||||
public <T> Stream<T> keys(DynamicOps<T> ops) {
|
||||
- return memoryTypes.stream()
|
||||
- .flatMap(
|
||||
- memoryModuleType -> memoryModuleType.getCodec()
|
||||
- .map(codec -> BuiltInRegistries.MEMORY_MODULE_TYPE.getKey((MemoryModuleType<?>)memoryModuleType))
|
||||
- .stream()
|
||||
- )
|
||||
- .map(resourceLocation -> ops.createString(resourceLocation.toString()));
|
||||
+ // Leaf start - Remove stream in Brain
|
||||
+ List<T> results = new java.util.ArrayList<>();
|
||||
+
|
||||
+ for (MemoryModuleType<?> memoryModuleType : memoryTypes) {
|
||||
+ final Optional<?> codec = memoryModuleType.getCodec();
|
||||
+
|
||||
+ if (codec.isPresent()) {
|
||||
+ final net.minecraft.resources.ResourceLocation resourceLocation = BuiltInRegistries.MEMORY_MODULE_TYPE.getKey(memoryModuleType);
|
||||
+ final T opsResult = ops.createString(resourceLocation.toString());
|
||||
+
|
||||
+ results.add(opsResult);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return results.stream();
|
||||
+ // Leaf end - Remove stream in Brain
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -111,7 +120,14 @@ public class Brain<E extends LivingEntity> {
|
||||
|
||||
@Override
|
||||
public <T> RecordBuilder<T> encode(Brain<E> input, DynamicOps<T> ops, RecordBuilder<T> prefix) {
|
||||
- input.memories().forEach(memoryValue -> memoryValue.serialize(ops, prefix));
|
||||
+ // Leaf start - Remove stream in Brain
|
||||
+ for (Entry<MemoryModuleType<?>, Optional<? extends ExpirableValue<?>>> memory : input.memories.entrySet()) {
|
||||
+ final Brain.MemoryValue<?> result = Brain.MemoryValue.createUnchecked(memory.getKey(), memory.getValue());
|
||||
+
|
||||
+ result.serialize(ops, prefix);
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in Brain
|
||||
+
|
||||
return prefix;
|
||||
}
|
||||
})
|
||||
@@ -153,7 +169,7 @@ public class Brain<E extends LivingEntity> {
|
||||
}
|
||||
|
||||
Stream<Brain.MemoryValue<?>> memories() {
|
||||
- return this.memories.entrySet().stream().map(memory -> Brain.MemoryValue.createUnchecked(memory.getKey(), memory.getValue()));
|
||||
+ return this.memories.entrySet().stream().map(memory -> Brain.MemoryValue.createUnchecked(memory.getKey(), memory.getValue())); // Leaf - Remove stream in Brain - diff on change
|
||||
}
|
||||
|
||||
public boolean hasMemoryValue(MemoryModuleType<?> type) {
|
||||
@@ -1,48 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Sat, 26 Oct 2024 00:56:24 +0800
|
||||
Subject: [PATCH] Remove stream in BehaviorUtils
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java b/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
|
||||
index e7f74b4f54069ffdf74f029639cbf0756f2db095..b5257eefa04e930b45ffd9d46f28e53026ad728f 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorUtils.java
|
||||
@@ -110,10 +110,33 @@ public class BehaviorUtils {
|
||||
|
||||
public static SectionPos findSectionClosestToVillage(ServerLevel serverLevel, SectionPos sectionPos, int radius) {
|
||||
int i = serverLevel.sectionsToVillage(sectionPos);
|
||||
- return SectionPos.cube(sectionPos, radius)
|
||||
- .filter(pos -> serverLevel.sectionsToVillage(pos) < i)
|
||||
- .min(Comparator.comparingInt(serverLevel::sectionsToVillage))
|
||||
- .orElse(sectionPos);
|
||||
+ // Leaf start - Remove stream in BehaviorUtils
|
||||
+ SectionPos closestSection = sectionPos;
|
||||
+ int closestDistance = i;
|
||||
+
|
||||
+ final int lowerX = sectionPos.getX() - radius;
|
||||
+ final int lowerY = sectionPos.getY() - radius;
|
||||
+ final int lowerZ = sectionPos.getZ() - radius;
|
||||
+ final int upperX = sectionPos.getX() + radius;
|
||||
+ final int upperY = sectionPos.getY() + radius;
|
||||
+ final int upperZ = sectionPos.getZ() + radius;
|
||||
+
|
||||
+ for (int x = lowerX; x <= upperX; x++) {
|
||||
+ for (int z = lowerZ; z <= upperZ; z++) {
|
||||
+ for (int y = lowerY; y <= upperY; y++) {
|
||||
+ SectionPos pos = SectionPos.of(x, y, z);
|
||||
+ int distance = serverLevel.sectionsToVillage(pos);
|
||||
+
|
||||
+ if (distance < closestDistance) {
|
||||
+ closestDistance = distance;
|
||||
+ closestSection = pos;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return closestSection;
|
||||
+ // Leaf end - Remove stream in BehaviorUtils
|
||||
}
|
||||
|
||||
public static boolean isWithinAttackRange(Mob mob, LivingEntity target, int cooldown) {
|
||||
@@ -1,53 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Sat, 26 Oct 2024 14:04:54 +0800
|
||||
Subject: [PATCH] Remove stream in YieldJobSite
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/YieldJobSite.java b/net/minecraft/world/entity/ai/behavior/YieldJobSite.java
|
||||
index 37ad79e201e36a1a9520219e3faa4dcffa7b4dfd..d174bb065911c22526b8d6c58f2c748e4f816894 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/YieldJobSite.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/YieldJobSite.java
|
||||
@@ -38,23 +38,26 @@ public class YieldJobSite {
|
||||
if (type.isEmpty()) {
|
||||
return true;
|
||||
} else {
|
||||
- instance.<List<LivingEntity>>get(nearestLivingEntities)
|
||||
- .stream()
|
||||
- .filter(nearEntity -> nearEntity instanceof Villager && nearEntity != villager)
|
||||
- .map(nearEntity -> (Villager)nearEntity)
|
||||
- .filter(LivingEntity::isAlive)
|
||||
- .filter(nearVillager -> nearbyWantsJobsite(type.get(), nearVillager, blockPos))
|
||||
- .findFirst()
|
||||
- .ifPresent(nearVillager -> {
|
||||
- walkTarget.erase();
|
||||
- lookTarget.erase();
|
||||
- potentialJobSite.erase();
|
||||
- if (nearVillager.getBrain().getMemory(MemoryModuleType.JOB_SITE).isEmpty()) {
|
||||
- BehaviorUtils.setWalkAndLookTargetMemories(nearVillager, blockPos, speedModifier, 1);
|
||||
- nearVillager.getBrain().setMemory(MemoryModuleType.POTENTIAL_JOB_SITE, GlobalPos.of(level.dimension(), blockPos));
|
||||
- DebugPackets.sendPoiTicketCountPacket(level, blockPos);
|
||||
+ // Leaf start - Remove stream in YieldJobSite
|
||||
+ List<LivingEntity> mobsList = instance.get(nearestLivingEntities);
|
||||
+ for (LivingEntity nearEntity : mobsList) {
|
||||
+ if (nearEntity instanceof Villager nearVillager && nearEntity != villager && nearEntity.isAlive()) {
|
||||
+ if (nearbyWantsJobsite(type.get(), nearVillager, blockPos)) {
|
||||
+ walkTarget.erase();
|
||||
+ lookTarget.erase();
|
||||
+ potentialJobSite.erase();
|
||||
+
|
||||
+ if (nearVillager.getBrain().getMemory(MemoryModuleType.JOB_SITE).isEmpty()) {
|
||||
+ BehaviorUtils.setWalkAndLookTargetMemories(nearVillager, blockPos, speedModifier, 1);
|
||||
+ nearVillager.getBrain().setMemory(MemoryModuleType.POTENTIAL_JOB_SITE, GlobalPos.of(level.dimension(), blockPos));
|
||||
+ DebugPackets.sendPoiTicketCountPacket(level, blockPos);
|
||||
+ }
|
||||
+
|
||||
+ break;
|
||||
}
|
||||
- });
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in YieldJobSite
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Tue, 9 Nov 2077 00:00:00 +0800
|
||||
Subject: [PATCH] Remove stream in PlayerSensor
|
||||
|
||||
Stream operations in PlayerSensor take too much time
|
||||
while ticking Villager farms, so just replace it with for loop =-=
|
||||
Before: 164ms
|
||||
After: 18ms
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/sensing/PlayerSensor.java b/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
|
||||
index 6233e6b48aaa69ba9f577d0b480b1cdf2f55d16e..996c93f2b7ffd83134535f75c0ead45cc34ef13c 100644
|
||||
--- a/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/PlayerSensor.java
|
||||
@@ -22,17 +22,40 @@ public class PlayerSensor extends Sensor<LivingEntity> {
|
||||
|
||||
@Override
|
||||
protected void doTick(ServerLevel level, LivingEntity entity) {
|
||||
- List<Player> list = level.players()
|
||||
- .stream()
|
||||
- .filter(EntitySelector.NO_SPECTATORS)
|
||||
- .filter(serverPlayer -> entity.closerThan(serverPlayer, this.getFollowDistance(entity)))
|
||||
- .sorted(Comparator.comparingDouble(entity::distanceToSqr))
|
||||
- .collect(Collectors.toList());
|
||||
+ // Leaf start - Remove stream in PlayerSensor
|
||||
+ List<Player> list = new java.util.ArrayList<>();
|
||||
+ for (Player serverPlayer : level.players()) {
|
||||
+ if (!EntitySelector.NO_SPECTATORS.test(serverPlayer)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ if (!entity.closerThan(serverPlayer, this.getFollowDistance(entity))) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ list.add(serverPlayer);
|
||||
+ }
|
||||
+ list.sort(Comparator.comparingDouble(entity::distanceToSqr));
|
||||
+ // Leaf end - Remove stream in PlayerSensor
|
||||
Brain<?> brain = entity.getBrain();
|
||||
brain.setMemory(MemoryModuleType.NEAREST_PLAYERS, list);
|
||||
- List<Player> list1 = list.stream().filter(player -> isEntityTargetable(level, entity, player)).collect(Collectors.toList());
|
||||
+ // Leaf start - Remove stream in PlayerSensor
|
||||
+ List<Player> list1 = new java.util.ArrayList<>();
|
||||
+ for (Player player : list) {
|
||||
+ if (isEntityTargetable(level, entity, player)) {
|
||||
+ list1.add(player);
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in PlayerSensor
|
||||
brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_PLAYER, list1.isEmpty() ? null : list1.get(0));
|
||||
- Optional<Player> optional = list1.stream().filter(player -> isEntityAttackable(level, entity, player)).findFirst();
|
||||
+ // Leaf start - Remove stream in PlayerSensor
|
||||
+ Optional<Player> optional = Optional.empty();
|
||||
+ for (Player player : list1) {
|
||||
+ if (isEntityAttackable(level, entity, player)) {
|
||||
+ optional = Optional.of(player);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in PlayerSensor
|
||||
brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, optional);
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Tue, 9 Nov 2077 00:00:00 +0800
|
||||
Subject: [PATCH] Remove stream in GolemSensor
|
||||
|
||||
Stream operations in GolemSensor is really expensive and takes
|
||||
up 80% time per method call.
|
||||
Before: 192ms
|
||||
After: 17ms
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/sensing/GolemSensor.java b/net/minecraft/world/entity/ai/sensing/GolemSensor.java
|
||||
index 84d9e2a43adbabda8401e8ad8dd8d87f7dbeeea7..ed277d93254a30a817dd8246539c292240dc9669 100644
|
||||
--- a/net/minecraft/world/entity/ai/sensing/GolemSensor.java
|
||||
+++ b/net/minecraft/world/entity/ai/sensing/GolemSensor.java
|
||||
@@ -34,7 +34,15 @@ public class GolemSensor extends Sensor<LivingEntity> {
|
||||
public static void checkForNearbyGolem(LivingEntity livingEntity) {
|
||||
Optional<List<LivingEntity>> memory = livingEntity.getBrain().getMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES);
|
||||
if (!memory.isEmpty()) {
|
||||
- boolean flag = memory.get().stream().anyMatch(entity -> entity.getType().equals(EntityType.IRON_GOLEM));
|
||||
+ // Leaf start - Remove stream in GolemSensor
|
||||
+ boolean flag = false;
|
||||
+ for (LivingEntity entity : memory.get()) {
|
||||
+ if (entity.getType().equals(EntityType.IRON_GOLEM)) {
|
||||
+ flag = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in GolemSensor
|
||||
if (flag) {
|
||||
golemDetected(livingEntity);
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Taiyou06 <kaandindar21@gmail.com>
|
||||
Date: Tue, 9 Nov 2077 00:00:00 +0800
|
||||
Subject: [PATCH] Remove stream in GateBehavior
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/behavior/GateBehavior.java b/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
||||
index bd31d1cac0d022a72bd536c41d1ef811886e7068..2830792cd98c0849280aa1e2116fa89f3c8d2c85 100644
|
||||
--- a/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
||||
+++ b/net/minecraft/world/entity/ai/behavior/GateBehavior.java
|
||||
@@ -73,9 +73,19 @@ public class GateBehavior<E extends LivingEntity> implements BehaviorControl<E>
|
||||
}
|
||||
}
|
||||
// Paper end - Perf: Remove streams from hot code
|
||||
- if (this.behaviors.stream().noneMatch(behavior -> behavior.getStatus() == Behavior.Status.RUNNING)) {
|
||||
+ // Leaf start - Remove more streams in GateBehavior
|
||||
+ boolean hasRunningTask = false;
|
||||
+ for (final BehaviorControl<? super E> behavior : this.behaviors) {
|
||||
+ if (behavior.getStatus() == Behavior.Status.RUNNING) {
|
||||
+ hasRunningTask = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!hasRunningTask) {
|
||||
this.doStop(level, entity, gameTime);
|
||||
}
|
||||
+ // Leaf end - Remove more streams in GateBehavior
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,75 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Taiyou06 <kaandindar21@gmail.com>
|
||||
Date: Mon, 11 Nov 2024 16:55:50 -0500
|
||||
Subject: [PATCH] Remove stream in updateFluidOnEyes
|
||||
|
||||
|
||||
diff --git a/net/minecraft/core/Holder.java b/net/minecraft/core/Holder.java
|
||||
index 6c7edbbf3935c40ccb78bee680ea75431718b9bd..a1b4dc70d555cce5e06c0298736d8b89e04a96be 100644
|
||||
--- a/net/minecraft/core/Holder.java
|
||||
+++ b/net/minecraft/core/Holder.java
|
||||
@@ -29,6 +29,8 @@ public interface Holder<T> {
|
||||
|
||||
Stream<TagKey<T>> tags();
|
||||
|
||||
+ Set<TagKey<T>> tagsAsSet(); // Leaf - Remove stream in updateFluidOnEyes
|
||||
+
|
||||
Either<ResourceKey<T>, T> unwrap();
|
||||
|
||||
Optional<ResourceKey<T>> unwrapKey();
|
||||
@@ -105,6 +107,13 @@ public interface Holder<T> {
|
||||
public Stream<TagKey<T>> tags() {
|
||||
return Stream.of();
|
||||
}
|
||||
+
|
||||
+ // Leaf start - Remove stream in updateFluidOnEyes
|
||||
+ @Override
|
||||
+ public Set<TagKey<T>> tagsAsSet() {
|
||||
+ return Set.of();
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in updateFluidOnEyes
|
||||
}
|
||||
|
||||
public static enum Kind {
|
||||
@@ -238,6 +247,13 @@ public interface Holder<T> {
|
||||
return this.boundTags().stream();
|
||||
}
|
||||
|
||||
+ // Leaf start - Remove stream in updateFluidOnEyes
|
||||
+ @Override
|
||||
+ public Set<TagKey<T>> tagsAsSet() {
|
||||
+ return this.boundTags();
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in updateFluidOnEyes
|
||||
+
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Reference{" + this.key + "=" + this.value + "}";
|
||||
diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java
|
||||
index 970420761b2c3b82a60479c556e76e385bf211e1..4d88aa70c01e03baf8aea897b00f335c7be91f46 100644
|
||||
--- a/net/minecraft/world/entity/Entity.java
|
||||
+++ b/net/minecraft/world/entity/Entity.java
|
||||
@@ -1984,7 +1984,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
|
||||
FluidState fluidState = this.level().getFluidState(blockPos);
|
||||
double d = blockPos.getY() + fluidState.getHeight(this.level(), blockPos);
|
||||
if (d > eyeY) {
|
||||
- fluidState.getTags().forEach(this.fluidOnEyes::add);
|
||||
+ this.fluidOnEyes.addAll(fluidState.getTagsAsSet()); // Leaf - Remove stream in updateFluidOnEyes
|
||||
}
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/material/FluidState.java b/net/minecraft/world/level/material/FluidState.java
|
||||
index 481cb46973acb9785fdee5732e98aac560c6ec08..06581fe010ca722d62d0b6d3c44d845f9db0231f 100644
|
||||
--- a/net/minecraft/world/level/material/FluidState.java
|
||||
+++ b/net/minecraft/world/level/material/FluidState.java
|
||||
@@ -158,4 +158,10 @@ public final class FluidState extends StateHolder<Fluid, FluidState> implements
|
||||
public Stream<TagKey<Fluid>> getTags() {
|
||||
return this.owner.builtInRegistryHolder().tags();
|
||||
}
|
||||
+
|
||||
+ // Leaf start - Remove stream in updateFluidOnEyes
|
||||
+ public java.util.Set<TagKey<Fluid>> getTagsAsSet() {
|
||||
+ return this.owner.builtInRegistryHolder().tagsAsSet();
|
||||
+ }
|
||||
+ // Leaf end - Remove stream in updateFluidOnEyes
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Taiyou06 <kaandindar21@gmail.com>
|
||||
Date: Tue, 26 Nov 2024 19:58:29 -0500
|
||||
Subject: [PATCH] Remove stream in matchingSlot
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/item/enchantment/Enchantment.java b/net/minecraft/world/item/enchantment/Enchantment.java
|
||||
index 7a620eb92b1e672cedd72ec4d986c01eba337686..183874d90d576d740c5d924accc5c0d7fdb8450c 100644
|
||||
--- a/net/minecraft/world/item/enchantment/Enchantment.java
|
||||
+++ b/net/minecraft/world/item/enchantment/Enchantment.java
|
||||
@@ -126,7 +126,15 @@ public record Enchantment(Component description, Enchantment.EnchantmentDefiniti
|
||||
}
|
||||
|
||||
public boolean matchingSlot(EquipmentSlot slot) {
|
||||
- return this.definition.slots().stream().anyMatch(equipmentSlotGroup -> equipmentSlotGroup.test(slot));
|
||||
+ // Leaf start - Remove stream in matchingSlot
|
||||
+ for (EquipmentSlotGroup equipmentSlotGroup : this.definition.slots()) {
|
||||
+ if (equipmentSlotGroup.test(slot)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ // Leaf end - Remove stream in matchingSlot
|
||||
}
|
||||
|
||||
public boolean isPrimaryItem(ItemStack stack) {
|
||||
@@ -1,41 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Tue, 17 Sep 2024 02:35:13 -0400
|
||||
Subject: [PATCH] Replace Entity active effects map with optimized collection
|
||||
|
||||
Dreeam TODO: check this
|
||||
|
||||
diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java
|
||||
index a307ee08f12cb21d17cfbaf969db7c46f10040fb..4f0da30fa659ecabdfbd1d17e50888c32501b6e7 100644
|
||||
--- a/net/minecraft/world/entity/LivingEntity.java
|
||||
+++ b/net/minecraft/world/entity/LivingEntity.java
|
||||
@@ -211,6 +211,10 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
};
|
||||
private final AttributeMap attributes;
|
||||
public CombatTracker combatTracker = new CombatTracker(this);
|
||||
+ // Need to figure out the difference of mem access pattern between hash map and obj2obj hash map (separate chaining vs open addressing)
|
||||
+ // Benchmark is needed for get calls for this active effects map.
|
||||
+ // Also need to check whether call from out of main using bukkit api
|
||||
+ //public final Map<Holder<MobEffect>, MobEffectInstance> activeEffects = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>(0); // Leaf - Replace Entity active effects map with optimized collection
|
||||
public final Map<Holder<MobEffect>, MobEffectInstance> activeEffects = Maps.newHashMap();
|
||||
private final NonNullList<ItemStack> lastHandItemStacks = NonNullList.withSize(2, ItemStack.EMPTY);
|
||||
private final NonNullList<ItemStack> lastArmorItemStacks = NonNullList.withSize(4, ItemStack.EMPTY);
|
||||
@@ -990,15 +994,16 @@ public abstract class LivingEntity extends Entity implements Attackable {
|
||||
private void updateSynchronizedMobEffectParticles() {
|
||||
// Leaf start - Remove stream in entity visible effects filter
|
||||
List<ParticleOptions> list = new ArrayList<>();
|
||||
+ final Collection<MobEffectInstance> effectsValues = this.activeEffects.values(); // Leaf - Replace Entity active effects map with optimized collection
|
||||
|
||||
- for (MobEffectInstance effect : this.activeEffects.values()) {
|
||||
+ for (MobEffectInstance effect : effectsValues) { // Leaf - Replace Entity active effects map with optimized collection
|
||||
if (effect.isVisible()) {
|
||||
list.add(effect.getParticleOptions());
|
||||
}
|
||||
}
|
||||
// Leaf end - Remove stream in entity visible effects filter
|
||||
this.entityData.set(DATA_EFFECT_PARTICLES, list);
|
||||
- this.entityData.set(DATA_EFFECT_AMBIENCE_ID, areAllEffectsAmbient(this.activeEffects.values()));
|
||||
+ this.entityData.set(DATA_EFFECT_AMBIENCE_ID, areAllEffectsAmbient(effectsValues)); // Leaf - Replace Entity active effects map with optimized collection
|
||||
}
|
||||
|
||||
private void updateGlowingStatus() {
|
||||
@@ -1,19 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Sat, 7 Sep 2024 02:12:55 -0400
|
||||
Subject: [PATCH] Replace criterion map with optimized collection
|
||||
|
||||
|
||||
diff --git a/net/minecraft/server/PlayerAdvancements.java b/net/minecraft/server/PlayerAdvancements.java
|
||||
index e4ea26ae84efde7ce54e08a246a6ea2ae2a17151..ddd1eac136fc3327aea8286769efd2d7309f67ec 100644
|
||||
--- a/net/minecraft/server/PlayerAdvancements.java
|
||||
+++ b/net/minecraft/server/PlayerAdvancements.java
|
||||
@@ -60,7 +60,7 @@ public class PlayerAdvancements {
|
||||
private AdvancementHolder lastSelectedTab;
|
||||
private boolean isFirstPacket = true;
|
||||
private final Codec<PlayerAdvancements.Data> codec;
|
||||
- public final Map<net.minecraft.advancements.critereon.SimpleCriterionTrigger<?>, Set<CriterionTrigger.Listener<?>>> criterionData = new java.util.IdentityHashMap<>(); // Paper - fix advancement data player leakage
|
||||
+ public final Map<net.minecraft.advancements.critereon.SimpleCriterionTrigger<?>, Set<CriterionTrigger.Listener<?>>> criterionData = new it.unimi.dsi.fastutil.objects.Reference2ReferenceOpenHashMap<>(); // Paper - fix advancement data player leakage // Leaf - Replace criterion map with optimized collection
|
||||
|
||||
public PlayerAdvancements(DataFixer dataFixer, PlayerList playerList, ServerAdvancementManager manager, Path playerSavePath, ServerPlayer player) {
|
||||
this.playerList = playerList;
|
||||
@@ -1,35 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Sat, 26 Oct 2024 00:06:04 +0800
|
||||
Subject: [PATCH] Replace brain maps with optimized collection
|
||||
|
||||
|
||||
diff --git a/net/minecraft/world/entity/ai/Brain.java b/net/minecraft/world/entity/ai/Brain.java
|
||||
index 083eb9a7a0bc14d30db944f356d98ca552fa1784..c561b749fb9b76ba9b1e9689089b743248c65d50 100644
|
||||
--- a/net/minecraft/world/entity/ai/Brain.java
|
||||
+++ b/net/minecraft/world/entity/ai/Brain.java
|
||||
@@ -45,14 +45,18 @@ public class Brain<E extends LivingEntity> {
|
||||
static final Logger LOGGER = LogUtils.getLogger();
|
||||
private final Supplier<Codec<Brain<E>>> codec;
|
||||
private static final int SCHEDULE_UPDATE_DELAY = 20;
|
||||
- private final Map<MemoryModuleType<?>, Optional<? extends ExpirableValue<?>>> memories = Maps.newHashMap();
|
||||
- private final Map<SensorType<? extends Sensor<? super E>>, Sensor<? super E>> sensors = Maps.newLinkedHashMap();
|
||||
+ // Leaf start - Replace brain maps with optimized collection
|
||||
+ private final Map<MemoryModuleType<?>, Optional<? extends ExpirableValue<?>>> memories = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>();
|
||||
+ private final Map<SensorType<? extends Sensor<? super E>>, Sensor<? super E>> sensors = new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>();
|
||||
+ // Leaf end - Replace brain maps with optimized collection
|
||||
private final Map<Integer, Map<Activity, Set<BehaviorControl<? super E>>>> availableBehaviorsByPriority = Maps.newTreeMap();
|
||||
private Schedule schedule = Schedule.EMPTY;
|
||||
- private final Map<Activity, Set<Pair<MemoryModuleType<?>, MemoryStatus>>> activityRequirements = Maps.newHashMap();
|
||||
- private final Map<Activity, Set<MemoryModuleType<?>>> activityMemoriesToEraseWhenStopped = Maps.newHashMap();
|
||||
- private Set<Activity> coreActivities = Sets.newHashSet();
|
||||
- private final Set<Activity> activeActivities = Sets.newHashSet();
|
||||
+ // Leaf start - Replace brain maps with optimized collection
|
||||
+ private final Map<Activity, Set<Pair<MemoryModuleType<?>, MemoryStatus>>> activityRequirements = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>();
|
||||
+ private final Map<Activity, Set<MemoryModuleType<?>>> activityMemoriesToEraseWhenStopped = new it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap<>();
|
||||
+ private Set<Activity> coreActivities = new it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<>();
|
||||
+ private final Set<Activity> activeActivities = new it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<>();
|
||||
+ // Leaf end - Replace brain maps with optimized collection
|
||||
private Activity defaultActivity = Activity.IDLE;
|
||||
private long lastScheduleUpdate = -9999L;
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
||||
Date: Fri, 14 Jun 2024 23:19:55 +0800
|
||||
Subject: [PATCH] Reduce worldgen allocations
|
||||
|
||||
This change optimizes the way SurfaceRules update their biome supplier,avoiding unnecessary object creations and thus reducing memory allocations
|
||||
during world generation. The update method now reuses the existing PositionalBiomeGetter object if it's already present, otherwise it
|
||||
initializes a new one.
|
||||
Additionally, the tryApply method in SurfaceRules now avoids iterator
|
||||
allocation by directly accessing the rules list, which further contributes
|
||||
to reducing garbage collection pressure during world generation.
|
||||
|
||||
diff --git a/net/minecraft/world/level/levelgen/NoiseChunk.java b/net/minecraft/world/level/levelgen/NoiseChunk.java
|
||||
index f861f9e087182470a3bbb22678dbdacb8a73e943..a3d0d17178eedfaef83e2e0df6b1c2d7784d8656 100644
|
||||
--- a/net/minecraft/world/level/levelgen/NoiseChunk.java
|
||||
+++ b/net/minecraft/world/level/levelgen/NoiseChunk.java
|
||||
@@ -362,7 +362,17 @@ public class NoiseChunk implements DensityFunction.ContextProvider, DensityFunct
|
||||
}
|
||||
|
||||
protected DensityFunction wrap(DensityFunction densityFunction) {
|
||||
- return this.wrapped.computeIfAbsent(densityFunction, this::wrapNew);
|
||||
+ // Leaf start - Reduce worldgen allocations
|
||||
+ // Avoid lambda allocation
|
||||
+ DensityFunction func = this.wrapped.get(densityFunction);
|
||||
+
|
||||
+ if (func == null) {
|
||||
+ func = this.wrapNew(densityFunction);
|
||||
+ this.wrapped.put(densityFunction, func);
|
||||
+ }
|
||||
+
|
||||
+ return func;
|
||||
+ // Leaf end - Reduce worldgen allocations
|
||||
}
|
||||
|
||||
private DensityFunction wrapNew(DensityFunction densityFunction) {
|
||||
diff --git a/net/minecraft/world/level/levelgen/SurfaceRules.java b/net/minecraft/world/level/levelgen/SurfaceRules.java
|
||||
index 0948c8db90605a15a043b5c5bc74edecd7f9db1b..009e8a270c25614d03413d8b8b1f39c2da8ba12f 100644
|
||||
--- a/net/minecraft/world/level/levelgen/SurfaceRules.java
|
||||
+++ b/net/minecraft/world/level/levelgen/SurfaceRules.java
|
||||
@@ -313,8 +313,15 @@ public class SurfaceRules {
|
||||
}
|
||||
|
||||
protected void updateY(int stoneDepthAbove, int stoneDepthBelow, int waterHeight, int blockX, int blockY, int blockZ) {
|
||||
- this.lastUpdateY++;
|
||||
- this.biome = Suppliers.memoize(() -> this.biomeGetter.apply(this.pos.set(blockX, blockY, blockZ)));
|
||||
+ // Leaf start - Reduce worldgen allocations
|
||||
+ // Reuse supplier object instead of creating new ones every time
|
||||
+ ++this.lastUpdateY;
|
||||
+ Supplier<Holder<Biome>> getter = this.biome;
|
||||
+ if (getter == null) {
|
||||
+ this.biome = getter = new org.dreeam.leaf.util.biome.PositionalBiomeGetter(this.biomeGetter, this.pos);
|
||||
+ }
|
||||
+ ((org.dreeam.leaf.util.biome.PositionalBiomeGetter) getter).update(blockX, blockY, blockZ);
|
||||
+ // Leaf end - Reduce worldgen allocations
|
||||
this.blockY = blockY;
|
||||
this.waterHeight = waterHeight;
|
||||
this.stoneDepthBelow = stoneDepthBelow;
|
||||
@@ -582,8 +589,13 @@ public class SurfaceRules {
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState tryApply(int x, int y, int z) {
|
||||
- for (SurfaceRules.SurfaceRule surfaceRule : this.rules) {
|
||||
- BlockState blockState = surfaceRule.tryApply(x, y, z);
|
||||
+ // Leaf start - Reduce worldgen allocations
|
||||
+ // Avoid iterator allocation
|
||||
+ int size = this.rules.size();
|
||||
+ //noinspection ForLoopReplaceableByForEach
|
||||
+ for (int i = 0; i < size; i++) {
|
||||
+ BlockState blockState = this.rules.get(i).tryApply(x, y, z);
|
||||
+ // Leaf end - Reduce worldgen allocations
|
||||
if (blockState != null) {
|
||||
return blockState;
|
||||
}
|
||||
diff --git a/net/minecraft/world/level/levelgen/material/MaterialRuleList.java b/net/minecraft/world/level/levelgen/material/MaterialRuleList.java
|
||||
index 1605cc013d5a89a5d3cb68365bdcc18e2dd0a921..a3b5f74b5f9a0f4e62dee67e50f51e9e6b78d7fd 100644
|
||||
--- a/net/minecraft/world/level/levelgen/material/MaterialRuleList.java
|
||||
+++ b/net/minecraft/world/level/levelgen/material/MaterialRuleList.java
|
||||
@@ -9,13 +9,17 @@ public record MaterialRuleList(NoiseChunk.BlockStateFiller[] materialRuleList) i
|
||||
@Nullable
|
||||
@Override
|
||||
public BlockState calculate(DensityFunction.FunctionContext context) {
|
||||
- for (NoiseChunk.BlockStateFiller blockStateFiller : this.materialRuleList) {
|
||||
- BlockState blockState = blockStateFiller.calculate(context);
|
||||
- if (blockState != null) {
|
||||
- return blockState;
|
||||
- }
|
||||
+ // Leaf start - Reduce worldgen allocations
|
||||
+ // Avoid iterator allocation
|
||||
+ BlockState blockState = null;
|
||||
+ int length = this.materialRuleList.length;
|
||||
+
|
||||
+ for (int i = 0; blockState == null && i < length; i++) {
|
||||
+ NoiseChunk.BlockStateFiller blockStateFiller = this.materialRuleList[i];
|
||||
+ blockState = blockStateFiller.calculate(context);
|
||||
}
|
||||
|
||||
- return null;
|
||||
+ return blockState;
|
||||
+ // Leaf end - Reduce worldgen allocations
|
||||
}
|
||||
}
|
||||
@@ -1,187 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Kevin Raneri <kevin.raneri@gmail.com>
|
||||
Date: Wed, 10 Nov 2021 00:37:03 -0500
|
||||
Subject: [PATCH] Pufferfish: Optimize mob spawning
|
||||
|
||||
Original license: GPL v3
|
||||
Original project: https://github.com/pufferfish-gg/Pufferfish
|
||||
|
||||
Co-authored-by: booky10 <boooky10@gmail.com>
|
||||
|
||||
This patch aims to reduce the main-thread impact of mob spawning by
|
||||
offloading as much work as possible to other threads. It is possible for
|
||||
inconsistencies to come up, but when they happen they never interfere
|
||||
with the server's operation (they don't produce errors), and side
|
||||
effects are limited to more or less mobs being spawned in any particular
|
||||
tick.
|
||||
|
||||
It is possible to disable this optimization if it is not required or if
|
||||
it interferes with any plugins. On servers with thousands of entities,
|
||||
this can result in performance gains of up to 15%, which is significant
|
||||
and, in my opinion, worth the low risk of minor mob-spawning-related
|
||||
inconsistencies.
|
||||
|
||||
diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java
|
||||
index 4ba85d704ffebae38f7a76a97a182e3674730c6f..a76b67a846b12a7b3d0c41b6ac4833d4f0372531 100644
|
||||
--- a/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/net/minecraft/server/MinecraftServer.java
|
||||
@@ -286,6 +286,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
public boolean isIteratingOverLevels = false; // Paper - Throw exception on world create while being ticked
|
||||
private final Set<String> pluginsBlockingSleep = new java.util.HashSet<>(); // Paper - API to allow/disallow tick sleeping
|
||||
public static final long SERVER_INIT = System.nanoTime(); // Paper - Lag compensation
|
||||
+ public gg.pufferfish.pufferfish.util.AsyncExecutor mobSpawnExecutor = new gg.pufferfish.pufferfish.util.AsyncExecutor("MobSpawning"); // Pufferfish - optimize mob spawning
|
||||
|
||||
public static <S extends MinecraftServer> S spin(Function<Thread, S> threadFunction) {
|
||||
ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system
|
||||
diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
index bd7f792c45059f0652e530608ef0c77c5caf7cfa..649403ef1d5d898052412d6d47783769f291b94f 100644
|
||||
--- a/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
+++ b/net/minecraft/server/dedicated/DedicatedServer.java
|
||||
@@ -363,6 +363,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface
|
||||
LOGGER.info("JMX monitoring enabled");
|
||||
}
|
||||
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled) mobSpawnExecutor.start(); // Pufferfish
|
||||
+
|
||||
return true;
|
||||
}
|
||||
}
|
||||
diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java
|
||||
index 7a18b11782b2524280fddf20e6b1cabdddf07c49..55f708438e5d71cf14f4e632fc20a65b4bfb7d25 100644
|
||||
--- a/net/minecraft/server/level/ServerChunkCache.java
|
||||
+++ b/net/minecraft/server/level/ServerChunkCache.java
|
||||
@@ -179,6 +179,8 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
}
|
||||
// Paper end - chunk tick iteration optimisations
|
||||
|
||||
+ public boolean firstRunSpawnCounts = true; // Pufferfish
|
||||
+ public final java.util.concurrent.atomic.AtomicBoolean _pufferfish_spawnCountsReady = new java.util.concurrent.atomic.AtomicBoolean(false); // Pufferfish - optimize countmobs
|
||||
|
||||
public ServerChunkCache(
|
||||
ServerLevel level,
|
||||
@@ -503,7 +505,8 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
this.collectTickingChunks(list);
|
||||
// Paper start - chunk tick iteration optimisation
|
||||
this.shuffleRandom.setSeed(this.level.random.nextLong());
|
||||
- if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns) Util.shuffle(list, this.shuffleRandom); // Paper - Optional per player mob spawns; do not need this when per-player is enabled
|
||||
+ if (!this.level.paperConfig().entities.spawning.perPlayerMobSpawns)
|
||||
+ Util.shuffle(list, this.shuffleRandom); // Paper - Optional per player mob spawns; do not need this when per-player is enabled
|
||||
// Paper end - chunk tick iteration optimisation
|
||||
this.tickChunks(l, list); // Gale - Purpur - remove vanilla profiler
|
||||
} finally {
|
||||
@@ -513,6 +516,54 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
|
||||
this.broadcastChangedChunks(); // Gale - Purpur - remove vanilla profiler
|
||||
}
|
||||
+
|
||||
+ // Pufferfish start - optimize mob spawning
|
||||
+ if (org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled) {
|
||||
+ for (ServerPlayer player : this.level.players) {
|
||||
+ // Paper start - per player mob spawning backoff
|
||||
+ for (int ii = 0; ii < ServerPlayer.MOBCATEGORY_TOTAL_ENUMS; ii++) {
|
||||
+ player.mobCounts[ii] = 0;
|
||||
+
|
||||
+ int newBackoff = player.mobBackoffCounts[ii] - 1; // TODO make configurable bleed // TODO use nonlinear algorithm?
|
||||
+ if (newBackoff < 0) {
|
||||
+ newBackoff = 0;
|
||||
+ }
|
||||
+ player.mobBackoffCounts[ii] = newBackoff;
|
||||
+ }
|
||||
+ // Paper end - per player mob spawning backoff
|
||||
+ }
|
||||
+ if (firstRunSpawnCounts) {
|
||||
+ firstRunSpawnCounts = false;
|
||||
+ _pufferfish_spawnCountsReady.set(true);
|
||||
+ }
|
||||
+ if (_pufferfish_spawnCountsReady.getAndSet(false)) {
|
||||
+ net.minecraft.server.MinecraftServer.getServer().mobSpawnExecutor.submit(() -> {
|
||||
+ int mapped = distanceManager.getNaturalSpawnChunkCount();
|
||||
+ ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet.Iterator<Entity> objectiterator =
|
||||
+ level.entityTickList.entities.iterator(ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet.ITERATOR_FLAG_SEE_ADDITIONS);
|
||||
+ try {
|
||||
+ gg.pufferfish.pufferfish.util.IterableWrapper<Entity> wrappedIterator =
|
||||
+ new gg.pufferfish.pufferfish.util.IterableWrapper<>(objectiterator);
|
||||
+ // Fix: Use proper mob cap calculator based on configuration
|
||||
+ LocalMobCapCalculator mobCapCalculator = !level.paperConfig().entities.spawning.perPlayerMobSpawns ?
|
||||
+ new LocalMobCapCalculator(chunkMap) : null;
|
||||
+
|
||||
+ // This ensures the caps are properly enforced by using the correct calculator
|
||||
+ lastSpawnState = NaturalSpawner.createState(
|
||||
+ mapped,
|
||||
+ wrappedIterator,
|
||||
+ ServerChunkCache.this::getFullChunk,
|
||||
+ mobCapCalculator, // This is the key fix - was previously null
|
||||
+ level.paperConfig().entities.spawning.perPlayerMobSpawns
|
||||
+ );
|
||||
+ } finally {
|
||||
+ objectiterator.finishedIterating();
|
||||
+ }
|
||||
+ _pufferfish_spawnCountsReady.set(true);
|
||||
+ });
|
||||
+ }
|
||||
+ }
|
||||
+ // Pufferfish end
|
||||
}
|
||||
|
||||
private void broadcastChangedChunks() { // Gale - Purpur - remove vanilla profiler
|
||||
@@ -560,6 +611,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
int naturalSpawnChunkCount = this.distanceManager.getNaturalSpawnChunkCount();
|
||||
// Paper start - Optional per player mob spawns
|
||||
if ((this.spawnFriendlies || this.spawnEnemies) && this.level.paperConfig().entities.spawning.perPlayerMobSpawns) { // don't count mobs when animals and monsters are disabled
|
||||
+ if (!org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled) { // Pufferfish - moved down when async processing
|
||||
// re-set mob counts
|
||||
for (ServerPlayer player : this.level.players) {
|
||||
// Paper start - per player mob spawning backoff
|
||||
@@ -574,12 +626,16 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
}
|
||||
// Paper end - per player mob spawning backoff
|
||||
}
|
||||
- spawnState = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, null, true);
|
||||
+ lastSpawnState = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, null, true); // Pufferfish - async mob spawning
|
||||
+ } // Pufferfish - (endif) moved down when async processing
|
||||
} else {
|
||||
- spawnState = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false);
|
||||
+ // Pufferfish start - async mob spawning
|
||||
+ lastSpawnState = NaturalSpawner.createState(naturalSpawnChunkCount, this.level.getAllEntities(), this::getFullChunk, !this.level.paperConfig().entities.spawning.perPlayerMobSpawns ? new LocalMobCapCalculator(this.chunkMap) : null, false);
|
||||
+ _pufferfish_spawnCountsReady.set(true);
|
||||
+ // Pufferfish end
|
||||
}
|
||||
// Paper end - Optional per player mob spawns
|
||||
- this.lastSpawnState = spawnState;
|
||||
+ //this.lastSpawnState = spawnState; // Pufferfish - this is managed asynchronously
|
||||
// Gale start - MultiPaper - skip unnecessary mob spawning computations
|
||||
} else {
|
||||
spawnState = null;
|
||||
@@ -597,7 +653,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
}
|
||||
// Paper end - PlayerNaturallySpawnCreaturesEvent
|
||||
boolean flag = this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) != 0L && this.level.getLevelData().getGameTime() % this.level.ticksPerSpawnCategory.getLong(org.bukkit.entity.SpawnCategory.ANIMAL) == 0L; // CraftBukkit
|
||||
- filteredSpawningCategories = NaturalSpawner.getFilteredSpawningCategories(spawnState, this.spawnFriendlies, this.spawnEnemies, flag, this.level); // CraftBukkit
|
||||
+ filteredSpawningCategories = NaturalSpawner.getFilteredSpawningCategories(lastSpawnState, this.spawnFriendlies, this.spawnEnemies, flag, this.level); // CraftBukkit // Pufferfish
|
||||
} else {
|
||||
filteredSpawningCategories = List.of();
|
||||
}
|
||||
@@ -605,8 +661,8 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon
|
||||
for (LevelChunk levelChunk : chunks) {
|
||||
ChunkPos pos = levelChunk.getPos();
|
||||
levelChunk.incrementInhabitedTime(timeInhabited);
|
||||
- if (!filteredSpawningCategories.isEmpty() && this.level.getWorldBorder().isWithinBounds(pos) && this.chunkMap.anyPlayerCloseEnoughForSpawning(pos, true)) { // Spigot
|
||||
- NaturalSpawner.spawnForChunk(this.level, levelChunk, spawnState, filteredSpawningCategories);
|
||||
+ if (!filteredSpawningCategories.isEmpty() && this.level.getWorldBorder().isWithinBounds(pos) && (!org.dreeam.leaf.config.modules.async.AsyncMobSpawning.enabled || _pufferfish_spawnCountsReady.get()) && this.chunkMap.anyPlayerCloseEnoughForSpawning(pos, true)) { // Spigot // Pufferfish
|
||||
+ NaturalSpawner.spawnForChunk(this.level, levelChunk, lastSpawnState, filteredSpawningCategories); // Pufferfish
|
||||
}
|
||||
|
||||
if (true) { // Paper - rewrite chunk system
|
||||
diff --git a/net/minecraft/world/level/entity/EntityTickList.java b/net/minecraft/world/level/entity/EntityTickList.java
|
||||
index 423779a2b690f387a4f0bd07b97b50e0baefda76..dec51066fc3f57b7bdc56195313c219f45a7fbee 100644
|
||||
--- a/net/minecraft/world/level/entity/EntityTickList.java
|
||||
+++ b/net/minecraft/world/level/entity/EntityTickList.java
|
||||
@@ -9,7 +9,7 @@ import javax.annotation.Nullable;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
|
||||
public class EntityTickList {
|
||||
- private final ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<net.minecraft.world.entity.Entity> entities = new ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<>(); // Paper - rewrite chunk system
|
||||
+ public final ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<net.minecraft.world.entity.Entity> entities = new ca.spottedleaf.moonrise.common.list.IteratorSafeOrderedReferenceSet<>(); // Paper - rewrite chunk system // Pufferfish - private->public
|
||||
|
||||
private void ensureActiveIsNotIterated() {
|
||||
// Paper - rewrite chunk system
|
||||
@@ -1,81 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Tue, 2 Jan 2024 21:13:53 -0500
|
||||
Subject: [PATCH] Faster sequencing of futures for chunk structure gen
|
||||
|
||||
Replace `thenApply` with `thenCompose`. Once one task is completed then the next task starts immediately,
|
||||
to prevent blocking threads while waiting to complete all tasks. But may cause the sequence of future compose disorder.
|
||||
|
||||
diff --git a/net/minecraft/Util.java b/net/minecraft/Util.java
|
||||
index 80a7a85e1a03a1ca406259207e1ae3b909b3284f..b097f685e826e70008e3a096ee5f1d4fccf25680 100644
|
||||
--- a/net/minecraft/Util.java
|
||||
+++ b/net/minecraft/Util.java
|
||||
@@ -607,17 +607,42 @@ public class Util {
|
||||
return map;
|
||||
}
|
||||
|
||||
+ // Leaf start - Faster sequencing of futures for chunk structure gen
|
||||
public static <V> CompletableFuture<List<V>> sequence(List<? extends CompletableFuture<V>> futures) {
|
||||
+ return sequence(futures, false);
|
||||
+ }
|
||||
+
|
||||
+ public static <V> CompletableFuture<List<V>> sequence(List<? extends CompletableFuture<V>> futures, boolean useFaster) {
|
||||
+ // Leaf end - Faster sequencing of futures for chunk structure gen
|
||||
if (futures.isEmpty()) {
|
||||
return CompletableFuture.completedFuture(List.of());
|
||||
} else if (futures.size() == 1) {
|
||||
return futures.get(0).thenApply(List::of);
|
||||
} else {
|
||||
CompletableFuture<Void> completableFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]));
|
||||
+
|
||||
+ if (useFaster) return sequenceFaster(futures, completableFuture); // Leaf - Faster sequencing of futures for chunk structure gen
|
||||
+
|
||||
return completableFuture.thenApply(_void -> futures.stream().map(CompletableFuture::join).toList());
|
||||
}
|
||||
}
|
||||
|
||||
+ // Leaf start - Faster sequencing of futures for chunk structure gen
|
||||
+ private static <V> CompletableFuture<List<V>> sequenceFaster(List<? extends CompletableFuture<V>> futures, CompletableFuture<Void> completableFuture) {
|
||||
+ return completableFuture.thenCompose(void_ ->
|
||||
+ CompletableFuture.supplyAsync(() -> {
|
||||
+ List<V> list = new java.util.ArrayList<>();
|
||||
+
|
||||
+ for (CompletableFuture<V> future : futures) {
|
||||
+ list.add(future.join());
|
||||
+ }
|
||||
+
|
||||
+ return list;
|
||||
+ }
|
||||
+ ));
|
||||
+ }
|
||||
+ // Leaf end - Faster sequencing of futures for chunk structure gen
|
||||
+
|
||||
public static <V> CompletableFuture<List<V>> sequenceFailFast(List<? extends CompletableFuture<? extends V>> completableFutures) {
|
||||
CompletableFuture<List<V>> completableFuture = new CompletableFuture<>();
|
||||
return fallibleSequence(completableFutures, completableFuture::completeExceptionally).applyToEither(completableFuture, Function.identity());
|
||||
diff --git a/net/minecraft/server/ReloadableServerRegistries.java b/net/minecraft/server/ReloadableServerRegistries.java
|
||||
index d8c472b8c6aadcaadef14abd8ab43f466e94417e..bc079b6c3d751f2a63d089bf209cf7d8e0da76e8 100644
|
||||
--- a/net/minecraft/server/ReloadableServerRegistries.java
|
||||
+++ b/net/minecraft/server/ReloadableServerRegistries.java
|
||||
@@ -52,7 +52,7 @@ public class ReloadableServerRegistries {
|
||||
List<CompletableFuture<WritableRegistry<?>>> list1 = LootDataType.values()
|
||||
.map(lootDataType -> scheduleRegistryLoad((LootDataType<?>)lootDataType, registryOps, resourceManager, backgroundExecutor, conversions)) // Paper
|
||||
.toList();
|
||||
- CompletableFuture<List<WritableRegistry<?>>> completableFuture = Util.sequence(list1);
|
||||
+ CompletableFuture<List<WritableRegistry<?>>> completableFuture = Util.sequence(list1, false); // Leaf - Faster sequencing of futures for chunk structure gen
|
||||
return completableFuture.thenApplyAsync(
|
||||
list2 -> createAndValidateFullContext(registryAccess, provider, (List<WritableRegistry<?>>)list2), backgroundExecutor
|
||||
);
|
||||
diff --git a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||
index 619b98e42e254c0c260c171a26a2472ddf59b885..f07a5416e5dc7e9a798a78ce9573a0c42bc59d04 100644
|
||||
--- a/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||
+++ b/net/minecraft/world/level/chunk/ChunkGeneratorStructureState.java
|
||||
@@ -255,7 +255,7 @@ public class ChunkGeneratorStructureState {
|
||||
}
|
||||
}
|
||||
|
||||
- return Util.sequence(list).thenApply(completed -> {
|
||||
+ return Util.sequence(list, org.dreeam.leaf.config.modules.opt.FasterStructureGenFutureSequencing.enabled).thenApply(completed -> { // Leaf - Faster sequencing of futures for chunk structure gen
|
||||
double d2 = stopwatch.stop().elapsed(TimeUnit.MILLISECONDS) / 1000.0;
|
||||
LOGGER.debug("Calculation for {} took {}s", structureSet, d2);
|
||||
return completed;
|
||||
@@ -1,27 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
|
||||
Date: Mon, 15 Jan 2024 10:53:10 -0500
|
||||
Subject: [PATCH] Reduce active items finding hopper nearby check
|
||||
|
||||
This patch add a toggle for active items checking MinecraftHopper nearby,
|
||||
|
||||
But still recommend to turn-off `checkForMinecartNearItemWhileActive`
|
||||
Since `Reduce-hopper-item-checks.patch` will cause lag under massive dropped items
|
||||
|
||||
diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java
|
||||
index 6436afc0e59a8efdc9551fdde4d03d245548f3ef..280d9d5a23f5fc8560ca8eeb4f3652ea9c1505b2 100644
|
||||
--- a/net/minecraft/world/entity/item/ItemEntity.java
|
||||
+++ b/net/minecraft/world/entity/item/ItemEntity.java
|
||||
@@ -241,7 +241,11 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
||||
this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
return; // Gale - EMC - reduce hopper item checks
|
||||
}
|
||||
- this.markNearbyHopperCartsAsImmune(); // Gale - EMC - reduce hopper item checks
|
||||
+ // Leaf start - Reduce active items finding hopper nearby check
|
||||
+ if (level().galeConfig().smallOptimizations.reducedIntervals.checkNearbyItem.hopper.minecart.temporaryImmunity.checkForMinecartNearItemWhileActive) {
|
||||
+ this.markNearbyHopperCartsAsImmune(); // Gale - EMC - reduce hopper item checks
|
||||
+ }
|
||||
+ // Leaf end - Reduce active items finding hopper nearby check
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user