diff --git a/BACKPORT_COMMITS b/BACKPORT_COMMITS new file mode 100644 index 0000000..d07a5bd --- /dev/null +++ b/BACKPORT_COMMITS @@ -0,0 +1,22 @@ +https://github.com/papermc/paper/.patch + +Make sure author and date are correct + +225c95025bdd6bab445cf109cc7d63637e1bf2e5 "Hotfix double entity removal making entity scheduler retire call" +9bc70e6888c670750547caf0f9d692c011111d26 "Make the cursor limit option apply to banners" (client lag exploit) +9395aa60799f816cebee2fe753ccf9b931de9a1e "Improve performance of mass crafts" (see commit below) +44ee1cd05e5dea4a2537077bff4114e47962bd19 "fix recipe packet limiter" (crash exploit) +8493340be4fa69fa9369719272e5dff1b7a2f455 "Add another slot sanity check" (inventory crash exploit) +f1820dc80a02009980e6466ea5847933861b911a "Fix incorrect border collision detection" +0b952981e6e96157d2cea8322c04c0f69965f2bf "Make worldborder collisions consistent with Vanilla" (fixes players walking through the border with cheats) +086ca616d8bd98dde4e4859d29ce89314494d90c "Fix world border edge collision" +55ffcb1111acb558d470790485d8835768873ba8 "Fix tripwire disarming not working as intended" (string dupe) +ef5fa909321a2837c6923d0a50d34eb939a05a1e "Fix crash relating to bad recipes in furnace-like tile entities" +9367e6e6b37a0ac9a9cb298fbe0b0730ba954c6c "Prevent GameEvents being fired from unloaded chunks" +813d0399f9880c4ee5ccd3e60d9e20b358b70df2 "Make sure the player didn't disconnect when processing commands" (item dupe, ex `/ah sell`) +4f9575eed827007f31ce17da471820fe8bc14573 "Break redstone on top of trap doors early" (crash exploit) +4939f8711884901ddf1c56337f606de71cdae78d (port vex patch) + +port "improve-tag-parser-handling" from 1.20.4 + +remove unused config options diff --git a/build.gradle.kts b/build.gradle.kts index 95730f6..505d234 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,8 +2,8 @@ import io.papermc.paperweight.util.constants.PAPERCLIP_CONFIG plugins { java - id("com.github.johnrengelman.shadow") version "8.1.1" apply false - id("io.papermc.paperweight.patcher") version "1.5.15" + id("com.github.johnrengelman.shadow") version "8.1.0" apply false + id("io.papermc.paperweight.patcher") version "1.5.2" } repositories { @@ -14,9 +14,9 @@ repositories { } dependencies { - remapper("net.fabricmc:tiny-remapper:0.10.1:fat") - decompiler("org.vineflower:vineflower:1.10.1") - paperclip("io.papermc:paperclip:3.0.3") + remapper("net.fabricmc:tiny-remapper:0.8.6:fat") + decompiler("net.minecraftforge:forgeflower:2.0.627.2") + paperclip("io.papermc:paperclip:3.0.2") } subprojects { @@ -57,11 +57,5 @@ paperweight { serverPatchDir = layout.projectDirectory.dir("patches/server") serverOutputDir = layout.projectDirectory.dir("sakura-server") } - patchTasks.register("generatedApi") { - isBareDirectory = true - upstreamDirPath = "paper-api-generator/generated" - patchDir = layout.projectDirectory.dir("patches/generatedApi") - outputDir = layout.projectDirectory.dir("paper-api-generator/generated") - } } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index e98a09f..f72ccbf 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ group=me.samsuik.sakura -version=1.20.4-R0.1-SNAPSHOT +version=1.19.3-R0.1-SNAPSHOT -mcVersion=1.20.4 -paperRef=ba31f4128208e954d6648001724887352f71ece9 +mcVersion=1.19.3 +paperRef=155aa36d89b260ef5841615899299756b5983c0a org.gradle.jvmargs=-Xmx2G diff --git a/patches/api/0001-Customise-Version-Command.patch b/patches/api/0001-Customise-Version-Command.patch index 84e08ca..bab307e 100644 --- a/patches/api/0001-Customise-Version-Command.patch +++ b/patches/api/0001-Customise-Version-Command.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Customise Version Command diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index ca27559cf4aa1c2e44fdca2022e213b1b1c80f4e..958dfcccc79aeeb5d457ee2fd0d5db05d859366a 100644 +index ac9b690fcccb60b587e5345f12f1383afd0a73a1..80d836d561f9de3f4dba660a065edfe1092582d8 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -129,6 +129,20 @@ public final class Bukkit { +@@ -125,6 +125,20 @@ public final class Bukkit { // Paper end } @@ -30,13 +30,13 @@ index ca27559cf4aa1c2e44fdca2022e213b1b1c80f4e..958dfcccc79aeeb5d457ee2fd0d5db05 * Gets the name of this server implementation. * diff --git a/src/main/java/org/bukkit/command/defaults/VersionCommand.java b/src/main/java/org/bukkit/command/defaults/VersionCommand.java -index fd5d9881abfd930bb883120f018f76dc78b62b14..5fdafa08fb8932333cacd1a6ddb701e96f89bec2 100644 +index e40f017f87d6b6b4770501b106c76dc69ec69abb..2b0e110c1531bae49ee634f2c5904c0ce68e89d7 100644 --- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java +++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java -@@ -32,6 +32,11 @@ import net.kyori.adventure.text.event.ClickEvent; - import net.kyori.adventure.text.format.TextDecoration; - import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; - // Paper end - version command 2.0 +@@ -25,6 +25,11 @@ import org.bukkit.plugin.Plugin; + import org.bukkit.plugin.PluginDescriptionFile; + import org.bukkit.util.StringUtil; + import org.jetbrains.annotations.NotNull; +// Sakura start +import net.kyori.adventure.text.event.HoverEvent; +import net.kyori.adventure.text.minimessage.MiniMessage; @@ -44,8 +44,8 @@ index fd5d9881abfd930bb883120f018f76dc78b62b14..5fdafa08fb8932333cacd1a6ddb701e9 +// Sakura end public class VersionCommand extends BukkitCommand { - private VersionFetcher versionFetcher; // Paper - version command 2.0 -@@ -43,6 +48,15 @@ public class VersionCommand extends BukkitCommand { + private VersionFetcher versionFetcher; +@@ -36,6 +41,15 @@ public class VersionCommand extends BukkitCommand { return versionFetcher; } @@ -61,7 +61,7 @@ index fd5d9881abfd930bb883120f018f76dc78b62b14..5fdafa08fb8932333cacd1a6ddb701e9 public VersionCommand(@NotNull String name) { super(name); -@@ -54,12 +68,18 @@ public class VersionCommand extends BukkitCommand { +@@ -47,12 +61,18 @@ public class VersionCommand extends BukkitCommand { @Override public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { @@ -74,8 +74,8 @@ index fd5d9881abfd930bb883120f018f76dc78b62b14..5fdafa08fb8932333cacd1a6ddb701e9 - } else { + // Sakura start + sender.sendMessage(MiniMessage.miniMessage().deserialize(VERSION_MESSAGE, -+ Placeholder.component("commit", Component.text("hover", NamedTextColor.YELLOW) -+ .hoverEvent(HoverEvent.showText(Component.text(Bukkit.getGitInformation())))), ++ Placeholder.component("commit", net.kyori.adventure.text.Component.text("hover", net.kyori.adventure.text.format.NamedTextColor.YELLOW) ++ .hoverEvent(HoverEvent.showText(net.kyori.adventure.text.Component.text(Bukkit.getGitInformation())))), + Placeholder.unparsed("version", Bukkit.getMinecraftVersion()) + )); + } else if (testPermission(sender)) { diff --git a/patches/api/0003-Visibility-API.patch b/patches/api/0003-Visibility-API.patch index b80c3aa..4e32a5e 100644 --- a/patches/api/0003-Visibility-API.patch +++ b/patches/api/0003-Visibility-API.patch @@ -209,12 +209,12 @@ index 0000000000000000000000000000000000000000..3df11f07ce533b8b911ec423be850374 + +} diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index d048ae07cc33fd77d128cc1ebf88b0804969fa3c..af8ec9dca850dc921fd33c393f1b606ce90c21db 100644 +index fd890d0a3a2c92ad821ade7711191bdb0e3e3624..50cda6408fa196e2c3bfdbafe5933d52cbebd915 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java -@@ -56,6 +56,15 @@ import org.jetbrains.annotations.Nullable; +@@ -41,6 +41,15 @@ import org.jetbrains.annotations.Nullable; */ - public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, net.kyori.adventure.bossbar.BossBarViewer, com.destroystokyo.paper.network.NetworkClient { // Paper + public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, com.destroystokyo.paper.network.NetworkClient { // Paper + // Sakura start + /** @@ -227,4 +227,4 @@ index d048ae07cc33fd77d128cc1ebf88b0804969fa3c..af8ec9dca850dc921fd33c393f1b606c + // Paper start @Override - default net.kyori.adventure.identity.@NotNull Identity identity() { + default @NotNull net.kyori.adventure.identity.Identity identity() { diff --git a/patches/api/0005-isPushedByFluid-API.patch b/patches/api/0005-isPushedByFluid-API.patch index 3e18824..f3a37fb 100644 --- a/patches/api/0005-isPushedByFluid-API.patch +++ b/patches/api/0005-isPushedByFluid-API.patch @@ -5,10 +5,10 @@ Subject: [PATCH] isPushedByFluid API diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java -index 1d0fd7ff8449f815a7d980af0b378181ea8bf8d8..e0ef6e5a4664b69a5797afeafac2c6436137cab3 100644 +index 11cf1bb585e2754bda443b776e9fcaf0a6cc289e..730af8a127ab55a22a7fd576156311dfde1f010c 100644 --- a/src/main/java/org/bukkit/entity/Entity.java +++ b/src/main/java/org/bukkit/entity/Entity.java -@@ -111,6 +111,22 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent +@@ -107,6 +107,22 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent */ public boolean isInWater(); diff --git a/patches/api/0006-Falling-Block-Parity-API.patch b/patches/api/0006-Falling-Block-Parity-API.patch index a1f9e3a..13810dd 100644 --- a/patches/api/0006-Falling-Block-Parity-API.patch +++ b/patches/api/0006-Falling-Block-Parity-API.patch @@ -5,13 +5,13 @@ Subject: [PATCH] Falling Block Parity API diff --git a/src/main/java/org/bukkit/entity/FallingBlock.java b/src/main/java/org/bukkit/entity/FallingBlock.java -index 2479453b96a75fda2c307261f84c91034e73000d..a8e3a1c34957b7f7e225dc9932edbd300755be23 100644 +index 1b58e600ff4ecb8c290a9a6429eba08c65f1fc3e..ef6a28bb3882d8801e1a80baee0a1edff2fac48f 100644 --- a/src/main/java/org/bukkit/entity/FallingBlock.java +++ b/src/main/java/org/bukkit/entity/FallingBlock.java -@@ -183,4 +183,19 @@ public interface FallingBlock extends Entity, me.samsuik.sakura.entity.merge.Mer +@@ -84,4 +84,19 @@ public interface FallingBlock extends Entity, me.samsuik.sakura.entity.merge.Mer */ void shouldAutoExpire(boolean autoExpires); - // Paper end - Auto expire setting + // Paper End - Auto expire setting + // Sakura start + /** + * Gets if falling block has height parity diff --git a/patches/api/0007-Local-Value-Storage-API.patch b/patches/api/0007-Local-Value-Storage-API.patch index c4367ed..288a312 100644 --- a/patches/api/0007-Local-Value-Storage-API.patch +++ b/patches/api/0007-Local-Value-Storage-API.patch @@ -155,10 +155,10 @@ index 0000000000000000000000000000000000000000..de18836d1a2a6038a661cdc60161d3ba + } +} diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java -index e6f66d70d024cf4f0536a5bf8e51bf7b306335df..d554b1f54e706500153718527a6b60c7743901ea 100644 +index aa04d7df70d99402c91e920fd693d7d4fb655786..44d40c0fcb420199ec6e2c8a4cca3b2887f440ed 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -157,6 +157,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient +@@ -128,6 +128,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient return new Location(this, x, y, z); } // Paper end @@ -168,4 +168,4 @@ index e6f66d70d024cf4f0536a5bf8e51bf7b306335df..d554b1f54e706500153718527a6b60c7 + // Sakura end /** - * Gets the highest non-empty (impassable) block at the given coordinates. + * Gets the highest non-empty (impassable) coordinate at the given diff --git a/patches/api/0008-Add-physics-version-API.patch b/patches/api/0008-Add-physics-version-API.patch index 06fb044..39401df 100644 --- a/patches/api/0008-Add-physics-version-API.patch +++ b/patches/api/0008-Add-physics-version-API.patch @@ -27,10 +27,10 @@ index ee3057c7969956b9c552ac5ceb2f5e38a30e9cdf..58f220a3f48a8cc1a25249d4a56cf356 public boolean equals(Object o) { diff --git a/src/main/java/me/samsuik/sakura/physics/PhysicsVersion.java b/src/main/java/me/samsuik/sakura/physics/PhysicsVersion.java new file mode 100644 -index 0000000000000000000000000000000000000000..b27a757b6d3d43df589947fa65857011da920529 +index 0000000000000000000000000000000000000000..227306a2f37756d646e619f572be9fc24bc925b3 --- /dev/null +++ b/src/main/java/me/samsuik/sakura/physics/PhysicsVersion.java -@@ -0,0 +1,94 @@ +@@ -0,0 +1,93 @@ +package me.samsuik.sakura.physics; + +public enum PhysicsVersion { @@ -49,7 +49,6 @@ index 0000000000000000000000000000000000000000..b27a757b6d3d43df589947fa65857011 + v1_17("1.17", 1_17_0), + v1_18_2("1.18.2", 1_18_2), + v1_19_3("1.19.3", 1_19_3), -+ v1_20("1.20", 1_20_0), + // refers to the latest mechanic version + LATEST("latest", 9_99_9); + diff --git a/patches/api/0013-Entity-tracking-range-modifier.patch b/patches/api/0013-Entity-tracking-range-modifier.patch index eed0754..bdb7da2 100644 --- a/patches/api/0013-Entity-tracking-range-modifier.patch +++ b/patches/api/0013-Entity-tracking-range-modifier.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Entity tracking range modifier diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index af8ec9dca850dc921fd33c393f1b606ce90c21db..3c6d5d5a52b441abd88f577c293beb3cc9f9581e 100644 +index 50cda6408fa196e2c3bfdbafe5933d52cbebd915..9075337807b54047b499f9979b03872aa9fa46e5 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java -@@ -65,6 +65,12 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM +@@ -50,6 +50,12 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM me.samsuik.sakura.player.visibility.Visibility getVisibility(); // Sakura end @@ -20,4 +20,4 @@ index af8ec9dca850dc921fd33c393f1b606ce90c21db..3c6d5d5a52b441abd88f577c293beb3c + // Paper start @Override - default net.kyori.adventure.identity.@NotNull Identity identity() { + default @NotNull net.kyori.adventure.identity.Identity identity() { diff --git a/patches/server/0001-Branding-changes.patch b/patches/server/0001-Branding-changes.patch index 5dac94e..eb6df9a 100644 --- a/patches/server/0001-Branding-changes.patch +++ b/patches/server/0001-Branding-changes.patch @@ -6,11 +6,11 @@ Subject: [PATCH] Branding changes From ForkPaper. diff --git a/build.gradle.kts b/build.gradle.kts -index bcfe59b6efb628ee1e7f9d60667360d4d885fb6a..08745682d6543ce8f06f5a9f94016e2f04b89177 100644 +index 1919a8e9cb7c995b2a9c876ff4980bdc98977133..8e9b3ebe3b074c4991cd543446fa2d9aafa83251 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -13,8 +13,12 @@ configurations.named(log4jPlugins.compileClasspathConfigurationName) { - val alsoShade: Configuration by configurations.creating +@@ -7,8 +7,12 @@ plugins { + } dependencies { - implementation(project(":paper-api")) @@ -24,7 +24,7 @@ index bcfe59b6efb628ee1e7f9d60667360d4d885fb6a..08745682d6543ce8f06f5a9f94016e2f // Paper start implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") -@@ -71,7 +75,7 @@ tasks.jar { +@@ -62,7 +66,7 @@ tasks.jar { attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", "Implementation-Title" to "CraftBukkit", @@ -34,23 +34,23 @@ index bcfe59b6efb628ee1e7f9d60667360d4d885fb6a..08745682d6543ce8f06f5a9f94016e2f "Specification-Title" to "Bukkit", "Specification-Version" to project.version, diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 2dc07e5ef249636e85ad9c78e3729e9e066a8fe8..e4ef4306d93cb81868468b78b98fc4c6b7633103 100644 +index 753a917d34a1e1c1521a8916bc8e44a6acd90a46..777b012f7b3b35b89177d94f2c1d8dd1ee4adf7d 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1865,7 +1865,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop // Spigot - Spigot > // CraftBukkit - cb > vanilla! ++ return "Sakura"; // Sakura - Sakura > // Paper - Paper > // Spigot - Spigot > // CraftBukkit - cb > vanilla! } public SystemReport fillSystemReport(SystemReport details) { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index c490a29bcf7410bc54959ee71375605964379ed5..af2c7758373ca3ecd53ca185f6730c284e964b26 100644 +index bbb8335dae0a3e2761e6bbb8dc723bcf28cd82ba..f3c1e3a6951a17b42bff6a32a9b2fe29edfaf81c 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -266,7 +266,7 @@ import javax.annotation.Nullable; // Paper +@@ -261,7 +261,7 @@ import javax.annotation.Nullable; // Paper import javax.annotation.Nonnull; // Paper public final class CraftServer implements Server { diff --git a/patches/server/0002-Decompile-fixes.patch b/patches/server/0002-Decompile-fixes.patch new file mode 100644 index 0000000..3b7168d --- /dev/null +++ b/patches/server/0002-Decompile-fixes.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik +Date: Sun, 1 Dec 2024 17:00:34 +0000 +Subject: [PATCH] Decompile fixes + + +diff --git a/src/main/java/net/minecraft/world/level/block/Blocks.java b/src/main/java/net/minecraft/world/level/block/Blocks.java +index 42f46d338886e2892ee4219d19be4dc97f61616f..8bcc52021a51e5b020b4a544e6b8b0b326783729 100644 +--- a/src/main/java/net/minecraft/world/level/block/Blocks.java ++++ b/src/main/java/net/minecraft/world/level/block/Blocks.java +@@ -1127,7 +1127,7 @@ public class Blocks { + } + + private static Boolean ocelotOrParrot(BlockState state, BlockGetter world, BlockPos pos, EntityType type) { +- return (boolean)type == EntityType.OCELOT || type == EntityType.PARROT; ++ return type == EntityType.OCELOT || type == EntityType.PARROT; // Sakura - decompile fix + } + + private static BedBlock bed(DyeColor color) { diff --git a/patches/server/0002-Sakura-Utils.patch b/patches/server/0003-Sakura-Utils.patch similarity index 100% rename from patches/server/0002-Sakura-Utils.patch rename to patches/server/0003-Sakura-Utils.patch diff --git a/patches/server/0003-Sakura-Configuration-Files.patch b/patches/server/0004-Sakura-Configuration-Files.patch similarity index 67% rename from patches/server/0003-Sakura-Configuration-Files.patch rename to patches/server/0004-Sakura-Configuration-Files.patch index ba0b60f..10ec9da 100644 --- a/patches/server/0003-Sakura-Configuration-Files.patch +++ b/patches/server/0004-Sakura-Configuration-Files.patch @@ -4,11 +4,23 @@ Date: Sun, 5 Sep 2021 18:01:34 +0100 Subject: [PATCH] Sakura Configuration Files +diff --git a/src/main/java/io/papermc/paper/configuration/ConfigurationPart.java b/src/main/java/io/papermc/paper/configuration/ConfigurationPart.java +index 7a4a7a654fe2516ed894a68f2657344df9d70f4c..dae98d95597f303020c3404d5bf4d983cb20b603 100644 +--- a/src/main/java/io/papermc/paper/configuration/ConfigurationPart.java ++++ b/src/main/java/io/papermc/paper/configuration/ConfigurationPart.java +@@ -1,6 +1,6 @@ + package io.papermc.paper.configuration; + +-abstract class ConfigurationPart { ++public abstract class ConfigurationPart { // Sakura + + public static abstract class Post extends ConfigurationPart { + diff --git a/src/main/java/io/papermc/paper/configuration/Configurations.java b/src/main/java/io/papermc/paper/configuration/Configurations.java -index 218bf89fd7583d6db9f64754c4db8fcce5415bdb..df0da18b38f382a452b1e1489a4f2c332f2f1311 100644 +index c2dca89291361d60cbf160cab77749cb0130035a..f3a2b625e26dcc715b5df8c996c1c1412f242b83 100644 --- a/src/main/java/io/papermc/paper/configuration/Configurations.java +++ b/src/main/java/io/papermc/paper/configuration/Configurations.java -@@ -93,7 +93,7 @@ public abstract class Configurations { +@@ -88,7 +88,7 @@ public abstract class Configurations { }; } @@ -17,20 +29,51 @@ index 218bf89fd7583d6db9f64754c4db8fcce5415bdb..df0da18b38f382a452b1e1489a4f2c33 return node -> { ObjectMapper.Factory factory = (ObjectMapper.Factory) Objects.requireNonNull(node.options().serializers().get(type)); ObjectMapper.Mutable mutable = (ObjectMapper.Mutable) factory.get(type); -@@ -227,7 +227,7 @@ public abstract class Configurations { +@@ -206,7 +206,7 @@ public abstract class Configurations { .path(worldConfigFile) .build(); final ConfigurationNode worldNode = worldLoader.load(); - if (newFile) { // set the version field if new file + if (newFile && this instanceof PaperConfigurations) { // Sakura - hack this into working // set the version field if new file - worldNode.node(Configuration.VERSION_FIELD).set(this.worldConfigVersion()); - } else { - this.verifyWorldConfigVersion(contextMap, worldNode); + worldNode.node(Configuration.VERSION_FIELD).set(WorldConfiguration.CURRENT_VERSION); + } + this.applyWorldConfigTransformations(contextMap, worldNode); +diff --git a/src/main/java/io/papermc/paper/configuration/InnerClassFieldDiscoverer.java b/src/main/java/io/papermc/paper/configuration/InnerClassFieldDiscoverer.java +index a0aa1f1a7adf986d500a2135aa42e138aa3c4f08..c9a351d02b0b5f5a9856fde433c1d64ece46cdee 100644 +--- a/src/main/java/io/papermc/paper/configuration/InnerClassFieldDiscoverer.java ++++ b/src/main/java/io/papermc/paper/configuration/InnerClassFieldDiscoverer.java +@@ -17,7 +17,7 @@ import java.util.Map; + + import static io.leangen.geantyref.GenericTypeReflector.erase; + +-final class InnerClassFieldDiscoverer implements FieldDiscoverer> { ++public final class InnerClassFieldDiscoverer implements FieldDiscoverer> { // Sakura + + private final Map, Object> instanceMap = new HashMap<>(); + private final Map, Object> overrides; +@@ -55,7 +55,7 @@ final class InnerClassFieldDiscoverer implements FieldDiscoverer, Object> overrides) { ++ public InnerClassFieldDiscoverer(Map, Object> overrides) { // Sakura + this.overrides = overrides; + } + +@@ -136,7 +136,7 @@ final class InnerClassFieldDiscoverer implements FieldDiscoverer globalConfig() { ++ public static FieldDiscoverer globalConfig() { // Sakura + return new InnerClassFieldDiscoverer(Collections.emptyMap()); + } + } diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -index fa1c0aee8c3a4d0868482cf5c703bbfd08e09874..9ea2e60095526e63a1f4a0087cfd59067bb92c7e 100644 +index 9fde9ccb5d069ddce8dd837ef1bc68b93ce66434..0cdde29feeb5a308ded845280b6137a7a9671057 100644 --- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -@@ -457,7 +457,7 @@ public class PaperConfigurations extends Configurations> { -+public final class InnerClassInstanceFactory implements FieldDiscoverer.MutableInstanceFactory> { // Sakura - - private final InnerClassInstanceSupplier instanceSupplier; - private final FieldDiscoverer.MutableInstanceFactory> fallback; - private final AnnotatedType targetType; - -- InnerClassInstanceFactory(final InnerClassInstanceSupplier instanceSupplier, final FieldDiscoverer.MutableInstanceFactory> fallback, final AnnotatedType targetType) { -+ public InnerClassInstanceFactory(final InnerClassInstanceSupplier instanceSupplier, final FieldDiscoverer.MutableInstanceFactory> fallback, final AnnotatedType targetType) { // Sakura - this.instanceSupplier = instanceSupplier; - this.fallback = fallback; - this.targetType = targetType; -diff --git a/src/main/java/io/papermc/paper/configuration/mapping/InnerClassInstanceSupplier.java b/src/main/java/io/papermc/paper/configuration/mapping/InnerClassInstanceSupplier.java -index 8d8bc050441c02cf65dfcb6400978363d6b8ef10..5872095a811452037cc0772ba2a31bf9a795cc82 100644 ---- a/src/main/java/io/papermc/paper/configuration/mapping/InnerClassInstanceSupplier.java -+++ b/src/main/java/io/papermc/paper/configuration/mapping/InnerClassInstanceSupplier.java -@@ -19,7 +19,7 @@ import static io.leangen.geantyref.GenericTypeReflector.erase; - * {@link ConfigurationPart}. Only 1 instance of each {@link ConfigurationPart} should be present for each instance - * of the field discoverer this is used in. - */ --final class InnerClassInstanceSupplier implements CheckedFunction, SerializationException> { -+public final class InnerClassInstanceSupplier implements CheckedFunction, SerializationException> { // Sakua - :< - - private final Map, Object> instanceMap = new HashMap<>(); - private final Map, Object> initialOverrides; -@@ -27,7 +27,7 @@ final class InnerClassInstanceSupplier implements CheckedFunction, Object> initialOverrides) { -+ public InnerClassInstanceSupplier(final Map, Object> initialOverrides) { // Sakura - this.initialOverrides = initialOverrides; - } - diff --git a/src/main/java/me/samsuik/sakura/command/BaseSubCommand.java b/src/main/java/me/samsuik/sakura/command/BaseSubCommand.java new file mode 100644 index 0000000000000000000000000000000000000000..9b5af05f7a4593eb44f36fff90d94e98d6999c7f @@ -388,17 +389,16 @@ index 0000000000000000000000000000000000000000..5296d4e0a1041932e36562f42fbf3e1d +} diff --git a/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java b/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java new file mode 100644 -index 0000000000000000000000000000000000000000..dd5a70f70c2e7bdc30b8f5655b0b7a082c1b472b +index 0000000000000000000000000000000000000000..aa5ff55fa619be429d23841dbf268f11e50a3346 --- /dev/null +++ b/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java -@@ -0,0 +1,253 @@ +@@ -0,0 +1,229 @@ +package me.samsuik.sakura.configuration; + +import com.google.common.collect.Table; +import com.mojang.logging.LogUtils; +import io.leangen.geantyref.TypeToken; +import io.papermc.paper.configuration.*; -+import io.papermc.paper.configuration.mapping.InnerClassFieldDiscoverer; +import io.papermc.paper.configuration.serializer.*; +import io.papermc.paper.configuration.serializer.collections.FastutilMapSerializer; +import io.papermc.paper.configuration.serializer.collections.MapSerializer; @@ -407,23 +407,18 @@ index 0000000000000000000000000000000000000000..dd5a70f70c2e7bdc30b8f5655b0b7a08 +import io.papermc.paper.configuration.serializer.registry.RegistryValueSerializer; +import io.papermc.paper.configuration.transformation.Transformations; +import io.papermc.paper.configuration.type.BooleanOrDefault; -+import io.papermc.paper.configuration.type.Duration; -+import io.papermc.paper.configuration.type.DurationOrDisabled; -+import io.papermc.paper.configuration.type.number.DoubleOr; -+import io.papermc.paper.configuration.type.number.IntOr; ++import io.papermc.paper.configuration.type.DoubleOrDefault; ++import io.papermc.paper.configuration.type.IntOr; +import it.unimi.dsi.fastutil.objects.Reference2IntMap; +import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; +import it.unimi.dsi.fastutil.objects.Reference2LongMap; +import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap; -+import me.samsuik.sakura.configuration.transformation.world.*; -+import net.minecraft.core.RegistryAccess; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.item.Item; -+import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; +import org.slf4j.Logger; +import org.spongepowered.configurate.ConfigurateException; @@ -521,8 +516,8 @@ index 0000000000000000000000000000000000000000..dd5a70f70c2e7bdc30b8f5655b0b7a08 + } + + @Override -+ public GlobalConfiguration initializeGlobalConfiguration(final RegistryAccess registryAccess) throws ConfigurateException { -+ GlobalConfiguration configuration = super.initializeGlobalConfiguration(registryAccess); ++ public GlobalConfiguration initializeGlobalConfiguration() throws ConfigurateException { ++ GlobalConfiguration configuration = super.initializeGlobalConfiguration(); + GlobalConfiguration.set(configuration); + return configuration; + } @@ -549,7 +544,6 @@ index 0000000000000000000000000000000000000000..dd5a70f70c2e7bdc30b8f5655b0b7a08 + + @Override + protected YamlConfigurationLoader.Builder createWorldConfigLoaderBuilder(final ContextMap contextMap) { -+ final RegistryAccess access = contextMap.require(REGISTRY_ACCESS); + return super.createWorldConfigLoaderBuilder(contextMap) + .defaultOptions(options -> options + .header(contextMap.require(WORLD_NAME).equals(WORLD_DEFAULTS) ? WORLD_DEFAULTS_HEADER : WORLD_HEADER.apply(contextMap)) @@ -560,15 +554,13 @@ index 0000000000000000000000000000000000000000..dd5a70f70c2e7bdc30b8f5655b0b7a08 + .register(StringRepresentableSerializer::isValidFor, new StringRepresentableSerializer()) + .register(IntOr.Default.SERIALIZER) + .register(IntOr.Disabled.SERIALIZER) -+ .register(DoubleOr.Default.SERIALIZER) ++ .register(DoubleOrDefault.SERIALIZER) + .register(BooleanOrDefault.SERIALIZER) -+ .register(Duration.SERIALIZER) -+ .register(DurationOrDisabled.SERIALIZER) + .register(NbtPathSerializer.SERIALIZER) -+ .register(new RegistryValueSerializer<>(new TypeToken>() {}, access, Registries.ENTITY_TYPE, true)) -+ .register(new RegistryValueSerializer<>(Item.class, access, Registries.ITEM, true)) -+ .register(new RegistryValueSerializer<>(Block.class, access, Registries.BLOCK, true)) -+ .register(new RegistryHolderSerializer<>(new TypeToken>() {}, access, Registries.CONFIGURED_FEATURE, false)) ++ .register(new RegistryValueSerializer<>(new TypeToken>() {}, Registries.ENTITY_TYPE, true)) ++ .register(new RegistryValueSerializer<>(Item.class, Registries.ITEM, true)) ++ .register(new RegistryHolderSerializer<>(new TypeToken>() {}, Registries.CONFIGURED_FEATURE, false)) ++ .register(new RegistryHolderSerializer<>(Item.class, Registries.ITEM, true)) + ) + ); + } @@ -576,11 +568,7 @@ index 0000000000000000000000000000000000000000..dd5a70f70c2e7bdc30b8f5655b0b7a08 + @Override + protected void applyWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode node) throws ConfigurateException { + final ConfigurationTransformation.VersionedBuilder versionedBuilder = Transformations.versionedBuilder(); -+ V2_VerticalKnockbackUseDefault.apply(versionedBuilder); -+ V3_RenameKnockback.apply(versionedBuilder); -+ V4_RenameNonStrictMergeLevel.apply(versionedBuilder); -+ V5_CombineLoadChunksOptions.apply(versionedBuilder); -+ V6_FixIncorrectExtraKnockback.apply(versionedBuilder); ++ + // ADD FUTURE VERSIONED TRANSFORMS TO versionedBuilder HERE + versionedBuilder.build().apply(node); + } @@ -600,20 +588,10 @@ index 0000000000000000000000000000000000000000..dd5a70f70c2e7bdc30b8f5655b0b7a08 + return ConfigurationPart.class.isAssignableFrom(erase(type)); + } + -+ @Override -+ protected int globalConfigVersion() { -+ return GlobalConfiguration.CURRENT_VERSION; -+ } -+ -+ @Override -+ protected int worldConfigVersion() { -+ return WorldConfiguration.CURRENT_VERSION; -+ } -+ + public void reloadConfigs(MinecraftServer server) { + try { + this.initializeGlobalConfiguration(reloader(this.globalConfigClass, GlobalConfiguration.get())); -+ this.initializeWorldDefaultsConfiguration(server.registryAccess()); ++ this.initializeWorldDefaultsConfiguration(); + for (ServerLevel level : server.getAllLevels()) { + this.createWorldConfig(createWorldContextMap(level), reloader(this.worldConfigClass, level.sakuraConfig())); + } @@ -623,15 +601,14 @@ index 0000000000000000000000000000000000000000..dd5a70f70c2e7bdc30b8f5655b0b7a08 + } + + private static ContextMap createWorldContextMap(ServerLevel level) { -+ return createWorldContextMap(level.convertable.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().location(), level.registryAccess()); ++ return createWorldContextMap(level.convertable.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().location()); + } + -+ public static ContextMap createWorldContextMap(Path dir, String levelName, ResourceLocation worldKey, RegistryAccess registryAccess) { ++ public static ContextMap createWorldContextMap(Path dir, String levelName, ResourceLocation worldKey) { + return ContextMap.builder() + .put(WORLD_DIRECTORY, dir) + .put(WORLD_NAME, levelName) + .put(WORLD_KEY, worldKey) -+ .put(REGISTRY_ACCESS, registryAccess) + .build(); + } + @@ -647,7 +624,7 @@ index 0000000000000000000000000000000000000000..dd5a70f70c2e7bdc30b8f5655b0b7a08 +} diff --git a/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java new file mode 100644 -index 0000000000000000000000000000000000000000..b2ae26cb6cac23c8da52106c398fab1c954020b4 +index 0000000000000000000000000000000000000000..907c2e62848c395d61c3ea94df458e2be72b9f1b --- /dev/null +++ b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java @@ -0,0 +1,237 @@ @@ -658,8 +635,8 @@ index 0000000000000000000000000000000000000000..b2ae26cb6cac23c8da52106c398fab1c +import io.papermc.paper.configuration.ConfigurationPart; +import io.papermc.paper.configuration.NestedSetting; +import io.papermc.paper.configuration.PaperConfigurations; -+import io.papermc.paper.configuration.type.number.DoubleOr; -+import io.papermc.paper.configuration.type.number.IntOr; ++import io.papermc.paper.configuration.type.DoubleOrDefault; ++import io.papermc.paper.configuration.type.IntOr; +import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap; +import me.samsuik.sakura.entity.merge.MergeLevel; +import me.samsuik.sakura.explosion.durable.DurableMaterial; @@ -734,8 +711,8 @@ index 0000000000000000000000000000000000000000..b2ae26cb6cac23c8da52106c398fab1c + public boolean preventAtWorldHeight = false; + + public boolean isFallingBlockInBounds(FallingBlockEntity entity) { -+ return (!preventAgainstBorder || !io.papermc.paper.util.CollisionUtil.isCollidingWithBorder(entity.level().getWorldBorder(), entity.getBoundingBox().inflate(0.01))) -+ && (!preventAtWorldHeight || entity.blockPosition().getY() < entity.level().getMaxBuildHeight() - 1); ++ return (!preventAgainstBorder || !io.papermc.paper.util.CollisionUtil.isCollidingWithBorderEdge(entity.level.getWorldBorder(), entity.getBoundingBox().inflate(0.01))) ++ && (!preventAtWorldHeight || entity.blockPosition().getY() < entity.level.getMaxBuildHeight() - 1); + } + } + @@ -798,7 +775,7 @@ index 0000000000000000000000000000000000000000..b2ae26cb6cac23c8da52106c398fab1c + + public Knockback knockback = new Knockback(); + public class Knockback extends ConfigurationPart { -+ public DoubleOr.Default knockbackVertical = DoubleOr.Default.USE_DEFAULT; ++ public DoubleOrDefault knockbackVertical = DoubleOrDefault.USE_DEFAULT; + public double knockbackVerticalLimit = 0.4; + public boolean verticalKnockbackRequireGround = true; + public double baseKnockback = 0.4; @@ -888,203 +865,6 @@ index 0000000000000000000000000000000000000000..b2ae26cb6cac23c8da52106c398fab1c + } + +} -diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/world/V2_VerticalKnockbackUseDefault.java b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V2_VerticalKnockbackUseDefault.java -new file mode 100644 -index 0000000000000000000000000000000000000000..97d5224ef110cb2fa4f44a90a54a1611dc0182d9 ---- /dev/null -+++ b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V2_VerticalKnockbackUseDefault.java -@@ -0,0 +1,31 @@ -+package me.samsuik.sakura.configuration.transformation.world; -+ -+import io.papermc.paper.configuration.type.number.DoubleOr; -+import org.checkerframework.checker.nullness.qual.Nullable; -+import org.spongepowered.configurate.ConfigurateException; -+import org.spongepowered.configurate.ConfigurationNode; -+import org.spongepowered.configurate.NodePath; -+import org.spongepowered.configurate.transformation.ConfigurationTransformation; -+import org.spongepowered.configurate.transformation.TransformAction; -+ -+import static org.spongepowered.configurate.NodePath.path; -+ -+public final class V2_VerticalKnockbackUseDefault implements TransformAction { -+ private static final int VERSION = 2; -+ private static final NodePath PATH = path("players", "knockback", "knockback-vertical"); -+ private static final V2_VerticalKnockbackUseDefault INSTANCE = new V2_VerticalKnockbackUseDefault(); -+ -+ private V2_VerticalKnockbackUseDefault() {} -+ -+ public static void apply(ConfigurationTransformation.VersionedBuilder builder) { -+ builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build()); -+ } -+ -+ @Override -+ public Object @Nullable [] visitPath(NodePath path, ConfigurationNode value) throws ConfigurateException { -+ if (value.getDouble() == 0.4) { -+ value.set(DoubleOr.Default.USE_DEFAULT); -+ } -+ return null; -+ } -+} -diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/world/V3_RenameKnockback.java b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V3_RenameKnockback.java -new file mode 100644 -index 0000000000000000000000000000000000000000..efba1f83cb079d0e75904adc439b715d17793979 ---- /dev/null -+++ b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V3_RenameKnockback.java -@@ -0,0 +1,27 @@ -+package me.samsuik.sakura.configuration.transformation.world; -+ -+import org.spongepowered.configurate.NodePath; -+import org.spongepowered.configurate.transformation.ConfigurationTransformation; -+ -+import java.util.Map; -+ -+import static org.spongepowered.configurate.NodePath.path; -+import static org.spongepowered.configurate.transformation.TransformAction.*; -+ -+public final class V3_RenameKnockback { -+ private static final int VERSION = 3; -+ private static final Map RENAME = Map.of( -+ path("players", "knockback", "vertical-limit-require-ground"), "vertical-knockback-require-ground", -+ path("players", "knockback", "knockback-horizontal"), "base-knockback" -+ ); -+ -+ private V3_RenameKnockback() {} -+ -+ public static void apply(ConfigurationTransformation.VersionedBuilder builder) { -+ ConfigurationTransformation.Builder transformationBuilder = ConfigurationTransformation.builder(); -+ for (Map.Entry entry : RENAME.entrySet()) { -+ transformationBuilder.addAction(entry.getKey(), rename(entry.getValue())); -+ } -+ builder.addVersion(VERSION, transformationBuilder.build()); -+ } -+} -diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/world/V4_RenameNonStrictMergeLevel.java b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V4_RenameNonStrictMergeLevel.java -new file mode 100644 -index 0000000000000000000000000000000000000000..198eb5f030ec5def4d93dec51dde352261654bb5 ---- /dev/null -+++ b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V4_RenameNonStrictMergeLevel.java -@@ -0,0 +1,35 @@ -+package me.samsuik.sakura.configuration.transformation.world; -+ -+import org.checkerframework.checker.nullness.qual.Nullable; -+import org.spongepowered.configurate.ConfigurateException; -+import org.spongepowered.configurate.ConfigurationNode; -+import org.spongepowered.configurate.NodePath; -+import org.spongepowered.configurate.transformation.ConfigurationTransformation; -+import org.spongepowered.configurate.transformation.TransformAction; -+ -+import java.util.Locale; -+ -+import static org.spongepowered.configurate.NodePath.path; -+ -+public final class V4_RenameNonStrictMergeLevel implements TransformAction { -+ private static final int VERSION = 4; -+ private static final String OLD_LEVEL_NAME = "NON_STRICT"; -+ private static final String NEW_LEVEL_NAME = "LENIENT"; -+ private static final NodePath PATH = path("cannons", "merge-level"); -+ private static final V4_RenameNonStrictMergeLevel INSTANCE = new V4_RenameNonStrictMergeLevel(); -+ -+ private V4_RenameNonStrictMergeLevel() {} -+ -+ public static void apply(ConfigurationTransformation.VersionedBuilder builder) { -+ builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build()); -+ } -+ -+ @Override -+ public Object @Nullable [] visitPath(NodePath path, ConfigurationNode value) throws ConfigurateException { -+ String level = value.getString(); -+ if (level != null && OLD_LEVEL_NAME.equals(level.toUpperCase(Locale.ENGLISH))) { -+ value.set(NEW_LEVEL_NAME); -+ } -+ return null; -+ } -+} -diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/world/V5_CombineLoadChunksOptions.java b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V5_CombineLoadChunksOptions.java -new file mode 100644 -index 0000000000000000000000000000000000000000..3d647a3db0862232f158d823da9a797d4e0d5608 ---- /dev/null -+++ b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V5_CombineLoadChunksOptions.java -@@ -0,0 +1,44 @@ -+package me.samsuik.sakura.configuration.transformation.world; -+ -+import org.checkerframework.checker.nullness.qual.Nullable; -+import org.spongepowered.configurate.ConfigurateException; -+import org.spongepowered.configurate.ConfigurationNode; -+import org.spongepowered.configurate.NodePath; -+import org.spongepowered.configurate.transformation.ConfigurationTransformation; -+import org.spongepowered.configurate.transformation.TransformAction; -+ -+import java.util.List; -+ -+import static org.spongepowered.configurate.NodePath.path; -+ -+public final class V5_CombineLoadChunksOptions implements TransformAction { -+ private static final int VERSION = 5; -+ private static final List ENTITY_PATHS = List.of("tnt", "sand"); -+ private static final String OLD_NAME = "loads-chunks"; -+ private static final String NAME = "load-chunks"; -+ private static final NodePath PATH = path("cannons"); -+ private static final V5_CombineLoadChunksOptions INSTANCE = new V5_CombineLoadChunksOptions(); -+ -+ private V5_CombineLoadChunksOptions() {} -+ -+ public static void apply(ConfigurationTransformation.VersionedBuilder builder) { -+ builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build()); -+ } -+ -+ @Override -+ public Object @Nullable [] visitPath(NodePath path, ConfigurationNode value) throws ConfigurateException { -+ boolean shouldLoadChunks = false; -+ -+ for (String entity : ENTITY_PATHS) { -+ NodePath entityPath = NodePath.path(entity, OLD_NAME); -+ if (value.hasChild(entityPath)) { -+ ConfigurationNode node = value.node(entityPath); -+ shouldLoadChunks |= node.getBoolean(); -+ node.raw(null); -+ } -+ } -+ -+ value.node(NAME).set(shouldLoadChunks); -+ return null; -+ } -+} -diff --git a/src/main/java/me/samsuik/sakura/configuration/transformation/world/V6_FixIncorrectExtraKnockback.java b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V6_FixIncorrectExtraKnockback.java -new file mode 100644 -index 0000000000000000000000000000000000000000..f9fdf1a87420c78136deccf8822f5cf177b41aed ---- /dev/null -+++ b/src/main/java/me/samsuik/sakura/configuration/transformation/world/V6_FixIncorrectExtraKnockback.java -@@ -0,0 +1,30 @@ -+package me.samsuik.sakura.configuration.transformation.world; -+ -+import org.checkerframework.checker.nullness.qual.Nullable; -+import org.spongepowered.configurate.ConfigurateException; -+import org.spongepowered.configurate.ConfigurationNode; -+import org.spongepowered.configurate.NodePath; -+import org.spongepowered.configurate.transformation.ConfigurationTransformation; -+import org.spongepowered.configurate.transformation.TransformAction; -+ -+import static org.spongepowered.configurate.NodePath.path; -+ -+public final class V6_FixIncorrectExtraKnockback implements TransformAction { -+ private static final int VERSION = 6; -+ private static final NodePath PATH = path("players", "knockback", "sprinting", "extra-knockback"); -+ private static final V6_FixIncorrectExtraKnockback INSTANCE = new V6_FixIncorrectExtraKnockback(); -+ -+ private V6_FixIncorrectExtraKnockback() {} -+ -+ public static void apply(ConfigurationTransformation.VersionedBuilder builder) { -+ builder.addVersion(VERSION, ConfigurationTransformation.builder().addAction(PATH, INSTANCE).build()); -+ } -+ -+ @Override -+ public Object @Nullable [] visitPath(NodePath path, ConfigurationNode value) throws ConfigurateException { -+ if (value.getDouble() == 1.0) { -+ value.set(0.5); -+ } -+ return null; -+ } -+} diff --git a/src/main/java/me/samsuik/sakura/explosion/durable/DurableMaterial.java b/src/main/java/me/samsuik/sakura/explosion/durable/DurableMaterial.java new file mode 100644 index 0000000000000000000000000000000000000000..4024f9738e039ffffd560a07a2210f758879d3c0 @@ -1099,65 +879,65 @@ index 0000000000000000000000000000000000000000..4024f9738e039ffffd560a07a2210f75 +public record DurableMaterial(int durability, float resistance) { +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index e4ef4306d93cb81868468b78b98fc4c6b7633103..ca9013a7141a4e6b5b45651961dd977929a0756b 100644 +index 777b012f7b3b35b89177d94f2c1d8dd1ee4adf7d..36ebba2b3cab5a7e92cceae1b295db10f5cd7c70 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -306,6 +306,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop resourcekey, LevelStem worlddimension, ChunkProgressListener worldloadlistener, boolean flag, long i, List list, boolean flag1, org.bukkit.World.Environment env, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider) { // Holder holder = worlddimension.type(); // CraftBukkit - decompile error - // Objects.requireNonNull(minecraftserver); // CraftBukkit - decompile error -- super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess())), executor); // Paper - create paper world configs; Async-Anti-Xray: Pass executor -+ super(iworlddataserver, resourcekey, minecraftserver.registryAccess(), worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig, minecraftserver.registryAccess())), () -> minecraftserver.sakuraConfigurations.createWorldConfig(me.samsuik.sakura.configuration.SakuraConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), minecraftserver.registryAccess())), executor); // Sakura // Paper - create paper world configs; Async-Anti-Xray: Pass executor +- super(iworlddataserver, resourcekey, worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig)), executor); // Paper - Async-Anti-Xray - Pass executor ++ super(iworlddataserver, resourcekey, worlddimension.type(), minecraftserver::getProfiler, false, flag, i, minecraftserver.getMaxChainedNeighborUpdates(), gen, biomeProvider, env, spigotConfig -> minecraftserver.paperConfigurations.createWorldConfig(io.papermc.paper.configuration.PaperConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location(), spigotConfig)), () -> minecraftserver.sakuraConfigurations.createWorldConfig(me.samsuik.sakura.configuration.SakuraConfigurations.createWorldContextMap(convertable_conversionsession.levelDirectory.path(), iworlddataserver.getLevelName(), resourcekey.location())), executor); // Sakura // Paper - Async-Anti-Xray - Pass executor this.pvpMode = minecraftserver.isPvpAllowed(); this.convertable = convertable_conversionsession; this.uuid = WorldUUID.getUUID(convertable_conversionsession.levelDirectory.path().toFile()); diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index ca89d1593bf1b46c79a882db528cbca1359dc9d4..a0a68ff09689d457f3c6e17f3e5d6d595f84684a 100644 +index db971ca4136c7f922d630f38aa5c78cb04adbdfa..fa3ed1b2292abafa9f7cc79bc20f7c7beba02224 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -171,6 +171,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { return this.paperConfig; } - // Paper end - add paper world config + // Paper end + // Sakura start + private final me.samsuik.sakura.configuration.WorldConfiguration sakuraConfig; + public final me.samsuik.sakura.configuration.WorldConfiguration sakuraConfig() { @@ -1167,31 +947,31 @@ index ca89d1593bf1b46c79a882db528cbca1359dc9d4..a0a68ff09689d457f3c6e17f3e5d6d59 public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray public final co.aikar.timings.WorldTimingsHandler timings; // Paper -@@ -216,9 +222,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -270,9 +276,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public abstract ResourceKey getTypeKey(); -- protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - create paper world config; Async-Anti-Xray: Pass executor -+ protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, Supplier sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - create paper world config; Async-Anti-Xray: Pass executor +- protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor ++ protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, Supplier sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - Async-Anti-Xray - Pass executor this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot - this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config + this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper + this.sakuraConfig = sakuraWorldConfigCreator.get(); // Sakura this.generator = gen; this.world = new CraftWorld((ServerLevel) this, gen, biomeProvider, env); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index af2c7758373ca3ecd53ca185f6730c284e964b26..870da24cb911f1cad20c79cc1bfbf3dc69ed3b83 100644 +index f3c1e3a6951a17b42bff6a32a9b2fe29edfaf81c..faddb7cefa3a26911c0ab509ead71387bf79a7de 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -1054,6 +1054,7 @@ public final class CraftServer implements Server { +@@ -961,6 +961,7 @@ public final class CraftServer implements Server { - org.spigotmc.SpigotConfig.init((File) this.console.options.valueOf("spigot-settings")); // Spigot + org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot this.console.paperConfigurations.reloadConfigs(this.console); + this.console.sakuraConfigurations.reloadConfigs(this.console); // Sakura - missing comment above for (ServerLevel world : this.console.getAllLevels()) { // world.serverLevelData.setDifficulty(config.difficulty); // Paper - per level difficulty world.setSpawnSettings(world.serverLevelData.getDifficulty() != Difficulty.PEACEFUL && config.spawnMonsters, config.spawnAnimals); // Paper - per level difficulty (from MinecraftServer#setDifficulty(ServerLevel, Difficulty, boolean)) -@@ -1084,6 +1085,7 @@ public final class CraftServer implements Server { +@@ -991,6 +992,7 @@ public final class CraftServer implements Server { this.reloadData(); org.spigotmc.SpigotConfig.registerCommands(); // Spigot io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper @@ -1200,10 +980,10 @@ index af2c7758373ca3ecd53ca185f6730c284e964b26..870da24cb911f1cad20c79cc1bfbf3dc this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions"); diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index 8d626fadcd4743b6472a2954d2b1b2ec89669814..7107b54327f76bbd5265898f09e166423fee96e0 100644 +index f30621be24c6c3a4f173436fce1ad1c13507c84f..d24c80dca90ae3b399bec6a23022a8db1e574868 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java -@@ -174,6 +174,14 @@ public class Main { +@@ -166,6 +166,14 @@ public class Main { .describedAs("Jar file"); // Paper end diff --git a/patches/server/0004-Local-Config-and-Value-Storage-API.patch b/patches/server/0005-Local-Config-and-Value-Storage-API.patch similarity index 95% rename from patches/server/0004-Local-Config-and-Value-Storage-API.patch rename to patches/server/0005-Local-Config-and-Value-Storage-API.patch index 2bf1cfb..54891a9 100644 --- a/patches/server/0004-Local-Config-and-Value-Storage-API.patch +++ b/patches/server/0005-Local-Config-and-Value-Storage-API.patch @@ -231,19 +231,19 @@ index 0000000000000000000000000000000000000000..3f518f3f1241d3dc1f76fab42e9fd789 + +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index ca9013a7141a4e6b5b45651961dd977929a0756b..1f169b9bc09052137187654a7331033779694ad4 100644 +index 36ebba2b3cab5a7e92cceae1b295db10f5cd7c70..0e83e4e0fc1123dadca03dc0e3e1011640722c0a 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1743,6 +1743,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop -Date: Tue, 1 Mar 2022 18:40:09 +0000 -Subject: [PATCH] Optimise rayTracing - - -diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 90a82bd7977ebe520bdcc2ab99e11452d5cf4a21..eeacf65ebb0ea7070de6e773d31651e4c190d592 100644 ---- a/src/main/java/net/minecraft/world/level/Explosion.java -+++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -295,7 +295,7 @@ public class Explosion { - } - } - -- if (!collision.isEmpty() && collision.clip(from, to, currPos) != null) { -+ if (!collision.isEmpty() && collision.clipDirect(from, to, currPos)) { // Sakura - optimise block clipping - return true; - } - } -diff --git a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java -index e6b17f32f2b6930739a98c6139442383c1847add..24c1caa060e7c41eac81c19f873ac9273c6b84c2 100644 ---- a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java -+++ b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java -@@ -720,6 +720,110 @@ public abstract class VoxelShape { - // Paper end - optimise collisions - } - -+ // Sakura start -+ // As of 1.20.2 paper has their own version of the pufferfish patch that this patch expanded on. -+ // A bit this patch is now obsolete such as simple AABB clipping. -+ // We will still use our method when a detailed hit result isn't required. -+ public boolean clipDirect(Vec3 start, Vec3 end, BlockPos pos) { -+ if (this.isEmpty) { -+ return false; -+ } -+ -+ double vec3_x = end.x - start.x; -+ double vec3_y = end.y - start.y; -+ double vec3_z = end.z - start.z; -+ double vec3_lengthSqr = (vec3_x * vec3_x) + (vec3_y * vec3_y) + (vec3_z * vec3_z); -+ -+ if (vec3_lengthSqr < 1.0E-7D) { -+ return false; -+ } -+ -+ AABB singleAABB = this.singleAABBRepresentation; -+ //noinspection ConstantValue -+ if (singleAABB != null) { -+ return clipWithBBDirect(singleAABB, vec3_x, vec3_y, vec3_z, start, pos); -+ } -+ -+ return clipWithBBsDirect(vec3_x, vec3_y, vec3_z, start, pos); -+ } -+ -+ protected boolean clipWithBBDirect(AABB single, double deltaX, double deltaY, double deltaZ, Vec3 from, BlockPos pos) { -+ double posX = pos.getX(); -+ double posY = pos.getY(); -+ double posZ = pos.getZ(); -+ -+ return clipPointBB(single, from, posX, posY, posZ, deltaX, deltaY, deltaZ) -+ || clipInsideDirectBB(single, deltaX, deltaY, deltaZ, from, pos); -+ } -+ -+ protected boolean clipWithBBsDirect(double deltaX, double deltaY, double deltaZ, Vec3 from, BlockPos pos) { -+ double posX = pos.getX(); -+ double posY = pos.getY(); -+ double posZ = pos.getZ(); -+ -+ for (AABB bb : toAabbs()) { // err -+ if (clipPointBB(bb, from, posX, posY, posZ, deltaX, deltaY, deltaZ)) { -+ return true; -+ } -+ } -+ -+ return clipInsideDirectBBs(deltaX, deltaY, deltaZ, from, pos); -+ } -+ -+ @SuppressWarnings("SuspiciousNameCombination") -+ protected static boolean clipPointBB(AABB box, Vec3 p, double posX, double posY, double posZ, double deltaX, double deltaY, double deltaZ) { -+ double minX = box.minX + posX; -+ double minY = box.minY + posY; -+ double minZ = box.minZ + posZ; -+ double maxX = box.maxX + posX; -+ double maxY = box.maxY + posY; -+ double maxZ = box.maxZ + posZ; -+ -+ // todo: this could be simplified by using the centre of the bb -+ // if the bb dimensions are not the same then either scale or subtract from the result. -+ double closestX = deltaX > 1.0E-7D ? minX : maxX; -+ double closestY = deltaY > 1.0E-7D ? minY : maxY; -+ double closestZ = deltaZ > 1.0E-7D ? minZ : maxZ; -+ -+ return clipPoint(deltaX, deltaY, deltaZ, closestX, minY, maxY, minZ, maxZ, p.x, p.y, p.z) -+ || clipPoint(deltaY, deltaZ, deltaX, closestY, minZ, maxZ, minX, maxX, p.y, p.z, p.x) -+ || clipPoint(deltaZ, deltaX, deltaY, closestZ, minX, maxX, minY, maxY, p.z, p.x, p.y); -+ } -+ -+ private static boolean clipPoint(double deltaX, double deltaY, double deltaZ, double begin, double minX, double maxX, double minZ, double maxZ, double startX, double startY, double startZ) { -+ double d = (begin - startX) / deltaX; -+ double e = startY + d * deltaY; -+ double f = startZ + d * deltaZ; -+ return (d > 0.0D && d < 1.0) && (minX - 1.0E-7D < e && maxX + 1.0E-7D > e) && (minZ - 1.0E-7D < f && maxZ + 1.0E-7D > f); -+ } -+ -+ // Absolutely horrendous code that takes a toll on all clip misses. -+ // This cannot be removed to maintain edge cases caused by this code existing in vanilla. -+ protected boolean clipInsideDirectBB(AABB single, double vec3_x, double vec3_y, double vec3_z, Vec3 start, BlockPos pos) { -+ double fromBehindX = start.x + (vec3_x * 0.001D); -+ double fromBehindY = start.y + (vec3_y * 0.001D); -+ double fromBehindZ = start.z + (vec3_z * 0.001D); -+ -+ double fromBehindOffsetX = fromBehindX - (double) pos.getX(); -+ double fromBehindOffsetY = fromBehindY - (double) pos.getY(); -+ double fromBehindOffsetZ = fromBehindZ - (double) pos.getZ(); -+ -+ return single.contains(fromBehindOffsetX, fromBehindOffsetY, fromBehindOffsetZ); -+ } -+ -+ protected boolean clipInsideDirectBBs(double vec3_x, double vec3_y, double vec3_z, Vec3 start, BlockPos pos) { -+ double fromBehindX = start.x + (vec3_x * 0.001D); -+ double fromBehindY = start.y + (vec3_y * 0.001D); -+ double fromBehindZ = start.z + (vec3_z * 0.001D); -+ -+ int indexX = this.findIndex(Direction.Axis.X, fromBehindX - (double)pos.getX()); -+ int indexY = this.findIndex(Direction.Axis.Y, fromBehindY - (double)pos.getY()); -+ int indexZ = this.findIndex(Direction.Axis.Z, fromBehindZ - (double)pos.getZ()); -+ -+ return this.shape.isFullWide(indexX, indexY, indexZ); -+ } -+ // Sakura end -+ - public Optional closestPointTo(Vec3 target) { - // Paper start - optimise collisions - if (this.isEmpty) { diff --git a/patches/server/0005-Visibility-API-and-Command.patch b/patches/server/0006-Visibility-API-and-Command.patch similarity index 65% rename from patches/server/0005-Visibility-API-and-Command.patch rename to patches/server/0006-Visibility-API-and-Command.patch index 946c952..37e259e 100644 --- a/patches/server/0005-Visibility-API-and-Command.patch +++ b/patches/server/0006-Visibility-API-and-Command.patch @@ -114,10 +114,10 @@ index 0000000000000000000000000000000000000000..148a583279333eeb3e5db16652623082 +} diff --git a/src/main/java/me/samsuik/sakura/player/visibility/VisibilityGUI.java b/src/main/java/me/samsuik/sakura/player/visibility/VisibilityGUI.java new file mode 100644 -index 0000000000000000000000000000000000000000..6f74429456e78f17fa3e4426d9d9b5f008d8df42 +index 0000000000000000000000000000000000000000..0380753ce7d65a98b9d008f13bc9bc7908c6dc8a --- /dev/null +++ b/src/main/java/me/samsuik/sakura/player/visibility/VisibilityGUI.java -@@ -0,0 +1,123 @@ +@@ -0,0 +1,124 @@ +package me.samsuik.sakura.player.visibility; + +import me.samsuik.sakura.configuration.GlobalConfiguration; @@ -126,6 +126,7 @@ index 0000000000000000000000000000000000000000..6f74429456e78f17fa3e4426d9d9b5f0 +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.format.NamedTextColor; +import net.kyori.adventure.text.format.TextDecoration; ++import net.kyori.adventure.text.minimessage.MiniMessage; +import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; +import org.bukkit.Bukkit; +import org.bukkit.Material; @@ -230,10 +231,10 @@ index 0000000000000000000000000000000000000000..6f74429456e78f17fa3e4426d9d9b5f0 + String state = visibility.isEnabled(setting) ? "Enabled" : "Disabled"; + + // Send message to player -+ player.sendRichMessage(GlobalConfiguration.get().fps.message, ++ player.sendMessage(MiniMessage.miniMessage().deserialize(GlobalConfiguration.get().fps.message, + Placeholder.unparsed("name", setting.friendlyName()), + Placeholder.unparsed("state", state) -+ ); ++ )); + + // Update toggle all icon + this.refreshSlot(player, 26); @@ -242,7 +243,7 @@ index 0000000000000000000000000000000000000000..6f74429456e78f17fa3e4426d9d9b5f0 + +} diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java -index ccdc2345465313991f065e1176b58fb7d5e8722f..ab8bb26bceb2ec6f541aab348d420b9390c8c47a 100644 +index 24c677e80af652952263253409c050641e72e3b5..62b08f8216abc1bc82bc5457e74811c823e900e0 100644 --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundSectionBlocksUpdatePacket.java @@ -16,7 +16,7 @@ public class ClientboundSectionBlocksUpdatePacket implements Packet public + private final boolean suppressLightUpdates; - public ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, ShortSet positions, LevelChunkSection section) { - this.sectionPos = sectionPos; + public ClientboundSectionBlocksUpdatePacket(SectionPos sectionPos, ShortSet positions, LevelChunkSection section, boolean noLightingUpdates) { diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 1f169b9bc09052137187654a7331033779694ad4..8e2ee508d2290ace16714ed9927983f29a230304 100644 +index 0e83e4e0fc1123dadca03dc0e3e1011640722c0a..0fa8b271c58c74820461f7bec213062b266ec18b 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1744,6 +1744,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop cachedSingleMobDistanceMap; + // Paper end + public final me.samsuik.sakura.player.visibility.Visibility visibility = new me.samsuik.sakura.player.visibility.Visibility(); // Sakura - visiblity api // CraftBukkit start public String displayName; -@@ -567,6 +568,15 @@ public class ServerPlayer extends Player { +@@ -505,6 +506,15 @@ public class ServerPlayer extends Player { this.respawnDimension = (ResourceKey) dataresult1.resultOrPartial(logger1::error).orElse(Level.OVERWORLD); } } @@ -346,7 +344,7 @@ index b3781efbd3edcf102fe1bda5d6149915dc1127c6..68ea7cd8148ff4a80da761cf38e73bfa } -@@ -633,6 +643,13 @@ public class ServerPlayer extends Player { +@@ -571,6 +581,13 @@ public class ServerPlayer extends Player { }); } this.getBukkitEntity().setExtraData(nbt); // CraftBukkit @@ -360,114 +358,11 @@ index b3781efbd3edcf102fe1bda5d6149915dc1127c6..68ea7cd8148ff4a80da761cf38e73bfa } -diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index 0306771b8f90dcdd77f151c19c6c2d75c41f8feb..7451f65cef49248793815965bda4bcbe257b722e 100644 ---- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -40,6 +40,23 @@ import org.bukkit.craftbukkit.util.Waitable; - import org.bukkit.event.player.PlayerKickEvent; - import org.bukkit.event.player.PlayerResourcePackStatusEvent; - // CraftBukkit end -+// Sakura start -+import com.mojang.datafixers.util.Pair; -+import me.samsuik.sakura.player.visibility.Visibility.Setting; -+import net.minecraft.world.level.block.Blocks; -+import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket; -+import net.minecraft.network.protocol.game.ClientboundBlockEventPacket; -+import net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket; -+import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData; -+import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData.BlockEntityTagOutput; -+import net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket; -+import net.minecraft.network.protocol.game.ClientboundSetEquipmentPacket; -+import net.minecraft.world.level.block.DiodeBlock; -+import net.minecraft.world.level.block.entity.BlockEntityType; -+import net.minecraft.world.level.block.RedStoneWireBlock; -+import net.minecraft.world.level.block.piston.PistonBaseBlock; -+import net.minecraft.world.level.block.piston.PistonHeadBlock; -+// Sakura end - - public abstract class ServerCommonPacketListenerImpl implements ServerCommonPacketListener { - -@@ -247,6 +264,61 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack - } else if (packet instanceof ClientboundSetDefaultSpawnPositionPacket) { - ClientboundSetDefaultSpawnPositionPacket packet6 = (ClientboundSetDefaultSpawnPositionPacket) packet; - this.player.compassTarget = CraftLocation.toBukkit(packet6.pos, this.getCraftPlayer().getWorld()); -+ // Sakura start - visibility api -+ } else if (!player.visibility.isModified()) { -+ // Skip players that haven't modified their settings -+ } else if (packet instanceof ClientboundSetEquipmentPacket equipment -+ && player.visibility.isToggled(Setting.ENCHANTMENT_GLINT)) { -+ var slots = new java.util.ArrayList>(); -+ -+ for (int i = 0; i < equipment.getSlots().size(); i++) { -+ var pair = equipment.getSlots().get(i); -+ var itemstack = pair.getSecond(); -+ -+ if (itemstack.isEnchanted()) { -+ var copy = itemstack.copy(); -+ copy.getTag().remove("ench"); -+ itemstack = copy; -+ } -+ -+ slots.add(new Pair<>(pair.getFirst(), itemstack)); -+ } -+ -+ packet = new ClientboundSetEquipmentPacket(equipment.getEntity(), slots); -+ } else if (packet instanceof ClientboundBlockEntityDataPacket blockdata -+ && player.visibility.isToggled(Setting.SPAWNERS) -+ && player.level().getBlockIfLoaded(blockdata.getPos()) == Blocks.SPAWNER) { -+ packet = new ClientboundBlockUpdatePacket(blockdata.getPos(), Blocks.BLACK_STAINED_GLASS.defaultBlockState()); -+ } else if (packet instanceof ClientboundBlockUpdatePacket updatePacket) { -+ if (player.visibility.isToggled(Setting.SPAWNERS) && updatePacket.blockState.getBlock() == Blocks.SPAWNER) { -+ packet = new ClientboundBlockUpdatePacket(updatePacket.getPos(), Blocks.BLACK_STAINED_GLASS.defaultBlockState()); -+ } else if (player.visibility.isToggled(Setting.REDSTONE) -+ && (updatePacket.blockState.getBlock() instanceof DiodeBlock -+ || updatePacket.blockState.getBlock() instanceof RedStoneWireBlock)) { -+ return; -+ } else if (player.visibility.isToggled(Setting.PISTONS) -+ && (updatePacket.blockState.getBlock() instanceof PistonBaseBlock -+ || updatePacket.blockState.getBlock() instanceof PistonHeadBlock)) { -+ return; -+ } -+ } else if (packet instanceof ClientboundSectionBlocksUpdatePacket sectionPacket) { -+ for (var state : sectionPacket.states) { -+ if (player.visibility.isToggled(Setting.REDSTONE) -+ && (state.getBlock() instanceof DiodeBlock -+ || state.getBlock() instanceof RedStoneWireBlock)) { -+ return; -+ } else if (player.visibility.isToggled(Setting.PISTONS) -+ && (state.getBlock() instanceof PistonBaseBlock -+ || state.getBlock() instanceof PistonHeadBlock)) { -+ return; -+ } -+ } -+ } else if (packet instanceof ClientboundBlockEventPacket blockevent -+ && player.visibility.isToggled(Setting.PISTONS) -+ && (blockevent.getBlock() instanceof PistonBaseBlock -+ || blockevent.getBlock() instanceof PistonHeadBlock)) { -+ return; -+ // Sakura end - } - // CraftBukkit end - boolean flag = !this.suspendFlushingOnServerThread || !this.server.isSameThread(); -@@ -257,8 +329,11 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack - CrashReport crashreport = CrashReport.forThrowable(throwable, "Sending packet"); - CrashReportCategory crashreportsystemdetails = crashreport.addCategory("Packet being sent"); - -+ // Sakura start - this has to be effectively final as we're modifying the packet above -+ var packetFinal = packet; - crashreportsystemdetails.setDetail("Packet class", () -> { -- return packet.getClass().getCanonicalName(); -+ return packetFinal.getClass().getCanonicalName(); -+ // Sakura end - }); - throw new ReportedException(crashreport); - } diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..d6e60e4e7b5410f30b47e6b9b57b390837368dfc 100644 +index bac6b62419d85b3772ef243aa3d5f73311abdda7..60fc19f25245f491c31018ec7cb065ced3516c44 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -3116,6 +3116,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl +@@ -3162,6 +3162,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic event.setCancelled(cancelled); AbstractContainerMenu oldContainer = this.player.containerMenu; // SPIGOT-1224 @@ -476,13 +371,13 @@ index fe2ef36ab5dc4b933abf24dbfd0e811c53239cf0..d6e60e4e7b5410f30b47e6b9b57b3908 if (this.player.containerMenu != oldContainer) { return; diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..7e4ed21080c56961713f35e219dd592f5f717d63 100644 +index 1eaab1f6923e6aa34b643293347348e5cc19af3c..0636aab71c93413ee40d842daae1b4232f7b2b9d 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -567,6 +567,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - - public boolean updatingSectionStatus = false; - // Paper end +@@ -541,6 +541,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + this.teleportTo(worldserver, null); + } + // Paper end - make end portalling safe + // Sakura start - visibility api and command + public boolean isPrimedTNT; + public boolean isFallingBlock; @@ -491,10 +386,10 @@ index 637478fd8a284e6833cf8f5fa17ccf9d73d1dd3f..7e4ed21080c56961713f35e219dd592f public Entity(EntityType type, Level world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); 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 a52c2fc38fd97ffa1684270443646d605ec35830..4f072853272bedd79bdf53d2a8373d8e0f6fdd29 100644 +index eacb8a407fe99af2c13f23c12b5544696bda8890..d693fb7fd81f046615ad062153c1a2599948d391 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -74,6 +74,7 @@ public class FallingBlockEntity extends Entity { +@@ -70,6 +70,7 @@ public class FallingBlockEntity extends Entity { this.blockState = Blocks.SAND.defaultBlockState(); this.dropItem = true; this.fallDamageMax = 40; @@ -503,10 +398,10 @@ index a52c2fc38fd97ffa1684270443646d605ec35830..4f072853272bedd79bdf53d2a8373d8e public FallingBlockEntity(Level world, double x, double y, double z, BlockState block) { diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index e712bd07ea2946167782473a536e0c72fab4bccd..2e6691b86e161616bb2dcf5ce0391ad57a3ef422 100644 +index bedee2c93bd0aff148f93dcf111e0fc3d9bce4a0..e2d016561d68901d86819bd830d516cad2a3bedd 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -39,6 +39,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -27,6 +27,7 @@ public class PrimedTnt extends Entity { public PrimedTnt(EntityType type, Level world) { super(type, world); this.blocksBuilding = true; @@ -515,24 +410,24 @@ index e712bd07ea2946167782473a536e0c72fab4bccd..2e6691b86e161616bb2dcf5ce0391ad5 public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) { diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 702bd6f2468559d425a95f8ad2622e98c373c065..dc8d34adac1a2834777a8fe1fe7f142e0b13c0bf 100644 +index 7c22957714c182579885a1a6197c09ce84755593..00ebe6b2e3068a3b9c1c4a7566685191f21ed379 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -228,6 +228,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -282,6 +282,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public abstract ResourceKey getTypeKey(); + public final it.unimi.dsi.fastutil.longs.Long2IntMap minimalTNT = new it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap(); // Sakura - visibility api + - protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, Supplier sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - create paper world config; Async-Anti-Xray: Pass executor + protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, Supplier sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - Async-Anti-Xray - Pass executor this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot - this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config + this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 44f4665db613c558078df5bb49106e4ca5679dfe..29f0c4c3fd9185bf8768572c135b50a9db34dbbe 100644 +index c546a465a2f85e1b0e785074af15546637619e8f..aaa3b2aa8e8791d88e2fb08342ec8c133cd219d6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -458,6 +458,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - this.getHandle().displayName = name == null ? this.getName() : name; +@@ -494,6 +494,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + this.getHandle().displayName = name == null ? getName() : name; } + // Sakura start - visiblity api diff --git a/patches/server/0007-Reduce-deltaMovement-Allocations.patch b/patches/server/0007-Reduce-deltaMovement-Allocations.patch index 00df522..e3f239b 100644 --- a/patches/server/0007-Reduce-deltaMovement-Allocations.patch +++ b/patches/server/0007-Reduce-deltaMovement-Allocations.patch @@ -5,27 +5,27 @@ Subject: [PATCH] Reduce deltaMovement Allocations diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 7e4ed21080c56961713f35e219dd592f5f717d63..5fbcdbaf4c0344dc3e8fff7bf31c2b021a0ae6cf 100644 +index 0636aab71c93413ee40d842daae1b4232f7b2b9d..3b6efce07745df062d5d3ef60011718842217336 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -1253,7 +1253,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1166,7 +1166,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.tryCheckInsideBlocks(); - float f = this.getBlockSpeedFactor(); + float f2 = this.getBlockSpeedFactor(); -- this.setDeltaMovement(this.getDeltaMovement().multiply((double) f, 1.0D, (double) f)); -+ this.multiplyDeltaMovement((double) f, 1.0D, (double) f); // Sakura - reduce movement allocations +- this.setDeltaMovement(this.getDeltaMovement().multiply((double) f2, 1.0D, (double) f2)); ++ this.multiplyDeltaMovement((double) f2, 1.0D, (double) f2); // Sakura - reduce movement allocations // Paper start - remove expensive streams from here boolean noneMatch = true; AABB fireSearchBox = this.getBoundingBox().deflate(1.0E-6D); -@@ -2069,6 +2069,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1895,6 +1895,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { public void moveTo(double x, double y, double z, float yaw, float pitch) { - // Paper start - Fix Entity Teleportation and cancel velocity if teleported + // Paper - cancel entity velocity if teleported if (!preserveMotion) { + this.movementDirty = false; // Sakura this.deltaMovement = Vec3.ZERO; } else { this.preserveMotion = false; -@@ -3473,29 +3474,33 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3199,29 +3200,33 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public void onAboveBubbleCol(boolean drag) { @@ -63,11 +63,11 @@ index 7e4ed21080c56961713f35e219dd592f5f717d63..5fbcdbaf4c0344dc3e8fff7bf31c2b02 - this.setDeltaMovement(vec3d.x, d0, vec3d.z); + this.setDeltaMovement(movementX, d0, movementZ); -+ // Sakura end ++ // Sakura end - reduce movement allocations this.resetFallDistance(); } -@@ -4484,16 +4489,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4155,16 +4160,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { vec3d = vec3d.normalize(); } @@ -90,7 +90,7 @@ index 7e4ed21080c56961713f35e219dd592f5f717d63..5fbcdbaf4c0344dc3e8fff7bf31c2b02 } this.fluidHeight.put(tag, d1); -@@ -4564,11 +4572,53 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4231,11 +4239,53 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return this.chunkPosition; } @@ -144,7 +144,7 @@ index 7e4ed21080c56961713f35e219dd592f5f717d63..5fbcdbaf4c0344dc3e8fff7bf31c2b02 synchronized (this.posLock) { // Paper this.deltaMovement = velocity; } // Paper -@@ -4579,7 +4629,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4246,7 +4296,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public void setDeltaMovement(double x, double y, double z) { @@ -153,15 +153,15 @@ index 7e4ed21080c56961713f35e219dd592f5f717d63..5fbcdbaf4c0344dc3e8fff7bf31c2b02 + movementY = y; + movementZ = z; + movementDirty = true; -+ // Sakura end ++ // Sakura end - reduce movement allocations } public final int getBlockX() { 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 4f072853272bedd79bdf53d2a8373d8e0f6fdd29..91aa2714bae3f8f5d0fb76426b2b8cfc61941f54 100644 +index d693fb7fd81f046615ad062153c1a2599948d391..1a83f88e7759b168d6f3c2f6ed4532d65a7cf437 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -141,7 +141,7 @@ public class FallingBlockEntity extends Entity { +@@ -142,7 +142,7 @@ public class FallingBlockEntity extends Entity { ++this.time; if (!this.isNoGravity()) { @@ -170,16 +170,16 @@ index 4f072853272bedd79bdf53d2a8373d8e0f6fdd29..91aa2714bae3f8f5d0fb76426b2b8cfc } this.move(MoverType.SELF, this.getDeltaMovement()); -@@ -181,7 +181,7 @@ public class FallingBlockEntity extends Entity { +@@ -189,7 +189,7 @@ public class FallingBlockEntity extends Entity { } else { - BlockState iblockdata = this.level().getBlockState(blockposition); + BlockState iblockdata = this.level.getBlockState(blockposition); - this.setDeltaMovement(this.getDeltaMovement().multiply(0.7D, -0.5D, 0.7D)); + this.multiplyDeltaMovement(0.7D, -0.5D, 0.7D); // Sakura - reduce movement allocations if (!iblockdata.is(Blocks.MOVING_PISTON)) { if (!this.cancelDrop) { - boolean flag2 = iblockdata.canBeReplaced((BlockPlaceContext) (new DirectionalPlaceContext(this.level(), blockposition, Direction.DOWN, ItemStack.EMPTY, Direction.UP))); -@@ -248,7 +248,7 @@ public class FallingBlockEntity extends Entity { + boolean flag2 = iblockdata.canBeReplaced((BlockPlaceContext) (new DirectionalPlaceContext(this.level, blockposition, Direction.DOWN, ItemStack.EMPTY, Direction.UP))); +@@ -256,7 +256,7 @@ public class FallingBlockEntity extends Entity { } } @@ -189,67 +189,48 @@ index 4f072853272bedd79bdf53d2a8373d8e0f6fdd29..91aa2714bae3f8f5d0fb76426b2b8cfc } diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index 2e6691b86e161616bb2dcf5ce0391ad57a3ef422..7890f84d7a69e2e6820ef0daa35f898534f7372f 100644 +index e2d016561d68901d86819bd830d516cad2a3bedd..80e495688b00d1297357350f9abebe5fbbf24cd8 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -75,7 +75,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -62,7 +62,7 @@ public class PrimedTnt extends Entity { public void tick() { - if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot + if (level.spigotConfig.maxTntTicksPerTick > 0 && ++level.spigotConfig.currentPrimedTnt > level.spigotConfig.maxTntTicksPerTick) { return; } // Spigot if (!this.isNoGravity()) { - this.setDeltaMovement(this.getDeltaMovement().add(0.0D, -0.04D, 0.0D)); + this.addDeltaMovement(0.0D, -0.04D, 0.0D); // Sakura - reduce movement allocations } this.move(MoverType.SELF, this.getDeltaMovement()); -@@ -85,9 +85,9 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -72,9 +72,9 @@ public class PrimedTnt extends Entity { return; } - // Paper end - Configurable TNT height nerf + // Paper end - this.setDeltaMovement(this.getDeltaMovement().scale(0.98D)); + this.scaleDeltaMovement(0.98D); // Sakura - reduce movement allocations - if (this.onGround()) { + if (this.onGround) { - this.setDeltaMovement(this.getDeltaMovement().multiply(0.7D, -0.5D, 0.7D)); + this.multiplyDeltaMovement(0.7D, -0.5D, 0.7D); // Sakura - reduce movement allocations } int i = this.getFuse() - 1; diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index eeacf65ebb0ea7070de6e773d31651e4c190d592..8fd87dc8f925a160bf390b05040110735f2a145b 100644 +index 5ef6b5ad4dd69a57595914c7af8422ee2f6ad054..e60410d2d1a09f935caffe0cfb9b6232c00b1c8c 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -617,10 +617,11 @@ public class Explosion { - d8 *= d13; - d9 *= d13; - d10 *= d13; -- Vec3 vec3d1 = new Vec3(d8, d9, d10); -+ Vec3 vec3d1 = null; // Sakura - move allocation below living entity condition - - // CraftBukkit start - Call EntityKnockbackEvent - if (entity instanceof LivingEntity) { -+ vec3d1 = new Vec3(d8, d9, d10); // Sakura - reduce deltaMovement allocations - Vec3 result = entity.getDeltaMovement().add(vec3d1); - org.bukkit.event.entity.EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) entity.getBukkitEntity(), this.source, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.EXPLOSION, d13, vec3d1, result.x, result.y, result.z); - -@@ -635,9 +636,13 @@ public class Explosion { - vec3d1 = org.bukkit.craftbukkit.util.CraftVector.toNMS(paperEvent.getAcceleration()); - } - // Paper end - call EntityKnockbackByEntityEvent for explosions -+ // Sakura start - reduce deltaMovement allocations -+ entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d1)); -+ } else { -+ entity.addDeltaMovement(d8, d9, d10); -+ // Sakura end - reduce deltaMovement allocations +@@ -273,7 +273,7 @@ public class Explosion { + d14 = entity instanceof Player && level.paperConfig().environment.disableExplosionKnockback ? 0 : ProtectionEnchantment.getExplosionKnockbackAfterDampener((LivingEntity) entity, d13); // Paper - Disable explosion knockback } - // CraftBukkit end -- entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d1)); + +- entity.setDeltaMovement(entity.getDeltaMovement().add(d8 * d14, d9 * d14, d10 * d14)); ++ entity.addDeltaMovement(d8 * d14, d9 * d14, d10 * d14); // Sakura - reduce movement allocations if (entity instanceof Player) { Player entityhuman = (Player) entity; diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java -index 22036ed3ea0629bc12981a8d91a03e55cc2117d6..73a453ef678ed90ebc1de4d1efc258ad81cf36b8 100644 +index 7b71073027f4cf79736546500ededdfbb83d968e..90e4d105754a1c8fba4e9b63e1c4f6096da3eabd 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java -@@ -469,7 +469,7 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -461,7 +461,7 @@ public class Block extends BlockBehaviour implements ItemLike { } public void updateEntityAfterFallOn(BlockGetter world, Entity entity) { @@ -257,4 +238,4 @@ index 22036ed3ea0629bc12981a8d91a03e55cc2117d6..73a453ef678ed90ebc1de4d1efc258ad + entity.multiplyDeltaMovement(1.0D, 0.0D, 1.0D); // Sakura } - public ItemStack getCloneItemStack(LevelReader world, BlockPos pos, BlockState state) { + public ItemStack getCloneItemStack(BlockGetter world, BlockPos pos, BlockState state) { diff --git a/patches/server/0008-Optional-Force-Position-Updates.patch b/patches/server/0008-Optional-Force-Position-Updates.patch index 1efca73..56512b6 100644 --- a/patches/server/0008-Optional-Force-Position-Updates.patch +++ b/patches/server/0008-Optional-Force-Position-Updates.patch @@ -5,21 +5,32 @@ Subject: [PATCH] Optional Force Position Updates diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index 7890f84d7a69e2e6820ef0daa35f898534f7372f..5aa02f28b6be60688e340099b1637fb0ebfe7aa9 100644 +index 80e495688b00d1297357350f9abebe5fbbf24cd8..7d2a2d69241344593b691321ba859e5ba246d15d 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -108,6 +108,14 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -60,7 +60,9 @@ public class PrimedTnt extends Entity { + + @Override + public void tick() { +- if (level.spigotConfig.maxTntTicksPerTick > 0 && ++level.spigotConfig.currentPrimedTnt > level.spigotConfig.maxTntTicksPerTick) { return; } // Spigot ++ if (level.spigotConfig.maxTntTicksPerTick > 0 && ++level.spigotConfig.currentPrimedTnt > level.spigotConfig.maxTntTicksPerTick) { ++ return; ++ } // Spigot + if (!this.isNoGravity()) { + this.addDeltaMovement(0.0D, -0.04D, 0.0D); // Sakura - reduce movement allocations + } +@@ -95,6 +97,14 @@ public class PrimedTnt extends Entity { } } + // Sakura start - configure force position updates -+ if (level().sakuraConfig().cannons.tnt.forcePositionUpdates) { -+ forcePositionUpdate(); ++ if (this.level.sakuraConfig().cannons.tnt.forcePositionUpdates) { ++ this.forcePositionUpdate(); + } + } + + private void forcePositionUpdate() { + // Sakura end - configure force position updates - // Paper start - Option to prevent TNT from moving in water - if (!this.isRemoved() && this.wasTouchingWater && this.level().paperConfig().fixes.preventTntFromMovingInWater) { + // Paper start - Optional prevent TNT from moving in water + if (!this.isRemoved() && this.wasTouchingWater && this.level.paperConfig().fixes.preventTntFromMovingInWater) { /* diff --git a/patches/server/0009-Load-Chunks-on-Movement.patch b/patches/server/0009-Load-Chunks-on-Movement.patch index 9cf8f3d..7eca70d 100644 --- a/patches/server/0009-Load-Chunks-on-Movement.patch +++ b/patches/server/0009-Load-Chunks-on-Movement.patch @@ -5,85 +5,109 @@ Subject: [PATCH] Load Chunks on Movement diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java -index ee0331a6bc40cdde08d926fd8eb1dc642630c2e5..ae068cd14042bfab0fc3ab1a6473ec09fb1d7185 100644 +index a87f6380b2c387fb0cdd40d5087b5c93492e3c88..4db0a1b1270e2ff1ea1a4723b3dd28860f4c2087 100644 --- a/src/main/java/io/papermc/paper/util/CollisionUtil.java +++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java -@@ -1569,6 +1569,7 @@ public final class CollisionUtil { - public static final int COLLISION_FLAG_COLLIDE_WITH_UNLOADED_CHUNKS = 1 << 1; - public static final int COLLISION_FLAG_CHECK_BORDER = 1 << 2; - public static final int COLLISION_FLAG_CHECK_ONLY = 1 << 3; -+ public static final int COLLISION_FLAG_ADD_TICKET = 1 << 4; // Sakura +@@ -403,9 +403,17 @@ public final class CollisionUtil { + return boxMinX < borderMinX || boxMaxX > borderMaxX || boxMinZ < borderMinZ || boxMaxZ > borderMaxZ; + } - public static boolean getCollisionsForBlocksOrWorldBorder(final Level world, final Entity entity, final AABB aabb, - final List intoVoxel, final List intoAABB, -@@ -1619,11 +1620,21 @@ public final class CollisionUtil { - final int maxChunkZ = maxBlockZ >> 4; ++ // Sakura start - load chunks on movement + public static boolean getCollisionsForBlocksOrWorldBorder(final CollisionGetter getter, final Entity entity, final AABB aabb, +- final List into, final boolean loadChunks, final boolean collidesWithUnloaded, +- final boolean checkBorder, final boolean checkOnly, final BiPredicate predicate) { ++ final List into, final boolean loadChunks, final boolean collidesWithUnloaded, ++ final boolean checkBorder, final boolean checkOnly, final BiPredicate predicate) { ++ return getCollisionsForBlocksOrWorldBorder(getter, entity, aabb, into, loadChunks, collidesWithUnloaded, checkBorder, false, checkOnly, predicate); ++ } ++ public static boolean getCollisionsForBlocksOrWorldBorder(final CollisionGetter getter, final Entity entity, final AABB aabb, ++ final List into, final boolean loadChunks, final boolean collidesWithUnloaded, ++ final boolean checkBorder, final boolean addTicket, final boolean checkOnly, ++ final BiPredicate predicate) { ++ // Sakura end - load chunks on movement + boolean ret = false; - final boolean loadChunks = (collisionFlags & COLLISION_FLAG_LOAD_CHUNKS) != 0; -+ final boolean addTicket = (collisionFlags & COLLISION_FLAG_ADD_TICKET) != 0; // Sakura - final ServerChunkCache chunkSource = (ServerChunkCache)world.getChunkSource(); - - for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) { - for (int currChunkX = minChunkX; currChunkX <= maxChunkX; ++currChunkX) { - final ChunkAccess chunk = loadChunks ? chunkSource.getChunk(currChunkX, currChunkZ, ChunkStatus.FULL, true) : chunkSource.getChunkAtIfLoadedImmediately(currChunkX, currChunkZ); -+ // Sakura start - keep chunks loaded on movement -+ if (addTicket && chunk instanceof net.minecraft.world.level.chunk.LevelChunk levelChunk && levelChunk.movementLoadTicketRequiresUpdate()) { -+ chunkSource.chunkMap.getDistanceManager().getChunkHolderManager().addTicketAtLevel(net.minecraft.server.level.TicketType.ENTITY_MOVEMENT, currChunkX, currChunkZ, 31, CoordinateUtils.getChunkKey(currChunkX, currChunkZ)); -+ // This is known to work, uncomment if any issues -+ // var pos = new net.minecraft.world.level.ChunkPos(currChunkX, currChunkZ); -+ // chunkSource.addTicketAtLevel(net.minecraft.server.level.TicketType.ENTITY_MOVEMENT, pos, 33, pos.toLong()); -+ levelChunk.updatedMovementLoadTicket(); -+ } -+ // Sakura end + if (checkBorder) { +@@ -479,8 +487,17 @@ public final class CollisionUtil { + final ChunkAccess chunk; + if (chunkProvider == null) { + chunk = (ChunkAccess)getter.getChunkForCollisions(currChunkX, currChunkZ); ++ // Sakura start - load chunks on movement ++ } else if (loadChunks) { ++ chunk = chunkProvider.getChunk(currChunkX, currChunkZ, true); ++ if (addTicket && chunk instanceof net.minecraft.world.level.chunk.LevelChunk levelChunk && levelChunk.movementLoadTicketRequiresUpdate()) { ++ net.minecraft.world.level.ChunkPos chunkPos = new net.minecraft.world.level.ChunkPos(currChunkX, currChunkZ); ++ chunkProvider.addTicketAtLevel(net.minecraft.server.level.TicketType.ENTITY_MOVEMENT, chunkPos, 33, chunkPos.toLong()); ++ levelChunk.updatedMovementLoadTicket(); ++ } + } else { +- chunk = loadChunks ? chunkProvider.getChunk(currChunkX, currChunkZ, true) : chunkProvider.getChunkAtIfLoadedImmediately(currChunkX, currChunkZ); ++ chunk = chunkProvider.getChunkAtIfLoadedImmediately(currChunkX, currChunkZ); ++ // Sakura end - load chunks on movement + } if (chunk == null) { - if ((collisionFlags & COLLISION_FLAG_COLLIDE_WITH_UNLOADED_CHUNKS) != 0) { +@@ -846,16 +863,24 @@ public final class CollisionUtil { + return ret; + } + ++ // Sakura start - load chunks on movement + public static boolean getCollisions(final CollisionGetter view, final Entity entity, final AABB aabb, + final List into, final boolean loadChunks, final boolean collidesWithUnloadedChunks, + final boolean checkBorder, final boolean checkOnly, final BiPredicate blockPredicate, + final Predicate entityPredicate) { ++ return getCollisions(view, entity, aabb, into, loadChunks, collidesWithUnloadedChunks, checkBorder, false, checkOnly, blockPredicate, entityPredicate); ++ } ++ public static boolean getCollisions(final CollisionGetter view, final Entity entity, final AABB aabb, ++ final List into, final boolean loadChunks, final boolean collidesWithUnloadedChunks, ++ final boolean checkBorder, final boolean addTicket, final boolean checkOnly, ++ final BiPredicate blockPredicate, final Predicate entityPredicate) { + if (checkOnly) { +- return getCollisionsForBlocksOrWorldBorder(view, entity, aabb, into, loadChunks, collidesWithUnloadedChunks, checkBorder, checkOnly, blockPredicate) ++ return getCollisionsForBlocksOrWorldBorder(view, entity, aabb, into, loadChunks, collidesWithUnloadedChunks, checkBorder, addTicket, checkOnly, blockPredicate) + || getEntityHardCollisions(view, entity, aabb, into, checkOnly, entityPredicate); + } else { +- return getCollisionsForBlocksOrWorldBorder(view, entity, aabb, into, loadChunks, collidesWithUnloadedChunks, checkBorder, checkOnly, blockPredicate) ++ return getCollisionsForBlocksOrWorldBorder(view, entity, aabb, into, loadChunks, collidesWithUnloadedChunks, checkBorder, addTicket, checkOnly, blockPredicate) + | getEntityHardCollisions(view, entity, aabb, into, checkOnly, entityPredicate); ++ // Sakura end - load chunks on movement + } + } + diff --git a/src/main/java/net/minecraft/server/level/TicketType.java b/src/main/java/net/minecraft/server/level/TicketType.java -index 658e63ebde81dc14c8ab5850fb246dc0aab25dea..f1ff1a67fee37ee7b241ceaa164fa4ee64d3767b 100644 +index 97d1ff2af23bac14e67bca5896843325aaa5bfc1..c90b265a9cd92d40960d5513d9585e47d93fed3c 100644 --- a/src/main/java/net/minecraft/server/level/TicketType.java +++ b/src/main/java/net/minecraft/server/level/TicketType.java -@@ -37,6 +37,7 @@ public class TicketType { - public static final TicketType NON_FULL_SYNC_LOAD = create("non_full_sync_load", Long::compareTo); - public static final TicketType DELAY_UNLOAD = create("delay_unload", Comparator.comparingLong(ChunkPos::toLong), 1); +@@ -35,6 +35,7 @@ public class TicketType { + public static final TicketType POI_LOAD = create("poi_load", Long::compareTo); + public static final TicketType UNLOAD_COOLDOWN = create("unload_cooldown", (u1, u2) -> 0, 5 * 20); // Paper end - rewrite chunk system + public static final TicketType ENTITY_MOVEMENT = create("entity_movement", Long::compareTo, 10 * 20); // Sakura public static TicketType create(String name, Comparator argumentComparator) { return new TicketType<>(name, argumentComparator, 0L); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 5fbcdbaf4c0344dc3e8fff7bf31c2b021a0ae6cf..6e217474e7224cc5cc0a9818d39233c6757eca50 100644 +index 3b6efce07745df062d5d3ef60011718842217336..c0fb35497cfab69e5d28a70a2756f0d74a406630 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -571,6 +571,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -545,6 +545,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { public boolean isPrimedTNT; public boolean isFallingBlock; // Sakura end - visibility api and command -+ // Sakura start - load chunks on cannon entity movement -+ protected boolean loadChunks = false; -+ -+ private int getExtraCollisionFlags() { -+ int flags = 0; -+ -+ if (this.loadChunks) { -+ flags |= io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_LOAD_CHUNKS | io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_ADD_TICKET; -+ } -+ -+ return flags; -+ } -+ // Sakura end - load chunks on cannon entity movement ++ public boolean loadChunks = false; // Sakura - load chunks on cannon entity movement public Entity(EntityType type, Level world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -1514,7 +1527,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1394,7 +1395,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + } - io.papermc.paper.util.CollisionUtil.getCollisions( - world, this, collisionBox, potentialCollisionsVoxel, potentialCollisionsBB, -- io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_CHECK_BORDER, -+ io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | this.getExtraCollisionFlags(), // Sakura - null, null - ); + io.papermc.paper.util.CollisionUtil.getCollisions(world, this, collisionBox, potentialCollisions, false, this.level.paperConfig().chunks.preventMovingIntoUnloadedChunks, +- false, false, null, null); ++ false, this.loadChunks, false, null, null); // Sakura - load chunks on movement -@@ -4897,12 +4910,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S + if (collidingWithWorldBorder = io.papermc.paper.util.CollisionUtil.isCollidingWithBorderEdge(world.getWorldBorder(), collisionBox)) { // Paper - this line *is* correct, ignore the IDE warning about assignments being used as a condition + io.papermc.paper.util.CollisionUtil.addBoxesToIfIntersects(world.getWorldBorder().getCollisionShape(), collisionBox, potentialCollisions); +@@ -4532,12 +4533,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @Override public boolean shouldBeSaved() { @@ -99,10 +123,10 @@ index 5fbcdbaf4c0344dc3e8fff7bf31c2b021a0ae6cf..6e217474e7224cc5cc0a9818d39233c6 public boolean mayInteract(Level world, BlockPos pos) { 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 91aa2714bae3f8f5d0fb76426b2b8cfc61941f54..eb2f4fcfe04cb5aa135590b620927ffbe12c8a1e 100644 +index 1a83f88e7759b168d6f3c2f6ed4532d65a7cf437..3559457024f5c9bef4c44a27514e338c7d2b4172 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -75,6 +75,7 @@ public class FallingBlockEntity extends Entity { +@@ -71,6 +71,7 @@ public class FallingBlockEntity extends Entity { this.dropItem = true; this.fallDamageMax = 40; this.isFallingBlock = true; // Sakura @@ -111,10 +135,10 @@ index 91aa2714bae3f8f5d0fb76426b2b8cfc61941f54..eb2f4fcfe04cb5aa135590b620927ffb public FallingBlockEntity(Level world, double x, double y, double z, BlockState block) { diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index 5aa02f28b6be60688e340099b1637fb0ebfe7aa9..2202138b4ee5d78c9d67f0d53516d135ac9dc745 100644 +index 7d2a2d69241344593b691321ba859e5ba246d15d..5761b786f036df1516189edd67ea4439d64c6ea8 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -40,6 +40,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -28,6 +28,7 @@ public class PrimedTnt extends Entity { super(type, world); this.blocksBuilding = true; this.isPrimedTNT = true; // Sakura @@ -123,13 +147,13 @@ index 5aa02f28b6be60688e340099b1637fb0ebfe7aa9..2202138b4ee5d78c9d67f0d53516d135 public PrimedTnt(Level world, double x, double y, double z, @Nullable LivingEntity igniter) { diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -index 465458e8a7dbaf9afb32709a71c7b2620d1e1fd2..27b6baae9ac0feec2f2578540e29da6281593add 100644 +index 28e4b302284f955a73e75d0f4276d55fb51826f5..2bb7195bdb977de6b899cade0847cd6414f3eae2 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -218,6 +218,17 @@ public class LevelChunk extends ChunkAccess { +@@ -361,6 +361,17 @@ public class LevelChunk extends ChunkAccess { } } - // Paper end + // Paper end - optimise checkDespawn + // Sakura start + private long lastMovementLoadTicket = 0; + diff --git a/patches/server/0010-TPS-Graph-Command.patch b/patches/server/0010-TPS-Graph-Command.patch index b1d4e39..19fc7c4 100644 --- a/patches/server/0010-TPS-Graph-Command.patch +++ b/patches/server/0010-TPS-Graph-Command.patch @@ -418,38 +418,38 @@ index 0000000000000000000000000000000000000000..6903863ad293a335a8ed1aeaa06fccb4 + +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 8e2ee508d2290ace16714ed9927983f29a230304..3c98362624e1b02b6b028db95564254e044c7b0d 100644 +index 0fa8b271c58c74820461f7bec213062b266ec18b..321bd1d6c2cbf8384b08708abb837ed3ad4a0078 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1125,6 +1125,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { - return false; - } : this::haveTime); -+ tickTracking.tickSample((System.nanoTime() - currentTime) / 1_000_000L); // Sakura +@@ -1176,6 +1178,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop[] itemsArray = new SynchedEntityData.DataItem[DEFAULT_ENTRY_COUNT]; - // Paper end - Perf: array backed synched entity data +@@ -34,6 +34,7 @@ public class SynchedEntityData { + private final Int2ObjectMap> itemsById = new Int2ObjectOpenHashMap(); + // private final ReadWriteLock lock = new ReentrantReadWriteLock(); // Spigot - not required + private boolean isDirty; + private boolean isForeignDirty; // Slice public SynchedEntityData(Entity trackedEntity) { this.entity = trackedEntity; -@@ -165,6 +166,16 @@ public class SynchedEntityData { +@@ -135,6 +136,12 @@ public class SynchedEntityData { } - public void set(EntityDataAccessor key, T value, boolean force) { + public void set(EntityDataAccessor key, T value) { + // Slice start -+ this.set(key, value, null, force); ++ this.set(key, value, null); + } + + public void set(EntityDataAccessor key, T value, T foreignValue) { -+ this.set(key, value, foreignValue, false); -+ } -+ -+ public void set(EntityDataAccessor key, T value, T foreignValue, boolean force) { + // Slice end SynchedEntityData.DataItem datawatcher_item = this.getItem(key); - if (force || ObjectUtils.notEqual(value, datawatcher_item.getValue())) { -@@ -174,6 +185,12 @@ public class SynchedEntityData { + if (ObjectUtils.notEqual(value, datawatcher_item.getValue())) { +@@ -144,6 +151,12 @@ public class SynchedEntityData { this.isDirty = true; } @@ -60,7 +56,7 @@ index 58b602e550258c1062ee940bc46538dac95d8979..50c6647ef3755c3712bf095c14c82001 } // CraftBukkit start - add method from above -@@ -183,6 +200,12 @@ public class SynchedEntityData { +@@ -153,6 +166,12 @@ public class SynchedEntityData { } // CraftBukkit end @@ -73,7 +69,7 @@ index 58b602e550258c1062ee940bc46538dac95d8979..50c6647ef3755c3712bf095c14c82001 public boolean isDirty() { return this.isDirty; } -@@ -215,6 +238,29 @@ public class SynchedEntityData { +@@ -185,6 +204,29 @@ public class SynchedEntityData { return list; } @@ -103,7 +99,7 @@ index 58b602e550258c1062ee940bc46538dac95d8979..50c6647ef3755c3712bf095c14c82001 @Nullable public List> getNonDefaultValues() { List> list = null; -@@ -339,11 +385,14 @@ public class SynchedEntityData { +@@ -291,11 +333,14 @@ public class SynchedEntityData { T value; private final T initialValue; private boolean dirty; @@ -118,7 +114,7 @@ index 58b602e550258c1062ee940bc46538dac95d8979..50c6647ef3755c3712bf095c14c82001 } public EntityDataAccessor getAccessor() { -@@ -370,6 +419,35 @@ public class SynchedEntityData { +@@ -322,6 +367,35 @@ public class SynchedEntityData { return this.initialValue.equals(this.value); } @@ -155,10 +151,10 @@ index 58b602e550258c1062ee940bc46538dac95d8979..50c6647ef3755c3712bf095c14c82001 return SynchedEntityData.DataValue.create(this.accessor, this.value); } diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 529ab44baaf573b97cf7e89560c548642733188f..b37f568fbd39be15f08e00f4ea5f28738a1d99fe 100644 +index 190e9761087baec5827d722a8281f0ffb6798341..18676547ee697bea691c0ee69df5906455c5f238 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -141,7 +141,7 @@ public class ServerEntity { +@@ -129,7 +129,7 @@ public class ServerEntity { } } @@ -167,7 +163,7 @@ index 529ab44baaf573b97cf7e89560c548642733188f..b37f568fbd39be15f08e00f4ea5f2873 int i; int j; -@@ -380,7 +380,15 @@ public class ServerEntity { +@@ -367,7 +367,15 @@ public class ServerEntity { if (list != null) { this.trackedDataValues = datawatcher.getNonDefaultValues(); @@ -185,10 +181,10 @@ index 529ab44baaf573b97cf7e89560c548642733188f..b37f568fbd39be15f08e00f4ea5f2873 if (this.entity instanceof LivingEntity) { diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 6e217474e7224cc5cc0a9818d39233c6757eca50..95137b2a064e98e476ef1bc56b0d2b2920f18d17 100644 +index c0fb35497cfab69e5d28a70a2756f0d74a406630..35c4253e1ee951c31958bb9275a4f497fd5b16bb 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -3418,7 +3418,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3131,7 +3131,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.entityData.markDirty(Entity.DATA_AIR_SUPPLY_ID); return; } @@ -198,10 +194,10 @@ index 6e217474e7224cc5cc0a9818d39233c6757eca50..95137b2a064e98e476ef1bc56b0d2b29 } 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 aae2093c42d76af5bdb0d4bda3e5ee362a2143e3..743aac4ba5d08ef3e6b67136bd4919b62411a7a0 100644 +index 3559457024f5c9bef4c44a27514e338c7d2b4172..6b85eecde57a809391d531bb11d189d0a25ccfdc 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -111,7 +111,7 @@ public class FallingBlockEntity extends Entity { +@@ -107,7 +107,7 @@ public class FallingBlockEntity extends Entity { } public void setStartPos(BlockPos pos) { @@ -211,10 +207,10 @@ index aae2093c42d76af5bdb0d4bda3e5ee362a2143e3..743aac4ba5d08ef3e6b67136bd4919b6 public BlockPos getStartPos() { diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index 7a5ea7e0ea063eb0355dea89746a0e581548d131..90f10473ae441d68333cd497c718a3c982544533 100644 +index 5761b786f036df1516189edd67ea4439d64c6ea8..c2f04fca63ebef48a3092b60c703277abcb9b586 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -189,7 +189,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -171,7 +171,7 @@ public class PrimedTnt extends Entity { } public void setFuse(int fuse) { @@ -224,10 +220,10 @@ index 7a5ea7e0ea063eb0355dea89746a0e581548d131..90f10473ae441d68333cd497c718a3c9 public int getFuse() { diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index 567704f61034363e48ef2a5b5566ebdc91682297..74dcfabdc66ef289b8d6a5c6606579b5321af1db 100644 +index 1116116e4ba6c5ecec400cd371b70b9e14efd92b..407401198c21dd5887aa3b7d86cdb112ef369007 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -646,7 +646,7 @@ public abstract class Player extends LivingEntity { +@@ -637,7 +637,7 @@ public abstract class Player extends LivingEntity { public void increaseScore(int score) { int j = this.getScore(); diff --git a/patches/server/0013-Use-Optimised-TrackedEntityMap.patch b/patches/server/0013-Use-Optimised-TrackedEntityMap.patch index ff2cd6b..8956b6f 100644 --- a/patches/server/0013-Use-Optimised-TrackedEntityMap.patch +++ b/patches/server/0013-Use-Optimised-TrackedEntityMap.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Use Optimised TrackedEntityMap diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index bb6a2be67394b9a6904d759b7564008dd1c282b3..8a817dda325898b759de63ab6e4300b050286bf7 100644 +index 500d0b297de5234b4c622d407d511b161acc2233..c3b3e984f8a19252b6feabb9ba1f7169dcec2fa2 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -251,7 +251,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -295,7 +295,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider // Paper - rewrite chunk system this.tickingGenerated = new AtomicInteger(); this.playerMap = new PlayerMap(); diff --git a/patches/server/0014-Copy-EntityList-methods-to-BasicEntityList.patch b/patches/server/0014-Copy-EntityList-methods-to-BasicEntityList.patch index aa01830..6b57432 100644 --- a/patches/server/0014-Copy-EntityList-methods-to-BasicEntityList.patch +++ b/patches/server/0014-Copy-EntityList-methods-to-BasicEntityList.patch @@ -5,19 +5,19 @@ Subject: [PATCH] Copy EntityList methods to BasicEntityList diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -index c78cbec447032de9fe69748591bef6be300160ed..01701cdd0d984e35ff3453e6253ba9bcaa0db7b9 100644 +index f597d65d56964297eeeed6c7e77703764178fee0..1d6b96fd6dae9524c31e71a778351e8b2d325b7f 100644 --- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java +++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -@@ -26,6 +26,8 @@ import java.util.List; +@@ -24,6 +24,8 @@ import java.util.Iterator; + import java.util.List; import java.util.function.Predicate; - import org.bukkit.event.entity.EntityRemoveEvent; +import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; // Sakura + public final class ChunkEntitySlices { protected final int minSection; -@@ -304,6 +306,13 @@ public final class ChunkEntitySlices { +@@ -298,6 +300,13 @@ public final class ChunkEntitySlices { protected static final class BasicEntityList { @@ -31,7 +31,7 @@ index c78cbec447032de9fe69748591bef6be300160ed..01701cdd0d984e35ff3453e6253ba9bc protected static final Entity[] EMPTY = new Entity[0]; protected static final int DEFAULT_CAPACITY = 4; -@@ -326,55 +335,52 @@ public final class ChunkEntitySlices { +@@ -320,55 +329,52 @@ public final class ChunkEntitySlices { return this.size; } diff --git a/patches/server/0015-Add-utility-methods-to-EntitySlices.patch b/patches/server/0015-Add-utility-methods-to-EntitySlices.patch index 4b1383a..185fd96 100644 --- a/patches/server/0015-Add-utility-methods-to-EntitySlices.patch +++ b/patches/server/0015-Add-utility-methods-to-EntitySlices.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add utility methods to EntitySlices diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -index 01701cdd0d984e35ff3453e6253ba9bcaa0db7b9..8fcaa00e461c7f4413bf655ddd8165a2b908f900 100644 +index 1d6b96fd6dae9524c31e71a778351e8b2d325b7f..ce231d8b230d4983b21c597357c0b22377e4bcca 100644 --- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java +++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -@@ -252,6 +252,12 @@ public final class ChunkEntitySlices { +@@ -246,6 +246,12 @@ public final class ChunkEntitySlices { return true; } @@ -21,7 +21,7 @@ index 01701cdd0d984e35ff3453e6253ba9bcaa0db7b9..8fcaa00e461c7f4413bf655ddd8165a2 public void getHardCollidingEntities(final Entity except, final AABB box, final List into, final Predicate predicate) { this.hardCollidingEntities.getEntities(except, box, into, predicate); -@@ -430,6 +436,18 @@ public final class ChunkEntitySlices { +@@ -424,6 +430,18 @@ public final class ChunkEntitySlices { this.nonEmptyBitset[sectionIndex >>> 6] ^= (1L << (sectionIndex & (Long.SIZE - 1))); } } diff --git a/patches/server/0016-Optimise-paper-explosions.patch b/patches/server/0016-Optimise-paper-explosions.patch index f2a3e70..7042fa6 100644 --- a/patches/server/0016-Optimise-paper-explosions.patch +++ b/patches/server/0016-Optimise-paper-explosions.patch @@ -5,14 +5,41 @@ Subject: [PATCH] Optimise paper explosions diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 8fd87dc8f925a160bf390b05040110735f2a145b..e5335d64799005a4cdd2cb11cef637f250880b0c 100644 +index e60410d2d1a09f935caffe0cfb9b6232c00b1c8c..7924adff65f0fa4ce4e1c1b4d8632a4c3c55d52f 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -111,6 +111,41 @@ public class Explosion { - this.yield = this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F; // CraftBukkit +@@ -96,7 +96,196 @@ public class Explosion { + this.damageCalculator = behavior == null ? this.makeDamageCalculator(entity) : behavior; } -+ // Sakura start - optimise paper explosions ++ // Sakura start - optimise vanilla explosions ++ private static final double[] EXPLOSION_RAYS; ++ ++ static { ++ it.unimi.dsi.fastutil.doubles.DoubleArrayList list = new it.unimi.dsi.fastutil.doubles.DoubleArrayList(); ++ for (int k = 0; k < 16; ++k) { ++ for (int i = 0; i < 16; ++i) { ++ for (int j = 0; j < 16; ++j) { ++ if (k == 0 || k == 15 || i == 0 || i == 15 || j == 0 || j == 15) { ++ double d0 = (double) ((float) k / 15.0F * 2.0F - 1.0F); ++ double d1 = (double) ((float) i / 15.0F * 2.0F - 1.0F); ++ double d2 = (double) ((float) j / 15.0F * 2.0F - 1.0F); ++ double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2); ++ ++ d0 /= d3; ++ d1 /= d3; ++ d2 /= d3; ++ ++ list.add(d0 * 0.30000001192092896D); ++ list.add(d1 * 0.30000001192092896D); ++ list.add(d2 * 0.30000001192092896D); ++ } ++ } ++ } ++ } ++ EXPLOSION_RAYS = sortExplosionRays(list); ++ } ++ + /* + * Sort the explosion rays to better utilise the chunk and block cache. + * x + Vanilla Sorted @@ -28,8 +55,8 @@ index 8fd87dc8f925a160bf390b05040110735f2a145b..e5335d64799005a4cdd2cb11cef637f2 + return sign + 8 + vec[2] * dir; + }); + -+ private static double[] sortExplosionRays(final it.unimi.dsi.fastutil.doubles.DoubleArrayList rayCoords) { -+ List explosionRays = new ArrayList<>(); ++ private static double[] sortExplosionRays(it.unimi.dsi.fastutil.doubles.DoubleArrayList rayCoords) { ++ List explosionRays = new ObjectArrayList<>(); + + for (int i = 0; i < rayCoords.size(); i += 3) { + double[] ray = new double[3]; @@ -46,79 +73,98 @@ index 8fd87dc8f925a160bf390b05040110735f2a145b..e5335d64799005a4cdd2cb11cef637f2 + } + return rays; + } -+ // Sakura end - optimise paper explosions - // Paper start - optimise collisions - private static final double[] CACHED_RAYS; - static { -@@ -136,7 +171,7 @@ public class Explosion { - } - } - -- CACHED_RAYS = rayCoords.toDoubleArray(); -+ CACHED_RAYS = sortExplosionRays(rayCoords); // Sakura - optimise paper explosions - } - - private static final int CHUNK_CACHE_SHIFT = 2; -@@ -430,7 +465,7 @@ public class Explosion { - } - // CraftBukkit end - this.level.gameEvent(this.source, GameEvent.EXPLODE, new Vec3(this.x, this.y, this.z)); -- Set set = Sets.newHashSet(); -+ // Sakura - moved into searchForBlocks - boolean flag = true; - - int i; -@@ -456,6 +491,17 @@ public class Explosion { - - initialCache = this.getOrCacheExplosionBlock(blockX, blockY, blockZ, key, true); - } -+ // Sakura start - optimise paper explosions -+ if (initialCache.resistance <= (this.radius * 1.3f) && this.interactsWithBlocks()) { -+ this.searchForBlocks(blockCache, initialCache); ++ ++ protected final void searchForBlocks() { ++ it.unimi.dsi.fastutil.longs.LongOpenHashSet positions = new it.unimi.dsi.fastutil.longs.LongOpenHashSet(); ++ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); ++ double[] explosionRays = EXPLOSION_RAYS; ++ int prevChunkX = Integer.MIN_VALUE; ++ int prevChunkZ = Integer.MIN_VALUE; ++ net.minecraft.world.level.chunk.LevelChunk currChunk = null; ++ for (int ray = 0, len = explosionRays.length; ray < len;) { ++ double rayX = explosionRays[ray++]; ++ double rayY = explosionRays[ray++]; ++ double rayZ = explosionRays[ray++]; ++ ++ float power = this.radius * (0.7F + this.level.random.nextFloat() * 0.6F); ++ double x = this.x; ++ double y = this.y; ++ double z = this.z; ++ ++ float prevBlockResistance = 0.0f; ++ int prevBlockX = Integer.MIN_VALUE; ++ int prevBlockY = Integer.MIN_VALUE; ++ int prevBlockZ = Integer.MIN_VALUE; ++ for (; power > 0.0F; power -= 0.22500001F) { ++ int blockX = Mth.floor(x); ++ int blockY = Mth.floor(y); ++ int blockZ = Mth.floor(z); ++ x += rayX; ++ y += rayY; ++ z += rayZ; ++ ++ if (blockX == prevBlockX && blockY == prevBlockY && blockZ == prevBlockZ) { ++ power -= prevBlockResistance; ++ continue; ++ } else { ++ prevBlockX = blockX; ++ prevBlockY = blockY; ++ prevBlockZ = blockZ; ++ ++ final int chunkX = blockX >> 4; ++ final int chunkZ = blockZ >> 4; ++ if (chunkX != prevChunkX || chunkZ != prevChunkZ) { ++ currChunk = this.level.getChunk(chunkX, chunkZ); ++ prevChunkX = chunkX; ++ prevChunkZ = chunkZ; ++ } ++ } ++ ++ BlockState blockstate = currChunk.getBlockState(blockX, blockY, blockZ); ++ if (!blockstate.isDestroyable() || this.level.isOutsideBuildHeight(blockY)) { ++ break; ++ } else { ++ FluidState fluid = blockstate.getFluidState(); ++ if (blockstate.isAir() && fluid.isEmpty()) { ++ prevBlockResistance = 0.0f; ++ continue; ++ } ++ ++ mutableBlockPos.set(blockX, blockY, blockZ); ++ Optional optional = this.damageCalculator.getBlockExplosionResistance( ++ this, this.level, mutableBlockPos, blockstate, fluid ++ ); ++ ++ if (optional.isPresent()) { ++ prevBlockResistance = (optional.get() + 0.3F) * 0.3F; ++ } else { ++ prevBlockResistance = 0.0f; ++ continue; ++ } ++ } ++ ++ power -= prevBlockResistance; ++ if (power > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, mutableBlockPos, blockstate, power)) { ++ if (positions.add(mutableBlockPos.asLong())) { ++ BlockPos explodedPosition = mutableBlockPos.immutable(); ++ this.toBlow.add(explodedPosition); ++ // Paper start - prevent headless pistons from forming ++ if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && blockstate.getBlock() == Blocks.MOVING_PISTON) { ++ BlockEntity extension = this.level.getBlockEntity(explodedPosition); ++ if (extension instanceof net.minecraft.world.level.block.piston.PistonMovingBlockEntity blockEntity && blockEntity.isSourcePiston()) { ++ net.minecraft.core.Direction direction = blockstate.getValue(net.minecraft.world.level.block.piston.PistonHeadBlock.FACING); ++ this.toBlow.add(explodedPosition.relative(direction.getOpposite())); ++ } ++ } ++ // Paper end ++ } ++ } ++ } + } -+ this.locateAndImpactEntities(blockCache); -+ this.clearBlockCache(); + } + -+ protected final void searchForBlocks(final ExplosionBlockCache[] blockCache, final ExplosionBlockCache initialCache) { -+ Set set = Sets.newHashSet(); -+ // Sakura end - optimise paper explosions - // only ~1/3rd of the loop iterations in vanilla will result in a ray, as it is iterating the perimeter of - // a 16x16x16 cube - // we can cache the rays and their normals as well, so that we eliminate the excess iterations / checks and -@@ -541,23 +587,63 @@ public class Explosion { - } - - this.toBlow.addAll(set); -- float f2 = this.radius * 2.0F; -+ // Sakura start - optimise paper explosions -+ } - -- i = Mth.floor(this.x - (double) f2 - 1.0D); -- j = Mth.floor(this.x + (double) f2 + 1.0D); -+ protected final AABB getExplosionBounds(float f2) { -+ // Sakura - moved into locateAndImpactEntities -+ -+ int i = Mth.floor(this.x - (double) f2 - 1.0D); -+ int j = Mth.floor(this.x + (double) f2 + 1.0D); - int l = Mth.floor(this.y - (double) f2 - 1.0D); - int i1 = Mth.floor(this.y + (double) f2 + 1.0D); - int j1 = Mth.floor(this.z - (double) f2 - 1.0D); - int k1 = Mth.floor(this.z + (double) f2 + 1.0D); -- List list = this.level.getEntities(this.source, new AABB((double) i, (double) l, (double) j1, (double) j, (double) i1, (double) k1), (com.google.common.base.Predicate) entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities -- Vec3 vec3d = new Vec3(this.x, this.y, this.z); -- Iterator iterator = list.iterator(); -+ return new AABB((double) i, (double) l, (double) j1, (double) j, (double) i1, (double) k1); -+ } - -+ protected final void locateAndImpactEntities(final ExplosionBlockCache[] blockCache) { -+ float f2 = this.radius * 2.0F; -+ ++ protected final void locateAndImpactEntities(float f2) { + Vec3 vec3d = new Vec3(this.x, this.y, this.z); - final BlockPos.MutableBlockPos blockPos = new BlockPos.MutableBlockPos(); // Paper - optimise explosions - -- while (iterator.hasNext()) { -- Entity entity = (Entity) iterator.next(); + int minSection = io.papermc.paper.util.WorldUtil.getMinSection(this.level); + int maxSection = io.papermc.paper.util.WorldUtil.getMaxSection(this.level); + @@ -128,88 +174,157 @@ index 8fd87dc8f925a160bf390b05040110735f2a145b..e5335d64799005a4cdd2cb11cef637f2 + int maxChunkY = Mth.clamp(Mth.floor(this.y + f2) >> 4, minSection, maxSection); + int minChunkZ = Mth.floor(this.z - f2) >> 4; + int maxChunkZ = Mth.floor(this.z + f2) >> 4; - -+ io.papermc.paper.chunk.system.entity.EntityLookup entityLookup = ((net.minecraft.server.level.ServerLevel) this.level).getEntityLookup(); + ++ io.papermc.paper.chunk.system.entity.EntityLookup entityLookup = ((net.minecraft.server.level.ServerLevel) this.level).getEntityLookup(); + for (int chunkX = minChunkX; chunkX <= maxChunkX; ++chunkX) { + for (int chunkZ = minChunkZ; chunkZ <= maxChunkZ; ++chunkZ) { + io.papermc.paper.world.ChunkEntitySlices chunk = entityLookup.getChunk(chunkX, chunkZ); + if (chunk == null) continue; // empty slice + + for (int chunkY = minChunkY; chunkY <= maxChunkY; ++chunkY) { -+ this.impactEntities(blockCache, blockPos, f2, vec3d, chunk.getSectionEntities(chunkY)); ++ this.impactEntities(chunk.getSectionEntities(chunkY), vec3d, f2); + } + } + } + } + -+ protected final void impactEntities(final ExplosionBlockCache[] blockCache, final BlockPos.MutableBlockPos blockPos, float f2, Vec3 vec3d, Entity[] entities) { ++ protected final void impactEntities(Entity[] entities, Vec3 vec3d, float f2) { + for (int i = 0; i < entities.length; i++) { + Entity entity = entities[i]; + if (entity == null) break; // end of entity section -+ this.impactEntity(blockCache, blockPos, f2, vec3d, entity); ++ this.impactEntity(entity, vec3d, f2); + if (entity != entities[i]) i--; // entities can be removed mid-explosion + } + } + -+ protected final void impactEntity(final ExplosionBlockCache[] blockCache, final BlockPos.MutableBlockPos blockPos, float f2, Vec3 vec3d, Entity entity) { -+ if (entity.isAlive() && !entity.isSpectator()) { // Paper - Fix lag from explosions processing dead entities -+ // Sakura end - optimise paper explosions - if (!entity.ignoreExplosion(this)) { - double d7 = Math.sqrt(entity.distanceToSqr(vec3d)) / (double) f2; + private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) { ++ if (entity instanceof net.minecraft.world.entity.item.PrimedTnt) { ++ return EXPLOSION_DAMAGE_CALCULATOR; ++ } ++ // Sakura end - optimise vanilla explosions + return (ExplosionDamageCalculator) (entity == null ? Explosion.EXPLOSION_DAMAGE_CALCULATOR : new EntityBasedExplosionDamageCalculator(entity)); + } -@@ -581,24 +667,27 @@ public class Explosion { - // - Damaging EntityEnderDragon does nothing - // - EntityEnderDragon hitbock always covers the other parts and is therefore always present - if (entity instanceof EnderDragonPart) { -- continue; -+ return; // Sakura - optimise paper explosions - } +@@ -148,76 +337,34 @@ public class Explosion { + int i; + int j; - entity.lastDamageCancelled = false; - - if (entity instanceof EnderDragon) { -+ // Sakura start - optimise paper explosions -+ AABB bounds = this.getExplosionBounds(f2); - for (EnderDragonPart entityComplexPart : ((EnderDragon) entity).subEntities) { - // Calculate damage separately for each EntityComplexPart -- if (list.contains(entityComplexPart)) { -- entityComplexPart.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entityComplexPart, getSeenFraction(vec3d, entityComplexPart, blockCache, blockPos))); // Paper - actually optimise explosions and use the right entity to calculate the damage -+ if (entityComplexPart.getBoundingBox().intersects(bounds)) { -+ entityComplexPart.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entityComplexPart, getBlockDensity(vec3d, entityComplexPart, blockCache, blockPos))); // Paper - actually optimise explosions and use the right entity to calculate the damage - } - } - } else { -- entity.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, getSeenFraction(vec3d, entity, blockCache, blockPos))); // Paper - actually optimise explosions -+ entity.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity, getBlockDensity(vec3d, entity, blockCache, blockPos))); // Paper - actually optimise explosions -+ // Sakura end - optimise paper explosions - } - - if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled -- continue; -+ return; // Sakura - optimise paper explosions - } - // CraftBukkit end - } -@@ -631,7 +720,7 @@ public class Explosion { - final org.bukkit.entity.Entity hitBy = this.damageSource.getEntity() != null ? this.damageSource.getEntity().getBukkitEntity() : this.source.getBukkitEntity(); - com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent paperEvent = new com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent(((LivingEntity) entity).getBukkitLivingEntity(), hitBy, (float) event.getForce(), org.bukkit.craftbukkit.util.CraftVector.toBukkit(vec3d1)); - if (!paperEvent.callEvent()) { -- continue; -+ return; // Sakura - optimise paper explosions - } - vec3d1 = org.bukkit.craftbukkit.util.CraftVector.toNMS(paperEvent.getAcceleration()); - } -@@ -653,8 +742,12 @@ public class Explosion { - } - } - } -+ // Sakura start - optimise paper explosions +- for (int k = 0; k < 16; ++k) { +- for (i = 0; i < 16; ++i) { +- for (j = 0; j < 16; ++j) { +- if (k == 0 || k == 15 || i == 0 || i == 15 || j == 0 || j == 15) { +- double d0 = (double) ((float) k / 15.0F * 2.0F - 1.0F); +- double d1 = (double) ((float) i / 15.0F * 2.0F - 1.0F); +- double d2 = (double) ((float) j / 15.0F * 2.0F - 1.0F); +- double d3 = Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2); +- +- d0 /= d3; +- d1 /= d3; +- d2 /= d3; +- float f = this.radius * (0.7F + this.level.random.nextFloat() * 0.6F); +- double d4 = this.x; +- double d5 = this.y; +- double d6 = this.z; +- +- for (float f1 = 0.3F; f > 0.0F; f -= 0.22500001F) { +- BlockPos blockposition = new BlockPos(d4, d5, d6); +- BlockState iblockdata = this.level.getBlockState(blockposition); +- if (!iblockdata.isDestroyable()) continue; // Paper +- FluidState fluid = iblockdata.getFluidState(); // Paper +- +- if (!this.level.isInWorldBounds(blockposition)) { +- break; +- } +- +- Optional optional = this.damageCalculator.getBlockExplosionResistance(this, this.level, blockposition, iblockdata, fluid); +- +- if (optional.isPresent()) { +- f -= ((Float) optional.get() + 0.3F) * 0.3F; +- } +- +- if (f > 0.0F && this.damageCalculator.shouldBlockExplode(this, this.level, blockposition, iblockdata, f)) { +- set.add(blockposition); +- // Paper start - prevent headless pistons from forming +- if (!io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.allowHeadlessPistons && iblockdata.getBlock() == Blocks.MOVING_PISTON) { +- BlockEntity extension = this.level.getBlockEntity(blockposition); +- if (extension instanceof net.minecraft.world.level.block.piston.PistonMovingBlockEntity blockEntity && blockEntity.isSourcePiston()) { +- net.minecraft.core.Direction direction = iblockdata.getValue(net.minecraft.world.level.block.piston.PistonHeadBlock.FACING); +- set.add(blockposition.relative(direction.getOpposite())); +- } +- } +- // Paper end +- } +- +- d4 += d0 * 0.30000001192092896D; +- d5 += d1 * 0.30000001192092896D; +- d6 += d2 * 0.30000001192092896D; +- } +- } +- } +- } ++ // Sakura start - optimise vanilla explosions ++ BlockPos explosionBlockPos = new BlockPos(this.x, this.y, this.z); ++ BlockState blockstate = this.level.getBlockState(explosionBlockPos); ++ float resistance = blockstate.getBlock().getExplosionResistance(); ++ if ((resistance + 0.3f) * 0.3f < (this.radius * 1.3f) && this.blockInteraction != BlockInteraction.KEEP) { ++ this.searchForBlocks(); } + + this.toBlow.addAll(set); + float f2 = this.radius * 2.0F; ++ this.locateAndImpactEntities(f2); + } -+ protected void clearBlockCache() { -+ // Sakura end - optimise paper explosions - this.blockCache = null; // Paper - optimise explosions - this.chunkPosCache = null; // Paper - optimise explosions - this.chunkCache = null; // Paper - optimise explosions ++ protected final AABB getExplosionBounds(float f2) { ++ int i; ++ int j; + i = Mth.floor(this.x - (double) f2 - 1.0D); + j = Mth.floor(this.x + (double) f2 + 1.0D); + int l = Mth.floor(this.y - (double) f2 - 1.0D); + int i1 = Mth.floor(this.y + (double) f2 + 1.0D); + int j1 = Mth.floor(this.z - (double) f2 - 1.0D); + int k1 = Mth.floor(this.z + (double) f2 + 1.0D); +- List list = this.level.getEntities(this.source, new AABB((double) i, (double) l, (double) j1, (double) j, (double) i1, (double) k1), (com.google.common.base.Predicate) entity -> entity.isAlive() && !entity.isSpectator()); // Paper - Fix lag from explosions processing dead entities +- Vec3 vec3d = new Vec3(this.x, this.y, this.z); +- +- for (int l1 = 0; l1 < list.size(); ++l1) { +- Entity entity = (Entity) list.get(l1); ++ return new AABB((double) i, (double) l, (double) j1, (double) j, (double) i1, (double) k1); ++ } + ++ protected final void impactEntity(Entity entity, Vec3 vec3d, float f2) { ++ if (entity.isAlive() && !entity.isSpectator()) { // Paper - Fix lag from explosions processing dead entities ++ // Sakura end - optimise vanilla explosions + if (!entity.ignoreExplosion()) { + double d7 = Math.sqrt(entity.distanceToSqr(vec3d)) / (double) f2; + +@@ -243,17 +390,18 @@ public class Explosion { + // - Damaging EntityEnderDragon does nothing + // - EntityEnderDragon hitbock always covers the other parts and is therefore always present + if (entity instanceof EnderDragonPart) { +- continue; ++ return; // Sakura - optimise vanilla explosions + } + + CraftEventFactory.entityDamage = this.source; + entity.lastDamageCancelled = false; + + if (entity instanceof EnderDragon) { ++ final AABB bounds = this.getExplosionBounds(f2); // Sakura - optimise vanilla explosions + for (EnderDragonPart entityComplexPart : ((EnderDragon) entity).subEntities) { + // Calculate damage separately for each EntityComplexPart + double d7part; +- if (list.contains(entityComplexPart) && (d7part = Math.sqrt(entityComplexPart.distanceToSqr(vec3d)) / f2) <= 1.0D) { ++ if (entityComplexPart.getBoundingBox().intersects(bounds) && (d7part = Math.sqrt(entityComplexPart.distanceToSqr(vec3d)) / f2) <= 1.0D) { // Sakura - optimise vanilla explosions + double d13part = (1.0D - d7part) * Explosion.getSeenPercent(vec3d, entityComplexPart); + entityComplexPart.hurt(this.getDamageSource(), (float) ((int) ((d13part * d13part + d13part) / 2.0D * 7.0D * (double) f2 + 1.0D))); + } +@@ -264,7 +412,7 @@ public class Explosion { + + CraftEventFactory.entityDamage = null; + if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled +- continue; ++ return; // Sakura - optimise vanilla explosions + } + // CraftBukkit end + double d14 = d13; diff --git a/patches/server/0017-Store-Entity-Data-State.patch b/patches/server/0017-Store-Entity-Data-State.patch index abe9a51..14a2c8f 100644 --- a/patches/server/0017-Store-Entity-Data-State.patch +++ b/patches/server/0017-Store-Entity-Data-State.patch @@ -6,23 +6,19 @@ Subject: [PATCH] Store Entity Data/State diff --git a/src/main/java/me/samsuik/sakura/entity/EntityState.java b/src/main/java/me/samsuik/sakura/entity/EntityState.java new file mode 100644 -index 0000000000000000000000000000000000000000..c9f2c5ae57878283e8c8bc3847fe63b98f4e8d10 +index 0000000000000000000000000000000000000000..5b72f13e6fb5d9999940e640c0341c2e9defb961 --- /dev/null +++ b/src/main/java/me/samsuik/sakura/entity/EntityState.java -@@ -0,0 +1,41 @@ +@@ -0,0 +1,35 @@ +package me.samsuik.sakura.entity; + -+import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; + -+import java.util.Optional; -+ -+public record EntityState(Vec3 position, Vec3 momentum, AABB bb, Vec3 stuckSpeed, Optional supportingPos, boolean onGround, float fallDistance) { -+ ++public record EntityState(Vec3 position, Vec3 momentum, AABB bb, Vec3 stuckSpeed, boolean onGround, float fallDistance) { + public static EntityState of(Entity entity) { -+ return new EntityState(entity.position(), entity.getDeltaMovement(), entity.getBoundingBox(), entity.stuckSpeedMultiplier(), entity.mainSupportingBlockPos, entity.onGround(), entity.fallDistance); ++ return new EntityState(entity.position(), entity.getDeltaMovement(), entity.getBoundingBox(), entity.stuckSpeedMultiplier(), entity.onGround, entity.fallDistance); + } + + public void apply(Entity entity) { @@ -33,7 +29,6 @@ index 0000000000000000000000000000000000000000..c9f2c5ae57878283e8c8bc3847fe63b9 + //noinspection DataFlowIssue + entity.makeStuckInBlock(null, stuckSpeed); + entity.onGround = onGround; -+ entity.mainSupportingBlockPos = supportingPos; + entity.fallDistance = fallDistance; + } + @@ -49,16 +44,15 @@ index 0000000000000000000000000000000000000000..c9f2c5ae57878283e8c8bc3847fe63b9 + // If there are any related issues uncomment this line of code. + // && entity.getBoundingBox().equals(bb); + } -+ +} diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 95137b2a064e98e476ef1bc56b0d2b2920f18d17..e657b5f88195f1db2cb9a9a97f255ff23992cadd 100644 +index 35c4253e1ee951c31958bb9275a4f497fd5b16bb..106e03e0eae24f47a49d2495e98cb30195b27013 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -584,6 +584,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - return flags; - } - // Sakura end - load chunks on cannon entity movement +@@ -546,6 +546,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + public boolean isFallingBlock; + // Sakura end - visibility api and command + public boolean loadChunks = false; // Sakura - load chunks on cannon entity movement + // Sakura start - store entity data/state + private @Nullable me.samsuik.sakura.entity.EntityState entityState = null; + @@ -82,10 +76,10 @@ index 95137b2a064e98e476ef1bc56b0d2b2920f18d17..e657b5f88195f1db2cb9a9a97f255ff2 public Entity(EntityType type, Level world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index dc8d34adac1a2834777a8fe1fe7f142e0b13c0bf..684fd53a34fae43cd916a6f0a5cf38a2505d9bfe 100644 +index 00ebe6b2e3068a3b9c1c4a7566685191f21ed379..d80cdbbd9cd569e6db31950f05695c1cf476be3c 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -1330,6 +1330,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -932,6 +932,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public void guardEntityTick(Consumer tickConsumer, T entity) { try { diff --git a/patches/server/0018-Merge-Cannon-Entities.patch b/patches/server/0018-Merge-Cannon-Entities.patch index 5dc1c71..c9f34a1 100644 --- a/patches/server/0018-Merge-Cannon-Entities.patch +++ b/patches/server/0018-Merge-Cannon-Entities.patch @@ -169,30 +169,30 @@ index 0000000000000000000000000000000000000000..e63935c17e213bf60571d120ad9ce311 + +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 3c98362624e1b02b6b028db95564254e044c7b0d..f78881fcf186c44da243c2f31ff855b878e172cf 100644 +index 321bd1d6c2cbf8384b08708abb837ed3ad4a0078..1358f800a29ef15163442331100816bb418ae3f6 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1748,6 +1748,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { if (!entity.isRemoved()) { if (false && this.shouldDiscardEntity(entity)) { // CraftBukkit - We prevent spawning in general, so this butchering is not needed -@@ -912,6 +913,15 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -727,6 +728,15 @@ public class ServerLevel extends Level implements WorldGenLevel { entity.stopRiding(); } @@ -209,10 +209,10 @@ index 55e0be135ec084ee7ebe6bc7bb9323519e0cd864..51fa57e8b9d5c9ee563ec3608a437c69 this.guardEntityTick(this::tickNonPassenger, entity); gameprofilerfiller.pop(); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index e657b5f88195f1db2cb9a9a97f255ff23992cadd..c10f6574cc08aafe34a63c803e55e406b3d972c6 100644 +index 106e03e0eae24f47a49d2495e98cb30195b27013..c34e4077ba1c8768d3ed8f32a14df46a32009ab8 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -603,6 +603,120 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -565,6 +565,119 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return to.entityState() != null && to.entityState().isCurrentState(this); } // Sakura end - store entity data/state @@ -316,24 +316,23 @@ index e657b5f88195f1db2cb9a9a97f255ff23992cadd..c10f6574cc08aafe34a63c803e55e406 + mergeList.clear(); // clear the list to stop our tracking when merging + stacked = 0; // prevent any possible duplication + -+ discard(null); // MERGE is appropriate here but plugins may not expect tnt or falling blocks to merge -+ -+ updateEntityHandle(entity); ++ this.discard(); // MERGE is appropriate here but plugins may not expect tnt or falling blocks to merge ++ this.updateEntityHandle(entity); + } + -+ public void updateEntityHandle(Entity entity) { ++ public final void updateEntityHandle(Entity entity) { + // update api handle, this is so cannondebug can function + //noinspection ConstantValue -+ if (bukkitEntity != null) { -+ bukkitEntity.setHandle(entity); -+ bukkitEntity = entity.bukkitEntity; ++ if (this.bukkitEntity != null) { ++ this.bukkitEntity.setHandle(entity); ++ this.bukkitEntity = entity.bukkitEntity; + } + } + // Sakura end - cannon entity merging public Entity(EntityType type, Level world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -651,6 +765,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -611,6 +724,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.getEntityData().registrationLocked = true; // Spigot this.setPos(0.0D, 0.0D, 0.0D); this.eyeHeight = this.getEyeHeight(net.minecraft.world.entity.Pose.STANDING, this.dimensions); @@ -341,19 +340,19 @@ index e657b5f88195f1db2cb9a9a97f255ff23992cadd..c10f6574cc08aafe34a63c803e55e406 } public boolean isColliding(BlockPos pos, BlockState state) { -@@ -2533,6 +2648,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - nbttagcompound.putBoolean("Paper.FreezeLock", true); +@@ -2317,6 +2431,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + nbt.putBoolean("Paper.FreezeLock", true); } // Paper end + // Sakura start + if (stacked > 0) { -+ nbttagcompound.putInt("Sakura.Stacked", stacked); ++ nbt.putInt("Sakura.Stacked", stacked); + } + // Sakura end - return nbttagcompound; + return nbt; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); -@@ -2680,6 +2800,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -2484,6 +2603,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { freezeLocked = nbt.getBoolean("Paper.FreezeLock"); } // Paper end @@ -365,23 +364,23 @@ index e657b5f88195f1db2cb9a9a97f255ff23992cadd..c10f6574cc08aafe34a63c803e55e406 } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); -@@ -4889,6 +5014,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4529,6 +4653,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + return; + } // Paper end - rewrite chunk system - CraftEventFactory.callEntityRemoveEvent(this, cause); - // CraftBukkit end + // Sakura start -+ if (entity_removalreason == RemovalReason.DISCARDED && !mergeList.isEmpty()) { ++ if (reason == RemovalReason.DISCARDED && !mergeList.isEmpty()) { + level.mergeHistory.markPositions(this); + } + // Sakura end - final boolean alreadyRemoved = this.removalReason != null; // Paper - Folia schedulers if (this.removalReason == null) { - this.removalReason = entity_removalreason; + this.removalReason = reason; + } 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 4efdb2c114c96c32ce33593d35552c1c3da53e56..66b6250dc692e1222ac1661cdd206a1094049a15 100644 +index 6b85eecde57a809391d531bb11d189d0a25ccfdc..2965d963ca7eaf7bfd010094c08aa8b80af79a13 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -133,6 +133,60 @@ public class FallingBlockEntity extends Entity { +@@ -129,6 +129,60 @@ public class FallingBlockEntity extends Entity { return !this.isRemoved(); } @@ -404,7 +403,7 @@ index 4efdb2c114c96c32ce33593d35552c1c3da53e56..66b6250dc692e1222ac1661cdd206a10 + + while (stacked-- >= 1) { + // Unlike PrimedTnt we have to try respawn each stacked entity -+ FallingBlockEntity fallingBlock = new FallingBlockEntity(EntityType.FALLING_BLOCK, level()); ++ FallingBlockEntity fallingBlock = new FallingBlockEntity(EntityType.FALLING_BLOCK, this.level); + + // Try to stack the falling block + this.entityState().apply(fallingBlock); @@ -420,7 +419,7 @@ index 4efdb2c114c96c32ce33593d35552c1c3da53e56..66b6250dc692e1222ac1661cdd206a10 + fallingBlock.entityState().apply(this); + break; + } else if (stacked == 0) { -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); ++ this.discard(); + } + } + @@ -441,20 +440,20 @@ index 4efdb2c114c96c32ce33593d35552c1c3da53e56..66b6250dc692e1222ac1661cdd206a10 + @Override public void tick() { - if (this.blockState.isAir()) { -@@ -200,6 +254,7 @@ public class FallingBlockEntity extends Entity { + // Paper start - fix sand duping +@@ -208,6 +262,7 @@ public class FallingBlockEntity extends Entity { return; } // CraftBukkit end + if (this.respawnMerged()) return; // Sakura - if (this.level().setBlock(blockposition, this.blockState, 3)) { - ((ServerLevel) this.level()).getChunkSource().chunkMap.broadcast(this, new ClientboundBlockUpdatePacket(blockposition, this.level().getBlockState(blockposition))); - this.discard(EntityRemoveEvent.Cause.DESPAWN); + if (this.level.setBlock(blockposition, this.blockState, 3)) { + ((ServerLevel) this.level).getChunkSource().chunkMap.broadcast(this, new ClientboundBlockUpdatePacket(blockposition, this.level.getBlockState(blockposition))); + this.discard(); diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index 7ebcd07c40e25fb909d7eec81820702181df1b5d..284ab0a2add55394f42fc0b5e62748ba1b629531 100644 +index c2f04fca63ebef48a3092b60c703277abcb9b586..b9ee3115ea6f2929d8cd66ab189acc1614126574 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -72,6 +72,44 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -59,6 +59,44 @@ public class PrimedTnt extends Entity { return !this.isRemoved(); } @@ -477,7 +476,7 @@ index 7ebcd07c40e25fb909d7eec81820702181df1b5d..284ab0a2add55394f42fc0b5e62748ba + protected boolean respawnMerged() { + if (stacked <= 1) return false; + -+ PrimedTnt tnt = new PrimedTnt(EntityType.TNT, level()); ++ PrimedTnt tnt = new PrimedTnt(EntityType.TNT, this.level); + + while (stacked-- > 1) { + this.setFuse(100); // Prevent unwanted explosions while ticking @@ -498,42 +497,42 @@ index 7ebcd07c40e25fb909d7eec81820702181df1b5d..284ab0a2add55394f42fc0b5e62748ba + @Override public void tick() { - if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot -@@ -97,6 +135,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { + if (level.spigotConfig.maxTntTicksPerTick > 0 && ++level.spigotConfig.currentPrimedTnt > level.spigotConfig.maxTntTicksPerTick) { +@@ -86,6 +124,7 @@ public class PrimedTnt extends Entity { if (i <= 0) { // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event // this.discard(); + this.respawnMerged(); // Sakura - if (!this.level().isClientSide) { + if (!this.level.isClientSide) { this.explode(); } diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 684fd53a34fae43cd916a6f0a5cf38a2505d9bfe..9507b2419834ace4f71a781ad90284af5e4d8aa1 100644 +index d80cdbbd9cd569e6db31950f05695c1cf476be3c..05ee07f06721b16801ae7420da7705b64db52eed 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -229,6 +229,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -283,6 +283,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public abstract ResourceKey getTypeKey(); public final it.unimi.dsi.fastutil.longs.Long2IntMap minimalTNT = new it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap(); // Sakura - visibility api + public final me.samsuik.sakura.entity.merge.MergeHistory mergeHistory = new me.samsuik.sakura.entity.merge.MergeHistory(); // Sakura - cannon entity merging - protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, Supplier sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - create paper world config; Async-Anti-Xray: Pass executor + protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, Supplier sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - Async-Anti-Xray - Pass executor this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot diff --git a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java -index 0d573c05f4f8838d4492f749ca473f7a9e8d60dd..b88dc572f6fbd7642f86196bf3525ad33686a64b 100644 +index caa0fbe5cad9cdc11d6e4af92bc627990cd8204c..6923a34e82e49004b29a77e57fea8c2a00180299 100644 --- a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java -@@ -88,7 +88,7 @@ public abstract class BasePressurePlateBlock extends Block { +@@ -79,7 +79,7 @@ public abstract class BasePressurePlateBlock extends Block { } - private void checkPressed(@Nullable Entity entity, Level world, BlockPos pos, BlockState state, int output) { + protected void checkPressed(@Nullable Entity entity, Level world, BlockPos pos, BlockState state, int output) { - int j = this.getSignalStrength(world, pos); + int j = this.getSignalStrength(world, pos, output == 0); // Sakura - cannon entity merging boolean flag = output > 0; boolean flag1 = j > 0; -@@ -170,6 +170,12 @@ public abstract class BasePressurePlateBlock extends Block { - })); // CraftBukkit +@@ -158,6 +158,12 @@ public abstract class BasePressurePlateBlock extends Block { + return PushReaction.DESTROY; } + // Sakura start - cannon entity merging @@ -546,10 +545,10 @@ index 0d573c05f4f8838d4492f749ca473f7a9e8d60dd..b88dc572f6fbd7642f86196bf3525ad3 protected abstract int getSignalForState(BlockState state); diff --git a/src/main/java/net/minecraft/world/level/block/WeightedPressurePlateBlock.java b/src/main/java/net/minecraft/world/level/block/WeightedPressurePlateBlock.java -index 05bf23bd9ec951840ffceb68638458de02ad0063..ade85fb5a26da9272d392f24318ce6360ceb6414 100644 +index e3bcb7fc520abcb1854d89b65ebc947cc885caa6..f9786ba3bead763e4f880b99e0e0cae64fb62613 100644 --- a/src/main/java/net/minecraft/world/level/block/WeightedPressurePlateBlock.java +++ b/src/main/java/net/minecraft/world/level/block/WeightedPressurePlateBlock.java -@@ -42,6 +42,11 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock { +@@ -32,6 +32,11 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock { @Override protected int getSignalStrength(Level world, BlockPos pos) { @@ -559,9 +558,9 @@ index 05bf23bd9ec951840ffceb68638458de02ad0063..ade85fb5a26da9272d392f24318ce636 + protected final int getSignalStrength(Level world, BlockPos pos, boolean entityInside) { + // Sakura end - cannon entity merging // CraftBukkit start - // int i = Math.min(getEntityCount(world, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition), Entity.class), this.maxWeight); + // int i = Math.min(world.getEntitiesOfClass(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition)).size(), this.maxWeight); int i = 0; -@@ -57,7 +62,7 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock { +@@ -51,7 +56,7 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock { // We only want to block turning the plate on if all events are cancelled if (!cancellable.isCancelled()) { @@ -571,7 +570,7 @@ index 05bf23bd9ec951840ffceb68638458de02ad0063..ade85fb5a26da9272d392f24318ce636 } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java -index 1359d25a32b4a5d5e8e68ce737bd19f7b5afaf69..0afa2cfb04b5097788927076669e85fe24041df9 100644 +index 87c413c2f3b59ae9ef36e5becc10b29a81348022..65bac64214112ebd9e067202fe13293abe10559d 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java @@ -14,6 +14,28 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock { @@ -602,12 +601,12 @@ index 1359d25a32b4a5d5e8e68ce737bd19f7b5afaf69..0afa2cfb04b5097788927076669e85fe + @Override public FallingBlockEntity getHandle() { - return (FallingBlockEntity) this.entity; + return (FallingBlockEntity) entity; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java -index dac3d34677688ac560bc1be2087a08479ef71b87..3e80513263236d56019e3402c52f4a3677c83c76 100644 +index 06540d3771949daff641e518219090559f363959..9b03ba0b3a7b491fafad5afae606cb6b8a6b53e6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java -@@ -12,6 +12,28 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed { +@@ -13,6 +13,28 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed { super(server, entity); } diff --git a/patches/server/0019-Replace-explosion-density-cache.patch b/patches/server/0019-Replace-explosion-density-cache.patch index f0300fb..233bcc9 100644 --- a/patches/server/0019-Replace-explosion-density-cache.patch +++ b/patches/server/0019-Replace-explosion-density-cache.patch @@ -129,71 +129,57 @@ index 0000000000000000000000000000000000000000..d7e24638f07f243502004970ab4ce646 + } +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index f78881fcf186c44da243c2f31ff855b878e172cf..62d54547fc8c1a9f7b19a2020b754a189ba7c52f 100644 +index 1358f800a29ef15163442331100816bb418ae3f6..f14abf532e9cd80e0a270826143c7489a4f4a5e4 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1749,6 +1749,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, Supplier sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - create paper world config; Async-Anti-Xray: Pass executor + protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, Supplier sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - Async-Anti-Xray - Pass executor this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot diff --git a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java -index 0d573c05f4f8838d4492f749ca473f7a9e8d60dd..88c2c2d9fbda662509b57535c718a0cb7aa72918 100644 +index 6923a34e82e49004b29a77e57fea8c2a00180299..56dce65e4d5070f7b08b07c4412ef95a54f3e1c7 100644 --- a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java -@@ -108,6 +108,11 @@ public abstract class BasePressurePlateBlock extends Block { +@@ -99,6 +99,11 @@ public abstract class BasePressurePlateBlock extends Block { if (output != j) { BlockState iblockdata1 = this.setSignalForState(state, j); @@ -237,28 +223,28 @@ index 0d573c05f4f8838d4492f749ca473f7a9e8d60dd..88c2c2d9fbda662509b57535c718a0cb this.updateNeighbours(world, pos); world.setBlocksDirty(pos, state, iblockdata1); diff --git a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java -index efd8d77a441fd334ea4c09c5e31c6d946c1ae0b7..b3ff822f97237be81edba4fc5aa90121307ede0b 100644 +index 004dce26ff073f1de52a84cd425c4f60fdab5e50..89928300608865a2cea6834fa0ac98a0796140e0 100644 --- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java -@@ -172,6 +172,11 @@ public class TripWireHookBlock extends Block { - blockposition1 = pos.relative(enumdirection, j); - Direction enumdirection1 = enumdirection.getOpposite(); +@@ -164,6 +164,11 @@ public class TripWireHookBlock extends Block { + blockposition1 = pos.relative(enumdirection, j); + Direction enumdirection1 = enumdirection.getOpposite(); -+ // Sakura start - explosion density cache -+ if (!world.paperConfig().environment.optimizeExplosions) { -+ world.densityCache.clear(-1); -+ } -+ // Sakura end - explosion density cache - world.setBlock(blockposition1, (BlockState) iblockdata3.setValue(TripWireHookBlock.FACING, enumdirection1), 3); - TripWireHookBlock.notifyNeighbors(block, world, blockposition1, enumdirection1); - TripWireHookBlock.emitState(world, blockposition1, flag4, flag5, flag2, flag3); ++ // Sakura start - explosion density cache ++ if (!world.paperConfig().environment.optimizeExplosions) { ++ world.densityCache.clear(-1); ++ } ++ // Sakura end - explosion density cache + world.setBlock(blockposition1, (BlockState) iblockdata3.setValue(TripWireHookBlock.FACING, enumdirection1), 3); + this.notifyNeighbors(world, blockposition1, enumdirection1); + this.emitState(world, blockposition1, flag4, flag5, flag2, flag3); diff --git a/src/main/java/net/minecraft/world/phys/AABB.java b/src/main/java/net/minecraft/world/phys/AABB.java -index 92394960fc76886f393cba02ac33c57739a4b383..f6c420fc86c08dcc49bfd56be6c47d2b32f813b6 100644 +index 68cc6f2a78a06293a29317fda72ab3ee79b3533a..a142bf12ef0b8c8d41cab846da2e161700f2db2b 100644 --- a/src/main/java/net/minecraft/world/phys/AABB.java +++ b/src/main/java/net/minecraft/world/phys/AABB.java -@@ -502,4 +502,28 @@ public class AABB { +@@ -367,4 +367,28 @@ public class AABB { public static AABB ofSize(Vec3 center, double dx, double dy, double dz) { - return new AABB(center.x - dx / 2.0, center.y - dy / 2.0, center.z - dz / 2.0, center.x + dx / 2.0, center.y + dy / 2.0, center.z + dz / 2.0); + return new AABB(center.x - dx / 2.0D, center.y - dy / 2.0D, center.z - dz / 2.0D, center.x + dx / 2.0D, center.y + dy / 2.0D, center.z + dz / 2.0D); } + + // Sakura start - explosion density cache diff --git a/patches/server/0020-Optimise-explosions-in-protected-regions.patch b/patches/server/0020-Optimise-explosions-in-protected-regions.patch index 36daf84..b8d3a28 100644 --- a/patches/server/0020-Optimise-explosions-in-protected-regions.patch +++ b/patches/server/0020-Optimise-explosions-in-protected-regions.patch @@ -5,13 +5,13 @@ Subject: [PATCH] Optimise explosions in protected regions diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 55f3f6bd77976f1ba4f7ac820a0333f1df82ab4d..fa1a06e6455390c3c945d988a3d4ee9a9ea92d38 100644 +index 212d0a2d61e8d8515820d85c511937bd17679c71..738015f5aa1e405623ad41ea4f039bde9a2ec572 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -415,6 +415,21 @@ public class Explosion { - return (float)missedRays / (float)totalRays; +@@ -281,6 +281,22 @@ public class Explosion { + } } - // Paper end - optimise collisions + + // Sakura start - optimise protected explosions + protected final boolean isRegionUnprotected() { + // As an optimisation, check if a plugin has cancelled or cleared the blockList. @@ -27,15 +27,16 @@ index 55f3f6bd77976f1ba4f7ac820a0333f1df82ab4d..fa1a06e6455390c3c945d988a3d4ee9a + return true; + } + // Sakura end - optimise protected explosions - ++ private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) { - return (ExplosionDamageCalculator) (entity == null ? Explosion.EXPLOSION_DAMAGE_CALCULATOR : new EntityBasedExplosionDamageCalculator(entity)); -@@ -506,7 +521,7 @@ public class Explosion { - initialCache = this.getOrCacheExplosionBlock(blockX, blockY, blockZ, key, true); + if (entity instanceof net.minecraft.world.entity.item.PrimedTnt) { + return EXPLOSION_DAMAGE_CALCULATOR; +@@ -350,7 +366,7 @@ public class Explosion { + BlockPos explosionBlockPos = new BlockPos(this.x, this.y, this.z); + BlockState blockstate = this.level.getBlockState(explosionBlockPos); + float resistance = blockstate.getBlock().getExplosionResistance(); +- if ((resistance + 0.3f) * 0.3f < (this.radius * 1.3f) && this.blockInteraction != BlockInteraction.KEEP) { ++ if ((resistance + 0.3f) * 0.3f < (this.radius * 1.3f) && this.blockInteraction != BlockInteraction.KEEP && this.isRegionUnprotected()) { // Sakura - optimise protected explosions + this.searchForBlocks(); } - // Sakura start - optimise paper explosions -- if (initialCache.resistance <= (this.radius * 1.3f) && this.interactsWithBlocks()) { -+ if (initialCache.resistance <= (this.radius * 1.3f) && this.interactsWithBlocks() && this.isRegionUnprotected()) { // Sakura - optimise protected explosions - this.searchForBlocks(blockCache, initialCache); - } - this.locateAndImpactEntities(blockCache); + diff --git a/patches/server/0021-Specialised-Explosions.patch b/patches/server/0021-Specialised-Explosions.patch index 87d57f6..1d02835 100644 --- a/patches/server/0021-Specialised-Explosions.patch +++ b/patches/server/0021-Specialised-Explosions.patch @@ -23,17 +23,15 @@ index 0fd814f1d65c111266a2b20f86561839a4cef755..932f7a0d030d2d4932e6e6d4a5805e9b if (index >= 0) { diff --git a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java new file mode 100644 -index 0000000000000000000000000000000000000000..8857449c2443b1c9fc97a43a5bd3f446056259c7 +index 0000000000000000000000000000000000000000..e654f48386e21e049facb6d90b356117af2bace6 --- /dev/null +++ b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java -@@ -0,0 +1,200 @@ +@@ -0,0 +1,176 @@ +package me.samsuik.sakura.explosion.special; + +import io.papermc.paper.util.WorldUtil; +import net.minecraft.core.BlockPos; -+import net.minecraft.core.particles.ParticleOptions; +import net.minecraft.server.level.ServerLevel; -+import net.minecraft.sounds.SoundEvent; +import net.minecraft.util.Mth; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; @@ -55,11 +53,9 @@ index 0000000000000000000000000000000000000000..8857449c2443b1c9fc97a43a5bd3f446 + protected Vec3 position; + protected final T cause; // preferred over source + private Vec3 impactPosition; -+ protected ExplosionBlockCache[] recentBlockCache; -+ protected final BlockPos.MutableBlockPos mutablePos = new BlockPos.MutableBlockPos(); + -+ public SpecialisedExplosion(Level world, T entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, BlockInteraction destructionType, ParticleOptions particle, ParticleOptions emitterParticle, SoundEvent soundEvent) { -+ super(world, entity, damageSource, behavior, x, y, z, power, createFire, destructionType, particle, emitterParticle, soundEvent); ++ public SpecialisedExplosion(Level world, T entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, BlockInteraction destructionType) { ++ super(world, entity, damageSource, behavior, x, y, z, power, createFire, destructionType); + this.level = (ServerLevel) world; + this.position = new Vec3(x, y, z); + this.cause = entity; @@ -73,23 +69,15 @@ index 0000000000000000000000000000000000000000..8857449c2443b1c9fc97a43a5bd3f446 + protected abstract void startExplosion(); + + @Override -+ protected final void clearBlockCache() { -+ super.clearBlockCache(); -+ this.recentBlockCache = null; -+ } -+ -+ @Override + @Deprecated + public final void explode() { -+ if (this.radius() < 0.1F) { ++ if (this.radius < 0.1F) { + // (radius < 0.1F) in bukkit is assumed to not be able to find any blocks or entities. + for (int i = 1; i < this.cause.getStacked(); ++i) { + this.finalizeExplosionAndParticles(); + } + } else { -+ this.recentBlockCache = this.createBlockCache(); + this.startExplosion(); // search for blocks, impact entities, finalise if necessary -+ this.clearBlockCache(); + } + } + @@ -111,7 +99,7 @@ index 0000000000000000000000000000000000000000..8857449c2443b1c9fc97a43a5bd3f446 + } + + if (!this.wasCanceled) { -+ this.level.notifyPlayersOfExplosion(this.x, this.y, this.z, this.radius(), this); ++ this.level.notifyPlayersOfExplosion(this.x, this.y, this.z, this.radius, this); + this.getHitPlayers().clear(); + } + @@ -119,19 +107,7 @@ index 0000000000000000000000000000000000000000..8857449c2443b1c9fc97a43a5bd3f446 + return destroyedBlocks; + } + -+ protected void postExplosion(List foundBlocks, boolean destroyedBlocks) { -+ // optimisation: Keep the block cache across explosions and invalidate any found blocks. -+ // This can help reduce block retrievals while block searching when there's a durable block, -+ // and when ray tracing for obstructions. This is disabled by default because plugins can -+ // change blocks in the explosion event. -+ if (this.level.sakuraConfig().cannons.explosion.useBlockCacheAcrossExplosions && !foundBlocks.isEmpty() && !destroyedBlocks) { -+ this.markBlocksInCacheAsExplodable(foundBlocks); -+ } else { -+ super.blockCache.clear(); -+ } -+ -+ java.util.Arrays.fill(this.recentBlockCache, null); -+ } ++ protected abstract void postExplosion(List foundBlocks, boolean destroyedBlocks); + + protected final void recalculateExplosionPosition() { + this.recalculateExplosionPosition(this.cause); @@ -176,7 +152,7 @@ index 0000000000000000000000000000000000000000..8857449c2443b1c9fc97a43a5bd3f446 + Entity entity = entities[i]; + if (entity == null) break; + -+ if (entity != source && !entity.ignoreExplosion(this)) { ++ if (entity != source && !entity.ignoreExplosion()) { + this.impactEntity(entity, position, potential, radius); + } + @@ -191,7 +167,7 @@ index 0000000000000000000000000000000000000000..8857449c2443b1c9fc97a43a5bd3f446 + this.impactCannonEntity(entity, pos, potential, radius); + } else { + for (int i = 0; i < potential; ++i) { -+ super.impactEntity(this.recentBlockCache, this.mutablePos, (float) radius, pos, entity); ++ super.impactEntity(entity, pos, (float) radius); + } + } + } @@ -209,7 +185,7 @@ index 0000000000000000000000000000000000000000..8857449c2443b1c9fc97a43a5bd3f446 + x /= distance; + y /= distance; + z /= distance; -+ double density = this.getBlockDensity(pos, entity, this.recentBlockCache, this.mutablePos); // Paper - Optimize explosions // Paper - optimise explosions ++ double density = this.getBlockDensity(pos, entity); // Paper - Optimize explosions + double exposure = (1.0D - distanceFromBottom) * density; + + if (exposure == 0.0) { @@ -229,10 +205,10 @@ index 0000000000000000000000000000000000000000..8857449c2443b1c9fc97a43a5bd3f446 +} diff --git a/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java new file mode 100644 -index 0000000000000000000000000000000000000000..51f6c04e2a3861369013a4fb2b193a9df6c961cf +index 0000000000000000000000000000000000000000..52c1990bd3bcfe0a3f6e70748fca42f3e3994da4 --- /dev/null +++ b/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java -@@ -0,0 +1,201 @@ +@@ -0,0 +1,192 @@ +package me.samsuik.sakura.explosion.special; + +import io.papermc.paper.util.maplist.IteratorSafeOrderedReferenceSet; @@ -240,15 +216,12 @@ index 0000000000000000000000000000000000000000..51f6c04e2a3861369013a4fb2b193a9d +import me.samsuik.sakura.entity.EntityState; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; -+import net.minecraft.core.particles.ParticleOptions; -+import net.minecraft.sounds.SoundEvent; -+import net.minecraft.util.Mth; +import net.minecraft.world.damagesource.DamageSource; +import net.minecraft.world.entity.Entity; -+import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.item.PrimedTnt; +import net.minecraft.world.level.ExplosionDamageCalculator; +import net.minecraft.world.level.Level; ++import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.bukkit.util.Vector; @@ -266,8 +239,8 @@ index 0000000000000000000000000000000000000000..51f6c04e2a3861369013a4fb2b193a9d + private int wrapped = 0; + private boolean moved = false; + -+ public TntExplosion(Level world, PrimedTnt tnt, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, BlockInteraction destructionType, ParticleOptions particle, ParticleOptions emitterParticle, SoundEvent soundEvent) { -+ super(world, tnt, damageSource, behavior, x, y, z, power, createFire, destructionType, particle, emitterParticle, soundEvent); ++ public TntExplosion(Level world, PrimedTnt tnt, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, BlockInteraction destructionType) { ++ super(world, tnt, damageSource, behavior, x, y, z, power, createFire, destructionType); + this.originalPosition = this.position; + this.bounds = new AABB(x, y, z, x, y, z); + } @@ -291,16 +264,11 @@ index 0000000000000000000000000000000000000000..51f6c04e2a3861369013a4fb2b193a9d + + private void midExplosion(Vec3 previousMomentum, boolean lastCycle) { + if (this.wrapped < FOUND_ALL_BLOCKS) { -+ final int blockX = Mth.floor(this.x); -+ final int blockY = Mth.floor(this.y); -+ final int blockZ = Mth.floor(this.z); -+ -+ final long key = BlockPos.asLong(blockX, blockY, blockZ); -+ -+ final ExplosionBlockCache initialCache = this.getOrCacheExplosionBlock(blockX, blockY, blockZ, key, true); -+ -+ if (initialCache.resistance <= (this.radius() * 1.3f) && this.interactsWithBlocks() && this.isRegionUnprotected()) { // Sakura - optimise protected explosions -+ this.searchForBlocks(this.recentBlockCache, initialCache); ++ BlockPos explosionBlockPos = new BlockPos(this.x, this.y, this.z); ++ BlockState blockstate = this.level.getBlockState(explosionBlockPos); ++ float resistance = blockstate.getBlock().getExplosionResistance(); ++ if ((resistance + 0.3f) * 0.3f < (this.radius * 1.3f) && this.interactsWithBlocks() && this.isRegionUnprotected()) { // Sakura - optimise protected explosions ++ this.searchForBlocks(); + } + } + @@ -327,7 +295,6 @@ index 0000000000000000000000000000000000000000..51f6c04e2a3861369013a4fb2b193a9d + + @Override + protected void postExplosion(List foundBlocks, boolean destroyedBlocks) { -+ super.postExplosion(foundBlocks, destroyedBlocks); + // Update wrapped, this is for tracking swinging and if blocks are found + if (this.wrapped >= 7) { + if (!destroyedBlocks && this.level.sakuraConfig().cannons.explosion.avoidRedundantBlockSearches) { @@ -347,7 +314,7 @@ index 0000000000000000000000000000000000000000..51f6c04e2a3861369013a4fb2b193a9d + Vector origin = this.getCauseOrigin(); // valid position to use while creating a temporary entity + PrimedTnt tnt = new PrimedTnt(this.level, origin.getX(), origin.getY(), origin.getZ(), null); + this.cause.entityState().apply(tnt); -+ this.impactCannonEntity(tnt, this.position, 1, this.radius() * 2.0f); ++ this.impactCannonEntity(tnt, this.position, 1, this.radius * 2.0f); + return EntityState.of(tnt); + } + @@ -361,7 +328,7 @@ index 0000000000000000000000000000000000000000..51f6c04e2a3861369013a4fb2b193a9d + } else { + double newMomentum = entityState.momentum().lengthSqr(); + double oldMomentum = this.cause.entityState().momentum().lengthSqr(); -+ hasMoved = oldMomentum <= Math.pow(this.radius() * 2.0 + 1.0, 2.0) || newMomentum <= oldMomentum; ++ hasMoved = oldMomentum <= Math.pow(this.radius * 2.0 + 1.0, 2.0) || newMomentum <= oldMomentum; + } + + // Keep track of entity state @@ -395,7 +362,7 @@ index 0000000000000000000000000000000000000000..51f6c04e2a3861369013a4fb2b193a9d + } + + private void locateAndImpactEntitiesInBounds() { -+ double radius = this.radius() * 2.0f; ++ double radius = this.radius * 2.0f; + AABB bb = this.bounds; + + Vec3 center = bb.getCenter(); @@ -417,7 +384,7 @@ index 0000000000000000000000000000000000000000..51f6c04e2a3861369013a4fb2b193a9d + Entity entity = entities[i]; + if (entity == null) break; + -+ if (entity != this.source && !entity.ignoreExplosion(this) && entity.distanceToSqr(center.x, center.y, center.z) <= maxDistanceSqr) { ++ if (entity != this.source && !entity.ignoreExplosion() && entity.distanceToSqr(center.x, center.y, center.z) <= maxDistanceSqr) { + this.impactEntity(entity, radius); + } + @@ -435,10 +402,10 @@ index 0000000000000000000000000000000000000000..51f6c04e2a3861369013a4fb2b193a9d + } +} diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 297ab4dde3cfef55bd9dca662f473c0652ca3b7b..6af0a91e5ae053330f80f40ea4369dff22f5d634 100644 +index 839ab14b901f7deae5c53626c16ff1e74b57a531..ab5472c27f94e196a2747466f8721173cef937fc 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -1957,6 +1957,12 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1752,6 +1752,12 @@ public class ServerLevel extends Level implements WorldGenLevel { explosion.clearToBlow(); } @@ -451,7 +418,7 @@ index 297ab4dde3cfef55bd9dca662f473c0652ca3b7b..6af0a91e5ae053330f80f40ea4369dff Iterator iterator = this.players.iterator(); while (iterator.hasNext()) { -@@ -1979,7 +1985,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1771,7 +1777,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } } @@ -461,10 +428,10 @@ index 297ab4dde3cfef55bd9dca662f473c0652ca3b7b..6af0a91e5ae053330f80f40ea4369dff @Override diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index 284ab0a2add55394f42fc0b5e62748ba1b629531..0c8775fd29fdc811c8a3becb484abf3ed92686c7 100644 +index b9ee3115ea6f2929d8cd66ab189acc1614126574..f3330d5219edfac9fd23b10e3f97e999fc3b5b0e 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -86,28 +86,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -73,28 +73,7 @@ public class PrimedTnt extends Entity { && (tnt.entityState().fallDistance() == fallDistance || tnt.entityState().fallDistance() > 2.5f && fallDistance > 2.5f); } @@ -473,7 +440,7 @@ index 284ab0a2add55394f42fc0b5e62748ba1b629531..0c8775fd29fdc811c8a3becb484abf3e - protected boolean respawnMerged() { - if (stacked <= 1) return false; - -- PrimedTnt tnt = new PrimedTnt(EntityType.TNT, level()); +- PrimedTnt tnt = new PrimedTnt(EntityType.TNT, this.level); - - while (stacked-- > 1) { - this.setFuse(100); // Prevent unwanted explosions while ticking @@ -495,10 +462,10 @@ index 284ab0a2add55394f42fc0b5e62748ba1b629531..0c8775fd29fdc811c8a3becb484abf3e @Override diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index c9cf9373d3eae4e54ae27fbb8993f858e91e98cc..27d17da5d560bbe97f088ecec4b95d2ad4a34bcb 100644 +index 738015f5aa1e405623ad41ea4f039bde9a2ec572..74cd5133a7944ecb7ab76a4d1be3b77214b64161 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -55,9 +55,11 @@ public class Explosion { +@@ -55,12 +55,14 @@ public class Explosion { private final Explosion.BlockInteraction blockInteraction; private final RandomSource random; private final Level level; @@ -512,108 +479,47 @@ index c9cf9373d3eae4e54ae27fbb8993f858e91e98cc..27d17da5d560bbe97f088ecec4b95d2a + // Sakura end - private -> protected @Nullable public final Entity source; - private final float radius; -@@ -185,7 +187,7 @@ public class Explosion { - // resistance = (res + 0.3F) * 0.3F; - // so for resistance = 0, we need res = -0.3F - private static final Float ZERO_RESISTANCE = Float.valueOf(-0.3f); -- private it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap blockCache = null; -+ protected it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap blockCache = null; // Sakura - private -> protected - - public static final class ExplosionBlockCache { - -@@ -212,7 +214,29 @@ public class Explosion { - private long[] chunkPosCache = null; - private net.minecraft.world.level.chunk.LevelChunk[] chunkCache = null; - -- private ExplosionBlockCache getOrCacheExplosionBlock(final int x, final int y, final int z, -+ // Sakura start - specialised explosions -+ protected final ExplosionBlockCache[] createBlockCache() { -+ this.blockCache = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>(); -+ -+ this.chunkPosCache = new long[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH]; -+ java.util.Arrays.fill(this.chunkPosCache, ChunkPos.INVALID_CHUNK_POS); -+ -+ this.chunkCache = new net.minecraft.world.level.chunk.LevelChunk[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH]; -+ -+ return new ExplosionBlockCache[BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH]; -+ } -+ -+ protected final void markBlocksInCacheAsExplodable(List blocks) { -+ for (BlockPos blow : blocks) { -+ ExplosionBlockCache cache = this.blockCache.get(blow.asLong()); -+ // May be null if the blockCache is cleared then retrieved from the recent block cache -+ if (cache != null) { -+ cache.shouldExplode = null; -+ } -+ } -+ } -+ // Sakura end - specialised explosions -+ protected final ExplosionBlockCache getOrCacheExplosionBlock(final int x, final int y, final int z, // Sakura - private -> protected - final long key, final boolean calculateResistance) { - ExplosionBlockCache ret = this.blockCache.get(key); - if (ret != null) { -@@ -310,7 +334,7 @@ public class Explosion { - (currZ & BLOCK_EXPLOSION_CACHE_MASK) << (BLOCK_EXPLOSION_CACHE_SHIFT + BLOCK_EXPLOSION_CACHE_SHIFT); - ExplosionBlockCache cachedBlock = blockCache[cacheKey]; - if (cachedBlock == null || cachedBlock.key != key) { -- blockCache[cacheKey] = cachedBlock = this.getOrCacheExplosionBlock(currX, currY, currZ, key, false); -+ blockCache[cacheKey] = cachedBlock = this.getOrCacheExplosionBlock(currX, currY, currZ, key, this.level.sakuraConfig().cannons.explosion.useBlockCacheAcrossExplosions); // Sakura - specialised explosions - } - - final BlockState blockState = cachedBlock.blockState; -@@ -501,14 +525,7 @@ public class Explosion { - int j; - - // Paper start - optimise explosions -- this.blockCache = new it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap<>(); -- -- this.chunkPosCache = new long[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH]; -- java.util.Arrays.fill(this.chunkPosCache, ChunkPos.INVALID_CHUNK_POS); -- -- this.chunkCache = new net.minecraft.world.level.chunk.LevelChunk[CHUNK_CACHE_WIDTH * CHUNK_CACHE_WIDTH]; -- -- final ExplosionBlockCache[] blockCache = new ExplosionBlockCache[BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH * BLOCK_EXPLOSION_CACHE_WIDTH]; -+ final ExplosionBlockCache[] blockCache = this.createBlockCache(); - // use initial cache value that is most likely to be used: the source position - final ExplosionBlockCache initialCache; - { -@@ -765,7 +782,10 @@ public class Explosion { +- private final float radius; ++ protected final float radius; // Sakura - private -> protected + private final DamageSource damageSource; + private final ExplosionDamageCalculator damageCalculator; + private final ObjectArrayList toBlow; +@@ -451,7 +453,10 @@ public class Explosion { Player entityhuman = (Player) entity; - if (!entityhuman.isSpectator() && (!entityhuman.isCreative() || !entityhuman.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback -- this.hitPlayers.put(entityhuman, vec3d1); + if (!entityhuman.isSpectator() && (!entityhuman.isCreative() || !entityhuman.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Disable explosion knockback +- this.hitPlayers.put(entityhuman, new Vec3(d8 * d13, d9 * d13, d10 * d13)); + // Sakura start - specialised explosions; tally player velocity -+ final Vec3 explosionImpact = vec3d1; ++ final Vec3 explosionImpact = new Vec3(d8 * d13, d9 * d13, d10 * d13); + this.hitPlayers.compute(entityhuman, (p, v) -> v != null ? v.add(explosionImpact) : explosionImpact); + // Sakura end - specialised explosions; tally player velocity } } } -@@ -998,7 +1018,7 @@ public class Explosion { +@@ -683,7 +688,7 @@ public class Explosion { private BlockInteraction() {} } // Paper start - Optimize explosions -- private float getBlockDensity(Vec3 vec3d, Entity entity, ExplosionBlockCache[] blockCache, BlockPos.MutableBlockPos blockPos) { // Paper - optimise explosions -+ protected final float getBlockDensity(Vec3 vec3d, Entity entity, ExplosionBlockCache[] blockCache, BlockPos.MutableBlockPos blockPos) { // Sakura - private -> protected // Paper - optimise explosions +- private float getBlockDensity(Vec3 vec3d, Entity entity) { ++ protected final float getBlockDensity(Vec3 vec3d, Entity entity) { // Sakura - private -> protected // Sakura start - replace density cache float blockDensity = this.level.densityCache.getDensity(vec3d, entity); if (blockDensity == me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) { diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index d555ea21a6e53938003a45d5de2ce97c4986f9e7..ad4076dd0352eb4f62588e3c83ffb2c42b07a3e0 100644 +index 66eeaa8941b4e10614e79d01bd9601d48aa44eb0..5c3aa8335b47a8ac0956c6caed3569f9244f4bd6 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -1419,7 +1419,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -1004,7 +1004,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { } Explosion.BlockInteraction explosion_effect1 = explosion_effect; -- Explosion explosion = new Explosion(this, entity, damageSource, behavior, x, y, z, power, createFire, explosion_effect1, particle, emitterParticle, soundEvent); +- Explosion explosion = new Explosion(this, entity, damageSource, behavior, x, y, z, power, createFire, explosion_effect1); + // Sakura start - specialised explosions + final Explosion explosion; + if (entity instanceof net.minecraft.world.entity.item.PrimedTnt tnt) { -+ explosion = new me.samsuik.sakura.explosion.special.TntExplosion(this, tnt, damageSource, behavior, x, y, z, power, createFire, explosion_effect1, particle, emitterParticle, soundEvent); ++ explosion = new me.samsuik.sakura.explosion.special.TntExplosion(this, tnt, damageSource, behavior, x, y, z, power, createFire, explosion_effect1); + } else { -+ explosion = new Explosion(this, entity, damageSource, behavior, x, y, z, power, createFire, explosion_effect1, particle, emitterParticle, soundEvent); ++ explosion = new Explosion(this, entity, damageSource, behavior, x, y, z, power, createFire, explosion_effect1); + } + // Sakura end - specialised explosions diff --git a/patches/server/0022-Optimise-Fast-Movement.patch b/patches/server/0022-Optimise-Fast-Movement.patch index d8a3bb9..150bca4 100644 --- a/patches/server/0022-Optimise-Fast-Movement.patch +++ b/patches/server/0022-Optimise-Fast-Movement.patch @@ -5,17 +5,16 @@ Subject: [PATCH] Optimise Fast Movement diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index c10f6574cc08aafe34a63c803e55e406b3d972c6..ad0743957b17c3a31a09836672eba47bc794401a 100644 +index c34e4077ba1c8768d3ed8f32a14df46a32009ab8..d7216d8e4c2a60d94b6c8ca2580c8aa9a7b58c67 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -1239,6 +1239,95 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1137,6 +1137,92 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } // Paper end - detailed watchdog information + // Sakura start - stripped back movement method for basic entities + public void moveBasic(MoverType movementType, Vec3 movement) { + io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main"); -+ + if (this.noPhysics) { + this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); + } else { @@ -26,7 +25,7 @@ index c10f6574cc08aafe34a63c803e55e406b3d972c6..ad0743957b17c3a31a09836672eba47b + } + } + -+ this.level().getProfiler().push("move"); ++ this.level.getProfiler().push("move"); + if (this.stuckSpeedMultiplier.lengthSqr() > 1.0E-7D) { + movement = movement.multiply(this.stuckSpeedMultiplier); + this.stuckSpeedMultiplier = Vec3.ZERO; @@ -38,10 +37,8 @@ index c10f6574cc08aafe34a63c803e55e406b3d972c6..ad0743957b17c3a31a09836672eba47b + double d0 = vec3d1.lengthSqr(); + + if (d0 > 1.0E-7D) { -+ // NOTE: if there are any blocks in the future that rely on fall distance make sure this is correct. -+ // The only block I am aware of is powdered snow that has a special case for falling blocks. -+ if (this.fallDistance != 0.0F && d0 >= 1.0D && !isFallingBlock) { -+ BlockHitResult movingobjectpositionblock = this.level().clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this)); ++ if (this.fallDistance != 0.0F && d0 >= 1.0D && !this.isFallingBlock) { ++ BlockHitResult movingobjectpositionblock = this.level.clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this)); + + if (movingobjectpositionblock.getType() != HitResult.Type.MISS) { + this.resetFallDistance(); @@ -51,8 +48,8 @@ index c10f6574cc08aafe34a63c803e55e406b3d972c6..ad0743957b17c3a31a09836672eba47b + this.setPos(this.getX() + vec3d1.x, this.getY() + vec3d1.y, this.getZ() + vec3d1.z); + } + -+ this.level().getProfiler().pop(); -+ this.level().getProfiler().push("rest"); ++ this.level.getProfiler().pop(); ++ this.level.getProfiler().push("rest"); + boolean flag = !Mth.equal(movement.x, vec3d1.x); + boolean flag1 = !Mth.equal(movement.z, vec3d1.z); + @@ -65,13 +62,13 @@ index c10f6574cc08aafe34a63c803e55e406b3d972c6..ad0743957b17c3a31a09836672eba47b + this.minorHorizontalCollision = false; + } + -+ this.setOnGroundWithKnownMovement(this.verticalCollisionBelow, vec3d1); ++ this.onGround = this.verticalCollision && movement.y < 0.0D; + BlockPos blockposition = this.getOnPosLegacy(); -+ BlockState iblockdata = this.level().getBlockState(blockposition); ++ BlockState iblockdata = this.level.getBlockState(blockposition); + -+ this.checkFallDamage(vec3d1.y, this.onGround(), iblockdata, blockposition); ++ this.checkFallDamage(vec3d1.y, this.onGround, iblockdata, blockposition); + if (this.isRemoved()) { -+ this.level().getProfiler().pop(); ++ this.level.getProfiler().pop(); + } else { + if (this.horizontalCollision) { + Vec3 vec3d2 = this.getDeltaMovement(); @@ -82,12 +79,12 @@ index c10f6574cc08aafe34a63c803e55e406b3d972c6..ad0743957b17c3a31a09836672eba47b + Block block = iblockdata.getBlock(); + + if (movement.y != vec3d1.y) { -+ block.updateEntityAfterFallOn(this.level(), this); ++ block.updateEntityAfterFallOn(this.level, this); + } + -+ if (this.onGround()) { ++ if (this.onGround) { + // used for slowing down entities on top of slime -+ block.stepOn(this.level(), blockposition, iblockdata, this); ++ block.stepOn(this.level, blockposition, iblockdata, this); + } + + this.tryCheckInsideBlocks(); @@ -95,16 +92,16 @@ index c10f6574cc08aafe34a63c803e55e406b3d972c6..ad0743957b17c3a31a09836672eba47b + float f = this.getBlockSpeedFactor(); + + this.multiplyDeltaMovement((double) f, 1.0D, (double) f); // Sakura - reduce movement allocations -+ this.level().getProfiler().pop(); ++ this.level.getProfiler().pop(); + } + } + } + // Sakura end + public void move(MoverType movementType, Vec3 movement) { - final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity // Paper start - detailed watchdog information -@@ -1617,6 +1706,95 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S + io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main"); +@@ -1489,6 +1575,88 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return offsetFactor; } @@ -116,19 +113,18 @@ index c10f6574cc08aafe34a63c803e55e406b3d972c6..ad0743957b17c3a31a09836672eba47b + + final boolean scan = movement.lengthSqr() >= 12.0; + final List potentialCollisionsBB = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(4); -+ final List potentialCollisionsVoxel = new it.unimi.dsi.fastutil.objects.ObjectArrayList<>(1); + final AABB currBoundingBox = getBoundingBox(); + + if (scan) { -+ return scanAndCollide(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB); ++ return scanAndCollide(movement, currBoundingBox, potentialCollisionsBB); + } else { + final AABB bb = currBoundingBox.expandTowards(movement.x, movement.y, movement.z); -+ collectCollisions(bb, potentialCollisionsVoxel, potentialCollisionsBB); -+ return io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB); ++ this.collectCollisions(bb, potentialCollisionsBB); ++ return io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisionsBB); + } + } + -+ private Vec3 scanAndCollide(Vec3 movement, AABB currBoundingBox, List voxelList, List bbList) { ++ private Vec3 scanAndCollide(Vec3 movement, AABB currBoundingBox, List bbList) { + double x = movement.x; + double y = movement.y; + double z = movement.z; @@ -136,93 +132,87 @@ index c10f6574cc08aafe34a63c803e55e406b3d972c6..ad0743957b17c3a31a09836672eba47b + final boolean xSmaller = Math.abs(x) < Math.abs(z); + + if (y != 0.0) { -+ y = scanY(currBoundingBox, y, voxelList, bbList); -+ ++ y = this.scanY(currBoundingBox, y, bbList); + if (y != 0.0) { + currBoundingBox = io.papermc.paper.util.CollisionUtil.offsetY(currBoundingBox, y); + } + } + + if (xSmaller && z != 0.0) { -+ z = scanZ(currBoundingBox, z, voxelList, bbList); -+ ++ z = this.scanZ(currBoundingBox, z, bbList); + if (z != 0.0) { + currBoundingBox = io.papermc.paper.util.CollisionUtil.offsetZ(currBoundingBox, z); + } + } + + if (x != 0.0) { -+ x = scanX(currBoundingBox, x, voxelList, bbList); -+ ++ x = this.scanX(currBoundingBox, x, bbList); + if (x != 0.0) { + currBoundingBox = io.papermc.paper.util.CollisionUtil.offsetX(currBoundingBox, x); + } + } + + if (!xSmaller && z != 0.0) { -+ z = scanZ(currBoundingBox, z, voxelList, bbList); ++ z = this.scanZ(currBoundingBox, z, bbList); + } + + return new Vec3(x, y, z); + } + -+ private void collectCollisions(AABB collisionBox, List voxelList, List bbList) { ++ private void collectCollisions(AABB collisionBox, List bbList) { + // Copied from the collide method below + io.papermc.paper.util.CollisionUtil.getCollisions( -+ level, this, collisionBox, voxelList, bbList, -+ io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_CHECK_BORDER | this.getExtraCollisionFlags(), // Sakura -+ null, null ++ this.level, this, collisionBox, bbList, ++ false, this.level.paperConfig().chunks.preventMovingIntoUnloadedChunks, ++ false, this.loadChunks, false, null, null // Sakura - load chunks on movement + ); + } + -+ private double scanX(AABB currBoundingBox, double x, List voxelList, List bbList) { ++ private double scanX(AABB currBoundingBox, double x, List bbList) { + AABB scanBox = currBoundingBox.expandTowards(x, 0.0, 0.0); -+ collectCollisions(scanBox, voxelList, bbList); -+ x = io.papermc.paper.util.CollisionUtil.performAABBCollisionsX(currBoundingBox, x, bbList); -+ return io.papermc.paper.util.CollisionUtil.performVoxelCollisionsX(currBoundingBox, x, voxelList); ++ this.collectCollisions(scanBox, bbList); ++ return io.papermc.paper.util.CollisionUtil.performCollisionsX(currBoundingBox, x, bbList); + } + -+ private double scanY(AABB currBoundingBox, double y, List voxelList, List bbList) { ++ private double scanY(AABB currBoundingBox, double y, List bbList) { + AABB scanBox = currBoundingBox.expandTowards(0.0, y, 0.0); -+ collectCollisions(scanBox, voxelList, bbList); -+ y = io.papermc.paper.util.CollisionUtil.performAABBCollisionsY(currBoundingBox, y, bbList); -+ return io.papermc.paper.util.CollisionUtil.performVoxelCollisionsY(currBoundingBox, y, voxelList); ++ this.collectCollisions(scanBox, bbList); ++ return io.papermc.paper.util.CollisionUtil.performCollisionsY(currBoundingBox, y, bbList); + } + -+ private double scanZ(AABB currBoundingBox, double z, List voxelList, List bbList) { ++ private double scanZ(AABB currBoundingBox, double z, List bbList) { + AABB scanBox = currBoundingBox.expandTowards(0.0, 0.0, z); -+ collectCollisions(scanBox, voxelList, bbList); -+ z = io.papermc.paper.util.CollisionUtil.performAABBCollisionsZ(currBoundingBox, z, bbList); -+ return io.papermc.paper.util.CollisionUtil.performVoxelCollisionsZ(currBoundingBox, z, voxelList); ++ this.collectCollisions(scanBox, bbList); ++ return io.papermc.paper.util.CollisionUtil.performCollisionsZ(currBoundingBox, z, bbList); + } + // Sakura end + private Vec3 collide(Vec3 movement) { // Paper start - optimise collisions - final boolean xZero = movement.x == 0.0; + // This is a copy of vanilla's except that it uses strictly AABB math 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 66b6250dc692e1222ac1661cdd206a1094049a15..d2ad54dd3975e2dd8ef26ad28ad1bb2c71ba9f1a 100644 +index 2965d963ca7eaf7bfd010094c08aa8b80af79a13..33a247ac617c17e7c0cf1614ca485398c60ea579 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -199,7 +199,7 @@ public class FallingBlockEntity extends Entity { +@@ -200,7 +200,7 @@ public class FallingBlockEntity extends Entity { this.addDeltaMovement(0.0D, -0.04D, 0.0D); // Sakura - reduce movement allocations } - this.move(MoverType.SELF, this.getDeltaMovement()); + this.moveBasic(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise simple entity movement - // Paper start - Configurable falling blocks height nerf - if (this.level().paperConfig().fixes.fallingBlockHeightNerf.test(v -> this.getY() > v)) { - if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { + + // Paper start - fix sand duping + if (this.isRemoved()) { diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index 0c8775fd29fdc811c8a3becb484abf3ed92686c7..dbebba5c36b034270d4c238966957bc25a35aa86 100644 +index f3330d5219edfac9fd23b10e3f97e999fc3b5b0e..ab4bcf2383e060a348eb172d1b36310cbbe17f72 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -96,7 +96,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -85,7 +85,7 @@ public class PrimedTnt extends Entity { this.addDeltaMovement(0.0D, -0.04D, 0.0D); // Sakura - reduce movement allocations } - this.move(MoverType.SELF, this.getDeltaMovement()); + this.moveBasic(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise simple entity movement - // Paper start - Configurable TNT height nerf - if (this.level().paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) { - this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD); + // Paper start - Configurable TNT entity height nerf + if (this.level.paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) { + this.discard(); diff --git a/patches/server/0023-Limited-Get-Entities.patch b/patches/server/0023-Limited-Get-Entities.patch index 2e6dbcb..147e584 100644 --- a/patches/server/0023-Limited-Get-Entities.patch +++ b/patches/server/0023-Limited-Get-Entities.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Limited Get Entities diff --git a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java -index 15ee41452992714108efe53b708b5a4e1da7c1ff..b62a1ae53a891802db17046271b9981ab3af1df0 100644 +index 61c170555c8854b102c640b0b6a615f9f732edbf..40c075c90993cdc7d0e6b908ed0f290a78286960 100644 --- a/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java +++ b/src/main/java/io/papermc/paper/chunk/system/entity/EntityLookup.java -@@ -522,6 +522,128 @@ public final class EntityLookup implements LevelEntityGetter { +@@ -459,6 +459,128 @@ public final class EntityLookup implements LevelEntityGetter { return slices; } @@ -42,7 +42,7 @@ index 15ee41452992714108efe53b708b5a4e1da7c1ff..b62a1ae53a891802db17046271b9981a + for (int currZ = minZ; currZ <= maxZ; ++currZ) { + for (int currX = minX; currX <= maxX; ++currX) { + final ChunkEntitySlices chunk = region.get(currX | (currZ << REGION_SHIFT)); -+ if (chunk == null || !chunk.status.isOrAfter(FullChunkStatus.FULL)) { ++ if (chunk == null || !chunk.status.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)) { + continue; + } + @@ -82,7 +82,7 @@ index 15ee41452992714108efe53b708b5a4e1da7c1ff..b62a1ae53a891802db17046271b9981a + for (int currZ = minZ; currZ <= maxZ; ++currZ) { + for (int currX = minX; currX <= maxX; ++currX) { + final ChunkEntitySlices chunk = region.get(currX | (currZ << REGION_SHIFT)); -+ if (chunk == null || !chunk.status.isOrAfter(FullChunkStatus.FULL)) { ++ if (chunk == null || !chunk.status.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)) { + continue; + } + @@ -122,7 +122,7 @@ index 15ee41452992714108efe53b708b5a4e1da7c1ff..b62a1ae53a891802db17046271b9981a + for (int currZ = minZ; currZ <= maxZ; ++currZ) { + for (int currX = minX; currX <= maxX; ++currX) { + final ChunkEntitySlices chunk = region.get(currX | (currZ << REGION_SHIFT)); -+ if (chunk == null || !chunk.status.isOrAfter(FullChunkStatus.FULL)) { ++ if (chunk == null || !chunk.status.isOrAfter(ChunkHolder.FullChunkStatus.BORDER)) { + continue; + } + @@ -138,10 +138,10 @@ index 15ee41452992714108efe53b708b5a4e1da7c1ff..b62a1ae53a891802db17046271b9981a final int minChunkX = (Mth.floor(box.minX) - 2) >> 4; final int minChunkZ = (Mth.floor(box.minZ) - 2) >> 4; diff --git a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -index 8fcaa00e461c7f4413bf655ddd8165a2b908f900..404b99def4562942e036089085a667979b1cac81 100644 +index ce231d8b230d4983b21c597357c0b22377e4bcca..91b0e10a60173b428612e2515fdcfd62110a7a3e 100644 --- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java +++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -@@ -259,6 +259,30 @@ public final class ChunkEntitySlices { +@@ -253,6 +253,30 @@ public final class ChunkEntitySlices { } // Sakura end @@ -172,7 +172,7 @@ index 8fcaa00e461c7f4413bf655ddd8165a2b908f900..404b99def4562942e036089085a66797 public void getHardCollidingEntities(final Entity except, final AABB box, final List into, final Predicate predicate) { this.hardCollidingEntities.getEntities(except, box, into, predicate); } -@@ -449,6 +473,155 @@ public final class ChunkEntitySlices { +@@ -443,6 +467,155 @@ public final class ChunkEntitySlices { } // Sakura end @@ -329,14 +329,14 @@ index 8fcaa00e461c7f4413bf655ddd8165a2b908f900..404b99def4562942e036089085a66797 if (this.count == 0) { return; diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index ad4076dd0352eb4f62588e3c83ffb2c42b07a3e0..360e72b8e540f3cdb557bc59bca5e0a9cda239f8 100644 +index 5c3aa8335b47a8ac0956c6caed3569f9244f4bd6..562ce3115ff6814f52872eb0e36a95d255ea4187 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -232,6 +232,39 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -286,6 +286,39 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public final me.samsuik.sakura.entity.merge.MergeHistory mergeHistory = new me.samsuik.sakura.entity.merge.MergeHistory(); // Sakura - cannon entity merging public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(); // Sakura - explosion density cache -+ // Sakura start - add entity retrival methods with search limits ++ // Sakura start - add entity retrieval methods with search limits + public void getLimitedEntities(Entity except, AABB box, Predicate predicate, List into, int limit, int search) { + ((ServerLevel)this).getEntityLookup().getLimitedEntities(except, box, into, predicate, limit, search); + } @@ -367,8 +367,8 @@ index ad4076dd0352eb4f62588e3c83ffb2c42b07a3e0..360e72b8e540f3cdb557bc59bca5e0a9 + public List getLimitedEntities(@Nullable Entity except, AABB box, int limit, int search) { + return this.getLimitedEntities(except, box, net.minecraft.world.entity.EntitySelector.NO_SPECTATORS, limit, search); + } -+ // Sakura end - add entity retrival methods with search limits ++ // Sakura end - add entity retrieval methods with search limits + - protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, Supplier sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - create paper world config; Async-Anti-Xray: Pass executor + protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, Supplier sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - Async-Anti-Xray - Pass executor this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot - this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper - create paper world config + this.paperConfig = paperWorldConfigCreator.apply(this.spigotConfig); // Paper diff --git a/patches/server/0024-isPushedByFluid-API.patch b/patches/server/0024-isPushedByFluid-API.patch index 46324bc..99b3c34 100644 --- a/patches/server/0024-isPushedByFluid-API.patch +++ b/patches/server/0024-isPushedByFluid-API.patch @@ -5,10 +5,10 @@ Subject: [PATCH] isPushedByFluid API diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index ad0743957b17c3a31a09836672eba47bc794401a..6ad96ca1a5d220ecd209e6c212108a3832c65535 100644 +index d7216d8e4c2a60d94b6c8ca2580c8aa9a7b58c67..1265e7d7e5615481229c89d3a76244a6603fd756 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -717,6 +717,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -678,6 +678,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } } // Sakura end - cannon entity merging @@ -16,7 +16,7 @@ index ad0743957b17c3a31a09836672eba47bc794401a..6ad96ca1a5d220ecd209e6c212108a38 public Entity(EntityType type, Level world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -4255,7 +4256,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -3950,7 +3951,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public boolean isPushedByFluid() { @@ -26,10 +26,10 @@ index ad0743957b17c3a31a09836672eba47bc794401a..6ad96ca1a5d220ecd209e6c212108a38 public static double getViewScale() { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index e8e4489bcd64fde1b3226bdc7a7cc612508bda3f..4731d10dd5e493af9564d38d8bf1ff223390bd75 100644 +index 750ac80eed6ba03e138dd4c03f57ddfe4a123276..b70fb77f360e970c689d7f996d479674f6de0d90 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -@@ -201,6 +201,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -523,6 +523,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return this.entity.isInWater(); } @@ -47,4 +47,4 @@ index e8e4489bcd64fde1b3226bdc7a7cc612508bda3f..4731d10dd5e493af9564d38d8bf1ff22 + @Override public World getWorld() { - return this.entity.level().getWorld(); + return entity.level.getWorld(); diff --git a/patches/server/0025-Cannon-Mechanics.patch b/patches/server/0025-Cannon-Mechanics.patch index 0a57fa7..6eebf7c 100644 --- a/patches/server/0025-Cannon-Mechanics.patch +++ b/patches/server/0025-Cannon-Mechanics.patch @@ -5,18 +5,18 @@ Subject: [PATCH] Cannon Mechanics 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 d2ad54dd3975e2dd8ef26ad28ad1bb2c71ba9f1a..eb972c8082ba4371479b8bf691dbfac082a53a2f 100644 +index 33a247ac617c17e7c0cf1614ca485398c60ea579..ad8a3f5c41bcd2860d6872655b6b2ef25b6d349c 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -68,6 +68,7 @@ public class FallingBlockEntity extends Entity { +@@ -64,6 +64,7 @@ public class FallingBlockEntity extends Entity { public CompoundTag blockData; protected static final EntityDataAccessor DATA_START_POS = SynchedEntityData.defineId(FallingBlockEntity.class, EntityDataSerializers.BLOCK_POS); - public boolean autoExpire = true; // Paper - Expand FallingBlock API + public boolean autoExpire = true; // Paper - Auto expire setting + public boolean heightParity; // Sakura - configure cannon mechanics public FallingBlockEntity(EntityType type, Level world) { super(type, world); -@@ -76,6 +77,7 @@ public class FallingBlockEntity extends Entity { +@@ -72,6 +73,7 @@ public class FallingBlockEntity extends Entity { this.fallDamageMax = 40; this.isFallingBlock = true; // Sakura this.loadChunks = world.sakuraConfig().cannons.loadChunks; // Sakura - falling blocks load chunks @@ -24,7 +24,7 @@ index d2ad54dd3975e2dd8ef26ad28ad1bb2c71ba9f1a..eb972c8082ba4371479b8bf691dbfac0 } public FallingBlockEntity(Level world, double x, double y, double z, BlockState block) { -@@ -186,6 +188,12 @@ public class FallingBlockEntity extends Entity { +@@ -182,6 +184,12 @@ public class FallingBlockEntity extends Entity { return itemEntity; } // Sakura end @@ -38,10 +38,10 @@ index d2ad54dd3975e2dd8ef26ad28ad1bb2c71ba9f1a..eb972c8082ba4371479b8bf691dbfac0 @Override public void tick() { diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index dbebba5c36b034270d4c238966957bc25a35aa86..5bc7e9c135d02fe8817643bd21d8f245a6e984df 100644 +index ab4bcf2383e060a348eb172d1b36310cbbe17f72..683d44becb21689b95ba4babd235ee9199f4f6d8 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -54,6 +54,12 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -42,6 +42,12 @@ public class PrimedTnt extends Entity { this.yo = y; this.zo = z; this.owner = igniter; @@ -54,17 +54,17 @@ index dbebba5c36b034270d4c238966957bc25a35aa86..5bc7e9c135d02fe8817643bd21d8f245 } @Override -@@ -225,7 +231,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { - // Paper start - Option to prevent TNT from moving in water +@@ -199,7 +205,7 @@ public class PrimedTnt extends Entity { + // Paper start - Optional prevent TNT from moving in water @Override public boolean isPushedByFluid() { -- return !level().paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid(); -+ return !level().paperConfig().fixes.preventTntFromMovingInWater && level().sakuraConfig().cannons.mechanics.tntFlowsInWater && super.isPushedByFluid(); // Sakura - convenience +- return !level.paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid(); ++ return !level.paperConfig().fixes.preventTntFromMovingInWater && this.level.sakuraConfig().cannons.mechanics.tntFlowsInWater && super.isPushedByFluid(); // Sakura - cannon mechanics } - // Paper end - Option to prevent TNT from moving in water + // Paper end } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java -index 0afa2cfb04b5097788927076669e85fe24041df9..8e678a811e232bbd78de45b80fae47964bdf8f98 100644 +index 65bac64214112ebd9e067202fe13293abe10559d..d43431c7609866cb5ba89b68fea909f5ff76f825 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftFallingBlock.java @@ -34,6 +34,16 @@ public class CraftFallingBlock extends CraftEntity implements FallingBlock { diff --git a/patches/server/0026-Cache-MovingBlockEntity-collision-shape.patch b/patches/server/0026-Cache-MovingBlockEntity-collision-shape.patch index 518b51f..c1a7dd9 100644 --- a/patches/server/0026-Cache-MovingBlockEntity-collision-shape.patch +++ b/patches/server/0026-Cache-MovingBlockEntity-collision-shape.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Cache MovingBlockEntity collision shape diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -index 9f45dda6ff45ac1ffb7ac99575b7d09bdc61c56a..c89e1fe5fafac46d82b2b20d27586c6997ce8906 100644 +index 221c5d080d55326e458c1182823d6b49224ef498..26e11fbe0ddeed23d286e83adfa7d2a5e9cf88c8 100644 --- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -@@ -41,6 +41,11 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -43,6 +43,11 @@ public class PistonMovingBlockEntity extends BlockEntity { private float progressO; private long lastTicked; private int deathTicks; @@ -20,7 +20,7 @@ index 9f45dda6ff45ac1ffb7ac99575b7d09bdc61c56a..c89e1fe5fafac46d82b2b20d27586c69 public PistonMovingBlockEntity(BlockPos pos, BlockState state) { super(BlockEntityType.PISTON, pos, state); -@@ -348,6 +353,18 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -336,6 +341,18 @@ public class PistonMovingBlockEntity extends BlockEntity { } public VoxelShape getCollisionShape(BlockGetter world, BlockPos pos) { diff --git a/patches/server/0027-Optimise-TNT-fluid-state-and-pushing.patch b/patches/server/0027-Optimise-TNT-fluid-state-and-pushing.patch index 42912e3..9304795 100644 --- a/patches/server/0027-Optimise-TNT-fluid-state-and-pushing.patch +++ b/patches/server/0027-Optimise-TNT-fluid-state-and-pushing.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Optimise TNT fluid state and pushing diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 6ad96ca1a5d220ecd209e6c212108a3832c65535..499618b41531103456be9b7879198bd9105ca6b4 100644 +index 1265e7d7e5615481229c89d3a76244a6603fd756..5bd03c22c046938d90aa8de17f843b7a8394d0ae 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2202,7 +2202,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -2013,7 +2013,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return this.isInWater() || flag; } @@ -18,10 +18,10 @@ index 6ad96ca1a5d220ecd209e6c212108a3832c65535..499618b41531103456be9b7879198bd9 if (entity instanceof Boat) { diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index 5bc7e9c135d02fe8817643bd21d8f245a6e984df..bf606cf3d2217a1ecc97d9d31cd02d9618bac0f6 100644 +index 683d44becb21689b95ba4babd235ee9199f4f6d8..bf6d7411716ff73c2f65965ec9bc33f70f719e19 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -94,6 +94,19 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -81,6 +81,19 @@ public class PrimedTnt extends Entity { } // Sakura - specialised explosions // Sakura end diff --git a/patches/server/0028-Optimise-LivingEntity-pushEntities.patch b/patches/server/0028-Optimise-LivingEntity-pushEntities.patch index f0ff25d..acf65e7 100644 --- a/patches/server/0028-Optimise-LivingEntity-pushEntities.patch +++ b/patches/server/0028-Optimise-LivingEntity-pushEntities.patch @@ -5,19 +5,19 @@ Subject: [PATCH] Optimise LivingEntity#pushEntities diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index e9bb7feb591032904516d1b9374f486d8a7d066c..6162631e863dd15c7fdb70dbde2f85d273c7020b 100644 +index 902a19def9d902e7bfb476688354a070633a3454..c10c3f46fe29733c4b7fab7dd6d68a76905488eb 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -3580,7 +3580,11 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3510,7 +3510,11 @@ public abstract class LivingEntity extends Entity { return; } // Paper end - don't run getEntities if we're not going to use its result -- List list = this.level().getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushable(this, this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule)); // Paper - Climbing should not bypass cramming gamerule +- List list = this.level.getEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushable(this, level.paperConfig().collisions.fixClimbingBypassingCrammingRule)); // Paper - fix climbing bypassing cramming rule + // Sakura start - use maxEntityCollision limit for entity retrival -+ int limit = Math.max(i, this.level().paperConfig().collisions.maxEntityCollisions); ++ int limit = Math.max(i, this.level.paperConfig().collisions.maxEntityCollisions); + int search = limit * limit; -+ List list = this.level().getLimitedEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushable(this, this.level().paperConfig().collisions.fixClimbingBypassingCrammingRule), limit, search); // Paper - Climbing should not bypass cramming gamerule ++ List list = this.level.getLimitedEntities((Entity) this, this.getBoundingBox(), EntitySelector.pushable(this, level.paperConfig().collisions.fixClimbingBypassingCrammingRule), limit, search); // Paper - fix climbing bypassing cramming rule + // Sakura end - use maxEntityCollision limit for entity retrival if (!list.isEmpty()) { - // Paper - don't run getEntities if we're not going to use its result; moved up + // Paper - moved up diff --git a/patches/server/0029-Despawn-falling-blocks-inside-moving-pistons.patch b/patches/server/0029-Despawn-falling-blocks-inside-moving-pistons.patch index b2a7706..91c5045 100644 --- a/patches/server/0029-Despawn-falling-blocks-inside-moving-pistons.patch +++ b/patches/server/0029-Despawn-falling-blocks-inside-moving-pistons.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Despawn falling blocks inside moving pistons 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 eb972c8082ba4371479b8bf691dbfac082a53a2f..6cccfdcc33e9ea2a79fe3fec5534e461fd697ecb 100644 +index ad8a3f5c41bcd2860d6872655b6b2ef25b6d349c..e9e65c72f3bdd193ea5acf614c68a11f828ece10 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -233,7 +233,7 @@ public class FallingBlockEntity extends Entity { +@@ -241,7 +241,7 @@ public class FallingBlockEntity extends Entity { } } -- if (!this.onGround() && !flag1) { -+ if (!this.onGround() && !flag1 || level().sakuraConfig().cannons.sand.despawnInsideMovingPistons && autoExpire && this.time > 600) { // Sakura - allow falling blocks to despawn inside moving pistons - if (!this.level().isClientSide && ((this.time > 100 && autoExpire) && (blockposition.getY() <= this.level().getMinBuildHeight() || blockposition.getY() > this.level().getMaxBuildHeight()) || (this.time > 600 && autoExpire))) { // Paper - Expand FallingBlock API - if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { +- if (!this.onGround && !flag1) { ++ if (!this.onGround && !flag1 || this.level.sakuraConfig().cannons.sand.despawnInsideMovingPistons && autoExpire && this.time > 600) { // Sakura - allow falling blocks to despawn inside moving pistons + if (!this.level.isClientSide && ((this.time > 100 && autoExpire) && (blockposition.getY() <= this.level.getMinBuildHeight() || blockposition.getY() > this.level.getMaxBuildHeight()) || (this.time > 600 && autoExpire))) { // Paper - Auto expire setting + if (this.dropItem && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { this.spawnAtLocation((ItemLike) block); diff --git a/patches/server/0030-Configure-Entity-Knockback.patch b/patches/server/0030-Configure-Entity-Knockback.patch index 376364d..766d011 100644 --- a/patches/server/0030-Configure-Entity-Knockback.patch +++ b/patches/server/0030-Configure-Entity-Knockback.patch @@ -5,91 +5,91 @@ Subject: [PATCH] Configure Entity Knockback diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 6162631e863dd15c7fdb70dbde2f85d273c7020b..e75322367764805443f9a9f5639d804b87a0ab5e 100644 +index c10c3f46fe29733c4b7fab7dd6d68a76905488eb..3b4ba5c9e2aeab85f79a2d3a583017cd84f3c1cd 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -1549,7 +1549,7 @@ public abstract class LivingEntity extends Entity implements Attackable { - d0 = (Math.random() - Math.random()) * 0.01D; +@@ -1475,7 +1475,7 @@ public abstract class LivingEntity extends Entity { } -- this.knockback(0.4000000059604645D, d0, d1, entity1, entity1 == null ? EntityKnockbackEvent.KnockbackCause.DAMAGE : EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit -+ this.knockback((float) level().sakuraConfig().players.knockback.baseKnockback, d0, d1, entity1, entity1 == null ? EntityKnockbackEvent.KnockbackCause.DAMAGE : EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // Sakura - configure entity knockback // CraftBukkit - if (!flag) { - this.indicateDamage(d0, d1); - } -@@ -1596,7 +1596,7 @@ public abstract class LivingEntity extends Entity implements Attackable { + this.hurtDir = (float) (Mth.atan2(d1, d0) * 57.2957763671875D - (double) this.getYRot()); +- this.knockback(0.4000000059604645D, d0, d1, entity1); // Paper ++ this.knockback((float) this.level.sakuraConfig().players.knockback.baseKnockback, d0, d1, entity1); // Sakura - configure entity knockback + } else { + this.hurtDir = (float) ((int) (Math.random() * 2.0D) * 180); + } +@@ -1522,7 +1522,7 @@ public abstract class LivingEntity extends Entity { } protected void blockedByShield(LivingEntity target) { -- target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ(), this, EntityKnockbackEvent.KnockbackCause.SHIELD_BLOCK); // CraftBukkit // Paper - fix attacker -+ target.knockback((float) level().sakuraConfig().players.knockback.shieldHitKnockback, target.getX() - this.getX(), target.getZ() - this.getZ(), this, EntityKnockbackEvent.KnockbackCause.SHIELD_BLOCK); // Sakura - configure entity knockback // CraftBukkit // Paper - fix attacker +- target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ(), this); // Paper ++ target.knockback((float) this.level.sakuraConfig().players.knockback.shieldHitKnockback, target.getX() - this.getX(), target.getZ() - this.getZ(), this); // Sakura - configure entity knockback // Paper } private boolean checkTotemDeathProtection(DamageSource source) { -@@ -1914,13 +1914,26 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -1834,13 +1834,26 @@ public abstract class LivingEntity extends Entity { } - - public void knockback(double d0, double d1, double d2, @Nullable Entity attacker, EntityKnockbackEvent.KnockbackCause cause) { // Paper - add nullable to attacker param -- d0 *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); -+ d0 *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE) * level().sakuraConfig().players.knockback.knockbackResistanceModifier; // Sakura - configure entity knockback - if (true || d0 > 0.0D) { // CraftBukkit - Call event even when force is 0 - //this.hasImpulse = true; // CraftBukkit - Move down + public void knockback(double strength, double x, double z, Entity knockingBackEntity) { + // Paper end - add knockbacking entity parameter +- strength *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE); ++ strength *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE) * this.level.sakuraConfig().players.knockback.knockbackResistanceModifier; // Sakura - configure entity knockback + if (strength > 0.0D) { + this.hasImpulse = true; Vec3 vec3d = this.getDeltaMovement(); - Vec3 vec3d1 = (new Vec3(d1, 0.0D, d2)).normalize().scale(d0); + Vec3 vec3d1 = (new Vec3(x, 0.0D, z)).normalize().scale(strength); -- EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) this.getBukkitEntity(), attacker, cause, d0, vec3d1, vec3d.x / 2.0D - vec3d1.x, this.onGround() ? Math.min(0.4D, vec3d.y / 2.0D + d0) : vec3d.y, vec3d.z / 2.0D - vec3d1.z); +- this.setDeltaMovement(vec3d.x / 2.0D - vec3d1.x, this.onGround ? Math.min(0.4D, vec3d.y / 2.0D + strength) : vec3d.y, vec3d.z / 2.0D - vec3d1.z); + // Sakura start - configure entity knockback + double velocityX = vec3d.x / 2.0D - vec3d1.x; -+ double velocityY = vec3d.y / 2.0D + level().sakuraConfig().players.knockback.knockbackVertical.or(d0); ++ double velocityY = vec3d.y / 2.0D + this.level.sakuraConfig().players.knockback.knockbackVertical.or(strength); + double velocityZ = vec3d.z / 2.0D - vec3d1.z; + + // this.onGround() ? Math.min(0.4D, vec3d.y / 2.0D + d0) : vec3d.y -+ if (!level().sakuraConfig().players.knockback.verticalKnockbackRequireGround || this.onGround()) { -+ velocityY = Math.min(level().sakuraConfig().players.knockback.knockbackVerticalLimit, velocityY); ++ if (!this.level.sakuraConfig().players.knockback.verticalKnockbackRequireGround || this.onGround) { ++ velocityY = Math.min(this.level.sakuraConfig().players.knockback.knockbackVerticalLimit, velocityY); + } else { + velocityY = vec3d.y; + } + -+ EntityKnockbackEvent event = CraftEventFactory.callEntityKnockbackEvent((org.bukkit.craftbukkit.entity.CraftLivingEntity) this.getBukkitEntity(), attacker, cause, d0, vec3d1, velocityX, velocityY, velocityZ); ++ this.setDeltaMovement(velocityX, velocityY, velocityZ); + // Sakura end - configure entity knockback - if (event.isCancelled()) { - return; - } + // Paper start - call EntityKnockbackByEntityEvent + Vec3 currentMovement = this.getDeltaMovement(); + org.bukkit.util.Vector delta = new org.bukkit.util.Vector(currentMovement.x - vec3d.x, currentMovement.y - vec3d.y, currentMovement.z - vec3d.z); diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index 74dcfabdc66ef289b8d6a5c6606579b5321af1db..ddf9acf79356d6fff5caa436f67641512fb16f59 100644 +index 407401198c21dd5887aa3b7d86cdb112ef369007..0807d9d33131bf36b02f075e2150eaf33774ad27 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java @@ -183,6 +183,7 @@ public abstract class Player extends LivingEntity { - public float hurtDir; // Paper - protected -> public - public boolean affectsSpawning = true; // Paper - Affects Spawning API - public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; // Paper - flying fall damage + public boolean affectsSpawning = true; + public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; + // Paper end + private long lastSprintKnockback = -1; // Sakura - configure entity knockback // CraftBukkit start public boolean fauxSleeping; -@@ -1274,7 +1275,7 @@ public abstract class Player extends LivingEntity { +@@ -1265,7 +1266,7 @@ public abstract class Player extends LivingEntity { byte b0 = 0; int i = b0 + EnchantmentHelper.getKnockbackBonus(this); - if (this.isSprinting() && flag) { -+ if (this.isSprinting() && (!level().sakuraConfig().players.knockback.sprinting.requireFullAttack || flag)) { // Sakura ++ if (this.isSprinting() && (!this.level.sakuraConfig().players.knockback.sprinting.requireFullAttack || flag)) { // Sakura sendSoundEffect(this, this.getX(), this.getY(), this.getZ(), SoundEvents.PLAYER_ATTACK_KNOCKBACK, this.getSoundSource(), 1.0F, 1.0F); // Paper - send while respecting visibility ++i; flag1 = true; -@@ -1324,10 +1325,26 @@ public abstract class Player extends LivingEntity { +@@ -1315,10 +1316,26 @@ public abstract class Player extends LivingEntity { if (flag5) { if (i > 0) { - if (target instanceof LivingEntity) { -- ((LivingEntity) target).knockback((double) ((float) i * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit +- ((LivingEntity) target).knockback((double) ((float) i * 0.5F), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper + // Sakura start - configure extra sprinting knockback + float extraKnockback = (float) i * 0.5F; + long millis = System.currentTimeMillis(); + long sinceLastKnockback = millis - this.lastSprintKnockback; + if (flag1) { // attackHasExtraKnockback + double knockbackToApply = 0.0; -+ if (sinceLastKnockback >= this.level().sakuraConfig().players.knockback.sprinting.knockbackDelay.value().orElse(0)) { -+ knockbackToApply = this.level().sakuraConfig().players.knockback.sprinting.extraKnockback; ++ if (sinceLastKnockback >= this.level.sakuraConfig().players.knockback.sprinting.knockbackDelay.value().orElse(0)) { ++ knockbackToApply = this.level.sakuraConfig().players.knockback.sprinting.extraKnockback; + this.lastSprintKnockback = millis; + } + // -0.5 is to negate the vanilla sprinting knockback @@ -98,35 +98,35 @@ index 74dcfabdc66ef289b8d6a5c6606579b5321af1db..ddf9acf79356d6fff5caa436f6764151 + if (extraKnockback == 0.0) { + // required + } else if (target instanceof LivingEntity) { -+ ((LivingEntity) target).knockback((double) (extraKnockback), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit ++ ((LivingEntity) target).knockback((double) (extraKnockback), (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper } else { -- target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * (float) i * 0.5F), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent -+ target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * extraKnockback), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * extraKnockback), this); // Paper - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent +- target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * (float) i * 0.5F), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * (float) i * 0.5F), this); // Paper ++ target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * extraKnockback), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * extraKnockback), this); // Paper + // Sakura end - configure extra sprinting knockback } this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D)); -@@ -1349,7 +1366,7 @@ public abstract class Player extends LivingEntity { +@@ -1340,7 +1357,7 @@ public abstract class Player extends LivingEntity { if (entityliving != this && entityliving != target && !this.isAlliedTo((Entity) entityliving) && (!(entityliving instanceof ArmorStand) || !((ArmorStand) entityliving).isMarker()) && this.distanceToSqr((Entity) entityliving) < 9.0D) { // CraftBukkit start - Only apply knockback if the damage hits - if (entityliving.hurt(this.damageSources().playerAttack(this).sweep().critical(flag2), f4)) { // Paper - add critical damage API -- entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, EntityKnockbackEvent.KnockbackCause.SWEEP_ATTACK); // CraftBukkit -+ entityliving.knockback((float) level().sakuraConfig().players.knockback.sweepingEdgeKnockback, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this, EntityKnockbackEvent.KnockbackCause.SWEEP_ATTACK); // Sakura - configure entity knockback // CraftBukkit + if (entityliving.hurt(DamageSource.playerAttack(this).sweep().critical(flag2), f4)) { // Paper - add critical damage API +- entityliving.knockback(0.4000000059604645D, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Paper ++ entityliving.knockback((float) this.level.sakuraConfig().players.knockback.sweepingEdgeKnockback, (double) Mth.sin(this.getYRot() * 0.017453292F), (double) (-Mth.cos(this.getYRot() * 0.017453292F)), this); // Sakura - configure entity knockback // Paper } // CraftBukkit end } diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java -index 91497f5e6c07fcf1b05eca6846c51e1a15ed3bc0..ba906ceb807b21c01cf4d3c0122f626959f6e775 100644 +index 15fb5ee374b19366ebb23181896fb943e95819f0..70016e105066a16d19ebdf631cc3ef0a03466e3a 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java -@@ -298,6 +298,12 @@ public class FishingHook extends Projectile { +@@ -291,6 +291,12 @@ public class FishingHook extends Projectile { this.setHookedEntity(entityHitResult.getEntity()); } + // Sakura start - configure entity knockback -+ if (this.level().sakuraConfig().players.knockback.fishingHooksApplyKnockback) { ++ if (this.level.sakuraConfig().players.knockback.fishingHooksApplyKnockback) { + Entity entity = entityHitResult.getEntity(); -+ entity.hurt(this.damageSources().thrown(this, this.getOwner()), 0.0f); ++ entity.hurt(net.minecraft.world.damagesource.DamageSource.thrown(this, this.getOwner()), 0.0f); + } + // Sakura end - configure entity knockback } diff --git a/patches/server/0031-Explosion-Durable-Blocks.patch b/patches/server/0031-Explosion-Durable-Blocks.patch index 635e810..9c8a66b 100644 --- a/patches/server/0031-Explosion-Durable-Blocks.patch +++ b/patches/server/0031-Explosion-Durable-Blocks.patch @@ -74,19 +74,19 @@ index 0000000000000000000000000000000000000000..c58e52f7cc012babf4235e405e5fb501 + +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 62d54547fc8c1a9f7b19a2020b754a189ba7c52f..622ab8f82f1b641f32912788ce44381b88f46093 100644 +index f14abf532e9cd80e0a270826143c7489a4f4a5e4..bd62b4de0da6f30fa87333889b15857fffc48666 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1750,6 +1750,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop resistance = !calculateResistance ? Optional.empty() : this.damageCalculator.getBlockExplosionResistance((Explosion)(Object)this, this.level, pos, blockState, fluidState); -+ Optional resistance = !calculateResistance ? Optional.empty() : this.calculateBlockResistance(blockState, fluidState, pos); // Sakura - explosion durable blocks + mutableBlockPos.set(blockX, blockY, blockZ); +- Optional optional = this.damageCalculator.getBlockExplosionResistance( +- this, this.level, mutableBlockPos, blockstate, fluid ++ Optional optional = this.calculateBlockResistance( // Sakura - explosion durable blocks ++ mutableBlockPos, blockstate, fluid // Sakura - explosion durable blocks + ); - ret = new ExplosionBlockCache( - key, pos, blockState, fluidState, -@@ -275,6 +275,21 @@ public class Explosion { - return ret; + if (optional.isPresent()) { +@@ -298,6 +298,20 @@ public class Explosion { + return true; } - + // Sakura end - optimise protected explosions + // Sakura start - explosion durable blocks -+ private Optional calculateBlockResistance(BlockState blockState, FluidState fluidState, BlockPos pos) { ++ private Optional calculateBlockResistance(BlockPos.MutableBlockPos pos, BlockState blockState, FluidState fluidState) { + if (!blockState.isAir()) { + Block block = blockState.getBlock(); + me.samsuik.sakura.explosion.durable.DurableMaterial material = this.level.localConfig().config(pos).durableMaterials.get(block); @@ -151,15 +153,14 @@ index 27d17da5d560bbe97f088ecec4b95d2ad4a34bcb..e8ca758f563833c48c55eb7ec2b50a23 + } + } + -+ return this.damageCalculator.getBlockExplosionResistance((Explosion)(Object)this, this.level, pos, blockState, fluidState); ++ return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState); + } + // Sakura end - explosion durable blocks -+ - private boolean clipsAnything(final Vec3 from, final Vec3 to, - final io.papermc.paper.util.CollisionUtil.LazyEntityCollisionContext context, - final ExplosionBlockCache[] blockCache, -@@ -875,6 +890,16 @@ public class Explosion { - // CraftBukkit start - TNTPrimeEvent + + private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) { + if (entity instanceof net.minecraft.world.entity.item.PrimedTnt) { +@@ -542,6 +556,16 @@ public class Explosion { + BlockPos blockposition = (BlockPos) objectlistiterator.next(); BlockState iblockdata = this.level.getBlockState(blockposition); Block block = iblockdata.getBlock(); + // Sakura start - explosion durable blocks @@ -172,18 +173,18 @@ index 27d17da5d560bbe97f088ecec4b95d2ad4a34bcb..e8ca758f563833c48c55eb7ec2b50a23 + } + } + // Sakura end - explosion durable blocks - if (block instanceof net.minecraft.world.level.block.TntBlock) { - Entity sourceEntity = this.source == null ? null : this.source; - BlockPos sourceBlock = sourceEntity == null ? BlockPos.containing(this.x, this.y, this.z) : null; + + if (!iblockdata.isAir() && iblockdata.isDestroyable()) { // Paper + BlockPos blockposition1 = blockposition.immutable(); diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 360e72b8e540f3cdb557bc59bca5e0a9cda239f8..d424337f7ee70d6b488dcb8b59a1bd59b87e3e53 100644 +index 562ce3115ff6814f52872eb0e36a95d255ea4187..f22a538e37835c0424b8f87c9bef1e6fd0764718 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -231,6 +231,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -285,6 +285,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public final it.unimi.dsi.fastutil.longs.Long2IntMap minimalTNT = new it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap(); // Sakura - visibility api public final me.samsuik.sakura.entity.merge.MergeHistory mergeHistory = new me.samsuik.sakura.entity.merge.MergeHistory(); // Sakura - cannon entity merging public final me.samsuik.sakura.explosion.density.BlockDensityCache densityCache = new me.samsuik.sakura.explosion.density.BlockDensityCache(); // Sakura - explosion density cache + public final me.samsuik.sakura.explosion.durable.DurableBlockManager durabilityManager = new me.samsuik.sakura.explosion.durable.DurableBlockManager(); // Sakura - explosion durable blocks - // Sakura start - add entity retrival methods with search limits + // Sakura start - add entity retrieval methods with search limits public void getLimitedEntities(Entity except, AABB box, Predicate predicate, List into, int limit, int search) { diff --git a/patches/server/0032-Destroy-Waterlogged-Blocks.patch b/patches/server/0032-Destroy-Waterlogged-Blocks.patch index a7afa7c..d077066 100644 --- a/patches/server/0032-Destroy-Waterlogged-Blocks.patch +++ b/patches/server/0032-Destroy-Waterlogged-Blocks.patch @@ -5,18 +5,18 @@ Subject: [PATCH] Destroy Waterlogged Blocks diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 0fdb87741c2f78a70a87a7e4036943be1830410b..6530890aaf429d8148e63380af548f70502a5389 100644 +index 411a2eeb6e8fabf0b755e7938396e1e239ea1ff4..06d6ed111de0349f4e4f382021f91056ae71fb86 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -284,6 +284,11 @@ public class Explosion { +@@ -307,6 +307,11 @@ public class Explosion { if (material != null && material.resistance() >= 0.0f && (this.level.sakuraConfig().cannons.explosion.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) { return Optional.of(material.resistance()); } + // Sakura start - destroy water logged blocks -+ if (!fluidState.isEmpty() && !blockState.liquid() && this.level.sakuraConfig().cannons.explosion.destroyWaterloggedBlocks) { -+ return Optional.of(ZERO_RESISTANCE); ++ if (!fluidState.isEmpty() && !(block instanceof net.minecraft.world.level.block.LiquidBlock) && this.level.sakuraConfig().cannons.explosion.destroyWaterloggedBlocks) { ++ return Optional.of(-0.3f); + } + // Sakura end - destroy water logged blocks } - return this.damageCalculator.getBlockExplosionResistance((Explosion)(Object)this, this.level, pos, blockState, fluidState); + return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState); diff --git a/patches/server/0034-Falling-Block-Stacking-Restrictions.patch b/patches/server/0033-Falling-Block-Stacking-Restrictions.patch similarity index 64% rename from patches/server/0034-Falling-Block-Stacking-Restrictions.patch rename to patches/server/0033-Falling-Block-Stacking-Restrictions.patch index 5de8241..5507fb2 100644 --- a/patches/server/0034-Falling-Block-Stacking-Restrictions.patch +++ b/patches/server/0033-Falling-Block-Stacking-Restrictions.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Falling Block Stacking Restrictions 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 6cccfdcc33e9ea2a79fe3fec5534e461fd697ecb..df58cbeffe4e343febce2b27fb38c007afda88c6 100644 +index e9e65c72f3bdd193ea5acf614c68a11f828ece10..abf1ddbb6f8fc6dd7dadf9c7a244863b1b89a473 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -251,7 +251,7 @@ public class FallingBlockEntity extends Entity { - boolean flag3 = FallingBlock.isFree(this.level().getBlockState(blockposition.below())) && (!flag || !flag1); - boolean flag4 = this.blockState.canSurvive(this.level(), blockposition) && !flag3; +@@ -259,7 +259,7 @@ public class FallingBlockEntity extends Entity { + boolean flag3 = FallingBlock.isFree(this.level.getBlockState(blockposition.below())) && (!flag || !flag1); + boolean flag4 = this.blockState.canSurvive(this.level, blockposition) && !flag3; - if (flag2 && flag4) { -+ if (flag2 && flag4 && level().sakuraConfig().cannons.sand.isFallingBlockInBounds(this)) { // Sakura - if (this.blockState.hasProperty(BlockStateProperties.WATERLOGGED) && this.level().getFluidState(blockposition).getType() == Fluids.WATER) { ++ if (flag2 && flag4 && this.level.sakuraConfig().cannons.sand.isFallingBlockInBounds(this)) { // Sakura + if (this.blockState.hasProperty(BlockStateProperties.WATERLOGGED) && this.level.getFluidState(blockposition).getType() == Fluids.WATER) { this.blockState = (BlockState) this.blockState.setValue(BlockStateProperties.WATERLOGGED, true); } diff --git a/patches/server/0035-Added-list-of-ItemEntity-s-that-ignore-explosions.patch b/patches/server/0034-Added-list-of-ItemEntity-s-that-ignore-explosions.patch similarity index 54% rename from patches/server/0035-Added-list-of-ItemEntity-s-that-ignore-explosions.patch rename to patches/server/0034-Added-list-of-ItemEntity-s-that-ignore-explosions.patch index cc17dcd..eb8e171 100644 --- a/patches/server/0035-Added-list-of-ItemEntity-s-that-ignore-explosions.patch +++ b/patches/server/0034-Added-list-of-ItemEntity-s-that-ignore-explosions.patch @@ -5,24 +5,24 @@ Subject: [PATCH] Added list of ItemEntity's that ignore explosions diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -index 29ce703a79f7893ac990ad80e0f1c1cf63546e6c..b658dc82397ed32aacda77d725d15f3d6ccc666c 100644 +index f0ccdfbd7d7be8c6e302609accf8fe9cac8885c4..b0b0ccd50276919e799eaa93f75904216e8e98b4 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -@@ -579,6 +579,17 @@ public class ItemEntity extends Entity implements TraceableEntity { - +@@ -87,6 +87,17 @@ public class ItemEntity extends Entity { + this.bobOffs = entity.bobOffs; } + // Sakura start + @Override -+ public boolean ignoreExplosion(net.minecraft.world.level.Explosion explosion) { -+ if (this.level().sakuraConfig().entity.items.explosionResistantItems.contains(this.getItem().getItem())) { ++ public boolean ignoreExplosion() { ++ if (this.level.sakuraConfig().entity.items.explosionResistantItems.contains(this.getItem().getItem())) { + return true; + } else { -+ return super.ignoreExplosion(explosion); ++ return super.ignoreExplosion(); + } + } + // Sakura end + - public void setTarget(@Nullable UUID owner) { - this.target = owner; - } + @Override + public boolean dampensVibrations() { + return this.getItem().is(ItemTags.DAMPENS_VIBRATIONS); diff --git a/patches/server/0036-Add-option-to-disable-entity-ai.patch b/patches/server/0035-Add-option-to-disable-entity-ai.patch similarity index 60% rename from patches/server/0036-Add-option-to-disable-entity-ai.patch rename to patches/server/0035-Add-option-to-disable-entity-ai.patch index 323424a..f79ce06 100644 --- a/patches/server/0036-Add-option-to-disable-entity-ai.patch +++ b/patches/server/0035-Add-option-to-disable-entity-ai.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Add option to disable entity ai diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java -index d2c92df28475f0a32a0134324eb0a5609a9afb99..61f93498759e722279a10f750ba2a6e14ab90048 100644 +index 49b983064ea810382b6112f5dc7f93ba4e5710bd..36eeb27679b2d1868cc9dc77f0df0f80e3c7333f 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -898,7 +898,7 @@ public abstract class Mob extends LivingEntity implements Targeting { +@@ -860,7 +860,7 @@ public abstract class Mob extends LivingEntity { + @Override protected final void serverAiStep() { ++this.noActionTime; - // Paper start - Allow nerfed mobs to jump and float -- if (!this.aware) { -+ if (!this.aware || this.level().sakuraConfig().entity.disableMobAi) { // Sakura +- if (!this.aware) { // Paper start - Allow nerfed mobs to jump, float and take water damage ++ if (!this.aware || this.level.sakuraConfig().entity.disableMobAi) { // Sakura // Paper start - Allow nerfed mobs to jump, float and take water damage if (goalFloat != null) { if (goalFloat.canUse()) goalFloat.tick(); this.getJumpControl().tick(); diff --git a/patches/server/0036-Consistent-Explosion-Radius.patch b/patches/server/0036-Consistent-Explosion-Radius.patch new file mode 100644 index 0000000..c827f35 --- /dev/null +++ b/patches/server/0036-Consistent-Explosion-Radius.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik <40902469+Samsuik@users.noreply.github.com> +Date: Mon, 20 Nov 2023 19:32:31 +0000 +Subject: [PATCH] Consistent Explosion Radius + + +diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java +index 06d6ed111de0349f4e4f382021f91056ae71fb86..0157727b9849e40d555460faf33e8a88da60ada9 100644 +--- a/src/main/java/net/minecraft/world/level/Explosion.java ++++ b/src/main/java/net/minecraft/world/level/Explosion.java +@@ -68,6 +68,7 @@ public class Explosion { + private final ObjectArrayList toBlow; + private final Map hitPlayers; + public boolean wasCanceled = false; // CraftBukkit - add field ++ private final boolean consistentRadius; // Sakura - consistent explosion radius + + public Explosion(Level world, @Nullable Entity entity, double x, double y, double z, float power, List affectedBlocks) { + this(world, entity, x, y, z, power, false, Explosion.BlockInteraction.DESTROY_WITH_DECAY, affectedBlocks); +@@ -96,6 +97,7 @@ public class Explosion { + this.blockInteraction = destructionType; + this.damageSource = damageSource == null ? DamageSource.explosion(this) : damageSource; + this.damageCalculator = behavior == null ? this.makeDamageCalculator(entity) : behavior; ++ this.consistentRadius = world.localConfig().config(new BlockPos(x, y, z)).consistentRadius; // Sakura - consistent explosion radius + } + + // Sakura start - optimise vanilla explosions +@@ -172,7 +174,7 @@ public class Explosion { + double rayY = explosionRays[ray++]; + double rayZ = explosionRays[ray++]; + +- float power = this.radius * (0.7F + this.level.random.nextFloat() * 0.6F); ++ float power = this.radius * (0.7F + (this.consistentRadius ? 0.7F : this.level.random.nextFloat()) * 0.6F); // Sakura - consistent explosion radius + double x = this.x; + double y = this.y; + double z = this.z; diff --git a/patches/server/0037-Reduce-living-entity-sensing.patch b/patches/server/0037-Reduce-living-entity-sensing.patch deleted file mode 100644 index 3ca881a..0000000 --- a/patches/server/0037-Reduce-living-entity-sensing.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Samsuik <40902469+Samsuik@users.noreply.github.com> -Date: Sat, 18 Nov 2023 17:24:19 +0000 -Subject: [PATCH] Reduce living entity sensing - - -diff --git a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java -index 5a059e1ec232d82e8e891ae78fea962bec2f878e..43a5d969595e8ecb3da3cf2ac949f042a7015578 100644 ---- a/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java -+++ b/src/main/java/net/minecraft/world/entity/ai/sensing/NearestLivingEntitySensor.java -@@ -15,8 +15,21 @@ public class NearestLivingEntitySensor extends Sensor - @Override - protected void doTick(ServerLevel world, T entity) { - AABB aABB = entity.getBoundingBox().inflate((double)this.radiusXZ(), (double)this.radiusY(), (double)this.radiusXZ()); -- List list = world.getEntitiesOfClass(LivingEntity.class, aABB, e -> e != entity && e.isAlive()); -- list.sort(Comparator.comparingDouble(entity::distanceToSqr)); -+ // Sakura start - reduce nearest living entity sensing -+ var distanceMap = new it.unimi.dsi.fastutil.objects.Reference2DoubleOpenHashMap<>(); -+ distanceMap.defaultReturnValue(Double.MAX_VALUE); -+ List list = world.getLimitedEntitiesOfClass(LivingEntity.class, aABB, (e) -> { -+ if (e == entity || !e.isAlive()) -+ return false; -+ double stored = distanceMap.getDouble(e.getType()); -+ double distance = e.distanceToSqr(entity); -+ if (stored < distance) -+ return false; -+ distanceMap.put(e.getType(), distance); -+ return true; -+ }, 12, Integer.MAX_VALUE); -+ java.util.Collections.reverse(list); -+ // Sakura end - reduce nearest living entity sensing - Brain brain = entity.getBrain(); - brain.setMemory(MemoryModuleType.NEAREST_LIVING_ENTITIES, list); - brain.setMemory(MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, new NearestVisibleLivingEntities(entity, list)); diff --git a/patches/server/0039-Remove-spigot-max-tnt-per-tick.patch b/patches/server/0037-Remove-spigot-max-tnt-per-tick.patch similarity index 66% rename from patches/server/0039-Remove-spigot-max-tnt-per-tick.patch rename to patches/server/0037-Remove-spigot-max-tnt-per-tick.patch index 57d9033..0235526 100644 --- a/patches/server/0039-Remove-spigot-max-tnt-per-tick.patch +++ b/patches/server/0037-Remove-spigot-max-tnt-per-tick.patch @@ -5,14 +5,16 @@ Subject: [PATCH] Remove spigot max tnt per tick diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index b4b509bcdd470ff21bbe6e0c3f58848c168bc120..9493fbae91f0ef6c3aaf81e548c225748f6f83b5 100644 +index bf6d7411716ff73c2f65965ec9bc33f70f719e19..0aed01b24e17aed7f5f7845ced78f64f57cabac3 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -110,7 +110,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -97,9 +97,7 @@ public class PrimedTnt extends Entity { @Override public void tick() { -- if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot +- if (level.spigotConfig.maxTntTicksPerTick > 0 && ++level.spigotConfig.currentPrimedTnt > level.spigotConfig.maxTntTicksPerTick) { +- return; +- } // Spigot + // Sakura - remove max tnt per tick if (!this.isNoGravity()) { this.addDeltaMovement(0.0D, -0.04D, 0.0D); // Sakura - reduce movement allocations diff --git a/patches/server/0038-Consistent-Explosion-Radius.patch b/patches/server/0038-Consistent-Explosion-Radius.patch deleted file mode 100644 index 8c1f45b..0000000 --- a/patches/server/0038-Consistent-Explosion-Radius.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Samsuik <40902469+Samsuik@users.noreply.github.com> -Date: Mon, 20 Nov 2023 19:32:31 +0000 -Subject: [PATCH] Consistent Explosion Radius - - -diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 529274e0fd3338254035b64742b18f2e009e1c6a..cc936e4c842dfc84f134e5dc1e3d0cac30494b28 100644 ---- a/src/main/java/net/minecraft/world/level/Explosion.java -+++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -74,6 +74,7 @@ public class Explosion { - public boolean wasCanceled = false; - public float yield; - // CraftBukkit end -+ private final boolean consistentRadius; // Sakura - consistent explosion radius - - public static DamageSource getDefaultDamageSource(Level world, @Nullable Entity source) { - return world.damageSources().explosion(source, Explosion.getIndirectSourceEntityInternal(source)); -@@ -111,6 +112,7 @@ public class Explosion { - this.largeExplosionParticles = emitterParticle; - this.explosionSound = soundEvent; - this.yield = this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F; // CraftBukkit -+ this.consistentRadius = world.localConfig().config(BlockPos.containing(x, y, z)).consistentRadius; // Sakura - consistent explosion radius - } - - // Sakura start - optimise paper explosions -@@ -585,7 +587,7 @@ public class Explosion { - double d2 = CACHED_RAYS[ray + 2]; - ray += 3; - // Paper end - optimise explosions -- float f = this.radius * (0.7F + this.level.random.nextFloat() * 0.6F); -+ float f = this.radius * (0.7F + (consistentRadius ? 0.7F : this.level.random.nextFloat()) * 0.6F); // Sakura - consistent explosion radius - double d4 = this.x; - double d5 = this.y; - double d6 = this.z; diff --git a/patches/server/0038-Option-to-configure-entity-water-sensitivity.patch b/patches/server/0038-Option-to-configure-entity-water-sensitivity.patch new file mode 100644 index 0000000..deb24ae --- /dev/null +++ b/patches/server/0038-Option-to-configure-entity-water-sensitivity.patch @@ -0,0 +1,19 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik <40902469+Samsuik@users.noreply.github.com> +Date: Tue, 21 Nov 2023 11:21:37 +0000 +Subject: [PATCH] Option to configure entity water sensitivity + + +diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java +index 3b4ba5c9e2aeab85f79a2d3a583017cd84f3c1cd..691f2c1d00d3cb17af017c997b11525709d6cd15 100644 +--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java ++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +@@ -3458,7 +3458,7 @@ public abstract class LivingEntity extends Entity { + } + } + // Paper end +- if (!this.level.isClientSide && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) { ++ if (!this.level.isClientSide && this.level.sakuraConfig().entity.waterSensitivity && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) { // Sakura - configure entity water sensitivity + this.hurt(DamageSource.DROWN, 1.0F); + } + diff --git a/patches/server/0041-Configure-cannon-physics-by-version.patch b/patches/server/0039-Configure-cannon-physics-by-version.patch similarity index 73% rename from patches/server/0041-Configure-cannon-physics-by-version.patch rename to patches/server/0039-Configure-cannon-physics-by-version.patch index 64550a4..cefcc24 100644 --- a/patches/server/0041-Configure-cannon-physics-by-version.patch +++ b/patches/server/0039-Configure-cannon-physics-by-version.patch @@ -5,26 +5,25 @@ Subject: [PATCH] Configure cannon physics by version diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java -index ae068cd14042bfab0fc3ab1a6473ec09fb1d7185..a6bc0bcd0694ee4f73d4e55c7929ac24e7cd341f 100644 +index 4db0a1b1270e2ff1ea1a4723b3dd28860f4c2087..93977027caa8c398ca6f0d2bb0890231adf8bf49 100644 --- a/src/main/java/io/papermc/paper/util/CollisionUtil.java +++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java -@@ -1457,7 +1457,15 @@ public final class CollisionUtil { - return new Vec3(x, y, z); +@@ -249,6 +249,14 @@ public final class CollisionUtil { } -+ // Sakura start - physics version api - public static Vec3 performAABBCollisions(final Vec3 moveVector, AABB axisalignedbb, final List potentialCollisions) { -+ return performAABBCollisions(moveVector, axisalignedbb, potentialCollisions, null); + public static Vec3 performCollisions(final Vec3 moveVector, AABB axisalignedbb, final List potentialCollisions) { ++ // Sakura start - physics version api ++ return performCollisions(moveVector, axisalignedbb, potentialCollisions, null); + } -+ public static Vec3 performAABBCollisions(final Vec3 moveVector, -+ AABB axisalignedbb, -+ final List potentialCollisions, -+ final me.samsuik.sakura.physics.PhysicsVersion physics) { ++ public static Vec3 performCollisions(final Vec3 moveVector, ++ AABB axisalignedbb, ++ final List potentialCollisions, ++ final me.samsuik.sakura.physics.PhysicsVersion physics) { + // Sakura end - physics version api double x = moveVector.x; double y = moveVector.y; double z = moveVector.z; -@@ -1469,7 +1477,10 @@ public final class CollisionUtil { +@@ -260,7 +268,10 @@ public final class CollisionUtil { } } @@ -35,43 +34,12 @@ index ae068cd14042bfab0fc3ab1a6473ec09fb1d7185..a6bc0bcd0694ee4f73d4e55c7929ac24 + // Sakura end - physics version api if (xSmaller && z != 0.0) { - z = performAABBCollisionsZ(axisalignedbb, z, potentialCollisions); -@@ -1495,9 +1506,17 @@ public final class CollisionUtil { - public static Vec3 performCollisions(final Vec3 moveVector, AABB axisalignedbb, - final List voxels, - final List aabbs) { -+ // Sakura start - physics version api -+ return performCollisions(moveVector, axisalignedbb, voxels, aabbs, null); -+ } -+ public static Vec3 performCollisions(final Vec3 moveVector, AABB axisalignedbb, -+ final List voxels, -+ final List aabbs, -+ final me.samsuik.sakura.physics.PhysicsVersion physics) { - if (voxels.isEmpty()) { - // fast track only AABBs -- return performAABBCollisions(moveVector, axisalignedbb, aabbs); -+ return performAABBCollisions(moveVector, axisalignedbb, aabbs, physics); -+ // Sakura end - physics version api - } - - double x = moveVector.x; -@@ -1512,7 +1531,10 @@ public final class CollisionUtil { - } - } - -- final boolean xSmaller = Math.abs(x) < Math.abs(z); -+ // Sakura start - physics version api -+ final boolean xSmaller = physics == null || physics.afterOrEqual(1_14_0) ? Math.abs(x) < Math.abs(z) -+ : physics.isLegacy() && Math.abs(x) > Math.abs(z); -+ // Sakura end - physics version api - - if (xSmaller && z != 0.0) { - z = performAABBCollisionsZ(axisalignedbb, z, aabbs); + z = performCollisionsZ(axisalignedbb, z, potentialCollisions); diff --git a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java -index 8857449c2443b1c9fc97a43a5bd3f446056259c7..1b6b535836d939fe07c509176871af4e76669760 100644 +index e654f48386e21e049facb6d90b356117af2bace6..a6b4cae3f04cda71629b5da3a08a8c4c7b51b8a7 100644 --- a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java +++ b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java -@@ -172,9 +172,15 @@ public abstract class SpecialisedExplosion extends Explosion { +@@ -148,9 +148,15 @@ public abstract class SpecialisedExplosion extends Explosion { if (distanceFromBottom <= 1.0) { double x = entity.getX() - pos.x; @@ -89,10 +57,10 @@ index 8857449c2443b1c9fc97a43a5bd3f446056259c7..1b6b535836d939fe07c509176871af4e if (distance != 0.0D) { x /= distance; diff --git a/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java -index 51f6c04e2a3861369013a4fb2b193a9df6c961cf..2ef0151556d090e1e890edbe8c9f02991db00eaa 100644 +index 52c1990bd3bcfe0a3f6e70748fca42f3e3994da4..49a698d9e5559aac4943b4b0ae3ced1305717f3c 100644 --- a/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java +++ b/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java -@@ -37,6 +37,13 @@ public final class TntExplosion extends SpecialisedExplosion { +@@ -34,6 +34,13 @@ public final class TntExplosion extends SpecialisedExplosion { this.bounds = new AABB(x, y, z, x, y, z); } @@ -107,10 +75,10 @@ index 51f6c04e2a3861369013a4fb2b193a9df6c961cf..2ef0151556d090e1e890edbe8c9f0299 protected void startExplosion() { for (int i = this.calculateExplosionPotential() - 1; i >= 0; --i) { diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 499618b41531103456be9b7879198bd9105ca6b4..413d129f44b48584b6b8dd59fae866838a01dfeb 100644 +index 5bd03c22c046938d90aa8de17f843b7a8394d0ae..626e192d8a7f9c9821e529c2bdd31b2a17c5695d 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -380,7 +380,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -362,7 +362,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { private final double[] pistonDeltas; private long pistonDeltasGameTime; private EntityDimensions dimensions; @@ -119,7 +87,7 @@ index 499618b41531103456be9b7879198bd9105ca6b4..413d129f44b48584b6b8dd59fae86683 public boolean isInPowderSnow; public boolean wasInPowderSnow; public boolean wasOnFire; -@@ -718,6 +718,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -679,6 +679,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } // Sakura end - cannon entity merging public boolean pushedByFluid = true; // Sakura - entity pushed by fluid api @@ -133,16 +101,7 @@ index 499618b41531103456be9b7879198bd9105ca6b4..413d129f44b48584b6b8dd59fae86683 public Entity(EntityType type, Level world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -1185,7 +1192,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - } - - protected void checkSupportingBlock(boolean onGround, @Nullable Vec3 movement) { -- if (onGround) { -+ if (onGround && this.physics.afterOrEqual(1_20_0)) { // Sakura - physics version - AABB axisalignedbb = this.getBoundingBox(); - AABB axisalignedbb1 = new AABB(axisalignedbb.minX, axisalignedbb.minY - 1.0E-6D, axisalignedbb.minZ, axisalignedbb.maxX, axisalignedbb.minY, axisalignedbb.maxZ); - Optional optional = this.level.findSupportingBlock(this, axisalignedbb1); -@@ -1247,7 +1254,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1144,7 +1151,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (this.noPhysics) { this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); } else { @@ -151,20 +110,18 @@ index 499618b41531103456be9b7879198bd9105ca6b4..413d129f44b48584b6b8dd59fae86683 movement = this.limitPistonMovement(movement); if (movement.equals(Vec3.ZERO)) { return; -@@ -1265,10 +1272,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1162,8 +1169,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { Vec3 vec3d1 = this.collideScan(movement); double d0 = vec3d1.lengthSqr(); - if (d0 > 1.0E-7D) { +- if (this.fallDistance != 0.0F && d0 >= 1.0D && !this.isFallingBlock) { + if (d0 > 1.0E-7D || this.physics.before(1_14_0)) { // Sakura - physics version api - // NOTE: if there are any blocks in the future that rely on fall distance make sure this is correct. - // The only block I am aware of is powdered snow that has a special case for falling blocks. -- if (this.fallDistance != 0.0F && d0 >= 1.0D && !isFallingBlock) { -+ if (this.fallDistance != 0.0F && d0 >= 1.0D && !isFallingBlock && this.physics.afterOrEqual(1_18_2)) { // Sakura - physics version api - BlockHitResult movingobjectpositionblock = this.level().clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this)); ++ if (this.fallDistance != 0.0F && d0 >= 1.0D && !this.isFallingBlock && this.physics.afterOrEqual(1_18_2)) { // Sakura - physics version api + BlockHitResult movingobjectpositionblock = this.level.clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this)); if (movingobjectpositionblock.getType() != HitResult.Type.MISS) { -@@ -1304,6 +1311,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1199,6 +1206,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (this.horizontalCollision) { Vec3 vec3d2 = this.getDeltaMovement(); @@ -177,7 +134,7 @@ index 499618b41531103456be9b7879198bd9105ca6b4..413d129f44b48584b6b8dd59fae86683 this.setDeltaMovement(flag ? 0.0D : vec3d2.x, vec3d2.y, flag1 ? 0.0D : vec3d2.z); } -@@ -1345,7 +1358,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1239,7 +1252,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.setPos(this.getX() + movement.x, this.getY() + movement.y, this.getZ() + movement.z); } else { this.wasOnFire = this.isOnFire(); @@ -186,7 +143,7 @@ index 499618b41531103456be9b7879198bd9105ca6b4..413d129f44b48584b6b8dd59fae86683 this.activatedTick = Math.max(this.activatedTick, MinecraftServer.currentTick + 20); // Paper this.activatedImmunityTick = Math.max(this.activatedImmunityTick, MinecraftServer.currentTick + 20); // Paper movement = this.limitPistonMovement(movement); -@@ -1372,8 +1385,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1266,8 +1279,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { Vec3 vec3d1 = this.collide(movement); double d0 = vec3d1.lengthSqr(); @@ -194,10 +151,10 @@ index 499618b41531103456be9b7879198bd9105ca6b4..413d129f44b48584b6b8dd59fae86683 - if (this.fallDistance != 0.0F && d0 >= 1.0D) { + if (d0 > 1.0E-7D || this.physics.before(1_14_0)) { // Sakura - physics version api + if (this.fallDistance != 0.0F && d0 >= 1.0D && this.physics.afterOrEqual(1_18_2)) { // Sakura - physics version api - BlockHitResult movingobjectpositionblock = this.level().clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this)); + BlockHitResult movingobjectpositionblock = this.level.clip(new ClipContext(this.position(), this.position().add(vec3d1), ClipContext.Block.FALLDAMAGE_RESETTING, ClipContext.Fluid.WATER, this)); if (movingobjectpositionblock.getType() != HitResult.Type.MISS) { -@@ -1409,6 +1422,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1303,6 +1316,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (this.horizontalCollision) { Vec3 vec3d2 = this.getDeltaMovement(); @@ -210,16 +167,16 @@ index 499618b41531103456be9b7879198bd9105ca6b4..413d129f44b48584b6b8dd59fae86683 this.setDeltaMovement(flag ? 0.0D : vec3d2.x, vec3d2.y, flag1 ? 0.0D : vec3d2.z); } -@@ -1723,7 +1742,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1591,7 +1610,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } else { final AABB bb = currBoundingBox.expandTowards(movement.x, movement.y, movement.z); - collectCollisions(bb, potentialCollisionsVoxel, potentialCollisionsBB); -- return io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB); -+ return io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB, this.physics); // Sakura - physics version api + this.collectCollisions(bb, potentialCollisionsBB); +- return io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisionsBB); ++ return io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisionsBB, this.physics); // Sakura - physics version api } } -@@ -1732,7 +1751,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1600,7 +1619,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { double y = movement.y; double z = movement.z; @@ -230,35 +187,35 @@ index 499618b41531103456be9b7879198bd9105ca6b4..413d129f44b48584b6b8dd59fae86683 + // Sakura end - physics version api if (y != 0.0) { - y = scanY(currBoundingBox, y, voxelList, bbList); -@@ -1848,7 +1870,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - return movement; - } + y = this.scanY(currBoundingBox, y, bbList); +@@ -1703,7 +1725,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + io.papermc.paper.util.CollisionUtil.addBoxesToIfIntersects(world.getWorldBorder().getCollisionShape(), collisionBox, potentialCollisions); + } -- final Vec3 limitedMoveVector = io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB); -+ final Vec3 limitedMoveVector = io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisionsVoxel, potentialCollisionsBB, this.physics); // Sakura - physics version api +- final Vec3 limitedMoveVector = io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisions); ++ final Vec3 limitedMoveVector = io.papermc.paper.util.CollisionUtil.performCollisions(movement, currBoundingBox, potentialCollisions, this.physics); // Sakura - physics version api - if (stepHeight > 0.0 - && (onGround || (limitedMoveVector.y != movement.y && movement.y < 0.0)) -@@ -1964,8 +1986,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S + if (stepHeight > 0.0 + && (this.onGround || (limitedMoveVector.y != movement.y && movement.y < 0.0)) +@@ -1822,8 +1844,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { protected void checkInsideBlocks() { AABB axisalignedbb = this.getBoundingBox(); -- BlockPos blockposition = BlockPos.containing(axisalignedbb.minX + 1.0E-7D, axisalignedbb.minY + 1.0E-7D, axisalignedbb.minZ + 1.0E-7D); -- BlockPos blockposition1 = BlockPos.containing(axisalignedbb.maxX - 1.0E-7D, axisalignedbb.maxY - 1.0E-7D, axisalignedbb.maxZ - 1.0E-7D); +- BlockPos blockposition = new BlockPos(axisalignedbb.minX + 1.0E-7D, axisalignedbb.minY + 1.0E-7D, axisalignedbb.minZ + 1.0E-7D); +- BlockPos blockposition1 = new BlockPos(axisalignedbb.maxX - 1.0E-7D, axisalignedbb.maxY - 1.0E-7D, axisalignedbb.maxZ - 1.0E-7D); + // Sakura start - physics version + double offset = this.physics.afterOrEqual(1_19_3) ? 1.0E-7D : 0.001D; -+ BlockPos blockposition = BlockPos.containing(axisalignedbb.minX + offset, axisalignedbb.minY + offset, axisalignedbb.minZ + offset); -+ BlockPos blockposition1 = BlockPos.containing(axisalignedbb.maxX - offset, axisalignedbb.maxY - offset, axisalignedbb.maxZ - offset); ++ BlockPos blockposition = new BlockPos(axisalignedbb.minX + offset, axisalignedbb.minY + offset, axisalignedbb.minZ + offset); ++ BlockPos blockposition1 = new BlockPos(axisalignedbb.maxX - offset, axisalignedbb.maxY - offset, axisalignedbb.maxZ - offset); + // Sakura end - if (this.level().hasChunksAt(blockposition, blockposition1)) { + if (this.level.hasChunksAt(blockposition, blockposition1)) { BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); 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 df58cbeffe4e343febce2b27fb38c007afda88c6..e7aa5b0f976c8bf236240c4c9708ea1751a03629 100644 +index abf1ddbb6f8fc6dd7dadf9c7a244863b1b89a473..05457d0a8fedeb66340486f8c82b2a694fe09378 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -90,6 +90,8 @@ public class FallingBlockEntity extends Entity { +@@ -86,6 +86,8 @@ public class FallingBlockEntity extends Entity { this.yo = y; this.zo = z; this.setStartPos(this.blockPosition()); @@ -267,9 +224,9 @@ index df58cbeffe4e343febce2b27fb38c007afda88c6..e7aa5b0f976c8bf236240c4c9708ea17 } public static FallingBlockEntity fall(Level world, BlockPos pos, BlockState state) { -@@ -102,7 +104,11 @@ public class FallingBlockEntity extends Entity { +@@ -98,7 +100,11 @@ public class FallingBlockEntity extends Entity { FallingBlockEntity entityfallingblock = new FallingBlockEntity(world, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, iblockdata.hasProperty(BlockStateProperties.WATERLOGGED) ? (BlockState) iblockdata.setValue(BlockStateProperties.WATERLOGGED, false) : iblockdata); - if (!CraftEventFactory.callEntityChangeBlockEvent(entityfallingblock, blockposition, iblockdata.getFluidState().createLegacyBlock())) return entityfallingblock; // CraftBukkit + if (CraftEventFactory.callEntityChangeBlockEvent(entityfallingblock, blockposition, iblockdata.getFluidState().createLegacyBlock()).isCancelled()) return entityfallingblock; // CraftBukkit - world.setBlock(blockposition, iblockdata.getFluidState().createLegacyBlock(), 3); + // Sakura start - physics version api @@ -280,7 +237,7 @@ index df58cbeffe4e343febce2b27fb38c007afda88c6..e7aa5b0f976c8bf236240c4c9708ea17 world.addFreshEntity(entityfallingblock, spawnReason); // CraftBukkit return entityfallingblock; } -@@ -191,9 +197,46 @@ public class FallingBlockEntity extends Entity { +@@ -187,9 +193,46 @@ public class FallingBlockEntity extends Entity { // Sakura start @Override public final double getEyeY() { @@ -302,33 +259,33 @@ index df58cbeffe4e343febce2b27fb38c007afda88c6..e7aa5b0f976c8bf236240c4c9708ea17 + private BlockPos patchedBlockPosition() { + // mitigate the floating point issue for sand breaking below y-0 + // 1.0e-12 allows tech that uses indirect collision clipping to still function -+ return BlockPos.containing(this.getX(), this.getY() + 1.0e-12, this.getZ()); ++ return new BlockPos(this.getX(), this.getY() + 1.0e-12, this.getZ()); + } + + private boolean isAbleToStackOnBlock() { -+ BlockPos pos = BlockPos.containing(this.getX(), this.getY() - 0.001f, this.getZ()); -+ BlockState state = this.level().getBlockState(pos); ++ BlockPos pos = new BlockPos(this.getX(), this.getY() - 0.001f, this.getZ()); ++ BlockState state = this.level.getBlockState(pos); + return !FallingBlock.isFree(state); + } + + private void removeBlockOnFall(Block block) { + BlockPos blockposition = this.blockPosition(); -+ BlockState blockstate = this.level().getBlockState(blockposition); ++ BlockState blockstate = this.level.getBlockState(blockposition); + -+ if (blockstate.is(block) && CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState())) { -+ this.level().removeBlock(blockposition, false); ++ if (blockstate.is(block) && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) { ++ this.level.removeBlock(blockposition, false); + } else { + if (blockstate.is(block)) { -+ ((ServerLevel) level()).getChunkSource().blockChanged(blockposition); ++ ((ServerLevel) this.level).getChunkSource().blockChanged(blockposition); + } -+ this.discard(EntityRemoveEvent.Cause.DESPAWN); ++ this.discard(); + } + } + // Sakura end - physics version api @Override public void tick() { -@@ -202,9 +245,16 @@ public class FallingBlockEntity extends Entity { +@@ -203,9 +246,15 @@ public class FallingBlockEntity extends Entity { } else { Block block = this.blockState.getBlock(); @@ -336,7 +293,6 @@ index df58cbeffe4e343febce2b27fb38c007afda88c6..e7aa5b0f976c8bf236240c4c9708ea17 + if (this.time == 0 && this.physics.before(1_18_2)) { + this.removeBlockOnFall(block); + } -+ ++this.time; if (!this.isNoGravity()) { - this.addDeltaMovement(0.0D, -0.04D, 0.0D); // Sakura - reduce movement allocations @@ -346,27 +302,26 @@ index df58cbeffe4e343febce2b27fb38c007afda88c6..e7aa5b0f976c8bf236240c4c9708ea17 } this.moveBasic(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise simple entity movement -@@ -218,8 +268,16 @@ public class FallingBlockEntity extends Entity { +@@ -226,8 +275,15 @@ public class FallingBlockEntity extends Entity { return; } - // Paper end - Configurable falling blocks height nerf + // Paper end + // Sakura start - physics version api + if (this.physics.before(1_12_0)) { + this.scaleDeltaMovement(0.98F); + } - if (!this.level().isClientSide) { + if (!this.level.isClientSide) { - BlockPos blockposition = this.blockPosition(); + // Patching the floating point issue on modern versions can break some cannons that rely on it. + // However, it makes sense for legacy versions pre-1.17 before the world height change. + BlockPos blockposition = this.physics.before(1_17_0) ? this.patchedBlockPosition() : this.blockPosition(); + // Sakura end - physics version api -+ boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock; - boolean flag1 = flag && this.level().getFluidState(blockposition).is(FluidTags.WATER); + boolean flag1 = flag && this.level.getFluidState(blockposition).is(FluidTags.WATER); double d0 = this.getDeltaMovement().lengthSqr(); -@@ -244,8 +302,11 @@ public class FallingBlockEntity extends Entity { +@@ -252,8 +308,11 @@ public class FallingBlockEntity extends Entity { } else { - BlockState iblockdata = this.level().getBlockState(blockposition); + BlockState iblockdata = this.level.getBlockState(blockposition); - this.multiplyDeltaMovement(0.7D, -0.5D, 0.7D); // Sakura - reduce movement allocations - if (!iblockdata.is(Blocks.MOVING_PISTON)) { @@ -376,16 +331,16 @@ index df58cbeffe4e343febce2b27fb38c007afda88c6..e7aa5b0f976c8bf236240c4c9708ea17 + if (!iblockdata.is(Blocks.MOVING_PISTON) && (flag1 || !this.physics.isWithin(1_9_0, 1_12_0) || this.isAbleToStackOnBlock())) { + // Sakura end - physics version api if (!this.cancelDrop) { - boolean flag2 = iblockdata.canBeReplaced((BlockPlaceContext) (new DirectionalPlaceContext(this.level(), blockposition, Direction.DOWN, ItemStack.EMPTY, Direction.UP))); - boolean flag3 = FallingBlock.isFree(this.level().getBlockState(blockposition.below())) && (!flag || !flag1); -@@ -312,7 +373,12 @@ public class FallingBlockEntity extends Entity { + boolean flag2 = iblockdata.canBeReplaced((BlockPlaceContext) (new DirectionalPlaceContext(this.level, blockposition, Direction.DOWN, ItemStack.EMPTY, Direction.UP))); + boolean flag3 = FallingBlock.isFree(this.level.getBlockState(blockposition.below())) && (!flag || !flag1); +@@ -320,7 +379,12 @@ public class FallingBlockEntity extends Entity { } } - this.scaleDeltaMovement(0.98D); // Sakura - reduce movement allocations + // Sakura start - physics version api -+ if (physics.afterOrEqual(1_12_0)) { -+ double drag = physics.before(1_14_0) ? 0.98F : 0.98D; ++ if (this.physics.afterOrEqual(1_12_0)) { ++ double drag = this.physics.before(1_14_0) ? 0.98F : 0.98D; + this.scaleDeltaMovement(drag); // Sakura - reduce movement allocations + } + // Sakura end - physics version api @@ -393,10 +348,10 @@ index df58cbeffe4e343febce2b27fb38c007afda88c6..e7aa5b0f976c8bf236240c4c9708ea17 } diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -index 2db76425a1f295ad179aacfb3abb7efb1be647d9..e7dd0c8aab980d9850a2124598f8a0369603e825 100644 +index 0aed01b24e17aed7f5f7845ced78f64f57cabac3..5f61c5c591ac68e843da22cc1efac7e7308e8d99 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -60,6 +60,13 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -48,6 +48,13 @@ public class PrimedTnt extends Entity { case Y -> multiplyDeltaMovement(0, 1, 0); } // Sakura end @@ -410,7 +365,7 @@ index 2db76425a1f295ad179aacfb3abb7efb1be647d9..e7dd0c8aab980d9850a2124598f8a036 } @Override -@@ -107,12 +114,30 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -94,12 +101,30 @@ public class PrimedTnt extends Entity { } } // Sakura end @@ -442,15 +397,15 @@ index 2db76425a1f295ad179aacfb3abb7efb1be647d9..e7dd0c8aab980d9850a2124598f8a036 } this.moveBasic(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise simple entity movement -@@ -122,15 +147,19 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -109,15 +134,19 @@ public class PrimedTnt extends Entity { return; } - // Paper end - Configurable TNT height nerf + // Paper end - this.scaleDeltaMovement(0.98D); // Sakura - reduce movement allocations + // Sakura start - physics version api + double drag = this.physics.before(1_14_0) ? 0.98F : 0.98D; + this.scaleDeltaMovement(drag); // Sakura - reduce movement allocations - if (this.onGround()) { + if (this.onGround) { - this.multiplyDeltaMovement(0.7D, -0.5D, 0.7D); // Sakura - reduce movement allocations + double friction = this.physics.before(1_14_0) ? 0.7F : 0.7D; + this.multiplyDeltaMovement(friction, -0.5D, friction); // Sakura - reduce movement allocations @@ -465,77 +420,77 @@ index 2db76425a1f295ad179aacfb3abb7efb1be647d9..e7dd0c8aab980d9850a2124598f8a036 // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event // this.discard(); this.respawnMerged(); // Sakura -@@ -183,7 +212,10 @@ public class PrimedTnt extends Entity implements TraceableEntity { - ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive)this.getBukkitEntity()); +@@ -172,7 +201,10 @@ public class PrimedTnt extends Entity { + this.level.getCraftServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { -- this.level().explode(this, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.TNT); +- this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.TNT); + // Sakura start - physics version api + double pos = this.physics.before(1_10_0) ? this.getY() + (double) 0.49f : this.getY(0.0625D); -+ this.level().explode(this, this.getX(), pos, this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.TNT); ++ this.level.explode(this, this.getX(), pos, this.getZ(), event.getRadius(), event.getFire(), Level.ExplosionInteraction.TNT); + // Sakura end } // CraftBukkit end } -@@ -244,7 +276,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { - // Paper start - Option to prevent TNT from moving in water +@@ -216,7 +248,7 @@ public class PrimedTnt extends Entity { + // Paper start - Optional prevent TNT from moving in water @Override public boolean isPushedByFluid() { -- return !level().paperConfig().fixes.preventTntFromMovingInWater && level().sakuraConfig().cannons.mechanics.tntFlowsInWater && super.isPushedByFluid(); // Sakura - convenience -+ return !level().paperConfig().fixes.preventTntFromMovingInWater && !this.physics.isLegacy() && level().sakuraConfig().cannons.mechanics.tntFlowsInWater && super.isPushedByFluid(); // Sakura - physics version // Sakura - convenience +- return !level.paperConfig().fixes.preventTntFromMovingInWater && this.level.sakuraConfig().cannons.mechanics.tntFlowsInWater && super.isPushedByFluid(); // Sakura - cannon mechanics ++ return !level.paperConfig().fixes.preventTntFromMovingInWater && !this.physics.isLegacy() && this.level.sakuraConfig().cannons.mechanics.tntFlowsInWater && super.isPushedByFluid(); // Sakura - physics version // Sakura - cannon mechanics } - // Paper end - Option to prevent TNT from moving in water + // Paper end } diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 6761eed10948a92d686168e5784fd5f8265953e6..1582c81bbb00b8dd8fadde94a79ff091943a13c2 100644 +index 0157727b9849e40d555460faf33e8a88da60ada9..cd8f19b6644fa43460f97525cf47526fd5db40b3 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -75,6 +75,7 @@ public class Explosion { - public float yield; - // CraftBukkit end +@@ -69,6 +69,7 @@ public class Explosion { + private final Map hitPlayers; + public boolean wasCanceled = false; // CraftBukkit - add field private final boolean consistentRadius; // Sakura - consistent explosion radius + protected final me.samsuik.sakura.physics.PhysicsVersion physics; // Sakura - physics version api - public static DamageSource getDefaultDamageSource(Level world, @Nullable Entity source) { - return world.damageSources().explosion(source, Explosion.getIndirectSourceEntityInternal(source)); -@@ -113,6 +114,7 @@ public class Explosion { - this.explosionSound = soundEvent; - this.yield = this.blockInteraction == Explosion.BlockInteraction.DESTROY_WITH_DECAY ? 1.0F / this.radius : 1.0F; // CraftBukkit - this.consistentRadius = world.localConfig().config(BlockPos.containing(x, y, z)).consistentRadius; // Sakura - consistent explosion radius -+ this.physics = entity != null ? entity.physics() : world.localConfig().config(BlockPos.containing(x, y, z)).physicsVersion; // Sakura - physics version api + public Explosion(Level world, @Nullable Entity entity, double x, double y, double z, float power, List affectedBlocks) { + this(world, entity, x, y, z, power, false, Explosion.BlockInteraction.DESTROY_WITH_DECAY, affectedBlocks); +@@ -98,6 +99,7 @@ public class Explosion { + this.damageSource = damageSource == null ? DamageSource.explosion(this) : damageSource; + this.damageCalculator = behavior == null ? this.makeDamageCalculator(entity) : behavior; + this.consistentRadius = world.localConfig().config(new BlockPos(x, y, z)).consistentRadius; // Sakura - consistent explosion radius ++ this.physics = entity != null ? entity.physics() : world.localConfig().config(new BlockPos(x, y, z)).physicsVersion; // Sakura - physics version api } - // Sakura start - optimise paper explosions -@@ -506,8 +508,12 @@ public class Explosion { - final float density = entity.level().densityCache.getKnownDensity(vec3d1); + // Sakura start - optimise vanilla explosions +@@ -209,7 +211,12 @@ public class Explosion { + } + + BlockState blockstate = currChunk.getBlockState(blockX, blockY, blockZ); +- if (!blockstate.isDestroyable() || this.level.isOutsideBuildHeight(blockY)) { ++ // Sakura start - physics version api ++ final boolean outsideWorld = this.level.isOutsideBuildHeight(blockY); ++ if (this.physics.before(1_17_0) && outsideWorld) { ++ continue; ++ } else if (!blockstate.isDestroyable() || outsideWorld) { ++ // Sakura end - physics version api + break; + } else { + FluidState fluid = blockstate.getFluidState(); +@@ -353,8 +360,13 @@ public class Explosion { + final float density = entity.level.densityCache.getKnownDensity(vec3d1); if (density != me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) { hitResult = density != 0.0f ? net.minecraft.world.phys.HitResult.Type.MISS : net.minecraft.world.phys.HitResult.Type.BLOCK; + // Sakura start - physics version api + } else if (entity.physics().before(1_14_0)) { -+ hitResult = entity.level().rayTrace(vec3d1, source); ++ hitResult = entity.level.rayTrace(vec3d1, source); } else { -- hitResult = entity.level().clip(new ClipContext(vec3d1, source, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType(); -+ hitResult = entity.level().clip(new ClipContext(vec3d1, source, entity.physics().afterOrEqual(1_16_0) ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, entity)).getType(); +- hitResult = entity.level.clip(new ClipContext(vec3d1, source, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)).getType(); ++ ClipContext.Block context = entity.physics().afterOrEqual(1_16_0) ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE; ++ hitResult = entity.level.clip(new ClipContext(vec3d1, source, context, ClipContext.Fluid.NONE, entity)).getType(); + // Sakura end - physics version api } if (hitResult == HitResult.Type.MISS) { // Sakura end - replace density cache -@@ -612,6 +618,14 @@ public class Explosion { - } - - if (cachedBlock.outOfWorld) { -+ // Sakura start - physics version api -+ if (this.physics.before(1_17_0)) { -+ d4 += d0; -+ d5 += d1; -+ d6 += d2; -+ continue; -+ } -+ // Sakura end - physics version api - break; - } - -@@ -717,9 +731,15 @@ public class Explosion { +@@ -418,9 +430,15 @@ public class Explosion { if (d7 <= 1.0D) { double d8 = entity.getX() - this.x; @@ -552,41 +507,14 @@ index 6761eed10948a92d686168e5784fd5f8265953e6..1582c81bbb00b8dd8fadde94a79ff091 if (d11 != 0.0D) { d8 /= d11; -@@ -1054,7 +1074,7 @@ public class Explosion { - // Sakura start - replace density cache - float blockDensity = this.level.densityCache.getDensity(vec3d, entity); - if (blockDensity == me.samsuik.sakura.explosion.density.BlockDensityCache.UNKNOWN_DENSITY) { -- blockDensity = this.getSeenFraction(vec3d, entity, blockCache, blockPos); // Paper - optimise explosions; -+ blockDensity = this.getSeenPercent(vec3d, entity, blockCache, blockPos); // Sakura - physics version api // Paper - optimise explosions; - this.level.densityCache.putDensity(vec3d, entity, blockDensity); - // Sakura end - replace density cache - } -@@ -1062,6 +1082,17 @@ public class Explosion { - return blockDensity; - } - -+ // Sakura start - physics version api -+ private float getSeenPercent(Vec3 vec3d, Entity entity, ExplosionBlockCache[] blockCache, BlockPos.MutableBlockPos blockPos) { -+ if (this.physics.afterOrEqual(1_16_0)) { -+ // Papers impl is untouched, intended to be used as a fast path. -+ return this.getSeenFraction(vec3d, entity, blockCache, blockPos); -+ } else { -+ return getSeenPercent(vec3d, entity); -+ } -+ } -+ // Sakura end - physics version api -+ - static class CacheKey { - private final Level world; - private final double posX, posY, posZ; diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 8e5bd44b93cfd4b3abdb76a5ee6dd6eb4e714223..ea15ef94540b78029c8f78021ace6998f62a701a 100644 +index f22a538e37835c0424b8f87c9bef1e6fd0764718..3c37eaf12fc256a8edf5a5d060e4ca262ec83108 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -266,6 +266,205 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -319,6 +319,205 @@ public abstract class Level implements LevelAccessor, AutoCloseable { return this.getLimitedEntities(except, box, net.minecraft.world.entity.EntitySelector.NO_SPECTATORS, limit, search); } - // Sakura end - add entity retrival methods with search limits + // Sakura end - add entity retrieval methods with search limits + // Sakura start - physics version api + public net.minecraft.world.phys.BlockHitResult.Type rayTrace(net.minecraft.world.phys.Vec3 vec3d, net.minecraft.world.phys.Vec3 vec3d1) { + // May deviate from vanilla here; I remember noticing a bug and there's no fix commit. @@ -787,13 +715,13 @@ index 8e5bd44b93cfd4b3abdb76a5ee6dd6eb4e714223..ea15ef94540b78029c8f78021ace6998 + } + // Sakura end - physics version api - protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, RegistryAccess iregistrycustom, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, Supplier sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - create paper world config; Async-Anti-Xray: Pass executor + protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, Supplier sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - Async-Anti-Xray - Pass executor this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot diff --git a/src/main/java/net/minecraft/world/level/block/FallingBlock.java b/src/main/java/net/minecraft/world/level/block/FallingBlock.java -index 7c994b72820cbff158009e86b7d540cb479b01b2..6456e0c20d654b6b001e73bf815da9efd2883a1c 100644 +index 6d453d78faa2af7fdb5d49f56909af3284bf0769..830137ef8eb6bab00c47d1dcfa53bdfd83aa9eee 100644 --- a/src/main/java/net/minecraft/world/level/block/FallingBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FallingBlock.java -@@ -35,6 +35,15 @@ public abstract class FallingBlock extends Block implements Fallable { +@@ -31,6 +31,15 @@ public class FallingBlock extends Block implements Fallable { return super.updateShape(state, direction, neighborState, world, pos, neighborPos); } @@ -810,10 +738,10 @@ index 7c994b72820cbff158009e86b7d540cb479b01b2..6456e0c20d654b6b001e73bf815da9ef public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { if (isFree(world.getBlockState(pos.below())) && pos.getY() >= world.getMinBuildHeight()) { diff --git a/src/main/java/net/minecraft/world/level/block/FenceGateBlock.java b/src/main/java/net/minecraft/world/level/block/FenceGateBlock.java -index 6524272aab5a876e2a2164181da72c765959b550..4c242b501e7e5c7af6676b9554b00405838c4eb0 100644 +index a444a335727cf790e63fb9d0fd5d64657675b35c..6b8a61169b324e5b59502e4bf89266ee7f87861a 100644 --- a/src/main/java/net/minecraft/world/level/block/FenceGateBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FenceGateBlock.java -@@ -180,8 +180,13 @@ public class FenceGateBlock extends HorizontalDirectionalBlock { +@@ -154,8 +154,13 @@ public class FenceGateBlock extends HorizontalDirectionalBlock { } // CraftBukkit end @@ -827,16 +755,21 @@ index 6524272aab5a876e2a2164181da72c765959b550..4c242b501e7e5c7af6676b9554b00405 + world.setBlock(pos, (BlockState) ((BlockState) state.setValue(FenceGateBlock.POWERED, flag1)).setValue(FenceGateBlock.OPEN, openGate), 2); + // Sakura end if ((Boolean) state.getValue(FenceGateBlock.OPEN) != flag1) { - world.playSound((Player) null, pos, flag1 ? this.type.fenceGateOpen() : this.type.fenceGateClose(), SoundSource.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.1F + 0.9F); + world.playSound((Player) null, pos, flag1 ? this.openSound : this.closeSound, SoundSource.BLOCKS, 1.0F, world.getRandom().nextFloat() * 0.1F + 0.9F); world.gameEvent((Entity) null, flag1 ? GameEvent.BLOCK_OPEN : GameEvent.BLOCK_CLOSE, pos); diff --git a/src/main/java/net/minecraft/world/level/block/LadderBlock.java b/src/main/java/net/minecraft/world/level/block/LadderBlock.java -index dbfbf477ceef5bd162e1740471f719466f49c1a8..86ed1e1cdbab5004a767831bcb0b34d2b2c3adf8 100644 +index 6bcc83245e8046518921b82d948d45900ae0c8db..cee2e15af942915b4a68cd66e799a2c8b33e6823 100644 --- a/src/main/java/net/minecraft/world/level/block/LadderBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LadderBlock.java -@@ -28,6 +28,21 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock { - protected static final VoxelShape WEST_AABB = Block.box(13.0, 0.0, 0.0, 16.0, 16.0, 16.0); - protected static final VoxelShape SOUTH_AABB = Block.box(0.0, 0.0, 0.0, 16.0, 16.0, 3.0); - protected static final VoxelShape NORTH_AABB = Block.box(0.0, 0.0, 13.0, 16.0, 16.0, 16.0); +@@ -32,8 +32,33 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock { + this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, Boolean.valueOf(false))); + } + ++ // Sakura start - physics version api ++ @Override ++ public final boolean hasDynamicShape() { ++ return true; ++ } + // Sakura start - physics version api + protected static final VoxelShape LEGACY_EAST_AABB = Block.box(0.0, 0.0, 0.0, 2.0, 16.0, 16.0); + protected static final VoxelShape LEGACY_WEST_AABB = Block.box(14.0, 0.0, 0.0, 16.0, 16.0, 16.0); @@ -852,18 +785,6 @@ index dbfbf477ceef5bd162e1740471f719466f49c1a8..86ed1e1cdbab5004a767831bcb0b34d2 + }; + } + // Sakura end - physics version api - - @Override - public MapCodec codec() { -@@ -39,8 +54,18 @@ public class LadderBlock extends Block implements SimpleWaterloggedBlock { - this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(WATERLOGGED, Boolean.valueOf(false))); - } - -+ // Sakura start - physics version api -+ @Override -+ public final boolean hasDynamicShape() { -+ return true; -+ } + @Override public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { @@ -875,10 +796,10 @@ index dbfbf477ceef5bd162e1740471f719466f49c1a8..86ed1e1cdbab5004a767831bcb0b34d2 case NORTH: return NORTH_AABB; diff --git a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java -index 9b3dcf1a4d4cece92a629506d341f6bfe79d13d0..1ed3568b363df38b196567d8a93089550913d659 100644 +index 43e8ef1d6a65d4fd3fe53a587639ffb814368217..28bdb44599a8862d58cfb2e087119b843f25f311 100644 --- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java -@@ -192,8 +192,26 @@ public class LiquidBlock extends Block implements BucketPickup { +@@ -154,8 +154,26 @@ public class LiquidBlock extends Block implements BucketPickup { BlockPos blockposition1 = pos.relative(enumdirection.getOpposite()); if (world.getFluidState(blockposition1).is(FluidTags.WATER)) { @@ -908,10 +829,10 @@ index 9b3dcf1a4d4cece92a629506d341f6bfe79d13d0..1ed3568b363df38b196567d8a9308955 if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, pos, block.defaultBlockState())) { this.fizz(world, pos); diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java -index 9033043a0e8c749291582f99d26685ca1828e4c8..2b449577ced233c7265b2b4972078ac2939b57d4 100644 +index 5ea09cc455bd86beb450f0e0275d7c6c8da98084..002f807d19232f14fe8b195e0404a9bf333a9bdf 100644 --- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -700,6 +700,10 @@ public class RedStoneWireBlock extends Block { +@@ -661,6 +661,10 @@ public class RedStoneWireBlock extends Block { public InteractionResult use(BlockState state, Level world, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) { if (!player.getAbilities().mayBuild) { return InteractionResult.PASS; @@ -923,18 +844,18 @@ index 9033043a0e8c749291582f99d26685ca1828e4c8..2b449577ced233c7265b2b4972078ac2 if (RedStoneWireBlock.isCross(state) || RedStoneWireBlock.isDot(state)) { BlockState iblockdata1 = RedStoneWireBlock.isCross(state) ? this.defaultBlockState() : this.crossState; diff --git a/src/main/java/net/minecraft/world/level/block/WaterlilyBlock.java b/src/main/java/net/minecraft/world/level/block/WaterlilyBlock.java -index 05e14322e519d1399e87beb532e1cc4a95f689aa..8b86ec469d7d0a0a7a62d563bd585b5b46815517 100644 +index bd4295f8d24ca9fd8c3af31abcd13da24db1c5d5..648a50e55baabc37fb7376aa061ae63110297c2e 100644 --- a/src/main/java/net/minecraft/world/level/block/WaterlilyBlock.java +++ b/src/main/java/net/minecraft/world/level/block/WaterlilyBlock.java -@@ -21,6 +21,7 @@ public class WaterlilyBlock extends BushBlock { +@@ -17,6 +17,7 @@ import net.minecraft.world.phys.shapes.VoxelShape; + public class WaterlilyBlock extends BushBlock { - public static final MapCodec CODEC = simpleCodec(WaterlilyBlock::new); protected static final VoxelShape AABB = Block.box(1.0D, 0.0D, 1.0D, 15.0D, 1.5D, 15.0D); + protected static final VoxelShape LEGACY_AABB = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 0.25D, 16.0D); // Sakura - @Override - public MapCodec codec() { -@@ -46,8 +47,18 @@ public class WaterlilyBlock extends BushBlock { + protected WaterlilyBlock(BlockBehaviour.Properties settings) { + super(settings); +@@ -32,8 +33,18 @@ public class WaterlilyBlock extends BushBlock { } @@ -954,10 +875,10 @@ index 05e14322e519d1399e87beb532e1cc4a95f689aa..8b86ec469d7d0a0a7a62d563bd585b5b } diff --git a/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java b/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java -index 54abde54b2341d85c6f02a0a28f02a0e229de42b..4bd60b3f16809bb89212ada6dfc374f0595fec80 100644 +index e09780f6e50e53b488e58aa6907935b3202c91ee..3aa05aae98d8d732529ecced81a972e2e9f69647 100644 --- a/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java +++ b/src/main/java/net/minecraft/world/level/block/piston/MovingPistonBlock.java -@@ -111,6 +111,17 @@ public class MovingPistonBlock extends BaseEntityBlock { +@@ -103,6 +103,17 @@ public class MovingPistonBlock extends BaseEntityBlock { @Override public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext context) { PistonMovingBlockEntity pistonMovingBlockEntity = this.getBlockEntity(world, pos); @@ -976,10 +897,10 @@ index 54abde54b2341d85c6f02a0a28f02a0e229de42b..4bd60b3f16809bb89212ada6dfc374f0 } diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java -index be74adc86f0ca467f3b59e7b57fd47a8f381d86e..cd66c83a91ea9ee9f3f48af40889e2d58e0355f5 100644 +index f456ad8a74464414f69b616a48ee9a2c1cee4d90..bd1ebeccb75408b59cdf8ebe600da1a06f042131 100644 --- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java -@@ -170,6 +170,11 @@ public class PistonBaseBlock extends DirectionalBlock { +@@ -157,6 +157,11 @@ public class PistonBaseBlock extends DirectionalBlock { // } // PAIL: checkME - what happened to setTypeAndData? // CraftBukkit end @@ -992,10 +913,10 @@ index be74adc86f0ca467f3b59e7b57fd47a8f381d86e..cd66c83a91ea9ee9f3f48af40889e2d5 } diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java -index d62cc6e8075b6c1564df29c1b15e8c0246ae786c..b8c33de8aff6c7df5e4e6b628a06d59e8fec4199 100644 +index 6091e3c3adbcc92c9ca438c301a99f646e3cb549..df6e859688c5b45a541b11f2046395474c083c1b 100644 --- a/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonHeadBlock.java -@@ -138,6 +138,11 @@ public class PistonHeadBlock extends DirectionalBlock { +@@ -132,6 +132,11 @@ public class PistonHeadBlock extends DirectionalBlock { @Override public boolean canSurvive(BlockState state, LevelReader world, BlockPos pos) { BlockState blockState = world.getBlockState(pos.relative(state.getValue(FACING).getOpposite())); @@ -1007,7 +928,7 @@ index d62cc6e8075b6c1564df29c1b15e8c0246ae786c..b8c33de8aff6c7df5e4e6b628a06d59e return this.isFittingBase(state, blockState) || blockState.is(Blocks.MOVING_PISTON) && blockState.getValue(FACING) == state.getValue(FACING); } -@@ -145,6 +150,10 @@ public class PistonHeadBlock extends DirectionalBlock { +@@ -139,6 +144,10 @@ public class PistonHeadBlock extends DirectionalBlock { public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { if (state.canSurvive(world, pos)) { world.neighborChanged(pos.relative(state.getValue(FACING).getOpposite()), sourceBlock, sourcePos); @@ -1016,15 +937,15 @@ index d62cc6e8075b6c1564df29c1b15e8c0246ae786c..b8c33de8aff6c7df5e4e6b628a06d59e + world.setBlock(pos, Blocks.AIR.defaultBlockState(), 19); + // Sakura end } - } + } diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -index c89e1fe5fafac46d82b2b20d27586c6997ce8906..3ae9eea57de59c2d78a719412cdc6559d657ebb7 100644 +index 26e11fbe0ddeed23d286e83adfa7d2a5e9cf88c8..044f6daf4a7d30b6d42a21a12fa409f05121ac91 100644 --- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -@@ -163,6 +163,12 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -159,6 +159,12 @@ public class PistonMovingBlockEntity extends BlockEntity { - double i = 0.0; + double i = 0.0D; + // Sakura start - physics version api + if (entity.physics().before(1_11_0)) { @@ -1032,12 +953,12 @@ index c89e1fe5fafac46d82b2b20d27586c6997ce8906..3ae9eea57de59c2d78a719412cdc6559 + return; + } + // Sakura end - physics version api - for (AABB aABB2 : list2) { + for(AABB aABB2 : list2) { AABB aABB3 = PistonMath.getMovementArea(moveByPositionAndProgress(pos, aABB2, blockEntity), direction, d); AABB aABB4 = entity.getBoundingBox(); -@@ -292,14 +298,167 @@ public class PistonMovingBlockEntity extends BlockEntity { - } +@@ -280,14 +286,167 @@ public class PistonMovingBlockEntity extends BlockEntity { } + } + + // Sakura start - physics version api @@ -1190,7 +1111,7 @@ index c89e1fe5fafac46d82b2b20d27586c6997ce8906..3ae9eea57de59c2d78a719412cdc6559 blockEntity.progressO = blockEntity.progress; if (blockEntity.progressO >= 1.0F) { if (world.isClientSide && blockEntity.deathTicks < 5) { - blockEntity.deathTicks++; + ++blockEntity.deathTicks; } else { + // Sakura start - physics version api + if (physicsVersion.isWithin(1_9_0, 1_10_0)) { @@ -1203,7 +1124,7 @@ index c89e1fe5fafac46d82b2b20d27586c6997ce8906..3ae9eea57de59c2d78a719412cdc6559 world.removeBlockEntity(pos); blockEntity.setRemoved(); if (world.getBlockState(pos).is(Blocks.MOVING_PISTON)) { -@@ -319,12 +478,23 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -308,13 +467,23 @@ public class PistonMovingBlockEntity extends BlockEntity { } } else { float f = blockEntity.progress + 0.5F; @@ -1217,6 +1138,7 @@ index c89e1fe5fafac46d82b2b20d27586c6997ce8906..3ae9eea57de59c2d78a719412cdc6559 if (blockEntity.progress >= 1.0F) { blockEntity.progress = 1.0F; } +- + if (physicsVersion.isWithin(1_9_0, 1_10_0)) { + moveCollidedEntities(world, pos, f, blockEntity); + moveStuckEntities(world, pos, f, blockEntity); @@ -1228,10 +1150,10 @@ index c89e1fe5fafac46d82b2b20d27586c6997ce8906..3ae9eea57de59c2d78a719412cdc6559 } 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 67db57686dd29713128d5b233454b6147b8e460b..e53327f05cb6843c6ef78102042369f762e3677f 100644 +index 6a01bfd7aeded9d25eb2a96f2723a2a352f74147..90b4373dd4c0b4c05c69714b10639d20c69f60f9 100644 --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java +++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -@@ -527,7 +527,7 @@ public abstract class FlowingFluid extends Fluid { +@@ -517,7 +517,7 @@ public abstract class FlowingFluid extends Fluid { this.spread(world, pos, state); } @@ -1241,7 +1163,7 @@ index 67db57686dd29713128d5b233454b6147b8e460b..e53327f05cb6843c6ef78102042369f7 } diff --git a/src/main/java/net/minecraft/world/level/material/LavaFluid.java b/src/main/java/net/minecraft/world/level/material/LavaFluid.java -index 3bb4a9a1a6249e8ba2de237f801210e7f4fd5825..8dfa05a586bd21ef8aeab713cad4628166982bfa 100644 +index 783e315d92227cbcb5cd207b0a06a12e0778d14b..ad001d4ae5ef5d0efc2c4fd04b1d8331cd40590a 100644 --- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java +++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java @@ -175,7 +175,10 @@ public abstract class LavaFluid extends FlowingFluid { @@ -1257,10 +1179,10 @@ index 3bb4a9a1a6249e8ba2de237f801210e7f4fd5825..8dfa05a586bd21ef8aeab713cad46281 @Override diff --git a/src/main/java/net/minecraft/world/level/material/WaterFluid.java b/src/main/java/net/minecraft/world/level/material/WaterFluid.java -index 109f71401c65f476ccf6813137386fc9fef10254..786aba3810b71a543469dab6b2b2c1ff4ca2edd5 100644 +index 82e85fbbd45244d02df90fa00c9046e7f51275a2..43df400227429a8a1a18d5ad6fce8a57b198e766 100644 --- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java +++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java -@@ -120,7 +120,10 @@ public abstract class WaterFluid extends FlowingFluid { +@@ -104,7 +104,10 @@ public abstract class WaterFluid extends FlowingFluid { @Override public boolean canBeReplacedWith(FluidState state, BlockGetter world, BlockPos pos, Fluid fluid, Direction direction) { diff --git a/patches/server/0042-Allow-water-in-the-nether.patch b/patches/server/0040-Allow-water-in-the-nether.patch similarity index 79% rename from patches/server/0042-Allow-water-in-the-nether.patch rename to patches/server/0040-Allow-water-in-the-nether.patch index 4acd5c0..c5d892e 100644 --- a/patches/server/0042-Allow-water-in-the-nether.patch +++ b/patches/server/0040-Allow-water-in-the-nether.patch @@ -5,12 +5,12 @@ Subject: [PATCH] Allow water in the nether diff --git a/src/main/java/net/minecraft/world/item/BucketItem.java b/src/main/java/net/minecraft/world/item/BucketItem.java -index 6371f326fc86cfc53e39bf8ed13b646f7705fbbc..6c2eca802cf04a189e36cd6b37d503cf32ec0aa1 100644 +index 5c6aa9c464784ad5ee366412d080c72d3d22a76f..4f21231d6ede7bf1b82185f115b2c48b87732c14 100644 --- a/src/main/java/net/minecraft/world/item/BucketItem.java +++ b/src/main/java/net/minecraft/world/item/BucketItem.java -@@ -195,7 +195,7 @@ public class BucketItem extends Item implements DispensibleContainerItem { +@@ -166,7 +166,7 @@ public class BucketItem extends Item implements DispensibleContainerItem { // CraftBukkit end - if (!flag2) { + if (!flag1) { return movingobjectpositionblock != null && this.emptyContents(entityhuman, world, movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection()), (BlockHitResult) null, enumdirection, clicked, itemstack, enumhand); // CraftBukkit - } else if (world.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { + } else if (!world.sakuraConfig().environment.allowWaterInTheNether && world.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { // Sakura @@ -18,19 +18,19 @@ index 6371f326fc86cfc53e39bf8ed13b646f7705fbbc..6c2eca802cf04a189e36cd6b37d503cf int j = blockposition.getY(); int k = blockposition.getZ(); diff --git a/src/main/java/net/minecraft/world/level/block/IceBlock.java b/src/main/java/net/minecraft/world/level/block/IceBlock.java -index 9c8c1df5187daefb1c8098b4d4a0976c71a7bbfd..f5b4733d182f0831ae07a9ff71f2c2e8dd496aaf 100644 +index 64206d94a5bf210116d208f9678618b905a61428..ea336c764fa5f0ab9583eff2018c9594bf41b5d1 100644 --- a/src/main/java/net/minecraft/world/level/block/IceBlock.java +++ b/src/main/java/net/minecraft/world/level/block/IceBlock.java -@@ -41,7 +41,7 @@ public class IceBlock extends HalfTransparentBlock { - public void afterDestroy(Level world, BlockPos pos, ItemStack tool) { - // Paper end - Improve Block#breakNaturally API - if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, tool) == 0) { +@@ -31,7 +31,7 @@ public class IceBlock extends HalfTransparentBlock { + public void afterDestroy(Level world, BlockPos pos, ItemStack stack) { + // Paper end + if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) == 0) { - if (world.dimensionType().ultraWarm()) { + if (!world.sakuraConfig().environment.allowWaterInTheNether && world.dimensionType().ultraWarm()) { // Sakura world.removeBlock(pos, false); return; } -@@ -69,7 +69,7 @@ public class IceBlock extends HalfTransparentBlock { +@@ -59,7 +59,7 @@ public class IceBlock extends HalfTransparentBlock { return; } // CraftBukkit end @@ -38,4 +38,4 @@ index 9c8c1df5187daefb1c8098b4d4a0976c71a7bbfd..f5b4733d182f0831ae07a9ff71f2c2e8 + if (!world.sakuraConfig().environment.allowWaterInTheNether && world.dimensionType().ultraWarm()) { // Sakura world.removeBlock(pos, false); } else { - world.setBlockAndUpdate(pos, IceBlock.meltsInto()); + world.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState()); diff --git a/patches/server/0040-Option-to-configure-entity-water-sensitivity.patch b/patches/server/0040-Option-to-configure-entity-water-sensitivity.patch deleted file mode 100644 index 81a1fb9..0000000 --- a/patches/server/0040-Option-to-configure-entity-water-sensitivity.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Samsuik <40902469+Samsuik@users.noreply.github.com> -Date: Tue, 21 Nov 2023 11:21:37 +0000 -Subject: [PATCH] Option to configure entity water sensitivity - - -diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index e75322367764805443f9a9f5639d804b87a0ab5e..faa95807bb2afbeb90b31f8bee0d30b590a10075 100644 ---- a/src/main/java/net/minecraft/world/entity/LivingEntity.java -+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -3528,7 +3528,7 @@ public abstract class LivingEntity extends Entity implements Attackable { - } - } - // Paper end - Add EntityMoveEvent -- if (!this.level().isClientSide && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) { -+ if (!this.level().isClientSide && this.level().sakuraConfig().entity.waterSensitivity && this.isSensitiveToWater() && this.isInWaterRainOrBubble()) { // Sakura - configure entity water sensitivity - this.hurt(this.damageSources().drown(), 1.0F); - } - diff --git a/patches/server/0043-Configure-concrete-solidifying-in-water.patch b/patches/server/0041-Configure-concrete-solidifying-in-water.patch similarity index 62% rename from patches/server/0043-Configure-concrete-solidifying-in-water.patch rename to patches/server/0041-Configure-concrete-solidifying-in-water.patch index f62ce1e..5121b3d 100644 --- a/patches/server/0043-Configure-concrete-solidifying-in-water.patch +++ b/patches/server/0041-Configure-concrete-solidifying-in-water.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Configure concrete solidifying in water 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 e7aa5b0f976c8bf236240c4c9708ea1751a03629..46cc4243bbe4700e4543a531ee40bc504d7c6956 100644 +index 05457d0a8fedeb66340486f8c82b2a694fe09378..358a2a5de2c39bb1b3829af29a4a70f2b720dc24 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -278,7 +278,7 @@ public class FallingBlockEntity extends Entity { +@@ -284,7 +284,7 @@ public class FallingBlockEntity extends Entity { + // However, it makes sense for legacy versions pre-1.17 before the world height change. BlockPos blockposition = this.physics.before(1_17_0) ? this.patchedBlockPosition() : this.blockPosition(); // Sakura end - physics version api - - boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock; -+ boolean flag = this.level().sakuraConfig().cannons.sand.concreteSolidifyInWater && this.blockState.getBlock() instanceof ConcretePowderBlock; // Sakura - boolean flag1 = flag && this.level().getFluidState(blockposition).is(FluidTags.WATER); ++ boolean flag = this.level.sakuraConfig().cannons.sand.concreteSolidifyInWater && this.blockState.getBlock() instanceof ConcretePowderBlock; // Sakura + boolean flag1 = flag && this.level.getFluidState(blockposition).is(FluidTags.WATER); double d0 = this.getDeltaMovement().lengthSqr(); diff --git a/patches/server/0044-Option-for-fast-nether-dimension-lava.patch b/patches/server/0042-Option-for-fast-nether-dimension-lava.patch similarity index 90% rename from patches/server/0044-Option-for-fast-nether-dimension-lava.patch rename to patches/server/0042-Option-for-fast-nether-dimension-lava.patch index eaffbe6..95475ad 100644 --- a/patches/server/0044-Option-for-fast-nether-dimension-lava.patch +++ b/patches/server/0042-Option-for-fast-nether-dimension-lava.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Option for fast nether dimension lava diff --git a/src/main/java/net/minecraft/world/level/material/LavaFluid.java b/src/main/java/net/minecraft/world/level/material/LavaFluid.java -index 8dfa05a586bd21ef8aeab713cad4628166982bfa..f8fdb09b7b3f696cd6c7309a90c7fd2138c845ba 100644 +index ad001d4ae5ef5d0efc2c4fd04b1d8331cd40590a..2d3d991c826286083377b5e92bf6d807c1836253 100644 --- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java +++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java @@ -183,7 +183,7 @@ public abstract class LavaFluid extends FlowingFluid { diff --git a/patches/server/0043-Allow-explosions-to-destroy-lava.patch b/patches/server/0043-Allow-explosions-to-destroy-lava.patch new file mode 100644 index 0000000..b910e46 --- /dev/null +++ b/patches/server/0043-Allow-explosions-to-destroy-lava.patch @@ -0,0 +1,31 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik <40902469+Samsuik@users.noreply.github.com> +Date: Sat, 25 Nov 2023 21:14:45 +0000 +Subject: [PATCH] Allow explosions to destroy lava + + +diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java +index cd8f19b6644fa43460f97525cf47526fd5db40b3..6f610de34ac165d2e9a2d353eee46f26da2c22c1 100644 +--- a/src/main/java/net/minecraft/world/level/Explosion.java ++++ b/src/main/java/net/minecraft/world/level/Explosion.java +@@ -321,6 +321,11 @@ public class Explosion { + return Optional.of(-0.3f); + } + // Sakura end - destroy water logged blocks ++ // Sakura start - allow explosions to destroy lava ++ if (blockState.is(Blocks.LAVA) && this.level.sakuraConfig().cannons.explosion.explodeLava) { ++ return Optional.of(-0.3f); ++ } ++ // Sakura end - allow explosions to destroy lava + } + + return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState); +@@ -615,7 +620,7 @@ public class Explosion { + } + } + +- this.level.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 3); ++ this.level.setBlock(blockposition, Blocks.AIR.defaultBlockState(), this.level.sakuraConfig().cannons.explosion.explodeLava && iblockdata.is(Blocks.LAVA) ? 2 : 3); // Sakura - allow explosions to destroy lava + block.wasExploded(this.level, blockposition, this); + this.level.getProfiler().pop(); + } diff --git a/patches/server/0046-Disable-bubble-columns-affecting-cannon-entities.patch b/patches/server/0044-Disable-bubble-columns-affecting-cannon-entities.patch similarity index 82% rename from patches/server/0046-Disable-bubble-columns-affecting-cannon-entities.patch rename to patches/server/0044-Disable-bubble-columns-affecting-cannon-entities.patch index b0ee35a..f929afa 100644 --- a/patches/server/0046-Disable-bubble-columns-affecting-cannon-entities.patch +++ b/patches/server/0044-Disable-bubble-columns-affecting-cannon-entities.patch @@ -5,13 +5,13 @@ Subject: [PATCH] Disable bubble columns affecting cannon entities diff --git a/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java b/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java -index addd8b3758254e4f4cd4e951cd065f83ad5dcdf8..2c666b53360b438546f5ffce468a77eed829b039 100644 +index 461288cb56793f11e8dac80720b36cb9b42da518..63ec5bbb3fee17a5a08ec852de60426d0f26d520 100644 --- a/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java -@@ -48,6 +48,7 @@ public class BubbleColumnBlock extends Block implements BucketPickup { +@@ -39,6 +39,7 @@ public class BubbleColumnBlock extends Block implements BucketPickup { @Override public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) { - if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent + if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, pos)).callEvent()) { return; } // Paper + if (!world.sakuraConfig().cannons.tntAndSandAffectedByBubbleColumns && (entity.isPrimedTNT || entity.isFallingBlock)) return; // Sakura - configure bubble columns affecting cannon entities BlockState blockState = world.getBlockState(pos.above()); if (blockState.isAir()) { diff --git a/patches/server/0045-Allow-explosions-to-destroy-lava.patch b/patches/server/0045-Allow-explosions-to-destroy-lava.patch deleted file mode 100644 index 501094a..0000000 --- a/patches/server/0045-Allow-explosions-to-destroy-lava.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Samsuik <40902469+Samsuik@users.noreply.github.com> -Date: Sat, 25 Nov 2023 21:14:45 +0000 -Subject: [PATCH] Allow explosions to destroy lava - - -diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 7b4f924379f529947f3f3a5ecc0ba3d8f0d97ccd..38c5b7030f3691f155a427ce93165759d985ea63 100644 ---- a/src/main/java/net/minecraft/world/level/Explosion.java -+++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -293,6 +293,11 @@ public class Explosion { - return Optional.of(ZERO_RESISTANCE); - } - // Sakura end - destroy water logged blocks -+ // Sakura start - allow explosions to destroy lava -+ if (blockState.is(Blocks.LAVA) && this.level.sakuraConfig().cannons.explosion.explodeLava) { -+ return Optional.of(ZERO_RESISTANCE); -+ } -+ // Sakura end - allow explosions to destroy lava - } - - return this.damageCalculator.getBlockExplosionResistance((Explosion)(Object)this, this.level, pos, blockState, fluidState); -diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -index 2892e586146cbc560f0bcf4b9af6d0575cb0a82e..355a6fa3791f46049423af75a6ab36eac9774437 100644 ---- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -210,7 +210,7 @@ public abstract class BlockBehaviour implements FeatureElement { - }); - } - -- world.setBlock(pos, Blocks.AIR.defaultBlockState(), 3); -+ world.setBlock(pos, Blocks.AIR.defaultBlockState(), world.sakuraConfig().cannons.explosion.explodeLava && state.is(Blocks.LAVA) ? 2 : 3); // Sakura - allow explosions to destroy lava - block.wasExploded(world, pos, explosion); - } - } diff --git a/patches/server/0045-Treat-all-collidable-blocks-as-full-while-moving-fas.patch b/patches/server/0045-Treat-all-collidable-blocks-as-full-while-moving-fas.patch new file mode 100644 index 0000000..dc8b3ff --- /dev/null +++ b/patches/server/0045-Treat-all-collidable-blocks-as-full-while-moving-fas.patch @@ -0,0 +1,62 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik <40902469+Samsuik@users.noreply.github.com> +Date: Sun, 26 Nov 2023 17:57:50 +0000 +Subject: [PATCH] Treat all collidable blocks as full while moving fast + + +diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java +index 93977027caa8c398ca6f0d2bb0890231adf8bf49..07d3aac679ed4a3d85573706bd664e4d6f6af0ab 100644 +--- a/src/main/java/io/papermc/paper/util/CollisionUtil.java ++++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java +@@ -485,6 +485,7 @@ public final class CollisionUtil { + chunkProvider = null; + } + ++ final boolean fullBlocks = entity != null && entity.treatAllBlocksAsFullWhenMoving(); // Sakura + for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) { + final int minZ = currChunkZ == minChunkZ ? minBlockZ & 15 : 0; // coordinate in chunk + final int maxZ = currChunkZ == maxChunkZ ? maxBlockZ & 15 : 15; // coordinate in chunk +@@ -539,7 +540,7 @@ public final class CollisionUtil { + final int maxY = currChunkY == maxChunkYIterate ? maxYIterate & 15 : 15; // coordinate in chunk + final int chunkYGlobalPos = currChunkY << 4; + +- final boolean sectionHasSpecial = section.hasSpecialCollidingBlocks(); ++ final boolean sectionHasSpecial = !fullBlocks && section.hasSpecialCollidingBlocks(); // Sakura + + final int minXIterate; + final int maxXIterate; +@@ -651,6 +652,11 @@ public final class CollisionUtil { + } + VoxelShape voxelshape2 = blockData.getCollisionShape(getter, mutablePos, collisionShape); + if (voxelshape2 != Shapes.empty()) { ++ // Sakura start - Treat all collidable blocks as full when moving fast ++ if (fullBlocks) { ++ voxelshape2 = Shapes.block(); ++ } ++ // Sakura end - Treat all collidable blocks as full when moving fast + VoxelShape voxelshape3 = voxelshape2.move((double)blockX, (double)blockY, (double)blockZ); + + if (predicate != null && !predicate.test(blockData, mutablePos)) { +diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java +index 626e192d8a7f9c9821e529c2bdd31b2a17c5695d..2c7672b23414df3c8e48785f22fdb0ae9d5a5a60 100644 +--- a/src/main/java/net/minecraft/world/entity/Entity.java ++++ b/src/main/java/net/minecraft/world/entity/Entity.java +@@ -686,6 +686,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + return this.physics; + } + // Sakura end - physics version api ++ // Sakura start - Treat all collidable blocks as full when moving fast ++ public final boolean treatAllBlocksAsFullWhenMoving() { ++ if (this.level.sakuraConfig().cannons.treatAllBlocksAsFullWhenMoving && (this.isPrimedTNT || this.isFallingBlock)) { ++ this.syncDeltaMovement(); ++ double horizontalMovementSqr = this.movementX*this.movementX + this.movementZ*this.movementZ; ++ if (horizontalMovementSqr > Math.pow(this.level.sakuraConfig().cannons.treatAllBlocksAsFullWhenMovingFasterThan, 2.0)) { ++ return true; ++ } ++ } ++ return false; ++ } ++ // Sakura end - Treat all collidable blocks as full when moving fast + + public Entity(EntityType type, Level world) { + this.id = Entity.ENTITY_COUNTER.incrementAndGet(); diff --git a/patches/server/0048-Add-redstone-implementation-API.patch b/patches/server/0046-Add-redstone-implementation-API.patch similarity index 89% rename from patches/server/0048-Add-redstone-implementation-API.patch rename to patches/server/0046-Add-redstone-implementation-API.patch index ed710c2..abd3020 100644 --- a/patches/server/0048-Add-redstone-implementation-API.patch +++ b/patches/server/0046-Add-redstone-implementation-API.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add redstone implementation API diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java -index f2c393dc0b0ece39932f202b404f2e385acd68ef..9d8c0d2b5a1d5a23966b49f8fefbb3d379a07364 100644 +index 002f807d19232f14fe8b195e0404a9bf333a9bdf..a9f84d594e2adda096d872d4b7ca59e73305544b 100644 --- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -269,7 +269,7 @@ public class RedStoneWireBlock extends Block { +@@ -262,7 +262,7 @@ public class RedStoneWireBlock extends Block { * Note: Added 'source' argument so as to help determine direction of information flow */ private void updateSurroundingRedstone(Level worldIn, BlockPos pos, BlockState state, BlockPos source) { @@ -17,7 +17,7 @@ index f2c393dc0b0ece39932f202b404f2e385acd68ef..9d8c0d2b5a1d5a23966b49f8fefbb3d3 turbo.updateSurroundingRedstone(worldIn, pos, state, source); return; } -@@ -293,7 +293,7 @@ public class RedStoneWireBlock extends Block { +@@ -286,7 +286,7 @@ public class RedStoneWireBlock extends Block { int k = worldIn.getBestNeighborSignal(pos1); this.shouldSignal = true; @@ -26,7 +26,7 @@ index f2c393dc0b0ece39932f202b404f2e385acd68ef..9d8c0d2b5a1d5a23966b49f8fefbb3d3 // This code is totally redundant to if statements just below the loop. if (k > 0 && k > j - 1) { j = k; -@@ -307,7 +307,7 @@ public class RedStoneWireBlock extends Block { +@@ -300,7 +300,7 @@ public class RedStoneWireBlock extends Block { // redstone wire will be set to 'k'. If 'k' is already 15, then nothing inside the // following loop can affect the power level of the wire. Therefore, the loop is // skipped if k is already 15. @@ -35,7 +35,7 @@ index f2c393dc0b0ece39932f202b404f2e385acd68ef..9d8c0d2b5a1d5a23966b49f8fefbb3d3 for (Direction enumfacing : Direction.Plane.HORIZONTAL) { BlockPos blockpos = pos1.relative(enumfacing); boolean flag = blockpos.getX() != pos2.getX() || blockpos.getZ() != pos2.getZ(); -@@ -326,7 +326,7 @@ public class RedStoneWireBlock extends Block { +@@ -319,7 +319,7 @@ public class RedStoneWireBlock extends Block { } } @@ -44,7 +44,7 @@ index f2c393dc0b0ece39932f202b404f2e385acd68ef..9d8c0d2b5a1d5a23966b49f8fefbb3d3 // The old code would decrement the wire value only by 1 at a time. if (l > j) { j = l - 1; -@@ -479,7 +479,7 @@ public class RedStoneWireBlock extends Block { +@@ -455,7 +455,7 @@ public class RedStoneWireBlock extends Block { public void onPlace(BlockState state, Level world, BlockPos pos, BlockState oldState, boolean notify) { if (!oldState.is(state.getBlock()) && !world.isClientSide) { // Paper start - optimize redstone - replace call to updatePowerStrength @@ -53,7 +53,7 @@ index f2c393dc0b0ece39932f202b404f2e385acd68ef..9d8c0d2b5a1d5a23966b49f8fefbb3d3 world.getWireHandler().onWireAdded(pos); // Alternate Current } else { this.updateSurroundingRedstone(world, pos, state, null); // vanilla/Eigencraft -@@ -512,7 +512,7 @@ public class RedStoneWireBlock extends Block { +@@ -488,7 +488,7 @@ public class RedStoneWireBlock extends Block { } // Paper start - optimize redstone - replace call to updatePowerStrength @@ -62,7 +62,7 @@ index f2c393dc0b0ece39932f202b404f2e385acd68ef..9d8c0d2b5a1d5a23966b49f8fefbb3d3 world.getWireHandler().onWireRemoved(pos, state); // Alternate Current } else { this.updateSurroundingRedstone(world, pos, state, null); // vanilla/Eigencraft -@@ -553,7 +553,7 @@ public class RedStoneWireBlock extends Block { +@@ -529,7 +529,7 @@ public class RedStoneWireBlock extends Block { if (!world.isClientSide) { // Paper start - optimize redstone (Alternate Current) // Alternate Current handles breaking of redstone wires in the WireHandler. @@ -70,4 +70,4 @@ index f2c393dc0b0ece39932f202b404f2e385acd68ef..9d8c0d2b5a1d5a23966b49f8fefbb3d3 + if (world.localConfig().config(pos).redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { // Sakura world.getWireHandler().onWireUpdated(pos); } else - // Paper end - optimize redstone (Alternate Current) + // Paper end diff --git a/patches/server/0049-Reduce-entity-tracker-player-updates.patch b/patches/server/0047-Reduce-entity-tracker-player-updates.patch similarity index 87% rename from patches/server/0049-Reduce-entity-tracker-player-updates.patch rename to patches/server/0047-Reduce-entity-tracker-player-updates.patch index 6225802..043a11f 100644 --- a/patches/server/0049-Reduce-entity-tracker-player-updates.patch +++ b/patches/server/0047-Reduce-entity-tracker-player-updates.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Reduce entity tracker player updates diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index 8a817dda325898b759de63ab6e4300b050286bf7..baec8d775957f3ef3224d743f961f0a23aee92ab 100644 +index c3b3e984f8a19252b6feabb9ba1f7169dcec2fa2..5e326f26b5166b7ce79bad5724ae63392d53fa45 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1145,6 +1145,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1254,6 +1254,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider try { for (TrackedEntity tracker : this.entityMap.values()) { // update tracker entry @@ -16,10 +16,10 @@ index 8a817dda325898b759de63ab6e4300b050286bf7..baec8d775957f3ef3224d743f961f0a2 tracker.updatePlayers(tracker.entity.getPlayersInTrackRange()); } } finally { -@@ -1311,14 +1312,34 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1501,14 +1502,34 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider private final int range; SectionPos lastSectionPos; - public final Set seenBy = new it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet<>(); // Paper - Perf: optimise map impl + public final Set seenBy = new ReferenceOpenHashSet<>(); // Paper - optimise map impl + private final int playerSearchInterval; // Sakura - reduce entity tracker player updates + private Vec3 entityPosition; // Sakura - reduce entity tracker player updates diff --git a/patches/server/0047-Treat-all-collidable-blocks-as-full-while-moving-fas.patch b/patches/server/0047-Treat-all-collidable-blocks-as-full-while-moving-fas.patch deleted file mode 100644 index 293dc45..0000000 --- a/patches/server/0047-Treat-all-collidable-blocks-as-full-while-moving-fas.patch +++ /dev/null @@ -1,72 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Samsuik <40902469+Samsuik@users.noreply.github.com> -Date: Sun, 26 Nov 2023 17:57:50 +0000 -Subject: [PATCH] Treat all collidable blocks as full while moving fast - - -diff --git a/src/main/java/io/papermc/paper/util/CollisionUtil.java b/src/main/java/io/papermc/paper/util/CollisionUtil.java -index 510d722fffd4bdcee2db42aefa662c49563ffa81..1d2a51b13fb92ed35614790190b9b3b95dba3972 100644 ---- a/src/main/java/io/papermc/paper/util/CollisionUtil.java -+++ b/src/main/java/io/papermc/paper/util/CollisionUtil.java -@@ -1592,6 +1592,7 @@ public final class CollisionUtil { - public static final int COLLISION_FLAG_CHECK_BORDER = 1 << 2; - public static final int COLLISION_FLAG_CHECK_ONLY = 1 << 3; - public static final int COLLISION_FLAG_ADD_TICKET = 1 << 4; // Sakura -+ public static final int COLLISION_FLAG_FULL_BLOCKS = 1 << 5; // Sakura - - public static boolean getCollisionsForBlocksOrWorldBorder(final Level world, final Entity entity, final AABB aabb, - final List intoVoxel, final List intoAABB, -@@ -1643,6 +1644,7 @@ public final class CollisionUtil { - - final boolean loadChunks = (collisionFlags & COLLISION_FLAG_LOAD_CHUNKS) != 0; - final boolean addTicket = (collisionFlags & COLLISION_FLAG_ADD_TICKET) != 0; // Sakura -+ final boolean fullBlocks = (collisionFlags & COLLISION_FLAG_FULL_BLOCKS) != 0; // Sakura - final ServerChunkCache chunkSource = (ServerChunkCache)world.getChunkSource(); - - for (int currChunkZ = minChunkZ; currChunkZ <= maxChunkZ; ++currChunkZ) { -@@ -1684,7 +1686,7 @@ public final class CollisionUtil { - continue; - } - -- final boolean hasSpecial = section.getSpecialCollidingBlocks() != 0; -+ final boolean hasSpecial = !fullBlocks && section.getSpecialCollidingBlocks() != 0; // Sakura - final int sectionAdjust = !hasSpecial ? 1 : 0; - - final PalettedContainer blocks = section.states; -@@ -1718,12 +1720,15 @@ public final class CollisionUtil { - } - - if (edgeCount == 0 || ((edgeCount != 1 || blockData.hasLargeCollisionShape()) && (edgeCount != 2 || blockData.getBlock() == Blocks.MOVING_PISTON))) { -+ // Sakura start - if flag is set treat all block as full - VoxelShape blockCollision = blockData.getConstantCollisionShape(); -- -- if (blockCollision == null) { -+ if (fullBlocks && blockCollision != null) { -+ blockCollision = Shapes.block(); -+ } else if (blockCollision == null) { - mutablePos.set(blockX, blockY, blockZ); - blockCollision = blockData.getCollisionShape(world, mutablePos, collisionShape); - } -+ // Sakura end - - AABB singleAABB = blockCollision.getSingleAABBRepresentation(); - if (singleAABB != null) { -diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 413d129f44b48584b6b8dd59fae866838a01dfeb..78fc8b0d534d3682697424f4931836d9a26167ea 100644 ---- a/src/main/java/net/minecraft/world/entity/Entity.java -+++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -581,6 +581,14 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - flags |= io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_LOAD_CHUNKS | io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_ADD_TICKET; - } - -+ if (this.level().sakuraConfig().cannons.treatAllBlocksAsFullWhenMoving && (this.isPrimedTNT || this.isFallingBlock)) { -+ this.syncDeltaMovement(); -+ double horizontalMovementSqr = this.movementX*this.movementX + this.movementZ*this.movementZ; -+ if (horizontalMovementSqr > Math.pow(this.level().sakuraConfig().cannons.treatAllBlocksAsFullWhenMovingFasterThan, 2.0)) { -+ flags |= io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_FULL_BLOCKS; -+ } -+ } -+ - return flags; - } - // Sakura end - load chunks on cannon entity movement diff --git a/patches/server/0050-Add-option-for-legacy-lava-block-formation.patch b/patches/server/0048-Add-option-for-legacy-lava-block-formation.patch similarity index 88% rename from patches/server/0050-Add-option-for-legacy-lava-block-formation.patch rename to patches/server/0048-Add-option-for-legacy-lava-block-formation.patch index 2429dc3..d431e72 100644 --- a/patches/server/0050-Add-option-for-legacy-lava-block-formation.patch +++ b/patches/server/0048-Add-option-for-legacy-lava-block-formation.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add option for legacy lava block formation diff --git a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java -index 1ed3568b363df38b196567d8a93089550913d659..e5d9b9c1c86b0beab3efdd4784582fd9de0bf926 100644 +index 28bdb44599a8862d58cfb2e087119b843f25f311..51dc3b81fcb76b1bc185486db26ca2a36ca36e98 100644 --- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java -@@ -199,7 +199,15 @@ public class LiquidBlock extends Block implements BucketPickup { +@@ -161,7 +161,15 @@ public class LiquidBlock extends Block implements BucketPickup { if (fluidState.isSource()) { block = Blocks.OBSIDIAN; } else { @@ -26,7 +26,7 @@ index 1ed3568b363df38b196567d8a93089550913d659..e5d9b9c1c86b0beab3efdd4784582fd9 // SANITY: In legacy a patch by paper removes the fluid level condition from vanilla. if (physics.afterOrEqual(1_16_0) || physics.isLegacy() diff --git a/src/main/java/net/minecraft/world/level/material/LavaFluid.java b/src/main/java/net/minecraft/world/level/material/LavaFluid.java -index f8fdb09b7b3f696cd6c7309a90c7fd2138c845ba..c3c24f616345e41772062032406c308ca130147d 100644 +index 2d3d991c826286083377b5e92bf6d807c1836253..1fb85a64eca4ef8a778f5b8652f774d1cfb707c4 100644 --- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java +++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java @@ -177,7 +177,7 @@ public abstract class LavaFluid extends FlowingFluid { @@ -39,10 +39,10 @@ index f8fdb09b7b3f696cd6c7309a90c7fd2138c845ba..c3c24f616345e41772062032406c308c } diff --git a/src/main/java/net/minecraft/world/level/material/WaterFluid.java b/src/main/java/net/minecraft/world/level/material/WaterFluid.java -index 786aba3810b71a543469dab6b2b2c1ff4ca2edd5..f883b9b0a336591dcf685cf34ad09eee832992c2 100644 +index 43df400227429a8a1a18d5ad6fce8a57b198e766..3a955377a13b67e955f90614b975f76f3fcfe9b8 100644 --- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java +++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java -@@ -122,7 +122,7 @@ public abstract class WaterFluid extends FlowingFluid { +@@ -106,7 +106,7 @@ public abstract class WaterFluid extends FlowingFluid { public boolean canBeReplacedWith(FluidState state, BlockGetter world, BlockPos pos, Fluid fluid, Direction direction) { // Sakura start return direction == Direction.DOWN && !fluid.is(FluidTags.WATER) diff --git a/patches/server/0051-Configure-mob-spawner-defaults.patch b/patches/server/0049-Configure-mob-spawner-defaults.patch similarity index 88% rename from patches/server/0051-Configure-mob-spawner-defaults.patch rename to patches/server/0049-Configure-mob-spawner-defaults.patch index bd3c942..4d01eab 100644 --- a/patches/server/0051-Configure-mob-spawner-defaults.patch +++ b/patches/server/0049-Configure-mob-spawner-defaults.patch @@ -5,12 +5,12 @@ Subject: [PATCH] Configure mob spawner defaults diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java -index 65c3e91ac4541c0150057dc9f012eb1ee566516e..218e06c3e0dd17f2801a5d3ca12b049ee24275a1 100644 +index af799b61cec48ca290ed66cb47cfc0b244ac41a7..c7c11747879fecd0e01a4c5de1c396957303f3bc 100644 --- a/src/main/java/net/minecraft/world/level/BaseSpawner.java +++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java -@@ -49,7 +49,16 @@ public abstract class BaseSpawner { +@@ -47,7 +47,16 @@ public abstract class BaseSpawner { public int spawnRange = 4; - private int tickDelay = 0; // Paper - Configurable mob spawner tick rate + private int tickDelay = 0; // Paper - public BaseSpawner() {} + // Sakura start - configure spawner defaults diff --git a/patches/server/0052-Allow-disabling-random-dispenser-item-selection.patch b/patches/server/0050-Allow-disabling-random-dispenser-item-selection.patch similarity index 100% rename from patches/server/0052-Allow-disabling-random-dispenser-item-selection.patch rename to patches/server/0050-Allow-disabling-random-dispenser-item-selection.patch diff --git a/patches/server/0053-Add-instant-mob-death-animation.patch b/patches/server/0051-Add-instant-mob-death-animation.patch similarity index 51% rename from patches/server/0053-Add-instant-mob-death-animation.patch rename to patches/server/0051-Add-instant-mob-death-animation.patch index 9364928..bcbba57 100644 --- a/patches/server/0053-Add-instant-mob-death-animation.patch +++ b/patches/server/0051-Add-instant-mob-death-animation.patch @@ -5,19 +5,19 @@ Subject: [PATCH] Add instant mob death animation diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index faa95807bb2afbeb90b31f8bee0d30b590a10075..9fa79ba7f50fa20f3794fd955db1a4cc0fa8ee02 100644 +index 691f2c1d00d3cb17af017c997b11525709d6cd15..f2e0f4eb5f07ef4bd31282f3d12b8d8380ce22a0 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -1776,6 +1776,12 @@ public abstract class LivingEntity extends Entity implements Attackable { - - // Paper start - if (this.dead) { // Paper -+ // Sakura start -+ if (level().sakuraConfig().entity.instantDeathAnimation && !(this instanceof Player)) { -+ this.deathTime = 20; -+ return; -+ } -+ // Sakura end - this.level().broadcastEntityEvent(this, (byte) 3); - this.setPose(Pose.DYING); +@@ -1696,6 +1696,12 @@ public abstract class LivingEntity extends Entity { + this.createWitherRose(entityliving); } + ++ // Sakura start ++ if (this.dead && this.level.sakuraConfig().entity.instantDeathAnimation && !(this instanceof Player)) { ++ this.deathTime = 20; ++ return; ++ } ++ // Sakura end + if (this.dead) { // Paper + this.level.broadcastEntityEvent(this, (byte) 3); + this.setPose(Pose.DYING); diff --git a/patches/server/0054-Configure-fluids-breaking-redstone.patch b/patches/server/0052-Configure-fluids-breaking-redstone.patch similarity index 57% rename from patches/server/0054-Configure-fluids-breaking-redstone.patch rename to patches/server/0052-Configure-fluids-breaking-redstone.patch index a8b97ac..9dd581e 100644 --- a/patches/server/0054-Configure-fluids-breaking-redstone.patch +++ b/patches/server/0052-Configure-fluids-breaking-redstone.patch @@ -5,17 +5,17 @@ Subject: [PATCH] Configure fluids breaking redstone 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 e53327f05cb6843c6ef78102042369f762e3677f..3eba722647c60f7991b7ca9dcc91565a94653860 100644 +index 90b4373dd4c0b4c05c69714b10639d20c69f60f9..5089f51667912627cfeaac79be689aee151110ae 100644 --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java +++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -@@ -479,6 +479,10 @@ public abstract class FlowingFluid extends Fluid { - LiquidBlockContainer ifluidcontainer = (LiquidBlockContainer) block; +@@ -465,6 +465,10 @@ public abstract class FlowingFluid extends Fluid { - return ifluidcontainer.canPlaceLiquid((Player) null, world, pos, state, fluid); + if (block instanceof LiquidBlockContainer) { + return ((LiquidBlockContainer) block).canPlaceLiquid(world, pos, state, fluid); + // Sakura start + } else if (world instanceof Level level && !level.sakuraConfig().technical.redstone.fluidsBreakRedstone && (state.isSignalSource() || state.getBlock() instanceof net.minecraft.world.level.block.CarpetBlock)) { + return false; + // Sakura end - } else { - return !(block instanceof DoorBlock) && !state.is(BlockTags.SIGNS) && !state.is(Blocks.LADDER) && !state.is(Blocks.SUGAR_CANE) && !state.is(Blocks.BUBBLE_COLUMN) ? (!state.is(Blocks.NETHER_PORTAL) && !state.is(Blocks.END_PORTAL) && !state.is(Blocks.END_GATEWAY) && !state.is(Blocks.STRUCTURE_VOID) ? !state.blocksMotion() : false) : false; - } + } else if (!(block instanceof DoorBlock) && !state.is(BlockTags.SIGNS) && !state.is(Blocks.LADDER) && !state.is(Blocks.SUGAR_CANE) && !state.is(Blocks.BUBBLE_COLUMN)) { + Material material = state.getMaterial(); + diff --git a/patches/server/0053-Option-to-disable-explosions-hurting-players.patch b/patches/server/0053-Option-to-disable-explosions-hurting-players.patch new file mode 100644 index 0000000..b6bb20e --- /dev/null +++ b/patches/server/0053-Option-to-disable-explosions-hurting-players.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik <40902469+Samsuik@users.noreply.github.com> +Date: Sat, 9 Dec 2023 00:25:11 +0000 +Subject: [PATCH] Option to disable explosions hurting players + + +diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java +index 0807d9d33131bf36b02f075e2150eaf33774ad27..62b1009b28c28307e2226248181721bf67bfa079 100644 +--- a/src/main/java/net/minecraft/world/entity/player/Player.java ++++ b/src/main/java/net/minecraft/world/entity/player/Player.java +@@ -926,6 +926,11 @@ public abstract class Player extends LivingEntity { + + @Override + public boolean isInvulnerableTo(DamageSource damageSource) { ++ // Sakura start ++ if (!this.level.sakuraConfig().cannons.explosion.explosionsHurtPlayers && damageSource.isExplosion()) { ++ return true; ++ } ++ // Sakura end + return super.isInvulnerableTo(damageSource) ? true : (damageSource == DamageSource.DROWN ? !this.level.getGameRules().getBoolean(GameRules.RULE_DROWNING_DAMAGE) : (damageSource.isFall() ? !this.level.getGameRules().getBoolean(GameRules.RULE_FALL_DAMAGE) : (damageSource.isFire() ? !this.level.getGameRules().getBoolean(GameRules.RULE_FIRE_DAMAGE) : (damageSource == DamageSource.FREEZE ? !this.level.getGameRules().getBoolean(GameRules.RULE_FREEZE_DAMAGE) : false)))); + } + diff --git a/patches/server/0056-Iron-golems-take-fall-damage.patch b/patches/server/0054-Iron-golems-take-fall-damage.patch similarity index 83% rename from patches/server/0056-Iron-golems-take-fall-damage.patch rename to patches/server/0054-Iron-golems-take-fall-damage.patch index 5217d38..1c1e638 100644 --- a/patches/server/0056-Iron-golems-take-fall-damage.patch +++ b/patches/server/0054-Iron-golems-take-fall-damage.patch @@ -5,17 +5,17 @@ Subject: [PATCH] Iron golems take fall damage diff --git a/src/main/java/net/minecraft/world/entity/animal/IronGolem.java b/src/main/java/net/minecraft/world/entity/animal/IronGolem.java -index 6cfe0d6c46caa122db107c607d27a2bdcd82f7a8..fdfb04589869fc06908b61899c225cccb168e117 100644 +index e73acfa2f5a4066fa1beee1758082a2fe97a43b3..3249197545ab5597b677c9e698c0aecaf024aeee 100644 --- a/src/main/java/net/minecraft/world/entity/animal/IronGolem.java +++ b/src/main/java/net/minecraft/world/entity/animal/IronGolem.java -@@ -240,6 +240,20 @@ public class IronGolem extends AbstractGolem implements NeutralMob { +@@ -249,6 +249,20 @@ public class IronGolem extends AbstractGolem implements NeutralMob { } + // Sakura start + @Override + protected int calculateFallDamage(float fallDistance, float damageMultiplier) { -+ if (!this.level().sakuraConfig().entity.ironGolemsTakeFalldamage) { ++ if (!this.level.sakuraConfig().entity.ironGolemsTakeFalldamage) { + return super.calculateFallDamage(fallDistance, damageMultiplier); + } else { + net.minecraft.world.effect.MobEffectInstance mobeffect = this.getEffect(net.minecraft.world.effect.MobEffects.JUMP); diff --git a/patches/server/0057-Add-explosions-dropping-items-config.patch b/patches/server/0055-Add-explosions-dropping-items-config.patch similarity index 57% rename from patches/server/0057-Add-explosions-dropping-items-config.patch rename to patches/server/0055-Add-explosions-dropping-items-config.patch index 82df8f8..1c8d04e 100644 --- a/patches/server/0057-Add-explosions-dropping-items-config.patch +++ b/patches/server/0055-Add-explosions-dropping-items-config.patch @@ -5,18 +5,18 @@ Subject: [PATCH] Add explosions dropping items config diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index b69b7818a5613bd210ccfd259f01ce025e88a675..0152e7ea9b9aad9b443bef784a2bec5e22e66680 100644 +index 6f610de34ac165d2e9a2d353eee46f26da2c22c1..4047610d0a01ce58f023da9a810ea3f5320892e7 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -952,6 +952,11 @@ public class Explosion { - this.level.densityCache.clear(-1); +@@ -626,6 +626,11 @@ public class Explosion { + } } - // Sakura end - explosion density cache + + // Sakura start - config for explosions dropping items -+ if (!level.sakuraConfig().cannons.explosion.explosionsDropItems) { -+ list.clear(); ++ if (!this.level.sakuraConfig().cannons.explosion.explosionsDropItems) { ++ objectarraylist.clear(); + } + // Sakura end - config for explosions dropping items - Iterator iterator = list.iterator(); + objectlistiterator = objectarraylist.iterator(); - while (iterator.hasNext()) { + while (objectlistiterator.hasNext()) { diff --git a/patches/server/0055-Option-to-disable-explosions-hurting-players.patch b/patches/server/0055-Option-to-disable-explosions-hurting-players.patch deleted file mode 100644 index 208d3fd..0000000 --- a/patches/server/0055-Option-to-disable-explosions-hurting-players.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Samsuik <40902469+Samsuik@users.noreply.github.com> -Date: Sat, 9 Dec 2023 00:25:11 +0000 -Subject: [PATCH] Option to disable explosions hurting players - - -diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index 94577ca6de11d23d2a2561b645212a7717088974..127b83d92719fb5149d936125423a509779e577d 100644 ---- a/src/main/java/net/minecraft/world/entity/player/Player.java -+++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -935,7 +935,7 @@ public abstract class Player extends LivingEntity { - - @Override - public boolean isInvulnerableTo(DamageSource damageSource) { -- return super.isInvulnerableTo(damageSource) ? true : (damageSource.is(DamageTypeTags.IS_DROWNING) ? !this.level().getGameRules().getBoolean(GameRules.RULE_DROWNING_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FALL) ? !this.level().getGameRules().getBoolean(GameRules.RULE_FALL_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FIRE) ? !this.level().getGameRules().getBoolean(GameRules.RULE_FIRE_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FREEZING) ? !this.level().getGameRules().getBoolean(GameRules.RULE_FREEZE_DAMAGE) : false)))); -+ return super.isInvulnerableTo(damageSource) ? true : (damageSource.is(DamageTypeTags.IS_DROWNING) ? !this.level().getGameRules().getBoolean(GameRules.RULE_DROWNING_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FALL) ? !this.level().getGameRules().getBoolean(GameRules.RULE_FALL_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FIRE) ? !this.level().getGameRules().getBoolean(GameRules.RULE_FIRE_DAMAGE) : (damageSource.is(DamageTypeTags.IS_FREEZING) ? !this.level().getGameRules().getBoolean(GameRules.RULE_FREEZE_DAMAGE) : (damageSource.is(DamageTypeTags.IS_EXPLOSION) ? !level().sakuraConfig().cannons.explosion.explosionsHurtPlayers : false))))); // Sakura - } - - @Override diff --git a/patches/server/0058-Optimise-check-inside-blocks-and-fluids.patch b/patches/server/0056-Optimise-check-inside-blocks-and-fluids.patch similarity index 65% rename from patches/server/0058-Optimise-check-inside-blocks-and-fluids.patch rename to patches/server/0056-Optimise-check-inside-blocks-and-fluids.patch index cd146c4..33efac1 100644 --- a/patches/server/0058-Optimise-check-inside-blocks-and-fluids.patch +++ b/patches/server/0056-Optimise-check-inside-blocks-and-fluids.patch @@ -5,18 +5,19 @@ Subject: [PATCH] Optimise check inside blocks and fluids diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 78fc8b0d534d3682697424f4931836d9a26167ea..060f3ebc5823d450f6389044721eea89a56ca85c 100644 +index 2c7672b23414df3c8e48785f22fdb0ae9d5a5a60..7145d3ad574e3e5f99d46fc4c18678e80a60087f 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2000,18 +2000,37 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - BlockPos blockposition1 = BlockPos.containing(axisalignedbb.maxX - offset, axisalignedbb.maxY - offset, axisalignedbb.maxZ - offset); +@@ -1862,14 +1862,34 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + BlockPos blockposition1 = new BlockPos(axisalignedbb.maxX - offset, axisalignedbb.maxY - offset, axisalignedbb.maxZ - offset); // Sakura end -- if (this.level().hasChunksAt(blockposition, blockposition1)) { +- if (this.level.hasChunksAt(blockposition, blockposition1)) { + // Sakura start - optimise check inside blocks -+ if (blockposition1.getY() >= level.getMinBuildHeight() || blockposition.getY() < level.getMaxBuildHeight()) { ++ if (blockposition1.getY() >= this.level.getMinBuildHeight() || blockposition.getY() < this.level.getMaxBuildHeight()) { BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); ++ net.minecraft.server.level.ServerChunkCache chunkSource = ((net.minecraft.server.level.ServerLevel) this.level).getChunkSource(); + net.minecraft.world.level.chunk.ChunkAccess chunk = null; + int lastChunkX = Integer.MIN_VALUE; + int lastChunkZ = Integer.MIN_VALUE; @@ -24,12 +25,12 @@ index 78fc8b0d534d3682697424f4931836d9a26167ea..060f3ebc5823d450f6389044721eea89 for (int i = blockposition.getX(); i <= blockposition1.getX(); ++i) { - for (int j = blockposition.getY(); j <= blockposition1.getY(); ++j) { - for (int k = blockposition.getZ(); k <= blockposition1.getZ(); ++k) { -+ final int chunkX = i >> 4; ++ int chunkX = i >> 4; + for (int k = blockposition.getZ(); k <= blockposition1.getZ(); ++k) { -+ final int chunkZ = k >> 4; ++ int chunkZ = k >> 4; + + if (lastChunkX != chunkX || lastChunkZ != chunkZ) { -+ chunk = level.getChunkIfLoadedImmediately(chunkX, chunkZ); ++ chunk = chunkSource.getChunkAtIfLoadedMainThread(chunkX, chunkZ); + lastChunkX = chunkX; + lastChunkZ = chunkZ; + } @@ -39,18 +40,14 @@ index 78fc8b0d534d3682697424f4931836d9a26167ea..060f3ebc5823d450f6389044721eea89 + } + + for (int j = blockposition.getY(); j <= blockposition1.getY(); ++j) { - if (!this.isAlive()) { - return; - } - blockposition_mutableblockposition.set(i, j, k); -- BlockState iblockdata = this.level().getBlockState(blockposition_mutableblockposition); +- BlockState iblockdata = this.level.getBlockState(blockposition_mutableblockposition); + BlockState iblockdata = chunk.getBlockState(blockposition_mutableblockposition); + // Sakura end try { - iblockdata.entityInside(this.level(), blockposition_mutableblockposition, this); -@@ -4799,7 +4818,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S + iblockdata.entityInside(this.level, blockposition_mutableblockposition, this); +@@ -4451,7 +4471,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public boolean updateFluidHeightAndDoFluidPushing(TagKey tag, double speed) { @@ -59,11 +56,12 @@ index 78fc8b0d534d3682697424f4931836d9a26167ea..060f3ebc5823d450f6389044721eea89 return false; } else { AABB axisalignedbb = this.getBoundingBox().deflate(0.001D); -@@ -4816,11 +4835,30 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -4468,11 +4488,31 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { int k1 = 0; BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); + // Sakura start ++ net.minecraft.server.level.ServerChunkCache chunkSource = ((net.minecraft.server.level.ServerLevel) this.level).getChunkSource(); + net.minecraft.world.level.chunk.ChunkAccess chunk = null; + int lastChunkX = Integer.MIN_VALUE; + int lastChunkZ = Integer.MIN_VALUE; @@ -71,12 +69,12 @@ index 78fc8b0d534d3682697424f4931836d9a26167ea..060f3ebc5823d450f6389044721eea89 for (int l1 = i; l1 < j; ++l1) { - for (int i2 = k; i2 < l; ++i2) { - for (int j2 = i1; j2 < j1; ++j2) { -+ final int chunkX = l1 >> 4; ++ int chunkX = l1 >> 4; + for (int j2 = i1; j2 < j1; ++j2) { -+ final int chunkZ = j2 >> 4; ++ int chunkZ = j2 >> 4; + + if (chunkX != lastChunkX || chunkZ != lastChunkZ) { -+ chunk = level.getChunkIfLoadedImmediately(chunkX, chunkZ); ++ chunk = chunkSource.getChunkAtIfLoadedMainThread(chunkX, chunkZ); + lastChunkX = chunkX; + lastChunkZ = chunkZ; + } @@ -87,9 +85,9 @@ index 78fc8b0d534d3682697424f4931836d9a26167ea..060f3ebc5823d450f6389044721eea89 + + for (int i2 = k; i2 < l; ++i2) { blockposition_mutableblockposition.set(l1, i2, j2); -- FluidState fluid = this.level().getFluidState(blockposition_mutableblockposition); +- FluidState fluid = this.level.getFluidState(blockposition_mutableblockposition); + FluidState fluid = chunk.getFluidState(blockposition_mutableblockposition); + // Sakura end if (fluid.is(tag)) { - double d2 = (double) ((float) i2 + fluid.getHeight(this.level(), blockposition_mutableblockposition)); + double d2 = (double) ((float) i2 + fluid.getHeight(this.level, blockposition_mutableblockposition)); diff --git a/patches/server/0057-Avoid-searching-for-lava-if-throttled-water-flow-spe.patch b/patches/server/0057-Avoid-searching-for-lava-if-throttled-water-flow-spe.patch new file mode 100644 index 0000000..2b282d5 --- /dev/null +++ b/patches/server/0057-Avoid-searching-for-lava-if-throttled-water-flow-spe.patch @@ -0,0 +1,20 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik +Date: Mon, 22 Jan 2024 15:24:51 +0000 +Subject: [PATCH] Avoid searching for lava if throttled water flow speed is + default + + +diff --git a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java +index 51dc3b81fcb76b1bc185486db26ca2a36ca36e98..211f4574c3053487ce689efc5cfc0f6d94b629a8 100644 +--- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java +@@ -113,7 +113,7 @@ public class LiquidBlock extends Block implements BucketPickup { + + // Paper start - Get flow speed. Throttle if its water and flowing adjacent to lava + public int getFlowSpeed(Level world, BlockPos blockposition) { +- if (this.material == net.minecraft.world.level.material.Material.WATER) { ++ if (this.material == net.minecraft.world.level.material.Material.WATER && this.fluid.getTickDelay(world) != world.paperConfig().environment.waterOverLavaFlowSpeed) { // Sakura + if ( + world.getMaterialIfLoaded(blockposition.north(1)) == net.minecraft.world.level.material.Material.LAVA || + world.getMaterialIfLoaded(blockposition.south(1)) == net.minecraft.world.level.material.Material.LAVA || diff --git a/patches/server/0061-Calculate-biome-noise-once-per-chunk-section.patch b/patches/server/0058-Calculate-biome-noise-once-per-chunk-section.patch similarity index 58% rename from patches/server/0061-Calculate-biome-noise-once-per-chunk-section.patch rename to patches/server/0058-Calculate-biome-noise-once-per-chunk-section.patch index 9e1c5fb..e1662f3 100644 --- a/patches/server/0061-Calculate-biome-noise-once-per-chunk-section.patch +++ b/patches/server/0058-Calculate-biome-noise-once-per-chunk-section.patch @@ -5,26 +5,25 @@ Subject: [PATCH] Calculate biome noise once per chunk section 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 796bbef3544e06b8e7aac7e8ac5f740a2613f4bd..27ba0a6d3439b9b4dfae3b9c49975879c4295443 100644 +index b0c9fce9d4e06cac139e341d218d0b6aac1f1943..a256712836ae89bea619f534097d6111ba58d390 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java -@@ -227,12 +227,18 @@ public class LevelChunkSection { - - public void fillBiomesFromNoise(BiomeResolver biomeSupplier, Climate.Sampler sampler, int x, int y, int z) { +@@ -315,11 +315,17 @@ public class LevelChunkSection { PalettedContainer> datapaletteblock = this.biomes.recreate(); -+ Holder biome = null; // Sakura + int k = QuartPos.fromBlock(this.bottomBlockY()); boolean flag = true; ++ Holder biomeHolder = null; // Sakura - calculate biome noise once per chunk section for (int l = 0; l < 4; ++l) { for (int i1 = 0; i1 < 4; ++i1) { for (int j1 = 0; j1 < 4; ++j1) { -- datapaletteblock.getAndSetUnchecked(l, i1, j1, biomeSupplier.getNoiseBiome(x + l, y + i1, z + j1, sampler)); +- datapaletteblock.getAndSetUnchecked(l, i1, j1, biomeSupplier.getNoiseBiome(x + l, k + i1, z + j1, sampler)); + // Sakura start - calculate biome noise once per chunk section -+ if (biome == null || !me.samsuik.sakura.configuration.GlobalConfiguration.get().environment.calculateBiomeNoiseOncePerChunkSection) { -+ biome = biomeSupplier.getNoiseBiome(x + l, y + i1, z + j1, sampler); ++ if (biomeHolder == null || !me.samsuik.sakura.configuration.GlobalConfiguration.get().environment.calculateBiomeNoiseOncePerChunkSection) { ++ biomeHolder = biomeSupplier.getNoiseBiome(x + l, k + i1, z + j1, sampler); + } -+ datapaletteblock.getAndSetUnchecked(l, i1, j1, biome); -+ // Sakura end ++ datapaletteblock.getAndSetUnchecked(l, i1, j1, biomeHolder); ++ // Sakura end - calculate biome noise once per chunk section } } } diff --git a/patches/server/0062-Fix-doEntityDrops-gamerule-preventing-falling-blocks.patch b/patches/server/0059-Fix-doEntityDrops-gamerule-preventing-falling-blocks.patch similarity index 70% rename from patches/server/0062-Fix-doEntityDrops-gamerule-preventing-falling-blocks.patch rename to patches/server/0059-Fix-doEntityDrops-gamerule-preventing-falling-blocks.patch index 46430eb..439ed7f 100644 --- a/patches/server/0062-Fix-doEntityDrops-gamerule-preventing-falling-blocks.patch +++ b/patches/server/0059-Fix-doEntityDrops-gamerule-preventing-falling-blocks.patch @@ -6,24 +6,25 @@ Subject: [PATCH] Fix doEntityDrops gamerule preventing falling blocks from 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 46cc4243bbe4700e4543a531ee40bc504d7c6956..ab88fc1db9740ab249b332a6c01a6d6e2a998c1c 100644 +index 358a2a5de2c39bb1b3829af29a4a70f2b720dc24..d4e8bffc31415663fd3628ad33acc2d59e2036ca 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -353,10 +353,14 @@ public class FallingBlockEntity extends Entity { +@@ -359,10 +359,14 @@ public class FallingBlockEntity extends Entity { tileentity.setChanged(); } } -- } else if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { -+ // Sakura start - fix the do entity drops gamerule -+ } else { - this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause +- } else if (this.dropItem && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { +- this.discard(); - this.callOnBrokenAfterFall(block, blockposition); - this.spawnAtLocation((ItemLike) block); -+ if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { ++ // Sakura start - fix the do entity drops gamerule ++ } else { ++ if (this.dropItem && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) { ++ this.discard(); + this.callOnBrokenAfterFall(block, blockposition); + this.spawnAtLocation((ItemLike) block); + } -+ // Sakura end ++ // Sakura end - fix the do entity drops gamerule } } else { - this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause + this.discard(); diff --git a/patches/server/0063-Add-entity-travel-distance-limits.patch b/patches/server/0060-Add-entity-travel-distance-limits.patch similarity index 76% rename from patches/server/0063-Add-entity-travel-distance-limits.patch rename to patches/server/0060-Add-entity-travel-distance-limits.patch index e77d6eb..c1b3faf 100644 --- a/patches/server/0063-Add-entity-travel-distance-limits.patch +++ b/patches/server/0060-Add-entity-travel-distance-limits.patch @@ -5,29 +5,29 @@ Subject: [PATCH] Add entity travel distance limits diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index ec7d7f22b267ae6572e6005f10221755cbb1a480..2a9a6a9f00343f614a0d2430095a17088861eb1f 100644 +index ab5472c27f94e196a2747466f8721173cef937fc..c32140ded7da15123774b2443830528598b982d4 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -1417,6 +1417,11 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1219,6 +1219,11 @@ public class ServerLevel extends Level implements WorldGenLevel { if (isActive) { // Paper - EAR 2 TimingHistory.activatedEntityTicks++; entity.tick(); + // Sakura start - entity travel distance limits + if (entity.isPastTravelDistanceLimit()) { -+ entity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); ++ entity.discard(); + } + // Sakura end - entity travel distance limits entity.postTick(); // CraftBukkit } else { entity.inactiveTick(); } // Paper - EAR 2 this.getProfiler().pop(); diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 060f3ebc5823d450f6389044721eea89a56ca85c..42642b77213567e9bf6acb3728f75e76e3f3447c 100644 +index 7145d3ad574e3e5f99d46fc4c18678e80a60087f..cbe68a30983380068c54eec708ce8ec8c0d3db38 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -733,6 +733,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - return this.physics; +@@ -698,6 +698,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + return false; } - // Sakura end - physics version api + // Sakura end - Treat all collidable blocks as full when moving fast + // Sakura start - entity travel distance limits + private final double travelDistanceLimit; + @@ -38,13 +38,13 @@ index 060f3ebc5823d450f6389044721eea89a56ca85c..42642b77213567e9bf6acb3728f75e76 + + double x = Math.pow(origin.getX() - position.x(), 2); + double z = Math.pow(origin.getZ() - position.z(), 2); -+ return Math.max(x, z) >= travelDistanceLimit; ++ return Math.max(x, z) >= this.travelDistanceLimit; + } + // Sakura end - entity travel distance limits public Entity(EntityType type, Level world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -782,6 +795,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -745,6 +758,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.setPos(0.0D, 0.0D, 0.0D); this.eyeHeight = this.getEyeHeight(net.minecraft.world.entity.Pose.STANDING, this.dimensions); this.mergeLevel = level.sakuraConfig().cannons.mergeLevel; // Sakura diff --git a/patches/server/0060-Avoid-searching-for-lava-if-throttled-water-flow-spe.patch b/patches/server/0060-Avoid-searching-for-lava-if-throttled-water-flow-spe.patch deleted file mode 100644 index b5f31ab..0000000 --- a/patches/server/0060-Avoid-searching-for-lava-if-throttled-water-flow-spe.patch +++ /dev/null @@ -1,20 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Samsuik -Date: Mon, 22 Jan 2024 15:24:51 +0000 -Subject: [PATCH] Avoid searching for lava if throttled water flow speed is - default - - -diff --git a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java -index e5d9b9c1c86b0beab3efdd4784582fd9de0bf926..5ae4f1cb1397509df3d1aae7200facade84afe39 100644 ---- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java -+++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java -@@ -147,7 +147,7 @@ public class LiquidBlock extends Block implements BucketPickup { - - // Paper start - Configurable speed for water flowing over lava - public int getFlowSpeed(Level world, BlockPos blockposition) { -- if (net.minecraft.core.registries.BuiltInRegistries.FLUID.wrapAsHolder(this.fluid).is(FluidTags.WATER)) { -+ if (net.minecraft.core.registries.BuiltInRegistries.FLUID.wrapAsHolder(this.fluid).is(FluidTags.WATER) && this.fluid.getTickDelay(world) != world.paperConfig().environment.waterOverLavaFlowSpeed) { // Sakura - if ( - isLava(world, blockposition.north(1)) || - isLava(world, blockposition.south(1)) || diff --git a/patches/server/0064-Configure-potion-speed-and-breaking-inside-entities.patch b/patches/server/0061-Configure-potion-speed-and-breaking-inside-entities.patch similarity index 60% rename from patches/server/0064-Configure-potion-speed-and-breaking-inside-entities.patch rename to patches/server/0061-Configure-potion-speed-and-breaking-inside-entities.patch index a98b4f8..5c6bc89 100644 --- a/patches/server/0064-Configure-potion-speed-and-breaking-inside-entities.patch +++ b/patches/server/0061-Configure-potion-speed-and-breaking-inside-entities.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Configure potion speed and breaking inside entities 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 156809090f1f83ad68e7e2477a3cfddac5757a8e..f834a3a2634a7b245ea8881b2cc613296f3b94ba 100644 +index 893975e8587b9036f622e2088c302e33004496d2..b0b96d3e254e96ca5b61ce7faea17baa9f85be23 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -151,7 +151,7 @@ public abstract class Projectile extends Entity implements TraceableEntity { +@@ -122,7 +122,7 @@ public abstract class Projectile extends Entity { super.tick(); } @@ -18,30 +18,30 @@ index 156809090f1f83ad68e7e2477a3cfddac5757a8e..f834a3a2634a7b245ea8881b2cc61329 if (entity != null) { diff --git a/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java b/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java -index 8bf45af0b802b90b7e27197ca16e9f2ebe0162e9..3ab65cb7d891ddba011afd795dbf699f37cb8a17 100644 +index 0524161f7cb414d526e6118258bddd989be6cc9a..ce237e75637d15e2eee70447feb97cbcbc6d384c 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java -@@ -51,7 +51,14 @@ public final class ProjectileUtil { - vec3 = hitResult.getLocation(); +@@ -29,7 +29,14 @@ public final class ProjectileUtil { + vec33 = hitResult.getLocation(); } -- HitResult hitResult2 = getEntityHitResult(world, entity, pos, vec3, entity.getBoundingBox().expandTowards(velocity).inflate(1.0), predicate, margin); +- HitResult hitResult2 = getEntityHitResult(level, entity, vec32, vec33, entity.getBoundingBox().expandTowards(entity.getDeltaMovement()).inflate(1.0D), predicate); + // Sakura start - configure potion mechanics + final HitResult hitResult2; -+ if (world.sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && entity instanceof ThrownPotion) { -+ hitResult2 = getEntityHitResult(entity, pos, vec3, entity.getBoundingBox().expandTowards(velocity).inflate(1.0), predicate, margin); ++ if (level.sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && entity instanceof ThrownPotion) { ++ hitResult2 = getEntityHitResult(entity, vec32, vec33, entity.getBoundingBox().expandTowards(vec3).inflate(1.0), predicate, 0.3f); + } else { -+ hitResult2 = getEntityHitResult(world, entity, pos, vec3, entity.getBoundingBox().expandTowards(velocity).inflate(1.0), predicate, margin); ++ hitResult2 = getEntityHitResult(level, entity, vec32, vec33, entity.getBoundingBox().expandTowards(vec3).inflate(1.0), predicate, 0.3f); + } + // Sakura end - configure potion mechanics if (hitResult2 != null) { hitResult = hitResult2; } diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java -index 19af5552e36964996082226b4f77561d7deb99f6..23c19fb83603974d3d70bc983cf7763bf05142bf 100644 +index 1f1519c1b33d16eba59546c86f20a099486441d7..22afbd3054875cd769f42a3fbd89b51a2e1d94af 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java -@@ -61,6 +61,25 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie +@@ -60,6 +60,25 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie super(EntityType.POTION, x, y, z, world); } @@ -51,16 +51,16 @@ index 19af5552e36964996082226b4f77561d7deb99f6..23c19fb83603974d3d70bc983cf7763b + super.shoot(x, y, z, speed, divergence); + + net.minecraft.world.phys.Vec3 movement = getDeltaMovement(); -+ double moveX = movement.x * level().sakuraConfig().entity.thrownPotion.horizontalSpeed; -+ double moveY = movement.y * level().sakuraConfig().entity.thrownPotion.verticalSpeed; -+ double moveZ = movement.z * level().sakuraConfig().entity.thrownPotion.horizontalSpeed; ++ double moveX = movement.x * this.level.sakuraConfig().entity.thrownPotion.horizontalSpeed; ++ double moveY = movement.y * this.level.sakuraConfig().entity.thrownPotion.verticalSpeed; ++ double moveZ = movement.z * this.level.sakuraConfig().entity.thrownPotion.horizontalSpeed; + + setDeltaMovement(moveX, moveY, moveZ); + } + + @Override + protected final boolean checkLeftOwner() { -+ return super.checkLeftOwner() || level().sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && tickCount >= 5; ++ return super.checkLeftOwner() || this.level.sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && this.tickCount >= 5; + } + // Sakura end - configure potion mechanics + diff --git a/patches/server/0062-Add-outline-colliison-to-enderpearls.patch b/patches/server/0062-Add-outline-colliison-to-enderpearls.patch new file mode 100644 index 0000000..a4cecc5 --- /dev/null +++ b/patches/server/0062-Add-outline-colliison-to-enderpearls.patch @@ -0,0 +1,50 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik +Date: Thu, 14 Mar 2024 18:13:24 +0000 +Subject: [PATCH] Add outline colliison to enderpearls + + +diff --git a/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java b/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java +index ce237e75637d15e2eee70447feb97cbcbc6d384c..1736d6c7c5ca0205b7be302a0574a08b4b9ca548 100644 +--- a/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java ++++ b/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java +@@ -19,12 +19,17 @@ import net.minecraft.world.phys.HitResult; + import net.minecraft.world.phys.Vec3; + + public final class ProjectileUtil { ++ // Sakura start - enderpearls use outline for collision + public static HitResult getHitResult(Entity entity, Predicate predicate) { ++ return getHitResult(entity, predicate, ClipContext.Block.COLLIDER); ++ } ++ public static HitResult getHitResult(Entity entity, Predicate predicate, ClipContext.Block type) { ++ // Sakura end - enderpearls use outline for collision + Vec3 vec3 = entity.getDeltaMovement(); + Level level = entity.level; + Vec3 vec32 = entity.position(); + Vec3 vec33 = vec32.add(vec3); +- HitResult hitResult = level.clip(new ClipContext(vec32, vec33, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, entity)); ++ HitResult hitResult = level.clip(new ClipContext(vec32, vec33, type, ClipContext.Fluid.NONE, entity)); // Sakura - enderpearls use outline for collision + if (hitResult.getType() != HitResult.Type.MISS) { + vec33 = hitResult.getLocation(); + } +diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java +index 88181c59e604ba3b132b9e695cef5eaf5b836029..864043a6abb48372231bb847af3f8c76e933194d 100644 +--- a/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java ++++ b/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java +@@ -44,7 +44,15 @@ public abstract class ThrowableProjectile extends Projectile { + @Override + public void tick() { + super.tick(); +- HitResult movingobjectposition = ProjectileUtil.getHitResult(this, this::canHitEntity); ++ // Sakura start - enderpearls use outline for collision ++ final net.minecraft.world.level.ClipContext.Block type; ++ if (this.level.sakuraConfig().entity.enderPearl.useOutlineForCollision && this instanceof ThrownEnderpearl) { ++ type = net.minecraft.world.level.ClipContext.Block.OUTLINE; ++ } else { ++ type = net.minecraft.world.level.ClipContext.Block.COLLIDER; ++ } ++ HitResult movingobjectposition = ProjectileUtil.getHitResult(this, this::canHitEntity, type); ++ // Sakura end - enderpearls use outline for collision + boolean flag = false; + + if (movingobjectposition.getType() == HitResult.Type.BLOCK) { diff --git a/patches/server/0066-Disable-player-poses-shrinking-collision-box.patch b/patches/server/0063-Disable-player-poses-shrinking-collision-box.patch similarity index 79% rename from patches/server/0066-Disable-player-poses-shrinking-collision-box.patch rename to patches/server/0063-Disable-player-poses-shrinking-collision-box.patch index e4d0c7a..7468fc7 100644 --- a/patches/server/0066-Disable-player-poses-shrinking-collision-box.patch +++ b/patches/server/0063-Disable-player-poses-shrinking-collision-box.patch @@ -5,17 +5,17 @@ Subject: [PATCH] Disable player poses shrinking collision box diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index d09dfbccfb504fc5340089048541cc002d46c15f..8493566fec47ecef3fd7423b993d9e6e378df7e5 100644 +index 62b1009b28c28307e2226248181721bf67bfa079..2c36d3c1939ca4185f4143b846c522a0c9f5b460 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -2249,7 +2249,13 @@ public abstract class Player extends LivingEntity { +@@ -2278,7 +2278,13 @@ public abstract class Player extends LivingEntity { @Override public EntityDimensions getDimensions(Pose pose) { - return (EntityDimensions) Player.POSES.getOrDefault(pose, Player.STANDING_DIMENSIONS); + // Sakura start - player poses shrink collision box + EntityDimensions dimensions = (EntityDimensions) Player.POSES.getOrDefault(pose, Player.STANDING_DIMENSIONS); -+ if (!level().sakuraConfig().players.posesShrinkCollisionBox && dimensions.height == 0.6f) { ++ if (!this.level.sakuraConfig().players.posesShrinkCollisionBox && dimensions.height == 0.6f) { + dimensions = Player.STANDING_DIMENSIONS; + } + return dimensions; diff --git a/patches/server/0067-Mob-spawner-behaviour.patch b/patches/server/0064-Mob-spawner-behaviour.patch similarity index 72% rename from patches/server/0067-Mob-spawner-behaviour.patch rename to patches/server/0064-Mob-spawner-behaviour.patch index 5e3c796..6c1ee5b 100644 --- a/patches/server/0067-Mob-spawner-behaviour.patch +++ b/patches/server/0064-Mob-spawner-behaviour.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Mob spawner behaviour diff --git a/src/main/java/net/minecraft/world/level/BaseSpawner.java b/src/main/java/net/minecraft/world/level/BaseSpawner.java -index 218e06c3e0dd17f2801a5d3ca12b049ee24275a1..de0ca67b4bc51bd2001f4b5b9e483ad650318c08 100644 +index c7c11747879fecd0e01a4c5de1c396957303f3bc..d97d1aa47590b7c8250f1221f078641e01e430eb 100644 --- a/src/main/java/net/minecraft/world/level/BaseSpawner.java +++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java -@@ -66,7 +66,7 @@ public abstract class BaseSpawner { +@@ -64,7 +64,7 @@ public abstract class BaseSpawner { } public boolean isNearPlayer(Level world, BlockPos pos) { @@ -17,7 +17,7 @@ index 218e06c3e0dd17f2801a5d3ca12b049ee24275a1..de0ca67b4bc51bd2001f4b5b9e483ad6 } public void clientTick(Level world, BlockPos pos) { -@@ -137,7 +137,7 @@ public abstract class BaseSpawner { +@@ -135,7 +135,7 @@ public abstract class BaseSpawner { if (!mobspawnerdata_a.blockLightLimit().isValueInRange(world.getBrightness(LightLayer.BLOCK, blockposition1)) || !mobspawnerdata_a.skyLightLimit().isValueInRange(world.getBrightness(LightLayer.SKY, blockposition1))) { continue; } @@ -25,17 +25,17 @@ index 218e06c3e0dd17f2801a5d3ca12b049ee24275a1..de0ca67b4bc51bd2001f4b5b9e483ad6 + } else if (world.sakuraConfig().environment.mobSpawner.checkSpawnConditions && !SpawnPlacements.checkSpawnRules((EntityType) optional.get(), world, MobSpawnType.SPAWNER, blockposition1, world.getRandom())) { // Sakura - mob spawner behaviour continue; } - // Paper start - PreCreatureSpawnEvent -@@ -165,7 +165,7 @@ public abstract class BaseSpawner { + // Paper start +@@ -170,7 +170,7 @@ public abstract class BaseSpawner { return; } -- int k = world.getEntities(EntityTypeTest.forExactClass(entity.getClass()), (new AABB((double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), (double) (pos.getX() + 1), (double) (pos.getY() + 1), (double) (pos.getZ() + 1))).inflate((double) this.spawnRange), EntitySelector.NO_SPECTATORS).size(); -+ int k = world.sakuraConfig().environment.mobSpawner.ignoreEntityLimit ? 0 : world.getEntities(EntityTypeTest.forExactClass(entity.getClass()), (new AABB((double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), (double) (pos.getX() + 1), (double) (pos.getY() + 1), (double) (pos.getZ() + 1))).inflate((double) this.spawnRange), EntitySelector.NO_SPECTATORS).size(); // Sakura - mob spawner behaviour +- int k = world.getEntitiesOfClass(entity.getClass(), (new AABB((double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), (double) (pos.getX() + 1), (double) (pos.getY() + 1), (double) (pos.getZ() + 1))).inflate((double) this.spawnRange)).size(); ++ int k = world.sakuraConfig().environment.mobSpawner.ignoreEntityLimit ? 0 : world.getEntitiesOfClass(entity.getClass(), (new AABB((double) pos.getX(), (double) pos.getY(), (double) pos.getZ(), (double) (pos.getX() + 1), (double) (pos.getY() + 1), (double) (pos.getZ() + 1))).inflate((double) this.spawnRange)).size(); // Sakura - mob spawner behaviour if (k >= this.maxNearbyEntities) { this.delay(world, pos); -@@ -177,7 +177,7 @@ public abstract class BaseSpawner { +@@ -182,7 +182,7 @@ public abstract class BaseSpawner { if (entity instanceof Mob) { Mob entityinsentient = (Mob) entity; diff --git a/patches/server/0065-Add-outline-colliison-to-enderpearls.patch b/patches/server/0065-Add-outline-colliison-to-enderpearls.patch deleted file mode 100644 index 30a36b9..0000000 --- a/patches/server/0065-Add-outline-colliison-to-enderpearls.patch +++ /dev/null @@ -1,27 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Samsuik -Date: Thu, 14 Mar 2024 18:13:24 +0000 -Subject: [PATCH] Add outline colliison to enderpearls - - -diff --git a/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java -index ab777952bda1651796ed41e8a7fc6621f27db9aa..72676ea1458e91e46a62bb6fd88d7a425664d56a 100644 ---- a/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java -+++ b/src/main/java/net/minecraft/world/entity/projectile/ThrowableProjectile.java -@@ -44,7 +44,15 @@ public abstract class ThrowableProjectile extends Projectile { - @Override - public void tick() { - super.tick(); -- HitResult movingobjectposition = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity); -+ // Sakura start - enderpearls use outline for collision -+ final net.minecraft.world.level.ClipContext.Block type; -+ if (level().sakuraConfig().entity.enderPearl.useOutlineForCollision && this instanceof ThrownEnderpearl) { -+ type = net.minecraft.world.level.ClipContext.Block.OUTLINE; -+ } else { -+ type = net.minecraft.world.level.ClipContext.Block.COLLIDER; -+ } -+ HitResult movingobjectposition = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity, type); -+ // Sakura end - enderpearls use outline for collision - boolean flag = false; - - if (movingobjectposition.getType() == HitResult.Type.BLOCK) { diff --git a/patches/server/0068-Fix-block-placement-causing-physics-when-cancelled.patch b/patches/server/0065-Fix-block-placement-causing-physics-when-cancelled.patch similarity index 86% rename from patches/server/0068-Fix-block-placement-causing-physics-when-cancelled.patch rename to patches/server/0065-Fix-block-placement-causing-physics-when-cancelled.patch index c7e2fff..fda8b55 100644 --- a/patches/server/0068-Fix-block-placement-causing-physics-when-cancelled.patch +++ b/patches/server/0065-Fix-block-placement-causing-physics-when-cancelled.patch @@ -5,11 +5,11 @@ Subject: [PATCH] Fix block placement causing physics when cancelled diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java -index 1ad126d992d95062a3db08374db7a927f23a0cac..bf4a5a35272ad0efc0fb26652ea63561ee0cd64d 100644 +index 31eed67d07097c7eb1b06547a9f556bcc709d96c..8970c0f6cf9a62f859e9a2bfd2f29b43bc0e1ac3 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -452,9 +452,16 @@ public final class ItemStack { - world.capturedTileEntities.clear(); // Paper - Allow chests to be placed with NBT data; clear out block entities as chests and such will pop loot +@@ -411,9 +411,16 @@ public final class ItemStack { + world.capturedTileEntities.clear(); // Paper - clear out tile entities as chests and such will pop loot // revert back all captured blocks world.preventPoiUpdated = true; // CraftBukkit - SPIGOT-5710 + // Sakura start - fix placement causing physics when event is cancelled @@ -26,22 +26,22 @@ index 1ad126d992d95062a3db08374db7a927f23a0cac..bf4a5a35272ad0efc0fb26652ea63561 // Brute force all possible updates diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 0572cf39080e549354b5adf437afc7dc3e8e824c..c2c0d80adb6fa8cb74fa5fe3ce5bc7ac0609abba 100644 +index 3c37eaf12fc256a8edf5a5d060e4ca262ec83108..785f621ab4be55cb6f216bf11731aee2f40198c3 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java @@ -150,6 +150,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - public boolean keepSpawnInMemory = true; public org.bukkit.generator.ChunkGenerator generator; + public static final boolean DEBUG_ENTITIES = Boolean.getBoolean("debug.entities"); // Paper + public boolean preventNeighborUpdates = false; // Sakura - fix placement causing physics when event is cancelled public boolean preventPoiUpdated = false; // CraftBukkit - SPIGOT-5710 public boolean captureBlockStates = false; public boolean captureTreeGeneration = false; diff --git a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java -index 9d8c0d2b5a1d5a23966b49f8fefbb3d379a07364..034f9788550802b4f1e85892a5055ee72a60454e 100644 +index a9f84d594e2adda096d872d4b7ca59e73305544b..42407844fb5af663f03bdcade2fe9c4a9e8058f8 100644 --- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -499,7 +499,7 @@ public class RedStoneWireBlock extends Block { +@@ -475,7 +475,7 @@ public class RedStoneWireBlock extends Block { @Override public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean moved) { diff --git a/patches/server/0069-Use-random-chance-for-crop-growth-instead-of-age.patch b/patches/server/0066-Use-random-chance-for-crop-growth-instead-of-age.patch similarity index 90% rename from patches/server/0069-Use-random-chance-for-crop-growth-instead-of-age.patch rename to patches/server/0066-Use-random-chance-for-crop-growth-instead-of-age.patch index 4cd96aa..2a087e2 100644 --- a/patches/server/0069-Use-random-chance-for-crop-growth-instead-of-age.patch +++ b/patches/server/0066-Use-random-chance-for-crop-growth-instead-of-age.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Use random chance for crop growth instead of age diff --git a/src/main/java/net/minecraft/world/level/block/CactusBlock.java b/src/main/java/net/minecraft/world/level/block/CactusBlock.java -index ba4aaf850af36a84517c70581e141157c4f15b99..1505a828ab9b3f39cab0ce15fb5a682d4d907a01 100644 +index 1ec242205b82a5a1f10deb2312795cc5dc157a76..2756ba14bdcd3b96dc945cd9281d2ec3eb9ffe9b 100644 --- a/src/main/java/net/minecraft/world/level/block/CactusBlock.java +++ b/src/main/java/net/minecraft/world/level/block/CactusBlock.java -@@ -52,6 +52,19 @@ public class CactusBlock extends Block { +@@ -46,6 +46,19 @@ public class CactusBlock extends Block { @Override public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { @@ -28,7 +28,7 @@ index ba4aaf850af36a84517c70581e141157c4f15b99..1505a828ab9b3f39cab0ce15fb5a682d BlockPos blockposition1 = pos.above(); if (world.isEmptyBlock(blockposition1)) { -@@ -68,7 +81,11 @@ public class CactusBlock extends Block { +@@ -62,7 +75,11 @@ public class CactusBlock extends Block { if (j >= 15 || (modifier != 100 && random.nextFloat() < (modifier / (100.0f * 16)))) { // Spigot - SPIGOT-7159: Better modifier resolution CraftEventFactory.handleBlockGrowEvent(world, blockposition1, this.defaultBlockState()); // CraftBukkit BlockState iblockdata1 = (BlockState) state.setValue(CactusBlock.AGE, 0); @@ -42,10 +42,10 @@ index ba4aaf850af36a84517c70581e141157c4f15b99..1505a828ab9b3f39cab0ce15fb5a682d world.neighborChanged(iblockdata1, blockposition1, this, pos, false); } else if (modifier == 100 || random.nextFloat() < (modifier / (100.0f * 16))) { // Spigot - SPIGOT-7159: Better modifier resolution diff --git a/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java b/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java -index 04957d461d0e968d443737068aaeec1d0bce78b2..8c086ee66921d79768daeecd9dec4047fbcba5ef 100644 +index 6b400a4759c8c8612a3b5c96ca0d87ef9dc71435..c94c9eb7abc93f2baf79a3336d4b9b96ef3eea33 100644 --- a/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java -@@ -52,6 +52,19 @@ public class SugarCaneBlock extends Block { +@@ -45,6 +45,19 @@ public class SugarCaneBlock extends Block { @Override public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { @@ -65,7 +65,7 @@ index 04957d461d0e968d443737068aaeec1d0bce78b2..8c086ee66921d79768daeecd9dec4047 if (world.isEmptyBlock(pos.above())) { int i; -@@ -66,6 +79,7 @@ public class SugarCaneBlock extends Block { +@@ -59,6 +72,7 @@ public class SugarCaneBlock extends Block { if (j >= 15 || (modifier != 100 && random.nextFloat() < (modifier / (100.0f * 16)))) { // Spigot - SPIGOT-7159: Better modifier resolution org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(world, pos.above(), this.defaultBlockState()); // CraftBukkit world.setBlock(pos, (BlockState) state.setValue(SugarCaneBlock.AGE, 0), 4); diff --git a/patches/server/0071-Legacy-player-combat-mechanics.patch b/patches/server/0067-Legacy-player-combat-mechanics.patch similarity index 82% rename from patches/server/0071-Legacy-player-combat-mechanics.patch rename to patches/server/0067-Legacy-player-combat-mechanics.patch index 6832d7c..f58419e 100644 --- a/patches/server/0071-Legacy-player-combat-mechanics.patch +++ b/patches/server/0067-Legacy-player-combat-mechanics.patch @@ -48,10 +48,10 @@ index 0000000000000000000000000000000000000000..6cda6ba8e29587fd04b727ef18848476 + } +} diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 9fa79ba7f50fa20f3794fd955db1a4cc0fa8ee02..532fef2f50a0904a7c64bac30aa61dc71fcfc7dd 100644 +index f2e0f4eb5f07ef4bd31282f3d12b8d8380ce22a0..4de9d99999c82854460b08b8b841699132e2f1e9 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -276,6 +276,64 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -279,6 +279,64 @@ public abstract class LivingEntity extends Entity { ++this.noActionTime; // Above all the floats } // Spigot end @@ -64,7 +64,7 @@ index 9fa79ba7f50fa20f3794fd955db1a4cc0fa8ee02..532fef2f50a0904a7c64bac30aa61dc7 + if (attackSpeed != null) { + attackSpeed.removeModifier(LEGACY_ATTACK_SPEED_MODIFIER); + -+ if (this.level().sakuraConfig().players.combat.legacyCombatMechanics) { ++ if (this.level.sakuraConfig().players.combat.legacyCombatMechanics) { + attackSpeed.addTransientModifier(LEGACY_ATTACK_SPEED_MODIFIER); + } + } @@ -74,7 +74,7 @@ index 9fa79ba7f50fa20f3794fd955db1a4cc0fa8ee02..532fef2f50a0904a7c64bac30aa61dc7 + AttributeInstance attackDamage = this.getAttribute(Attributes.ATTACK_DAMAGE); + AttributeModifier legacyModifier = null; + -+ if (this.level().sakuraConfig().players.combat.legacyCombatMechanics) { ++ if (this.level.sakuraConfig().players.combat.legacyCombatMechanics) { + legacyModifier = this.getLegacyAttackModifier(); + } + @@ -116,12 +116,12 @@ index 9fa79ba7f50fa20f3794fd955db1a4cc0fa8ee02..532fef2f50a0904a7c64bac30aa61dc7 protected LivingEntity(EntityType type, Level world) { super(type, world); -@@ -2145,7 +2203,16 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2052,7 +2110,16 @@ public abstract class LivingEntity extends Entity { protected float getDamageAfterArmorAbsorb(DamageSource source, float amount) { - if (!source.is(DamageTypeTags.BYPASSES_ARMOR)) { - // this.hurtArmor(damagesource, f); // CraftBukkit - Moved into actuallyHurt(DamageSource, float) + if (!source.isBypassArmor()) { + // this.damageArmor(damagesource, f); // CraftBukkit - Moved into damageEntity0(DamageSource, float) + // Sakura start - legacy combat mechanics -+ if (!this.level().sakuraConfig().players.combat.legacyCombatMechanics) { ++ if (!this.level.sakuraConfig().players.combat.legacyCombatMechanics) { amount = CombatRules.getDamageAfterAbsorb(amount, (float) this.getArmorValue(), (float) this.getAttributeValue(Attributes.ARMOR_TOUGHNESS)); + } else { + // See: applyArmorModifier(DamageSource, float) @@ -133,7 +133,7 @@ index 9fa79ba7f50fa20f3794fd955db1a4cc0fa8ee02..532fef2f50a0904a7c64bac30aa61dc7 } return amount; -@@ -3201,6 +3268,12 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3142,6 +3209,12 @@ public abstract class LivingEntity extends Entity { if (!itemstack1.isEmpty()) { this.getAttributes().addTransientAttributeModifiers(itemstack1.getAttributeModifiers(enumitemslot)); } @@ -146,7 +146,7 @@ index 9fa79ba7f50fa20f3794fd955db1a4cc0fa8ee02..532fef2f50a0904a7c64bac30aa61dc7 } } -@@ -3354,7 +3427,7 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -3288,7 +3361,7 @@ public abstract class LivingEntity extends Entity { this.lastArmorItemStacks.set(slot.getIndex(), armor); } @@ -156,24 +156,24 @@ index 9fa79ba7f50fa20f3794fd955db1a4cc0fa8ee02..532fef2f50a0904a7c64bac30aa61dc7 } diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index 8493566fec47ecef3fd7423b993d9e6e378df7e5..7f2b778706bdc1d24b97c53ac9278439a4a03d36 100644 +index 2c36d3c1939ca4185f4143b846c522a0c9f5b460..979c2c8ac3ed68dc2c4741cddb0c4415326a9271 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -1255,7 +1255,7 @@ public abstract class Player extends LivingEntity { +@@ -1251,7 +1251,7 @@ public abstract class Player extends LivingEntity { if (playerAttackEntityEvent.callEvent() && willAttack) { // Logic moved to willAttack local variable. { - // Paper end - PlayerAttackEntityEvent + // Paper end - float f = (float) this.getAttributeValue(Attributes.ATTACK_DAMAGE); + float f = this.getAttackDamageFromAttributes(); // Sakura - legacy combat mechanics float f1; if (target instanceof LivingEntity) { -@@ -1266,8 +1266,14 @@ public abstract class Player extends LivingEntity { +@@ -1262,8 +1262,14 @@ public abstract class Player extends LivingEntity { float f2 = this.getAttackStrengthScale(0.5F); + // Sakura start - legacy combat mechanics -+ if (!this.level().sakuraConfig().players.combat.legacyCombatMechanics) { ++ if (!this.level.sakuraConfig().players.combat.legacyCombatMechanics) { f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; + } else if (f1 != 0.0) { @@ -183,16 +183,16 @@ index 8493566fec47ecef3fd7423b993d9e6e378df7e5..7f2b778706bdc1d24b97c53ac9278439 // this.resetAttackCooldown(); // CraftBukkit - Moved to EntityLiving to reset the cooldown after the damage is dealt if (f > 0.0F || f1 > 0.0F) { boolean flag = f2 > 0.9F; -@@ -1284,7 +1290,7 @@ public abstract class Player extends LivingEntity { - boolean flag2 = flag && this.fallDistance > 0.0F && !this.onGround() && !this.onClimbable() && !this.isInWater() && !this.hasEffect(MobEffects.BLINDNESS) && !this.isPassenger() && target instanceof LivingEntity; // Paper - Add critical damage API; diff on change +@@ -1280,7 +1286,7 @@ public abstract class Player extends LivingEntity { + boolean flag2 = flag && this.fallDistance > 0.0F && !this.onGround && !this.onClimbable() && !this.isInWater() && !this.hasEffect(MobEffects.BLINDNESS) && !this.isPassenger() && target instanceof LivingEntity; // Paper - Add critical damage API - conflict on change - flag2 = flag2 && !this.level().paperConfig().entities.behavior.disablePlayerCrits; // Paper - Toggleable player crits + flag2 = flag2 && !level.paperConfig().entities.behavior.disablePlayerCrits; // Paper - flag2 = flag2 && !this.isSprinting(); -+ flag2 = flag2 && (this.level().sakuraConfig().players.combat.legacyCombatMechanics || !this.isSprinting()); // Sakura - legacy combat mechanics ++ flag2 = flag2 && (this.level.sakuraConfig().players.combat.legacyCombatMechanics || !this.isSprinting()); // Sakura - legacy combat mechanics if (flag2) { f *= 1.5F; } -@@ -1476,6 +1482,27 @@ public abstract class Player extends LivingEntity { +@@ -1472,6 +1478,27 @@ public abstract class Player extends LivingEntity { } } diff --git a/patches/server/0072-Allow-disabling-sweep-attacks.patch b/patches/server/0068-Allow-disabling-sweep-attacks.patch similarity index 61% rename from patches/server/0072-Allow-disabling-sweep-attacks.patch rename to patches/server/0068-Allow-disabling-sweep-attacks.patch index dc6359d..2191591 100644 --- a/patches/server/0072-Allow-disabling-sweep-attacks.patch +++ b/patches/server/0068-Allow-disabling-sweep-attacks.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Allow disabling sweep attacks diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index cef878d0876cf5eef8ce4bf220b50d21f64ad597..b613a0843a6a71ad80bdedb407d0402ec788a6f3 100644 +index 979c2c8ac3ed68dc2c4741cddb0c4415326a9271..c990388f5b0146c9b94c8d825edb723f607d11df 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -1361,7 +1361,7 @@ public abstract class Player extends LivingEntity { - // Paper end - Configurable sprint interruption on attack +@@ -1357,7 +1357,7 @@ public abstract class Player extends LivingEntity { + // Paper end } - if (flag3) { -+ if (flag3 && this.level().sakuraConfig().players.combat.allowSweepAttacks) { // Sakura - allow disabling sweep attacks ++ if (flag3 && this.level.sakuraConfig().players.combat.allowSweepAttacks) { // Sakura - allow disabling sweep attacks float f4 = 1.0F + EnchantmentHelper.getSweepingDamageRatio(this) * f; - List list = this.level().getEntitiesOfClass(LivingEntity.class, target.getBoundingBox().inflate(1.0D, 0.25D, 1.0D)); + List list = this.level.getEntitiesOfClass(LivingEntity.class, target.getBoundingBox().inflate(1.0D, 0.25D, 1.0D)); Iterator iterator = list.iterator(); diff --git a/patches/server/0073-Change-shields-to-reduce-damage.patch b/patches/server/0069-Change-shields-to-reduce-damage.patch similarity index 76% rename from patches/server/0073-Change-shields-to-reduce-damage.patch rename to patches/server/0069-Change-shields-to-reduce-damage.patch index 5caa3b0..f80fd21 100644 --- a/patches/server/0073-Change-shields-to-reduce-damage.patch +++ b/patches/server/0069-Change-shields-to-reduce-damage.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Change shields to reduce damage diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 532fef2f50a0904a7c64bac30aa61dc71fcfc7dd..0adf993b1b03b4e68d83e67872c0f592c2d7c91f 100644 +index 4de9d99999c82854460b08b8b841699132e2f1e9..659cf60f5a1da5c13ebdf2dc315f538265ba4a39 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -2279,7 +2279,13 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2186,7 +2186,13 @@ public abstract class LivingEntity extends Entity { Function blocking = new Function() { @Override public Double apply(Double f) { + // Sakura start - shield damage reduction -+ if (!level().sakuraConfig().players.combat.shieldDamageReduction || damagesource.getDirectEntity() instanceof AbstractArrow) { ++ if (!level.sakuraConfig().players.combat.shieldDamageReduction || damagesource.getDirectEntity() instanceof AbstractArrow) { return -((LivingEntity.this.isDamageSourceBlocked(damagesource)) ? f : 0.0); + } else { + return -(LivingEntity.this.isBlocking() ? f * 0.5 : 0.0); diff --git a/patches/server/0074-Old-enchanted-golden-apples.patch b/patches/server/0070-Old-enchanted-golden-apples.patch similarity index 51% rename from patches/server/0074-Old-enchanted-golden-apples.patch rename to patches/server/0070-Old-enchanted-golden-apples.patch index 1e5eeb0..3e4386d 100644 --- a/patches/server/0074-Old-enchanted-golden-apples.patch +++ b/patches/server/0070-Old-enchanted-golden-apples.patch @@ -5,17 +5,17 @@ Subject: [PATCH] Old enchanted golden apples diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 0adf993b1b03b4e68d83e67872c0f592c2d7c91f..99bc5f6665524dfb42d7e7dd3f71fb45147b3b58 100644 +index 659cf60f5a1da5c13ebdf2dc315f538265ba4a39..7cb6e250bd1c14e557c359fe211d8a1f9b4de986 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -4523,7 +4523,13 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -4411,7 +4411,13 @@ public abstract class LivingEntity extends Entity { Item item = stack.getItem(); if (item.isEdible()) { - List> list = item.getFoodProperties().getEffects(); + // Sakura start - old enchanted golden apple + FoodProperties food = item.getFoodProperties(); -+ if (this.level().sakuraConfig().players.combat.oldEnchantedGoldenApple && item.getFoodProperties() == net.minecraft.world.food.Foods.ENCHANTED_GOLDEN_APPLE) { ++ if (this.level.sakuraConfig().players.combat.oldEnchantedGoldenApple && item.getFoodProperties() == net.minecraft.world.food.Foods.ENCHANTED_GOLDEN_APPLE) { + food = net.minecraft.world.food.Foods.LEGACY_ENCHANTED_GOLDEN_APPLE; + } + List> list = food.getEffects(); @@ -24,13 +24,14 @@ index 0adf993b1b03b4e68d83e67872c0f592c2d7c91f..99bc5f6665524dfb42d7e7dd3f71fb45 while (iterator.hasNext()) { diff --git a/src/main/java/net/minecraft/world/food/Foods.java b/src/main/java/net/minecraft/world/food/Foods.java -index 4569cf30b33167a415256a8542820557ad38f89e..2851125fcb2c2ddade0d82b9a3d303c069a1a06f 100644 +index b16d9e2eaa589f19c563ee70b1a56d67dbcdecb0..5c6cec414d8b3f09cfbf9556a0b1c2a5adf5a9b4 100644 --- a/src/main/java/net/minecraft/world/food/Foods.java +++ b/src/main/java/net/minecraft/world/food/Foods.java -@@ -37,6 +37,15 @@ public class Foods { - .effect(new MobEffectInstance(MobEffects.ABSORPTION, 2400, 3), 1.0F) - .alwaysEat() - .build(); +@@ -24,6 +24,17 @@ public class Foods { + public static final FoodProperties COOKIE = (new FoodProperties.Builder()).nutrition(2).saturationMod(0.1F).build(); + public static final FoodProperties DRIED_KELP = (new FoodProperties.Builder()).nutrition(1).saturationMod(0.3F).fast().build(); + public static final FoodProperties ENCHANTED_GOLDEN_APPLE = (new FoodProperties.Builder()).nutrition(4).saturationMod(1.2F).effect(new MobEffectInstance(MobEffects.REGENERATION, 400, 1), 1.0F).effect(new MobEffectInstance(MobEffects.DAMAGE_RESISTANCE, 6000, 0), 1.0F).effect(new MobEffectInstance(MobEffects.FIRE_RESISTANCE, 6000, 0), 1.0F).effect(new MobEffectInstance(MobEffects.ABSORPTION, 2400, 3), 1.0F).alwaysEat().build(); ++ // Sakura start + public static final FoodProperties LEGACY_ENCHANTED_GOLDEN_APPLE = new FoodProperties.Builder() + .nutrition(4) + .saturationMod(1.2F) @@ -40,6 +41,7 @@ index 4569cf30b33167a415256a8542820557ad38f89e..2851125fcb2c2ddade0d82b9a3d303c0 + .effect(new MobEffectInstance(MobEffects.ABSORPTION, 2400, 0), 1.0F) + .alwaysEat() + .build(); - public static final FoodProperties GOLDEN_APPLE = new FoodProperties.Builder() - .nutrition(4) - .saturationMod(1.2F) ++ // Sakura end + public static final FoodProperties GOLDEN_APPLE = (new FoodProperties.Builder()).nutrition(4).saturationMod(1.2F).effect(new MobEffectInstance(MobEffects.REGENERATION, 100, 1), 1.0F).effect(new MobEffectInstance(MobEffects.ABSORPTION, 2400, 0), 1.0F).alwaysEat().build(); + public static final FoodProperties GOLDEN_CARROT = (new FoodProperties.Builder()).nutrition(6).saturationMod(1.2F).build(); + public static final FoodProperties HONEY_BOTTLE = (new FoodProperties.Builder()).nutrition(6).saturationMod(0.1F).build(); diff --git a/patches/server/0075-Configure-fast-health-regen.patch b/patches/server/0071-Configure-fast-health-regen.patch similarity index 67% rename from patches/server/0075-Configure-fast-health-regen.patch rename to patches/server/0071-Configure-fast-health-regen.patch index fb5bb34..359e2d9 100644 --- a/patches/server/0075-Configure-fast-health-regen.patch +++ b/patches/server/0071-Configure-fast-health-regen.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Configure fast health regen diff --git a/src/main/java/net/minecraft/world/food/FoodData.java b/src/main/java/net/minecraft/world/food/FoodData.java -index c3448707fd8a632b457cc97b35d08a9c6933d5ee..4c7e4c463167ab17ff15236e08b84d7ef317c38d 100644 +index 2934b6de1f1fb914a532ee20184df99d1acd8e65..9b4f0dfb6eea305063e145d45c98f57dd9c136a4 100644 --- a/src/main/java/net/minecraft/world/food/FoodData.java +++ b/src/main/java/net/minecraft/world/food/FoodData.java -@@ -78,7 +78,7 @@ public class FoodData { +@@ -79,7 +79,7 @@ public class FoodData { - boolean flag = player.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION); + boolean flag = player.level.getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION); - if (flag && this.saturationLevel > 0.0F && player.isHurt() && this.foodLevel >= 20) { -+ if (flag && this.saturationLevel > 0.0F && player.isHurt() && this.foodLevel >= 20 && player.level().sakuraConfig().players.combat.fastHealthRegen) { // Sakura - configure fast health regen ++ if (flag && this.saturationLevel > 0.0F && player.isHurt() && this.foodLevel >= 20 && player.level.sakuraConfig().players.combat.fastHealthRegen) { // Sakura - configure fast health regen ++this.tickTimer; if (this.tickTimer >= this.saturatedRegenRate) { // CraftBukkit float f = Math.min(this.saturationLevel, 6.0F); diff --git a/patches/server/0076-Add-option-for-fishing-hooks-pulling-entities.patch b/patches/server/0072-Add-option-for-fishing-hooks-pulling-entities.patch similarity index 71% rename from patches/server/0076-Add-option-for-fishing-hooks-pulling-entities.patch rename to patches/server/0072-Add-option-for-fishing-hooks-pulling-entities.patch index b0f1056..989a133 100644 --- a/patches/server/0076-Add-option-for-fishing-hooks-pulling-entities.patch +++ b/patches/server/0072-Add-option-for-fishing-hooks-pulling-entities.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Add option for fishing hooks pulling entities diff --git a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java -index ba906ceb807b21c01cf4d3c0122f626959f6e775..075a3b7ae760e73ef5674de80b6e37b5158f3e43 100644 +index 70016e105066a16d19ebdf631cc3ef0a03466e3a..35151fa7c8bc8bcafffda6b0292e2c9c50caae43 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java -@@ -598,7 +598,7 @@ public class FishingHook extends Projectile { +@@ -581,7 +581,7 @@ public class FishingHook extends Projectile { public void pullEntity(Entity entity) { Entity entity1 = this.getOwner(); - if (entity1 != null) { -+ if (entity1 != null && (this.level().sakuraConfig().players.fishingHooksPullEntities || entity instanceof ItemEntity)) { // Sakura - Add option for fishing hooks pulling entities ++ if (entity1 != null && (this.level.sakuraConfig().players.fishingHooksPullEntities || entity instanceof ItemEntity)) { // Sakura - Add option for fishing hooks pulling entities Vec3 vec3d = (new Vec3(entity1.getX() - this.getX(), entity1.getY() - this.getY(), entity1.getZ() - this.getZ())).scale(0.1D); entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d)); diff --git a/patches/server/0077-Old-combat-sounds-and-particle-effects.patch b/patches/server/0073-Old-combat-sounds-and-particle-effects.patch similarity index 52% rename from patches/server/0077-Old-combat-sounds-and-particle-effects.patch rename to patches/server/0073-Old-combat-sounds-and-particle-effects.patch index 08472ea..2ae33c7 100644 --- a/patches/server/0077-Old-combat-sounds-and-particle-effects.patch +++ b/patches/server/0073-Old-combat-sounds-and-particle-effects.patch @@ -5,23 +5,23 @@ Subject: [PATCH] Old combat sounds and particle effects diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java -index 7453ba523f1e0fac5192e6afe737f89bf6eab4f0..019f843ce65a115cf5157a5730c133e8908b8dbb 100644 +index c990388f5b0146c9b94c8d825edb723f607d11df..211d1dff3833bbf23a4d76ce70e8cf2ece2d8ec0 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -1457,7 +1457,7 @@ public abstract class Player extends LivingEntity { +@@ -1453,7 +1453,7 @@ public abstract class Player extends LivingEntity { // CraftBukkit end } -- if (this.level() instanceof ServerLevel && f5 > 2.0F) { -+ if (this.level() instanceof ServerLevel && f5 > 2.0F && !this.level().sakuraConfig().players.combat.oldSoundsAndParticleEffects) { // Sakura - old combat sounds and particles +- if (this.level instanceof ServerLevel && f5 > 2.0F) { ++ if (this.level instanceof ServerLevel && f5 > 2.0F && !this.level.sakuraConfig().players.combat.oldSoundsAndParticleEffects) { // Sakura - old combat sounds and particles int k = (int) ((double) f5 * 0.5D); - ((ServerLevel) this.level()).sendParticles(ParticleTypes.DAMAGE_INDICATOR, target.getX(), target.getY(0.5D), target.getZ(), k, 0.1D, 0.0D, 0.1D, 0.2D); -@@ -1906,6 +1906,7 @@ public abstract class Player extends LivingEntity { + ((ServerLevel) this.level).sendParticles(ParticleTypes.DAMAGE_INDICATOR, target.getX(), target.getY(0.5D), target.getZ(), k, 0.1D, 0.0D, 0.1D, 0.2D); +@@ -1937,6 +1937,7 @@ public abstract class Player extends LivingEntity { } - // Paper start - send while respecting visibility + // Paper start - send SoundEffect to everyone who can see fromEntity private static void sendSoundEffect(Player fromEntity, double x, double y, double z, SoundEvent soundEffect, SoundSource soundCategory, float volume, float pitch) { -+ if (fromEntity.level().sakuraConfig().players.combat.oldSoundsAndParticleEffects) return; // Sakura - old combat sounds and particles - fromEntity.level().playSound(fromEntity, x, y, z, soundEffect, soundCategory, volume, pitch); // This will not send the effect to the entity himself ++ if (fromEntity.level.sakuraConfig().players.combat.oldSoundsAndParticleEffects) return; // Sakura - old combat sounds and particles + fromEntity.level.playSound(fromEntity, x, y, z, soundEffect, soundCategory, volume, pitch); // This will not send the effect to the entity himself if (fromEntity instanceof ServerPlayer) { ((ServerPlayer) fromEntity).connection.send(new net.minecraft.network.protocol.game.ClientboundSoundPacket(net.minecraft.core.registries.BuiltInRegistries.SOUND_EVENT.wrapAsHolder(soundEffect), soundCategory, x, y, z, volume, pitch, fromEntity.random.nextLong())); diff --git a/patches/server/0078-Protect-scaffolding-from-creepers.patch b/patches/server/0074-Protect-scaffolding-from-creepers.patch similarity index 79% rename from patches/server/0078-Protect-scaffolding-from-creepers.patch rename to patches/server/0074-Protect-scaffolding-from-creepers.patch index 428dc6c..151c518 100644 --- a/patches/server/0078-Protect-scaffolding-from-creepers.patch +++ b/patches/server/0074-Protect-scaffolding-from-creepers.patch @@ -5,11 +5,11 @@ Subject: [PATCH] Protect scaffolding from creepers diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 035b5ea9570668fa8aaafd7b757458343fd26456..0f2fed57d94993d4f819a40b47503a62c60ac092 100644 +index 4047610d0a01ce58f023da9a810ea3f5320892e7..ea37fb1f7107f38ae2de0c6335d83e4de8587b3b 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -298,6 +298,11 @@ public class Explosion { - return Optional.of(ZERO_RESISTANCE); +@@ -326,6 +326,11 @@ public class Explosion { + return Optional.of(-0.3f); } // Sakura end - allow explosions to destroy lava + // Sakura start - protect scaffolding from creepers @@ -19,4 +19,4 @@ index 035b5ea9570668fa8aaafd7b757458343fd26456..0f2fed57d94993d4f819a40b47503a62 + // Sakura end - protect scaffolding from creepers } - return this.damageCalculator.getBlockExplosionResistance((Explosion)(Object)this, this.level, pos, blockState, fluidState); + return this.damageCalculator.getBlockExplosionResistance(this, this.level, pos, blockState, fluidState); diff --git a/patches/server/0079-Entity-tracking-range-modifier.patch b/patches/server/0075-Entity-tracking-range-modifier.patch similarity index 62% rename from patches/server/0079-Entity-tracking-range-modifier.patch rename to patches/server/0075-Entity-tracking-range-modifier.patch index ada7ad7..1193c37 100644 --- a/patches/server/0079-Entity-tracking-range-modifier.patch +++ b/patches/server/0075-Entity-tracking-range-modifier.patch @@ -5,39 +5,39 @@ Subject: [PATCH] Entity tracking range modifier diff --git a/src/main/java/net/minecraft/server/level/ChunkMap.java b/src/main/java/net/minecraft/server/level/ChunkMap.java -index baec8d775957f3ef3224d743f961f0a23aee92ab..f89667bd9a3960a0f2c3bd6e99a9b0a6566b0f24 100644 +index 5e326f26b5166b7ce79bad5724ae63392d53fa45..d7b3b3def7ae557dd8420096e8232a7be592ffcb 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1431,7 +1431,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1620,7 +1620,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + double vec3d_dx = player.getX() - this.entity.getX(); double vec3d_dz = player.getZ() - this.entity.getZ(); // Paper end - remove allocation of Vec3D here - int i = ChunkMap.this.getPlayerViewDistance(player); -- double d0 = (double) Math.min(this.getEffectiveRange(), i * 16); +- double d0 = (double) Math.min(this.getEffectiveRange(), io.papermc.paper.chunk.PlayerChunkLoader.getSendViewDistance(player) * 16); // Paper - per player view distance + // Sakura start - entity tracking range modifier + double visibleRange = (double) this.getEffectiveRange() * player.trackingRangeModifier; -+ double d0 = (double) Math.min(visibleRange, i * 16); ++ double d0 = (double) Math.min(visibleRange, io.papermc.paper.chunk.PlayerChunkLoader.getSendViewDistance(player) * 16); // Paper - per player view distance + // Sakura end - entity tracking range modifier double d1 = vec3d_dx * vec3d_dx + vec3d_dz * vec3d_dz; // Paper double d2 = d0 * d0; - boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(player) && ChunkMap.this.isChunkTracked(player, this.entity.chunkPosition().x, this.entity.chunkPosition().z); + boolean flag = d1 <= d2 && this.entity.broadcastToPlayer(player); diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java -index 68ea7cd8148ff4a80da761cf38e73bfa15f93b97..f7e7041366fe6dfd43299a0866962ddbbe5c2b29 100644 +index 5f38f9a7aca3af47dc3454035a7faf1d30d05932..5b876f7ee8f34f553a5e02dd2a6771a374996950 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -329,6 +329,7 @@ public class ServerPlayer extends Player { - // Paper start - optimise chunk tick iteration - public double lastEntitySpawnRadiusSquared = -1.0; - // Paper end - optimise chunk tick iteration +@@ -269,6 +269,7 @@ public class ServerPlayer extends Player { + public final com.destroystokyo.paper.util.misc.PooledLinkedHashSets.PooledObjectLinkedOpenHashSet cachedSingleHashSet; // Paper + public PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper + public org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - there are a lot of changes to do if we change all methods leading to the event + public double trackingRangeModifier = 1.0; // Sakura - entity tracking range modifier - public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile, ClientInformation clientOptions) { + public ServerPlayer(MinecraftServer server, ServerLevel world, GameProfile profile) { super(world, world.getSharedSpawnPos(), world.getSharedSpawnAngle(), profile); diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 29f0c4c3fd9185bf8768572c135b50a9db34dbbe..80c8d59566e9e6f0a2ea89b075981a13b65883b0 100644 +index aaa3b2aa8e8791d88e2fb08342ec8c133cd219d6..f05ede50e07805d2432c7ed6af02f8babb94c506 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -2922,6 +2922,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { - return (this.getHandle().requestedViewDistance() == 0) ? Bukkit.getViewDistance() : this.getHandle().requestedViewDistance(); +@@ -2562,6 +2562,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { + return (this.getHandle().clientViewDistance == null) ? Bukkit.getViewDistance() : this.getHandle().clientViewDistance; } + // Sakura start - entity tracking range modifier diff --git a/patches/server/0080-Set-entity-impulse-on-explosion.patch b/patches/server/0076-Set-entity-impulse-on-explosion.patch similarity index 68% rename from patches/server/0080-Set-entity-impulse-on-explosion.patch rename to patches/server/0076-Set-entity-impulse-on-explosion.patch index 89c799b..c37b7c7 100644 --- a/patches/server/0080-Set-entity-impulse-on-explosion.patch +++ b/patches/server/0076-Set-entity-impulse-on-explosion.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Set entity impulse on explosion diff --git a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java -index 1b6b535836d939fe07c509176871af4e76669760..35cddf7c87192341147734794d8580158feb1626 100644 +index a6b4cae3f04cda71629b5da3a08a8c4c7b51b8a7..b32a86c3b6e9d8b378626901389cf201c14b1428 100644 --- a/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java +++ b/src/main/java/me/samsuik/sakura/explosion/special/SpecialisedExplosion.java -@@ -197,6 +197,7 @@ public abstract class SpecialisedExplosion extends Explosion { +@@ -173,6 +173,7 @@ public abstract class SpecialisedExplosion extends Explosion { y *= exposure; z *= exposure; @@ -17,14 +17,14 @@ index 1b6b535836d939fe07c509176871af4e76669760..35cddf7c87192341147734794d858015 entity.addDeltaMovement(x, y, z); } diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 7fd7149d4c370d6893318b729f93778ef02bc4b1..4960d170a273eff18d2d83cdb7c4772fa020db4f 100644 +index ea37fb1f7107f38ae2de0c6335d83e4de8587b3b..26f65df8bb684f8f672c755f4c47cf9a64e459de 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -829,6 +829,7 @@ public class Explosion { - entity.addDeltaMovement(d8, d9, d10); - // Sakura end - reduce deltaMovement allocations +@@ -490,6 +490,7 @@ public class Explosion { + if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled + return; // Sakura - optimise vanilla explosions } + entity.hasImpulse = true; // Sakura - set entity impulse on explosion // CraftBukkit end - if (entity instanceof Player) { - Player entityhuman = (Player) entity; + double d14 = d13; + diff --git a/patches/server/0081-Configurable-left-shooting-and-adjusting-limits.patch b/patches/server/0077-Configurable-left-shooting-and-adjusting-limits.patch similarity index 84% rename from patches/server/0081-Configurable-left-shooting-and-adjusting-limits.patch rename to patches/server/0077-Configurable-left-shooting-and-adjusting-limits.patch index eda4104..6084bb4 100644 --- a/patches/server/0081-Configurable-left-shooting-and-adjusting-limits.patch +++ b/patches/server/0077-Configurable-left-shooting-and-adjusting-limits.patch @@ -5,11 +5,11 @@ Subject: [PATCH] Configurable left shooting and adjusting limits diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 42642b77213567e9bf6acb3728f75e76e3f3447c..09cdb4fb53552e23a4870649a6f834d9c2b36780 100644 +index cbe68a30983380068c54eec708ce8ec8c0d3db38..a7007de54ceca399b0cc3b611489dc6215be70a9 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -746,6 +746,24 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S - return Math.max(x, z) >= travelDistanceLimit; +@@ -711,6 +711,24 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + return Math.max(x, z) >= this.travelDistanceLimit; } // Sakura end - entity travel distance limits + // Sakura start - configurable left shooting and adjusting limits @@ -33,7 +33,7 @@ index 42642b77213567e9bf6acb3728f75e76e3f3447c..09cdb4fb53552e23a4870649a6f834d9 public Entity(EntityType type, Level world) { this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -1777,6 +1795,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, S +@@ -1649,6 +1667,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { final boolean xSmaller = this.physics == null || this.physics.afterOrEqual(1_14_0) ? Math.abs(x) < Math.abs(z) : this.physics.isLegacy() && Math.abs(x) > Math.abs(z); // Sakura end - physics version api @@ -58,9 +58,9 @@ index 42642b77213567e9bf6acb3728f75e76e3f3447c..09cdb4fb53552e23a4870649a6f834d9 + // Sakura end - configurable left shooting and adjusting limits if (y != 0.0) { - y = scanY(currBoundingBox, y, voxelList, bbList); + y = this.scanY(currBoundingBox, y, bbList); 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 ab88fc1db9740ab249b332a6c01a6d6e2a998c1c..c7ee16e80eab05fb80cc8ad04315cc68fa933af5 100644 +index d4e8bffc31415663fd3628ad33acc2d59e2036ca..d38d6c269a5da6ff5b347c8838123d9f3b7593e4 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java @@ -257,6 +257,7 @@ public class FallingBlockEntity extends Entity { @@ -69,5 +69,5 @@ index ab88fc1db9740ab249b332a6c01a6d6e2a998c1c..c7ee16e80eab05fb80cc8ad04315cc68 + this.limitLeftShooting(); // Sakura - configurable left shooting and adjusting limits this.moveBasic(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise simple entity movement - // Paper start - Configurable falling blocks height nerf - if (this.level().paperConfig().fixes.fallingBlockHeightNerf.test(v -> this.getY() > v)) { + + // Paper start - fix sand duping diff --git a/patches/server/0078-Allow-projectiles-to-load-chunks-for-collisions.patch b/patches/server/0078-Allow-projectiles-to-load-chunks-for-collisions.patch new file mode 100644 index 0000000..40b8953 --- /dev/null +++ b/patches/server/0078-Allow-projectiles-to-load-chunks-for-collisions.patch @@ -0,0 +1,64 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik +Date: Mon, 2 Sep 2024 22:11:46 +0100 +Subject: [PATCH] Allow projectiles to load chunks for collisions + + +diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java +index c56bc341ebb1592af9285d5e044951e7ae2ae0b2..070a0ce1c7140499be8222ad39e5ada0f79a0c82 100644 +--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java ++++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java +@@ -90,6 +90,7 @@ public abstract class AbstractArrow extends Projectile { + this.pickup = AbstractArrow.Pickup.DISALLOWED; + this.baseDamage = 2.0D; + this.soundEvent = this.getDefaultHitGroundSoundEvent(); ++ this.loadChunks = this.level.sakuraConfig().entity.projectilesLoadChunksForCollisions; // Sakura - allow projectiles to load chunks for collisions + } + + protected AbstractArrow(EntityType type, double x, double y, double z, Level world) { +diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java +index d1eefa6ef3e9abfe7af4d8310aa64465fa2d5463..04d45b2ddc3489c4d0764da1575cb9a373d9a490 100644 +--- a/src/main/java/net/minecraft/world/level/BlockGetter.java ++++ b/src/main/java/net/minecraft/world/level/BlockGetter.java +@@ -76,7 +76,14 @@ public interface BlockGetter extends LevelHeightAccessor { + // CraftBukkit start - moved block handling into separate method for use by Block#rayTrace + default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) { + // Paper start - Prevent raytrace from loading chunks +- BlockState iblockdata = this.getBlockStateIfLoaded(blockposition); ++ // Sakura start - allow projectiles to load chunks for collisions ++ final BlockState iblockdata; ++ if (raytrace1.loadChunks()) { ++ iblockdata = this.getBlockState(blockposition); ++ } else { ++ iblockdata = this.getBlockStateIfLoaded(blockposition); ++ } ++ // Sakura end - allow projectiles to load chunks for collisions + if (iblockdata == null) { + // copied the last function parameter (listed below) + Vec3 vec3d = raytrace1.getFrom().subtract(raytrace1.getTo()); +diff --git a/src/main/java/net/minecraft/world/level/ClipContext.java b/src/main/java/net/minecraft/world/level/ClipContext.java +index ad2c533e9a0f0e2d97620b0e16200d7eeaedeefb..1e351f85dd1d9c4f267b283dd93bb74306fd9311 100644 +--- a/src/main/java/net/minecraft/world/level/ClipContext.java ++++ b/src/main/java/net/minecraft/world/level/ClipContext.java +@@ -20,6 +20,13 @@ public class ClipContext { + private final ClipContext.Block block; + private final ClipContext.Fluid fluid; + private final CollisionContext collisionContext; ++ // Sakura start - allow projectiles to load chunks for collisions ++ private final boolean loadChunks; ++ ++ public boolean loadChunks() { ++ return this.loadChunks; ++ } ++ // Sakura end - allow projectiles to load chunks for collisions + + public ClipContext(Vec3 start, Vec3 end, ClipContext.Block shapeType, ClipContext.Fluid fluidHandling, Entity entity) { + this.from = start; +@@ -27,6 +34,7 @@ public class ClipContext { + this.block = shapeType; + this.fluid = fluidHandling; + this.collisionContext = (entity == null) ? CollisionContext.empty() : CollisionContext.of(entity); // CraftBukkit ++ this.loadChunks = entity != null && entity.loadChunks; // Sakura - allow projectiles to load chunks for collisions + } + + public Vec3 getTo() { diff --git a/patches/server/0083-Add-max-armour-durability-damage.patch b/patches/server/0079-Add-max-armour-durability-damage.patch similarity index 73% rename from patches/server/0083-Add-max-armour-durability-damage.patch rename to patches/server/0079-Add-max-armour-durability-damage.patch index e69ca72..c944b7c 100644 --- a/patches/server/0083-Add-max-armour-durability-damage.patch +++ b/patches/server/0079-Add-max-armour-durability-damage.patch @@ -5,15 +5,15 @@ Subject: [PATCH] Add max armour durability damage diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java -index 99bc5f6665524dfb42d7e7dd3f71fb45147b3b58..17709801c0c8ab34f35b776d68b120e9909849ef 100644 +index 7cb6e250bd1c14e557c359fe211d8a1f9b4de986..fd7c3b3bd3665a65c8412fd9455c2320878960a7 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -2371,6 +2371,12 @@ public abstract class LivingEntity extends Entity implements Attackable { +@@ -2278,6 +2278,12 @@ public abstract class LivingEntity extends Entity { // Apply damage to armor - if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) { + if (!damagesource.isBypassArmor()) { float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT)); + // Sakura start - add max armour durability damage -+ int maxArmourDamage = this.level().sakuraConfig().players.combat.maxArmourDamage.or(-1); ++ int maxArmourDamage = this.level.sakuraConfig().players.combat.maxArmourDamage.or(-1); + if (maxArmourDamage >= 0) { + armorDamage = Math.min(armorDamage, maxArmourDamage); + } diff --git a/patches/server/0080-Airplane-Strip-raytracing-for-EntityLiving-hasLineOf.patch b/patches/server/0080-Airplane-Strip-raytracing-for-EntityLiving-hasLineOf.patch new file mode 100644 index 0000000..782a367 --- /dev/null +++ b/patches/server/0080-Airplane-Strip-raytracing-for-EntityLiving-hasLineOf.patch @@ -0,0 +1,160 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Paul Sauve +Date: Sat, 31 Oct 2020 18:43:02 -0500 +Subject: [PATCH] Airplane - Strip raytracing for EntityLiving#hasLineOfSight + +The IBlockAccess#rayTrace method is very wasteful in both allocations, +and in logic. While EntityLiving#hasLineOfSight provides static +parameters for collisions with blocks and fluids, the method still does +a lot of dynamic checks for both of these, which result in extra work. +As well, since the fluid collision option is set to NONE, the entire +fluid collision system is completely unneeded, yet used anyways. + +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/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java +index fd7c3b3bd3665a65c8412fd9455c2320878960a7..2111c8cbefadb998734eb1eb0c09492d3752bf66 100644 +--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java ++++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +@@ -3755,7 +3755,10 @@ public abstract class LivingEntity extends Entity { + Vec3 vec3d1 = new Vec3(entity.getX(), entity.getEyeY(), entity.getZ()); + + // Paper - diff on change - used in CraftLivingEntity#hasLineOfSight(Location) and CraftWorld#lineOfSightExists +- return vec3d1.distanceToSqr(vec3d) > 128D * 128D ? false : this.level.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS; // Paper - use distanceToSqr ++ // Airplane start ++ //return vec3d1.distanceToSqr(vec3d) > 128D * 128D ? false : this.level.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)).getType() == HitResult.Type.MISS; // Paper - use distanceToSqr ++ return vec3d1.distanceToSqr(vec3d) > 128D * 128D ? false : this.level.rayTraceDirect(vec3d, vec3d1, net.minecraft.world.phys.shapes.CollisionContext.of(this)) == net.minecraft.world.phys.BlockHitResult.Type.MISS; ++ // Airplane end + } + } + +diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java +index 04d45b2ddc3489c4d0764da1575cb9a373d9a490..5cb899dd7ab92552605e74b2840d57a40f4c1434 100644 +--- a/src/main/java/net/minecraft/world/level/BlockGetter.java ++++ b/src/main/java/net/minecraft/world/level/BlockGetter.java +@@ -73,6 +73,16 @@ public interface BlockGetter extends LevelHeightAccessor { + }); + } + ++ // Airplane start - broken down variant of below rayTraceBlock, used by World#rayTraceDirect ++ default net.minecraft.world.phys.BlockHitResult.Type rayTraceBlockDirect(Vec3 vec3d, Vec3 vec3d1, BlockPos blockposition, BlockState iblockdata, net.minecraft.world.phys.shapes.CollisionContext voxelshapecoll) { ++ if (iblockdata.isAir()) return null; // Tuinity - optimise air cases ++ VoxelShape voxelshape = ClipContext.Block.COLLIDER.get(iblockdata, this, blockposition, voxelshapecoll); ++ net.minecraft.world.phys.BlockHitResult movingobjectpositionblock = this.clipWithInteractionOverride(vec3d, vec3d1, blockposition, voxelshape, iblockdata); ++ ++ return movingobjectpositionblock == null ? null : movingobjectpositionblock.getType(); ++ } ++ // Airplane end ++ + // CraftBukkit start - moved block handling into separate method for use by Block#rayTrace + default BlockHitResult clip(ClipContext raytrace1, BlockPos blockposition) { + // Paper start - Prevent raytrace from loading chunks +diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java +index 785f621ab4be55cb6f216bf11731aee2f40198c3..7c8c7f74bbb27ed8f23e2f99062e9502a3adf3f6 100644 +--- a/src/main/java/net/minecraft/world/level/Level.java ++++ b/src/main/java/net/minecraft/world/level/Level.java +@@ -519,6 +519,90 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + return x >= bb.minX && x <= bb.maxX && y >= bb.minY && y <= bb.maxY; + } + // Sakura end - physics version api ++ // Airplane start - broken down method of raytracing for EntityLiving#hasLineOfSight, replaces IBlockAccess#rayTrace(RayTrace) ++ public final net.minecraft.world.phys.BlockHitResult.Type rayTraceDirect(net.minecraft.world.phys.Vec3 vec3d, net.minecraft.world.phys.Vec3 vec3d1, net.minecraft.world.phys.shapes.CollisionContext voxelshapecoll) { ++ // most of this code comes from IBlockAccess#a(RayTrace, BiFunction, Function), but removes the needless functions ++ if (vec3d.equals(vec3d1)) { ++ return net.minecraft.world.phys.BlockHitResult.Type.MISS; ++ } ++ ++ double endX = Mth.lerp(-1.0E-7D, vec3d1.x, vec3d.x); ++ double endY = Mth.lerp(-1.0E-7D, vec3d1.y, vec3d.y); ++ double endZ = Mth.lerp(-1.0E-7D, vec3d1.z, vec3d.z); ++ ++ double startX = Mth.lerp(-1.0E-7D, vec3d.x, vec3d1.x); ++ double startY = Mth.lerp(-1.0E-7D, vec3d.y, vec3d1.y); ++ double startZ = Mth.lerp(-1.0E-7D, vec3d.z, vec3d1.z); ++ ++ int currentX = Mth.floor(startX); ++ int currentY = Mth.floor(startY); ++ int currentZ = Mth.floor(startZ); ++ ++ BlockPos.MutableBlockPos currentBlock = new BlockPos.MutableBlockPos(currentX, currentY, currentZ); ++ ++ LevelChunk chunk = this.getChunkIfLoaded(currentBlock); ++ if (chunk == null) { ++ return net.minecraft.world.phys.BlockHitResult.Type.MISS; ++ } ++ ++ net.minecraft.world.phys.BlockHitResult.Type initialCheck = this.rayTraceBlockDirect(vec3d, vec3d1, currentBlock, chunk.getBlockState(currentBlock), voxelshapecoll); ++ ++ if (initialCheck != null) { ++ return initialCheck; ++ } ++ ++ double diffX = endX - startX; ++ double diffY = endY - startY; ++ double diffZ = endZ - startZ; ++ ++ int xDirection = Mth.sign(diffX); ++ int yDirection = Mth.sign(diffY); ++ int zDirection = Mth.sign(diffZ); ++ ++ double normalizedX = xDirection == 0 ? Double.MAX_VALUE : (double) xDirection / diffX; ++ double normalizedY = yDirection == 0 ? Double.MAX_VALUE : (double) yDirection / diffY; ++ double normalizedZ = zDirection == 0 ? Double.MAX_VALUE : (double) zDirection / diffZ; ++ ++ double normalizedXDirection = normalizedX * (xDirection > 0 ? 1.0D - Mth.frac(startX) : Mth.frac(startX)); ++ double normalizedYDirection = normalizedY * (yDirection > 0 ? 1.0D - Mth.frac(startY) : Mth.frac(startY)); ++ double normalizedZDirection = normalizedZ * (zDirection > 0 ? 1.0D - Mth.frac(startZ) : Mth.frac(startZ)); ++ ++ net.minecraft.world.phys.BlockHitResult.Type result; ++ ++ do { ++ if (normalizedXDirection > 1.0D && normalizedYDirection > 1.0D && normalizedZDirection > 1.0D) { ++ return net.minecraft.world.phys.BlockHitResult.Type.MISS; ++ } ++ ++ if (normalizedXDirection < normalizedYDirection) { ++ if (normalizedXDirection < normalizedZDirection) { ++ currentX += xDirection; ++ normalizedXDirection += normalizedX; ++ } else { ++ currentZ += zDirection; ++ normalizedZDirection += normalizedZ; ++ } ++ } else if (normalizedYDirection < normalizedZDirection) { ++ currentY += yDirection; ++ normalizedYDirection += normalizedY; ++ } else { ++ currentZ += zDirection; ++ normalizedZDirection += normalizedZ; ++ } ++ ++ currentBlock.set(currentX, currentY, currentZ); ++ if (chunk.getPos().x != currentBlock.getX() >> 4 || chunk.getPos().z != currentBlock.getZ() >> 4) { ++ chunk = this.getChunkIfLoaded(currentBlock); ++ if (chunk == null) { ++ return net.minecraft.world.phys.BlockHitResult.Type.MISS; ++ } ++ } ++ result = this.rayTraceBlockDirect(vec3d, vec3d1, currentBlock, chunk.getBlockState(currentBlock), voxelshapecoll); ++ } while (result == null); ++ ++ return result; ++ } ++ // Airplane end + + protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, int j, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.function.Function paperWorldConfigCreator, Supplier sakuraWorldConfigCreator, java.util.concurrent.Executor executor) { // Sakura // Paper - Async-Anti-Xray - Pass executor + this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot diff --git a/patches/server/0081-Optimise-explosion-raytracing.patch b/patches/server/0081-Optimise-explosion-raytracing.patch new file mode 100644 index 0000000..f01fb5f --- /dev/null +++ b/patches/server/0081-Optimise-explosion-raytracing.patch @@ -0,0 +1,167 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik +Date: Tue, 1 Mar 2022 18:40:09 +0000 +Subject: [PATCH] Optimise explosion raytracing + + +diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java +index 5cb899dd7ab92552605e74b2840d57a40f4c1434..da60f48e50ecffd5bdd87badaaa7a51593f138b5 100644 +--- a/src/main/java/net/minecraft/world/level/BlockGetter.java ++++ b/src/main/java/net/minecraft/world/level/BlockGetter.java +@@ -75,11 +75,11 @@ public interface BlockGetter extends LevelHeightAccessor { + + // Airplane start - broken down variant of below rayTraceBlock, used by World#rayTraceDirect + default net.minecraft.world.phys.BlockHitResult.Type rayTraceBlockDirect(Vec3 vec3d, Vec3 vec3d1, BlockPos blockposition, BlockState iblockdata, net.minecraft.world.phys.shapes.CollisionContext voxelshapecoll) { +- if (iblockdata.isAir()) return null; // Tuinity - optimise air cases ++ // Sakura start - optimise explosion raytracing ++ if (iblockdata.isAir() || iblockdata.isLiquid()) return null; // Tuinity - optimise air cases + VoxelShape voxelshape = ClipContext.Block.COLLIDER.get(iblockdata, this, blockposition, voxelshapecoll); +- net.minecraft.world.phys.BlockHitResult movingobjectpositionblock = this.clipWithInteractionOverride(vec3d, vec3d1, blockposition, voxelshape, iblockdata); +- +- return movingobjectpositionblock == null ? null : movingobjectpositionblock.getType(); ++ return voxelshape.clipDirect(vec3d, vec3d1, blockposition) ? BlockHitResult.Type.BLOCK : null; ++ // Sakura end - optimise explosion raytracing + } + // Airplane end + +diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java +index 26f65df8bb684f8f672c755f4c47cf9a64e459de..8e8688402d27eaf79daf9027ac07e86f2a43a122 100644 +--- a/src/main/java/net/minecraft/world/level/Explosion.java ++++ b/src/main/java/net/minecraft/world/level/Explosion.java +@@ -373,6 +373,8 @@ public class Explosion { + // Sakura start - physics version api + } else if (entity.physics().before(1_14_0)) { + hitResult = entity.level.rayTrace(vec3d1, source); ++ } else if (entity.physics().afterOrEqual(1_16_0)) { ++ hitResult = entity.level.rayTraceDirect(vec3d1, source, net.minecraft.world.phys.shapes.CollisionContext.of(entity)); + } else { + ClipContext.Block context = entity.physics().afterOrEqual(1_16_0) ? ClipContext.Block.COLLIDER : ClipContext.Block.OUTLINE; + hitResult = entity.level.clip(new ClipContext(vec3d1, source, context, ClipContext.Fluid.NONE, entity)).getType(); +diff --git a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +index 25ce337ed266be7bafeacd9eb6f53a9474775fc5..4b3a93feb78dccd33ab7caf792a86816423f26be 100644 +--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java ++++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java +@@ -734,6 +734,7 @@ public abstract class BlockBehaviour implements FeatureElement { + this.offsetType = (BlockBehaviour.OffsetType) blockbase_info.offsetType.apply(this.asState()); + this.spawnParticlesOnBreak = blockbase_info.spawnParticlesOnBreak; + this.conditionallyFullOpaque = this.isOpaque() & this.isTransparentOnSomeFaces(); // Paper ++ this.liquidBlock = block instanceof net.minecraft.world.level.block.LiquidBlock; // Sakura - optimise explosion raytracing + } + // Paper start - impl cached craft block data, lazy load to fix issue with loading at the wrong time + private org.bukkit.craftbukkit.block.data.CraftBlockData cachedCraftBlockData; +@@ -768,6 +769,12 @@ public abstract class BlockBehaviour implements FeatureElement { + return this.blockCollisionBehavior; + } + // Paper end ++ // Sakura start - optimise explosion raytracing ++ private final boolean liquidBlock; ++ public final boolean isLiquid() { ++ return this.liquidBlock; ++ } ++ // Sakura end - optimise explosion raytracing + + public void initCache() { + this.fluidState = ((Block) this.owner).getFluidState(this.asState()); +diff --git a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java +index 2182afd1b95acf14c55bddfeec17dae0a63e1f00..5ef1748014ed4f9334fccc5f1344d676a19a2432 100644 +--- a/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java ++++ b/src/main/java/net/minecraft/world/phys/shapes/VoxelShape.java +@@ -132,6 +132,98 @@ public abstract class VoxelShape { + } + } + ++ // Sakura start - optimise explosion raytracing ++ public final boolean clipDirect(Vec3 start, Vec3 end, BlockPos pos) { ++ if (this == Shapes.empty() || this.isEmpty()) { ++ return false; ++ } ++ ++ double vec3_x = end.x - start.x; ++ double vec3_y = end.y - start.y; ++ double vec3_z = end.z - start.z; ++ double vec3_lengthSqr = (vec3_x * vec3_x) + (vec3_y * vec3_y) + (vec3_z * vec3_z); ++ if (vec3_lengthSqr < 1.0E-7D) { ++ return false; ++ } else if (this instanceof io.papermc.paper.voxel.AABBVoxelShape aabbVoxelShape) { ++ return this.clipWithBBDirect(aabbVoxelShape.aabb, vec3_x, vec3_y, vec3_z, start, pos); ++ } else { ++ return this.clipWithBBsDirect(vec3_x, vec3_y, vec3_z, start, pos); ++ } ++ } ++ ++ protected boolean clipWithBBDirect(AABB single, double deltaX, double deltaY, double deltaZ, Vec3 from, BlockPos pos) { ++ double posX = pos.getX(); ++ double posY = pos.getY(); ++ double posZ = pos.getZ(); ++ ++ return clipPointBB(single, from, posX, posY, posZ, deltaX, deltaY, deltaZ) ++ || this.clipInsideDirectBB(single, deltaX, deltaY, deltaZ, from, pos); ++ } ++ ++ protected boolean clipWithBBsDirect(double deltaX, double deltaY, double deltaZ, Vec3 from, BlockPos pos) { ++ double posX = pos.getX(); ++ double posY = pos.getY(); ++ double posZ = pos.getZ(); ++ ++ for (AABB bb : this.toAabbs()) { // err ++ if (clipPointBB(bb, from, posX, posY, posZ, deltaX, deltaY, deltaZ)) { ++ return true; ++ } ++ } ++ ++ return this.clipInsideDirectBBs(deltaX, deltaY, deltaZ, from, pos); ++ } ++ ++ @SuppressWarnings("SuspiciousNameCombination") ++ protected static boolean clipPointBB(AABB box, Vec3 p, double posX, double posY, double posZ, double deltaX, double deltaY, double deltaZ) { ++ double minX = box.minX + posX; ++ double minY = box.minY + posY; ++ double minZ = box.minZ + posZ; ++ double maxX = box.maxX + posX; ++ double maxY = box.maxY + posY; ++ double maxZ = box.maxZ + posZ; ++ ++ double closestX = deltaX > 1.0E-7D ? minX : maxX; ++ double closestY = deltaY > 1.0E-7D ? minY : maxY; ++ double closestZ = deltaZ > 1.0E-7D ? minZ : maxZ; ++ ++ return clipPoint(deltaX, deltaY, deltaZ, closestX, minY, maxY, minZ, maxZ, p.x, p.y, p.z) ++ || clipPoint(deltaY, deltaZ, deltaX, closestY, minZ, maxZ, minX, maxX, p.y, p.z, p.x) ++ || clipPoint(deltaZ, deltaX, deltaY, closestZ, minX, maxX, minY, maxY, p.z, p.x, p.y); ++ } ++ ++ private static boolean clipPoint(double deltaX, double deltaY, double deltaZ, double begin, double minX, double maxX, double minZ, double maxZ, double startX, double startY, double startZ) { ++ double d = (begin - startX) / deltaX; ++ double e = startY + d * deltaY; ++ double f = startZ + d * deltaZ; ++ return (d > 0.0D && d < 1.0) && (minX - 1.0E-7D < e && maxX + 1.0E-7D > e) && (minZ - 1.0E-7D < f && maxZ + 1.0E-7D > f); ++ } ++ ++ protected boolean clipInsideDirectBB(AABB single, double vec3_x, double vec3_y, double vec3_z, Vec3 start, BlockPos pos) { ++ double fromBehindX = start.x + (vec3_x * 0.001D); ++ double fromBehindY = start.y + (vec3_y * 0.001D); ++ double fromBehindZ = start.z + (vec3_z * 0.001D); ++ ++ double fromBehindOffsetX = fromBehindX - (double) pos.getX(); ++ double fromBehindOffsetY = fromBehindY - (double) pos.getY(); ++ double fromBehindOffsetZ = fromBehindZ - (double) pos.getZ(); ++ ++ return single.contains(fromBehindOffsetX, fromBehindOffsetY, fromBehindOffsetZ); ++ } ++ ++ protected boolean clipInsideDirectBBs(double vec3_x, double vec3_y, double vec3_z, Vec3 start, BlockPos pos) { ++ double fromBehindX = start.x + (vec3_x * 0.001D); ++ double fromBehindY = start.y + (vec3_y * 0.001D); ++ double fromBehindZ = start.z + (vec3_z * 0.001D); ++ ++ int indexX = this.findIndex(Direction.Axis.X, fromBehindX - (double) pos.getX()); ++ int indexY = this.findIndex(Direction.Axis.Y, fromBehindY - (double) pos.getY()); ++ int indexZ = this.findIndex(Direction.Axis.Z, fromBehindZ - (double) pos.getZ()); ++ ++ return this.shape.isFullWide(indexX, indexY, indexZ); ++ } ++ // Sakura end ++ + public Optional closestPointTo(Vec3 target) { + if (this.isEmpty()) { + return Optional.empty(); diff --git a/patches/server/0082-Allow-projectiles-to-load-chunks-for-collisions.patch b/patches/server/0082-Allow-projectiles-to-load-chunks-for-collisions.patch deleted file mode 100644 index 5dce020..0000000 --- a/patches/server/0082-Allow-projectiles-to-load-chunks-for-collisions.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Samsuik -Date: Mon, 2 Sep 2024 22:11:46 +0100 -Subject: [PATCH] Allow projectiles to load chunks for collisions - - -diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -index e8faca6e443239968f0111519f9e5cd018ed3297..36b645842a65dd017b6a8d1d12b751dd01ddfde0 100644 ---- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -213,7 +213,7 @@ public abstract class AbstractArrow extends Projectile { - Vec3 vec3d2 = this.position(); - - vec3d1 = vec3d2.add(vec3d); -- Object object = this.level().clip(new ClipContext(vec3d2, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this)); -+ Object object = this.level().clip(new ClipContext(vec3d2, vec3d1, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, this), this.level().sakuraConfig().entity.projectilesLoadChunksForCollisions); // Sakura - allow projectiles to load chunks for collisions - - if (((HitResult) object).getType() != HitResult.Type.MISS) { - vec3d1 = ((HitResult) object).getLocation(); -diff --git a/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java b/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java -index 3ab65cb7d891ddba011afd795dbf699f37cb8a17..451ccf4b02c7f43a81d5735d73cd923a155353fd 100644 ---- a/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java -+++ b/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java -@@ -46,7 +46,7 @@ public final class ProjectileUtil { - Vec3 pos, Entity entity, Predicate predicate, Vec3 velocity, Level world, float margin, ClipContext.Block raycastShapeType - ) { - Vec3 vec3 = pos.add(velocity); -- HitResult hitResult = world.clip(new ClipContext(pos, vec3, raycastShapeType, ClipContext.Fluid.NONE, entity)); -+ HitResult hitResult = world.clip(new ClipContext(pos, vec3, raycastShapeType, ClipContext.Fluid.NONE, entity), world.sakuraConfig().entity.projectilesLoadChunksForCollisions); // Sakura - allow projectiles to load chunks for collisions - if (hitResult.getType() != HitResult.Type.MISS) { - vec3 = hitResult.getLocation(); - } -diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index c2c0d80adb6fa8cb74fa5fe3ce5bc7ac0609abba..42d7a96c176368fdfcd433cba564ad18b451ff35 100644 ---- a/src/main/java/net/minecraft/world/level/Level.java -+++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -639,8 +639,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - - private static final FluidState AIR_FLUIDSTATE = Fluids.EMPTY.defaultFluidState(); - -+ // Sakura start - allow projectiles to load chunks for collisions - private static net.minecraft.world.phys.BlockHitResult fastClip(final Vec3 from, final Vec3 to, final Level level, - final ClipContext clipContext) { -+ return fastClip(from, to, level, clipContext, false); -+ } -+ private static net.minecraft.world.phys.BlockHitResult fastClip(final Vec3 from, final Vec3 to, final Level level, -+ final ClipContext clipContext, final boolean loadChunks) { -+ // Sakura end - allow projectiles to load chunks for collisions - final double adjX = io.papermc.paper.util.CollisionUtil.COLLISION_EPSILON * (from.x - to.x); - final double adjY = io.papermc.paper.util.CollisionUtil.COLLISION_EPSILON * (from.y - to.y); - final double adjZ = io.papermc.paper.util.CollisionUtil.COLLISION_EPSILON * (from.z - to.z); -@@ -703,7 +709,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - - if ((chunkDiff | chunkYDiff) != 0) { - if (chunkDiff != 0) { -- LevelChunk chunk = chunkProvider.getChunkAtIfLoadedImmediately(newChunkX, newChunkZ); -+ LevelChunk chunk = loadChunks ? level.getChunk(newChunkX, newChunkZ) : chunkProvider.getChunkAtIfLoadedImmediately(newChunkX, newChunkZ); // Sakura - allow projectiles to load chunks for collisions - lastChunk = chunk == null ? null : chunk.getSections(); // diff: don't load chunks for this - } - final int sectionY = newChunkY - minSection; -@@ -774,6 +780,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - return fastClip(clipContext.getFrom(), clipContext.getTo(), this, clipContext); - } - -+ // Sakura start - allow projectiles to load chunks for collisions -+ public final net.minecraft.world.phys.BlockHitResult clip(final ClipContext clipContext, final boolean loadChunks) { -+ return fastClip(clipContext.getFrom(), clipContext.getTo(), this, clipContext, loadChunks); -+ } -+ // Sakura end - allow projectiles to load chunks for collisions -+ - @Override - public final boolean noCollision(final Entity entity, final AABB box, final boolean loadChunks) { - int flags = io.papermc.paper.util.CollisionUtil.COLLISION_FLAG_CHECK_ONLY; diff --git a/patches/server/0084-PAPER-Check-for-block-type-in-SculkSensorBlock-canAc.patch b/patches/unap-server/0084-PAPER-Check-for-block-type-in-SculkSensorBlock-canAc.patch similarity index 100% rename from patches/server/0084-PAPER-Check-for-block-type-in-SculkSensorBlock-canAc.patch rename to patches/unap-server/0084-PAPER-Check-for-block-type-in-SculkSensorBlock-canAc.patch diff --git a/patches/server/0085-PAPER-Improve-standard-messenger-logging.patch b/patches/unap-server/0085-PAPER-Improve-standard-messenger-logging.patch similarity index 100% rename from patches/server/0085-PAPER-Improve-standard-messenger-logging.patch rename to patches/unap-server/0085-PAPER-Improve-standard-messenger-logging.patch diff --git a/patches/server/0033-Cache-Vanillia-and-Eigen-Redstone.patch b/patches/unap-server/removed/0033-Cache-Vanillia-and-Eigen-Redstone.patch similarity index 100% rename from patches/server/0033-Cache-Vanillia-and-Eigen-Redstone.patch rename to patches/unap-server/removed/0033-Cache-Vanillia-and-Eigen-Redstone.patch diff --git a/patches/server/0059-Fix-paper-findSupportingBlock-not-updating-last-chun.patch b/patches/unap-server/removed/0059-Fix-paper-findSupportingBlock-not-updating-last-chun.patch similarity index 100% rename from patches/server/0059-Fix-paper-findSupportingBlock-not-updating-last-chun.patch rename to patches/unap-server/removed/0059-Fix-paper-findSupportingBlock-not-updating-last-chun.patch diff --git a/patches/server/0070-Protect-block-shapes-against-plugins.patch b/patches/unap-server/removed/0070-Protect-block-shapes-against-plugins.patch similarity index 100% rename from patches/server/0070-Protect-block-shapes-against-plugins.patch rename to patches/unap-server/removed/0070-Protect-block-shapes-against-plugins.patch