diff --git a/gradle.properties b/gradle.properties index 0e97c58..574a40c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,13 +1,13 @@ group = me.earthme.luminol -version = 1.20.6-R0.1-SNAPSHOT +version = 1.21-R0.1-SNAPSHOT -foliaCommit = d79708296e75ee4f26e78c2925f6e7d4217d0575 +foliaCommit = 388cdacd1b373031caec202fca400f3fd7898285 org.gradle.caching = true org.gradle.parallel = true org.gradle.vfs.watch = false org.gradle.jvmargs = -Xmx3G -mcVersion = 1.20.6 -GroupMCV = 1.20 -preVersion = false \ No newline at end of file +mcVersion = 1.21 +GroupMCV = 1.21 +preVersion = true \ No newline at end of file diff --git a/patches/api/0003-KioCG-Chunk-API.patch b/patches/api/0003-KioCG-Chunk-API.patch index bb7786a..9d192a9 100644 --- a/patches/api/0003-KioCG-Chunk-API.patch +++ b/patches/api/0003-KioCG-Chunk-API.patch @@ -16,10 +16,10 @@ index bc8b5bc17706250b8535b1b309134843d2ce2bb1..1cfe84ad1094e3c4fab96487f328be53 + long getChunkHotAvg(); // KioCG } diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index eb34f22e973fe46529eb93f435f5bf7f85091404..b2d23eeb24d1132607cf68c2a6eec352db321fa2 100644 +index 7c56182acaf827f4b1a986a61cea8e9960604c98..2d40d7dff833a7e259a82cca758b89c2ef3d5375 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java -@@ -3854,4 +3854,6 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM +@@ -3859,4 +3859,6 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM @Override Spigot spigot(); // Spigot end diff --git a/patches/api/0004-FoliaPR-Add-TPS-From-Region.patch b/patches/api/0004-FoliaPR-Add-TPS-From-Region.patch index dd444ba..5bb6bf9 100644 --- a/patches/api/0004-FoliaPR-Add-TPS-From-Region.patch +++ b/patches/api/0004-FoliaPR-Add-TPS-From-Region.patch @@ -5,10 +5,10 @@ Subject: [PATCH] FoliaPR Add TPS From Region diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index 15049641b8123abf03edcbb49257fb4f3db0a5ec..0492d5738a7168b68b60dcbb24a09946a640a1a1 100644 +index 886920b33b37bdefc301f898ad0003e40eff6443..122433e2f0d3c8dfedb30814c8b24e75d4fe879f 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -2397,6 +2397,28 @@ public final class Bukkit { +@@ -2394,6 +2394,28 @@ public final class Bukkit { } // Paper end @@ -38,10 +38,10 @@ index 15049641b8123abf03edcbb49257fb4f3db0a5ec..0492d5738a7168b68b60dcbb24a09946 * Get the advancement specified by this key. * diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 1f51f80e8516cfac7ed4078ed96e535389a31f25..d5c89a7a63239e6403f1fa1429d8f5a9802883b1 100644 +index d6f72cb1e2380bd1a18d695c7d26ae3834f6eb52..280ce7ca1bfdd4b7924a48675192e24489b82b9e 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2050,6 +2050,24 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2047,6 +2047,24 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi double getAverageTickTime(); // Paper end diff --git a/patches/server/0002-Rebrand-to-Luminol.patch b/patches/server/0002-Rebrand-to-Luminol.patch index b332dfa..df368a5 100644 --- a/patches/server/0002-Rebrand-to-Luminol.patch +++ b/patches/server/0002-Rebrand-to-Luminol.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Rebrand to Luminol diff --git a/build.gradle.kts b/build.gradle.kts -index 32bfe781e5298e5ad1bd2ed4471fb824c49f0ab4..f9919b9da90317bd615d7e57607df73ebcc1d077 100644 +index ee6ae99ba31ec4c91d81be845a594481ce85beab..de5a43db5f0c7c507c492db8789ad2d4a4cff3c8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -80,14 +80,14 @@ tasks.jar { +@@ -84,14 +84,14 @@ tasks.jar { val gitBranch = git("rev-parse", "--abbrev-ref", "HEAD").getText().trim() // Paper attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", diff --git a/patches/server/0003-Empty-config-file-base.patch b/patches/server/0003-Empty-config-file-base.patch index 57ade0e..a969f69 100644 --- a/patches/server/0003-Empty-config-file-base.patch +++ b/patches/server/0003-Empty-config-file-base.patch @@ -1,11 +1,11 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Wed, 7 Feb 2024 00:45:19 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 11:49:53 +0800 Subject: [PATCH] Empty config file base diff --git a/build.gradle.kts b/build.gradle.kts -index f9919b9da90317bd615d7e57607df73ebcc1d077..ab07c307bea0d3b79a6239bdcca9714e1ddf3b28 100644 +index de5a43db5f0c7c507c492db8789ad2d4a4cff3c8..f657ee64810d1c02a967b9262b95fbc65eb3fce2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,6 +14,7 @@ val alsoShade: Configuration by configurations.creating @@ -191,20 +191,18 @@ index 0000000000000000000000000000000000000000..9f6896711907ac30fe0c00130207b970 +} diff --git a/src/main/java/me/earthme/luminol/config/LuminolConfig.java b/src/main/java/me/earthme/luminol/config/LuminolConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..2b4e64796bf01b0a5fcb306850cd60837ed4d36b +index 0000000000000000000000000000000000000000..976cc572861174787b37992388a03ab01f8703a4 --- /dev/null +++ b/src/main/java/me/earthme/luminol/config/LuminolConfig.java -@@ -0,0 +1,218 @@ +@@ -0,0 +1,220 @@ +package me.earthme.luminol.config; + +import com.electronwill.nightconfig.core.file.CommentedFileConfig; +import io.papermc.paper.threadedregions.RegionizedServer; +import me.earthme.luminol.commands.LuminolConfigCommand; +import org.bukkit.Bukkit; -+import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; -+ +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Field; @@ -218,7 +216,6 @@ index 0000000000000000000000000000000000000000..2b4e64796bf01b0a5fcb306850cd6083 +import java.util.concurrent.CompletableFuture; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; -+ +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + @@ -229,7 +226,6 @@ index 0000000000000000000000000000000000000000..2b4e64796bf01b0a5fcb306850cd6083 + private static final Set allInstanced = new HashSet<>(); + private static CommentedFileConfig configFileInstance; + public static boolean alreadyInited = false; -+ private static MinecraftInternalPlugin NULL_PLUGIN = new MinecraftInternalPlugin(); + + public static void setupLatch(){ + Bukkit.getCommandMap().register("luminolconfig","luminol",new LuminolConfigCommand()); @@ -249,7 +245,13 @@ index 0000000000000000000000000000000000000000..2b4e64796bf01b0a5fcb306850cd6083 + + @Contract(" -> new") + public static @NotNull CompletableFuture reloadAsync(){ -+ return CompletableFuture.runAsync(LuminolConfig::reload,task -> Bukkit.getGlobalRegionScheduler().run(NULL_PLUGIN,scheduled -> task.run())); ++ return CompletableFuture.runAsync(LuminolConfig::reload,task -> RegionizedServer.getInstance().addTask(() -> { ++ try{ ++ task.run(); ++ }catch (Exception e){ ++ logger.error(e); ++ } ++ })); + } + + public static void dropAllInstanced(){ @@ -413,16 +415,175 @@ index 0000000000000000000000000000000000000000..2b4e64796bf01b0a5fcb306850cd6083 + } + } +} +diff --git a/src/main/java/me/earthme/luminol/utils/NullPlugin.java b/src/main/java/me/earthme/luminol/utils/NullPlugin.java +new file mode 100644 +index 0000000000000000000000000000000000000000..de94c8e39f0ae0da80d5a79af63413e287f5d190 +--- /dev/null ++++ b/src/main/java/me/earthme/luminol/utils/NullPlugin.java +@@ -0,0 +1,152 @@ ++package me.earthme.luminol.utils; ++ ++import io.papermc.paper.plugin.configuration.PluginMeta; ++import io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager; ++import org.bukkit.Server; ++import org.bukkit.command.Command; ++import org.bukkit.command.CommandSender; ++import org.bukkit.configuration.file.FileConfiguration; ++import org.bukkit.generator.BiomeProvider; ++import org.bukkit.generator.ChunkGenerator; ++import org.bukkit.plugin.*; ++import org.jetbrains.annotations.NotNull; ++import org.jetbrains.annotations.Nullable; ++ ++import java.io.File; ++import java.io.InputStream; ++import java.util.List; ++import java.util.logging.Logger; ++ ++public class NullPlugin extends PluginBase { ++ private boolean enabled = true; ++ ++ private final String pluginName; ++ private PluginDescriptionFile pdf; ++ ++ public NullPlugin() { ++ this.pluginName = "Minecraft"; ++ pdf = new PluginDescriptionFile(pluginName, "1.0", "nms"); ++ } ++ ++ public void setEnabled(boolean enabled) { ++ this.enabled = enabled; ++ } ++ ++ @Override ++ public File getDataFolder() { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public PluginDescriptionFile getDescription() { ++ return pdf; ++ } ++ // Paper start ++ @Override ++ public io.papermc.paper.plugin.configuration.PluginMeta getPluginMeta() { ++ return pdf; ++ } ++ // Paper end ++ ++ @Override ++ public FileConfiguration getConfig() { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public InputStream getResource(String filename) { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public void saveConfig() { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public void saveDefaultConfig() { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public void saveResource(String resourcePath, boolean replace) { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public void reloadConfig() { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public PluginLogger getLogger() { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public PluginLoader getPluginLoader() { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public Server getServer() { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public boolean isEnabled() { ++ return enabled; ++ } ++ ++ @Override ++ public void onDisable() { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public void onLoad() { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public void onEnable() { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public boolean isNaggable() { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public void setNaggable(boolean canNag) { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public @Nullable BiomeProvider getDefaultBiomeProvider(@NotNull String worldName, @Nullable String id) { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ @Override ++ public List onTabComplete(CommandSender sender, Command command, String alias, String[] args) { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ ++ // Paper start - lifecycle events ++ @Override ++ public @NotNull io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager getLifecycleManager() { ++ throw new UnsupportedOperationException("Not supported."); ++ } ++ // Paper end - lifecycle events ++} +\ No newline at end of file diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index bd333ffb44798069e180cad67c07d86425253024..bbd3b57b83b71ae9840124909f3864c36254f02c 100644 +index 301d7fa29fce2997a5881b3852896eff5af33672..0755e8f460f59e2dbc00cac73026bb441c04e9ea 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -222,6 +222,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -226,6 +226,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface this.paperConfigurations.initializeGlobalConfiguration(this.registryAccess()); this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); // Paper end - initialize global and world-defaults configuration + me.earthme.luminol.config.LuminolConfig.loadConfig(); //Luminol - load config file + me.earthme.luminol.config.LuminolConfig.setupLatch(); //Luminol - load config file + this.server.spark.enableEarlyIfRequested(); // Paper - spark // Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save if (this.convertOldUsers()) { - this.getProfileCache().save(false); // Paper diff --git a/patches/server/0004-Add-config-for-server-mod-name.patch b/patches/server/0004-Add-config-for-server-mod-name.patch index f520db9..93f299a 100644 --- a/patches/server/0004-Add-config-for-server-mod-name.patch +++ b/patches/server/0004-Add-config-for-server-mod-name.patch @@ -47,10 +47,10 @@ index 0000000000000000000000000000000000000000..94e7c8910e3623163528a844fd7a08b3 + } +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 355c8408da189a4805e206db0932c41f940930f0..3a6d567ee9db93606aec30255400dff4f9f87b05 100644 +index ac56b02498eb38883ae462be6ef3d15cb2a855aa..05b8f509b119b8166012567f865b99a23ad84ae2 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -2016,7 +2016,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop -Date: Wed, 7 Feb 2024 00:53:03 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 11:59:44 +0800 Subject: [PATCH] Add config for unsafe teleportation @@ -31,32 +31,27 @@ index 0000000000000000000000000000000000000000..ea374875f529b30db17e8b8cb07b99a6 + } +} diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index fad6a7185e8e9ea160b47ec9da56d08af9df8396..bda387d022a0725074a2871424cfec97508c420b 100644 +index 7a102b4e90fbc09b8653e5b566299efe24a04cf6..de5263b0261ed2f8f97b9525936be8067ddb79b2 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -4117,6 +4117,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4142,6 +4142,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - protected boolean tryEndPortal() { - io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot portal entity async"); -+ if (me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled && !(this instanceof Player)) return false; //Luminol - Unsafe teleportation - BlockPos pos = this.portalBlock; - ServerLevel world = this.portalWorld; - this.portalBlock = null; -diff --git a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java -index aeac09f628bd04070fd302842c304a7dfd39b229..dcdb7199ce731b2899ebd847f7c2d66dcd6d62bd 100644 ---- a/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/EndPortalBlock.java -@@ -61,6 +61,13 @@ public class EndPortalBlock extends BaseEntityBlock { - // return; // CraftBukkit - always fire event in case plugins wish to change it - } + public boolean endPortalLogicAsync(BlockPos portalPos) { + ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this, "Cannot portal entity async"); ++ if (!me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled && !(this instanceof Player)) return false; // Luminol - Unsafe teleportation -+ //Luminol start - Unsafe teleportation -+ if (me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled && !(entity instanceof net.minecraft.world.entity.player.Player)){ -+ entity.endPortalLogicAsync(); -+ return; -+ } -+ //Luminol end - Unsafe teleportation -+ - // Paper start - move all of this logic into portal tick - entity.portalWorld = ((ServerLevel)world); - entity.portalBlock = pos.immutable(); + ServerLevel destination = this.getServer().getLevel(this.level().getTypeKey() == net.minecraft.world.level.dimension.LevelStem.END ? Level.OVERWORLD : Level.END); + if (destination == null) { +diff --git a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +index 5d6b1a63a2a213f8a4e81c5e574847007a82007b..65582bd070b1a5a963abca1e91ff05bf177942c0 100644 +--- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java ++++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +@@ -419,7 +419,7 @@ public class FallingBlockEntity extends Entity { + boolean flag = (resourcekey1 == Level.END || resourcekey == Level.END) && resourcekey1 != resourcekey; + Entity entity = super.changeDimension(teleportTarget); + +- this.forceTickAfterTeleportToDuplicate = entity != null && flag && io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation; // Paper ++ this.forceTickAfterTeleportToDuplicate = entity != null && flag && (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowUnsafeEndPortalTeleportation || me.earthme.luminol.config.modules.fixes.UnsafeTeleportationConfig.enabled); // Paper // Luminol - Unsafe teleportation + return entity; + } + } diff --git a/patches/server/0006-Add-config-for-void-trading.patch b/patches/server/0006-Add-config-for-void-trading.patch index 49964e5..1e7999e 100644 --- a/patches/server/0006-Add-config-for-void-trading.patch +++ b/patches/server/0006-Add-config-for-void-trading.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Wed, 7 Feb 2024 00:59:18 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 12:01:17 +0800 Subject: [PATCH] Add config for void trading @@ -31,15 +31,15 @@ index 0000000000000000000000000000000000000000..22f3c6c70e4287f1bdd0b18f87f57efe + } +} diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index b194f3448b5199e1204da31e1408f2e80803a77d..6b8cbf681203c20eebb214c5c0b0fe0374aa30dc 100644 +index 72aa1b66950c1111793dad1583c19ac0d7e5823d..8e94a8abf0fddf1756600c8ed80c0b8b9851ef6f 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -3011,7 +3011,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -2818,7 +2818,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. // Spigot Start if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message // Paper start - Fix merchant inventory not closing on entity removal - if (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null) { -+ if (!me.earthme.luminol.config.modules.fixes.VoidTradingFixConfig.enabled && (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null)) { //Luminol - Add config for void trading ++ if (!me.earthme.luminol.config.modules.fixes.VoidTradingFixConfig.enabled && (entity.getBukkitEntity() instanceof org.bukkit.inventory.Merchant merchant && merchant.getTrader() != null)) { // Luminol - Add config for void trading merchant.getTrader().closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.UNLOADED); } // Paper end - Fix merchant inventory not closing on entity removal diff --git a/patches/server/0007-Add-config-for-vanilla-random.patch b/patches/server/0007-Add-config-for-vanilla-random.patch index a531ee7..2973de4 100644 --- a/patches/server/0007-Add-config-for-vanilla-random.patch +++ b/patches/server/0007-Add-config-for-vanilla-random.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Wed, 7 Feb 2024 02:33:00 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 12:02:01 +0800 Subject: [PATCH] Add config for vanilla random @@ -31,10 +31,10 @@ index 0000000000000000000000000000000000000000..0e6bfc03be660415c333024b56ac6565 + } +} diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index bda387d022a0725074a2871424cfec97508c420b..681f1476754f49d01b99a892ef2618cac341cd25 100644 +index de5263b0261ed2f8f97b9525936be8067ddb79b2..dfac4257d8de1a607ff952a1b27f61f3b4329516 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -568,7 +568,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -570,7 +570,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.bb = Entity.INITIAL_AABB; this.stuckSpeedMultiplier = Vec3.ZERO; this.nextStep = 1.0F; diff --git a/patches/server/0009-Add-a-simple-tpsbar.patch b/patches/server/0009-Add-a-simple-tpsbar.patch index 6d48ee1..f214600 100644 --- a/patches/server/0009-Add-a-simple-tpsbar.patch +++ b/patches/server/0009-Add-a-simple-tpsbar.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Wed, 7 Feb 2024 04:39:56 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 12:05:39 +0800 Subject: [PATCH] Add a simple tpsbar @@ -117,7 +117,7 @@ index 0000000000000000000000000000000000000000..aafb2f5052c7c8e5971a47308253badb +} diff --git a/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java new file mode 100644 -index 0000000000000000000000000000000000000000..3f1478dde900d671c4bfa43df80f629519cd602e +index 0000000000000000000000000000000000000000..e456c54b4ac3906a0a0310bdfba5ef39dc02c4ef --- /dev/null +++ b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java @@ -0,0 +1,225 @@ @@ -128,6 +128,7 @@ index 0000000000000000000000000000000000000000..3f1478dde900d671c4bfa43df80f6295 +import io.papermc.paper.threadedregions.TickRegions; +import io.papermc.paper.threadedregions.scheduler.ScheduledTask; +import me.earthme.luminol.config.modules.misc.TpsBarConfig; ++import me.earthme.luminol.utils.NullPlugin; +import net.kyori.adventure.bossbar.BossBar; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; @@ -138,7 +139,6 @@ index 0000000000000000000000000000000000000000..3f1478dde900d671c4bfa43df80f6295 +import org.apache.logging.log4j.Logger; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.entity.CraftPlayer; -+import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + @@ -146,7 +146,7 @@ index 0000000000000000000000000000000000000000..3f1478dde900d671c4bfa43df80f6295 +import java.util.concurrent.TimeUnit; + +public class GlobalServerTpsBar { -+ protected static final MinecraftInternalPlugin NULL_PLUGIN = new MinecraftInternalPlugin(); ++ protected static final NullPlugin NULL_PLUGIN = new NullPlugin(); + protected static final Map uuid2Bossbars = new HashMap<>(); + protected static volatile ScheduledTask tpsbarTask = null; + private static final Logger logger = LogManager.getLogger(); @@ -233,7 +233,7 @@ index 0000000000000000000000000000000000000000..3f1478dde900d671c4bfa43df80f6295 + private static void updateBarValues(){ + for (Player apiPlayer : Bukkit.getOnlinePlayers()){ + final ServerPlayer nmsPlayer = ((CraftPlayer) apiPlayer).getHandle(); -+ final ThreadedRegionizer.ThreadedRegion region = ((ServerLevel) nmsPlayer.level()).regioniser.getRegionAtUnsynchronised(nmsPlayer.sectionX,nmsPlayer.sectionZ); ++ final ThreadedRegionizer.ThreadedRegion region = ((ServerLevel) nmsPlayer.level()).regioniser.getRegionAtUnsynchronised(nmsPlayer.moonrise$getSectionX(),nmsPlayer.moonrise$getSectionZ()); + + if (region == null){ + continue; @@ -347,10 +347,10 @@ index 0000000000000000000000000000000000000000..3f1478dde900d671c4bfa43df80f6295 + } +} diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index e456435e2f0606e840c7f4c0ff522e49da6e40e1..0c9b1289f445b7951a8c92c6d9effb0a7fb8ba01 100644 +index 0755e8f460f59e2dbc00cac73026bb441c04e9ea..690d0f59daf8c4630c3d70b6fb690c2e1cedd402 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -850,6 +850,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -855,6 +855,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @Override public void stopServer() { @@ -359,22 +359,23 @@ index e456435e2f0606e840c7f4c0ff522e49da6e40e1..0c9b1289f445b7951a8c92c6d9effb0a //Util.shutdownExecutors(); // Paper - moved into super SkullBlockEntity.clear(); diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 8ee61c2415455f8d4ff1ae687753117a40eb687b..a8f2eddba3ac3b7c551d39e260e096067e8bdc0f 100644 +index 2480166aa0f7acefc1302bc44bc31b6ad48c0711..466928317a9777318aeb08e38d2bcf4c49de4cd8 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -302,6 +302,7 @@ public class ServerPlayer extends Player { - // Paper start - replace player chunk loader - private final java.util.concurrent.atomic.AtomicReference viewDistances = new java.util.concurrent.atomic.AtomicReference<>(new io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances(-1, -1, -1)); - public io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader; +@@ -303,7 +303,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple + public com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent + public @Nullable String clientBrandName = null; // Paper - Brand support + public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event +- + public volatile boolean isTpsBarVisible = false; //Luminol - Tps bar - - public io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances getViewDistances() { - return this.viewDistances.get(); + // Paper start - rewrite chunk system + private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader; + private final ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder viewDistanceHolder = new ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder(); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 639b8678ad7711582f2e912772a98233c5313f63..28583ad8117167400faf3ca0dc4bc9f3f44dbedb 100644 +index eb1e14be98b3731e0557726324593dee2eadd31b..e77b7d98f53676010b2b7d91eeab2addaca1241a 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -2370,6 +2370,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2389,6 +2389,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player { handle.expToDrop = data.getInt("expToDrop"); handle.keepLevel = data.getBoolean("keepLevel"); } @@ -384,7 +385,7 @@ index 639b8678ad7711582f2e912772a98233c5313f63..28583ad8117167400faf3ca0dc4bc9f3 } } -@@ -2391,6 +2394,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2410,6 +2413,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player { data.putLong("lastPlayed", System.currentTimeMillis()); data.putString("lastKnownName", handle.getScoreboardName()); diff --git a/patches/server/0010-Add-a-simple-membar.patch b/patches/server/0010-Add-a-simple-membar.patch index 961478a..3aba254 100644 --- a/patches/server/0010-Add-a-simple-membar.patch +++ b/patches/server/0010-Add-a-simple-membar.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Sun, 2 Jun 2024 12:18:05 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 12:18:09 +0800 Subject: [PATCH] Add a simple membar @@ -115,7 +115,7 @@ index 0000000000000000000000000000000000000000..b632c4a636974535bf001f010de1dcb6 +} diff --git a/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java b/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java new file mode 100644 -index 0000000000000000000000000000000000000000..a33a45194273cc1b4e4157a5449c7994968a3480 +index 0000000000000000000000000000000000000000..8c98e26667465d2976751b01d5e0bb1458e3d996 --- /dev/null +++ b/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java @@ -0,0 +1,186 @@ @@ -125,6 +125,7 @@ index 0000000000000000000000000000000000000000..a33a45194273cc1b4e4157a5449c7994 +import io.papermc.paper.threadedregions.TickRegions; +import io.papermc.paper.threadedregions.scheduler.ScheduledTask; +import me.earthme.luminol.config.modules.misc.MembarConfig; ++import me.earthme.luminol.utils.NullPlugin; +import net.kyori.adventure.bossbar.BossBar; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; @@ -135,7 +136,6 @@ index 0000000000000000000000000000000000000000..a33a45194273cc1b4e4157a5449c7994 +import org.apache.logging.log4j.Logger; +import org.bukkit.Bukkit; +import org.bukkit.craftbukkit.entity.CraftPlayer; -+import org.bukkit.craftbukkit.scheduler.MinecraftInternalPlugin; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; + @@ -144,7 +144,7 @@ index 0000000000000000000000000000000000000000..a33a45194273cc1b4e4157a5449c7994 +import java.util.*; + +public class GlobalServerMemoryBar { -+ protected static final MinecraftInternalPlugin NULL_PLUGIN = new MinecraftInternalPlugin(); ++ protected static final NullPlugin NULL_PLUGIN = new NullPlugin(); + protected static final Map uuid2Bossbars = new HashMap<>(); + protected static volatile ScheduledTask membarTask = null; + private static final Logger logger = LogManager.getLogger(); @@ -238,7 +238,7 @@ index 0000000000000000000000000000000000000000..a33a45194273cc1b4e4157a5449c7994 + + for (Player apiPlayer : Bukkit.getOnlinePlayers()){ + final ServerPlayer nmsPlayer = ((CraftPlayer) apiPlayer).getHandle(); -+ final ThreadedRegionizer.ThreadedRegion region = ((ServerLevel) nmsPlayer.level()).regioniser.getRegionAtUnsynchronised(nmsPlayer.sectionX,nmsPlayer.sectionZ); ++ final ThreadedRegionizer.ThreadedRegion region = ((ServerLevel) nmsPlayer.level()).regioniser.getRegionAtUnsynchronised(nmsPlayer.moonrise$getSectionX(),nmsPlayer.moonrise$getSectionZ()); + + if (region == null){ + continue; @@ -306,10 +306,10 @@ index 0000000000000000000000000000000000000000..a33a45194273cc1b4e4157a5449c7994 + } +} diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index 09bde51d3da062c5788151c15c448eaf2a02ea1b..dcdfc70e6c9b021b941a667f288ea09e3c1935e2 100644 +index 690d0f59daf8c4630c3d70b6fb690c2e1cedd402..8bd9baba560051e681277b8cea9d1374ea3ee825 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -851,6 +851,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -856,6 +856,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface @Override public void stopServer() { me.earthme.luminol.functions.GlobalServerTpsBar.cancelBarUpdateTask(); //Luminol - Tpsbar @@ -318,14 +318,38 @@ index 09bde51d3da062c5788151c15c448eaf2a02ea1b..dcdfc70e6c9b021b941a667f288ea09e //Util.shutdownExecutors(); // Paper - moved into super SkullBlockEntity.clear(); diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index db32beabfa7ba17b1c46d36fa1dc27bc20e06feb..25bdaec097572ee58432516ae5983f4841587046 100644 +index 466928317a9777318aeb08e38d2bcf4c49de4cd8..dc95bd8ed9db016f8d5419f832b11e0b77097c0b 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -303,6 +303,7 @@ public class ServerPlayer extends Player { - private final java.util.concurrent.atomic.AtomicReference viewDistances = new java.util.concurrent.atomic.AtomicReference<>(new io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances(-1, -1, -1)); - public io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader; +@@ -304,6 +304,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple + public @Nullable String clientBrandName = null; // Paper - Brand support + public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event public volatile boolean isTpsBarVisible = false; //Luminol - Tps bar + public volatile boolean isMemBarVisible = false; //Luminol - Memory bar + // Paper start - rewrite chunk system + private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader; + private final ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder viewDistanceHolder = new ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder(); +diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +index e77b7d98f53676010b2b7d91eeab2addaca1241a..61683135b0462770cfe93e16fd0d0c1bca13e045 100644 +--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java ++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +@@ -2392,6 +2392,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + //Luminol start - Tpsbar + getHandle().isTpsBarVisible = data.getBoolean("tpsbarVisible"); + //Luminol end ++ //Luminol start - Membar ++ getHandle().isMemBarVisible = data.getBoolean("membarVisible"); ++ //Luminol end + } + } - public io.papermc.paper.chunk.system.RegionizedPlayerChunkLoader.ViewDistances getViewDistances() { - return this.viewDistances.get(); +@@ -2416,6 +2419,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + //Luminol start - Tpsbar + data.putBoolean("tpsbarVisible",handle.isTpsBarVisible); + //Luminol end ++ //Luminol start - Membar ++ data.putBoolean("membarVisible", handle.isMemBarVisible); ++ //Luminol end + // Paper start - persist for use in offline save data + if (!nbttagcompound.contains("Paper")) { + nbttagcompound.put("Paper", new CompoundTag()); diff --git a/patches/server/0011-Add-config-for-username-check.patch b/patches/server/0011-Add-config-for-username-check.patch index 0544f93..2595dfd 100644 --- a/patches/server/0011-Add-config-for-username-check.patch +++ b/patches/server/0011-Add-config-for-username-check.patch @@ -31,10 +31,10 @@ index 0000000000000000000000000000000000000000..c7e4724cc4ab8d911bcaf0106c098b26 + } +} diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -index 83b09feec13a00c35e6f8d4f0ccdae1c8da9c0e5..d946a08f7a7532079eab83a7d4affc89e6e6ac1e 100644 +index d0f8a81ed0363764d185682c3de667703d30e8eb..c785b7fdc7cdba1598e841703df1bd5edded4757 100644 --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java -@@ -171,7 +171,8 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, +@@ -173,7 +173,8 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener, public void handleHello(ServerboundHelloPacket packet) { Validate.validState(this.state == ServerLoginPacketListenerImpl.State.HELLO, "Unexpected hello packet", new Object[0]); // Paper start - Validate usernames diff --git a/patches/server/0012-Add-config-for-offline-mode-warning.patch b/patches/server/0012-Add-config-for-offline-mode-warning.patch index 294852c..cddadb0 100644 --- a/patches/server/0012-Add-config-for-offline-mode-warning.patch +++ b/patches/server/0012-Add-config-for-offline-mode-warning.patch @@ -31,10 +31,10 @@ index 0000000000000000000000000000000000000000..502b93c7bda9e8577a1901a8777b7cf9 + } +} diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -index b82ed9280f96bacbb87ae77a6afd5d82d8863b58..7991026d6ab467b1e889d56815bded3700ae5765 100644 +index 8bd9baba560051e681277b8cea9d1374ea3ee825..79b79a5d41dc3568ae6a3d7701e6ac6b91045e36 100644 --- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java -@@ -294,7 +294,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -300,7 +300,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord"; String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/"; // Paper end - Add Velocity IP Forwarding Support diff --git a/patches/server/0015-Add-a-simple-watchdog-for-tick-regions.patch b/patches/server/0015-Add-a-simple-watchdog-for-tick-regions.patch deleted file mode 100644 index edf68e1..0000000 --- a/patches/server/0015-Add-a-simple-watchdog-for-tick-regions.patch +++ /dev/null @@ -1,274 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Sun, 10 Mar 2024 05:04:33 +0000 -Subject: [PATCH] Add a simple watchdog for tick regions - - -diff --git a/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java b/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java -index fc3d332aa1c1d469cedfe2aaa7102dcd78e25642..1ae61bc6603dd3ac290e3ead20416f9c5b63ff02 100644 ---- a/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java -+++ b/src/main/java/io/papermc/paper/threadedregions/RegionizedServer.java -@@ -279,6 +279,7 @@ public final class RegionizedServer { - */ - - private void globalTick(final int tickCount) { -+ me.earthme.luminol.utils.LuminolWatchDog.globalRegionHeartBeat(); //Luminol - /* - if (false) { - io.papermc.paper.threadedregions.ThreadedTicketLevelPropagator.main(null); -diff --git a/src/main/java/io/papermc/paper/threadedregions/TickRegions.java b/src/main/java/io/papermc/paper/threadedregions/TickRegions.java -index 2ad25dd345ab42125d456f2b9cf67d8c4515c8b7..183fede965c3d227bbcc7e54781869e09796081f 100644 ---- a/src/main/java/io/papermc/paper/threadedregions/TickRegions.java -+++ b/src/main/java/io/papermc/paper/threadedregions/TickRegions.java -@@ -402,10 +402,11 @@ public final class TickRegions implements ThreadedRegionizer.RegionCallbacks globalRegionLastKeepalive = null; -+ private static final Map,Long>> otherTickRegionKeepalive = Maps.newHashMap(); -+ private static final Executor checkTimer = CompletableFuture.delayedExecutor(50, TimeUnit.MILLISECONDS,Executors.newSingleThreadExecutor()); -+ private static final Logger logger = MinecraftServer.LOGGER; -+ private static int tickCount = 0; -+ private static volatile boolean runScheduleNext = true; -+ -+ public static void boot(){ -+ if (!WatchdogConfig.enabled){ -+ return; -+ } -+ -+ runCheck(); -+ } -+ -+ private static void scheduleCheck(){ -+ checkTimer.execute(LuminolWatchDog::runCheck); -+ } -+ -+ public static void stopTicking(){ -+ runScheduleNext = false; -+ } -+ -+ private static void runCheck(){ -+ try { -+ if (MinecraftServer.getServer().isStopped() || !runScheduleNext){ -+ return; -+ } -+ -+ tickCount++; -+ -+ final List> threadsToWarn = new ArrayList<>(); -+ final long currentTimeNano = System.nanoTime(); -+ boolean shouldStopServer = false; -+ -+ synchronized (keepaliveDataLock){ -+ if (globalRegionLastKeepalive != null){ -+ final Thread lastGlobalRegionThread = globalRegionLastKeepalive.getLeft(); -+ final long lastTicked = globalRegionLastKeepalive.getRight(); -+ -+ final long timeEscaped = currentTimeNano - lastTicked; -+ -+ if (timeEscaped >= WatchdogConfig.warnPeriodTicks * 50 * 1000 * 1000){ -+ threadsToWarn.add(Pair.of(lastGlobalRegionThread,timeEscaped)); -+ } -+ } -+ -+ for (Map.Entry,Long>> tickData : otherTickRegionKeepalive.entrySet()){ -+ final Thread targetThread = tickData.getKey(); -+ final Pair, Long> keepaliveData = tickData.getValue(); -+ final long lastKeepalive = keepaliveData.getRight(); -+ -+ final long timeEscaped = currentTimeNano - lastKeepalive; -+ -+ if (timeEscaped >= WatchdogConfig.warnPeriodTicks * 50 * 1000 * 1000){ -+ threadsToWarn.add(Pair.of(targetThread,timeEscaped)); -+ } -+ } -+ -+ for(Pair warnInfo : threadsToWarn){ -+ final Thread targetThread = warnInfo.getLeft(); -+ final long timeEscaped = warnInfo.getRight(); -+ -+ final ThreadedRegionizer.ThreadedRegion targetRegion = targetThread == globalRegionLastKeepalive.getKey() ? null : otherTickRegionKeepalive.get(targetThread).getLeft(); -+ -+ if (tickCount % WatchdogConfig.warnPeriodTicks == 0){ -+ dumpSingleRegion(targetThread,targetRegion,timeEscaped); -+ } -+ -+ if (timeEscaped > WatchdogConfig.timeOutTicks * 50 * 1000 * 1000){ -+ shouldStopServer = true; -+ runScheduleNext = false; -+ } -+ } -+ -+ if (shouldStopServer){ -+ MinecraftServer.getServer().stopServer(); -+ } -+ } -+ }finally { -+ if (runScheduleNext){ -+ scheduleCheck(); -+ } -+ } -+ } -+ -+ private static void dumpSingleRegion(@NotNull Thread thread, @Nullable ThreadedRegionizer.ThreadedRegion region,long timeEscaped){ -+ final StringBuilder messageBuilder = new StringBuilder(); -+ messageBuilder.append("====================================").append("\n"); -+ messageBuilder.append("There is a single region that has no responding in " + TimeUnit.NANOSECONDS.toSeconds(timeEscaped) + " seconds!").append("\n"); -+ messageBuilder.append("If you believe this is a bug,please send it to github issue after checking your plugins!").append("\n"); -+ messageBuilder.append("Tick Region: ").append(region == null ? "Global Region" : "ChunkX(Center): " + region.getCenterChunk().x + " ChunkZ(Center): " + region.getCenterChunk().z).append("\n"); -+ messageBuilder.append("Thread Name: ").append(thread.getName()).append("\n"); -+ messageBuilder.append("Thread Id: ").append(thread.getId()).append("\n"); -+ -+ final ThreadInfo targetThreadInfo = ManagementFactory.getThreadMXBean().getThreadInfo(thread.getId()); -+ -+ messageBuilder.append("Is Suspend: ").append(targetThreadInfo.isSuspended()).append("\n"); -+ messageBuilder.append("Thread State: ").append(targetThreadInfo.getThreadState()).append("\n"); -+ messageBuilder.append("Thread Priority: ").append(targetThreadInfo.getPriority()).append("\n"); -+ messageBuilder.append("Thread Stack Trace:").append("\n"); -+ -+ for (StackTraceElement stackTraceElement : StacktraceDeobfuscator.INSTANCE.deobfuscateStacktrace(thread.getStackTrace())){ -+ messageBuilder.append("\t\t").append(stackTraceElement).append("\n"); -+ } -+ -+ messageBuilder.append("\n"); -+ messageBuilder.append("===================================="); -+ -+ logger.error(messageBuilder.toString()); -+ } -+ -+ public static void globalRegionHeartBeat(){ -+ if (!WatchdogConfig.enabled){ -+ return; -+ } -+ -+ synchronized (keepaliveDataLock){ -+ globalRegionLastKeepalive = Pair.of(Thread.currentThread(),System.nanoTime()); -+ } -+ } -+ -+ public static void tickRegionHeartBeat(){ -+ if (!WatchdogConfig.enabled){ -+ return; -+ } -+ -+ final ThreadedRegionizer.ThreadedRegion currentRegion = TickRegionScheduler.getCurrentRegion(); -+ -+ if (currentRegion == null) { -+ return; -+ } -+ -+ synchronized (keepaliveDataLock){ -+ if (!otherTickRegionKeepalive.containsKey(Thread.currentThread())){ -+ otherTickRegionKeepalive.put(Thread.currentThread(),Pair.of(currentRegion,System.nanoTime())); -+ return; -+ } -+ -+ otherTickRegionKeepalive.replace(Thread.currentThread(),Pair.of(currentRegion,System.nanoTime())); -+ } -+ } -+ -+ public static void releaseTickRegion(){ -+ if (!WatchdogConfig.enabled){ -+ return; -+ } -+ -+ synchronized (keepaliveDataLock){ -+ otherTickRegionKeepalive.remove(Thread.currentThread()); -+ } -+ } -+} -\ No newline at end of file -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 3a6d567ee9db93606aec30255400dff4f9f87b05..14114e868d3547f2f2d4149312742d5e995e8959 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1003,6 +1003,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { @@ -50,7 +50,7 @@ index aac1df9e2c0652bc6348af0404deba7465f82d42..4dcf71e9f861596bd02902d0851ffa57 } - + }; -+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(serverLevel2, blockPos) && me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled) ++ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(serverLevel2, blockPos) && me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled) + io.papermc.paper.threadedregions.RegionizedServer.getInstance().taskQueue.queueTickTaskQueue(serverLevel2, blockPos.getX() >> 4, blockPos.getZ() >> 4, scheduledRelease); + else + scheduledRelease.run(); @@ -59,7 +59,7 @@ index aac1df9e2c0652bc6348af0404deba7465f82d42..4dcf71e9f861596bd02902d0851ffa57 } }); diff --git a/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java b/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java -index d1a9b62d3304916275dd6b4c4e783cf1563b5e21..dd1baee4bc36b28b7e10d98525d55cbcfb562649 100644 +index d1a9b62d3304916275dd6b4c4e783cf1563b5e21..972fcb2282a20a75fbc7fc9e82c9fe71d32d4a74 100644 --- a/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java +++ b/src/main/java/net/minecraft/world/entity/ai/behavior/YieldJobSite.java @@ -6,6 +6,7 @@ import net.minecraft.core.BlockPos; @@ -78,20 +78,20 @@ index d1a9b62d3304916275dd6b4c4e783cf1563b5e21..dd1baee4bc36b28b7e10d98525d55cbc + final GlobalPos globalPos = context.get(potentialJobSite); //Luminol - Try fixing off main POI accessing + final ServerLevel targetLevel = net.minecraft.server.MinecraftServer.getServer().getLevel(globalPos.dimension()); //Luminol - Try fixing off main POI accessing + BlockPos blockPos = globalPos.pos(); //Luminol - Try fixing off main POI accessing -+ if (!io.papermc.paper.util.TickThread.isTickThreadFor(targetLevel, blockPos) && me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled) return true; //Luminol - Try fixing off main POI accessing ++ if (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(targetLevel, blockPos) && me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled) return true; //Luminol - Try fixing off main POI accessing Optional> optional = world.getPoiManager().getType(blockPos); if (optional.isEmpty()) { return true; diff --git a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java -index cf69b4ed4a40015a23d053230c3f326a700788ef..5fdcad0038aad61d68cd329e72c8db309c5e3926 100644 +index 1e7f11e5dda502fde6ca122f3edb2d2a161f3469..e57b5a3fddb890efc0245be5efb57c91d1e05f87 100644 --- a/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java +++ b/src/main/java/net/minecraft/world/entity/ai/village/poi/PoiManager.java -@@ -96,7 +96,7 @@ public class PoiManager extends SectionStorage { +@@ -226,7 +226,7 @@ public class PoiManager extends SectionStorage implements ca.spotted public Stream getInSquare(Predicate> typePredicate, BlockPos pos, int radius, PoiManager.Occupancy occupationStatus) { int i = Math.floorDiv(radius, 16) + 1; - return ChunkPos.rangeClosed(new ChunkPos(pos), i).flatMap(chunkPos -> this.getInChunk(typePredicate, chunkPos, occupationStatus)).filter(poi -> { -+ return ChunkPos.rangeClosed(new ChunkPos(pos), i).filter(cpos -> me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled ? io.papermc.paper.util.TickThread.isTickThreadFor(this.world,cpos) : true).flatMap(chunkPos -> this.getInChunk(typePredicate, chunkPos, occupationStatus)).filter(poi -> { //Luminol - Fix off region POI access ++ return ChunkPos.rangeClosed(new ChunkPos(pos), i).filter(cpos -> me.earthme.luminol.config.modules.fixes.FoliaPOIAccessOffRegionFixConfig.enabled ? ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.world,cpos) : true).flatMap(chunkPos -> this.getInChunk(typePredicate, chunkPos, occupationStatus)).filter(poi -> { //Luminol - Fix off region POI access BlockPos blockPos2 = poi.getPos(); return Math.abs(blockPos2.getX() - pos.getX()) <= radius && Math.abs(blockPos2.getZ() - pos.getZ()) <= radius; }); diff --git a/patches/server/0019-Prevent-teleportAsync-calling-during-moving-event-be.patch b/patches/server/0018-Prevent-teleportAsync-calling-during-moving-event-be.patch similarity index 85% rename from patches/server/0019-Prevent-teleportAsync-calling-during-moving-event-be.patch rename to patches/server/0018-Prevent-teleportAsync-calling-during-moving-event-be.patch index d066391..3db6bcd 100644 --- a/patches/server/0019-Prevent-teleportAsync-calling-during-moving-event-be.patch +++ b/patches/server/0018-Prevent-teleportAsync-calling-during-moving-event-be.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Wed, 7 Feb 2024 06:58:52 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 12:33:32 +0800 Subject: [PATCH] Prevent teleportAsync calling during moving event being @@ -35,12 +35,12 @@ index 0000000000000000000000000000000000000000..8f1449545d6d217b46a9ffae705123da + } +} diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index bdcf43104a53f530453615b17bd690c7a5c0a78d..8ec763f933e79a1c8e7a7d3b3c0277ca2fca4b74 100644 +index a278097ed9a8a6bada11bef1af2eda617f040ea8..e36672e7eb8393f58326091976ac45b5aa905013 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -348,6 +348,10 @@ public class ServerPlayer extends Player { - public double lastEntitySpawnRadiusSquared = -1.0; - // Paper end - optimise chunk tick iteration +@@ -335,6 +335,10 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple + } + // Paper end - rewrite chunk system + //Luminol start - Prevent teleportAsync calling during moving event being handled + public boolean handlingMoveEvent = false; @@ -50,10 +50,10 @@ index bdcf43104a53f530453615b17bd690c7a5c0a78d..8ec763f933e79a1c8e7a7d3b3c0277ca super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); this.chatVisibility = ChatVisiblity.FULL; diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 2ae2527bbe5a08af98eb6405a8403c2199052f19..7ddb7d5aa1047eb8151aef01d5db694d2683cf51 100644 +index 73057c695addefd9c8fa0949743803fdeab60dda..a6a05faf46aa236e6734cfe2f6a90d25cf857c4d 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -695,7 +695,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -686,7 +686,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl Location oldTo = to.clone(); PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); @@ -63,7 +63,7 @@ index 2ae2527bbe5a08af98eb6405a8403c2199052f19..7ddb7d5aa1047eb8151aef01d5db694d // If the event is cancelled we move the player back to their old location. if (event.isCancelled()) { -@@ -1612,7 +1614,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -1562,7 +1564,9 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl Location oldTo = to.clone(); PlayerMoveEvent event = new PlayerMoveEvent(player, from, to); @@ -74,12 +74,12 @@ index 2ae2527bbe5a08af98eb6405a8403c2199052f19..7ddb7d5aa1047eb8151aef01d5db694d // If the event is cancelled we move the player back to their old location. if (event.isCancelled()) { diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index fd1dbe0067d074101884fe1a66045f5316adeafc..816196016cad939c033a583e326ffff3894dca29 100644 +index f153159600fe14eff770b426fde318a4bd4b5b44..fe3aeadd4357cc0b28ac9cfc21f0f1100d22d3a0 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -4038,6 +4038,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -4073,6 +4073,18 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess java.util.function.Consumer teleportComplete) { - io.papermc.paper.util.TickThread.ensureTickThread(this, "Cannot teleport entity async"); + ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread(this, "Cannot teleport entity async"); + //Luminol start - Prevent teleportAsync calling during moving event being handled + if (this instanceof ServerPlayer player && me.earthme.luminol.config.modules.fixes.FoliaTeleportAsyncFixConfig.enabled){ @@ -93,11 +93,11 @@ index fd1dbe0067d074101884fe1a66045f5316adeafc..816196016cad939c033a583e326ffff3 + } + //Luminol end + - if (!ServerLevel.isInSpawnableBounds(new BlockPos(io.papermc.paper.util.CoordinateUtils.getBlockX(pos), io.papermc.paper.util.CoordinateUtils.getBlockY(pos), io.papermc.paper.util.CoordinateUtils.getBlockZ(pos)))) { + if (!ServerLevel.isInSpawnableBounds(new BlockPos(ca.spottedleaf.moonrise.common.util.CoordinateUtils.getBlockX(pos), ca.spottedleaf.moonrise.common.util.CoordinateUtils.getBlockY(pos), ca.spottedleaf.moonrise.common.util.CoordinateUtils.getBlockZ(pos)))) { return false; } diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java -index 4d7454e5a64fc18e63793a221daa94617f17c666..a1dc46ec6d53389eb7c801a7a14c4169406de580 100644 +index f403fc311a974558233028663dbe14c27b27d3f9..fbc936a218bc972866486f384baaa44949b29580 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java @@ -375,7 +375,21 @@ public abstract class AbstractMinecart extends VehicleEntity { @@ -123,10 +123,10 @@ index 4d7454e5a64fc18e63793a221daa94617f17c666..a1dc46ec6d53389eb7c801a7a14c4169 // CraftBukkit end if (this.getMinecartType() == AbstractMinecart.Type.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) { diff --git a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java -index b068cff9b5aa457d65b679529956e8210296d799..d002519a356072284faa5f879e188f3e3062939f 100644 +index f1955afc8e367f80ead85bd5ad3b8d66c255565a..19c19532947f785c8538f5bbdc6a88f6e09efbab 100644 --- a/src/main/java/net/minecraft/world/entity/vehicle/Boat.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/Boat.java -@@ -370,8 +370,22 @@ public class Boat extends VehicleEntity implements VariantHolder { +@@ -374,8 +374,22 @@ public class Boat extends VehicleEntity implements Leashable, VariantHolder { private boolean tryComputePath(Mob entity, WalkTarget walkTarget, long time) { BlockPos blockPos = walkTarget.getTarget().currentBlockPosition(); -+ if (io.papermc.paper.util.TickThread.isTickThreadFor((ServerLevel) entity.level(), blockPos)) // Kaiiju - Don't pathfind outside region ++ if (ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor((ServerLevel) entity.level(), blockPos)) // Kaiiju - Don't pathfind outside region this.path = entity.getNavigation().createPath(blockPos, 0); + else this.path = null; // Kaiiju - Don't pathfind outside region this.speedModifier = walkTarget.getSpeedModifier(); diff --git a/patches/server/0020-Added-linear-region-format-from-LinearPurpur.patch b/patches/server/0020-Added-linear-region-format-from-LinearPurpur.patch deleted file mode 100644 index f9f9947..0000000 --- a/patches/server/0020-Added-linear-region-format-from-LinearPurpur.patch +++ /dev/null @@ -1,1000 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Thu, 27 Jun 2024 18:25:12 +0800 -Subject: [PATCH] Added linear region format from LinearPurpur - - -diff --git a/build.gradle.kts b/build.gradle.kts -index ab07c307bea0d3b79a6239bdcca9714e1ddf3b28..0f543eccedc7191f8c391583af30231c8b68b2a4 100644 ---- a/build.gradle.kts -+++ b/build.gradle.kts -@@ -31,6 +31,10 @@ dependencies { - alsoShade(log4jPlugins.output) - implementation("io.netty:netty-codec-haproxy:4.1.97.Final") // Paper - Add support for proxy protocol - // Paper end -+ // LinearPaper start -+ implementation("com.github.luben:zstd-jni:1.5.6-3") -+ implementation("org.lz4:lz4-java:1.8.0") -+ // LinearPaper end - implementation("org.apache.logging.log4j:log4j-iostreams:2.22.1") // Paper - remove exclusion - implementation("org.ow2.asm:asm-commons:9.7") - implementation("org.spongepowered:configurate-yaml:4.2.0-SNAPSHOT") // Paper - config files -diff --git a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java b/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java -index 2096e57c025858519e7c46788993b9aac1ec60e8..9c8a3749c09ca4f5389cc9d240f713f0a12badee 100644 ---- a/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java -+++ b/src/main/java/io/papermc/paper/chunk/system/io/RegionFileIOThread.java -@@ -1077,9 +1077,9 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread { - return this.getCache().doesRegionFileNotExistNoIO(new ChunkPos(chunkX, chunkZ)); - } - -- public T computeForRegionFile(final int chunkX, final int chunkZ, final boolean existingOnly, final Function function) { -+ public T computeForRegionFile(final int chunkX, final int chunkZ, final boolean existingOnly, final Function function) { // LinearPaper - final RegionFileStorage cache = this.getCache(); -- final RegionFile regionFile; -+ final org.stupidcraft.linearpaper.region.AbstractRegionFile regionFile; // LinearPaper - synchronized (cache) { - try { - regionFile = cache.getRegionFile(new ChunkPos(chunkX, chunkZ), existingOnly, true); -@@ -1092,19 +1092,19 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread { - return function.apply(regionFile); - } finally { - if (regionFile != null) { -- regionFile.fileLock.unlock(); -+ regionFile.getFileLock().unlock(); // LinearPaper - } - } - } - -- public T computeForRegionFileIfLoaded(final int chunkX, final int chunkZ, final Function function) { -+ public T computeForRegionFileIfLoaded(final int chunkX, final int chunkZ, final Function function) { // LinearPaper - final RegionFileStorage cache = this.getCache(); -- final RegionFile regionFile; -+ final org.stupidcraft.linearpaper.region.AbstractRegionFile regionFile; // LinearPaper - - synchronized (cache) { - regionFile = cache.getRegionFileIfLoaded(new ChunkPos(chunkX, chunkZ)); - if (regionFile != null) { -- regionFile.fileLock.lock(); -+ regionFile.getFileLock().lock(); // LinearPaper - } - } - -@@ -1112,7 +1112,7 @@ public final class RegionFileIOThread extends PrioritisedQueueExecutorThread { - return function.apply(regionFile); - } finally { - if (regionFile != null) { -- regionFile.fileLock.unlock(); -+ regionFile.getFileLock().unlock(); // LinearPaper - } - } - } -diff --git a/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java b/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java -new file mode 100644 -index 0000000000000000000000000000000000000000..e0adfc6422f8db2c2bb81cbe8257f049a5334c93 ---- /dev/null -+++ b/src/main/java/me/earthme/luminol/config/modules/misc/RegionFormatConfig.java -@@ -0,0 +1,52 @@ -+package me.earthme.luminol.config.modules.misc; -+ -+import com.electronwill.nightconfig.core.file.CommentedFileConfig; -+import com.mojang.logging.LogUtils; -+import me.earthme.luminol.config.ConfigInfo; -+import me.earthme.luminol.config.DoNotLoad; -+import me.earthme.luminol.config.EnumConfigCategory; -+import me.earthme.luminol.config.IConfigModule; -+import org.slf4j.Logger; -+import org.stupidcraft.linearpaper.region.EnumRegionFileExtension; -+ -+public class RegionFormatConfig implements IConfigModule { -+ @ConfigInfo(baseName = "region_format") -+ public static String regionFormatTypeName = "MCA"; -+ @DoNotLoad -+ public static EnumRegionFileExtension regionFormatType = EnumRegionFileExtension.LINEAR; -+ @ConfigInfo(baseName = "linear_compress_level") -+ public static int linearCompressionLevel = 1; -+ @ConfigInfo(baseName = "thrown_on_unknown_extension_detected") -+ public static boolean throwOnUnknownExtension = false; -+ @ConfigInfo(baseName = "flush_every_seconds") -+ public static int linearFlushFrequency = 5; -+ -+ @DoNotLoad -+ private static final Logger logger = LogUtils.getLogger(); -+ -+ @Override -+ public EnumConfigCategory getCategory() { -+ return EnumConfigCategory.MISC; -+ } -+ -+ @Override -+ public String getBaseName() { -+ return "region_format_settings"; -+ } -+ -+ @Override -+ public void onLoaded(CommentedFileConfig configInstance) { -+ regionFormatType = EnumRegionFileExtension.fromName(regionFormatTypeName); -+ if (regionFormatType == EnumRegionFileExtension.UNKNOWN){ -+ logger.error("Unknown region file type {} !Falling back to MCA file.", regionFormatTypeName); -+ regionFormatType = EnumRegionFileExtension.MCA; -+ } -+ -+ if (linearCompressionLevel > 23 || linearCompressionLevel < 1) { -+ logger.error("Linear region compression level should be between 1 and 22 in config: {}", linearCompressionLevel); -+ logger.error("Falling back to compression level 1."); -+ linearCompressionLevel = 1; -+ } -+ -+ } -+} -diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 14114e868d3547f2f2d4149312742d5e995e8959..6ead4f65a07defbb7778365ce92d891528dc67aa 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -923,7 +923,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> progressMap = Reference2FloatMaps.synchronize(new Reference2FloatOpenHashMap()); - volatile Component status = Component.translatable("optimizeWorld.stage.counting"); -- static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.mca$"); -+ static final Pattern REGEX = Pattern.compile("^r\\.(-?[0-9]+)\\.(-?[0-9]+)\\.(linear | mca)$"); // LinearPaper - final DimensionDataStorage overworldDataStorage; - - public WorldUpgrader(LevelStorageSource.LevelStorageAccess session, DataFixer dataFixer, RegistryAccess dynamicRegistryManager, boolean eraseCache, boolean recreateRegionFiles) { -@@ -344,7 +344,7 @@ public class WorldUpgrader { - if (flag1) { - this.onFileFinished(worldupgrader_e.file); - } else { -- WorldUpgrader.LOGGER.error("Failed to convert region file {}", worldupgrader_e.file.getPath()); -+ WorldUpgrader.LOGGER.error("Failed to convert region file {}", worldupgrader_e.file.getRegionFile()); // LinearPaper - } - } - } -@@ -406,7 +406,7 @@ public class WorldUpgrader { - - private static List getAllChunkPositions(RegionStorageInfo key, Path regionDirectory) { - File[] afile = regionDirectory.toFile().listFiles((file, s) -> { -- return s.endsWith(".mca"); -+ return s.endsWith(".linear") || s.endsWith(".mca"); // LinearPaper - }); - - if (afile == null) { -@@ -426,7 +426,7 @@ public class WorldUpgrader { - List list1 = Lists.newArrayList(); - - try { -- RegionFile regionfile = new RegionFile(key, file.toPath(), regionDirectory, true); -+ org.stupidcraft.linearpaper.region.AbstractRegionFile regionfile = org.stupidcraft.linearpaper.region.AbstractRegionFileFactory.getAbstractRegionFile(key, file.toPath(), regionDirectory, true); // LinearPaper - - try { - for (int i1 = 0; i1 < 32; ++i1) { -@@ -489,13 +489,13 @@ public class WorldUpgrader { - - protected abstract boolean tryProcessOnePosition(T storage, ChunkPos chunkPos, ResourceKey worldKey); - -- private void onFileFinished(RegionFile regionFile) { -+ private void onFileFinished(org.stupidcraft.linearpaper.region.AbstractRegionFile regionFile) { // LinearPaper - if (WorldUpgrader.this.recreateRegionFiles) { - if (this.previousWriteFuture != null) { - this.previousWriteFuture.join(); - } - -- Path path = regionFile.getPath(); -+ Path path = regionFile.getRegionFile(); // LinearPaper - Path path1 = path.getParent(); - Path path2 = WorldUpgrader.resolveRecreateDirectory(path1).resolve(path.getFileName().toString()); - -@@ -514,7 +514,7 @@ public class WorldUpgrader { - } - } - -- static record FileToUpgrade(RegionFile file, List chunksToUpgrade) { -+ static record FileToUpgrade(org.stupidcraft.linearpaper.region.AbstractRegionFile file, List chunksToUpgrade) { // LinearPaper - - } - -diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java -index 1362a47943cf1a51a185a15094b1f74c94bf40ef..340b9d9fdfa54b7bef05b8ca47b8f3c2a6e31f17 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java -+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFile.java -@@ -28,7 +28,7 @@ import net.minecraft.nbt.NbtIo; // Paper - import net.minecraft.world.level.ChunkPos; - import org.slf4j.Logger; - --public class RegionFile implements AutoCloseable { -+public class RegionFile implements AutoCloseable, org.stupidcraft.linearpaper.region.AbstractRegionFile { // LinearPaper - - private static final Logger LOGGER = LogUtils.getLogger(); - private static final int SECTOR_BYTES = 4096; -@@ -59,6 +59,15 @@ public class RegionFile implements AutoCloseable { - long sign = -remainingBytes; // sign is 1 if nonzero - return sectors + (sign >>> 63); - } -+ -+ // LinearPaper start - Abstract getters -+ public Path getRegionFile() { -+ return this.path; -+ } -+ public java.util.concurrent.locks.ReentrantLock getFileLock() { -+ return this.fileLock; -+ } -+ // LinearPaper end - - private static final CompoundTag OVERSIZED_COMPOUND = new CompoundTag(); - -@@ -130,7 +139,7 @@ public class RegionFile implements AutoCloseable { - } - - // note: only call for CHUNK regionfiles -- boolean recalculateHeader() throws IOException { -+ public boolean recalculateHeader() throws IOException { // LinearPaper - if (!this.canRecalcHeader) { - return false; - } -@@ -972,10 +981,10 @@ public class RegionFile implements AutoCloseable { - private static int getChunkIndex(int x, int z) { - return (x & 31) + (z & 31) * 32; - } -- synchronized boolean isOversized(int x, int z) { -+ public synchronized boolean isOversized(int x, int z) { // LinearPaper - return this.oversized[getChunkIndex(x, z)] == 1; - } -- synchronized void setOversized(int x, int z, boolean oversized) throws IOException { -+ public synchronized void setOversized(int x, int z, boolean oversized) throws IOException { // LinearPaper - final int offset = getChunkIndex(x, z); - boolean previous = this.oversized[offset] == 1; - this.oversized[offset] = (byte) (oversized ? 1 : 0); -@@ -1014,7 +1023,7 @@ public class RegionFile implements AutoCloseable { - return this.path.getParent().resolve(this.path.getFileName().toString().replaceAll("\\.mca$", "") + "_oversized_" + x + "_" + z + ".nbt"); - } - -- synchronized CompoundTag getOversizedData(int x, int z) throws IOException { -+ public synchronized CompoundTag getOversizedData(int x, int z) throws IOException { // LinearPaper - Path file = getOversizedFile(x, z); - try (DataInputStream out = new DataInputStream(new java.io.BufferedInputStream(new InflaterInputStream(Files.newInputStream(file))))) { - return NbtIo.read((java.io.DataInput) out); -diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 1090b7e36e3c1c105bc36135b82751c651f237d4..329d4f5b5123d9d02b7c60046e28d1241e66425b 100644 ---- a/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -+++ b/src/main/java/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -@@ -21,7 +21,7 @@ public class RegionFileStorage implements AutoCloseable { - - public static final String ANVIL_EXTENSION = ".mca"; - private static final int MAX_CACHE_SIZE = 256; -- public final Long2ObjectLinkedOpenHashMap regionCache = new Long2ObjectLinkedOpenHashMap(); -+ public final Long2ObjectLinkedOpenHashMap regionCache = new Long2ObjectLinkedOpenHashMap(); // LinearPaper - private final RegionStorageInfo info; - private final Path folder; - private final boolean sync; -@@ -72,7 +72,7 @@ public class RegionFileStorage implements AutoCloseable { - @Nullable - public static ChunkPos getRegionFileCoordinates(Path file) { - String fileName = file.getFileName().toString(); -- if (!fileName.startsWith("r.") || !fileName.endsWith(".mca")) { -+ if (!fileName.startsWith("r.") || !fileName.endsWith(".linear") || !fileName.endsWith(".mca")) { // LinearPaper - return null; - } - -@@ -94,29 +94,29 @@ public class RegionFileStorage implements AutoCloseable { - // Paper end - - // Paper start -- public synchronized RegionFile getRegionFileIfLoaded(ChunkPos chunkcoordintpair) { -+ public synchronized org.stupidcraft.linearpaper.region.AbstractRegionFile getRegionFileIfLoaded(ChunkPos chunkcoordintpair) { // LinearPaper - return this.regionCache.getAndMoveToFirst(ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ())); - } - - public synchronized boolean chunkExists(ChunkPos pos) throws IOException { -- RegionFile regionfile = getRegionFile(pos, true); -+ org.stupidcraft.linearpaper.region.AbstractRegionFile regionfile = getRegionFile(pos, true); // LinearPaper - - return regionfile != null ? regionfile.hasChunk(pos) : false; - } - -- public synchronized RegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit -+ public synchronized org.stupidcraft.linearpaper.region.AbstractRegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly) throws IOException { // CraftBukkit // LinearPaper - return this.getRegionFile(chunkcoordintpair, existingOnly, false); - } -- public synchronized RegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly, boolean lock) throws IOException { -+ public synchronized org.stupidcraft.linearpaper.region.AbstractRegionFile getRegionFile(ChunkPos chunkcoordintpair, boolean existingOnly, boolean lock) throws IOException { // LinearPaper - // Paper end - long i = ChunkPos.asLong(chunkcoordintpair.getRegionX(), chunkcoordintpair.getRegionZ()); final long regionPos = i; // Paper - OBFHELPER -- RegionFile regionfile = (RegionFile) this.regionCache.getAndMoveToFirst(i); -+ org.stupidcraft.linearpaper.region.AbstractRegionFile regionfile = (org.stupidcraft.linearpaper.region.AbstractRegionFile) this.regionCache.getAndMoveToFirst(i); // LinearPaper - - if (regionfile != null) { - // Paper start - if (lock) { - // must be in this synchronized block -- regionfile.fileLock.lock(); -+ regionfile.getFileLock().lock(); // LinearPaper - } - // Paper end - return regionfile; -@@ -127,28 +127,37 @@ public class RegionFileStorage implements AutoCloseable { - } - // Paper end - cache regionfile does not exist state - if (this.regionCache.size() >= io.papermc.paper.configuration.GlobalConfiguration.get().misc.regionFileCacheSize) { // Paper - Sanitise RegionFileCache and make configurable -- ((RegionFile) this.regionCache.removeLast()).close(); -+ ((org.stupidcraft.linearpaper.region.AbstractRegionFile) this.regionCache.removeLast()).close(); // LinearPaper - } - - // Paper - only create directory if not existing only - moved down - Path path = this.folder; - int j = chunkcoordintpair.getRegionX(); -- Path path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); // Paper - diff on change -- if (existingOnly && !java.nio.file.Files.exists(path1)) { // Paper start - cache regionfile does not exist state -- this.markNonExisting(regionPos); -- return null; // CraftBukkit -+ // LinearPaper start -+ Path path1; -+ if (existingOnly) { -+ Path linear = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".linear"); -+ Path anvil = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + ".mca"); -+ path1 = java.nio.file.Files.exists(linear) ? linear : java.nio.file.Files.exists(anvil) ? anvil : null; -+ if (path1 == null) { -+ this.markNonExisting(regionPos); -+ return null; // CraftBukkit -+ } - } else { -+ String extension = me.earthme.luminol.config.modules.misc.RegionFormatConfig.regionFormatType.getExtensionName(); -+ path1 = path.resolve("r." + j + "." + chunkcoordintpair.getRegionZ() + extension); -+ // LinearPaper end - this.createRegionFile(regionPos); - } - // Paper end - cache regionfile does not exist state - FileUtil.createDirectoriesSafe(this.folder); // Paper - only create directory if not existing only - moved from above -- RegionFile regionfile1 = new RegionFile(this.info, path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header -+ org.stupidcraft.linearpaper.region.AbstractRegionFile regionfile1 = org.stupidcraft.linearpaper.region.AbstractRegionFileFactory.getAbstractRegionFile(this.info, path1, this.folder, this.sync, this.isChunkData); // Paper - allow for chunk regionfiles to regen header // LinearPaper - - this.regionCache.putAndMoveToFirst(i, regionfile1); - // Paper start - if (lock) { - // must be in this synchronized block -- regionfile1.fileLock.lock(); -+ regionfile1.getFileLock().lock(); // LinearPaper - } - // Paper end - return regionfile1; -@@ -160,7 +169,7 @@ public class RegionFileStorage implements AutoCloseable { - org.apache.logging.log4j.LogManager.getLogger().fatal(msg + " (" + file.toString().replaceAll(".+[\\\\/]", "") + " - " + x + "," + z + ") Go clean it up to remove this message. /minecraft:tp " + (x<<4)+" 128 "+(z<<4) + " - DO NOT REPORT THIS TO PAPER - You may ask for help on Discord, but do not file an issue. These error messages can not be removed."); - } - -- private static CompoundTag readOversizedChunk(RegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { -+ private static CompoundTag readOversizedChunk(org.stupidcraft.linearpaper.region.AbstractRegionFile regionfile, ChunkPos chunkCoordinate) throws IOException { // LinearPaper - synchronized (regionfile) { - try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) { - CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z); -@@ -195,14 +204,14 @@ public class RegionFileStorage implements AutoCloseable { - @Nullable - public CompoundTag read(ChunkPos pos) throws IOException { - // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing -- RegionFile regionfile = this.getRegionFile(pos, true, true); // Paper -+ org.stupidcraft.linearpaper.region.AbstractRegionFile regionfile = this.getRegionFile(pos, true, true); // Paper // LinearPaper - if (regionfile == null) { - return null; - } - // Paper start - Add regionfile parameter - return this.read(pos, regionfile); - } -- public CompoundTag read(ChunkPos pos, RegionFile regionfile) throws IOException { -+ public CompoundTag read(ChunkPos pos, org.stupidcraft.linearpaper.region.AbstractRegionFile regionfile) throws IOException { // LinearPaper - // We add the regionfile parameter to avoid the potential deadlock (on fileLock) if we went back to obtain a regionfile - // if we decide to re-read - // Paper end -@@ -212,7 +221,7 @@ public class RegionFileStorage implements AutoCloseable { - - // Paper start - if (regionfile.isOversized(pos.x, pos.z)) { -- printOversizedLog("Loading Oversized Chunk!", regionfile.getPath(), pos.x, pos.z); -+ printOversizedLog("Loading Oversized Chunk!", regionfile.getRegionFile(), pos.x, pos.z); // LinearPaper - return readOversizedChunk(regionfile, pos); - } - // Paper end -@@ -226,12 +235,12 @@ public class RegionFileStorage implements AutoCloseable { - if (this.isChunkData) { - ChunkPos chunkPos = ChunkSerializer.getChunkCoordinate(nbttagcompound); - if (!chunkPos.equals(pos)) { -- net.minecraft.server.MinecraftServer.LOGGER.error("Attempting to read chunk data at " + pos + " but got chunk data for " + chunkPos + " instead! Attempting regionfile recalculation for regionfile " + regionfile.getPath().toAbsolutePath()); -+ net.minecraft.server.MinecraftServer.LOGGER.error("Attempting to read chunk data at " + pos + " but got chunk data for " + chunkPos + " instead! Attempting regionfile recalculation for regionfile " + regionfile.getRegionFile().toAbsolutePath()); // LinearPaper - if (regionfile.recalculateHeader()) { -- regionfile.fileLock.lock(); // otherwise we will unlock twice and only lock once. -+ regionfile.getFileLock().lock(); // otherwise we will unlock twice and only lock once. // LinearPaper - return this.read(pos, regionfile); - } -- net.minecraft.server.MinecraftServer.LOGGER.error("Can't recalculate regionfile header, regenerating chunk " + pos + " for " + regionfile.getPath().toAbsolutePath()); -+ net.minecraft.server.MinecraftServer.LOGGER.error("Can't recalculate regionfile header, regenerating chunk " + pos + " for " + regionfile.getRegionFile().toAbsolutePath()); // LinearPaper - return null; - } - } -@@ -265,13 +274,13 @@ public class RegionFileStorage implements AutoCloseable { - - return nbttagcompound; - } finally { // Paper start -- regionfile.fileLock.unlock(); -+ regionfile.getFileLock().unlock(); // LinearPaper - } // Paper end - } - - public void scanChunk(ChunkPos chunkPos, StreamTagVisitor scanner) throws IOException { - // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing -- RegionFile regionfile = this.getRegionFile(chunkPos, true); -+ org.stupidcraft.linearpaper.region.AbstractRegionFile regionfile = this.getRegionFile(chunkPos, true); // LinearPaper - if (regionfile == null) { - return; - } -@@ -302,7 +311,7 @@ public class RegionFileStorage implements AutoCloseable { - - protected void write(ChunkPos pos, @Nullable CompoundTag nbt) throws IOException { - // Paper start - rewrite chunk system -- RegionFile regionfile = this.getRegionFile(pos, nbt == null, true); // CraftBukkit -+ org.stupidcraft.linearpaper.region.AbstractRegionFile regionfile = this.getRegionFile(pos, nbt == null, true); // CraftBukkit // LinearPaper - if (nbt == null && regionfile == null) { - return; - } -@@ -357,7 +366,7 @@ public class RegionFileStorage implements AutoCloseable { - // Paper end - Chunk save reattempt - // Paper start - rewrite chunk system - } finally { -- regionfile.fileLock.unlock(); -+ regionfile.getFileLock().unlock(); // LinearPaper - } - // Paper end - rewrite chunk system - } -@@ -367,7 +376,7 @@ public class RegionFileStorage implements AutoCloseable { - ObjectIterator objectiterator = this.regionCache.values().iterator(); - - while (objectiterator.hasNext()) { -- RegionFile regionfile = (RegionFile) objectiterator.next(); -+ org.stupidcraft.linearpaper.region.AbstractRegionFile regionfile = (org.stupidcraft.linearpaper.region.AbstractRegionFile) objectiterator.next(); // LinearPaper - - try { - regionfile.close(); -@@ -383,7 +392,7 @@ public class RegionFileStorage implements AutoCloseable { - ObjectIterator objectiterator = this.regionCache.values().iterator(); - - while (objectiterator.hasNext()) { -- RegionFile regionfile = (RegionFile) objectiterator.next(); -+ org.stupidcraft.linearpaper.region.AbstractRegionFile regionfile = (org.stupidcraft.linearpaper.region.AbstractRegionFile) objectiterator.next(); // LinearPaper - - regionfile.flush(); - } -diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 0a14c9ae6dc9daeeb370eee1da7fc5fc2472d480..53d0481d349b4c9c0ddbe8242532f7195866421b 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -611,7 +611,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { - world.getChunk(x, z); // make sure we're at ticket level 32 or lower - return true; - } -- net.minecraft.world.level.chunk.storage.RegionFile file; -+ org.stupidcraft.linearpaper.region.AbstractRegionFile file; // LinearPaper - try { - file = world.getChunkSource().chunkMap.regionFileCache.getRegionFile(chunkPos, false); - } catch (java.io.IOException ex) { -diff --git a/src/main/java/org/stupidcraft/linearpaper/region/AbstractRegionFile.java b/src/main/java/org/stupidcraft/linearpaper/region/AbstractRegionFile.java -new file mode 100644 -index 0000000000000000000000000000000000000000..1325ac1d603bc65224860170b5ffad3f8cca2e9c ---- /dev/null -+++ b/src/main/java/org/stupidcraft/linearpaper/region/AbstractRegionFile.java -@@ -0,0 +1,30 @@ -+package org.stupidcraft.linearpaper.region; -+ -+import java.io.DataInputStream; -+import java.io.DataOutputStream; -+import java.io.IOException; -+import java.nio.file.Path; -+import java.util.concurrent.locks.ReentrantLock; -+import net.minecraft.nbt.CompoundTag; -+import net.minecraft.world.level.ChunkPos; -+import net.minecraft.world.level.chunk.status.ChunkStatus; -+ -+public interface AbstractRegionFile { -+ void flush() throws IOException; -+ void clear(ChunkPos pos) throws IOException; -+ void close() throws IOException; -+ void setStatus(int x, int z, ChunkStatus status); -+ void setOversized(int x, int z, boolean b) throws IOException; -+ -+ boolean hasChunk(ChunkPos pos); -+ boolean doesChunkExist(ChunkPos pos) throws Exception; -+ boolean isOversized(int x, int z); -+ boolean recalculateHeader() throws IOException; -+ -+ DataOutputStream getChunkDataOutputStream(ChunkPos pos) throws IOException; -+ DataInputStream getChunkDataInputStream(ChunkPos pos) throws IOException; -+ CompoundTag getOversizedData(int x, int z) throws IOException; -+ ChunkStatus getStatusIfCached(int x, int z); -+ ReentrantLock getFileLock(); -+ Path getRegionFile(); -+} -diff --git a/src/main/java/org/stupidcraft/linearpaper/region/AbstractRegionFileFactory.java b/src/main/java/org/stupidcraft/linearpaper/region/AbstractRegionFileFactory.java -new file mode 100644 -index 0000000000000000000000000000000000000000..f28145b5575566a1e3224c3a2e177eee49fcdbbf ---- /dev/null -+++ b/src/main/java/org/stupidcraft/linearpaper/region/AbstractRegionFileFactory.java -@@ -0,0 +1,52 @@ -+package org.stupidcraft.linearpaper.region; -+ -+import java.io.IOException; -+import java.nio.file.Path; -+ -+import me.earthme.luminol.config.modules.misc.RegionFormatConfig; -+import net.minecraft.world.level.chunk.storage.RegionFile; -+import net.minecraft.world.level.chunk.storage.RegionFileVersion; -+import net.minecraft.world.level.chunk.storage.RegionStorageInfo; -+import org.jetbrains.annotations.Contract; -+import org.jetbrains.annotations.NotNull; -+ -+public class AbstractRegionFileFactory { -+ @Contract("_, _, _, _ -> new") -+ public static @NotNull AbstractRegionFile getAbstractRegionFile(RegionStorageInfo storageKey, Path directory, Path path, boolean dsync) throws IOException { -+ return getAbstractRegionFile(storageKey, directory, path, RegionFileVersion.getCompressionFormat(), dsync); -+ } -+ -+ @Contract("_, _, _, _, _ -> new") -+ public static @NotNull AbstractRegionFile getAbstractRegionFile(RegionStorageInfo storageKey, Path directory, Path path, boolean dsync, boolean canRecalcHeader) throws IOException { -+ return getAbstractRegionFile(storageKey, directory, path, RegionFileVersion.getCompressionFormat(), dsync, canRecalcHeader); -+ } -+ -+ @Contract("_, _, _, _, _ -> new") -+ public static @NotNull AbstractRegionFile getAbstractRegionFile(RegionStorageInfo storageKey, Path path, Path directory, RegionFileVersion compressionFormat, boolean dsync) throws IOException { -+ return getAbstractRegionFile(storageKey, path, directory, compressionFormat, dsync, true); -+ } -+ -+ @Contract("_, _, _, _, _, _ -> new") -+ public static @NotNull AbstractRegionFile getAbstractRegionFile(RegionStorageInfo storageKey, @NotNull Path path, Path directory, RegionFileVersion compressionFormat, boolean dsync, boolean canRecalcHeader) throws IOException { -+ final String fullFileName = path.getFileName().toString(); -+ final String[] fullNameSplit = fullFileName.split("\\."); -+ final String extensionName = fullNameSplit[fullNameSplit.length - 1]; -+ switch (EnumRegionFileExtension.fromExtension(extensionName)){ -+ case UNKNOWN -> { -+ if (RegionFormatConfig.throwOnUnknownExtension){ -+ throw new IllegalArgumentException("Unknown region file extension for file: " + fullFileName +"!"); -+ } -+ -+ return new RegionFile(storageKey, path, directory, compressionFormat, dsync, canRecalcHeader); -+ } -+ -+ case LINEAR ->{ -+ return new LinearRegionFile(path, RegionFormatConfig.linearCompressionLevel); -+ } -+ -+ default -> { -+ return new RegionFile(storageKey, path, directory, compressionFormat, dsync, canRecalcHeader); -+ } -+ } -+ } -+} -diff --git a/src/main/java/org/stupidcraft/linearpaper/region/EnumRegionFileExtension.java b/src/main/java/org/stupidcraft/linearpaper/region/EnumRegionFileExtension.java -new file mode 100644 -index 0000000000000000000000000000000000000000..d51ec3faeb6a78992d440a7996739f4a5f0a5387 ---- /dev/null -+++ b/src/main/java/org/stupidcraft/linearpaper/region/EnumRegionFileExtension.java -@@ -0,0 +1,55 @@ -+package org.stupidcraft.linearpaper.region; -+ -+ -+import org.jetbrains.annotations.Contract; -+import org.jetbrains.annotations.NotNull; -+ -+public enum EnumRegionFileExtension { -+ LINEAR(".linear"), -+ MCA(".mca"), -+ UNKNOWN(null); -+ -+ private final String extensionName; -+ -+ EnumRegionFileExtension(String extensionName) { -+ this.extensionName = extensionName; -+ } -+ -+ public String getExtensionName() { -+ return this.extensionName; -+ } -+ -+ @Contract(pure = true) -+ public static EnumRegionFileExtension fromName(@NotNull String name){ -+ switch (name){ -+ default -> { -+ return UNKNOWN; -+ } -+ -+ case "MCA" -> { -+ return MCA; -+ } -+ -+ case "LINEAR" -> { -+ return LINEAR; -+ } -+ } -+ } -+ -+ @Contract(pure = true) -+ public static EnumRegionFileExtension fromExtension(@NotNull String name){ -+ switch (name){ -+ default -> { -+ return UNKNOWN; -+ } -+ -+ case ".mca" -> { -+ return MCA; -+ } -+ -+ case ".linear" -> { -+ return LINEAR; -+ } -+ } -+ } -+} -diff --git a/src/main/java/org/stupidcraft/linearpaper/region/LinearRegionFile.java b/src/main/java/org/stupidcraft/linearpaper/region/LinearRegionFile.java -new file mode 100644 -index 0000000000000000000000000000000000000000..97092e1d419cb565466a25795966f6cc989f7898 ---- /dev/null -+++ b/src/main/java/org/stupidcraft/linearpaper/region/LinearRegionFile.java -@@ -0,0 +1,316 @@ -+package org.stupidcraft.linearpaper.region; -+ -+import com.github.luben.zstd.ZstdInputStream; -+import com.github.luben.zstd.ZstdOutputStream; -+import com.mojang.logging.LogUtils; -+import java.io.BufferedOutputStream; -+import java.io.ByteArrayInputStream; -+import java.io.ByteArrayOutputStream; -+import java.io.DataInputStream; -+import java.io.DataOutputStream; -+import java.io.File; -+import java.io.FileInputStream; -+import java.io.FileOutputStream; -+import java.io.IOException; -+import java.io.InputStream; -+import java.nio.ByteBuffer; -+import java.nio.file.Files; -+import java.nio.file.Path; -+import java.nio.file.StandardCopyOption; -+import java.util.ArrayList; -+import java.util.Arrays; -+import java.util.List; -+import java.util.concurrent.TimeUnit; -+import java.util.concurrent.atomic.AtomicBoolean; -+import java.util.concurrent.locks.ReentrantLock; -+import javax.annotation.Nullable; -+ -+import me.earthme.luminol.config.modules.misc.RegionFormatConfig; -+import net.jpountz.lz4.LZ4Compressor; -+import net.jpountz.lz4.LZ4Factory; -+import net.jpountz.lz4.LZ4FastDecompressor; -+import net.minecraft.nbt.CompoundTag; -+import net.minecraft.world.level.ChunkPos; -+import net.minecraft.world.level.chunk.status.ChunkStatus; -+import org.slf4j.Logger; -+ -+public class LinearRegionFile implements AbstractRegionFile, AutoCloseable { -+ private static final long SUPERBLOCK = -4323716122432332390L; -+ private static final byte VERSION = 2; -+ private static final int HEADER_SIZE = 32; -+ private static final int FOOTER_SIZE = 8; -+ private static final Logger LOGGER = LogUtils.getLogger(); -+ private static final List SUPPORTED_VERSIONS = Arrays.asList((byte) 1, (byte) 2); -+ public final ReentrantLock fileLock = new ReentrantLock(true); -+ private final byte[][] buffer = new byte[1024][]; -+ private final int[] bufferUncompressedSize = new int[1024]; -+ private final int[] chunkTimestamps = new int[1024]; -+ private final ChunkStatus[] statuses = new ChunkStatus[1024]; -+ private final LZ4Compressor compressor; -+ private final LZ4FastDecompressor decompressor; -+ private final int compressionLevel; -+ public boolean closed = false; -+ public Path path; -+ private volatile long lastFlushed = System.nanoTime(); -+ -+ -+ public LinearRegionFile(Path file, int compression) throws IOException { -+ this.path = file; -+ this.compressionLevel = compression; -+ this.compressor = LZ4Factory.fastestInstance().fastCompressor(); -+ this.decompressor = LZ4Factory.fastestInstance().fastDecompressor(); -+ -+ File regionFile = new File(this.path.toString()); -+ -+ Arrays.fill(this.bufferUncompressedSize, 0); -+ -+ if (!regionFile.canRead()) return; -+ -+ try (FileInputStream fileStream = new FileInputStream(regionFile); -+ DataInputStream rawDataStream = new DataInputStream(fileStream)) { -+ -+ long superBlock = rawDataStream.readLong(); -+ if (superBlock != SUPERBLOCK) -+ throw new RuntimeException("Invalid superblock: " + superBlock + " in " + file); -+ -+ byte version = rawDataStream.readByte(); -+ if (!SUPPORTED_VERSIONS.contains(version)) -+ throw new RuntimeException("Invalid version: " + version + " in " + file); -+ -+ // Skip newestTimestamp (Long) + Compression level (Byte) + Chunk count (Short): Unused. -+ rawDataStream.skipBytes(11); -+ -+ int dataCount = rawDataStream.readInt(); -+ long fileLength = file.toFile().length(); -+ if (fileLength != HEADER_SIZE + dataCount + FOOTER_SIZE) -+ throw new IOException("Invalid file length: " + this.path + " " + fileLength + " " + (HEADER_SIZE + dataCount + FOOTER_SIZE)); -+ -+ rawDataStream.skipBytes(8); // Skip data hash (Long): Unused. -+ -+ byte[] rawCompressed = new byte[dataCount]; -+ rawDataStream.readFully(rawCompressed, 0, dataCount); -+ -+ superBlock = rawDataStream.readLong(); -+ if (superBlock != SUPERBLOCK) -+ throw new IOException("Footer superblock invalid " + this.path); -+ -+ try (DataInputStream dataStream = new DataInputStream(new ZstdInputStream(new ByteArrayInputStream(rawCompressed)))) { -+ -+ int[] starts = new int[1024]; -+ for (int i = 0; i < 1024; i++) { -+ starts[i] = dataStream.readInt(); -+ dataStream.skipBytes(4); // Skip timestamps (Int): Unused. -+ } -+ -+ for (int i = 0; i < 1024; i++) { -+ if (starts[i] > 0) { -+ int size = starts[i]; -+ byte[] b = new byte[size]; -+ dataStream.readFully(b, 0, size); -+ -+ int maxCompressedLength = this.compressor.maxCompressedLength(size); -+ byte[] compressed = new byte[maxCompressedLength]; -+ int compressedLength = this.compressor.compress(b, 0, size, compressed, 0, maxCompressedLength); -+ b = new byte[compressedLength]; -+ System.arraycopy(compressed, 0, b, 0, compressedLength); -+ -+ this.buffer[i] = b; -+ this.bufferUncompressedSize[i] = size; -+ } -+ } -+ } -+ } -+ } -+ -+ private static int getChunkIndex(int x, int z) { -+ return (x & 31) + ((z & 31) << 5); -+ } -+ -+ private static int getTimestamp() { -+ return (int) (System.currentTimeMillis() / 1000L); -+ } -+ -+ public Path getRegionFile() { -+ return this.path; -+ } -+ -+ public ReentrantLock getFileLock() { -+ return this.fileLock; -+ } -+ -+ public void flush() throws IOException { -+ flushWrapper(); // sync -+ } -+ -+ public void flushWrapper() { -+ try { -+ save(); -+ } catch (IOException e) { -+ LOGGER.error("Failed to flush region file " + path.toAbsolutePath(), e); -+ } -+ } -+ -+ public boolean doesChunkExist(ChunkPos pos) throws Exception { -+ throw new Exception("doesChunkExist is a stub"); -+ } -+ -+ private synchronized void save() throws IOException { -+ long timestamp = getTimestamp(); -+ short chunkCount = 0; -+ -+ File tempFile = new File(path.toString() + ".tmp"); -+ -+ try (FileOutputStream fileStream = new FileOutputStream(tempFile); -+ ByteArrayOutputStream zstdByteArray = new ByteArrayOutputStream(); -+ ZstdOutputStream zstdStream = new ZstdOutputStream(zstdByteArray, this.compressionLevel); -+ DataOutputStream zstdDataStream = new DataOutputStream(zstdStream); -+ DataOutputStream dataStream = new DataOutputStream(fileStream)) { -+ -+ dataStream.writeLong(SUPERBLOCK); -+ dataStream.writeByte(VERSION); -+ dataStream.writeLong(timestamp); -+ dataStream.writeByte(this.compressionLevel); -+ -+ ArrayList byteBuffers = new ArrayList<>(); -+ for (int i = 0; i < 1024; i++) { -+ if (this.bufferUncompressedSize[i] != 0) { -+ chunkCount += 1; -+ byte[] content = new byte[bufferUncompressedSize[i]]; -+ this.decompressor.decompress(buffer[i], 0, content, 0, bufferUncompressedSize[i]); -+ -+ byteBuffers.add(content); -+ } else byteBuffers.add(null); -+ } -+ for (int i = 0; i < 1024; i++) { -+ zstdDataStream.writeInt(this.bufferUncompressedSize[i]); // Write uncompressed size -+ zstdDataStream.writeInt(this.chunkTimestamps[i]); // Write timestamp -+ } -+ for (int i = 0; i < 1024; i++) { -+ if (byteBuffers.get(i) != null) -+ zstdDataStream.write(byteBuffers.get(i), 0, byteBuffers.get(i).length); -+ } -+ zstdDataStream.close(); -+ -+ dataStream.writeShort(chunkCount); -+ -+ byte[] compressed = zstdByteArray.toByteArray(); -+ -+ dataStream.writeInt(compressed.length); -+ dataStream.writeLong(0); -+ -+ dataStream.write(compressed, 0, compressed.length); -+ dataStream.writeLong(SUPERBLOCK); -+ -+ dataStream.flush(); -+ fileStream.getFD().sync(); -+ fileStream.getChannel().force(true); // Ensure atomicity on Btrfs -+ } -+ Files.move(tempFile.toPath(), this.path, StandardCopyOption.REPLACE_EXISTING); -+ this.lastFlushed = System.nanoTime(); -+ } -+ -+ public void setStatus(int x, int z, ChunkStatus status) { -+ this.statuses[getChunkIndex(x, z)] = status; -+ } -+ -+ public synchronized void write(ChunkPos pos, ByteBuffer buffer) { -+ try { -+ byte[] b = toByteArray(new ByteArrayInputStream(buffer.array())); -+ int uncompressedSize = b.length; -+ -+ int maxCompressedLength = this.compressor.maxCompressedLength(b.length); -+ byte[] compressed = new byte[maxCompressedLength]; -+ int compressedLength = this.compressor.compress(b, 0, b.length, compressed, 0, maxCompressedLength); -+ b = new byte[compressedLength]; -+ System.arraycopy(compressed, 0, b, 0, compressedLength); -+ -+ int index = getChunkIndex(pos.x, pos.z); -+ this.buffer[index] = b; -+ this.chunkTimestamps[index] = getTimestamp(); -+ this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] = uncompressedSize; -+ } catch (IOException e) { -+ LOGGER.error("Chunk write IOException " + e + " " + this.path); -+ } -+ -+ if ((System.nanoTime() - this.lastFlushed) >= TimeUnit.NANOSECONDS.toSeconds(RegionFormatConfig.linearFlushFrequency)){ -+ this.flushWrapper(); -+ } -+ } -+ -+ public DataOutputStream getChunkDataOutputStream(ChunkPos pos) { -+ return new DataOutputStream(new BufferedOutputStream(new ChunkBuffer(pos))); -+ } -+ -+ private byte[] toByteArray(InputStream in) throws IOException { -+ ByteArrayOutputStream out = new ByteArrayOutputStream(); -+ byte[] tempBuffer = new byte[4096]; -+ -+ int length; -+ while ((length = in.read(tempBuffer)) >= 0) { -+ out.write(tempBuffer, 0, length); -+ } -+ -+ return out.toByteArray(); -+ } -+ -+ @Nullable -+ public synchronized DataInputStream getChunkDataInputStream(ChunkPos pos) { -+ if (this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] != 0) { -+ byte[] content = new byte[bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]]; -+ this.decompressor.decompress(this.buffer[getChunkIndex(pos.x, pos.z)], 0, content, 0, bufferUncompressedSize[getChunkIndex(pos.x, pos.z)]); -+ return new DataInputStream(new ByteArrayInputStream(content)); -+ } -+ return null; -+ } -+ -+ public ChunkStatus getStatusIfCached(int x, int z) { -+ return this.statuses[getChunkIndex(x, z)]; -+ } -+ -+ public void clear(ChunkPos pos) { -+ int i = getChunkIndex(pos.x, pos.z); -+ this.buffer[i] = null; -+ this.bufferUncompressedSize[i] = 0; -+ this.chunkTimestamps[i] = getTimestamp(); -+ this.flushWrapper(); -+ } -+ -+ public boolean hasChunk(ChunkPos pos) { -+ return this.bufferUncompressedSize[getChunkIndex(pos.x, pos.z)] > 0; -+ } -+ -+ public void close() throws IOException { -+ if (closed) return; -+ closed = true; -+ flush(); // sync -+ } -+ -+ public boolean recalculateHeader() { -+ return false; -+ } -+ -+ public void setOversized(int x, int z, boolean something) { -+ } -+ -+ public CompoundTag getOversizedData(int x, int z) throws IOException { -+ throw new IOException("getOversizedData is a stub " + this.path); -+ } -+ -+ public boolean isOversized(int x, int z) { -+ return false; -+ } -+ -+ private class ChunkBuffer extends ByteArrayOutputStream { -+ private final ChunkPos pos; -+ -+ public ChunkBuffer(ChunkPos chunkcoordintpair) { -+ super(); -+ this.pos = chunkcoordintpair; -+ } -+ -+ public void close() throws IOException { -+ ByteBuffer bytebuffer = ByteBuffer.wrap(this.buf, 0, this.count); -+ LinearRegionFile.this.write(this.pos, bytebuffer); -+ } -+ } -+} diff --git a/patches/server/0023-Petal-Reduce-sensor-work.patch b/patches/server/0020-Petal-Reduce-sensor-work.patch similarity index 89% rename from patches/server/0023-Petal-Reduce-sensor-work.patch rename to patches/server/0020-Petal-Reduce-sensor-work.patch index c88f99a..b843937 100644 --- a/patches/server/0023-Petal-Reduce-sensor-work.patch +++ b/patches/server/0020-Petal-Reduce-sensor-work.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Wed, 7 Feb 2024 04:46:30 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 12:41:14 +0800 Subject: [PATCH] Petal Reduce sensor work @@ -33,10 +33,10 @@ index 0000000000000000000000000000000000000000..dd45cf1fde5ee4cf8347064f106c64b8 + } +} diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index bb5de770b6659379a68c077ff1cfc8d95d149c5c..a6c1d59085e0c58d9d1996d9e905bc24a3678e0c 100644 +index 741ba5f0834ab5f0b0ffdeb91a9ff8cfaf922792..85ba544b5cb106847034c5e7a6827045c4f35040 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -983,12 +983,12 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti +@@ -936,12 +936,12 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab return; } // Paper end - Allow nerfed mobs to jump and float diff --git a/patches/server/0025-Pufferfish-Cache-climbing-check-for-activation.patch b/patches/server/0021-Pufferfish-Cache-climbing-check-for-activation.patch similarity index 82% rename from patches/server/0025-Pufferfish-Cache-climbing-check-for-activation.patch rename to patches/server/0021-Pufferfish-Cache-climbing-check-for-activation.patch index b4d9e41..9ee3c10 100644 --- a/patches/server/0025-Pufferfish-Cache-climbing-check-for-activation.patch +++ b/patches/server/0021-Pufferfish-Cache-climbing-check-for-activation.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Sun, 14 Jan 2024 00:40:35 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 12:47:11 +0800 Subject: [PATCH] Pufferfish Cache climbing check for activation diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index a424a9c9921eabca90bd7a49946e5814d4aea8dd..76911946c4ad5c87abc4a82c20d52a2e755801ef 100644 +index fe3aeadd4357cc0b28ac9cfc21f0f1100d22d3a0..c1881c4a590a64950679bdac452960ed8d394f89 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -311,7 +311,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -315,7 +315,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess public double yo; public double zo; private Vec3 position; @@ -18,10 +18,10 @@ index a424a9c9921eabca90bd7a49946e5814d4aea8dd..76911946c4ad5c87abc4a82c20d52a2e private Vec3 deltaMovement; private float yRot; diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index ed628d38136534b3391c0a06b9c892a922710235..b3f0de04a7448a31a87d50f630dd4d929a6b6f37 100644 +index 8ccc18881d047e2b06ab3494a25f27e209931413..f3c442976dd358958053ba71a433d7f104559857 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -2053,6 +2053,20 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2084,6 +2084,20 @@ public abstract class LivingEntity extends Entity implements Attackable { return this.lastClimbablePos; } @@ -43,7 +43,7 @@ index ed628d38136534b3391c0a06b9c892a922710235..b3f0de04a7448a31a87d50f630dd4d92 if (this.isSpectator()) { return false; diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index 4fc4690d03fd5f39e019f16845954052210c7361..c77beef9651aa2f7333d536e8ff4af3281834619 100644 +index 91c63c3dceddf09018d3651f4c11bf521eb53ecf..3918fcfbb85cf0be523b3c723d9861aa5bca6d8c 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -307,7 +307,7 @@ public class ActivationRange diff --git a/patches/server/0022-Kaiiju-Vanilla-end-portal-teleportation.patch b/patches/server/0022-Kaiiju-Vanilla-end-portal-teleportation.patch deleted file mode 100644 index 160f8f5..0000000 --- a/patches/server/0022-Kaiiju-Vanilla-end-portal-teleportation.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: M2ke4U <79621885+MrHua269@users.noreply.github.com> -Date: Sun, 26 Nov 2023 20:25:38 +0800 -Subject: [PATCH] Kaiiju Vanilla end portal teleportation - - -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 816196016cad939c033a583e326ffff3894dca29..a424a9c9921eabca90bd7a49946e5814d4aea8dd 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -4245,12 +4245,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - targetPos, 16, // load 16 blocks to be safe from block physics - ca.spottedleaf.concurrentutil.executor.standard.PrioritisedExecutor.Priority.HIGH, - (chunks) -> { -- ServerLevel.makeObsidianPlatform(destination, null, targetPos); -+ //ServerLevel.makeObsidianPlatform(destination, null, targetPos); // Kaiiju - Vanilla end teleportation - moved down - -+ // Kaiiju start - Vanilla end teleportation -+ Vec3 finalPos; -+ if (this instanceof Player) finalPos = Vec3.atBottomCenterOf(targetPos.below()); -+ else finalPos = Vec3.atBottomCenterOf(targetPos); -+ // Kaiiju end - // the portal obsidian is placed at targetPos.y - 2, so if we want to place the entity - // on the obsidian, we need to spawn at targetPos.y - 1 - portalInfoCompletable.complete( -- new PortalInfo(Vec3.atBottomCenterOf(targetPos.below()), Vec3.ZERO, 90.0f, 0.0f, destination, null) -+ new PortalInfo(finalPos, this.getDeltaMovement(), 90.0f, 0.0f, destination, null) // Kaiiju - Vanilla end teleportation - ); - } - ); -@@ -4437,6 +4442,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - if (!this.canPortalAsync(takePassengers)) { - return false; - } -+ // Kaiiju start - sync end platform spawning & entity teleportation -+ final java.util.function.Consumer tpComplete = type == PortalType.END && destination.getTypeKey() == LevelStem.END ? -+ e -> ServerLevel.makeObsidianPlatform(destination, null, ServerLevel.END_SPAWN_POINT) : teleportComplete; -+ // Kaiiju end - - Vec3 initialPosition = this.position(); - ChunkPos initialPositionChunk = new ChunkPos( -@@ -4495,7 +4504,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - // place - passengerTree.root.placeInAsync( - originWorld, destination, Entity.TELEPORT_FLAG_LOAD_CHUNK | (takePassengers ? Entity.TELEPORT_FLAG_TELEPORT_PASSENGERS : 0L), -- passengerTree, teleportComplete -+ passengerTree, tpComplete // Kaiiju - vanilla end teleportation - ); - }); - diff --git a/patches/server/0026-Pufferfish-Make-EntityCollisionContext-a-live-repres.patch b/patches/server/0022-Pufferfish-Make-EntityCollisionContext-a-live-repres.patch similarity index 100% rename from patches/server/0026-Pufferfish-Make-EntityCollisionContext-a-live-repres.patch rename to patches/server/0022-Pufferfish-Make-EntityCollisionContext-a-live-repres.patch diff --git a/patches/server/0027-Pufferfish-Improve-fluid-direction-caching.patch b/patches/server/0023-Pufferfish-Improve-fluid-direction-caching.patch similarity index 93% rename from patches/server/0027-Pufferfish-Improve-fluid-direction-caching.patch rename to patches/server/0023-Pufferfish-Improve-fluid-direction-caching.patch index b15db66..79bd5d8 100644 --- a/patches/server/0027-Pufferfish-Improve-fluid-direction-caching.patch +++ b/patches/server/0023-Pufferfish-Improve-fluid-direction-caching.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: M2ke4U <79621885+MrHua269@users.noreply.github.com> -Date: Sun, 26 Nov 2023 16:00:59 +0800 +From: MrHua269 +Date: Wed, 31 Jul 2024 12:52:54 +0800 Subject: [PATCH] Pufferfish Improve fluid direction caching @@ -147,7 +147,7 @@ index 0000000000000000000000000000000000000000..aa8467b9dda1f7707e41f50ac7b3e9d7 + } +} diff --git a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -index c2943d892b067b3f1fb3b93301a092e912d71f08..58296b67f80587af485b0068e461cfd3d8d6f96f 100644 +index 1c0712295695727ee9c4d430d4157b8e17cbd71f..6785baf574f233ed1c3bea8d406be8a524d9ff82 100644 --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java +++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java @@ -45,6 +45,8 @@ public abstract class FlowingFluid extends Fluid { @@ -174,16 +174,16 @@ index c2943d892b067b3f1fb3b93301a092e912d71f08..58296b67f80587af485b0068e461cfd3 private final Map shapes = Maps.newIdentityHashMap(); public FlowingFluid() {} -@@ -251,6 +261,8 @@ public abstract class FlowingFluid extends Fluid { - return false; - } - // Paper end - optimise collisions +@@ -240,6 +250,8 @@ public abstract class FlowingFluid extends Fluid { + } + + private boolean canPassThroughWall(Direction face, BlockGetter world, BlockPos pos, BlockState state, BlockPos fromPos, BlockState fromState) { + // Pufferfish start - modify to use our cache + /* Object2ByteLinkedOpenHashMap object2bytelinkedopenhashmap; if (!state.getBlock().hasDynamicShape() && !fromState.getBlock().hasDynamicShape()) { -@@ -258,9 +270,16 @@ public abstract class FlowingFluid extends Fluid { +@@ -247,9 +259,16 @@ public abstract class FlowingFluid extends Fluid { } else { object2bytelinkedopenhashmap = null; } @@ -200,7 +200,7 @@ index c2943d892b067b3f1fb3b93301a092e912d71f08..58296b67f80587af485b0068e461cfd3 if (object2bytelinkedopenhashmap != null) { block_a = new Block.BlockStatePairKey(state, fromState, face); byte b0 = object2bytelinkedopenhashmap.getAndMoveToFirst(block_a); -@@ -271,11 +290,22 @@ public abstract class FlowingFluid extends Fluid { +@@ -260,11 +279,22 @@ public abstract class FlowingFluid extends Fluid { } else { block_a = null; } @@ -223,7 +223,7 @@ index c2943d892b067b3f1fb3b93301a092e912d71f08..58296b67f80587af485b0068e461cfd3 if (object2bytelinkedopenhashmap != null) { if (object2bytelinkedopenhashmap.size() == 200) { object2bytelinkedopenhashmap.removeLastByte(); -@@ -283,6 +313,11 @@ public abstract class FlowingFluid extends Fluid { +@@ -272,6 +302,11 @@ public abstract class FlowingFluid extends Fluid { object2bytelinkedopenhashmap.putAndMoveToFirst(block_a, (byte) (flag ? 1 : 0)); } diff --git a/patches/server/0024-Pufferfish-Optimize-entity-coordinate-key.patch b/patches/server/0024-Pufferfish-Optimize-entity-coordinate-key.patch deleted file mode 100644 index d6dbf83..0000000 --- a/patches/server/0024-Pufferfish-Optimize-entity-coordinate-key.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: M2ke4U <79621885+MrHua269@users.noreply.github.com> -Date: Sun, 26 Nov 2023 15:59:49 +0800 -Subject: [PATCH] Pufferfish Optimize entity coordinate key - - -diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java -index bb915f30997059f22c9002b1ddc1c3aecbf4e979..2034c67f5702b7b8d093ef2dd7601901c5fef363 100644 ---- a/src/main/java/io/papermc/paper/util/MCUtil.java -+++ b/src/main/java/io/papermc/paper/util/MCUtil.java -@@ -215,7 +215,7 @@ public final class MCUtil { - } - - public static long getCoordinateKey(final Entity entity) { -- return ((long)(MCUtil.fastFloor(entity.getZ()) >> 4) << 32) | ((MCUtil.fastFloor(entity.getX()) >> 4) & 0xFFFFFFFFL); -+ return ((long)(entity.blockPosition.getZ() >> 4) << 32) | ((entity.blockPosition.getX() >> 4) & 0xFFFFFFFFL); // Pufferfish - eliminate double->long cast in hotpath - } - - public static long getCoordinateKey(final ChunkPos pair) { diff --git a/patches/server/0028-Pufferfish-Optimize-suffocation.patch b/patches/server/0024-Pufferfish-Optimize-suffocation.patch similarity index 90% rename from patches/server/0028-Pufferfish-Optimize-suffocation.patch rename to patches/server/0024-Pufferfish-Optimize-suffocation.patch index a492090..d1301ff 100644 --- a/patches/server/0028-Pufferfish-Optimize-suffocation.patch +++ b/patches/server/0024-Pufferfish-Optimize-suffocation.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Wed, 7 Feb 2024 04:55:43 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 12:53:49 +0800 Subject: [PATCH] Pufferfish Optimize suffocation @@ -31,10 +31,10 @@ index 0000000000000000000000000000000000000000..3e48cd297b4869e5c89b6abc43c726d3 + } +} diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index b3f0de04a7448a31a87d50f630dd4d929a6b6f37..216af15f706f777bd6350cdd2187a8e7c98dfa21 100644 +index f3c442976dd358958053ba71a433d7f104559857..3c5c0634088f523f422912837abab818156ca291 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -442,7 +442,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -464,7 +464,7 @@ public abstract class LivingEntity extends Entity implements Attackable { boolean flag = this instanceof net.minecraft.world.entity.player.Player; if (!this.level().isClientSide) { @@ -43,7 +43,7 @@ index b3f0de04a7448a31a87d50f630dd4d929a6b6f37..216af15f706f777bd6350cdd2187a8e7 this.hurt(this.damageSources().inWall(), 1.0F); } else if (flag && !this.level().getWorldBorder().isWithinBounds(this.getBoundingBox())) { double d0 = this.level().getWorldBorder().getDistanceToBorder(this) + this.level().getWorldBorder().getDamageSafeZone(); -@@ -1450,6 +1450,19 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1428,6 +1428,19 @@ public abstract class LivingEntity extends Entity implements Attackable { return this.getHealth() <= 0.0F; } @@ -64,7 +64,7 @@ index b3f0de04a7448a31a87d50f630dd4d929a6b6f37..216af15f706f777bd6350cdd2187a8e7 public boolean hurt(DamageSource source, float amount) { if (this.isInvulnerableTo(source)) { diff --git a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java -index 7ddca52f7fe3f289b4b867e134326b1ead1a2aee..5040b1a7125dd9647a98fd812f558ec3a2171092 100644 +index d3b4d492aee380dc17f4232d90eaae4f07bb9f86..82921c56c49edb0ca07425da563aa4876d4e6fb1 100644 --- a/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java +++ b/src/main/java/net/minecraft/world/entity/boss/wither/WitherBoss.java @@ -154,6 +154,13 @@ public class WitherBoss extends Monster implements PowerableMob, RangedAttackMob diff --git a/patches/server/0030-Pufferfish-Early-return-optimization-for-target-find.patch b/patches/server/0025-Pufferfish-Early-return-optimization-for-target-find.patch similarity index 91% rename from patches/server/0030-Pufferfish-Early-return-optimization-for-target-find.patch rename to patches/server/0025-Pufferfish-Early-return-optimization-for-target-find.patch index 4f15550..8a4a3ff 100644 --- a/patches/server/0030-Pufferfish-Early-return-optimization-for-target-find.patch +++ b/patches/server/0025-Pufferfish-Early-return-optimization-for-target-find.patch @@ -1,11 +1,11 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Tue, 6 Feb 2024 03:17:39 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:10:18 +0800 Subject: [PATCH] Pufferfish Early return optimization for target finding diff --git a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java -index d2f0c3b26d4beedb49d86e0242d843590d469d02..c55fe31f3fc1c9ccb949c6bfb64e1bd6f37b8356 100644 +index aecb0ad814586bfc5e56755ee14379a69388b38c..6381ef1385f85f0f576ad55b3b58dd62c0823f1c 100644 --- a/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java +++ b/src/main/java/net/minecraft/world/entity/ai/targeting/TargetingConditions.java @@ -76,9 +76,18 @@ public class TargetingConditions { diff --git a/patches/server/0031-Pufferfish-Reduce-chunk-loading-lookups.patch b/patches/server/0026-Pufferfish-Reduce-chunk-loading-lookups.patch similarity index 86% rename from patches/server/0031-Pufferfish-Reduce-chunk-loading-lookups.patch rename to patches/server/0026-Pufferfish-Reduce-chunk-loading-lookups.patch index 85e5aa5..b24d761 100644 --- a/patches/server/0031-Pufferfish-Reduce-chunk-loading-lookups.patch +++ b/patches/server/0026-Pufferfish-Reduce-chunk-loading-lookups.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: M2ke4U <79621885+MrHua269@users.noreply.github.com> -Date: Sun, 26 Nov 2023 16:07:56 +0800 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:10:34 +0800 Subject: [PATCH] Pufferfish Reduce chunk loading & lookups diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java -index 260202fab3ac300552c557b44dcf251f083c6a78..9cf4e2f309e182c69e9592ac606c0ae85a1200b6 100644 +index 828c51477cd8f35d591367b30bf4feef6a250292..ace4959f818bf56882b290d109b8b97f2c145631 100644 --- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java +++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java -@@ -318,11 +318,17 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -320,11 +320,17 @@ public class EnderMan extends Monster implements NeutralMob { private boolean teleport(double x, double y, double z) { BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(x, y, z); diff --git a/patches/server/0032-Pufferfish-Fix-Paper-6045-block-goal-shouldn-t-load-.patch b/patches/server/0027-Pufferfish-Fix-Paper-6045-block-goal-shouldn-t-load-.patch similarity index 94% rename from patches/server/0032-Pufferfish-Fix-Paper-6045-block-goal-shouldn-t-load-.patch rename to patches/server/0027-Pufferfish-Fix-Paper-6045-block-goal-shouldn-t-load-.patch index 6f0b677..f029e7f 100644 --- a/patches/server/0032-Pufferfish-Fix-Paper-6045-block-goal-shouldn-t-load-.patch +++ b/patches/server/0027-Pufferfish-Fix-Paper-6045-block-goal-shouldn-t-load-.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Tue, 6 Feb 2024 03:21:56 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:10:52 +0800 Subject: [PATCH] Pufferfish Fix Paper#6045, block goal shouldn't load chunks diff --git a/patches/server/0033-Pufferfish-Reduce-entity-fluid-lookups-if-no-fluids.patch b/patches/server/0028-Pufferfish-Reduce-entity-fluid-lookups-if-no-fluids.patch similarity index 88% rename from patches/server/0033-Pufferfish-Reduce-entity-fluid-lookups-if-no-fluids.patch rename to patches/server/0028-Pufferfish-Reduce-entity-fluid-lookups-if-no-fluids.patch index a2813fd..301ecec 100644 --- a/patches/server/0033-Pufferfish-Reduce-entity-fluid-lookups-if-no-fluids.patch +++ b/patches/server/0028-Pufferfish-Reduce-entity-fluid-lookups-if-no-fluids.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Sun, 16 Jun 2024 10:56:41 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:11:43 +0800 Subject: [PATCH] Pufferfish Reduce entity fluid lookups if no fluids @@ -31,10 +31,10 @@ index 0000000000000000000000000000000000000000..0523b3da3fb254bce1998bae6410c632 + } +} diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 76911946c4ad5c87abc4a82c20d52a2e755801ef..19d901c4560be4c44adc6513adca95c9ac4e0b95 100644 +index c1881c4a590a64950679bdac452960ed8d394f89..79b39562632a2e4dedfaa72db14c63d325e3eb4b 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -5325,6 +5325,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -5262,6 +5262,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess if (this.touchingUnloadedChunk()) { return false; } else { @@ -46,7 +46,7 @@ index 76911946c4ad5c87abc4a82c20d52a2e755801ef..19d901c4560be4c44adc6513adca95c9 AABB axisalignedbb = this.getBoundingBox().deflate(0.001D); int i = Mth.floor(axisalignedbb.minX); int j = Mth.ceil(axisalignedbb.maxX); -@@ -5398,6 +5403,133 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -5335,6 +5340,133 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } } @@ -181,18 +181,18 @@ index 76911946c4ad5c87abc4a82c20d52a2e755801ef..19d901c4560be4c44adc6513adca95c9 AABB axisalignedbb = this.getBoundingBox().inflate(1.0D); int i = Mth.floor(axisalignedbb.minX); diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java -index a2a5aef769ee8bb638a5a9f3da9812fa4a85dda5..7288261b8924d08e93abecb664e2273c624a325b 100644 +index c3b1caa352b988ec44fa2b2eb0536517711f5460..7a7b1a326c54b68adcae22365939d9cd6aa34cf8 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java -@@ -25,6 +25,7 @@ public class LevelChunkSection { +@@ -25,6 +25,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ public final PalettedContainer states; // CraftBukkit start - read/write private PalettedContainer> biomes; + public short fluidStateCount; // Pufferfish - public final com.destroystokyo.paper.util.maplist.IBlockDataList tickingList = new com.destroystokyo.paper.util.maplist.IBlockDataList(); // Paper - // Paper start - optimise collisions - private int specialCollidingBlocks; -@@ -102,6 +103,7 @@ public class LevelChunkSection { + + // Paper start - block counting + private static final it.unimi.dsi.fastutil.ints.IntArrayList FULL_LIST = new it.unimi.dsi.fastutil.ints.IntArrayList(16*16*16); +@@ -104,6 +105,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ if (!fluid.isEmpty()) { --this.tickingFluidCount; @@ -200,19 +200,19 @@ index a2a5aef769ee8bb638a5a9f3da9812fa4a85dda5..7288261b8924d08e93abecb664e2273c } if (!state.isAir()) { -@@ -116,6 +118,7 @@ public class LevelChunkSection { +@@ -115,6 +117,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ if (!fluid1.isEmpty()) { ++this.tickingFluidCount; + ++this.fluidStateCount; // Pufferfish } - this.updateBlockCallback(x, y, z, iblockdata1, state); // Paper - optimise collisions -@@ -162,6 +165,7 @@ public class LevelChunkSection { - if (fluid.isRandomlyTicking()) { - this.tickingFluidCount = (short) (this.tickingFluidCount + 1); + // Paper start - block counting +@@ -199,6 +202,7 @@ public class LevelChunkSection implements ca.spottedleaf.moonrise.patches.block_ + for (int i = 0; i < paletteCount; ++i) { + this.tickingBlocks.add(raw[i], state); } + this.fluidStateCount++; // Pufferfish } - // Paper start - optimise collisions + final FluidState fluid = state.getFluidState(); diff --git a/patches/server/0034-Pufferfish-Only-check-for-spooky-season-once-an-hour.patch b/patches/server/0029-Pufferfish-Only-check-for-spooky-season-once-an-hour.patch similarity index 94% rename from patches/server/0034-Pufferfish-Only-check-for-spooky-season-once-an-hour.patch rename to patches/server/0029-Pufferfish-Only-check-for-spooky-season-once-an-hour.patch index 5e1d8ad..80b5bd1 100644 --- a/patches/server/0034-Pufferfish-Only-check-for-spooky-season-once-an-hour.patch +++ b/patches/server/0029-Pufferfish-Only-check-for-spooky-season-once-an-hour.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: M2ke4U <79621885+MrHua269@users.noreply.github.com> -Date: Sun, 26 Nov 2023 16:15:28 +0800 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:13:07 +0800 Subject: [PATCH] Pufferfish Only check for spooky season once an hour diff --git a/patches/server/0029-Pufferfish-Use-aging-cache-for-biome-temperatures.patch b/patches/server/0029-Pufferfish-Use-aging-cache-for-biome-temperatures.patch deleted file mode 100644 index f054c0d..0000000 --- a/patches/server/0029-Pufferfish-Use-aging-cache-for-biome-temperatures.patch +++ /dev/null @@ -1,178 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Mon, 29 Jul 2024 19:53:42 +0800 -Subject: [PATCH] Pufferfish Use aging cache for biome temperatures - - -diff --git a/src/main/java/gg/airplane/structs/Long2FloatAgingCache.java b/src/main/java/gg/airplane/structs/Long2FloatAgingCache.java -new file mode 100644 -index 0000000000000000000000000000000000000000..a7f297ebb569f7c1f205e967ca485be70013a714 ---- /dev/null -+++ b/src/main/java/gg/airplane/structs/Long2FloatAgingCache.java -@@ -0,0 +1,119 @@ -+package gg.airplane.structs; -+ -+import it.unimi.dsi.fastutil.HashCommon; -+ -+/** -+ * A replacement for the cache used in Biome. -+ */ -+public class Long2FloatAgingCache { -+ -+ private static class AgingEntry { -+ private long data; -+ private float value; -+ private int uses = 0; -+ private int age = 0; -+ -+ private AgingEntry(long data, float value) { -+ this.data = data; -+ this.value = value; -+ } -+ -+ public void replace(long data, float flag) { -+ this.data = data; -+ this.value = flag; -+ } -+ -+ public int getValue() { -+ return this.uses - (this.age >> 1); // age isn't as important as uses -+ } -+ -+ public void incrementUses() { -+ this.uses = this.uses + 1 & Integer.MAX_VALUE; -+ } -+ -+ public void incrementAge() { -+ this.age = this.age + 1 & Integer.MAX_VALUE; -+ } -+ } -+ -+ private final AgingEntry[] entries; -+ private final int mask; -+ private final int maxDistance; // the most amount of entries to check for a value -+ -+ public Long2FloatAgingCache(int size) { -+ int arraySize = HashCommon.nextPowerOfTwo(size); -+ this.entries = new AgingEntry[arraySize]; -+ this.mask = arraySize - 1; -+ this.maxDistance = Math.min(arraySize, 4); -+ } -+ -+ public float getValue(long data) { -+ AgingEntry curr; -+ int pos; -+ -+ if ((curr = this.entries[pos = HashCommon.mix(HashCommon.long2int(data)) & this.mask]) == null) { -+ return Float.NaN; -+ } else if (data == curr.data) { -+ curr.incrementUses(); -+ return curr.value; -+ } -+ -+ int checked = 1; // start at 1 because we already checked the first spot above -+ -+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) { -+ if (data == curr.data) { -+ curr.incrementUses(); -+ return curr.value; -+ } else if (++checked >= this.maxDistance) { -+ break; -+ } -+ } -+ -+ return Float.NaN; -+ } -+ -+ public void putValue(long data, float value) { -+ AgingEntry curr; -+ int pos; -+ -+ if ((curr = this.entries[pos = HashCommon.mix(HashCommon.long2int(data)) & this.mask]) == null) { -+ this.entries[pos] = new AgingEntry(data, value); // add -+ return; -+ } else if (data == curr.data) { -+ curr.incrementUses(); -+ return; -+ } -+ -+ int checked = 1; // start at 1 because we already checked the first spot above -+ -+ while ((curr = this.entries[pos = (pos + 1) & this.mask]) != null) { -+ if (data == curr.data) { -+ curr.incrementUses(); -+ return; -+ } else if (++checked >= this.maxDistance) { -+ this.forceAdd(data, value); -+ return; -+ } -+ } -+ -+ this.entries[pos] = new AgingEntry(data, value); // add -+ } -+ -+ private void forceAdd(long data, float value) { -+ int expectedPos = HashCommon.mix(HashCommon.long2int(data)) & this.mask; -+ AgingEntry entryToRemove = this.entries[expectedPos]; -+ -+ for (int i = expectedPos + 1; i < expectedPos + this.maxDistance; i++) { -+ int pos = i & this.mask; -+ AgingEntry entry = this.entries[pos]; -+ if (entry.getValue() < entryToRemove.getValue()) { -+ entryToRemove = entry; -+ } -+ -+ entry.incrementAge(); // use this as a mechanism to age the other entries -+ } -+ -+ // remove the least used/oldest entry -+ entryToRemove.replace(data, value); -+ } -+} -diff --git a/src/main/java/net/minecraft/world/level/biome/Biome.java b/src/main/java/net/minecraft/world/level/biome/Biome.java -index 15f82c9a1ce1fef2e951d1b3c7a65e64b82061ea..f9fbfb63f19decb3b15284306d7edda072e609af 100644 ---- a/src/main/java/net/minecraft/world/level/biome/Biome.java -+++ b/src/main/java/net/minecraft/world/level/biome/Biome.java -@@ -63,13 +63,18 @@ public final class Biome { - private final BiomeGenerationSettings generationSettings; - private final MobSpawnSettings mobSettings; - private final BiomeSpecialEffects specialEffects; -- private final ThreadLocal temperatureCache = ThreadLocal.withInitial(() -> Util.make(() -> { -+ // Pufferfish start - use our cache -+ private final ThreadLocal temperatureCache = ThreadLocal.withInitial(() -> Util.make(() -> { -+ /* - Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = new Long2FloatLinkedOpenHashMap(1024, 0.25F) { - protected void rehash(int i) { - } - }; - long2FloatLinkedOpenHashMap.defaultReturnValue(Float.NaN); - return long2FloatLinkedOpenHashMap; -+ */ -+ return new gg.airplane.structs.Long2FloatAgingCache(TEMPERATURE_CACHE_SIZE); -+ // Pufferfish end - })); - - Biome(Biome.ClimateSettings weather, BiomeSpecialEffects effects, BiomeGenerationSettings generationSettings, MobSpawnSettings spawnSettings) { -@@ -112,17 +117,15 @@ public final class Biome { - @Deprecated - public float getTemperature(BlockPos blockPos) { - long l = blockPos.asLong(); -- Long2FloatLinkedOpenHashMap long2FloatLinkedOpenHashMap = this.temperatureCache.get(); -- float f = long2FloatLinkedOpenHashMap.get(l); -+ // Pufferfish start -+ gg.airplane.structs.Long2FloatAgingCache cache = this.temperatureCache.get(); -+ float f = cache.getValue(l); - if (!Float.isNaN(f)) { - return f; - } else { - float g = this.getHeightAdjustedTemperature(blockPos); -- if (long2FloatLinkedOpenHashMap.size() == 1024) { -- long2FloatLinkedOpenHashMap.removeFirstFloat(); -- } -- -- long2FloatLinkedOpenHashMap.put(l, g); -+ cache.putValue(l, g); -+ // Pufferfish end - return g; - } - } diff --git a/patches/server/0035-Pufferfish-Skip-cloning-loot-parameters.patch b/patches/server/0030-Pufferfish-Skip-cloning-loot-parameters.patch similarity index 100% rename from patches/server/0035-Pufferfish-Skip-cloning-loot-parameters.patch rename to patches/server/0030-Pufferfish-Skip-cloning-loot-parameters.patch diff --git a/patches/server/0036-Pufferfish-Entity-TTL.patch b/patches/server/0031-Pufferfish-Entity-TTL.patch similarity index 75% rename from patches/server/0036-Pufferfish-Entity-TTL.patch rename to patches/server/0031-Pufferfish-Entity-TTL.patch index 44ebd5d..96352d2 100644 --- a/patches/server/0036-Pufferfish-Entity-TTL.patch +++ b/patches/server/0031-Pufferfish-Entity-TTL.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Wed, 7 Feb 2024 05:19:37 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:20:23 +0800 Subject: [PATCH] Pufferfish Entity TTL @@ -49,10 +49,10 @@ index 0000000000000000000000000000000000000000..15697d69659b6e1e776acf5094684b5f + } +} diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 19d901c4560be4c44adc6513adca95c9ac4e0b95..053e9204104a886f4b7e828b7c5e0d277c44d676 100644 +index 79b39562632a2e4dedfaa72db14c63d325e3eb4b..47cfeef4d40ff9c99280d925eacb64d243f6ed8b 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -855,6 +855,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -857,6 +857,12 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } public void tick() { @@ -65,8 +65,19 @@ index 19d901c4560be4c44adc6513adca95c9ac4e0b95..053e9204104a886f4b7e828b7c5e0d27 this.baseTick(); } +@@ -5359,8 +5365,8 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); + + // Pufferfish start - based off CollisionUtil.getCollisionsForBlocksOrWorldBorder +- final int minSection = io.papermc.paper.util.WorldUtil.getMinSection(this.level()); +- final int maxSection = io.papermc.paper.util.WorldUtil.getMaxSection(this.level()); ++ final int minSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinSection(this.level()); ++ final int maxSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMaxSection(this.level()); + final int minBlock = minSection << 4; + final int maxBlock = (maxSection << 4) | 15; + diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java -index a2f0fb8b4057bd3a84d18298e49c4d02955240d3..aa2bb97ef305ed234a11b05e665ac1062b571591 100644 +index c74a01a8551457507441d266b6923b4248560abf..293ec464b1cb4db1734d0c059e59f60bfeb2b7eb 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java +++ b/src/main/java/net/minecraft/world/entity/EntityType.java @@ -325,6 +325,7 @@ public class EntityType implements FeatureElement, EntityTypeT diff --git a/patches/server/0038-Pufferfish-Dynamic-Activation-of-Brain.patch b/patches/server/0032-Pufferfish-Dynamic-Activation-of-Brain.patch similarity index 76% rename from patches/server/0038-Pufferfish-Dynamic-Activation-of-Brain.patch rename to patches/server/0032-Pufferfish-Dynamic-Activation-of-Brain.patch index 01acb48..829b1eb 100644 --- a/patches/server/0038-Pufferfish-Dynamic-Activation-of-Brain.patch +++ b/patches/server/0032-Pufferfish-Dynamic-Activation-of-Brain.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Wed, 7 Feb 2024 05:56:56 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:23:14 +0800 Subject: [PATCH] Pufferfish Dynamic Activation of Brain @@ -70,11 +70,39 @@ index 0000000000000000000000000000000000000000..af5893ba1f738ec9827d7b714682c314 + config.setComment("optimizations.dab", "Optimizes entity brains when\n" + "they're far away from the player"); + } +} +diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/ProjectileChunkReduceConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/ProjectileChunkReduceConfig.java +new file mode 100644 +index 0000000000000000000000000000000000000000..12683ec5a5102e45b6171fea0b833ba57e5e188c +--- /dev/null ++++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/ProjectileChunkReduceConfig.java +@@ -0,0 +1,22 @@ ++package me.earthme.luminol.config.modules.optimizations; ++ ++import me.earthme.luminol.config.ConfigInfo; ++import me.earthme.luminol.config.EnumConfigCategory; ++import me.earthme.luminol.config.IConfigModule; ++ ++public class ProjectileChunkReduceConfig implements IConfigModule { ++ @ConfigInfo(baseName = "max-loads-per-tick") ++ public static int maxProjectileLoadsPerTick; ++ @ConfigInfo(baseName = "max-loads-per-projectile") ++ public static int maxProjectileLoadsPerProjectile; ++ ++ @Override ++ public EnumConfigCategory getCategory() { ++ return EnumConfigCategory.OPTIMIZATIONS; ++ } ++ ++ @Override ++ public String getBaseName() { ++ return "projectile"; ++ } ++} diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 6b8cbf681203c20eebb214c5c0b0fe0374aa30dc..12c46e7a3f6a8675921d95dee97ece4a83252282 100644 +index 8e94a8abf0fddf1756600c8ed80c0b8b9851ef6f..618e0f585f4edf81246dcae66af63e391bc28658 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -994,6 +994,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -809,6 +809,7 @@ public class ServerLevel extends Level implements WorldGenLevel, ca.spottedleaf. this.timings.entityTick.startTiming(); // Spigot profiler.startTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.ENTITY_TICK); try { // Folia - profiler regionizedWorldData.forEachTickingEntity((entity) -> { // Folia - regionised ticking @@ -83,23 +111,23 @@ index 6b8cbf681203c20eebb214c5c0b0fe0374aa30dc..12c46e7a3f6a8675921d95dee97ece4a if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed entity.discard(); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 053e9204104a886f4b7e828b7c5e0d277c44d676..a999e3204d89ce2107026940cec7399360739ef0 100644 +index 47cfeef4d40ff9c99280d925eacb64d243f6ed8b..c1ac70dd05e049953e259f3b19135582ae21290e 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -482,6 +482,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess - - // Folia - region ticking - // Paper end - optimise entity tracking +@@ -429,6 +429,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + private UUID originWorld; + public boolean freezeLocked = false; // Paper - Freeze Tick Lock API + public boolean fixedPose = false; // Paper - Expand Pose API + //Pufferfish start + public boolean activatedPriorityReset = false; // DAB + public int activatedPriority = me.earthme.luminol.config.modules.optimizations.EntityDABConfig.maximumActivationPrio; // golf score + // Pufferfish end + - public float getBukkitYaw() { - return this.yRot; - } + + public void setOrigin(@javax.annotation.Nonnull Location location) { + this.origin = location.toVector(); diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java -index aa2bb97ef305ed234a11b05e665ac1062b571591..29699e51b3e791a1a82a19c95fd6a3f30bac75d5 100644 +index 293ec464b1cb4db1734d0c059e59f60bfeb2b7eb..5d3e5262d9b7565ddf045ce9f97ec1904e7b0291 100644 --- a/src/main/java/net/minecraft/world/entity/EntityType.java +++ b/src/main/java/net/minecraft/world/entity/EntityType.java @@ -316,6 +316,7 @@ public class EntityType implements FeatureElement, EntityTypeT @@ -111,10 +139,10 @@ index aa2bb97ef305ed234a11b05e665ac1062b571591..29699e51b3e791a1a82a19c95fd6a3f3 private String descriptionId; @Nullable diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index a6c1d59085e0c58d9d1996d9e905bc24a3678e0c..fae60501284a68238c53ffc19075d46ac49cfdaa 100644 +index 85ba544b5cb106847034c5e7a6827045c4f35040..96a95939df41721433cefbfc07a5d75ea6b961e9 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -249,10 +249,10 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti +@@ -244,10 +244,10 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab @Override public void inactiveTick() { super.inactiveTick(); @@ -127,7 +155,7 @@ index a6c1d59085e0c58d9d1996d9e905bc24a3678e0c..fae60501284a68238c53ffc19075d46a this.targetSelector.tick(); } } -@@ -992,16 +992,20 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti +@@ -945,16 +945,20 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab if (i % 2 != 0 && this.tickCount > 1) { gameprofilerfiller.push("targetSelector"); @@ -149,7 +177,7 @@ index a6c1d59085e0c58d9d1996d9e905bc24a3678e0c..fae60501284a68238c53ffc19075d46a gameprofilerfiller.pop(); } diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java -index 74d4f653d5c7f1923c59019effd78337402f7025..73f2a527d18f61db97d5b5050ebe67822771cf58 100644 +index 9bdbf3e9453bc3ce96d52d04b8cde0d05f7356d8..bbe425df9f231550da6d895b77cd7371a32cbd15 100644 --- a/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java +++ b/src/main/java/net/minecraft/world/entity/ai/goal/GoalSelector.java @@ -43,9 +43,13 @@ public class GoalSelector { @@ -169,10 +197,10 @@ index 74d4f653d5c7f1923c59019effd78337402f7025..73f2a527d18f61db97d5b5050ebe6782 public boolean hasTasks() { for (WrappedGoal task : this.availableGoals) { diff --git a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java -index 991e3274091c4e25eebc6debd44653e5b566eedb..789d3469ce4983868e4b880b6053bd2d8c33a10a 100644 +index 69986f75d3cf729204cca0c7e5428536af31f695..98a759dbe46e2ead39af0f340c9b73c8f4ddce1e 100644 --- a/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java +++ b/src/main/java/net/minecraft/world/entity/animal/allay/Allay.java -@@ -215,9 +215,11 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS +@@ -217,9 +217,11 @@ public class Allay extends PathfinderMob implements InventoryCarrier, VibrationS return 0.4F; } @@ -185,10 +213,10 @@ index 991e3274091c4e25eebc6debd44653e5b566eedb..789d3469ce4983868e4b880b6053bd2d this.level().getProfiler().pop(); this.level().getProfiler().push("allayActivityUpdate"); diff --git a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java -index a8cc6ddbf45370fe632e5c5fb7ceef3d299e62a4..98766696556b520cf565ccadc8dba207832b4ae3 100644 +index 01a0731e92d39c8718538244e34a271fb8717fc2..44937570f8e968ba4fe2822f69ca8f09679da89d 100644 --- a/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java +++ b/src/main/java/net/minecraft/world/entity/animal/axolotl/Axolotl.java -@@ -268,9 +268,11 @@ public class Axolotl extends Animal implements LerpingModel, VariantHolder> 4, previousZ = Mth.floor(this.getZ()) >> 4; ++ int newX = Mth.floor(x) >> 4, newZ = Mth.floor(z) >> 4; ++ if ((previousX != newX || previousZ != newZ) && ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(((ServerLevel) this.level()), newX, newZ)) { ++ boolean isLoaded = ((net.minecraft.server.level.ServerChunkCache) this.level().getChunkSource()).getChunkAtIfCachedImmediately(newX, newZ) != null; ++ if (!isLoaded) { ++ if (Projectile.loadedThisTick > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerTick) { ++ if (++this.loadedLifetime > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerProjectile) { ++ this.discard(); ++ } ++ return; ++ } ++ Projectile.loadedThisTick++; ++ } ++ } ++ } ++ super.setPos(x, y, z); ++ } ++ // Pufferfish end ++ + public void setOwner(@Nullable Entity entity) { + if (entity != null) { + this.ownerUUID = entity.getUUID(); diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index c77beef9651aa2f7333d536e8ff4af3281834619..9628cc2b7f200e0bab4fed48997dde3e266200ee 100644 +index 3918fcfbb85cf0be523b3c723d9861aa5bca6d8c..bf38bbd0d0abf5e73c94e0f9d1f4462cccd6a105 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -38,6 +38,10 @@ import co.aikar.timings.MinecraftTimings; diff --git a/patches/server/0039-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch b/patches/server/0033-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch similarity index 89% rename from patches/server/0039-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch rename to patches/server/0033-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch index 6effd60..531ba2b 100644 --- a/patches/server/0039-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch +++ b/patches/server/0033-Pufferfish-Throttle-goal-selector-during-inactive-ti.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Tue, 20 Feb 2024 13:03:42 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:27:19 +0800 Subject: [PATCH] Pufferfish Throttle goal selector during inactive ticking @@ -31,10 +31,10 @@ index 0000000000000000000000000000000000000000..acc032f727e605e79b688efb4873ff47 + } +} diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index fae60501284a68238c53ffc19075d46ac49cfdaa..03cf4ef6fd09de13709400dc508266c2b3d99330 100644 +index 96a95939df41721433cefbfc07a5d75ea6b961e9..2384a9e68f99b61382d9d8a46523d226786ee584 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -245,11 +245,13 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti +@@ -240,11 +240,13 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab return this.lookControl; } diff --git a/patches/server/0040-Pufferfish-Reduce-entity-allocations.patch b/patches/server/0034-Pufferfish-Reduce-entity-allocations.patch similarity index 75% rename from patches/server/0040-Pufferfish-Reduce-entity-allocations.patch rename to patches/server/0034-Pufferfish-Reduce-entity-allocations.patch index 9c41730..37bff4e 100644 --- a/patches/server/0040-Pufferfish-Reduce-entity-allocations.patch +++ b/patches/server/0034-Pufferfish-Reduce-entity-allocations.patch @@ -1,16 +1,16 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Tue, 20 Feb 2024 13:11:11 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:27:45 +0800 Subject: [PATCH] Pufferfish Reduce entity allocations diff --git a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java -index 9ef8f014af332da129bfcd3370da983ec035ecc6..bc178967affd21ad04b83ea26639a2dd9b497454 100644 +index 69992ebc999ea3ff9e47e4e049bcc514c01150ca..da843441ec9fa9b8be0ef09d36853a4bddd53107 100644 --- a/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java +++ b/src/main/java/net/minecraft/world/entity/ai/attributes/AttributeMap.java -@@ -22,9 +22,11 @@ public class AttributeMap { - private final Map, AttributeInstance> attributes = new Object2ObjectOpenHashMap<>(); - private final Set dirtyAttributes = new ObjectOpenHashSet<>(); +@@ -23,9 +23,11 @@ public class AttributeMap { + private final Set attributesToSync = new ObjectOpenHashSet<>(); + private final Set attributesToUpdate = new ObjectOpenHashSet<>(); private final AttributeSupplier supplier; + private final java.util.function.Function, AttributeInstance> createInstance; // Pufferfish @@ -20,7 +20,7 @@ index 9ef8f014af332da129bfcd3370da983ec035ecc6..bc178967affd21ad04b83ea26639a2dd } private void onAttributeModified(AttributeInstance instance) { -@@ -43,7 +45,7 @@ public class AttributeMap { +@@ -49,7 +51,7 @@ public class AttributeMap { @Nullable public AttributeInstance getInstance(Holder attribute) { diff --git a/patches/server/0041-Pufferfish-Improve-container-checking-with-a-bitset.patch b/patches/server/0035-Pufferfish-Improve-container-checking-with-a-bitset.patch similarity index 97% rename from patches/server/0041-Pufferfish-Improve-container-checking-with-a-bitset.patch rename to patches/server/0035-Pufferfish-Improve-container-checking-with-a-bitset.patch index def387e..b2814cd 100644 --- a/patches/server/0041-Pufferfish-Improve-container-checking-with-a-bitset.patch +++ b/patches/server/0035-Pufferfish-Improve-container-checking-with-a-bitset.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Thu, 20 Jun 2024 04:46:56 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:28:54 +0800 Subject: [PATCH] Pufferfish Improve container checking with a bitset @@ -160,7 +160,7 @@ index 241fec02e6869c638d3a160819b32173a081467b..6a8f9e8f5bf108674c47018def28906e public int getContainerSize() { return this.container1.getContainerSize() + this.container2.getContainerSize(); diff --git a/src/main/java/net/minecraft/world/Container.java b/src/main/java/net/minecraft/world/Container.java -index f402dbbfe3a443e6bc51f88b85abe937852b52f0..541cb29a10e2c87a8214ff5beadb71bc1922d353 100644 +index 5db5ba026462ca642dcee718af732f80fadabef5..71c07abbeb01bdea58bc968fce098aa1eda8f30f 100644 --- a/src/main/java/net/minecraft/world/Container.java +++ b/src/main/java/net/minecraft/world/Container.java @@ -3,6 +3,8 @@ package net.minecraft.world; @@ -387,7 +387,7 @@ index b88aa184cd06a0485146f58a5b61a56a50911209..7b64c57795fe27d8397500bfa41f71f9 @Override diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index 1280c358748bbb08f0361acd4ebc095bf6bc3496..957c217653a664bab26db476724d288b18d87102 100644 +index 09410e95ebb0fd0089c924f39914287465a453bd..636865c710c4509e7d73ad27cf20aa713b48147e 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -47,7 +47,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @@ -442,7 +442,7 @@ index 1280c358748bbb08f0361acd4ebc095bf6bc3496..957c217653a664bab26db476724d288b if (!this.tryLoadLootTable(nbt)) { ContainerHelper.loadAllItems(nbt, this.items, registryLookup); } -@@ -537,6 +563,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -538,6 +564,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } private static boolean isFullContainer(Container inventory, Direction direction) { @@ -450,7 +450,7 @@ index 1280c358748bbb08f0361acd4ebc095bf6bc3496..957c217653a664bab26db476724d288b int[] aint = HopperBlockEntity.getSlots(inventory, direction); int[] aint1 = aint; int i = aint.length; -@@ -736,7 +763,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -738,7 +765,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen if (HopperBlockEntity.canPlaceItemInContainer(to, stack, slot, side)) { boolean flag = false; @@ -459,7 +459,7 @@ index 1280c358748bbb08f0361acd4ebc095bf6bc3496..957c217653a664bab26db476724d288b if (itemstack1.isEmpty()) { // Spigot start - SPIGOT-6693, InventorySubcontainer#setItem -@@ -924,7 +951,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -926,7 +953,10 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @Override protected void setItems(NonNullList inventory) { diff --git a/patches/server/0043-Gale-Variable-entity-wake-up-duration.patch b/patches/server/0036-Gale-Variable-entity-wake-up-duration.patch similarity index 96% rename from patches/server/0043-Gale-Variable-entity-wake-up-duration.patch rename to patches/server/0036-Gale-Variable-entity-wake-up-duration.patch index af7d9a7..03b6d4a 100644 --- a/patches/server/0043-Gale-Variable-entity-wake-up-duration.patch +++ b/patches/server/0036-Gale-Variable-entity-wake-up-duration.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Wed, 7 Feb 2024 06:00:22 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:30:56 +0800 Subject: [PATCH] Gale Variable entity wake-up duration @@ -31,7 +31,7 @@ index 0000000000000000000000000000000000000000..fa30e8dc39a2d4bd1399e41230b307b1 + } +} diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java -index 9628cc2b7f200e0bab4fed48997dde3e266200ee..3a6ae320891f1e3202c59b63a5f2c96c18727314 100644 +index bf38bbd0d0abf5e73c94e0f9d1f4462cccd6a105..af61cfe8330c3aecc348bfe40838d25755621333 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java +++ b/src/main/java/org/spigotmc/ActivationRange.java @@ -75,28 +75,41 @@ public class ActivationRange diff --git a/patches/server/0044-Gale-Don-t-load-chunks-to-activate-climbing-entities.patch b/patches/server/0037-Gale-Don-t-load-chunks-to-activate-climbing-entities.patch similarity index 91% rename from patches/server/0044-Gale-Don-t-load-chunks-to-activate-climbing-entities.patch rename to patches/server/0037-Gale-Don-t-load-chunks-to-activate-climbing-entities.patch index 8bb2bbc..ce3f3c4 100644 --- a/patches/server/0044-Gale-Don-t-load-chunks-to-activate-climbing-entities.patch +++ b/patches/server/0037-Gale-Don-t-load-chunks-to-activate-climbing-entities.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Wed, 7 Feb 2024 06:03:02 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:32:24 +0800 Subject: [PATCH] Gale Don't load chunks to activate climbing entities @@ -31,10 +31,10 @@ index 0000000000000000000000000000000000000000..ed62d25d6cd6dfcf8c5db20ced36eb3d + } +} diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index a999e3204d89ce2107026940cec7399360739ef0..cb531ab68cee6bc1a24309290771eb39de2dc276 100644 +index c1ac70dd05e049953e259f3b19135582ae21290e..644fcde5b570e36139b1897c0eff527c6194d305 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -5600,6 +5600,16 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -5537,6 +5537,16 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess return this.inBlockState; } @@ -52,10 +52,10 @@ index a999e3204d89ce2107026940cec7399360739ef0..cb531ab68cee6bc1a24309290771eb39 return this.chunkPosition; } diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 216af15f706f777bd6350cdd2187a8e7c98dfa21..76758de966bba1eab9e10ecf6063303e01e80e49 100644 +index 3c5c0634088f523f422912837abab818156ca291..7aade876648e79e48b80b4048ba0f8c07483bd96 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -2073,19 +2073,43 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2104,19 +2104,43 @@ public abstract class LivingEntity extends Entity implements Attackable { public boolean onClimableCached() { if (!this.blockPosition().equals(this.lastClimbingPosition)) { diff --git a/patches/server/0037-Pufferfish-Reduce-projectile-chunk-loading.patch b/patches/server/0037-Pufferfish-Reduce-projectile-chunk-loading.patch deleted file mode 100644 index 07010f4..0000000 --- a/patches/server/0037-Pufferfish-Reduce-projectile-chunk-loading.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Wed, 7 Feb 2024 05:45:24 +0000 -Subject: [PATCH] Pufferfish Reduce projectile chunk loading - - -diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/ProjectileChunkReduceConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/ProjectileChunkReduceConfig.java -new file mode 100644 -index 0000000000000000000000000000000000000000..12683ec5a5102e45b6171fea0b833ba57e5e188c ---- /dev/null -+++ b/src/main/java/me/earthme/luminol/config/modules/optimizations/ProjectileChunkReduceConfig.java -@@ -0,0 +1,22 @@ -+package me.earthme.luminol.config.modules.optimizations; -+ -+import me.earthme.luminol.config.ConfigInfo; -+import me.earthme.luminol.config.EnumConfigCategory; -+import me.earthme.luminol.config.IConfigModule; -+ -+public class ProjectileChunkReduceConfig implements IConfigModule { -+ @ConfigInfo(baseName = "max-loads-per-tick") -+ public static int maxProjectileLoadsPerTick; -+ @ConfigInfo(baseName = "max-loads-per-projectile") -+ public static int maxProjectileLoadsPerProjectile; -+ -+ @Override -+ public EnumConfigCategory getCategory() { -+ return EnumConfigCategory.OPTIMIZATIONS; -+ } -+ -+ @Override -+ public String getBaseName() { -+ return "projectile"; -+ } -+} -diff --git a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -index a8d2f7a9d0bcb6db0b38ac30b098d59951053b47..829b63c8a7574d6aefe95b7d190dccc4c6ecf1ba 100644 ---- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -+++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -46,6 +46,38 @@ public abstract class Projectile extends Entity implements TraceableEntity { - super(type, world); - } - -+ // Pufferfish start -+ private static long loadedThisTick = 0; -+ private static long loadedTick; -+ -+ private int loadedLifetime = 0; -+ @Override -+ public void setPos(double x, double y, double z) { -+ if (io.papermc.paper.util.TickThread.isTickThreadFor(this) && io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion() != null){ -+ long currentTick = io.papermc.paper.threadedregions.TickRegionScheduler.getCurrentRegion().getData().getCurrentTick(); -+ if (loadedTick != currentTick) { -+ loadedTick = currentTick; -+ loadedThisTick = 0; -+ } -+ int previousX = Mth.floor(this.getX()) >> 4, previousZ = Mth.floor(this.getZ()) >> 4; -+ int newX = Mth.floor(x) >> 4, newZ = Mth.floor(z) >> 4; -+ if ((previousX != newX || previousZ != newZ) && io.papermc.paper.util.TickThread.isTickThreadFor(((ServerLevel) this.level()), newX, newZ)) { -+ boolean isLoaded = ((net.minecraft.server.level.ServerChunkCache) this.level().getChunkSource()).getChunkAtIfLoadedMainThread(newX, newZ) != null; -+ if (!isLoaded) { -+ if (Projectile.loadedThisTick > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerTick) { -+ if (++this.loadedLifetime > me.earthme.luminol.config.modules.optimizations.ProjectileChunkReduceConfig.maxProjectileLoadsPerProjectile) { -+ this.discard(); -+ } -+ return; -+ } -+ Projectile.loadedThisTick++; -+ } -+ } -+ } -+ super.setPos(x, y, z); -+ } -+ // Pufferfish end -+ - public void setOwner(@Nullable Entity entity) { - if (entity != null) { - this.ownerUUID = entity.getUUID(); diff --git a/patches/server/0045-Gale-Optimize-sun-burn-tick.patch b/patches/server/0038-Gale-Optimize-sun-burn-tick.patch similarity index 86% rename from patches/server/0045-Gale-Optimize-sun-burn-tick.patch rename to patches/server/0038-Gale-Optimize-sun-burn-tick.patch index bc13d07..a95c291 100644 --- a/patches/server/0045-Gale-Optimize-sun-burn-tick.patch +++ b/patches/server/0038-Gale-Optimize-sun-burn-tick.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: M2ke4U <79621885+MrHua269@users.noreply.github.com> -Date: Sun, 26 Nov 2023 17:21:44 +0800 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:35:06 +0800 Subject: [PATCH] Gale Optimize sun burn tick diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index cb531ab68cee6bc1a24309290771eb39de2dc276..bc16167dccaf865b831885a1b32f42ab60229fe4 100644 +index 644fcde5b570e36139b1897c0eff527c6194d305..bb585e163ea3e066c3d8fc7caebf6c2b6f7a945b 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -310,7 +310,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -314,7 +314,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess public double xo; public double yo; public double zo; @@ -17,7 +17,7 @@ index cb531ab68cee6bc1a24309290771eb39de2dc276..bc16167dccaf865b831885a1b32f42ab public BlockPos blockPosition; // Pufferfish - private->public private ChunkPos chunkPosition; private Vec3 deltaMovement; -@@ -2120,9 +2120,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -2124,9 +2124,17 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess /** @deprecated */ @Deprecated public float getLightLevelDependentMagicValue() { @@ -35,19 +35,20 @@ index cb531ab68cee6bc1a24309290771eb39de2dc276..bc16167dccaf865b831885a1b32f42ab + public void absMoveTo(double x, double y, double z, float yaw, float pitch) { this.absMoveTo(x, y, z); - this.setYRot(yaw % 360.0F); + this.absRotateTo(yaw, pitch); diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index 03cf4ef6fd09de13709400dc508266c2b3d99330..4e0335d683334b0c6ee4dbf16d93f4e0392cf8d4 100644 +index 2384a9e68f99b61382d9d8a46523d226786ee584..56c1b21aa02abaf3c1a13c9b500cc84798acc611 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -1869,13 +1869,29 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Targeti - return flag; - } +@@ -1774,13 +1774,30 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab + + protected void playAttackSound() {} + // Gale start - JettPack - optimize sun burn tick - cache eye blockpos + private BlockPos cached_eye_blockpos; + private int cached_position_hashcode; + // Gale end - JettPack - optimize sun burn tick - cache eye blockpos ++ + public boolean isSunBurnTick() { if (this.level().isDay() && !this.level().isClientSide) { diff --git a/patches/server/0042-Pufferfish-Simpler-ShapelessRecipes-comparison-for-V.patch b/patches/server/0039-Gale-Simpler-ShapelessRecipe-comparison-for-vanilla.patch similarity index 52% rename from patches/server/0042-Pufferfish-Simpler-ShapelessRecipes-comparison-for-V.patch rename to patches/server/0039-Gale-Simpler-ShapelessRecipe-comparison-for-vanilla.patch index 075092d..0046716 100644 --- a/patches/server/0042-Pufferfish-Simpler-ShapelessRecipes-comparison-for-V.patch +++ b/patches/server/0039-Gale-Simpler-ShapelessRecipe-comparison-for-vanilla.patch @@ -1,37 +1,72 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MrHua269 -Date: Mon, 29 Jul 2024 19:53:42 +0800 -Subject: [PATCH] Pufferfish Simpler ShapelessRecipes comparison for Vanilla +Date: Wed, 31 Jul 2024 13:35:06 +0800 +Subject: [PATCH] Gale Simpler ShapelessRecipe comparison for vanilla +License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +Gale - https://galemc.org + +This patch is based on the following patch: +"Simpler ShapelessRecipes comparison for Vanilla" +By: Paul Sauve +As part of: Airplane (https://github.com/TECHNOVE/Airplane) +Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) + +* Airplane description * + +Paper added a fancy sorting comparison due to Bukkit recipes breaking +the vanilla one, however this is far more advanced than what you need +for all the vanilla recipes. + +* Airplane copyright * + +Airplane +Copyright (C) 2020 Technove LLC + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . diff --git a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java -index 3554109bcc4651ca93b6275c914e57e007e2204e..60c7a9520335de8e2638572100affcfdd776c5a3 100644 +index 213ee4aa988dd4c2a5a7be99b1d13f67338e5209..a51f21995b66e08b33e8645297c25e1f979d0e73 100644 --- a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java -@@ -27,8 +27,13 @@ public class ShapelessRecipe extends io.papermc.paper.inventory.recipe.RecipeBoo +@@ -25,8 +25,15 @@ public class ShapelessRecipe extends io.papermc.paper.inventory.recipe.RecipeBoo final CraftingBookCategory category; final ItemStack result; final NonNullList ingredients; -+ private final boolean isBukkit; // Pufferfish ++ private final boolean isBukkit; // Gale - Airplane - simpler ShapelessRecipe comparison for vanilla -+ // Pufferfish start public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, NonNullList ingredients) { ++ // Gale start - Airplane - simpler ShapelessRecipe comparison for vanilla + this(group, category, result, ingredients, false); + } -+ public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, NonNullList ingredients, boolean isBukkit) { this.isBukkit = isBukkit; // Pufferfish end ++ public ShapelessRecipe(String group, CraftingBookCategory category, ItemStack result, NonNullList ingredients, boolean isBukkit) { ++ this.isBukkit = isBukkit; ++ // Gale end - Airplane - simpler ShapelessRecipe comparison for vanilla this.group = group; this.category = category; this.result = result; -@@ -78,6 +83,28 @@ public class ShapelessRecipe extends io.papermc.paper.inventory.recipe.RecipeBoo +@@ -76,6 +83,29 @@ public class ShapelessRecipe extends io.papermc.paper.inventory.recipe.RecipeBoo } - public boolean matches(CraftingContainer inventory, Level world) { -+ // Pufferfish start + public boolean matches(CraftingInput input, Level world) { ++ // Gale start - Airplane - simpler ShapelessRecipe comparison for vanilla + if (!this.isBukkit) { + java.util.List ingredients = com.google.common.collect.Lists.newArrayList(this.ingredients.toArray(new Ingredient[0])); + -+ inventory: for (int index = 0; index < inventory.getContainerSize(); index++) { -+ ItemStack itemStack = inventory.getItem(index); ++ inventory: ++ for (int index = 0; index < input.size(); index++) { ++ ItemStack itemStack = input.getItem(index); + + if (!itemStack.isEmpty()) { + for (int i = 0; i < ingredients.size(); i++) { @@ -46,13 +81,13 @@ index 3554109bcc4651ca93b6275c914e57e007e2204e..60c7a9520335de8e2638572100affcfd + + return ingredients.isEmpty(); + } -+ // Pufferfish end ++ // Gale end - Airplane - simpler ShapelessRecipe comparison for vanilla + - StackedContents autorecipestackmanager = new StackedContents(); - autorecipestackmanager.initialize(this); // Paper - better exact choice recipes - int i = 0; + // Paper start - unwrap ternary & better exact choice recipes + if (input.ingredientCount() != this.ingredients.size()) { + return false; diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java -index 96d772eb02f79f8c478f5e6f065e387aa7665b18..c5ce412f321b8b4f31cc042893659e213b081f29 100644 +index 96d772eb02f79f8c478f5e6f065e387aa7665b18..0d27792dcc3deb4cc7835512f4156b490223358d 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftShapelessRecipe.java @@ -45,6 +45,6 @@ public class CraftShapelessRecipe extends ShapelessRecipe implements CraftRecipe @@ -60,6 +95,6 @@ index 96d772eb02f79f8c478f5e6f065e387aa7665b18..c5ce412f321b8b4f31cc042893659e21 } - MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.ShapelessRecipe(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data))); -+ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.ShapelessRecipe(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data, true))); // Pufferfish ++ MinecraftServer.getServer().getRecipeManager().addRecipe(new RecipeHolder<>(CraftNamespacedKey.toMinecraft(this.getKey()), new net.minecraft.world.item.crafting.ShapelessRecipe(this.getGroup(), CraftRecipe.getCategory(this.getCategory()), CraftItemStack.asNMSCopy(this.getResult()), data, true))); // Gale - Airplane - simpler ShapelessRecipe comparison for vanilla } } diff --git a/patches/server/0047-Gale-Use-platform-math-functions.patch b/patches/server/0040-Gale-Use-platform-math-functions.patch similarity index 74% rename from patches/server/0047-Gale-Use-platform-math-functions.patch rename to patches/server/0040-Gale-Use-platform-math-functions.patch index 3072216..4cd5270 100644 --- a/patches/server/0047-Gale-Use-platform-math-functions.patch +++ b/patches/server/0040-Gale-Use-platform-math-functions.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Sun, 28 Jan 2024 09:31:27 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:38:04 +0800 Subject: [PATCH] Gale Use platform math functions License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) @@ -98,45 +98,11 @@ public class Main { } ``` -diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java -index 2034c67f5702b7b8d093ef2dd7601901c5fef363..2a88165dd4edbc2ca1acd2f6e0a4b99ec61cf958 100644 ---- a/src/main/java/io/papermc/paper/util/MCUtil.java -+++ b/src/main/java/io/papermc/paper/util/MCUtil.java -@@ -168,13 +168,11 @@ public final class MCUtil { - } - - public static int fastFloor(double x) { -- int truncated = (int)x; -- return x < (double)truncated ? truncated - 1 : truncated; -+ return (int) Math.floor(x); // Gale - use platform math functions - } - - public static int fastFloor(float x) { -- int truncated = (int)x; -- return x < (double)truncated ? truncated - 1 : truncated; -+ return (int) Math.floor(x); // Gale - use platform math functions - } - - public static float normalizeYaw(float f) { -@@ -235,11 +233,11 @@ public final class MCUtil { - } - - public static int getChunkCoordinate(final double coordinate) { -- return MCUtil.fastFloor(coordinate) >> 4; -+ return ((int) Math.floor(coordinate)) >> 4; // Gale - use platform math functions - } - - public static int getBlockCoordinate(final double coordinate) { -- return MCUtil.fastFloor(coordinate); -+ return (int) Math.floor(coordinate); // Gale - use platform math functions - } - - public static long getBlockKey(final int x, final int y, final int z) { diff --git a/src/main/java/net/minecraft/util/Mth.java b/src/main/java/net/minecraft/util/Mth.java -index 990ea96de8e940390b67e9462fcfd6025f2f5770..e102c109d01e0f992808a6096b5f6a323b52d970 100644 +index f298cdfcf1539e467f57f9f7789de3cf2ca54665..3468b7fbc7440f220fce8039f237658a593df296 100644 --- a/src/main/java/net/minecraft/util/Mth.java +++ b/src/main/java/net/minecraft/util/Mth.java -@@ -58,13 +58,11 @@ public class Mth { +@@ -58,18 +58,15 @@ public class Mth { } public static int floor(float value) { @@ -152,7 +118,13 @@ index 990ea96de8e940390b67e9462fcfd6025f2f5770..e102c109d01e0f992808a6096b5f6a32 } public static long lfloor(double value) { -@@ -81,13 +79,11 @@ public class Mth { +- long l = (long)value; +- return value < (double)l ? l - 1L : l; ++ return (long) Math.floor(value); // Gale - use platform math functions + } + + public static float abs(float value) { +@@ -81,13 +78,11 @@ public class Mth { } public static int ceil(float value) { @@ -168,7 +140,7 @@ index 990ea96de8e940390b67e9462fcfd6025f2f5770..e102c109d01e0f992808a6096b5f6a32 } public static int clamp(int value, int min, int max) { -@@ -123,15 +119,7 @@ public class Mth { +@@ -123,15 +118,7 @@ public class Mth { } public static double absMax(double a, double b) { diff --git a/patches/server/0048-Gale-Skip-entity-move-if-movement-is-zero.patch b/patches/server/0041-Gale-Skip-entity-move-if-movement-is-zero.patch similarity index 78% rename from patches/server/0048-Gale-Skip-entity-move-if-movement-is-zero.patch rename to patches/server/0041-Gale-Skip-entity-move-if-movement-is-zero.patch index f69ce69..abf1886 100644 --- a/patches/server/0048-Gale-Skip-entity-move-if-movement-is-zero.patch +++ b/patches/server/0041-Gale-Skip-entity-move-if-movement-is-zero.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Tue, 6 Feb 2024 04:21:05 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:38:04 +0800 Subject: [PATCH] Gale Skip entity move if movement is zero diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index bc16167dccaf865b831885a1b32f42ab60229fe4..99978531e19eb9d5a14354b7e518d609e2389b5a 100644 +index bb585e163ea3e066c3d8fc7caebf6c2b6f7a945b..3c217574bb9c161ac6c556d6abce31a10fce40c0 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -319,6 +319,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -323,6 +323,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess public float yRotO; public float xRotO; private AABB bb; @@ -16,7 +16,7 @@ index bc16167dccaf865b831885a1b32f42ab60229fe4..99978531e19eb9d5a14354b7e518d609 public boolean onGround; public boolean horizontalCollision; public boolean verticalCollision; -@@ -1143,6 +1144,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -1139,6 +1140,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess //Luminol end public void move(MoverType movementType, Vec3 movement) { @@ -27,8 +27,8 @@ index bc16167dccaf865b831885a1b32f42ab60229fe4..99978531e19eb9d5a14354b7e518d609 + // Gale end - VMP - skip entity move if movement is zero final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity // Paper start - detailed watchdog information - io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main"); -@@ -5011,6 +5017,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot move an entity off-main"); +@@ -4964,6 +4970,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess } public final void setBoundingBox(AABB boundingBox) { diff --git a/patches/server/0050-Gale-Optimize-noise-generation.patch b/patches/server/0042-Gale-Optimize-noise-generation.patch similarity index 100% rename from patches/server/0050-Gale-Optimize-noise-generation.patch rename to patches/server/0042-Gale-Optimize-noise-generation.patch diff --git a/patches/server/0051-Gale-Faster-chunk-serialization.patch b/patches/server/0043-Gale-Faster-chunk-serialization.patch similarity index 93% rename from patches/server/0051-Gale-Faster-chunk-serialization.patch rename to patches/server/0043-Gale-Faster-chunk-serialization.patch index bd4c2af..ad54c94 100644 --- a/patches/server/0051-Gale-Faster-chunk-serialization.patch +++ b/patches/server/0043-Gale-Faster-chunk-serialization.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Tue, 20 Feb 2024 13:21:53 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 13:42:17 +0800 Subject: [PATCH] Gale Faster chunk serialization @@ -203,21 +203,23 @@ index 0000000000000000000000000000000000000000..349618b7f544bf9a30e0796d4d9a2640 + } +} diff --git a/src/main/java/net/minecraft/util/BitStorage.java b/src/main/java/net/minecraft/util/BitStorage.java -index 8bafd5fd7499ba4a04bf706cfd1e156073716e21..f62aab492f231e688b448389b1910e6fc2f5d8e6 100644 +index 19661e106612b8e4e152085fb398db7bd06acc23..4fd45dc4dca29ac5f0be3b02d8ce17127bdc38cf 100644 --- a/src/main/java/net/minecraft/util/BitStorage.java +++ b/src/main/java/net/minecraft/util/BitStorage.java -@@ -31,4 +31,6 @@ public interface BitStorage { +@@ -21,6 +21,8 @@ public interface BitStorage extends ca.spottedleaf.moonrise.patches.block_counti + + BitStorage copy(); - } - // Paper end -+ + void compact(net.minecraft.world.level.chunk.Palette srcPalette, net.minecraft.world.level.chunk.Palette dstPalette, short[] out); // Gale - Lithium - faster chunk serialization - } ++ + // Paper start - block counting + // provide default impl in case mods implement this... + @Override diff --git a/src/main/java/net/minecraft/util/SimpleBitStorage.java b/src/main/java/net/minecraft/util/SimpleBitStorage.java -index 8d7d763bf51cac556057645e6169c9447993189b..c1e5f04df9529e9236a5c8a047b02ad560085025 100644 +index 8acf2f2491a8d9d13392c5e89b2bd5c9918285e1..5ff7b2c9d97cb428b7a3a54bd53ab385afe92ce1 100644 --- a/src/main/java/net/minecraft/util/SimpleBitStorage.java +++ b/src/main/java/net/minecraft/util/SimpleBitStorage.java -@@ -389,4 +389,45 @@ public class SimpleBitStorage implements BitStorage { +@@ -401,4 +401,45 @@ public class SimpleBitStorage implements BitStorage { super(message); } } @@ -264,16 +266,18 @@ index 8d7d763bf51cac556057645e6169c9447993189b..c1e5f04df9529e9236a5c8a047b02ad5 + } diff --git a/src/main/java/net/minecraft/util/ZeroBitStorage.java b/src/main/java/net/minecraft/util/ZeroBitStorage.java -index 01f5b946fabbe34f31110e75973dab9f39897346..1cd79ab7635d4a5e55538c1130f487245f45b4b6 100644 +index 15c5164d0ef41a978c16ee317fa73e97f2480207..60ffd244d5e1c528d908ee9a5dd2d8907a30bb24 100644 --- a/src/main/java/net/minecraft/util/ZeroBitStorage.java +++ b/src/main/java/net/minecraft/util/ZeroBitStorage.java -@@ -71,4 +71,6 @@ public class ZeroBitStorage implements BitStorage { - public BitStorage copy() { - return this; +@@ -12,6 +12,8 @@ public class ZeroBitStorage implements BitStorage { + this.size = size; } -+ + + @Override public void compact(net.minecraft.world.level.chunk.Palette srcPalette, net.minecraft.world.level.chunk.Palette dstPalette, short[] out) {} // Gale - Lithium - faster chunk serialization - } ++ + @Override + public final int getAndSet(int index, int value) { // Paper - Perf: Optimize SimpleBitStorage + //Validate.inclusiveBetween(0L, (long)(this.size - 1), (long)index); // Paper - Perf: Optimize SimpleBitStorage diff --git a/src/main/java/net/minecraft/world/level/chunk/PaletteResize.java b/src/main/java/net/minecraft/world/level/chunk/PaletteResize.java index acae3eb30e0689048937f479dc3070f0688abdad..4b79f0474a9013dd4fdb68c6363ca1942ba8b007 100644 --- a/src/main/java/net/minecraft/world/level/chunk/PaletteResize.java @@ -286,7 +290,7 @@ index acae3eb30e0689048937f479dc3070f0688abdad..4b79f0474a9013dd4fdb68c6363ca194 int onResize(int newBits, T object); } diff --git a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java -index 81368bf186365878db2e1ed305bb7bf36c26f61f..ee7ce575a80b47da752f1cc722b7f4dc3b1b1314 100644 +index 13d3c877b006a4975e7370713e3919c661e7890f..a2e0c9df771483904ffeaf6ef3bd3ab4b189fdb3 100644 --- a/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/src/main/java/net/minecraft/world/level/chunk/PalettedContainer.java @@ -25,6 +25,22 @@ import net.minecraft.util.ThreadingDetector; diff --git a/patches/server/0052-Gale-Reduce-lambda-and-Optional-allocation-in-Entity.patch b/patches/server/0044-Gale-Reduce-lambda-and-Optional-allocation-in-Entity.patch similarity index 100% rename from patches/server/0052-Gale-Reduce-lambda-and-Optional-allocation-in-Entity.patch rename to patches/server/0044-Gale-Reduce-lambda-and-Optional-allocation-in-Entity.patch diff --git a/patches/server/0053-Gale-Replace-throttle-tracker-map-with-optimized-col.patch b/patches/server/0045-Gale-Replace-throttle-tracker-map-with-optimized-col.patch similarity index 88% rename from patches/server/0053-Gale-Replace-throttle-tracker-map-with-optimized-col.patch rename to patches/server/0045-Gale-Replace-throttle-tracker-map-with-optimized-col.patch index 8a60567..4f5ed50 100644 --- a/patches/server/0053-Gale-Replace-throttle-tracker-map-with-optimized-col.patch +++ b/patches/server/0045-Gale-Replace-throttle-tracker-map-with-optimized-col.patch @@ -1,11 +1,11 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Sat, 6 Apr 2024 05:18:00 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 14:22:07 +0800 Subject: [PATCH] Gale Replace throttle tracker map with optimized collection diff --git a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java -index 45a2683c9489bee6d67a1f3d702c17f2e9dc02e4..8e90f35218e66690359dac35828a1485a77f34c1 100644 +index ddf42645402afefc0f5caebc684b191eef9d6ec2..a943f83e874d348251ddd3feb732e543641172d9 100644 --- a/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerHandshakePacketListenerImpl.java @@ -1,5 +1,7 @@ @@ -15,8 +15,8 @@ index 45a2683c9489bee6d67a1f3d702c17f2e9dc02e4..8e90f35218e66690359dac35828a1485 +import it.unimi.dsi.fastutil.objects.Object2LongOpenHashMap; import net.minecraft.SharedConstants; import net.minecraft.network.Connection; - import net.minecraft.network.chat.Component; -@@ -14,7 +16,8 @@ import net.minecraft.server.MinecraftServer; + import net.minecraft.network.DisconnectionDetails; +@@ -15,7 +17,8 @@ import net.minecraft.server.MinecraftServer; // CraftBukkit start import java.net.InetAddress; @@ -26,7 +26,7 @@ index 45a2683c9489bee6d67a1f3d702c17f2e9dc02e4..8e90f35218e66690359dac35828a1485 // CraftBukkit end public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketListener { -@@ -25,7 +28,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL +@@ -26,7 +29,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL static final java.util.regex.Pattern PROP_PATTERN = java.util.regex.Pattern.compile("\\w{0,16}"); // Spigot end // CraftBukkit start - add fields @@ -35,7 +35,7 @@ index 45a2683c9489bee6d67a1f3d702c17f2e9dc02e4..8e90f35218e66690359dac35828a1485 private static int throttleCounter = 0; // CraftBukkit end private static final Component IGNORE_STATUS_REASON = Component.translatable("disconnect.ignoring_status_request"); -@@ -86,7 +89,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL +@@ -87,7 +90,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL InetAddress address = ((java.net.InetSocketAddress) this.connection.getRemoteAddress()).getAddress(); synchronized (ServerHandshakePacketListenerImpl.throttleTracker) { @@ -44,7 +44,7 @@ index 45a2683c9489bee6d67a1f3d702c17f2e9dc02e4..8e90f35218e66690359dac35828a1485 ServerHandshakePacketListenerImpl.throttleTracker.put(address, currentTime); Component chatmessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.connectionThrottle); // Paper - Configurable connection throttle kick message this.connection.send(new ClientboundLoginDisconnectPacket(chatmessage)); -@@ -100,13 +103,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL +@@ -101,13 +104,7 @@ public class ServerHandshakePacketListenerImpl implements ServerHandshakePacketL ServerHandshakePacketListenerImpl.throttleCounter = 0; // Cleanup stale entries diff --git a/patches/server/0046-Gale-Check-frozen-ticks-before-landing-block.patch b/patches/server/0046-Gale-Check-frozen-ticks-before-landing-block.patch deleted file mode 100644 index 42d6adc..0000000 --- a/patches/server/0046-Gale-Check-frozen-ticks-before-landing-block.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Sun, 28 Jan 2024 09:30:22 +0000 -Subject: [PATCH] Gale Check frozen ticks before landing block - - -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 76758de966bba1eab9e10ecf6063303e01e80e49..69a44c8f9b79b9e2b1f7723e3229aab90109d5c6 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -609,11 +609,10 @@ public abstract class LivingEntity extends Entity implements Attackable { - } - - protected void tryAddFrost() { -- if (!this.getBlockStateOnLegacy().isAir()) { - int i = this.getTicksFrozen(); - - if (i > 0) { -- AttributeInstance attributemodifiable = this.getAttribute(Attributes.MOVEMENT_SPEED); -+ AttributeInstance attributemodifiable = this.getBlockStateOnLegacy().isAir() ? null : this.getAttribute(Attributes.MOVEMENT_SPEED); // Gale - Lithium - check frozen ticks before landing block - - if (attributemodifiable == null) { - return; -@@ -623,7 +622,6 @@ public abstract class LivingEntity extends Entity implements Attackable { - - attributemodifiable.addTransientModifier(new AttributeModifier(LivingEntity.SPEED_MODIFIER_POWDER_SNOW_UUID, "Powder snow slow", (double) f, AttributeModifier.Operation.ADD_VALUE)); - } -- } - - } - diff --git a/patches/server/0054-Sparkly-Paper-Optimize-canSee-checks.patch b/patches/server/0046-Sparkly-Paper-Optimize-canSee-checks.patch similarity index 74% rename from patches/server/0054-Sparkly-Paper-Optimize-canSee-checks.patch rename to patches/server/0046-Sparkly-Paper-Optimize-canSee-checks.patch index d43095c..d031f5e 100644 --- a/patches/server/0054-Sparkly-Paper-Optimize-canSee-checks.patch +++ b/patches/server/0046-Sparkly-Paper-Optimize-canSee-checks.patch @@ -1,27 +1,27 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Sun, 28 Jan 2024 09:11:58 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 14:25:46 +0800 Subject: [PATCH] Sparkly Paper Optimize canSee checks diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 4a0c5afd03dba788c40a71f00bc1fd0d4f0fc7e4..04f5efdc0d5729af5009e51a3e36ed7c34991123 100644 +index 31f2f6e841179a2fba2199afa7d6211eb68d3c07..1bc460051ded5faa7010f999dfee0904bce1a31e 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1422,7 +1422,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1221,7 +1221,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider // Folia end - region threading // CraftBukkit start - respect vanish API -- if (flag && (!io.papermc.paper.util.TickThread.isTickThreadFor(player) || !player.getBukkitEntity().canSee(this.entity.getBukkitEntity()))) { // Paper - only consider hits // Folia - region threading -+ if (flag && (!io.papermc.paper.util.TickThread.isTickThreadFor(player) || !player.getBukkitEntity().canSeeChunkMapUpdatePlayer(this.entity.getBukkitEntity()))) { // Paper - only consider hits // Folia - region threading // SparklyPaper - optimize canSee checks +- if (flag && (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(player) || !player.getBukkitEntity().canSee(this.entity.getBukkitEntity()))) { // Paper - only consider hits // Folia - region threading ++ if (flag && (!ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(player) || !player.getBukkitEntity().canSeeChunkMapUpdatePlayer(this.entity.getBukkitEntity()))) { // Paper - only consider hits // Folia - region threading // SparklyPaper - optimize canSee checks flag = false; } // CraftBukkit end diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 28583ad8117167400faf3ca0dc4bc9f3f44dbedb..a3d4dc232d011c262d85028351191ac2b8547398 100644 +index 61683135b0462770cfe93e16fd0d0c1bca13e045..572c85579237afa65ffb3409fa3b70c7f86fcb0f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -198,7 +198,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -200,7 +200,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { private boolean hasPlayedBefore = false; private final ConversationTracker conversationTracker = new ConversationTracker(); private final Set channels = new HashSet(); @@ -30,7 +30,7 @@ index 28583ad8117167400faf3ca0dc4bc9f3f44dbedb..a3d4dc232d011c262d85028351191ac2 private final Set unlistedEntities = new HashSet<>(); // Paper - Add Listing API for Player private static final WeakHashMap> pluginWeakReferences = new WeakHashMap<>(); private int hash = 0; -@@ -2234,9 +2234,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2253,9 +2253,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @Override public boolean canSee(org.bukkit.entity.Entity entity) { diff --git a/patches/server/0055-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch b/patches/server/0047-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch similarity index 93% rename from patches/server/0055-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch rename to patches/server/0047-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch index 21fe8e2..cefa2bf 100644 --- a/patches/server/0055-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch +++ b/patches/server/0047-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch @@ -1,8 +1,7 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MrHua269 -Date: Mon, 29 Jul 2024 20:06:27 +0800 +Date: Wed, 31 Jul 2024 14:28:06 +0800 Subject: [PATCH] SparklyPaper Skip "MapItem#update()" if the map does not have - the CraftMapRenderer present diff --git a/src/main/java/me/earthme/luminol/config/modules/optimizations/MapItemUpdateSkipConfig.java b/src/main/java/me/earthme/luminol/config/modules/optimizations/MapItemUpdateSkipConfig.java @@ -32,7 +31,7 @@ index 0000000000000000000000000000000000000000..6235ff18455a21695bdc2d65367558d3 + } +} diff --git a/src/main/java/net/minecraft/world/item/MapItem.java b/src/main/java/net/minecraft/world/item/MapItem.java -index 957396b145b1d1adf265f8b9aaeba052758f007a..6d0f67882885373b4772b9f747e68e490dd8797e 100644 +index e96f15814986109e5e947c7b3b210be6e56ba0ed..31354cbf344c222a8e6e892091ea30d81b8b2706 100644 --- a/src/main/java/net/minecraft/world/item/MapItem.java +++ b/src/main/java/net/minecraft/world/item/MapItem.java @@ -281,7 +281,7 @@ public class MapItem extends ComplexItem { diff --git a/patches/server/0057-Purpur-use-alternative-keep-alive.patch b/patches/server/0048-Purpur-use-alternative-keep-alive.patch similarity index 72% rename from patches/server/0057-Purpur-use-alternative-keep-alive.patch rename to patches/server/0048-Purpur-use-alternative-keep-alive.patch index 863baf7..4d7e600 100644 --- a/patches/server/0057-Purpur-use-alternative-keep-alive.patch +++ b/patches/server/0048-Purpur-use-alternative-keep-alive.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Wed, 7 Feb 2024 08:35:11 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 14:30:23 +0800 Subject: [PATCH] Purpur use alternative keep alive @@ -30,11 +30,31 @@ index 0000000000000000000000000000000000000000..43bbc2c30bdd3872a0179e0070403c3e + return "alternative_keepalive_handling"; + } +} +diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java +index 8ea2f24695f5dad55e21f238b69442513e7a90c6..d61359db1773ece7b0349e13ca56ad3883fd4b43 100644 +--- a/src/main/java/net/minecraft/server/level/ServerEntity.java ++++ b/src/main/java/net/minecraft/server/level/ServerEntity.java +@@ -216,6 +216,7 @@ public class ServerEntity { + + if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) { + Vec3 vec3d1 = this.entity.getDeltaMovement(); ++ if (vec3d1 != this.lastSentMovement) { // SparklyPaper start - skip distanceToSqr call in ServerEntity#sendChanges if the delta movement hasn't changed + double d0 = vec3d1.distanceToSqr(this.lastSentMovement); + + if (d0 > 1.0E-7D || d0 > 0.0D && vec3d1.lengthSqr() == 0.0D) { +@@ -230,6 +231,7 @@ public class ServerEntity { + this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.lastSentMovement)); + } + } ++ } // SparklyPaper end + } + + if (packet1 != null) { diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index f907dbb55369395058091dd75ae435d2025d94dd..972b6edfaac4b13313d078d8843a2d63f569afdc 100644 +index d766bb360eb98bab1e067cad032b54fa6455f386..89080162548c8343202bef910865136075172da7 100644 --- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -73,6 +73,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -74,6 +74,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack private long keepAliveChallenge; private long closedListenerTime; private boolean closed = false; @@ -42,7 +62,7 @@ index f907dbb55369395058091dd75ae435d2025d94dd..972b6edfaac4b13313d078d8843a2d63 private int latency; private volatile boolean suspendFlushingOnServerThread = false; public final java.util.Map packCallbacks = new java.util.concurrent.ConcurrentHashMap<>(); // Paper - adventure resource pack callbacks -@@ -135,6 +136,16 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -136,6 +137,16 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @Override public void handleKeepAlive(ServerboundKeepAlivePacket packet) { @@ -59,7 +79,7 @@ index f907dbb55369395058091dd75ae435d2025d94dd..972b6edfaac4b13313d078d8843a2d63 //PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); // CraftBukkit // Paper - handle ServerboundKeepAlivePacket async if (this.keepAlivePending && packet.getId() == this.keepAliveChallenge) { int i = (int) (Util.getMillis() - this.keepAliveTime); -@@ -264,6 +275,21 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -265,6 +276,21 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack long currentTime = Util.getMillis(); long elapsedTime = currentTime - this.keepAliveTime; @@ -80,8 +100,8 @@ index f907dbb55369395058091dd75ae435d2025d94dd..972b6edfaac4b13313d078d8843a2d63 + if (!this.isSingleplayerOwner() && elapsedTime >= 15000L) { // Paper - use vanilla's 15000L between keep alive packets if (this.keepAlivePending && !this.processedDisconnect && elapsedTime >= KEEPALIVE_LIMIT) { // Paper - check keepalive limit, don't fire if already disconnected - this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause -@@ -275,6 +301,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack + this.disconnect(ServerCommonPacketListenerImpl.TIMEOUT_DISCONNECTION_MESSAGE, PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause +@@ -276,6 +302,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack } } // Paper end - give clients a longer time to respond to pings as per pre 1.12.2 timings diff --git a/patches/server/0049-Gale-Optimize-world-generation-chunk-and-block-acces.patch b/patches/server/0049-Gale-Optimize-world-generation-chunk-and-block-acces.patch deleted file mode 100644 index c72e9f9..0000000 --- a/patches/server/0049-Gale-Optimize-world-generation-chunk-and-block-acces.patch +++ /dev/null @@ -1,183 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Fri, 9 Feb 2024 23:43:16 +0000 -Subject: [PATCH] Gale Optimize world generation chunk and block access - - -diff --git a/src/main/java/me/jellysquid/mods/lithium/common/util/Pos.java b/src/main/java/me/jellysquid/mods/lithium/common/util/Pos.java -new file mode 100644 -index 0000000000000000000000000000000000000000..f2f10b651e4fbecdd1ea1bc28ebf40d685a67cee ---- /dev/null -+++ b/src/main/java/me/jellysquid/mods/lithium/common/util/Pos.java -@@ -0,0 +1,95 @@ -+// Gale - Lithium - position utility -+ -+package me.jellysquid.mods.lithium.common.util; -+ -+import net.minecraft.core.SectionPos; -+import net.minecraft.world.level.LevelHeightAccessor; -+ -+public class Pos { -+ -+ public static class BlockCoord { -+ public static int getYSize(LevelHeightAccessor view) { -+ return view.getHeight(); -+ } -+ public static int getMinY(LevelHeightAccessor view) { -+ return view.getMinBuildHeight(); -+ } -+ public static int getMaxYInclusive(LevelHeightAccessor view) { -+ return view.getMaxBuildHeight() - 1; -+ } -+ public static int getMaxYExclusive(LevelHeightAccessor view) { -+ return view.getMaxBuildHeight(); -+ } -+ -+ public static int getMaxInSectionCoord(int sectionCoord) { -+ return 15 + getMinInSectionCoord(sectionCoord); -+ } -+ -+ public static int getMaxYInSectionIndex(LevelHeightAccessor view, int sectionIndex){ -+ return getMaxInSectionCoord(SectionYCoord.fromSectionIndex(view, sectionIndex)); -+ } -+ -+ public static int getMinInSectionCoord(int sectionCoord) { -+ return SectionPos.sectionToBlockCoord(sectionCoord); -+ } -+ -+ public static int getMinYInSectionIndex(LevelHeightAccessor view, int sectionIndex) { -+ return getMinInSectionCoord(SectionYCoord.fromSectionIndex(view, sectionIndex)); -+ } -+ } -+ -+ public static class ChunkCoord { -+ public static int fromBlockCoord(int blockCoord) { -+ return SectionPos.blockToSectionCoord(blockCoord); -+ } -+ -+ public static int fromBlockSize(int i) { -+ return i >> 4; //same method as fromBlockCoord, just be clear about coord/size semantic difference -+ } -+ } -+ -+ public static class SectionYCoord { -+ public static int getNumYSections(LevelHeightAccessor view) { -+ return view.getSectionsCount(); -+ } -+ public static int getMinYSection(LevelHeightAccessor view) { -+ return view.getMinSection(); -+ } -+ public static int getMaxYSectionInclusive(LevelHeightAccessor view) { -+ return view.getMaxSection() - 1; -+ } -+ public static int getMaxYSectionExclusive(LevelHeightAccessor view) { -+ return view.getMaxSection(); -+ } -+ -+ public static int fromSectionIndex(LevelHeightAccessor view, int sectionCoord) { -+ return sectionCoord + SectionYCoord.getMinYSection(view); -+ } -+ public static int fromBlockCoord(int blockCoord) { -+ return SectionPos.blockToSectionCoord(blockCoord); -+ } -+ } -+ -+ public static class SectionYIndex { -+ public static int getNumYSections(LevelHeightAccessor view) { -+ return view.getSectionsCount(); -+ } -+ public static int getMinYSectionIndex(LevelHeightAccessor view) { -+ return 0; -+ } -+ public static int getMaxYSectionIndexInclusive(LevelHeightAccessor view) { -+ return view.getSectionsCount() - 1; -+ } -+ public static int getMaxYSectionIndexExclusive(LevelHeightAccessor view) { -+ return view.getSectionsCount(); -+ } -+ -+ public static int fromSectionCoord(LevelHeightAccessor view, int sectionCoord) { -+ return sectionCoord - SectionYCoord.getMinYSection(view); -+ } -+ public static int fromBlockCoord(LevelHeightAccessor view, int blockCoord) { -+ return fromSectionCoord(view, SectionPos.blockToSectionCoord(blockCoord)); -+ } -+ } -+ -+} -diff --git a/src/main/java/net/minecraft/server/level/WorldGenRegion.java b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -index b17bb9b9387b9efa5cc7513e36ea896b17712cae..8f90d1571f019c637176ffc6403a3b2506dcd6a6 100644 ---- a/src/main/java/net/minecraft/server/level/WorldGenRegion.java -+++ b/src/main/java/net/minecraft/server/level/WorldGenRegion.java -@@ -86,6 +86,10 @@ public class WorldGenRegion implements WorldGenLevel { - private Supplier currentlyGenerating; - private final AtomicLong subTickCount = new AtomicLong(); - private static final ResourceLocation WORLDGEN_REGION_RANDOM = new ResourceLocation("worldgen_region_random"); -+ // Gale start - Lithium - optimize world generation chunk and block access -+ private ChunkAccess[] chunksArr; -+ private int minChunkX, minChunkZ; -+ // Gale end - Lithium - optimize world generation chunk and block access - - // Folia start - region threading - private final net.minecraft.world.level.StructureManager structureManager; -@@ -116,6 +120,11 @@ public class WorldGenRegion implements WorldGenLevel { - this.lastPos = ((ChunkAccess) chunks.get(chunks.size() - 1)).getPos(); - this.structureManager = world.structureManager().forWorldGenRegion(this); // Folia - region threading - } -+ // Gale start - Lithium - optimize world generation chunk and block access -+ this.minChunkX = this.firstPos.x; -+ this.minChunkZ = this.firstPos.z; -+ this.chunksArr = chunks.toArray(new ChunkAccess[0]); -+ // Gale end - Lithium - optimize world generation chunk and block access - } - - // Paper start - starlight -@@ -154,8 +163,28 @@ public class WorldGenRegion implements WorldGenLevel { - - @Override - public ChunkAccess getChunk(int chunkX, int chunkZ) { -- return this.getChunk(chunkX, chunkZ, ChunkStatus.EMPTY); -+ // Gale start - Lithium - optimize world generation chunk and block access - use the chunk array for faster access -+ int x = chunkX - this.minChunkX; -+ int z = chunkZ - this.minChunkZ; -+ int w = this.size; -+ -+ if (x >= 0 && z >= 0 && x < w && z < w) { -+ return this.chunksArr[x + z * w]; -+ } else { -+ throw new NullPointerException("No chunk exists at " + new ChunkPos(chunkX, chunkZ)); -+ } -+ // Gale end - Lithium - optimize world generation chunk and block access - use the chunk array for faster access -+ } -+ -+ // Gale start - Lithium - optimize world generation chunk and block access -+ /** -+ * Use our chunk fetch function -+ */ -+ public ChunkAccess getChunk(BlockPos pos) { -+ // Skip checking chunk.getStatus().isAtLeast(ChunkStatus.EMPTY) here, because it is always true -+ return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())); - } -+ // Gale end - Lithium - optimize world generation chunk and block access - - @Nullable - @Override -@@ -220,7 +249,17 @@ public class WorldGenRegion implements WorldGenLevel { - - @Override - public BlockState getBlockState(BlockPos pos) { -- return this.getChunk(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())).getBlockState(pos); -+ // Gale start - Lithium - optimize world generation chunk and block access - avoid pointer de-referencing, make method easier to inline -+ int x = SectionPos.blockToSectionCoord(pos.getX()) - this.minChunkX; -+ int z = SectionPos.blockToSectionCoord(pos.getZ()) - this.minChunkZ; -+ int w = this.size; -+ -+ if (x >= 0 && z >= 0 && x < w && z < w) { -+ return this.chunksArr[x + z * w].getBlockState(pos); -+ } else { -+ throw new NullPointerException("No chunk exists at " + new ChunkPos(pos)); -+ } -+ // Gale end - Lithium - optimize world generation chunk and block access - avoid pointer de-referencing, make method easier to inline - } - - @Override diff --git a/patches/server/0058-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch b/patches/server/0049-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch similarity index 82% rename from patches/server/0058-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch rename to patches/server/0049-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch index f23032f..60a93f9 100644 --- a/patches/server/0058-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch +++ b/patches/server/0049-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch @@ -1,9 +1,21 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Sat, 27 Apr 2024 12:36:55 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 14:41:52 +0800 Subject: [PATCH] KioCG Chunk API and display of chunkhot in tpsbar +diff --git a/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystem.java b/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystem.java +index f1cb1ecedf0e183cbf6acf12e2034907a8aa9cdd..43f55231adf4a6b11574bde1ba4dcd2b667611b2 100644 +--- a/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystem.java ++++ b/src/main/java/ca/spottedleaf/moonrise/common/util/ChunkSystem.java +@@ -119,6 +119,7 @@ public final class ChunkSystem { + } + + public static void onChunkNotTicking(final LevelChunk chunk, final ChunkHolder holder) { ++ chunk.getChunkHot().clear(); // KioCG + ((ChunkSystemServerLevel)((ServerLevel)chunk.getLevel())).moonrise$getTickingChunks().remove( + ((ChunkSystemLevelChunk)chunk).moonrise$getChunkAndHolder() + ); diff --git a/src/main/java/com/kiocg/ChunkHot.java b/src/main/java/com/kiocg/ChunkHot.java new file mode 100644 index 0000000000000000000000000000000000000000..53b4397997bc9b9b9d88e48304b37a2590161906 @@ -120,7 +132,7 @@ index aafb2f5052c7c8e5971a47308253badb3027093c..9fe7ac7ba83bbcc9a2a851a5cace4764 public static int updateInterval = 15; diff --git a/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java -index 3f1478dde900d671c4bfa43df80f629519cd602e..7abde30d420ff66026d1dee017c41bc23df22b26 100644 +index e456c54b4ac3906a0a0310bdfba5ef39dc02c4ef..0c6ae960cc1d1a39f625295f649169d3381f3b2d 100644 --- a/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java +++ b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java @@ -139,7 +139,8 @@ public class GlobalServerTpsBar { @@ -167,10 +179,10 @@ index 3f1478dde900d671c4bfa43df80f629519cd602e..7abde30d420ff66026d1dee017c41bc2 if (mspt == -1){ return BossBar.Color.valueOf(TpsBarConfig.tpsColors.get(3)); diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 6ead4f65a07defbb7778365ce92d891528dc67aa..87664187c073685573cb93bf51ba84ef26e6bd8c 100644 +index 05b8f509b119b8166012567f865b99a23ad84ae2..3cb2fe584503b8c605bd3aacdafbb6c33ea17bad 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1697,6 +1697,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop gameEventListenerRegistrySections; private final LevelChunkTicks blockTicks; private final LevelChunkTicks fluidTicks; - public volatile FullChunkStatus chunkStatus = FullChunkStatus.INACCESSIBLE; // Paper - rewrite chunk system + private final com.kiocg.ChunkHot chunkHot = new com.kiocg.ChunkHot(); public com.kiocg.ChunkHot getChunkHot() { return this.chunkHot; } // KioCG public LevelChunk(Level world, ChunkPos pos) { this(world, pos, UpgradeData.EMPTY, new LevelChunkTicks<>(), new LevelChunkTicks<>(), 0L, (LevelChunkSection[]) null, (LevelChunk.PostLoadProcessor) null, (BlendingData) null); -@@ -762,6 +763,7 @@ public class LevelChunk extends ChunkAccess { - } - - public void onChunkNotTicking(io.papermc.paper.chunk.system.scheduling.NewChunkHolder chunkHolder) { -+ this.chunkHot.clear(); // KioCG - io.papermc.paper.chunk.system.ChunkSystem.onChunkNotTicking(this, chunkHolder.vanillaChunkHolder); - } - -@@ -1186,6 +1188,7 @@ public class LevelChunk extends ChunkAccess { +@@ -1046,6 +1047,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p gameprofilerfiller.push(this::getType); this.blockEntity.tickTimer.startTiming(); // Spigot @@ -443,7 +447,7 @@ index 5f60010d44f2a3df8645a0e7dafa3f28d882aecf..7592c90fdf35bcaad7ea198f920bcf9e profiler.startTimer(timerId); try { // Folia - profiler BlockState iblockdata = LevelChunk.this.getBlockState(blockposition); -@@ -1216,6 +1219,7 @@ public class LevelChunk extends ChunkAccess { +@@ -1076,6 +1078,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p } finally { this.blockEntity.tickTimer.stopTiming(); // Spigot end @@ -467,10 +471,10 @@ index e679b40b9628b0eb7152978ef641f9c918c4c8b2..bf9ae765242bb61d3e279893b0355d12 } catch (StackOverflowError ex) { world.lastPhysicsProblem = new BlockPos(pos); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java -index 92f1ea81b5e90529905d9c508aca18c31443ff6a..3b972bf05d9ee79f2cdfc9b5a81692c229a5662e 100644 +index 45e262308aebafa377a2353661acdd122933b99e..10b2261169d3cd10d736273fe7703f509fe2dffc 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftChunk.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftChunk.java -@@ -434,4 +434,12 @@ public class CraftChunk implements Chunk { +@@ -436,4 +436,12 @@ public class CraftChunk implements Chunk { static { Arrays.fill(FULL_LIGHT, (byte) 0xFF); } @@ -484,12 +488,12 @@ index 92f1ea81b5e90529905d9c508aca18c31443ff6a..3b972bf05d9ee79f2cdfc9b5a81692c2 + // KioCG end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index a3d4dc232d011c262d85028351191ac2b8547398..a3aca277422d623c6998bbbe5d9574cd1e10f544 100644 +index 572c85579237afa65ffb3409fa3b70c7f86fcb0f..9097f5c05e625bb798cc1dd030f176cdaee1ddde 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -3554,4 +3554,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - public void setSendViewDistance(final int viewDistance) { - this.getHandle().setSendViewDistance(viewDistance); +@@ -3585,4 +3585,11 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + ((ca.spottedleaf.moonrise.patches.chunk_system.player.ChunkSystemServerPlayer)this.getHandle()) + .moonrise$getViewDistanceHolder().setSendViewDistance(viewDistance); } + + // KioCG start - ChunkHot diff --git a/patches/server/0059-Leaf-Skip-event-if-no-listeners.patch b/patches/server/0050-Leaf-Skip-event-if-no-listeners.patch similarity index 97% rename from patches/server/0059-Leaf-Skip-event-if-no-listeners.patch rename to patches/server/0050-Leaf-Skip-event-if-no-listeners.patch index 8551227..f8cef60 100644 --- a/patches/server/0059-Leaf-Skip-event-if-no-listeners.patch +++ b/patches/server/0050-Leaf-Skip-event-if-no-listeners.patch @@ -1,6 +1,6 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MrHua269 -Date: Mon, 29 Jul 2024 20:05:34 +0800 +Date: Wed, 31 Jul 2024 14:48:44 +0800 Subject: [PATCH] Leaf Skip event if no listeners diff --git a/patches/server/0060-Threaded-region-start-tick-and-finished-tick-event.patch b/patches/server/0051-Threaded-region-start-tick-and-finished-tick-event.patch similarity index 82% rename from patches/server/0060-Threaded-region-start-tick-and-finished-tick-event.patch rename to patches/server/0051-Threaded-region-start-tick-and-finished-tick-event.patch index 6096974..ecca02f 100644 --- a/patches/server/0060-Threaded-region-start-tick-and-finished-tick-event.patch +++ b/patches/server/0051-Threaded-region-start-tick-and-finished-tick-event.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Fri, 9 Feb 2024 03:32:05 +0000 +From: MrHua269 +Date: Wed, 31 Jul 2024 14:50:23 +0800 Subject: [PATCH] Threaded region start tick and finished tick event diff --git a/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java b/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java -index 865044d40a95d201765435cbc14b0384980eebf6..ab5f832aafc479eca1c5da012e180d6374e32325 100644 +index c43b263e6502ba48a876803385f8d05c5e84ba3e..9b1a2dd2538652298571c2abc3d9afb144fddd95 100644 --- a/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java +++ b/src/main/java/io/papermc/paper/threadedregions/TickRegionScheduler.java -@@ -389,7 +389,7 @@ public final class TickRegionScheduler { +@@ -394,7 +394,7 @@ public final class TickRegionScheduler { final long scheduledStart = this.getScheduledStart(); final long scheduledEnd = scheduledStart + TIME_BETWEEN_TICKS; @@ -17,7 +17,7 @@ index 865044d40a95d201765435cbc14b0384980eebf6..ab5f832aafc479eca1c5da012e180d63 synchronized (this) { this.currentTickData = new TickTime( lastTickStart, scheduledStart, tickStart, cpuStart, -@@ -424,6 +424,7 @@ public final class TickRegionScheduler { +@@ -429,6 +429,7 @@ public final class TickRegionScheduler { ); this.addTickTime(time); diff --git a/patches/server/0061-Fix-MC-2025.patch b/patches/server/0052-Fix-MC-2025.patch similarity index 86% rename from patches/server/0061-Fix-MC-2025.patch rename to patches/server/0052-Fix-MC-2025.patch index 7821042..7458ca5 100644 --- a/patches/server/0061-Fix-MC-2025.patch +++ b/patches/server/0052-Fix-MC-2025.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: HaHaWTH -Date: Fri, 15 Mar 2024 03:32:46 +0800 +From: MrHua269 +Date: Wed, 31 Jul 2024 14:51:16 +0800 Subject: [PATCH] Fix-MC-2025 diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 3baaf0eb1ab26ec269161f9c5f35bfc743e9d98e..56216f11320c1c12aa3f850d3764dbfd89d333e1 100644 +index 1fbdcfe496efc6615e5246a24c699de2d6e864bf..7e788ca8367d9c66bc916ab189037482975125fe 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2607,6 +2607,16 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -2623,6 +2623,16 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess nbttagcompound.putBoolean("Paper.FreezeLock", true); } // Paper end @@ -25,7 +25,7 @@ index 3baaf0eb1ab26ec269161f9c5f35bfc743e9d98e..56216f11320c1c12aa3f850d3764dbfd return nbttagcompound; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); -@@ -2684,6 +2694,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess +@@ -2700,6 +2710,13 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess this.reapplyPosition(); } diff --git a/patches/server/0062-FoliaPR-Add-TPS-From-Region.patch b/patches/server/0053-FoliaPR-Add-TPS-From-Region.patch similarity index 92% rename from patches/server/0062-FoliaPR-Add-TPS-From-Region.patch rename to patches/server/0053-FoliaPR-Add-TPS-From-Region.patch index 788377c..1ca066a 100644 --- a/patches/server/0062-FoliaPR-Add-TPS-From-Region.patch +++ b/patches/server/0053-FoliaPR-Add-TPS-From-Region.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: MrHua269 -Date: Tue, 30 Jul 2024 17:58:22 +0800 +Date: Wed, 31 Jul 2024 14:51:31 +0800 Subject: [PATCH] FoliaPR Add TPS From Region diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index af077ce30c01c5d1870b99617b339393f8907d36..6332d5713d1ac3e86d4922633f38d6db1a0f6406 100644 +index 60b10a6e1fcc06430c5cacd4c49d92e1de6e4778..956207ae37269884ba2852123c6503fcc2e0b9ba 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -3133,6 +3133,42 @@ public final class CraftServer implements Server { +@@ -3071,6 +3071,42 @@ public final class CraftServer implements Server { }; } diff --git a/patches/server/0056-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch b/patches/server/0056-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch deleted file mode 100644 index 94bf0c5..0000000 --- a/patches/server/0056-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MrHua269 -Date: Mon, 29 Jul 2024 20:12:08 +0800 -Subject: [PATCH] SparklyPaper Skip "distanceToSqr" call in - "ServerEntity#sendChanges" if the delta movement hasn't changed - - -diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index a2279262c93408c11f5d2290b48fd794975e8cfe..17cf318b89b8ecc12331714defa23c6dcf0305b4 100644 ---- a/src/main/java/net/minecraft/server/level/ServerEntity.java -+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -215,12 +215,14 @@ public class ServerEntity { - - if ((this.trackDelta || this.entity.hasImpulse || this.entity instanceof LivingEntity && ((LivingEntity) this.entity).isFallFlying()) && this.tickCount > 0) { - Vec3 vec3d1 = this.entity.getDeltaMovement(); -+ if (vec3d1 != this.ap) { // SparklyPaper start - skip distanceToSqr call in ServerEntity#sendChanges if the delta movement hasn't changed - double d0 = vec3d1.distanceToSqr(this.ap); - - if (d0 > 1.0E-7D || d0 > 0.0D && vec3d1.lengthSqr() == 0.0D) { - this.ap = vec3d1; - this.broadcast.accept(new ClientboundSetEntityMotionPacket(this.entity.getId(), this.ap)); - } -+ } // SparklyPaper end - } - - if (packet1 != null) {