From 9ec82c34eaea892325c6ec9fceeb89797bdebff7 Mon Sep 17 00:00:00 2001 From: Samsuik Date: Fri, 14 Mar 2025 18:45:24 +0000 Subject: [PATCH] Begin backporting to 1.18.2 --- build.gradle.kts | 8 +- gradle.properties | 6 +- .../api/0001-Customise-Version-Command.patch | 12 +- patches/api/0003-Visibility-API.patch | 4 +- patches/api/0005-isPushedByFluid-API.patch | 4 +- .../api/0007-Local-Value-Storage-API.patch | 4 +- .../0013-Entity-tracking-range-modifier.patch | 4 +- patches/server/0001-Branding-changes.patch | 14 +- ...ra-Utils.patch => 0002-Sakura-Utils.patch} | 0 .../0003-Sakura-Configuration-Files.patch | 990 ++++++++++++++++ ...-Local-Config-and-Value-Storage-API.patch} | 40 +- .../0004-Sakura-Configuration-Files.patch | 1002 ----------------- ... => 0005-Visibility-API-and-Command.patch} | 83 +- ...06-Reduce-deltaMovement-Allocations.patch} | 35 +- ...007-Optional-Force-Position-Updates.patch} | 10 +- ...tch => 0008-Load-Chunks-on-Movement.patch} | 48 +- ...and.patch => 0009-TPS-Graph-Command.patch} | 60 +- ...ce-Packet-obfuscation-and-reduction.patch} | 148 +-- ...0011-Use-Optimised-TrackedEntityMap.patch} | 8 +- ...tityList-methods-to-BasicEntityList.patch} | 8 +- ...Add-utility-methods-to-EntitySlices.patch} | 10 +- ...h => 0014-Optimise-paper-explosions.patch} | 35 +- ...tch => 0015-Store-Entity-Data-State.patch} | 18 +- ...patch => 0016-Merge-Cannon-Entities.patch} | 111 +- ...017-Replace-explosion-density-cache.patch} | 38 +- ...ise-explosions-in-protected-regions.patch} | 12 +- ...atch => 0019-Specialised-Explosions.patch} | 44 +- ...atch => 0020-Optimise-Fast-Movement.patch} | 20 +- ...I.patch => 0021-isPushedByFluid-API.patch} | 14 +- ...nics.patch => 0022-Cannon-Mechanics.patch} | 30 +- ...e-MovingBlockEntity-collision-shape.patch} | 6 +- ...ptimise-TNT-fluid-state-and-pushing.patch} | 14 +- ...alling-blocks-inside-moving-pistons.patch} | 6 +- ... => 0026-Configure-Entity-Knockback.patch} | 54 +- ...ch => 0027-Explosion-Durable-Blocks.patch} | 32 +- ... => 0028-Destroy-Waterlogged-Blocks.patch} | 8 +- ...Falling-Block-Stacking-Restrictions.patch} | 6 +- ...ItemEntity-s-that-ignore-explosions.patch} | 10 +- ...031-Add-option-to-disable-entity-ai.patch} | 6 +- ...=> 0032-Consistent-Explosion-Radius.patch} | 14 +- ...0033-Remove-spigot-max-tnt-per-tick.patch} | 4 +- ...-configure-entity-water-sensitivity.patch} | 4 +- ...Configure-cannon-physics-by-version.patch} | 168 ++- ...h => 0036-Allow-water-in-the-nether.patch} | 20 +- ...igure-concrete-solidifying-in-water.patch} | 6 +- ...tion-for-fast-nether-dimension-lava.patch} | 4 +- ...39-Allow-explosions-to-destroy-lava.patch} | 12 +- ...e-columns-affecting-cannon-entities.patch} | 4 +- ...ble-blocks-as-full-while-moving-fas.patch} | 12 +- ...042-Add-redstone-implementation-API.patch} | 45 +- ...educe-entity-tracker-player-updates.patch} | 8 +- ...ion-for-legacy-lava-block-formation.patch} | 16 +- .../0045-Configure-mob-spawner-defaults.patch | 28 + ...ing-random-dispenser-item-selection.patch} | 10 +- ...047-Add-instant-mob-death-animation.patch} | 6 +- ...-Configure-fluids-breaking-redstone.patch} | 6 +- .../0049-Configure-mob-spawner-defaults.patch | 28 - ...-disable-explosions-hurting-players.patch} | 6 +- ...> 0050-Iron-golems-take-fall-damage.patch} | 6 +- ...dd-explosions-dropping-items-config.patch} | 8 +- ...mise-check-inside-blocks-and-fluids.patch} | 12 +- ...or-lava-if-throttled-water-flow-spe.patch} | 12 +- ...e-biome-noise-once-per-chunk-section.patch | 29 + ...-gamerule-preventing-falling-blocks.patch} | 4 +- ...6-Add-entity-travel-distance-limits.patch} | 18 +- ...-speed-and-breaking-inside-entities.patch} | 22 +- ...dd-outline-colliison-to-enderpearls.patch} | 8 +- ...e-biome-noise-once-per-chunk-section.patch | 29 - ...layer-poses-shrinking-collision-box.patch} | 6 +- .../server/0060-Mob-spawner-behaviour.patch | 46 + ...ment-causing-physics-when-cancelled.patch} | 24 +- ...hance-for-crop-growth-instead-of-age.patch | 54 + ...0063-Legacy-player-combat-mechanics.patch} | 38 +- ... 0064-Allow-disabling-sweep-attacks.patch} | 6 +- .../server/0064-Mob-spawner-behaviour.patch | 46 - ...065-Change-shields-to-reduce-damage.patch} | 6 +- ...=> 0066-Old-enchanted-golden-apples.patch} | 4 +- ...hance-for-crop-growth-instead-of-age.patch | 75 -- ...=> 0067-Configure-fast-health-regen.patch} | 4 +- ...-for-fishing-hooks-pulling-entities.patch} | 6 +- ...-combat-sounds-and-particle-effects.patch} | 12 +- ...0-Protect-scaffolding-from-creepers.patch} | 6 +- ...0071-Entity-tracking-range-modifier.patch} | 14 +- ...072-Set-entity-impulse-on-explosion.patch} | 4 +- ...-left-shooting-and-adjusting-limits.patch} | 18 +- ...tiles-to-load-chunks-for-collisions.patch} | 6 +- ...75-Add-max-armour-durability-damage.patch} | 6 +- ...ytracing-for-EntityLiving-hasLineOf.patch} | 12 +- ... 0077-Optimise-explosion-raytracing.patch} | 16 +- ...lock-type-in-SculkSensorBlock-canAc.patch} | 4 +- ...-Improve-standard-messenger-logging.patch} | 4 +- ...redstone-on-top-of-trap-doors-early.patch} | 4 +- ...he-player-didn-t-disconnect-when-pr.patch} | 16 +- ...2-Improve-paper-biome-cache-locking.patch} | 10 +- ...tch => 0083-Add-lava-flow-speed-api.patch} | 12 +- patches/server/0084-temp.patch | 22 + .../1.18.2}/0002-Decompile-fixes.patch | 0 .../0011-Optimise-New-Liquid-Level.patch | 0 .../1.18.2}/0023-Limited-Get-Entities.patch | 0 ...8-Optimise-LivingEntity-pushEntities.patch | 0 ...0086-Dont-kick-for-out-of-order-chat.patch | 0 101 files changed, 1971 insertions(+), 2021 deletions(-) rename patches/server/{0003-Sakura-Utils.patch => 0002-Sakura-Utils.patch} (100%) create mode 100644 patches/server/0003-Sakura-Configuration-Files.patch rename patches/server/{0005-Local-Config-and-Value-Storage-API.patch => 0004-Local-Config-and-Value-Storage-API.patch} (86%) delete mode 100644 patches/server/0004-Sakura-Configuration-Files.patch rename patches/server/{0006-Visibility-API-and-Command.patch => 0005-Visibility-API-and-Command.patch} (83%) rename patches/server/{0007-Reduce-deltaMovement-Allocations.patch => 0006-Reduce-deltaMovement-Allocations.patch} (86%) rename patches/server/{0008-Optional-Force-Position-Updates.patch => 0007-Optional-Force-Position-Updates.patch} (80%) rename patches/server/{0009-Load-Chunks-on-Movement.patch => 0008-Load-Chunks-on-Movement.patch} (81%) rename patches/server/{0010-TPS-Graph-Command.patch => 0009-TPS-Graph-Command.patch} (90%) rename patches/server/{0012-Slice-Packet-obfuscation-and-reduction.patch => 0010-Slice-Packet-obfuscation-and-reduction.patch} (66%) rename patches/server/{0013-Use-Optimised-TrackedEntityMap.patch => 0011-Use-Optimised-TrackedEntityMap.patch} (77%) rename patches/server/{0014-Copy-EntityList-methods-to-BasicEntityList.patch => 0012-Copy-EntityList-methods-to-BasicEntityList.patch} (93%) rename patches/server/{0015-Add-utility-methods-to-EntitySlices.patch => 0013-Add-utility-methods-to-EntitySlices.patch} (86%) rename patches/server/{0016-Optimise-paper-explosions.patch => 0014-Optimise-paper-explosions.patch} (89%) rename patches/server/{0017-Store-Entity-Data-State.patch => 0015-Store-Entity-Data-State.patch} (86%) rename patches/server/{0018-Merge-Cannon-Entities.patch => 0016-Merge-Cannon-Entities.patch} (84%) rename patches/server/{0019-Replace-explosion-density-cache.patch => 0017-Replace-explosion-density-cache.patch} (86%) rename patches/server/{0020-Optimise-explosions-in-protected-regions.patch => 0018-Optimise-explosions-in-protected-regions.patch} (79%) rename patches/server/{0021-Specialised-Explosions.patch => 0019-Specialised-Explosions.patch} (93%) rename patches/server/{0022-Optimise-Fast-Movement.patch => 0020-Optimise-Fast-Movement.patch} (91%) rename patches/server/{0024-isPushedByFluid-API.patch => 0021-isPushedByFluid-API.patch} (75%) rename patches/server/{0025-Cannon-Mechanics.patch => 0022-Cannon-Mechanics.patch} (68%) rename patches/server/{0026-Cache-MovingBlockEntity-collision-shape.patch => 0023-Cache-MovingBlockEntity-collision-shape.patch} (89%) rename patches/server/{0027-Optimise-TNT-fluid-state-and-pushing.patch => 0024-Optimise-TNT-fluid-state-and-pushing.patch} (76%) rename patches/server/{0029-Despawn-falling-blocks-inside-moving-pistons.patch => 0025-Despawn-falling-blocks-inside-moving-pistons.patch} (78%) rename patches/server/{0030-Configure-Entity-Knockback.patch => 0026-Configure-Entity-Knockback.patch} (75%) rename patches/server/{0031-Explosion-Durable-Blocks.patch => 0027-Explosion-Durable-Blocks.patch} (86%) rename patches/server/{0032-Destroy-Waterlogged-Blocks.patch => 0028-Destroy-Waterlogged-Blocks.patch} (74%) rename patches/server/{0033-Falling-Block-Stacking-Restrictions.patch => 0029-Falling-Block-Stacking-Restrictions.patch} (84%) rename patches/server/{0034-Added-list-of-ItemEntity-s-that-ignore-explosions.patch => 0030-Added-list-of-ItemEntity-s-that-ignore-explosions.patch} (67%) rename patches/server/{0035-Add-option-to-disable-entity-ai.patch => 0031-Add-option-to-disable-entity-ai.patch} (71%) rename patches/server/{0036-Consistent-Explosion-Radius.patch => 0032-Consistent-Explosion-Radius.patch} (80%) rename patches/server/{0037-Remove-spigot-max-tnt-per-tick.patch => 0033-Remove-spigot-max-tnt-per-tick.patch} (85%) rename patches/server/{0038-Option-to-configure-entity-water-sensitivity.patch => 0034-Option-to-configure-entity-water-sensitivity.patch} (85%) rename patches/server/{0039-Configure-cannon-physics-by-version.patch => 0035-Configure-cannon-physics-by-version.patch} (87%) rename patches/server/{0040-Allow-water-in-the-nether.patch => 0036-Allow-water-in-the-nether.patch} (66%) rename patches/server/{0041-Configure-concrete-solidifying-in-water.patch => 0037-Configure-concrete-solidifying-in-water.patch} (76%) rename patches/server/{0042-Option-for-fast-nether-dimension-lava.patch => 0038-Option-for-fast-nether-dimension-lava.patch} (80%) rename patches/server/{0043-Allow-explosions-to-destroy-lava.patch => 0039-Allow-explosions-to-destroy-lava.patch} (75%) rename patches/server/{0044-Disable-bubble-columns-affecting-cannon-entities.patch => 0040-Disable-bubble-columns-affecting-cannon-entities.patch} (78%) rename patches/server/{0045-Treat-all-collidable-blocks-as-full-while-moving-fas.patch => 0041-Treat-all-collidable-blocks-as-full-while-moving-fas.patch} (87%) rename patches/server/{0046-Add-redstone-implementation-API.patch => 0042-Add-redstone-implementation-API.patch} (53%) rename patches/server/{0047-Reduce-entity-tracker-player-updates.patch => 0043-Reduce-entity-tracker-player-updates.patch} (90%) rename patches/server/{0048-Add-option-for-legacy-lava-block-formation.patch => 0044-Add-option-for-legacy-lava-block-formation.patch} (78%) create mode 100644 patches/server/0045-Configure-mob-spawner-defaults.patch rename patches/server/{0050-Allow-disabling-random-dispenser-item-selection.patch => 0046-Allow-disabling-random-dispenser-item-selection.patch} (70%) rename patches/server/{0051-Add-instant-mob-death-animation.patch => 0047-Add-instant-mob-death-animation.patch} (75%) rename patches/server/{0052-Configure-fluids-breaking-redstone.patch => 0048-Configure-fluids-breaking-redstone.patch} (76%) delete mode 100644 patches/server/0049-Configure-mob-spawner-defaults.patch rename patches/server/{0053-Option-to-disable-explosions-hurting-players.patch => 0049-Option-to-disable-explosions-hurting-players.patch} (80%) rename patches/server/{0054-Iron-golems-take-fall-damage.patch => 0050-Iron-golems-take-fall-damage.patch} (83%) rename patches/server/{0055-Add-explosions-dropping-items-config.patch => 0051-Add-explosions-dropping-items-config.patch} (71%) rename patches/server/{0056-Optimise-check-inside-blocks-and-fluids.patch => 0052-Optimise-check-inside-blocks-and-fluids.patch} (90%) rename patches/server/{0057-Avoid-searching-for-lava-if-throttled-water-flow-spe.patch => 0053-Avoid-searching-for-lava-if-throttled-water-flow-spe.patch} (60%) create mode 100644 patches/server/0054-Calculate-biome-noise-once-per-chunk-section.patch rename patches/server/{0059-Fix-doEntityDrops-gamerule-preventing-falling-blocks.patch => 0055-Fix-doEntityDrops-gamerule-preventing-falling-blocks.patch} (91%) rename patches/server/{0060-Add-entity-travel-distance-limits.patch => 0056-Add-entity-travel-distance-limits.patch} (73%) rename patches/server/{0061-Configure-potion-speed-and-breaking-inside-entities.patch => 0057-Configure-potion-speed-and-breaking-inside-entities.patch} (74%) rename patches/server/{0062-Add-outline-colliison-to-enderpearls.patch => 0058-Add-outline-colliison-to-enderpearls.patch} (87%) delete mode 100644 patches/server/0058-Calculate-biome-noise-once-per-chunk-section.patch rename patches/server/{0063-Disable-player-poses-shrinking-collision-box.patch => 0059-Disable-player-poses-shrinking-collision-box.patch} (79%) create mode 100644 patches/server/0060-Mob-spawner-behaviour.patch rename patches/server/{0065-Fix-block-placement-causing-physics-when-cancelled.patch => 0061-Fix-block-placement-causing-physics-when-cancelled.patch} (68%) create mode 100644 patches/server/0062-Use-random-chance-for-crop-growth-instead-of-age.patch rename patches/server/{0067-Legacy-player-combat-mechanics.patch => 0063-Legacy-player-combat-mechanics.patch} (86%) rename patches/server/{0068-Allow-disabling-sweep-attacks.patch => 0064-Allow-disabling-sweep-attacks.patch} (74%) delete mode 100644 patches/server/0064-Mob-spawner-behaviour.patch rename patches/server/{0069-Change-shields-to-reduce-damage.patch => 0065-Change-shields-to-reduce-damage.patch} (78%) rename patches/server/{0070-Old-enchanted-golden-apples.patch => 0066-Old-enchanted-golden-apples.patch} (95%) delete mode 100644 patches/server/0066-Use-random-chance-for-crop-growth-instead-of-age.patch rename patches/server/{0071-Configure-fast-health-regen.patch => 0067-Configure-fast-health-regen.patch} (79%) rename patches/server/{0072-Add-option-for-fishing-hooks-pulling-entities.patch => 0068-Add-option-for-fishing-hooks-pulling-entities.patch} (71%) rename patches/server/{0073-Old-combat-sounds-and-particle-effects.patch => 0069-Old-combat-sounds-and-particle-effects.patch} (64%) rename patches/server/{0074-Protect-scaffolding-from-creepers.patch => 0070-Protect-scaffolding-from-creepers.patch} (72%) rename patches/server/{0075-Entity-tracking-range-modifier.patch => 0071-Entity-tracking-range-modifier.patch} (84%) rename patches/server/{0076-Set-entity-impulse-on-explosion.patch => 0072-Set-entity-impulse-on-explosion.patch} (92%) rename patches/server/{0077-Configurable-left-shooting-and-adjusting-limits.patch => 0073-Configurable-left-shooting-and-adjusting-limits.patch} (84%) rename patches/server/{0078-Allow-projectiles-to-load-chunks-for-collisions.patch => 0074-Allow-projectiles-to-load-chunks-for-collisions.patch} (91%) rename patches/server/{0079-Add-max-armour-durability-damage.patch => 0075-Add-max-armour-durability-damage.patch} (80%) rename patches/server/{0080-Airplane-Strip-raytracing-for-EntityLiving-hasLineOf.patch => 0076-Airplane-Strip-raytracing-for-EntityLiving-hasLineOf.patch} (88%) rename patches/server/{0081-Optimise-explosion-raytracing.patch => 0077-Optimise-explosion-raytracing.patch} (92%) rename patches/server/{0082-PAPER-Check-for-block-type-in-SculkSensorBlock-canAc.patch => 0078-PAPER-Check-for-block-type-in-SculkSensorBlock-canAc.patch} (86%) rename patches/server/{0083-PAPER-Improve-standard-messenger-logging.patch => 0079-PAPER-Improve-standard-messenger-logging.patch} (88%) rename patches/server/{0084-PAPER-Break-redstone-on-top-of-trap-doors-early.patch => 0080-PAPER-Break-redstone-on-top-of-trap-doors-early.patch} (94%) rename patches/server/{0085-PAPER-Make-sure-the-player-didn-t-disconnect-when-pr.patch => 0081-PAPER-Make-sure-the-player-didn-t-disconnect-when-pr.patch} (60%) rename patches/server/{0087-Improve-paper-biome-cache-locking.patch => 0082-Improve-paper-biome-cache-locking.patch} (83%) rename patches/server/{0088-Add-lava-flow-speed-api.patch => 0083-Add-lava-flow-speed-api.patch} (84%) create mode 100644 patches/server/0084-temp.patch rename patches/{server => unap-server/removed/1.18.2}/0002-Decompile-fixes.patch (100%) rename patches/{server => unap-server/removed/1.18.2}/0011-Optimise-New-Liquid-Level.patch (100%) rename patches/{server => unap-server/removed/1.18.2}/0023-Limited-Get-Entities.patch (100%) rename patches/{server => unap-server/removed/1.18.2}/0028-Optimise-LivingEntity-pushEntities.patch (100%) rename patches/{server => unap-server/removed/1.18.2}/0086-Dont-kick-for-out-of-order-chat.patch (100%) diff --git a/build.gradle.kts b/build.gradle.kts index b1eebc8..60a52a6 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.0" apply false - id("io.papermc.paperweight.patcher") version "1.5.2" + id("com.github.johnrengelman.shadow") version "7.1.2" apply false + id("io.papermc.paperweight.patcher") version "1.3.7" } repositories { @@ -14,8 +14,8 @@ repositories { } dependencies { - remapper("net.fabricmc:tiny-remapper:0.8.6:fat") - decompiler("net.minecraftforge:forgeflower:2.0.627.2") + remapper("net.fabricmc:tiny-remapper:0.8.1:fat") + decompiler("net.minecraftforge:forgeflower:1.5.498.22") paperclip("io.papermc:paperclip:3.0.2") } diff --git a/gradle.properties b/gradle.properties index f72ccbf..1d5d864 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ group=me.samsuik.sakura -version=1.19.3-R0.1-SNAPSHOT +version=1.18.2-R0.1-SNAPSHOT -mcVersion=1.19.3 -paperRef=155aa36d89b260ef5841615899299756b5983c0a +mcVersion=1.18.2 +paperRef=fc9ee65a32622d03a91db39364b6f106cf88335b org.gradle.jvmargs=-Xmx2G diff --git a/patches/api/0001-Customise-Version-Command.patch b/patches/api/0001-Customise-Version-Command.patch index bab307e..61a813f 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 ac9b690fcccb60b587e5345f12f1383afd0a73a1..80d836d561f9de3f4dba660a065edfe1092582d8 100644 +index a87399fa4838d4b2c1ff9cc35d433ae76cc149bf..8cfb453c44a4daf308ee562a7e5f7a577bb2dc6c 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -125,6 +125,20 @@ public final class Bukkit { +@@ -124,6 +124,20 @@ public final class Bukkit { // Paper end } @@ -30,10 +30,10 @@ index ac9b690fcccb60b587e5345f12f1383afd0a73a1..80d836d561f9de3f4dba660a065edfe1 * 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 e40f017f87d6b6b4770501b106c76dc69ec69abb..2b0e110c1531bae49ee634f2c5904c0ce68e89d7 100644 +index 57a21495843f3a144cd73473cdc8781d6129b7ca..cfbbe38a8e204aab921a3950ff878dde488128eb 100644 --- a/src/main/java/org/bukkit/command/defaults/VersionCommand.java +++ b/src/main/java/org/bukkit/command/defaults/VersionCommand.java -@@ -25,6 +25,11 @@ import org.bukkit.plugin.Plugin; +@@ -26,6 +26,11 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.util.StringUtil; import org.jetbrains.annotations.NotNull; @@ -45,7 +45,7 @@ index e40f017f87d6b6b4770501b106c76dc69ec69abb..2b0e110c1531bae49ee634f2c5904c0c public class VersionCommand extends BukkitCommand { private VersionFetcher versionFetcher; -@@ -36,6 +41,15 @@ public class VersionCommand extends BukkitCommand { +@@ -37,6 +42,15 @@ public class VersionCommand extends BukkitCommand { return versionFetcher; } @@ -61,7 +61,7 @@ index e40f017f87d6b6b4770501b106c76dc69ec69abb..2b0e110c1531bae49ee634f2c5904c0c public VersionCommand(@NotNull String name) { super(name); -@@ -47,12 +61,18 @@ public class VersionCommand extends BukkitCommand { +@@ -48,12 +62,18 @@ public class VersionCommand extends BukkitCommand { @Override public boolean execute(@NotNull CommandSender sender, @NotNull String currentAlias, @NotNull String[] args) { diff --git a/patches/api/0003-Visibility-API.patch b/patches/api/0003-Visibility-API.patch index 4e32a5e..f777edd 100644 --- a/patches/api/0003-Visibility-API.patch +++ b/patches/api/0003-Visibility-API.patch @@ -209,10 +209,10 @@ index 0000000000000000000000000000000000000000..3df11f07ce533b8b911ec423be850374 + +} diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index fd890d0a3a2c92ad821ade7711191bdb0e3e3624..50cda6408fa196e2c3bfdbafe5933d52cbebd915 100644 +index 6cd0b10d1dc4506cfb1e4db5e1260cb705566cec..0d0bc62b4657fe46a37cb0ef30c4b7f67a1b2221 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java -@@ -41,6 +41,15 @@ import org.jetbrains.annotations.Nullable; +@@ -42,6 +42,15 @@ import org.jetbrains.annotations.Nullable; */ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, com.destroystokyo.paper.network.NetworkClient { // Paper diff --git a/patches/api/0005-isPushedByFluid-API.patch b/patches/api/0005-isPushedByFluid-API.patch index f3a37fb..ab4c81a 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 11cf1bb585e2754bda443b776e9fcaf0a6cc289e..730af8a127ab55a22a7fd576156311dfde1f010c 100644 +index 8bc6876c82935988436597161fa0ec94c032174b..43024ea9b578c7bf68d237cbca3c9603492fc0e0 100644 --- a/src/main/java/org/bukkit/entity/Entity.java +++ b/src/main/java/org/bukkit/entity/Entity.java -@@ -107,6 +107,22 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent +@@ -106,6 +106,22 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent */ public boolean isInWater(); diff --git a/patches/api/0007-Local-Value-Storage-API.patch b/patches/api/0007-Local-Value-Storage-API.patch index 288a312..b1af03e 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 aa04d7df70d99402c91e920fd693d7d4fb655786..44d40c0fcb420199ec6e2c8a4cca3b2887f440ed 100644 +index 7ad1cabe05277c1f3238da6e121c35d8a9f0d952..519c61c5c83ca4f9434be77b2c07d95c6bf7a198 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java -@@ -128,6 +128,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient +@@ -125,6 +125,10 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient return new Location(this, x, y, z); } // Paper end diff --git a/patches/api/0013-Entity-tracking-range-modifier.patch b/patches/api/0013-Entity-tracking-range-modifier.patch index bdb7da2..bbc34ad 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 50cda6408fa196e2c3bfdbafe5933d52cbebd915..9075337807b54047b499f9979b03872aa9fa46e5 100644 +index 0d0bc62b4657fe46a37cb0ef30c4b7f67a1b2221..24910cbb4f674fab5013f3ecaf6e24e43a366431 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java -@@ -50,6 +50,12 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM +@@ -51,6 +51,12 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM me.samsuik.sakura.player.visibility.Visibility getVisibility(); // Sakura end diff --git a/patches/server/0001-Branding-changes.patch b/patches/server/0001-Branding-changes.patch index eb6df9a..ae354dd 100644 --- a/patches/server/0001-Branding-changes.patch +++ b/patches/server/0001-Branding-changes.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Branding changes From ForkPaper. diff --git a/build.gradle.kts b/build.gradle.kts -index 1919a8e9cb7c995b2a9c876ff4980bdc98977133..8e9b3ebe3b074c4991cd543446fa2d9aafa83251 100644 +index 0282e3b75470e1a68ea1fc228082483514ba432e..d1b4eb9088d5780f56d8df2d4542e6d408c61e6c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts -@@ -7,8 +7,12 @@ plugins { +@@ -9,8 +9,12 @@ plugins { } dependencies { @@ -24,7 +24,7 @@ index 1919a8e9cb7c995b2a9c876ff4980bdc98977133..8e9b3ebe3b074c4991cd543446fa2d9a // Paper start implementation("org.jline:jline-terminal-jansi:3.21.0") implementation("net.minecrell:terminalconsoleappender:1.3.0") -@@ -62,7 +66,7 @@ tasks.jar { +@@ -60,7 +64,7 @@ tasks.jar { attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", "Implementation-Title" to "CraftBukkit", @@ -34,10 +34,10 @@ index 1919a8e9cb7c995b2a9c876ff4980bdc98977133..8e9b3ebe3b074c4991cd543446fa2d9a "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 753a917d34a1e1c1521a8916bc8e44a6acd90a46..777b012f7b3b35b89177d94f2c1d8dd1ee4adf7d 100644 +index da15a224b8b974e78b9d8d5f514229b3b2a5a63e..9cbb478205af1b12da66d89872ac6d3ef2d43e05 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1654,7 +1654,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop +Date: Sun, 5 Sep 2021 18:01:34 +0100 +Subject: [PATCH] Sakura Configuration Files + + +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 +--- /dev/null ++++ b/src/main/java/me/samsuik/sakura/command/BaseSubCommand.java +@@ -0,0 +1,47 @@ ++package me.samsuik.sakura.command; ++ ++import org.bukkit.command.Command; ++import org.bukkit.command.CommandSender; ++import org.checkerframework.checker.nullness.qual.NonNull; ++import org.checkerframework.framework.qual.DefaultQualifier; ++import org.jetbrains.annotations.NotNull; ++ ++import java.util.ArrayList; ++import java.util.List; ++ ++@DefaultQualifier(NonNull.class) ++public abstract class BaseSubCommand extends Command { ++ ++ public BaseSubCommand(String name) { ++ super(name); ++ this.description = "Sakura Command " + name; ++ this.setPermission("bukkit.command." + name); ++ } ++ ++ public abstract void execute(CommandSender sender, String[] args); ++ ++ public void tabComplete(List list, String[] args) throws IllegalArgumentException {} ++ ++ @Override ++ @Deprecated ++ public final boolean execute(CommandSender sender, String label, String[] args) { ++ if (testPermission(sender)) { ++ execute(sender, args); ++ } ++ ++ return true; ++ } ++ ++ @Override ++ @NotNull ++ public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { ++ var completions = new ArrayList(0); ++ ++ if (testPermissionSilent(sender)) { ++ tabComplete(completions, args); ++ } ++ ++ return completions; ++ } ++ ++} +diff --git a/src/main/java/me/samsuik/sakura/command/SakuraCommand.java b/src/main/java/me/samsuik/sakura/command/SakuraCommand.java +new file mode 100644 +index 0000000000000000000000000000000000000000..2b145614bf189ae56622016436bfefd63f5271eb +--- /dev/null ++++ b/src/main/java/me/samsuik/sakura/command/SakuraCommand.java +@@ -0,0 +1,93 @@ ++package me.samsuik.sakura.command; ++ ++import net.kyori.adventure.text.Component; ++import net.kyori.adventure.text.format.NamedTextColor; ++import net.kyori.adventure.text.minimessage.MiniMessage; ++import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; ++import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; ++import net.minecraft.server.MinecraftServer; ++import org.bukkit.command.Command; ++import org.bukkit.command.CommandSender; ++import org.checkerframework.checker.nullness.qual.NonNull; ++import org.checkerframework.framework.qual.DefaultQualifier; ++import org.jetbrains.annotations.NotNull; ++ ++import javax.annotation.Nullable; ++import java.util.ArrayList; ++import java.util.Arrays; ++import java.util.Collections; ++import java.util.List; ++ ++@DefaultQualifier(NonNull.class) ++public final class SakuraCommand extends Command { ++ ++ private static final Component INFORMATION_MESSAGE = MiniMessage.miniMessage().deserialize(""" ++ . ++ | This is the main command for Sakura. ++ | All exclusive commands are listed below.""" ++ ); ++ ++ private static final String COMMAND_MSG = "| * /"; ++ ++ public SakuraCommand(String name) { ++ super(name); ++ ++ this.description = ""; ++ this.usageMessage = "/sakura"; ++ this.setPermission("bukkit.command.sakura"); ++ } ++ ++ @Override ++ public boolean execute(CommandSender sender, String commandLabel, String[] args) { ++ if (args.length > 0) { ++ var commands = new ArrayList<>(SakuraCommands.COMMANDS.values()); ++ ++ // This part is copied from the VersionCommand SubCommand in paper ++ @Nullable ++ var internalVersion = MinecraftServer.getServer().server.getCommandMap().getCommand("version"); ++ if (internalVersion != null) { ++ commands.add(internalVersion); ++ } ++ ++ for (var base : commands) { ++ if (base.getName().equalsIgnoreCase(args[0])) { ++ return base.execute(sender, commandLabel, Arrays.copyOfRange(args, 1, args.length)); ++ } ++ } ++ } ++ ++ sendHelpMessage(sender); ++ return false; ++ } ++ ++ private void sendHelpMessage(CommandSender sender) { ++ sender.sendMessage(INFORMATION_MESSAGE); ++ ++ var uniqueCommands = SakuraCommands.COMMANDS.values() ++ .stream() ++ .filter(command -> command != this); ++ ++ uniqueCommands.forEach((command) -> { ++ sender.sendMessage(MiniMessage.miniMessage().deserialize(COMMAND_MSG, ++ Placeholder.unparsed("command", command.getName())) ++ ); ++ }); ++ ++ sender.sendMessage(Component.text("'", NamedTextColor.DARK_PURPLE)); ++ } ++ ++ @NotNull ++ @Override ++ public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { ++ if (!testPermissionSilent(sender)) { ++ return Collections.emptyList(); ++ } ++ ++ return SakuraCommands.COMMANDS.values().stream() ++ .filter(command -> command != this) // ahem ++ .map(Command::getName) ++ .filter(name -> args.length <= 1 || name.startsWith(args[args.length - 1])) ++ .toList(); ++ } ++ ++} +diff --git a/src/main/java/me/samsuik/sakura/command/SakuraCommands.java b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java +new file mode 100644 +index 0000000000000000000000000000000000000000..cd44b3400a1ab9544aa4a9e50b1054ea436a3643 +--- /dev/null ++++ b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java +@@ -0,0 +1,22 @@ ++package me.samsuik.sakura.command; ++ ++import me.samsuik.sakura.command.subcommands.ConfigCommand; ++import net.minecraft.server.MinecraftServer; ++import org.bukkit.command.Command; ++ ++import java.util.HashMap; ++import java.util.Map; ++ ++public final class SakuraCommands { ++ static final Map COMMANDS = new HashMap<>(); ++ static { ++ COMMANDS.put("sakura", new SakuraCommand("sakura")); ++ COMMANDS.put("config", new ConfigCommand("config")); ++ } ++ ++ public static void registerCommands(final MinecraftServer server) { ++ COMMANDS.forEach((s, command) -> { ++ server.server.getCommandMap().register(s, "sakura", command); ++ }); ++ } ++} +diff --git a/src/main/java/me/samsuik/sakura/command/subcommands/ConfigCommand.java b/src/main/java/me/samsuik/sakura/command/subcommands/ConfigCommand.java +new file mode 100644 +index 0000000000000000000000000000000000000000..93c0f22cdf0c3b7ce4db55171ea397f5673231b1 +--- /dev/null ++++ b/src/main/java/me/samsuik/sakura/command/subcommands/ConfigCommand.java +@@ -0,0 +1,50 @@ ++package me.samsuik.sakura.command.subcommands; ++ ++import me.samsuik.sakura.command.BaseSubCommand; ++import net.minecraft.server.MinecraftServer; ++import net.minecraft.server.level.ServerLevel; ++import org.bukkit.command.Command; ++import org.bukkit.command.CommandSender; ++import org.bukkit.craftbukkit.CraftServer; ++import org.checkerframework.checker.nullness.qual.NonNull; ++import org.checkerframework.framework.qual.DefaultQualifier; ++import org.jetbrains.annotations.NotNull; ++ ++import java.io.File; ++import java.util.Collections; ++import java.util.List; ++ ++import static net.kyori.adventure.text.Component.text; ++import static net.kyori.adventure.text.format.NamedTextColor.GREEN; ++import static net.kyori.adventure.text.format.NamedTextColor.RED; ++ ++@DefaultQualifier(NonNull.class) ++public final class ConfigCommand extends BaseSubCommand { ++ ++ public ConfigCommand(String name) { ++ super(name); ++ this.description = "Command for reloading the sakura configuration file"; ++ } ++ ++ @Override ++ public void execute(CommandSender sender, String[] args) { ++ Command.broadcastCommandMessage(sender, text("Please note that this command is not supported and may cause issues.", RED)); ++ Command.broadcastCommandMessage(sender, text("If you encounter any issues please use the /stop command to restart your server.", RED)); ++ ++ MinecraftServer server = ((CraftServer) sender.getServer()).getServer(); ++ me.samsuik.sakura.configuration.SakuraGlobalConfig.get().setup((File) server.options.valueOf("sakura-settings")); ++ for (ServerLevel world : server.getAllLevels()) { ++ world.sakuraConfig.init(); ++ } ++ server.server.reloadCount++; ++ ++ Command.broadcastCommandMessage(sender, text("Sakura config reload complete.", GREEN)); ++ } ++ ++ @NotNull ++ @Override ++ public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { ++ return Collections.emptyList(); ++ } ++ ++} +diff --git a/src/main/java/me/samsuik/sakura/configuration/SakuraGlobalConfig.java b/src/main/java/me/samsuik/sakura/configuration/SakuraGlobalConfig.java +new file mode 100644 +index 0000000000000000000000000000000000000000..7000fa68886057fb742cf4f655a739b0ee3f62e1 +--- /dev/null ++++ b/src/main/java/me/samsuik/sakura/configuration/SakuraGlobalConfig.java +@@ -0,0 +1,92 @@ ++package me.samsuik.sakura.configuration; ++ ++import org.bukkit.configuration.file.YamlConfiguration; ++ ++import java.io.File; ++ ++public final class SakuraGlobalConfig { ++ private static final String HEADER = """ ++ This is the main configuration file for Sakura. ++ As you can see, there's a lot to configure. Some options may impact gameplay, so use ++ with caution, and make sure you know what each option does before configuring. ++ ++ This configuration file is not compatible with Sakura for modern versions of minecraft. ++ """; ++ ++ private static final SakuraGlobalConfig INSTANCE = new SakuraGlobalConfig(); ++ ++ public static SakuraGlobalConfig get() { ++ return INSTANCE; ++ } ++ ++ private YamlConfiguration config; ++ private int version; ++ ++ public void setup(File configFile) { ++ this.config = YamlConfigHelper.loadConfig(configFile, HEADER, config -> { ++ this.version = this.getInt("config-version", 0); ++ this.set("config-version", 0); ++ }); ++ } ++ ++ public YamlConfiguration getYamlConfig() { ++ return this.config; ++ } ++ ++ private void set(String path, Object val) { ++ this.config.set(path, val); ++ } ++ ++ private boolean getBoolean(String path, boolean def) { ++ this.config.addDefault(path, def); ++ return this.config.getBoolean(path, this.config.getBoolean(path)); ++ } ++ ++ private int getInt(String path, int def) { ++ this.config.addDefault(path, def); ++ return this.config.getInt(path, this.config.getInt(path)); ++ } ++ ++ private String getString(String path, String def) { ++ this.config.addDefault(path, def); ++ return this.config.getString(path, this.config.getString(path)); ++ } ++ ++ public String fpsMessage = "(S) "; ++ public String fpsMaterial = "pink_stained_glass_pane"; ++ private void Fps() { ++ this.fpsMessage = this.getString("fps.messsage", this.fpsMessage); ++ this.fpsMaterial = this.getString("fps.material", this.fpsMaterial); ++ } ++ ++ public boolean reducedSearchRays; ++ private void Explosion() { ++ this.reducedSearchRays = this.getBoolean("cannons.explosion.reduced-search-rays", this.reducedSearchRays); ++ } ++ ++ public String potatoMessage = "(S) This block has of "; ++ private void Players() { ++ this.potatoMessage = this.getString("players.potato-message", this.potatoMessage); ++ } ++ ++ public boolean calculateBiomeNoiseOncePerChunkSection = false; ++ private void Environment() { ++ this.calculateBiomeNoiseOncePerChunkSection = this.getBoolean("environment.calculate-biome-noise-once-per-chunk-section", this.calculateBiomeNoiseOncePerChunkSection); ++ } ++ ++ public int minSpawnDelay = 200; ++ public int maxSpawnDelay = 800; ++ public int spawnCount = 4; ++ public int maxNearbyEntities = 6; ++ public int requiredPlayerRange = 16; ++ public int spawnRange = 4; ++ private void MobSpawnerDefaults() { ++ // as global and world configs are combined I moved the defaults into its own section ++ this.minSpawnDelay = this.getInt("environment.mob-spawner.defaults.min-spawn-delay", this.minSpawnDelay); ++ this.maxSpawnDelay = this.getInt("environment.mob-spawner.defaults.max-spawn-delay", this.maxSpawnDelay); ++ this.spawnCount = this.getInt("environment.mob-spawner.defaults.spawn-count", this.spawnCount); ++ this.maxNearbyEntities = this.getInt("environment.mob-spawner.defaults.max-nearby-entities", this.maxNearbyEntities); ++ this.requiredPlayerRange = this.getInt("environment.mob-spawner.defaults.required-player-range", this.requiredPlayerRange); ++ this.spawnRange = this.getInt("environment.mob-spawner.defaults.spawn-range", this.spawnRange); ++ } ++} +diff --git a/src/main/java/me/samsuik/sakura/configuration/SakuraWorldConfig.java b/src/main/java/me/samsuik/sakura/configuration/SakuraWorldConfig.java +new file mode 100644 +index 0000000000000000000000000000000000000000..34c4d0db007753f37cc4ca96c21175ce0f0d56e1 +--- /dev/null ++++ b/src/main/java/me/samsuik/sakura/configuration/SakuraWorldConfig.java +@@ -0,0 +1,325 @@ ++package me.samsuik.sakura.configuration; ++ ++import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap; ++import me.samsuik.sakura.configuration.serializer.*; ++import me.samsuik.sakura.entity.TntSpread; ++import me.samsuik.sakura.entity.merge.MergeLevel; ++import me.samsuik.sakura.explosion.durable.DurableMaterial; ++import me.samsuik.sakura.physics.PhysicsVersion; ++import net.minecraft.Util; ++import net.minecraft.world.entity.EntityType; ++import net.minecraft.world.entity.item.FallingBlockEntity; ++import net.minecraft.world.item.Item; ++import net.minecraft.world.level.block.Block; ++import net.minecraft.world.level.block.Blocks; ++import org.bukkit.configuration.ConfigurationSection; ++import org.bukkit.configuration.MemoryConfiguration; ++import org.bukkit.configuration.file.YamlConfiguration; ++ ++import java.util.*; ++ ++public final class SakuraWorldConfig { ++ private final String worldName; ++ private YamlConfiguration config; ++ ++ public SakuraWorldConfig(String worldName) { ++ this.worldName = worldName; ++ this.init(); ++ } ++ ++ public void init() { ++ this.config = SakuraGlobalConfig.get().getYamlConfig(); // grab updated reference ++ } ++ ++ private String worldPath(String path) { ++ return "world-settings." + this.worldName + "." + path; ++ } ++ ++ private void set(String path, Object val) { ++ this.config.set(path, val); ++ if (this.config.get(this.worldPath(path)) != null) { ++ this.config.set(this.worldPath(path), val); ++ } ++ } ++ ++ private void remove(String path) { ++ this.config.addDefault(path, null); ++ this.set(path, null); ++ } ++ ++ private boolean getBoolean(String path, boolean def) { ++ this.config.addDefault(path, def); ++ return this.config.getBoolean(this.worldPath(path), this.config.getBoolean(path, def)); ++ } ++ ++ private double getDouble(String path, double def) { ++ this.config.addDefault(path, def); ++ return this.config.getDouble(this.worldPath(path), this.config.getDouble(path)); ++ } ++ ++ private int getInt(String path, int def) { ++ this.config.addDefault(path, def); ++ return this.config.getInt(this.worldPath(path), this.config.getInt(path, def)); ++ } ++ ++ private List getList(String path, List def) { ++ this.config.addDefault(path, def); ++ return (List) this.config.getList(this.worldPath(path), this.config.getList(path)); ++ } ++ ++ private String getString(String path, String def) { ++ this.config.addDefault(path, def); ++ return this.config.getString(this.worldPath(path), this.config.getString(path)); ++ } ++ ++ private > T getEnum(String path, T def, Class enumClass) { ++ String name = this.getString(path, def.name()); ++ return Enum.valueOf(enumClass, name); ++ } ++ ++ private OptionalDouble getDoubleWithContext(String path, String context) { ++ this.config.addDefault(path, context); ++ double present = this.config.getDouble(path, this.config.getDouble(this.worldPath(path), Double.MIN_VALUE)); ++ return present != Double.MIN_VALUE ? OptionalDouble.of(present) : OptionalDouble.empty(); ++ } ++ ++ private OptionalInt getIntWithContext(String path, String context) { ++ this.config.addDefault(path, context); ++ int present = this.config.getInt(path, this.config.getInt(this.worldPath(path), Integer.MIN_VALUE)); ++ return present != Integer.MIN_VALUE ? OptionalInt.of(present) : OptionalInt.empty(); ++ } ++ ++ private void loadSerializedMap(String path, Map def, MapSerializer serializer) { ++ this.config.addDefault(path, this.getSerializedMapDefaults(def, serializer)); ++ ConfigurationSection section = this.config.getConfigurationSection(path); ++ def.clear(); ++ for (String serializedKey : section.getKeys(false)) { ++ K key = serializer.deserializeKey(serializedKey); ++ V value = serializer.deserializeValue((C) this.config.get(serializedKey)); ++ def.put(key, value); ++ } ++ } ++ ++ private ConfigurationSection getSerializedMapDefaults(Map def, MapSerializer serializer) { ++ ConfigurationSection section = new MemoryConfiguration(); ++ def.forEach((k, v) -> { ++ String key = serializer.serializeKey(k); ++ Object value = serializer.serializeValue(v); ++ section.set(key, value); ++ }); ++ return section; ++ } ++ ++ private void loadSerializedList(String path, List def, ListSerializer serializer) { ++ List defaults = def.stream() ++ .map(serializer::serialize) ++ .toList(); ++ def.clear(); ++ for (C object : this.getList(path, defaults)) { ++ def.add(serializer.deserialize(object)); ++ } ++ } ++ ++ public MergeLevel mergeLevel = MergeLevel.STRICT; ++ public boolean tntAndSandAffectedByBubbleColumns = true; ++ public boolean loadChunks = false; ++ public boolean collideWhenMoving; ++ public double collideMovingFasterThan = 64.0; ++ private void Cannons() { ++ this.mergeLevel = this.getEnum("cannons.merge-level", this.mergeLevel, MergeLevel.class); ++ this.tntAndSandAffectedByBubbleColumns = this.getBoolean("cannons.tnt-and-sand-affected-by-bubble-columns", this.tntAndSandAffectedByBubbleColumns); ++ this.loadChunks = this.getBoolean("cannons.load-chunks", this.loadChunks); ++ ++ this.collideWhenMoving = this.getBoolean("cannons.treat-collidable-blocks-as-full.while-moving", this.collideWhenMoving); ++ this.collideMovingFasterThan = this.getDouble("cannons.treat-collidable-blocks-as-full.moving-faster-than", this.collideMovingFasterThan); ++ } ++ ++ public OptionalInt leftShootingThreshold = OptionalInt.empty(); ++ public OptionalInt maxAdjustDistance = OptionalInt.empty(); ++ private void Restrictions() { ++ this.leftShootingThreshold = this.getIntWithContext("cannons.restrictions.left-shooting-threshold", "disabled"); ++ this.maxAdjustDistance = this.getIntWithContext("cannons.restrictions.max-adjust-distance", "disabled"); ++ } ++ ++ public boolean forcePositionUpdates; ++ private void Tnt() { ++ this.forcePositionUpdates = this.getBoolean("cannons.tnt.force-position-updates", this.forcePositionUpdates); ++ } ++ ++ public boolean despawnInsideMovingPistons = true; ++ public boolean concreteSolidifyInWater = true; ++ public boolean preventStackingAgainstBorder = false; ++ public boolean preventStackingAtWorldHeight = false; ++ private void Sand() { ++ this.despawnInsideMovingPistons = this.getBoolean("cannons.sand.despawn-inside-moving-pistons", this.despawnInsideMovingPistons); ++ this.concreteSolidifyInWater = this.getBoolean("cannons.sand.concrete-solidify-in-water", this.concreteSolidifyInWater); ++ this.preventStackingAgainstBorder = this.getBoolean("cannons.sand.prevent-stacking.against-border", this.preventStackingAgainstBorder); ++ this.preventStackingAtWorldHeight = this.getBoolean("cannons.sand.prevent-stacking.world-height", this.preventStackingAtWorldHeight); ++ } ++ ++ public boolean isFallingBlockInBounds(FallingBlockEntity entity) { ++ if (this.preventStackingAtWorldHeight && entity.blockPosition().getY() >= entity.level.getMaxBuildHeight()) { ++ return false; ++ } ++ if (this.preventStackingAgainstBorder && io.papermc.paper.util.CollisionUtil.isCollidingWithBorderEdge(entity.level.getWorldBorder(), entity.getBoundingBox().inflate(0.01))) { ++ return false; ++ } ++ return true; ++ } ++ ++ public boolean optimiseProtectedRegions = true; ++ public boolean avoidRedundantBlockSearches = false; ++ public Map durableMaterials = Util.make(new Reference2ObjectOpenHashMap<>(), map -> { ++ map.put(Blocks.OBSIDIAN, new DurableMaterial(4, Blocks.COBBLESTONE.getExplosionResistance())); ++ map.put(Blocks.ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance())); ++ map.put(Blocks.CHIPPED_ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance())); ++ map.put(Blocks.DAMAGED_ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance())); ++ }); ++ public boolean protectScaffoldingFromCreepers = false; ++ public boolean allowNonTntBreakingDurableBlocks = false; ++ public boolean destroyWaterloggedBlocks = false; ++ public boolean explodeLava = false; ++ public boolean consistentRadius = false; ++ public boolean explosionsHurtPlayers = true; ++ public boolean explosionsDropItems = true; ++ private void Explosion() { ++ this.optimiseProtectedRegions = this.getBoolean("cannons.explosion.optimise-protected-regions", this.optimiseProtectedRegions); ++ this.avoidRedundantBlockSearches = this.getBoolean("cannons.explosion.avoid-redundant-block-searches", this.avoidRedundantBlockSearches); ++ this.loadSerializedMap("cannons.explosion.durable-materials", this.durableMaterials, DurableMaterialSerializer.get()); ++ this.protectScaffoldingFromCreepers = this.getBoolean("cannons.explosion.protect-scaffolding-from-creepers", this.protectScaffoldingFromCreepers); ++ this.allowNonTntBreakingDurableBlocks = this.getBoolean("cannons.explosion.allow-non-tnt-breaking-durable-blocks", this.allowNonTntBreakingDurableBlocks); ++ this.destroyWaterloggedBlocks = this.getBoolean("cannons.explosion.destroy-waterlogged-blocks", this.destroyWaterloggedBlocks); ++ this.explodeLava = this.getBoolean("cannons.explosion.explode-lava", this.explodeLava); ++ this.consistentRadius = this.getBoolean("cannons.explosion.consistent-radius", this.consistentRadius); ++ this.explosionsHurtPlayers = this.getBoolean("cannons.explosion.explosions-hurt-players", this.explosionsHurtPlayers); ++ this.explosionsDropItems = this.getBoolean("cannons.explosion.explosions-drop-items", this.explosionsDropItems); ++ } ++ ++ public TntSpread tntSpread = TntSpread.ALL; ++ public boolean tntFlowsInWater = true; ++ public boolean fallingBlockParity = false; ++ public PhysicsVersion physicsVersion = PhysicsVersion.LATEST; ++ private void Mechanics() { ++ this.tntSpread = this.getEnum("cannons.mechanics.tnt-spread", this.tntSpread, TntSpread.class); ++ this.tntFlowsInWater = this.getBoolean("cannons.mechanics.tnt-flows-in-water", this.tntFlowsInWater); ++ this.fallingBlockParity = this.getBoolean("cannons.mechanics.falling-block-parity", this.fallingBlockParity); ++ this.physicsVersion = this.getEnum("cannons.mechanics.physics-version", this.physicsVersion, PhysicsVersion.class); ++ } ++ ++ public boolean dispenserRandomItemSelection = true; ++ public boolean fluidsBreakRedstone = true; ++ private void Technical() { ++ this.dispenserRandomItemSelection = this.getBoolean("technical.dispenser-random-item-selection", this.dispenserRandomItemSelection); ++ this.fluidsBreakRedstone = this.getBoolean("technical.redstone.fluids-break-redstone", this.fluidsBreakRedstone); ++ } ++ ++ public boolean legacyCombatMechanics = false; ++ public boolean allowSweepAttacks = true; ++ public boolean shieldDamageReduction = false; ++ public boolean oldEnchantedGoldenApple = false; ++ public boolean oldSoundsAndParticleEffects = false; ++ public boolean fastHealthRegen = true; ++ public OptionalInt maxArmourDamage = OptionalInt.empty(); ++ private void Combat() { ++ this.legacyCombatMechanics = this.getBoolean("players.combat.legacy-combat-mechanics", this.legacyCombatMechanics); ++ this.allowSweepAttacks = this.getBoolean("players.combat.allow-sweep-attacks", this.allowSweepAttacks); ++ this.shieldDamageReduction = this.getBoolean("players.combat.shield-damage-reduction", this.shieldDamageReduction); ++ this.oldEnchantedGoldenApple = this.getBoolean("players.combat.old-enchanted-golden-apple", this.oldEnchantedGoldenApple); ++ this.oldSoundsAndParticleEffects = this.getBoolean("players.combat.old-sounds-and-particle-effects", this.oldSoundsAndParticleEffects); ++ this.fastHealthRegen = this.getBoolean("players.combat.fast-health-regen", this.fastHealthRegen); ++ this.maxArmourDamage = this.getIntWithContext("players.combat.max-armour-damage", "default"); ++ } ++ ++ public OptionalDouble knockbackVertical = OptionalDouble.empty(); ++ public double knockbackVerticalLimit = 0.4; ++ public boolean verticalKnockbackRequireGround = true; ++ public double baseKnockback = 0.4; ++ public double sweepingEdgeKnockback = 0.4; ++ public boolean sprintingRequireFullAttack = true; ++ public double sprintingExtraKnockback = 0.5; ++ public OptionalInt sprintingKnockbackDelay = OptionalInt.empty(); ++ public boolean fishingHooksApplyKnockback; ++ public double knockbackResistanceModifier = 1.0; ++ public double shieldHitKnockback = 0.5; ++ private void Knockback() { ++ this.knockbackVertical = this.getDoubleWithContext("players.knockback.knockback-vertical", "default"); ++ this.knockbackVerticalLimit = this.getDouble("players.knockback.knockback-vertical-limit", this.knockbackVerticalLimit); ++ this.verticalKnockbackRequireGround = this.getBoolean("players.knockback.vertical-knockback-require-ground", this.verticalKnockbackRequireGround); ++ this.baseKnockback = this.getDouble("players.knockback.base-knockback", this.baseKnockback); ++ this.sweepingEdgeKnockback = this.getDouble("players.knockback.sweeping-edge-knockback", this.sweepingEdgeKnockback); ++ ++ this.sprintingRequireFullAttack = this.getBoolean("players.knockback.sprinting.require-full-attack", this.sprintingRequireFullAttack); ++ this.sprintingExtraKnockback = this.getDouble("players.knockback.sprinting.extra-knockback", this.sprintingExtraKnockback); ++ this.sprintingKnockbackDelay = this.getIntWithContext("players.knockback.sprinting.knockback-delay", "default"); ++ ++ this.fishingHooksApplyKnockback = this.getBoolean("players.knockback.projectiles.fishing-hooks-apply-knockback", this.fishingHooksApplyKnockback); ++ this.knockbackResistanceModifier = this.getDouble("players.knockback.knockback-resistance-modifier", this.knockbackResistanceModifier); ++ this.shieldHitKnockback = this.getDouble("players.knockback.shield-hit-knockback", this.shieldHitKnockback); ++ } ++ ++ public boolean posesShrinkCollisionBox = true; ++ public boolean fishingHooksPullEntities = true; ++ private void Players() { ++ this.posesShrinkCollisionBox = this.getBoolean("players.poses-shrink-collision-box", this.posesShrinkCollisionBox); ++ this.fishingHooksPullEntities = this.getBoolean("players.fishing-hooks-pull-entities", this.fishingHooksPullEntities); ++ } ++ ++ public boolean disableMobAi = false; ++ public boolean waterSensitivity = true; ++ public boolean instantDeathAnimation = false; ++ public boolean ironGolemsTakeFalldamage = false; ++ public Map, Integer> chunkTravelLimit = Util.make(new Reference2ObjectOpenHashMap<>(), map -> { ++ map.put(EntityType.ENDER_PEARL, 8); ++ }); ++ public boolean projectilesLoadChunksForCollisions = false; ++ public List explosionResistantItems = List.of(); ++ private void Entity() { ++ this.disableMobAi = this.getBoolean("entity.disable-mob-ai", this.disableMobAi); ++ this.waterSensitivity = this.getBoolean("entity.water-sensitivity", this.waterSensitivity); ++ this.instantDeathAnimation = this.getBoolean("entity.instant-death-animation", this.instantDeathAnimation); ++ this.ironGolemsTakeFalldamage = this.getBoolean("entity.iron-golems-take-falldamage", this.ironGolemsTakeFalldamage); ++ this.loadSerializedMap("entity.chunk-travel-limit", this.chunkTravelLimit, ChunkTravelLimitsSerializer.get()); ++ this.projectilesLoadChunksForCollisions = this.getBoolean("entity.projectiles-load-chunks-for-collisions", this.projectilesLoadChunksForCollisions); ++ this.loadSerializedList("entity.items.explosion-resistant-items", this.explosionResistantItems, ItemListSerializer.get()); ++ } ++ ++ public double horizontalSpeed = 1.0; ++ public double verticalSpeed = 1.0; ++ public boolean allowBreakingInsideEntities = false; ++ private void ThrownPotion() { ++ this.horizontalSpeed = this.getDouble("entity.thrown-potion.horizontal-speed", this.horizontalSpeed); ++ this.verticalSpeed = this.getDouble("entity.thrown-potion.vertical-speed", this.verticalSpeed); ++ this.allowBreakingInsideEntities = this.getBoolean("entity.thrown-potion.allow-breaking-inside-entities", this.allowBreakingInsideEntities); ++ } ++ ++ public boolean useOutlineForCollision = false; ++ private void EnderPearl() { ++ this.useOutlineForCollision = this.getBoolean("entity.ender-pearl.use-outline-for-collision", this.useOutlineForCollision); ++ } ++ ++ public boolean allowWaterInTheNether = false; ++ public boolean disableFastNetherLava = false; ++ private void Environment() { ++ this.allowWaterInTheNether = this.getBoolean("environment.allow-water-in-the-nether", this.allowWaterInTheNether); ++ this.disableFastNetherLava = this.getBoolean("environment.disable-fast-nether-lava", this.disableFastNetherLava); ++ } ++ ++ public boolean legacyBlockFormation = false; ++ private void BlockGeneration() { ++ this.legacyBlockFormation = this.getBoolean("environment.block-generation.legacy-block-formation", this.legacyBlockFormation); ++ } ++ ++ public boolean useRandomChanceToGrow = false; ++ private void Crops() { ++ this.useRandomChanceToGrow = this.getBoolean("environment.crops.use-random-chance-to-grow", this.useRandomChanceToGrow); ++ } ++ ++ public boolean checkSpawnConditions = true; ++ public boolean requireNearbyPlayer = true; ++ public boolean ignoreEntityLimit = false; ++ private void MobSpawner() { ++ this.checkSpawnConditions = this.getBoolean("environment.mob-spawner.check-spawn-conditions", this.checkSpawnConditions); ++ this.requireNearbyPlayer = this.getBoolean("environment.mob-spawner.require-nearby-player", this.requireNearbyPlayer); ++ this.ignoreEntityLimit = this.getBoolean("environment.mob-spawner.ignore-entity-limit", this.ignoreEntityLimit); ++ } ++} +diff --git a/src/main/java/me/samsuik/sakura/configuration/YamlConfigHelper.java b/src/main/java/me/samsuik/sakura/configuration/YamlConfigHelper.java +new file mode 100644 +index 0000000000000000000000000000000000000000..9340a0696d2a1bf4d91d67627df49191a40682b6 +--- /dev/null ++++ b/src/main/java/me/samsuik/sakura/configuration/YamlConfigHelper.java +@@ -0,0 +1,60 @@ ++package me.samsuik.sakura.configuration; ++ ++import com.google.common.base.Throwables; ++import org.bukkit.Bukkit; ++import org.bukkit.configuration.InvalidConfigurationException; ++import org.bukkit.configuration.file.YamlConfiguration; ++ ++import java.io.File; ++import java.io.IOException; ++import java.lang.reflect.InvocationTargetException; ++import java.lang.reflect.Method; ++import java.lang.reflect.Modifier; ++import java.util.function.Consumer; ++import java.util.logging.Level; ++ ++public final class YamlConfigHelper { ++ public static YamlConfiguration loadConfig(File configFile, String header, Consumer afterLoad) { ++ YamlConfiguration config = new YamlConfiguration(); ++ try { ++ config.load(configFile); ++ } catch (IOException ignored) { ++ } catch (InvalidConfigurationException ex) { ++ Bukkit.getLogger().log(Level.SEVERE, String.format("Could not load %s, please correct your syntax errors", configFile.getName()), ex); ++ throw Throwables.propagate(ex); ++ } ++ ++ config.options().header(header); ++ config.options().copyDefaults(true); ++ afterLoad.accept(config); ++ ++ readConfig(SakuraGlobalConfig.class, null); ++ saveConfig(config, configFile); ++ return config; ++ } ++ ++ public static void readConfig(Class clazz, Object instance) { ++ for (Method method : clazz.getDeclaredMethods()) { ++ if (Modifier.isPrivate(method.getModifiers())) { ++ if (method.getParameterTypes().length == 0 && method.getReturnType() == Void.TYPE) { ++ try { ++ method.setAccessible(true); ++ method.invoke(instance); ++ } catch (InvocationTargetException ex) { ++ throw Throwables.propagate(ex.getCause()); ++ } catch (Exception ex) { ++ Bukkit.getLogger().log(Level.SEVERE, "Error invoking " + method, ex); ++ } ++ } ++ } ++ } ++ } ++ ++ public static void saveConfig(YamlConfiguration config, File configFile) { ++ try { ++ config.save(configFile); ++ } catch (IOException ex) { ++ Bukkit.getLogger().log(Level.SEVERE, "Could not save " + configFile, ex); ++ } ++ } ++} +diff --git a/src/main/java/me/samsuik/sakura/configuration/serializer/ChunkTravelLimitsSerializer.java b/src/main/java/me/samsuik/sakura/configuration/serializer/ChunkTravelLimitsSerializer.java +new file mode 100644 +index 0000000000000000000000000000000000000000..37be21e53f33c1aa64e1919092daa4cb0b1515c4 +--- /dev/null ++++ b/src/main/java/me/samsuik/sakura/configuration/serializer/ChunkTravelLimitsSerializer.java +@@ -0,0 +1,33 @@ ++package me.samsuik.sakura.configuration.serializer; ++ ++import net.minecraft.core.Registry; ++import net.minecraft.resources.ResourceLocation; ++import net.minecraft.world.entity.EntityType; ++ ++public final class ChunkTravelLimitsSerializer implements MapSerializer, Integer, Integer> { ++ private static final ChunkTravelLimitsSerializer INSTANCE = new ChunkTravelLimitsSerializer(); ++ ++ public static ChunkTravelLimitsSerializer get() { ++ return INSTANCE; ++ } ++ ++ @Override ++ public String serializeKey(EntityType key) { ++ return Registry.ENTITY_TYPE.getKey(key).getPath(); ++ } ++ ++ @Override ++ public EntityType deserializeKey(String string) { ++ return Registry.ENTITY_TYPE.get(new ResourceLocation(string)); ++ } ++ ++ @Override ++ public Integer serializeValue(Integer val) { ++ return val; ++ } ++ ++ @Override ++ public Integer deserializeValue(Integer val) { ++ return val; ++ } ++} +diff --git a/src/main/java/me/samsuik/sakura/configuration/serializer/DurableMaterialSerializer.java b/src/main/java/me/samsuik/sakura/configuration/serializer/DurableMaterialSerializer.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0b1670515231be1408780fa6d4cc2daa599b024c +--- /dev/null ++++ b/src/main/java/me/samsuik/sakura/configuration/serializer/DurableMaterialSerializer.java +@@ -0,0 +1,41 @@ ++package me.samsuik.sakura.configuration.serializer; ++ ++import me.samsuik.sakura.explosion.durable.DurableMaterial; ++import net.minecraft.core.Registry; ++import net.minecraft.resources.ResourceLocation; ++import net.minecraft.world.level.block.Block; ++import org.bukkit.configuration.ConfigurationSection; ++import org.bukkit.configuration.MemoryConfiguration; ++ ++public final class DurableMaterialSerializer implements MapSerializer { ++ private static final DurableMaterialSerializer INSTANCE = new DurableMaterialSerializer(); ++ ++ public static DurableMaterialSerializer get() { ++ return INSTANCE; ++ } ++ ++ @Override ++ public String serializeKey(Block key) { ++ return Registry.BLOCK.getKey(key).getPath(); ++ } ++ ++ @Override ++ public Block deserializeKey(String blockName) { ++ return Registry.BLOCK.get(new ResourceLocation(blockName)); ++ } ++ ++ @Override ++ public ConfigurationSection serializeValue(DurableMaterial mat) { ++ MemoryConfiguration materialSection = new MemoryConfiguration(); ++ materialSection.set("durability", mat.durability()); ++ materialSection.set("resistance", mat.resistance()); ++ return materialSection; ++ } ++ ++ @Override ++ public DurableMaterial deserializeValue(ConfigurationSection materialSection) { ++ int durability = materialSection.getInt("durability", 0); ++ float resistance = (float) materialSection.getDouble("resistance", 0.0); ++ return new DurableMaterial(durability, resistance); ++ } ++} +diff --git a/src/main/java/me/samsuik/sakura/configuration/serializer/ItemListSerializer.java b/src/main/java/me/samsuik/sakura/configuration/serializer/ItemListSerializer.java +new file mode 100644 +index 0000000000000000000000000000000000000000..1619656cd9d776ce6abb5de15364cc6cf1ba8f12 +--- /dev/null ++++ b/src/main/java/me/samsuik/sakura/configuration/serializer/ItemListSerializer.java +@@ -0,0 +1,23 @@ ++package me.samsuik.sakura.configuration.serializer; ++ ++import net.minecraft.core.Registry; ++import net.minecraft.resources.ResourceLocation; ++import net.minecraft.world.item.Item; ++ ++public final class ItemListSerializer implements ListSerializer { ++ private static final ItemListSerializer INSTANCE = new ItemListSerializer(); ++ ++ public static ItemListSerializer get() { ++ return INSTANCE; ++ } ++ ++ @Override ++ public String serialize(Item val) { ++ return Registry.ITEM.getKey(val).getPath(); ++ } ++ ++ @Override ++ public Item deserialize(String any) { ++ return Registry.ITEM.get(new ResourceLocation(any)); ++ } ++} +diff --git a/src/main/java/me/samsuik/sakura/configuration/serializer/ListSerializer.java b/src/main/java/me/samsuik/sakura/configuration/serializer/ListSerializer.java +new file mode 100644 +index 0000000000000000000000000000000000000000..0937a8dd5b8dcb1c594c0afb82b5dfda3f6c8305 +--- /dev/null ++++ b/src/main/java/me/samsuik/sakura/configuration/serializer/ListSerializer.java +@@ -0,0 +1,7 @@ ++package me.samsuik.sakura.configuration.serializer; ++ ++public interface ListSerializer { ++ C serialize(V val); ++ ++ V deserialize(C any); ++} +diff --git a/src/main/java/me/samsuik/sakura/configuration/serializer/MapSerializer.java b/src/main/java/me/samsuik/sakura/configuration/serializer/MapSerializer.java +new file mode 100644 +index 0000000000000000000000000000000000000000..7eec08f2263ec1eef5571bcef33bb01771b36833 +--- /dev/null ++++ b/src/main/java/me/samsuik/sakura/configuration/serializer/MapSerializer.java +@@ -0,0 +1,13 @@ ++package me.samsuik.sakura.configuration.serializer; ++ ++public interface MapSerializer { ++ ++ ++ String serializeKey(K key); ++ ++ K deserializeKey(String string); ++ ++ C serializeValue(V val); ++ ++ V deserializeValue(C object); ++} +diff --git a/src/main/java/me/samsuik/sakura/entity/TntSpread.java b/src/main/java/me/samsuik/sakura/entity/TntSpread.java +new file mode 100644 +index 0000000000000000000000000000000000000000..83275db7686a656f8d932d03e092cc6ddaf31ebb +--- /dev/null ++++ b/src/main/java/me/samsuik/sakura/entity/TntSpread.java +@@ -0,0 +1,5 @@ ++package me.samsuik.sakura.entity; ++ ++public enum TntSpread { ++ ALL, Y, NONE; ++} +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 +--- /dev/null ++++ b/src/main/java/me/samsuik/sakura/explosion/durable/DurableMaterial.java +@@ -0,0 +1,7 @@ ++package me.samsuik.sakura.explosion.durable; ++ ++import org.spongepowered.configurate.objectmapping.ConfigSerializable; ++ ++@ConfigSerializable ++public record DurableMaterial(int durability, float resistance) { ++} +diff --git a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +index 257c94f7c1cb00c9a91ab82e311dfd8eca29c538..edd21098ee4c2773acf61fd073d8c87fe2880201 100644 +--- a/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java ++++ b/src/main/java/net/minecraft/server/dedicated/DedicatedServer.java +@@ -235,6 +235,10 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + io.papermc.paper.util.ObfHelper.INSTANCE.getClass(); // load mappings for stacktrace deobf and etc. + io.papermc.paper.brigadier.PaperBrigadierProviderImpl.INSTANCE.getClass(); // init PaperBrigadierProvider + // Paper end ++ // Sakura start ++ me.samsuik.sakura.configuration.SakuraGlobalConfig.get().setup((java.io.File) this.options.valueOf("sakura-settings")); ++ me.samsuik.sakura.command.SakuraCommands.registerCommands(this); ++ // Sakura end + + this.setPvpAllowed(dedicatedserverproperties.pvp); + this.setFlightAllowed(dedicatedserverproperties.allowFlight); +diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java +index fee8996f35b38fd79946cdfd677763e0201eb57d..db7335a079cf711a829b2e4fb7354717da2f8789 100644 +--- a/src/main/java/net/minecraft/world/level/Level.java ++++ b/src/main/java/net/minecraft/world/level/Level.java +@@ -162,6 +162,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot + + public final com.destroystokyo.paper.PaperWorldConfig paperConfig; // Paper ++ public final me.samsuik.sakura.configuration.SakuraWorldConfig sakuraConfig; // Sakura + public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray + + public final co.aikar.timings.WorldTimingsHandler timings; // Paper +@@ -264,6 +265,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + protected Level(WritableLevelData worlddatamutable, ResourceKey resourcekey, Holder holder, Supplier supplier, boolean flag, boolean flag1, long i, org.bukkit.generator.ChunkGenerator gen, org.bukkit.generator.BiomeProvider biomeProvider, org.bukkit.World.Environment env, java.util.concurrent.Executor executor) { // Paper - Async-Anti-Xray - Pass executor + this.spigotConfig = new org.spigotmc.SpigotWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // Spigot + this.paperConfig = new com.destroystokyo.paper.PaperWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName(), this.spigotConfig); // Paper ++ this.sakuraConfig = new me.samsuik.sakura.configuration.SakuraWorldConfig(((net.minecraft.world.level.storage.PrimaryLevelData) worlddatamutable).getLevelName()); // 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 3d07ef0cbd57d54d131cdc766dd55d210d67fb4c..62ee1aebdea1acb3c213d768f82f9131141343ad 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +@@ -956,6 +956,7 @@ public final class CraftServer implements Server { + + org.spigotmc.SpigotConfig.init((File) console.options.valueOf("spigot-settings")); // Spigot + com.destroystokyo.paper.PaperConfig.init((File) console.options.valueOf("paper-settings")); // Paper ++ me.samsuik.sakura.configuration.SakuraGlobalConfig.get().setup((File) console.options.valueOf("sakura-settings")); // Sakura + 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)) +@@ -972,6 +973,7 @@ public final class CraftServer implements Server { + } + world.spigotConfig.init(); // Spigot + world.paperConfig.init(); // Paper ++ world.sakuraConfig.init(); // Sakura + } + + Plugin[] pluginClone = pluginManager.getPlugins().clone(); // Paper +@@ -987,6 +989,7 @@ public final class CraftServer implements Server { + this.reloadData(); + org.spigotmc.SpigotConfig.registerCommands(); // Spigot + com.destroystokyo.paper.PaperConfig.registerCommands(); // Paper ++ me.samsuik.sakura.command.SakuraCommands.registerCommands(this.console); // Sakura + this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*"); + 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 fbe68bd4739d9a0e7d9bc4c3d5ba8ecfd2d13954..c779e4a4df4c954167a7445f2ac29da232e04f20 100644 +--- a/src/main/java/org/bukkit/craftbukkit/Main.java ++++ b/src/main/java/org/bukkit/craftbukkit/Main.java +@@ -153,6 +153,14 @@ public class Main { + .describedAs("Jar file"); + // Paper end + ++ // Sakura start ++ acceptsAll(asList("sakura", "sakura-settings"), "File for sakura settings") ++ .withRequiredArg() ++ .ofType(File.class) ++ .defaultsTo(new File("sakura.yml")) ++ .describedAs("Yml file"); ++ // Sakura end ++ + // Paper start + acceptsAll(asList("server-name"), "Name of the server") + .withRequiredArg() diff --git a/patches/server/0005-Local-Config-and-Value-Storage-API.patch b/patches/server/0004-Local-Config-and-Value-Storage-API.patch similarity index 86% rename from patches/server/0005-Local-Config-and-Value-Storage-API.patch rename to patches/server/0004-Local-Config-and-Value-Storage-API.patch index 94459b7..29f8344 100644 --- a/patches/server/0005-Local-Config-and-Value-Storage-API.patch +++ b/patches/server/0004-Local-Config-and-Value-Storage-API.patch @@ -155,13 +155,13 @@ index 0000000000000000000000000000000000000000..a3a09b8d58589883c7c465597bc64502 +} diff --git a/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java b/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java new file mode 100644 -index 0000000000000000000000000000000000000000..529087b8b5158e96a66e1cafc19979cd4afc8cf3 +index 0000000000000000000000000000000000000000..d50f51e3486e498adf32013c46b34d0d26a68221 --- /dev/null +++ b/src/main/java/me/samsuik/sakura/local/config/LocalValueConfig.java @@ -0,0 +1,75 @@ +package me.samsuik.sakura.local.config; + -+import io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation; ++import com.destroystokyo.paper.PaperWorldConfig; +import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap; +import me.samsuik.sakura.explosion.durable.DurableMaterial; +import me.samsuik.sakura.local.LocalValueKey; @@ -179,7 +179,7 @@ index 0000000000000000000000000000000000000000..529087b8b5158e96a66e1cafc19979cd + private final Expiry expiry; + public Map durableMaterials; + public PhysicsVersion physicsVersion; -+ public RedstoneImplementation redstoneImplementation; ++ public PaperWorldConfig.RedstoneImplementation redstoneImplementation; + public boolean consistentRadius; + public boolean redstoneCache; + public int lavaFlowSpeed = -1; @@ -190,19 +190,19 @@ index 0000000000000000000000000000000000000000..529087b8b5158e96a66e1cafc19979cd + + void init(Level level) { + // default materials -+ this.durableMaterials = new Reference2ObjectOpenHashMap<>(level.sakuraConfig().cannons.explosion.durableMaterials); ++ this.durableMaterials = new Reference2ObjectOpenHashMap<>(level.sakuraConfig.durableMaterials); + + // physics version -+ this.physicsVersion = level.sakuraConfig().cannons.mechanics.physicsVersion; ++ this.physicsVersion = level.sakuraConfig.physicsVersion; + + // redstone implementation -+ this.redstoneImplementation = level.paperConfig().misc.redstoneImplementation; ++ this.redstoneImplementation = level.paperConfig.redstoneImplementation; + + // consistent explosion radius -+ this.consistentRadius = level.sakuraConfig().cannons.explosion.consistentRadius; ++ this.consistentRadius = level.sakuraConfig.consistentRadius; + + // redstone cache -+ this.redstoneCache = level.sakuraConfig().technical.redstone.redstoneCache; ++ //this.redstoneCache = level.sakuraConfig.redstoneCache; + } + + void load(LocalValueStorage storage) { @@ -216,14 +216,14 @@ index 0000000000000000000000000000000000000000..529087b8b5158e96a66e1cafc19979cd + + // redstone implementation + if (storage.exists(LocalValueKey.REDSTONE_IMPLEMENTATION)) { -+ this.redstoneImplementation = RedstoneImplementation.values()[storage.value(LocalValueKey.REDSTONE_IMPLEMENTATION).ordinal()]; ++ this.redstoneImplementation = PaperWorldConfig.RedstoneImplementation.values()[storage.value(LocalValueKey.REDSTONE_IMPLEMENTATION).ordinal()]; + } + + // consistent explosion radius + this.consistentRadius = storage.getOrDefault(LocalValueKey.CONSISTENT_EXPLOSION_RADIUS, this.consistentRadius); + + // redstone cache -+ this.redstoneCache = storage.getOrDefault(LocalValueKey.REDSTONE_CACHE, this.redstoneCache); ++ //this.redstoneCache = storage.getOrDefault(LocalValueKey.REDSTONE_CACHE, this.redstoneCache); + + // lava flow speed + this.lavaFlowSpeed = storage.getOrDefault(LocalValueKey.LAVA_FLOW_SPEED, this.lavaFlowSpeed); @@ -235,10 +235,10 @@ index 0000000000000000000000000000000000000000..529087b8b5158e96a66e1cafc19979cd + +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 36ebba2b3cab5a7e92cceae1b295db10f5cd7c70..0e83e4e0fc1123dadca03dc0e3e1011640722c0a 100644 +index 9cbb478205af1b12da66d89872ac6d3ef2d43e05..80538dd6b0a02e1f5e9ac2e6942eeb453d6f39b2 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1562,6 +1562,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop getTypeKey(); + diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index c91bac6f3f1d60c950b93d157531cd8f7500e8d8..e4d38a83905a8ae8afd3c376429d383fbd84e9ee 100644 +index 43244a479a112786539a905a22cb12e3cf55b2dd..14ece3838a62a8330b975f75a5d0e2df8ace7f11 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -226,6 +226,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -223,6 +223,13 @@ public class CraftWorld extends CraftRegionAccessor implements World { } // Paper end diff --git a/patches/server/0004-Sakura-Configuration-Files.patch b/patches/server/0004-Sakura-Configuration-Files.patch deleted file mode 100644 index 1f3c5fa..0000000 --- a/patches/server/0004-Sakura-Configuration-Files.patch +++ /dev/null @@ -1,1002 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: "kfian294ma4@gmail.com" -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 c2dca89291361d60cbf160cab77749cb0130035a..f3a2b625e26dcc715b5df8c996c1c1412f242b83 100644 ---- a/src/main/java/io/papermc/paper/configuration/Configurations.java -+++ b/src/main/java/io/papermc/paper/configuration/Configurations.java -@@ -88,7 +88,7 @@ public abstract class Configurations { - }; - } - -- static CheckedFunction reloader(Class type, T instance) { -+ public static CheckedFunction reloader(Class type, T instance) { // Sakura - public - return node -> { - ObjectMapper.Factory factory = (ObjectMapper.Factory) Objects.requireNonNull(node.options().serializers().get(type)); - ObjectMapper.Mutable mutable = (ObjectMapper.Mutable) factory.get(type); -@@ -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(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 9fde9ccb5d069ddce8dd837ef1bc68b93ce66434..0cdde29feeb5a308ded845280b6137a7a9671057 100644 ---- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -@@ -431,7 +431,7 @@ public class PaperConfigurations extends Configurations list, String[] args) throws IllegalArgumentException {} -+ -+ @Override -+ @Deprecated -+ public final boolean execute(CommandSender sender, String label, String[] args) { -+ if (testPermission(sender)) { -+ execute(sender, args); -+ } -+ -+ return true; -+ } -+ -+ @Override -+ @NotNull -+ public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { -+ var completions = new ArrayList(0); -+ -+ if (testPermissionSilent(sender)) { -+ tabComplete(completions, args); -+ } -+ -+ return completions; -+ } -+ -+} -diff --git a/src/main/java/me/samsuik/sakura/command/SakuraCommand.java b/src/main/java/me/samsuik/sakura/command/SakuraCommand.java -new file mode 100644 -index 0000000000000000000000000000000000000000..2b145614bf189ae56622016436bfefd63f5271eb ---- /dev/null -+++ b/src/main/java/me/samsuik/sakura/command/SakuraCommand.java -@@ -0,0 +1,93 @@ -+package me.samsuik.sakura.command; -+ -+import net.kyori.adventure.text.Component; -+import net.kyori.adventure.text.format.NamedTextColor; -+import net.kyori.adventure.text.minimessage.MiniMessage; -+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; -+import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; -+import net.minecraft.server.MinecraftServer; -+import org.bukkit.command.Command; -+import org.bukkit.command.CommandSender; -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.checkerframework.framework.qual.DefaultQualifier; -+import org.jetbrains.annotations.NotNull; -+ -+import javax.annotation.Nullable; -+import java.util.ArrayList; -+import java.util.Arrays; -+import java.util.Collections; -+import java.util.List; -+ -+@DefaultQualifier(NonNull.class) -+public final class SakuraCommand extends Command { -+ -+ private static final Component INFORMATION_MESSAGE = MiniMessage.miniMessage().deserialize(""" -+ . -+ | This is the main command for Sakura. -+ | All exclusive commands are listed below.""" -+ ); -+ -+ private static final String COMMAND_MSG = "| * /"; -+ -+ public SakuraCommand(String name) { -+ super(name); -+ -+ this.description = ""; -+ this.usageMessage = "/sakura"; -+ this.setPermission("bukkit.command.sakura"); -+ } -+ -+ @Override -+ public boolean execute(CommandSender sender, String commandLabel, String[] args) { -+ if (args.length > 0) { -+ var commands = new ArrayList<>(SakuraCommands.COMMANDS.values()); -+ -+ // This part is copied from the VersionCommand SubCommand in paper -+ @Nullable -+ var internalVersion = MinecraftServer.getServer().server.getCommandMap().getCommand("version"); -+ if (internalVersion != null) { -+ commands.add(internalVersion); -+ } -+ -+ for (var base : commands) { -+ if (base.getName().equalsIgnoreCase(args[0])) { -+ return base.execute(sender, commandLabel, Arrays.copyOfRange(args, 1, args.length)); -+ } -+ } -+ } -+ -+ sendHelpMessage(sender); -+ return false; -+ } -+ -+ private void sendHelpMessage(CommandSender sender) { -+ sender.sendMessage(INFORMATION_MESSAGE); -+ -+ var uniqueCommands = SakuraCommands.COMMANDS.values() -+ .stream() -+ .filter(command -> command != this); -+ -+ uniqueCommands.forEach((command) -> { -+ sender.sendMessage(MiniMessage.miniMessage().deserialize(COMMAND_MSG, -+ Placeholder.unparsed("command", command.getName())) -+ ); -+ }); -+ -+ sender.sendMessage(Component.text("'", NamedTextColor.DARK_PURPLE)); -+ } -+ -+ @NotNull -+ @Override -+ public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { -+ if (!testPermissionSilent(sender)) { -+ return Collections.emptyList(); -+ } -+ -+ return SakuraCommands.COMMANDS.values().stream() -+ .filter(command -> command != this) // ahem -+ .map(Command::getName) -+ .filter(name -> args.length <= 1 || name.startsWith(args[args.length - 1])) -+ .toList(); -+ } -+ -+} -diff --git a/src/main/java/me/samsuik/sakura/command/SakuraCommands.java b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java -new file mode 100644 -index 0000000000000000000000000000000000000000..3b08454cf7411d12bb33225df59800bd73312123 ---- /dev/null -+++ b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java -@@ -0,0 +1,26 @@ -+package me.samsuik.sakura.command; -+ -+import io.papermc.paper.command.PaperPluginsCommand; -+import me.samsuik.sakura.command.subcommands.ConfigCommand; -+import net.minecraft.server.MinecraftServer; -+import org.bukkit.command.Command; -+ -+import java.util.HashMap; -+import java.util.Map; -+ -+public final class SakuraCommands { -+ -+ static final Map COMMANDS = new HashMap<>(); -+ static { -+ COMMANDS.put("sakura", new SakuraCommand("sakura")); -+ COMMANDS.put("config", new ConfigCommand("config")); -+ } -+ -+ public static void registerCommands(final MinecraftServer server) { -+ COMMANDS.forEach((s, command) -> { -+ server.server.getCommandMap().register(s, "sakura", command); -+ }); -+ server.server.getCommandMap().register("bukkit", new PaperPluginsCommand()); -+ } -+ -+} -diff --git a/src/main/java/me/samsuik/sakura/command/subcommands/ConfigCommand.java b/src/main/java/me/samsuik/sakura/command/subcommands/ConfigCommand.java -new file mode 100644 -index 0000000000000000000000000000000000000000..75febc3f40910a27a9fc651dac9697da48338cc1 ---- /dev/null -+++ b/src/main/java/me/samsuik/sakura/command/subcommands/ConfigCommand.java -@@ -0,0 +1,45 @@ -+package me.samsuik.sakura.command.subcommands; -+ -+import me.samsuik.sakura.command.BaseSubCommand; -+import net.minecraft.server.MinecraftServer; -+import org.bukkit.command.Command; -+import org.bukkit.command.CommandSender; -+import org.bukkit.craftbukkit.CraftServer; -+import org.checkerframework.checker.nullness.qual.NonNull; -+import org.checkerframework.framework.qual.DefaultQualifier; -+import org.jetbrains.annotations.NotNull; -+ -+import java.util.Collections; -+import java.util.List; -+ -+import static net.kyori.adventure.text.Component.text; -+import static net.kyori.adventure.text.format.NamedTextColor.GREEN; -+import static net.kyori.adventure.text.format.NamedTextColor.RED; -+ -+@DefaultQualifier(NonNull.class) -+public final class ConfigCommand extends BaseSubCommand { -+ -+ public ConfigCommand(String name) { -+ super(name); -+ this.description = "Command for reloading the sakura configuration file"; -+ } -+ -+ @Override -+ public void execute(CommandSender sender, String[] args) { -+ Command.broadcastCommandMessage(sender, text("Please note that this command is not supported and may cause issues.", RED)); -+ Command.broadcastCommandMessage(sender, text("If you encounter any issues please use the /stop command to restart your server.", RED)); -+ -+ MinecraftServer server = ((CraftServer) sender.getServer()).getServer(); -+ server.sakuraConfigurations.reloadConfigs(server); -+ server.server.reloadCount++; -+ -+ Command.broadcastCommandMessage(sender, text("Sakura config reload complete.", GREEN)); -+ } -+ -+ @NotNull -+ @Override -+ public List tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { -+ return Collections.emptyList(); -+ } -+ -+} -diff --git a/src/main/java/me/samsuik/sakura/configuration/GlobalConfiguration.java b/src/main/java/me/samsuik/sakura/configuration/GlobalConfiguration.java -new file mode 100644 -index 0000000000000000000000000000000000000000..5296d4e0a1041932e36562f42fbf3e1dcfea33fe ---- /dev/null -+++ b/src/main/java/me/samsuik/sakura/configuration/GlobalConfiguration.java -@@ -0,0 +1,64 @@ -+package me.samsuik.sakura.configuration; -+ -+import com.mojang.logging.LogUtils; -+import io.papermc.paper.configuration.Configuration; -+import io.papermc.paper.configuration.ConfigurationPart; -+import org.slf4j.Logger; -+import org.spongepowered.configurate.objectmapping.meta.Comment; -+import org.spongepowered.configurate.objectmapping.meta.Setting; -+ -+@SuppressWarnings({"CanBeFinal", "FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic", "RedundantSuppression"}) -+public class GlobalConfiguration extends ConfigurationPart { -+ -+ private static final Logger LOGGER = LogUtils.getClassLogger(); -+ static final int CURRENT_VERSION = 1;// (when you change the version, change the comment, so it conflicts on rebases): rename filter bad nbt from spawn eggs -+ -+ private static GlobalConfiguration instance; -+ public static GlobalConfiguration get() { -+ return instance; -+ } -+ -+ static void set(GlobalConfiguration instance) { -+ GlobalConfiguration.instance = instance; -+ } -+ -+ @Setting(Configuration.VERSION_FIELD) -+ public int version = CURRENT_VERSION; -+ -+ public Fps fps; -+ public class Fps extends ConfigurationPart { -+ public String message = "(S) "; -+ public String material = "pink_stained_glass_pane"; -+ } -+ -+ public Cannons cannons; -+ public class Cannons extends ConfigurationPart { -+ public Explosion explosion = new Explosion(); -+ -+ public class Explosion extends ConfigurationPart { -+ public boolean reducedSearchRays; -+ } -+ } -+ -+ public Players players; -+ public class Players extends ConfigurationPart { -+ public String potatoMessage = "(S) This block has of "; -+ } -+ -+ public Environment environment; -+ public class Environment extends ConfigurationPart { -+ @Comment("This is only intended for plot worlds. Will affect chunk generation on servers.") -+ public boolean calculateBiomeNoiseOncePerChunkSection = false; -+ -+ public MobSpawnerDefaults mobSpawnerDefaults = new MobSpawnerDefaults(); -+ public class MobSpawnerDefaults extends ConfigurationPart { -+ public int minSpawnDelay = 200; -+ public int maxSpawnDelay = 800; -+ public int spawnCount = 4; -+ public int maxNearbyEntities = 6; -+ public int requiredPlayerRange = 16; -+ public int spawnRange = 4; -+ } -+ } -+ -+} -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..2d1017435393dee33bb40f7da7a0b553cb48a489 ---- /dev/null -+++ b/src/main/java/me/samsuik/sakura/configuration/SakuraConfigurations.java -@@ -0,0 +1,231 @@ -+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.serializer.*; -+import io.papermc.paper.configuration.serializer.collections.FastutilMapSerializer; -+import io.papermc.paper.configuration.serializer.collections.MapSerializer; -+import io.papermc.paper.configuration.serializer.collections.TableSerializer; -+import io.papermc.paper.configuration.serializer.registry.RegistryHolderSerializer; -+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.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 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; -+import org.spongepowered.configurate.ConfigurationNode; -+import org.spongepowered.configurate.ConfigurationOptions; -+import org.spongepowered.configurate.objectmapping.FieldDiscoverer; -+import org.spongepowered.configurate.objectmapping.ObjectMapper; -+import org.spongepowered.configurate.transformation.ConfigurationTransformation; -+import org.spongepowered.configurate.yaml.YamlConfigurationLoader; -+ -+import java.io.IOException; -+import java.lang.reflect.Type; -+import java.nio.file.Path; -+import java.util.Map; -+import java.util.function.Function; -+ -+import static io.leangen.geantyref.GenericTypeReflector.erase; -+ -+@SuppressWarnings("Convert2Diamond") -+public class SakuraConfigurations extends Configurations { -+ -+ private static final Logger LOGGER = LogUtils.getClassLogger(); -+ static final String GLOBAL_CONFIG_FILE_NAME = "sakura-global.yml"; -+ static final String WORLD_DEFAULTS_CONFIG_FILE_NAME = "sakura-world-defaults.yml"; -+ static final String WORLD_CONFIG_FILE_NAME = "sakura-world.yml"; -+ public static final String CONFIG_DIR = "config"; -+ -+ private static final String GLOBAL_HEADER = String.format(""" -+ This is the global configuration file for Sakura. -+ As you can see, there's a lot to configure. Some options may impact gameplay, so use -+ with caution, and make sure you know what each option does before configuring. -+ -+ The world configuration options have been moved inside -+ their respective world folder. The files are named %s""", WORLD_CONFIG_FILE_NAME); -+ -+ private static final String WORLD_DEFAULTS_HEADER = """ -+ This is the world defaults configuration file for Sakura. -+ As you can see, there's a lot to configure. Some options may impact gameplay, so use -+ with caution, and make sure you know what each option does before configuring. -+ -+ Configuration options here apply to all worlds, unless you specify overrides inside -+ the world-specific config file inside each world folder."""; -+ -+ private static final Function WORLD_HEADER = map -> String.format(""" -+ This is a world configuration file for Sakura. -+ This file may start empty but can be filled with settings to override ones in the %s/%s -+ -+ World: %s (%s)""", -+ SakuraConfigurations.CONFIG_DIR, -+ SakuraConfigurations.WORLD_DEFAULTS_CONFIG_FILE_NAME, -+ map.require(WORLD_NAME), -+ map.require(WORLD_KEY) -+ ); -+ -+ public SakuraConfigurations(final Path globalFolder) { -+ super(globalFolder, GlobalConfiguration.class, WorldConfiguration.class, GLOBAL_CONFIG_FILE_NAME, WORLD_DEFAULTS_CONFIG_FILE_NAME, WORLD_CONFIG_FILE_NAME); -+ } -+ -+ @Override -+ protected YamlConfigurationLoader.Builder createLoaderBuilder() { -+ return super.createLoaderBuilder() -+ .defaultOptions(SakuraConfigurations::defaultOptions); -+ } -+ -+ private static ConfigurationOptions defaultOptions(ConfigurationOptions options) { -+ return options.serializers(builder -> builder -+ .register(MapSerializer.TYPE, new MapSerializer(false)) -+ .register(new EnumValueSerializer()) -+ .register(new ComponentSerializer()) -+ ); -+ } -+ -+ @Override -+ protected ObjectMapper.Factory.Builder createGlobalObjectMapperFactoryBuilder() { -+ return defaultGlobalFactoryBuilder(super.createGlobalObjectMapperFactoryBuilder()); -+ } -+ -+ private static ObjectMapper.Factory.Builder defaultGlobalFactoryBuilder(ObjectMapper.Factory.Builder builder) { -+ return builder.addDiscoverer(InnerClassFieldDiscoverer.globalConfig()); -+ } -+ -+ @Override -+ protected YamlConfigurationLoader.Builder createGlobalLoaderBuilder() { -+ return super.createGlobalLoaderBuilder() -+ .defaultOptions(SakuraConfigurations::defaultGlobalOptions); -+ } -+ -+ private static ConfigurationOptions defaultGlobalOptions(ConfigurationOptions options) { -+ return options -+ .header(GLOBAL_HEADER) -+ .serializers(builder -> builder -+ .register(new PacketClassSerializer()) -+ .register(IntOr.Default.SERIALIZER) -+ ); -+ } -+ -+ @Override -+ public GlobalConfiguration initializeGlobalConfiguration() throws ConfigurateException { -+ GlobalConfiguration configuration = super.initializeGlobalConfiguration(); -+ GlobalConfiguration.set(configuration); -+ return configuration; -+ } -+ -+ @Override -+ protected ObjectMapper.Factory.Builder createWorldObjectMapperFactoryBuilder(final ContextMap contextMap) { -+ return super.createWorldObjectMapperFactoryBuilder(contextMap) -+ .addNodeResolver(new NestedSetting.Factory()) -+ .addDiscoverer(createWorldConfigFieldDiscoverer(contextMap)); -+ } -+ -+ private static FieldDiscoverer createWorldConfigFieldDiscoverer(final ContextMap contextMap) { -+ final Map, Object> overrides = Map.of( -+ WorldConfiguration.class, createWorldConfigInstance(contextMap) -+ ); -+ return new InnerClassFieldDiscoverer(overrides); -+ } -+ -+ private static WorldConfiguration createWorldConfigInstance(ContextMap contextMap) { -+ return new WorldConfiguration( -+ contextMap.require(Configurations.WORLD_KEY) -+ ); -+ } -+ -+ @Override -+ protected YamlConfigurationLoader.Builder createWorldConfigLoaderBuilder(final ContextMap contextMap) { -+ return super.createWorldConfigLoaderBuilder(contextMap) -+ .defaultOptions(options -> options -+ .header(contextMap.require(WORLD_NAME).equals(WORLD_DEFAULTS) ? WORLD_DEFAULTS_HEADER : WORLD_HEADER.apply(contextMap)) -+ .serializers(serializers -> serializers -+ .register(new TypeToken>() {}, new FastutilMapSerializer.SomethingToPrimitive>(Reference2IntOpenHashMap::new, Integer.TYPE)) -+ .register(new TypeToken>() {}, new FastutilMapSerializer.SomethingToPrimitive>(Reference2LongOpenHashMap::new, Long.TYPE)) -+ .register(new TypeToken>() {}, new TableSerializer()) -+ .register(StringRepresentableSerializer::isValidFor, new StringRepresentableSerializer()) -+ .register(IntOr.Default.SERIALIZER) -+ .register(IntOr.Disabled.SERIALIZER) -+ .register(DoubleOrDefault.SERIALIZER) -+ .register(BooleanOrDefault.SERIALIZER) -+ .register(NbtPathSerializer.SERIALIZER) -+ .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)) -+ .register(new RegistryValueSerializer<>(Block.class, Registries.BLOCK, true)) -+ ) -+ ); -+ } -+ -+ @Override -+ protected void applyWorldConfigTransformations(final ContextMap contextMap, final ConfigurationNode node) throws ConfigurateException { -+// final ConfigurationTransformation.VersionedBuilder versionedBuilder = Transformations.versionedBuilder(); -+// -+// // ADD FUTURE VERSIONED TRANSFORMS TO versionedBuilder HERE -+// versionedBuilder.build().apply(node); -+ } -+ -+ @Override -+ public WorldConfiguration createWorldConfig(final ContextMap contextMap) { -+ final String levelName = contextMap.require(WORLD_NAME); -+ try { -+ return super.createWorldConfig(contextMap); -+ } catch (IOException exception) { -+ throw new RuntimeException("Could not create world config for " + levelName, exception); -+ } -+ } -+ -+ @Override -+ protected boolean isConfigType(final Type type) { -+ return ConfigurationPart.class.isAssignableFrom(erase(type)); -+ } -+ -+ public void reloadConfigs(MinecraftServer server) { -+ try { -+ this.initializeGlobalConfiguration(reloader(this.globalConfigClass, GlobalConfiguration.get())); -+ this.initializeWorldDefaultsConfiguration(); -+ for (ServerLevel level : server.getAllLevels()) { -+ this.createWorldConfig(createWorldContextMap(level), reloader(this.worldConfigClass, level.sakuraConfig())); -+ } -+ } catch (Exception ex) { -+ throw new RuntimeException("Could not reload paper configuration files", ex); -+ } -+ } -+ -+ private static ContextMap createWorldContextMap(ServerLevel level) { -+ return createWorldContextMap(level.convertable.levelDirectory.path(), level.serverLevelData.getLevelName(), level.dimension().location()); -+ } -+ -+ 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) -+ .build(); -+ } -+ -+ public static SakuraConfigurations setup(final Path configDir) { -+ try { -+ PaperConfigurations.createDirectoriesSymlinkAware(configDir); -+ return new SakuraConfigurations(configDir); -+ } catch (final IOException ex) { -+ throw new RuntimeException("Could not setup PaperConfigurations", ex); -+ } -+ } -+ -+} -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..907c2e62848c395d61c3ea94df458e2be72b9f1b ---- /dev/null -+++ b/src/main/java/me/samsuik/sakura/configuration/WorldConfiguration.java -@@ -0,0 +1,237 @@ -+package me.samsuik.sakura.configuration; -+ -+import com.mojang.logging.LogUtils; -+import io.papermc.paper.configuration.Configuration; -+import io.papermc.paper.configuration.ConfigurationPart; -+import io.papermc.paper.configuration.NestedSetting; -+import io.papermc.paper.configuration.PaperConfigurations; -+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; -+import me.samsuik.sakura.physics.PhysicsVersion; -+import net.minecraft.Util; -+import net.minecraft.resources.ResourceLocation; -+import net.minecraft.world.entity.EntityType; -+import net.minecraft.world.entity.item.FallingBlockEntity; -+import net.minecraft.world.item.Item; -+import net.minecraft.world.level.block.Block; -+import net.minecraft.world.level.block.Blocks; -+import org.slf4j.Logger; -+import org.spongepowered.configurate.objectmapping.meta.Comment; -+import org.spongepowered.configurate.objectmapping.meta.Setting; -+ -+import java.util.List; -+import java.util.Map; -+ -+@SuppressWarnings({"FieldCanBeLocal", "FieldMayBeFinal", "NotNullFieldNotInitialized", "InnerClassMayBeStatic", "RedundantSuppression"}) -+public class WorldConfiguration extends ConfigurationPart { -+ -+ private static final Logger LOGGER = LogUtils.getClassLogger(); -+ static final int CURRENT_VERSION = 6; // (when you change the version, change the comment, so it conflicts on rebases): rename filter bad nbt from spawn eggs -+ -+ private transient final ResourceLocation worldKey; -+ WorldConfiguration(ResourceLocation worldKey) { -+ this.worldKey = worldKey; -+ } -+ -+ public boolean isDefault() { -+ return this.worldKey.equals(PaperConfigurations.WORLD_DEFAULTS_KEY); -+ } -+ -+ @Setting(Configuration.VERSION_FIELD) -+ public int version = CURRENT_VERSION; -+ -+ public Cannons cannons; -+ public class Cannons extends ConfigurationPart { -+ public MergeLevel mergeLevel = MergeLevel.STRICT; -+ public boolean tntAndSandAffectedByBubbleColumns = true; -+ -+ @NestedSetting({"treat-collidable-blocks-as-full", "while-moving"}) -+ public boolean treatAllBlocksAsFullWhenMoving = false; -+ @NestedSetting({"treat-collidable-blocks-as-full", "moving-faster-than"}) -+ public double treatAllBlocksAsFullWhenMovingFasterThan = 64.0; -+ public boolean loadChunks = false; -+ -+ public Restrictions restrictions = new Restrictions(); -+ public class Restrictions extends ConfigurationPart { -+ @Comment("The amount of blocks that can be travelled before changing direction is restricted") -+ public IntOr.Disabled leftShootingThreshold = IntOr.Disabled.DISABLED; -+ @Comment( -+ "Maximum amount of blocks that a cannon can adjust\n" + -+ "It is recommended that this value kept sane and is more than 64 blocks" -+ ) -+ public IntOr.Disabled maxAdjustDistance = IntOr.Disabled.DISABLED; -+ } -+ -+ public Tnt tnt = new Tnt(); -+ public class Tnt extends ConfigurationPart { -+ public boolean forcePositionUpdates; -+ } -+ -+ public Sand sand = new Sand(); -+ public class Sand extends ConfigurationPart { -+ public boolean despawnInsideMovingPistons = true; -+ public boolean concreteSolidifyInWater = true; -+ -+ @NestedSetting({"prevent-stacking", "against-border"}) -+ public boolean preventAgainstBorder = false; -+ @NestedSetting({"prevent-stacking", "world-height"}) -+ public boolean preventAtWorldHeight = false; -+ -+ public boolean isFallingBlockInBounds(FallingBlockEntity entity) { -+ return (!preventAgainstBorder || !io.papermc.paper.util.CollisionUtil.isCollidingWithBorderEdge(entity.level.getWorldBorder(), entity.getBoundingBox().inflate(0.01))) -+ && (!preventAtWorldHeight || entity.blockPosition().getY() < entity.level.getMaxBuildHeight() - 1); -+ } -+ } -+ -+ public Explosion explosion = new Explosion(); -+ public class Explosion extends ConfigurationPart { -+ public boolean optimiseProtectedRegions = true; -+ public boolean avoidRedundantBlockSearches = false; -+ public Map durableMaterials = Util.make(new Reference2ObjectOpenHashMap<>(), map -> { -+ map.put(Blocks.OBSIDIAN, new DurableMaterial(4, Blocks.COBBLESTONE.getExplosionResistance())); -+ map.put(Blocks.ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance())); -+ map.put(Blocks.CHIPPED_ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance())); -+ map.put(Blocks.DAMAGED_ANVIL, new DurableMaterial(3, Blocks.END_STONE.getExplosionResistance())); -+ }); -+ public boolean protectScaffoldingFromCreepers = false; -+ public boolean allowNonTntBreakingDurableBlocks = false; -+ public boolean destroyWaterloggedBlocks = false; -+ public boolean explodeLava = false; -+ public boolean consistentRadius = false; -+ public boolean explosionsHurtPlayers = true; -+ public boolean explosionsDropItems = true; -+ public boolean useBlockCacheAcrossExplosions = false; -+ } -+ -+ public Mechanics mechanics = new Mechanics(); -+ public class Mechanics extends ConfigurationPart { -+ public TNTSpread tntSpread = TNTSpread.ALL; -+ public boolean tntFlowsInWater = true; -+ public boolean fallingBlockParity = false; -+ public PhysicsVersion physicsVersion = PhysicsVersion.LATEST; -+ -+ public enum TNTSpread { -+ ALL, Y, NONE; -+ } -+ } -+ } -+ -+ public Technical technical; -+ public class Technical extends ConfigurationPart { -+ public boolean dispenserRandomItemSelection = true; -+ -+ public Redstone redstone = new Redstone(); -+ public class Redstone extends ConfigurationPart { -+ public boolean redstoneCache = false; -+ public boolean fluidsBreakRedstone = true; -+ } -+ } -+ -+ public Players players; -+ public class Players extends ConfigurationPart { -+ public Combat combat = new Combat(); -+ public class Combat extends ConfigurationPart { -+ public boolean legacyCombatMechanics = false; -+ public boolean allowSweepAttacks = true; -+ public boolean shieldDamageReduction = false; -+ public boolean oldEnchantedGoldenApple = false; -+ public boolean oldSoundsAndParticleEffects = false; -+ public boolean fastHealthRegen = true; -+ public IntOr.Default maxArmourDamage = IntOr.Default.USE_DEFAULT; -+ } -+ -+ public Knockback knockback = new Knockback(); -+ public class Knockback extends ConfigurationPart { -+ public DoubleOrDefault knockbackVertical = DoubleOrDefault.USE_DEFAULT; -+ public double knockbackVerticalLimit = 0.4; -+ public boolean verticalKnockbackRequireGround = true; -+ public double baseKnockback = 0.4; -+ @Comment("Knockback caused by sweeping edge") -+ public double sweepingEdgeKnockback = 0.4; -+ -+ public Sprinting sprinting = new Sprinting(); -+ public class Sprinting extends ConfigurationPart { -+ public boolean requireFullAttack = true; -+ public double extraKnockback = 0.5; -+ @Comment("Delay between extra knockback hits in milliseconds") -+ public IntOr.Default knockbackDelay = IntOr.Default.USE_DEFAULT; -+ } -+ -+ @NestedSetting({"projectiles", "fishing-hooks-apply-knockback"}) -+ public boolean fishingHooksApplyKnockback; -+ -+ @Comment("Knockback resistance attribute modifier") -+ public double knockbackResistanceModifier = 1.0; -+ @Comment("Received by attacking a shielded enemy") -+ public double shieldHitKnockback = 0.5; -+ } -+ -+ @Comment("Prevents players swimming using elytra or riptide to enter holes") -+ public boolean posesShrinkCollisionBox = true; -+ public boolean fishingHooksPullEntities = true; -+ } -+ -+ public Entity entity; -+ public class Entity extends ConfigurationPart { -+ @Comment("Only modify if you know what you're doing") -+ public boolean disableMobAi = false; -+ public boolean waterSensitivity = true; -+ public boolean instantDeathAnimation = false; -+ public boolean ironGolemsTakeFalldamage = false; -+ -+ public Items items = new Items(); -+ public class Items extends ConfigurationPart { -+ public List explosionResistantItems = List.of(); -+ } -+ -+ @Comment("Entity travel distance limits") -+ public Map, Integer> chunkTravelLimit = Util.make(new Reference2ObjectOpenHashMap<>(), map -> { -+ map.put(EntityType.ENDER_PEARL, 8); -+ }); -+ -+ public ThrownPotion thrownPotion = new ThrownPotion(); -+ public class ThrownPotion extends ConfigurationPart { -+ public double horizontalSpeed = 1.0; -+ public double verticalSpeed = 1.0; -+ public boolean allowBreakingInsideEntities = false; -+ } -+ -+ public EnderPearl enderPearl = new EnderPearl(); -+ public class EnderPearl extends ConfigurationPart { -+ public boolean useOutlineForCollision = false; -+ } -+ -+ @Comment( -+ "Allows projectiles to load chunks for collisions\n" + -+ "This restores vanilla chunk loading behaviour" -+ ) -+ public boolean projectilesLoadChunksForCollisions = false; -+ } -+ -+ public Environment environment; -+ public class Environment extends ConfigurationPart { -+ public boolean allowWaterInTheNether = false; -+ public boolean disableFastNetherLava = false; -+ -+ public BlockGeneration blockGeneration = new BlockGeneration(); -+ public class BlockGeneration extends ConfigurationPart { -+ public boolean legacyBlockFormation = false; -+ } -+ -+ public Crops crops = new Crops(); -+ public class Crops extends ConfigurationPart { -+ public boolean useRandomChanceToGrow = false; -+ } -+ -+ public MobSpawner mobSpawner = new MobSpawner(); -+ public class MobSpawner extends ConfigurationPart { -+ public boolean checkSpawnConditions = true; -+ public boolean requireNearbyPlayer = true; -+ public boolean ignoreEntityLimit = false; -+ } -+ } -+ -+} -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 ---- /dev/null -+++ b/src/main/java/me/samsuik/sakura/explosion/durable/DurableMaterial.java -@@ -0,0 +1,7 @@ -+package me.samsuik.sakura.explosion.durable; -+ -+import org.spongepowered.configurate.objectmapping.ConfigSerializable; -+ -+@ConfigSerializable -+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 777b012f7b3b35b89177d94f2c1d8dd1ee4adf7d..36ebba2b3cab5a7e92cceae1b295db10f5cd7c70 100644 ---- a/src/main/java/net/minecraft/server/MinecraftServer.java -+++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -304,6 +304,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, 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 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 -+ // Sakura start -+ private final me.samsuik.sakura.configuration.WorldConfiguration sakuraConfig; -+ public final me.samsuik.sakura.configuration.WorldConfiguration sakuraConfig() { -+ return this.sakuraConfig; -+ } -+ // Sakura end - - public final com.destroystokyo.paper.antixray.ChunkPacketBlockController chunkPacketBlockController; // Paper - Anti-Xray - public final co.aikar.timings.WorldTimingsHandler timings; // Paper -@@ -270,9 +276,10 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - - public abstract ResourceKey getTypeKey(); - -- 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 -+ 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 f3c1e3a6951a17b42bff6a32a9b2fe29edfaf81c..faddb7cefa3a26911c0ab509ead71387bf79a7de 100644 ---- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java -+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -961,6 +961,7 @@ public final class CraftServer implements Server { - - 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)) -@@ -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 -+ me.samsuik.sakura.command.SakuraCommands.registerCommands(this.console); // Sakura - this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*"); - 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 f30621be24c6c3a4f173436fce1ad1c13507c84f..d24c80dca90ae3b399bec6a23022a8db1e574868 100644 ---- a/src/main/java/org/bukkit/craftbukkit/Main.java -+++ b/src/main/java/org/bukkit/craftbukkit/Main.java -@@ -166,6 +166,14 @@ public class Main { - .describedAs("Jar file"); - // Paper end - -+ // Sakura start -+ acceptsAll(asList("sakura-dir", "sakura-settings-directory"), "Directory for Sakura settings") -+ .withRequiredArg() -+ .ofType(File.class) -+ .defaultsTo(new File(me.samsuik.sakura.configuration.SakuraConfigurations.CONFIG_DIR)) -+ .describedAs("Config directory"); -+ // Sakura end -+ - // Paper start - acceptsAll(asList("server-name"), "Name of the server") - .withRequiredArg() diff --git a/patches/server/0006-Visibility-API-and-Command.patch b/patches/server/0005-Visibility-API-and-Command.patch similarity index 83% rename from patches/server/0006-Visibility-API-and-Command.patch rename to patches/server/0005-Visibility-API-and-Command.patch index 37e259e..2da8e05 100644 --- a/patches/server/0006-Visibility-API-and-Command.patch +++ b/patches/server/0005-Visibility-API-and-Command.patch @@ -5,12 +5,12 @@ Subject: [PATCH] Visibility API and Command diff --git a/src/main/java/me/samsuik/sakura/command/SakuraCommands.java b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java -index 3b08454cf7411d12bb33225df59800bd73312123..22676ec7a7ae9494b198e5e65e6be6d32e0feb85 100644 +index cd44b3400a1ab9544aa4a9e50b1054ea436a3643..a5020f97cfeefe5eaadc22321d89518ed3aa4b37 100644 --- a/src/main/java/me/samsuik/sakura/command/SakuraCommands.java +++ b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java -@@ -2,6 +2,9 @@ package me.samsuik.sakura.command; +@@ -1,6 +1,9 @@ + package me.samsuik.sakura.command; - import io.papermc.paper.command.PaperPluginsCommand; import me.samsuik.sakura.command.subcommands.ConfigCommand; +import me.samsuik.sakura.command.subcommands.FPSCommand; +import me.samsuik.sakura.command.subcommands.VisualCommand; @@ -18,7 +18,7 @@ index 3b08454cf7411d12bb33225df59800bd73312123..22676ec7a7ae9494b198e5e65e6be6d3 import net.minecraft.server.MinecraftServer; import org.bukkit.command.Command; -@@ -14,6 +17,10 @@ public final class SakuraCommands { +@@ -12,6 +15,10 @@ public final class SakuraCommands { static { COMMANDS.put("sakura", new SakuraCommand("sakura")); COMMANDS.put("config", new ConfigCommand("config")); @@ -63,14 +63,14 @@ index 0000000000000000000000000000000000000000..aa5ddf696b09226a0bd3d967d2ac2b11 +} diff --git a/src/main/java/me/samsuik/sakura/command/subcommands/VisualCommand.java b/src/main/java/me/samsuik/sakura/command/subcommands/VisualCommand.java new file mode 100644 -index 0000000000000000000000000000000000000000..148a583279333eeb3e5db16652623082cd5e0e60 +index 0000000000000000000000000000000000000000..6e1ec244731012cf0b75d9ee81de036a77cf46ca --- /dev/null +++ b/src/main/java/me/samsuik/sakura/command/subcommands/VisualCommand.java @@ -0,0 +1,45 @@ +package me.samsuik.sakura.command.subcommands; + +import me.samsuik.sakura.command.BaseSubCommand; -+import me.samsuik.sakura.configuration.GlobalConfiguration; ++import me.samsuik.sakura.configuration.SakuraGlobalConfig; +import me.samsuik.sakura.player.visibility.Visibility; +import net.kyori.adventure.text.minimessage.MiniMessage; +import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; @@ -105,7 +105,7 @@ index 0000000000000000000000000000000000000000..148a583279333eeb3e5db16652623082 + + // Send message to player + var state = visibility.isEnabled(type) ? "Enabled" : "Disabled"; -+ player.sendMessage(MiniMessage.miniMessage().deserialize(GlobalConfiguration.get().fps.message, ++ player.sendMessage(MiniMessage.miniMessage().deserialize(SakuraGlobalConfig.get().fpsMessage, + Placeholder.unparsed("name", type.friendlyName()), + Placeholder.unparsed("state", state)) + ); @@ -114,13 +114,13 @@ 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..0380753ce7d65a98b9d008f13bc9bc7908c6dc8a +index 0000000000000000000000000000000000000000..d2bdd2693dd64add54369990a4c05f122c04e394 --- /dev/null +++ b/src/main/java/me/samsuik/sakura/player/visibility/VisibilityGUI.java @@ -0,0 +1,124 @@ +package me.samsuik.sakura.player.visibility; + -+import me.samsuik.sakura.configuration.GlobalConfiguration; ++import me.samsuik.sakura.configuration.SakuraGlobalConfig; +import me.samsuik.sakura.player.gui.ItemIcon; +import me.samsuik.sakura.player.gui.PlayerGUI; +import net.kyori.adventure.text.Component; @@ -147,7 +147,7 @@ index 0000000000000000000000000000000000000000..0380753ce7d65a98b9d008f13bc9bc79 + int row = (i + 1) / 9; + + Material background = column > 0 && column < 8 ? (row > 0 && row < 4 || column > 1 && column < 7) -+ ? Material.matchMaterial(GlobalConfiguration.get().fps.material) ++ ? Material.matchMaterial(SakuraGlobalConfig.get().fpsMaterial) + : Material.WHITE_STAINED_GLASS_PANE + : Material.BLACK_STAINED_GLASS_PANE; + @@ -231,7 +231,7 @@ index 0000000000000000000000000000000000000000..0380753ce7d65a98b9d008f13bc9bc79 + String state = visibility.isEnabled(setting) ? "Enabled" : "Disabled"; + + // Send message to player -+ player.sendMessage(MiniMessage.miniMessage().deserialize(GlobalConfiguration.get().fps.message, ++ player.sendMessage(MiniMessage.miniMessage().deserialize(SakuraGlobalConfig.get().fpsMessage, + Placeholder.unparsed("name", setting.friendlyName()), + Placeholder.unparsed("state", state) + )); @@ -243,7 +243,7 @@ index 0000000000000000000000000000000000000000..0380753ce7d65a98b9d008f13bc9bc79 + +} 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 24c677e80af652952263253409c050641e72e3b5..62b08f8216abc1bc82bc5457e74811c823e900e0 100644 +index 652bea6868a03a5315965f79c76172fb9dbb93fb..7bdec48862e3a3e20b824f1384d5a80aefa933f7 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 cachedSingleMobDistanceMap; // Paper end @@ -328,8 +328,8 @@ index 289429eb464548acc80262a49444f49f8f57fc0c..5f38f9a7aca3af47dc3454035a7faf1d // CraftBukkit start public String displayName; -@@ -505,6 +506,15 @@ public class ServerPlayer extends Player { - this.respawnDimension = (ResourceKey) dataresult1.resultOrPartial(logger1::error).orElse(Level.OVERWORLD); +@@ -426,6 +427,15 @@ public class ServerPlayer extends Player { + this.setPos(this.getX(), this.getY() + 1.0D, this.getZ()); } } + // Sakura start - visibility api @@ -344,7 +344,7 @@ index 289429eb464548acc80262a49444f49f8f57fc0c..5f38f9a7aca3af47dc3454035a7faf1d } -@@ -571,6 +581,13 @@ public class ServerPlayer extends Player { +@@ -532,6 +542,13 @@ public class ServerPlayer extends Player { }); } this.getBukkitEntity().setExtraData(nbt); // CraftBukkit @@ -359,10 +359,10 @@ index 289429eb464548acc80262a49444f49f8f57fc0c..5f38f9a7aca3af47dc3454035a7faf1d } diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index bac6b62419d85b3772ef243aa3d5f73311abdda7..60fc19f25245f491c31018ec7cb065ced3516c44 100644 +index 3faf67d100e49836eb9b408e88c296e615ca33f8..f451ed92f75a6f5553790ca97cabbcdfd0d3d169 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -3162,6 +3162,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic +@@ -2858,6 +2858,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser event.setCancelled(cancelled); AbstractContainerMenu oldContainer = this.player.containerMenu; // SPIGOT-1224 @@ -371,10 +371,10 @@ index bac6b62419d85b3772ef243aa3d5f73311abdda7..60fc19f25245f491c31018ec7cb065ce 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 1eaab1f6923e6aa34b643293347348e5cc19af3c..0636aab71c93413ee40d842daae1b4232f7b2b9d 100644 +index dfd1f37757af1bd808cc2e2d8bf97123adf638bb..65e53582f3d2b49e795f0f98325ddf8063f5f752 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -541,6 +541,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -428,6 +428,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.teleportTo(worldserver, null); } // Paper end - make end portalling safe @@ -383,13 +383,13 @@ index 1eaab1f6923e6aa34b643293347348e5cc19af3c..0636aab71c93413ee40d842daae1b423 + public boolean isFallingBlock; + // Sakura end - visibility api and command - public Entity(EntityType type, Level world) { - this.id = Entity.ENTITY_COUNTER.incrementAndGet(); + // Paper start + /** 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 eacb8a407fe99af2c13f23c12b5544696bda8890..d693fb7fd81f046615ad062153c1a2599948d391 100644 +index 318ea6ebf4c13a984b3815f00bf6cb3856ff6fe0..cd587ad749699e14351e75be82363759b7ce4235 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -70,6 +70,7 @@ public class FallingBlockEntity extends Entity { +@@ -68,6 +68,7 @@ public class FallingBlockEntity extends Entity { this.blockState = Blocks.SAND.defaultBlockState(); this.dropItem = true; this.fallDamageMax = 40; @@ -398,10 +398,10 @@ index eacb8a407fe99af2c13f23c12b5544696bda8890..d693fb7fd81f046615ad062153c1a259 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 bedee2c93bd0aff148f93dcf111e0fc3d9bce4a0..e2d016561d68901d86819bd830d516cad2a3bedd 100644 +index 445d9d1ec6f02f32d819d8555ceddb8e1ada7acd..29830c07e61aaf74bfd876f2624c0fea859ddf4f 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -27,6 +27,7 @@ public class PrimedTnt extends Entity { +@@ -30,6 +30,7 @@ public class PrimedTnt extends Entity { public PrimedTnt(EntityType type, Level world) { super(type, world); this.blocksBuilding = true; @@ -410,23 +410,22 @@ index bedee2c93bd0aff148f93dcf111e0fc3d9bce4a0..e2d016561d68901d86819bd830d516ca 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 7c22957714c182579885a1a6197c09ce84755593..00ebe6b2e3068a3b9c1c4a7566685191f21ed379 100644 +index 6a777b6de479e11f112a01afbbc3226ce1dcd10c..9c28594590c57ced725f3e0c6fdb9c6a5ab9bfa2 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -282,6 +282,8 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -265,6 +265,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + return this.localConfig; + } + // Sakura end ++ public final it.unimi.dsi.fastutil.longs.Long2IntMap minimalTNT = new it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap(); // Sakura - visibility api 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, 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 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index c546a465a2f85e1b0e785074af15546637619e8f..aaa3b2aa8e8791d88e2fb08342ec8c133cd219d6 100644 +index ce78e024244c14530270b8276e5b0fd853f0a110..f16ba5860484de0e211d954436d2e5106a651808 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -494,6 +494,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -415,6 +415,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player { this.getHandle().displayName = name == null ? getName() : name; } diff --git a/patches/server/0007-Reduce-deltaMovement-Allocations.patch b/patches/server/0006-Reduce-deltaMovement-Allocations.patch similarity index 86% rename from patches/server/0007-Reduce-deltaMovement-Allocations.patch rename to patches/server/0006-Reduce-deltaMovement-Allocations.patch index e3f239b..aee31e6 100644 --- a/patches/server/0007-Reduce-deltaMovement-Allocations.patch +++ b/patches/server/0006-Reduce-deltaMovement-Allocations.patch @@ -5,10 +5,10 @@ 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 0636aab71c93413ee40d842daae1b4232f7b2b9d..3b6efce07745df062d5d3ef60011718842217336 100644 +index 65e53582f3d2b49e795f0f98325ddf8063f5f752..078ec45f7e0b51f6b78f71d909d43b8966fc1b0a 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -1166,7 +1166,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1100,7 +1100,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.tryCheckInsideBlocks(); float f2 = this.getBlockSpeedFactor(); @@ -17,7 +17,7 @@ index 0636aab71c93413ee40d842daae1b4232f7b2b9d..3b6efce07745df062d5d3ef600117188 // Paper start - remove expensive streams from here boolean noneMatch = true; AABB fireSearchBox = this.getBoundingBox().deflate(1.0E-6D); -@@ -1895,6 +1895,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1781,6 +1781,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { public void moveTo(double x, double y, double z, float yaw, float pitch) { // Paper - cancel entity velocity if teleported if (!preserveMotion) { @@ -25,7 +25,7 @@ index 0636aab71c93413ee40d842daae1b4232f7b2b9d..3b6efce07745df062d5d3ef600117188 this.deltaMovement = Vec3.ZERO; } else { this.preserveMotion = false; -@@ -3199,29 +3200,33 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3053,29 +3054,33 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public void onAboveBubbleCol(boolean drag) { @@ -67,7 +67,7 @@ index 0636aab71c93413ee40d842daae1b4232f7b2b9d..3b6efce07745df062d5d3ef600117188 this.resetFallDistance(); } -@@ -4155,16 +4160,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -3950,16 +3955,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { vec3d = vec3d.normalize(); } @@ -90,7 +90,7 @@ index 0636aab71c93413ee40d842daae1b4232f7b2b9d..3b6efce07745df062d5d3ef600117188 } this.fluidHeight.put(tag, d1); -@@ -4231,11 +4239,53 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4024,18 +4032,64 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return this.chunkPosition; } @@ -144,7 +144,6 @@ index 0636aab71c93413ee40d842daae1b4232f7b2b9d..3b6efce07745df062d5d3ef600117188 synchronized (this.posLock) { // Paper this.deltaMovement = velocity; } // Paper -@@ -4246,7 +4296,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public void setDeltaMovement(double x, double y, double z) { @@ -158,10 +157,10 @@ index 0636aab71c93413ee40d842daae1b4232f7b2b9d..3b6efce07745df062d5d3ef600117188 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 d693fb7fd81f046615ad062153c1a2599948d391..1a83f88e7759b168d6f3c2f6ed4532d65a7cf437 100644 +index cd587ad749699e14351e75be82363759b7ce4235..597efc61bdd46b951b62c2584a846942508983cf 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -142,7 +142,7 @@ public class FallingBlockEntity extends Entity { +@@ -140,7 +140,7 @@ public class FallingBlockEntity extends Entity { ++this.time; if (!this.isNoGravity()) { @@ -170,7 +169,7 @@ index d693fb7fd81f046615ad062153c1a2599948d391..1a83f88e7759b168d6f3c2f6ed4532d6 } this.move(MoverType.SELF, this.getDeltaMovement()); -@@ -189,7 +189,7 @@ public class FallingBlockEntity extends Entity { +@@ -187,7 +187,7 @@ public class FallingBlockEntity extends Entity { } else { BlockState iblockdata = this.level.getBlockState(blockposition); @@ -179,7 +178,7 @@ index d693fb7fd81f046615ad062153c1a2599948d391..1a83f88e7759b168d6f3c2f6ed4532d6 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))); -@@ -256,7 +256,7 @@ public class FallingBlockEntity extends Entity { +@@ -254,7 +254,7 @@ public class FallingBlockEntity extends Entity { } } @@ -189,10 +188,10 @@ index d693fb7fd81f046615ad062153c1a2599948d391..1a83f88e7759b168d6f3c2f6ed4532d6 } 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 e2d016561d68901d86819bd830d516cad2a3bedd..80e495688b00d1297357350f9abebe5fbbf24cd8 100644 +index 29830c07e61aaf74bfd876f2624c0fea859ddf4f..f997647a7ff29100acd5bab1d77ac3a6305e4717 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -62,7 +62,7 @@ public class PrimedTnt extends Entity { +@@ -65,7 +65,7 @@ public class PrimedTnt extends Entity { public void tick() { if (level.spigotConfig.maxTntTicksPerTick > 0 && ++level.spigotConfig.currentPrimedTnt > level.spigotConfig.maxTntTicksPerTick) { return; } // Spigot if (!this.isNoGravity()) { @@ -201,7 +200,7 @@ index e2d016561d68901d86819bd830d516cad2a3bedd..80e495688b00d1297357350f9abebe5f } this.move(MoverType.SELF, this.getDeltaMovement()); -@@ -72,9 +72,9 @@ public class PrimedTnt extends Entity { +@@ -75,9 +75,9 @@ public class PrimedTnt extends Entity { return; } // Paper end @@ -214,11 +213,11 @@ index e2d016561d68901d86819bd830d516cad2a3bedd..80e495688b00d1297357350f9abebe5f 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 5ef6b5ad4dd69a57595914c7af8422ee2f6ad054..e60410d2d1a09f935caffe0cfb9b6232c00b1c8c 100644 +index 29f6c10e2c2626a9726d295acf12efea2b463cd3..22ceea2deb22bc8bd082a5ad94de9a9ca02a4ec7 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -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 +@@ -277,7 +277,7 @@ public class Explosion { + d14 = entity instanceof Player && level.paperConfig.disableExplosionKnockback ? 0 : ProtectionEnchantment.getExplosionKnockbackAfterDampener((LivingEntity) entity, d13); // Paper - Disable explosion knockback } - entity.setDeltaMovement(entity.getDeltaMovement().add(d8 * d14, d9 * d14, d10 * d14)); @@ -227,7 +226,7 @@ index 5ef6b5ad4dd69a57595914c7af8422ee2f6ad054..e60410d2d1a09f935caffe0cfb9b6232 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 7b71073027f4cf79736546500ededdfbb83d968e..90e4d105754a1c8fba4e9b63e1c4f6096da3eabd 100644 +index a80f4dc0a642c744223a155232291ace6e007636..db023572478d44398ea0454f3c01eca382752b43 100644 --- a/src/main/java/net/minecraft/world/level/block/Block.java +++ b/src/main/java/net/minecraft/world/level/block/Block.java @@ -461,7 +461,7 @@ public class Block extends BlockBehaviour implements ItemLike { diff --git a/patches/server/0008-Optional-Force-Position-Updates.patch b/patches/server/0007-Optional-Force-Position-Updates.patch similarity index 80% rename from patches/server/0008-Optional-Force-Position-Updates.patch rename to patches/server/0007-Optional-Force-Position-Updates.patch index 56512b6..7625f10 100644 --- a/patches/server/0008-Optional-Force-Position-Updates.patch +++ b/patches/server/0007-Optional-Force-Position-Updates.patch @@ -5,10 +5,10 @@ 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 80e495688b00d1297357350f9abebe5fbbf24cd8..7d2a2d69241344593b691321ba859e5ba246d15d 100644 +index f997647a7ff29100acd5bab1d77ac3a6305e4717..2e618e8d930f95ef74497097f1ab205e712b2f58 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -60,7 +60,9 @@ public class PrimedTnt extends Entity { +@@ -63,7 +63,9 @@ public class PrimedTnt extends Entity { @Override public void tick() { @@ -19,12 +19,12 @@ index 80e495688b00d1297357350f9abebe5fbbf24cd8..7d2a2d69241344593b691321ba859e5b if (!this.isNoGravity()) { this.addDeltaMovement(0.0D, -0.04D, 0.0D); // Sakura - reduce movement allocations } -@@ -95,6 +97,14 @@ public class PrimedTnt extends Entity { +@@ -98,6 +100,14 @@ public class PrimedTnt extends Entity { } } + // Sakura start - configure force position updates -+ if (this.level.sakuraConfig().cannons.tnt.forcePositionUpdates) { ++ if (this.level.sakuraConfig.forcePositionUpdates) { + this.forcePositionUpdate(); + } + } @@ -32,5 +32,5 @@ index 80e495688b00d1297357350f9abebe5fbbf24cd8..7d2a2d69241344593b691321ba859e5b + private void forcePositionUpdate() { + // Sakura end - configure force position updates // Paper start - Optional prevent TNT from moving in water - if (!this.isRemoved() && this.wasTouchingWater && this.level.paperConfig().fixes.preventTntFromMovingInWater) { + if (!this.isRemoved() && this.wasTouchingWater && this.level.paperConfig.preventTntFromMovingInWater) { /* diff --git a/patches/server/0009-Load-Chunks-on-Movement.patch b/patches/server/0008-Load-Chunks-on-Movement.patch similarity index 81% rename from patches/server/0009-Load-Chunks-on-Movement.patch rename to patches/server/0008-Load-Chunks-on-Movement.patch index e1269f3..c9d4fb2 100644 --- a/patches/server/0009-Load-Chunks-on-Movement.patch +++ b/patches/server/0008-Load-Chunks-on-Movement.patch @@ -75,46 +75,46 @@ index a87f6380b2c387fb0cdd40d5087b5c93492e3c88..4db0a1b1270e2ff1ea1a4723b3dd2886 } diff --git a/src/main/java/net/minecraft/server/level/TicketType.java b/src/main/java/net/minecraft/server/level/TicketType.java -index 97d1ff2af23bac14e67bca5896843325aaa5bfc1..c90b265a9cd92d40960d5513d9585e47d93fed3c 100644 +index ae46429264e6a7e5c88b6b6a41a6df4db7b3e70d..1686abebbf0c99cd589f70c2f5259728f34f4f2a 100644 --- a/src/main/java/net/minecraft/server/level/TicketType.java +++ b/src/main/java/net/minecraft/server/level/TicketType.java -@@ -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 +@@ -33,6 +33,7 @@ public class TicketType { + public static final TicketType DELAY_UNLOAD = create("delay_unload", Long::compareTo, 300); // Paper + public static final TicketType REQUIRED_LOAD = create("required_load", Long::compareTo); // Paper - make sure getChunkAt does not fail + public static final TicketType CHUNK_RELIGHT = create("light_update", Long::compareTo); // Paper - ensure chunks stay loaded for lighting + 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 3b6efce07745df062d5d3ef60011718842217336..0025d08527f41c0d19f4a713ef072fae008cec25 100644 +index 078ec45f7e0b51f6b78f71d909d43b8966fc1b0a..67963fc50e1039192468a418335ba2bb581174cd 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -545,6 +545,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -432,6 +432,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { public boolean isPrimedTNT; public boolean isFallingBlock; // Sakura end - visibility api and command + public boolean loadChunks = false; // Sakura - load chunks on cannon entity movement - public Entity(EntityType type, Level world) { - this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -1393,8 +1394,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + // Paper start + /** +@@ -1309,8 +1310,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } } -- io.papermc.paper.util.CollisionUtil.getCollisions(world, this, collisionBox, potentialCollisions, false, this.level.paperConfig().chunks.preventMovingIntoUnloadedChunks, +- io.papermc.paper.util.CollisionUtil.getCollisions(world, this, collisionBox, potentialCollisions, false, true, - false, false, null, null); -+ io.papermc.paper.util.CollisionUtil.getCollisions(world, this, collisionBox, potentialCollisions, this.loadChunks, this.level.paperConfig().chunks.preventMovingIntoUnloadedChunks, // Sakura - load chunks on movement ++ io.papermc.paper.util.CollisionUtil.getCollisions(world, this, collisionBox, potentialCollisions, this.loadChunks, !this.loadChunks, // Sakura - load chunks on movement + false, this.loadChunks, false, null, null); // Sakura - load chunks on movement - 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 + if (io.papermc.paper.util.CollisionUtil.isCollidingWithBorderEdge(world.getWorldBorder(), collisionBox)) { io.papermc.paper.util.CollisionUtil.addBoxesToIfIntersects(world.getWorldBorder().getCollisionShape(), collisionBox, potentialCollisions); -@@ -4532,12 +4533,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4309,12 +4310,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { @Override public boolean shouldBeSaved() { -- return this.removalReason != null && !this.removalReason.shouldSave() ? false : (this.isPassenger() ? false : !this.isVehicle() || !this.hasAnyPlayerPassengers()); // Paper - rewrite chunk system - it should check if the entity has ANY player passengers -+ return this.removalReason != null && !this.removalReason.shouldSave() ? false : (this.loadChunks || this.isPassenger() ? false : !this.isVehicle() || !this.hasAnyPlayerPassengers()); // Sakura - used to determine whether a chunk should unload // Paper - rewrite chunk system - it should check if the entity has ANY player passengers +- return this.removalReason != null && !this.removalReason.shouldSave() ? false : (this.isPassenger() ? false : !this.isVehicle() || !this.hasExactlyOnePlayerPassenger()); ++ return this.removalReason != null && !this.removalReason.shouldSave() ? false : (this.loadChunks || this.isPassenger() ? false : !this.isVehicle() || !this.hasExactlyOnePlayerPassenger()); // Sakura - used to determine whether a chunk should unload } @Override @@ -125,34 +125,34 @@ index 3b6efce07745df062d5d3ef60011718842217336..0025d08527f41c0d19f4a713ef072fae 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 1a83f88e7759b168d6f3c2f6ed4532d65a7cf437..3559457024f5c9bef4c44a27514e338c7d2b4172 100644 +index 597efc61bdd46b951b62c2584a846942508983cf..e4a7d8decdd86b1cdd645ec36bee48792ef3a944 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -71,6 +71,7 @@ public class FallingBlockEntity extends Entity { +@@ -69,6 +69,7 @@ public class FallingBlockEntity extends Entity { this.dropItem = true; this.fallDamageMax = 40; this.isFallingBlock = true; // Sakura -+ this.loadChunks = world.sakuraConfig().cannons.loadChunks; // Sakura - falling blocks load chunks ++ this.loadChunks = world.sakuraConfig.loadChunks; // Sakura - falling blocks load chunks } 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 7d2a2d69241344593b691321ba859e5ba246d15d..5761b786f036df1516189edd67ea4439d64c6ea8 100644 +index 2e618e8d930f95ef74497097f1ab205e712b2f58..5cbda5c5d7f1a110548110959dfe1edddcc67def 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -28,6 +28,7 @@ public class PrimedTnt extends Entity { +@@ -31,6 +31,7 @@ public class PrimedTnt extends Entity { super(type, world); this.blocksBuilding = true; this.isPrimedTNT = true; // Sakura -+ this.loadChunks = world.sakuraConfig().cannons.loadChunks; // Sakura - tnt load chunks ++ this.loadChunks = world.sakuraConfig.loadChunks; // Sakura - tnt load chunks } 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 28e4b302284f955a73e75d0f4276d55fb51826f5..2bb7195bdb977de6b899cade0847cd6414f3eae2 100644 +index f667dafd44b6652788d3367cbbc76eef3bead23b..8a48d3234aa8819cdeeb85df1a37c72e341ca2ac 100644 --- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java +++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java -@@ -361,6 +361,17 @@ public class LevelChunk extends ChunkAccess { +@@ -368,6 +368,17 @@ public class LevelChunk extends ChunkAccess { } } // Paper end - optimise checkDespawn diff --git a/patches/server/0010-TPS-Graph-Command.patch b/patches/server/0009-TPS-Graph-Command.patch similarity index 90% rename from patches/server/0010-TPS-Graph-Command.patch rename to patches/server/0009-TPS-Graph-Command.patch index 19fc7c4..21c6afc 100644 --- a/patches/server/0010-TPS-Graph-Command.patch +++ b/patches/server/0009-TPS-Graph-Command.patch @@ -5,10 +5,10 @@ Subject: [PATCH] TPS Graph Command diff --git a/src/main/java/me/samsuik/sakura/command/SakuraCommands.java b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java -index 22676ec7a7ae9494b198e5e65e6be6d32e0feb85..6edc5195c3b496a12b17b2b9b528505d37ffdb12 100644 +index a5020f97cfeefe5eaadc22321d89518ed3aa4b37..80e31b13509bc13d4e52a01e6d72ee6d9b28cdc9 100644 --- a/src/main/java/me/samsuik/sakura/command/SakuraCommands.java +++ b/src/main/java/me/samsuik/sakura/command/SakuraCommands.java -@@ -4,6 +4,7 @@ import io.papermc.paper.command.PaperPluginsCommand; +@@ -3,6 +3,7 @@ package me.samsuik.sakura.command; import me.samsuik.sakura.command.subcommands.ConfigCommand; import me.samsuik.sakura.command.subcommands.FPSCommand; import me.samsuik.sakura.command.subcommands.VisualCommand; @@ -16,7 +16,7 @@ index 22676ec7a7ae9494b198e5e65e6be6d32e0feb85..6edc5195c3b496a12b17b2b9b528505d import me.samsuik.sakura.player.visibility.Visibility; import net.minecraft.server.MinecraftServer; import org.bukkit.command.Command; -@@ -21,6 +22,7 @@ public final class SakuraCommands { +@@ -19,6 +20,7 @@ public final class SakuraCommands { COMMANDS.put("tntvisibility", new VisualCommand(Visibility.Setting.TNT_VISIBILITY, "tnttoggle")); COMMANDS.put("sandvisibility", new VisualCommand(Visibility.Setting.SAND_VISIBILITY, "sandtoggle")); COMMANDS.put("minimal", new VisualCommand(Visibility.Setting.MINIMAL, "minimaltnt", "tntlag")); @@ -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 0fa8b271c58c74820461f7bec213062b266ec18b..321bd1d6c2cbf8384b08708abb837ed3ad4a0078 100644 +index 6c65c3235271d181ef5efc1263fe2161f1e6a157..7908e2f0aef64241db1a030f8ed4dbc85930fee9 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1097,6 +1097,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop entityManager; // Paper - rewrite chunk system - private final GameEventDispatcher gameEventDispatcher; + public final PersistentEntitySectionManager entityManager; public boolean noSave; + private final SleepStatus sleepStatus; diff --git a/src/main/java/net/minecraft/world/level/entity/EntityTickList.java b/src/main/java/net/minecraft/world/level/entity/EntityTickList.java index 4cdfc433df67afcd455422e9baf56f167dd712ae..0d64ec654fe7af4961facc2554df757deddad7f6 100644 --- a/src/main/java/net/minecraft/world/level/entity/EntityTickList.java @@ -488,7 +488,7 @@ index 4cdfc433df67afcd455422e9baf56f167dd712ae..0d64ec654fe7af4961facc2554df757d private void ensureActiveIsNotIterated() { // Paper - replace with better logic, do not delay removals diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java -index 612c3169c3463d702b85975e1db79ae6e47d60d0..2063a6c6ab0786aee51be027950c2a936f593b55 100644 +index d509187ca63963fdd7f1a44d89d2aa1a1b1ce3bd..56fe9e602df9ae6bf2bd3435203a5063eca8494e 100644 --- a/src/main/java/org/spigotmc/SpigotConfig.java +++ b/src/main/java/org/spigotmc/SpigotConfig.java @@ -283,7 +283,7 @@ public class SpigotConfig diff --git a/patches/server/0012-Slice-Packet-obfuscation-and-reduction.patch b/patches/server/0010-Slice-Packet-obfuscation-and-reduction.patch similarity index 66% rename from patches/server/0012-Slice-Packet-obfuscation-and-reduction.patch rename to patches/server/0010-Slice-Packet-obfuscation-and-reduction.patch index ea34b01..3931be1 100644 --- a/patches/server/0012-Slice-Packet-obfuscation-and-reduction.patch +++ b/patches/server/0010-Slice-Packet-obfuscation-and-reduction.patch @@ -19,18 +19,19 @@ The current packets modified/obfuscated are the following: # with packets instead of every single player within tracking distance diff --git a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java -index 37e193f57938047c8b886ed7d2816411392f94b4..6ca522b4a56eb210e15c914d13615ef497b33626 100644 +index 1d88edfd09a909044f6e3175af652914b4d06311..c5bcddb4562ce249e7676a72a5836efae700e27e 100644 --- a/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java +++ b/src/main/java/net/minecraft/network/syncher/SynchedEntityData.java -@@ -34,6 +34,7 @@ public class SynchedEntityData { - private final Int2ObjectMap> itemsById = new Int2ObjectOpenHashMap(); +@@ -34,6 +34,8 @@ public class SynchedEntityData { // private final ReadWriteLock lock = new ReentrantReadWriteLock(); // Spigot - not required + private boolean isEmpty = true; private boolean isDirty; + private boolean isForeignDirty; // Slice ++ private boolean packForeign; // Slice public SynchedEntityData(Entity trackedEntity) { this.entity = trackedEntity; -@@ -135,6 +136,12 @@ public class SynchedEntityData { +@@ -136,6 +138,12 @@ public class SynchedEntityData { } public void set(EntityDataAccessor key, T value) { @@ -43,7 +44,7 @@ index 37e193f57938047c8b886ed7d2816411392f94b4..6ca522b4a56eb210e15c914d13615ef4 SynchedEntityData.DataItem datawatcher_item = this.getItem(key); if (ObjectUtils.notEqual(value, datawatcher_item.getValue())) { -@@ -144,6 +151,12 @@ public class SynchedEntityData { +@@ -145,6 +153,12 @@ public class SynchedEntityData { this.isDirty = true; } @@ -56,11 +57,15 @@ index 37e193f57938047c8b886ed7d2816411392f94b4..6ca522b4a56eb210e15c914d13615ef4 } // CraftBukkit start - add method from above -@@ -153,6 +166,12 @@ public class SynchedEntityData { +@@ -154,6 +168,16 @@ public class SynchedEntityData { } // CraftBukkit end + // Slice start ++ public void packForeign(boolean shouldPackForeignData) { ++ this.packForeign = shouldPackForeignData; ++ } ++ + public boolean isForeignDirty() { + return this.isForeignDirty; + } @@ -69,55 +74,50 @@ index 37e193f57938047c8b886ed7d2816411392f94b4..6ca522b4a56eb210e15c914d13615ef4 public boolean isDirty() { return this.isDirty; } -@@ -185,6 +204,29 @@ public class SynchedEntityData { +@@ -178,18 +202,19 @@ public class SynchedEntityData { + + if (this.isDirty) { + // this.lock.readLock().lock(); // Spigot - not required ++ final boolean packForeignData = this.packForeign; // Slice + ObjectIterator objectiterator = this.itemsById.values().iterator(); + + while (objectiterator.hasNext()) { + SynchedEntityData.DataItem datawatcher_item = (SynchedEntityData.DataItem) objectiterator.next(); + +- if (datawatcher_item.isDirty()) { ++ if (datawatcher_item.isDirty(packForeignData)) { // Slice + datawatcher_item.setDirty(false); + if (list == null) { + list = Lists.newArrayList(); + } + +- list.add(datawatcher_item.copy()); ++ list.add(datawatcher_item.copy(packForeignData)); // Slice + } + } + +@@ -197,6 +222,7 @@ public class SynchedEntityData { + } + + this.isDirty = false; ++ this.isForeignDirty = false; // Slice return list; } -+ // Slice start -+ @Nullable -+ public List> packForeignDirty(List> unpackedData) { -+ List> list = null; -+ -+ for (DataValue dataItem : unpackedData) { -+ DataItem item = itemsById.get(dataItem.id()); -+ if (item.isDirty(true)) { -+ item.setForeignDirty(false); -+ -+ if (list == null) { -+ list = new ArrayList<>(); -+ } -+ -+ list.add(item.copy(true)); -+ } -+ } -+ -+ this.isForeignDirty = false; -+ return list; -+ } -+ // Slice end -+ - @Nullable - public List> getNonDefaultValues() { - List> list = null; -@@ -291,11 +333,14 @@ public class SynchedEntityData { +@@ -313,12 +339,44 @@ public class SynchedEntityData { + final EntityDataAccessor accessor; T value; - private final T initialValue; private boolean dirty; + @Nullable T foreignValue = null; // Slice + private boolean foreignDirty; // Slice public DataItem(EntityDataAccessor data, T value) { this.accessor = data; - this.initialValue = value; this.value = value; + this.dirty = true; + this.foreignDirty = true; // Slice - } - - public EntityDataAccessor getAccessor() { -@@ -322,6 +367,35 @@ public class SynchedEntityData { - return this.initialValue.equals(this.value); - } - ++ } ++ + // Slice start + public void setForeignValue(T foreignValue) { + this.foreignValue = foreignValue; @@ -142,20 +142,27 @@ index 37e193f57938047c8b886ed7d2816411392f94b4..6ca522b4a56eb210e15c914d13615ef4 + this.foreignDirty = dirty; + } + -+ public SynchedEntityData.DataValue copy(boolean foreign) { -+ return SynchedEntityData.DataValue.create(this.accessor, this.accessor.getSerializer().copy((foreign && this.foreignValue != null ? this.foreignValue : this.value))); -+ } -+ // Slice end -+ - public SynchedEntityData.DataValue value() { - return SynchedEntityData.DataValue.create(this.accessor, this.value); ++ public SynchedEntityData.DataItem copy(boolean foreign) { ++ return new SynchedEntityData.DataItem<>(this.accessor, this.accessor.getSerializer().copy((foreign && this.foreignValue != null ? this.foreignValue : this.value))); } ++ // Slice end + + public EntityDataAccessor getAccessor() { + return this.accessor; +@@ -338,6 +396,7 @@ public class SynchedEntityData { + + public void setDirty(boolean dirty) { + this.dirty = dirty; ++ this.foreignDirty &= dirty; // Slice + } + + public SynchedEntityData.DataItem copy() { diff --git a/src/main/java/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java -index 190e9761087baec5827d722a8281f0ffb6798341..18676547ee697bea691c0ee69df5906455c5f238 100644 +index f91e1a876ad4c46a7c92cead18947a941b4d9e68..96e45c6a8ac366bd9248b26389a5c99008d2ebf9 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java -@@ -129,7 +129,7 @@ public class ServerEntity { - } +@@ -121,7 +121,7 @@ public class ServerEntity { + this.sendDirtyEntityData(); } - if (this.tickCount % this.updateInterval == 0 || this.entity.hasImpulse || this.entity.getEntityData().isDirty()) { @@ -163,28 +170,21 @@ index 190e9761087baec5827d722a8281f0ffb6798341..18676547ee697bea691c0ee69df59064 int i; int j; -@@ -367,7 +367,15 @@ public class ServerEntity { +@@ -371,7 +371,9 @@ public class ServerEntity { + SynchedEntityData datawatcher = this.entity.getEntityData(); - if (list != null) { - this.trackedDataValues = datawatcher.getNonDefaultValues(); -- this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), list)); -+ // Slice start -+ if (!(this.entity instanceof ServerPlayer)) { -+ list = datawatcher.packForeignDirty(list); -+ } -+ -+ if (list != null) { -+ this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), list)); -+ } -+ // Slice end + if (datawatcher.isDirty()) { ++ datawatcher.packForeign(true); // Slice + this.broadcastAndSend(new ClientboundSetEntityDataPacket(this.entity.getId(), datawatcher, false)); ++ datawatcher.packForeign(false); // Slice } 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 c0fb35497cfab69e5d28a70a2756f0d74a406630..35c4253e1ee951c31958bb9275a4f497fd5b16bb 100644 +index 67963fc50e1039192468a418335ba2bb581174cd..296b7b5a3c5bd80f51a5cea3e37f08dca5df2c53 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -3131,7 +3131,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2989,7 +2989,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { this.entityData.markDirty(Entity.DATA_AIR_SUPPLY_ID); return; } @@ -194,10 +194,10 @@ index c0fb35497cfab69e5d28a70a2756f0d74a406630..35c4253e1ee951c31958bb9275a4f497 } 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 3559457024f5c9bef4c44a27514e338c7d2b4172..6b85eecde57a809391d531bb11d189d0a25ccfdc 100644 +index e4a7d8decdd86b1cdd645ec36bee48792ef3a944..39b27750df3c93c3b6481d1663b854750ee646db 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -107,7 +107,7 @@ public class FallingBlockEntity extends Entity { +@@ -105,7 +105,7 @@ public class FallingBlockEntity extends Entity { } public void setStartPos(BlockPos pos) { @@ -207,10 +207,10 @@ index 3559457024f5c9bef4c44a27514e338c7d2b4172..6b85eecde57a809391d531bb11d189d0 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 5761b786f036df1516189edd67ea4439d64c6ea8..c2f04fca63ebef48a3092b60c703277abcb9b586 100644 +index 5cbda5c5d7f1a110548110959dfe1edddcc67def..6a97e77b81359a6722293837088c01b6618a0976 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -171,7 +171,7 @@ public class PrimedTnt extends Entity { +@@ -174,7 +174,7 @@ public class PrimedTnt extends Entity { } public void setFuse(int fuse) { @@ -220,10 +220,10 @@ index 5761b786f036df1516189edd67ea4439d64c6ea8..c2f04fca63ebef48a3092b60c703277a 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 1116116e4ba6c5ecec400cd371b70b9e14efd92b..407401198c21dd5887aa3b7d86cdb112ef369007 100644 +index 2483d7df7f1bf94344afd38b37602c645a4a2dff..5c16235115a9233bce1f5b30bb020d105bdca3d1 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -637,7 +637,7 @@ public abstract class Player extends LivingEntity { +@@ -632,7 +632,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/0011-Use-Optimised-TrackedEntityMap.patch similarity index 77% rename from patches/server/0013-Use-Optimised-TrackedEntityMap.patch rename to patches/server/0011-Use-Optimised-TrackedEntityMap.patch index 8956b6f..6ce125b 100644 --- a/patches/server/0013-Use-Optimised-TrackedEntityMap.patch +++ b/patches/server/0011-Use-Optimised-TrackedEntityMap.patch @@ -5,15 +5,15 @@ 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 500d0b297de5234b4c622d407d511b161acc2233..c3b3e984f8a19252b6feabb9ba1f7169dcec2fa2 100644 +index 1dc2bc400afe5012fe03ea3799c100ed453d1148..759ac36b32eaddcc0cff4c2308030b692d6fc7f4 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -295,7 +295,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider - // Paper - rewrite chunk system +@@ -415,7 +415,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider + this.toDrop = new LongOpenHashSet(); this.tickingGenerated = new AtomicInteger(); this.playerMap = new PlayerMap(); - this.entityMap = new Int2ObjectOpenHashMap(); + this.entityMap = new me.samsuik.sakura.utils.collections.TrackedEntityChunkMap(); // Sakura - optimised tracked entity map this.chunkTypeCache = new Long2ByteOpenHashMap(); this.chunkSaveCooldowns = new Long2LongOpenHashMap(); - this.unloadQueue = Queues.newConcurrentLinkedQueue(); + this.structureManager = structureManager; diff --git a/patches/server/0014-Copy-EntityList-methods-to-BasicEntityList.patch b/patches/server/0012-Copy-EntityList-methods-to-BasicEntityList.patch similarity index 93% rename from patches/server/0014-Copy-EntityList-methods-to-BasicEntityList.patch rename to patches/server/0012-Copy-EntityList-methods-to-BasicEntityList.patch index 6b57432..6d20e79 100644 --- a/patches/server/0014-Copy-EntityList-methods-to-BasicEntityList.patch +++ b/patches/server/0012-Copy-EntityList-methods-to-BasicEntityList.patch @@ -5,10 +5,10 @@ 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 f597d65d56964297eeeed6c7e77703764178fee0..1d6b96fd6dae9524c31e71a778351e8b2d325b7f 100644 +index 47b5f75d9f27cf3ab947fd1f69cbd609fb9f2749..546c72143b7e94681b37a94f81be1303f608ae40 100644 --- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java +++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -@@ -24,6 +24,8 @@ import java.util.Iterator; +@@ -16,6 +16,8 @@ import java.util.Iterator; import java.util.List; import java.util.function.Predicate; @@ -17,7 +17,7 @@ index f597d65d56964297eeeed6c7e77703764178fee0..1d6b96fd6dae9524c31e71a778351e8b public final class ChunkEntitySlices { protected final int minSection; -@@ -298,6 +300,13 @@ public final class ChunkEntitySlices { +@@ -189,6 +191,13 @@ public final class ChunkEntitySlices { protected static final class BasicEntityList { @@ -31,7 +31,7 @@ index f597d65d56964297eeeed6c7e77703764178fee0..1d6b96fd6dae9524c31e71a778351e8b protected static final Entity[] EMPTY = new Entity[0]; protected static final int DEFAULT_CAPACITY = 4; -@@ -320,55 +329,52 @@ public final class ChunkEntitySlices { +@@ -211,55 +220,52 @@ public final class ChunkEntitySlices { return this.size; } diff --git a/patches/server/0015-Add-utility-methods-to-EntitySlices.patch b/patches/server/0013-Add-utility-methods-to-EntitySlices.patch similarity index 86% rename from patches/server/0015-Add-utility-methods-to-EntitySlices.patch rename to patches/server/0013-Add-utility-methods-to-EntitySlices.patch index 185fd96..0d655a3 100644 --- a/patches/server/0015-Add-utility-methods-to-EntitySlices.patch +++ b/patches/server/0013-Add-utility-methods-to-EntitySlices.patch @@ -5,12 +5,12 @@ 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 1d6b96fd6dae9524c31e71a778351e8b2d325b7f..ce231d8b230d4983b21c597357c0b22377e4bcca 100644 +index 546c72143b7e94681b37a94f81be1303f608ae40..f2753ad52b07236c702b41892ec98415b1dd7bbd 100644 --- a/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java +++ b/src/main/java/io/papermc/paper/world/ChunkEntitySlices.java -@@ -246,6 +246,12 @@ public final class ChunkEntitySlices { - - return true; +@@ -131,6 +131,12 @@ public final class ChunkEntitySlices { + } + } } + + // Sakura start @@ -21,7 +21,7 @@ index 1d6b96fd6dae9524c31e71a778351e8b2d325b7f..ce231d8b230d4983b21c597357c0b223 public void getHardCollidingEntities(final Entity except, final AABB box, final List into, final Predicate predicate) { this.hardCollidingEntities.getEntities(except, box, into, predicate); -@@ -424,6 +430,18 @@ public final class ChunkEntitySlices { +@@ -315,6 +321,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/0014-Optimise-paper-explosions.patch similarity index 89% rename from patches/server/0016-Optimise-paper-explosions.patch rename to patches/server/0014-Optimise-paper-explosions.patch index 95618e6..d2a6ba2 100644 --- a/patches/server/0016-Optimise-paper-explosions.patch +++ b/patches/server/0014-Optimise-paper-explosions.patch @@ -5,10 +5,10 @@ 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 e60410d2d1a09f935caffe0cfb9b6232c00b1c8c..0547588fba8cbb7871afd8601c9cb605f8bf09d2 100644 +index 22ceea2deb22bc8bd082a5ad94de9a9ca02a4ec7..2301773137d004b1fbfa030caea6a4f436d1beae 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -96,7 +96,196 @@ public class Explosion { +@@ -104,7 +104,196 @@ public class Explosion { this.damageCalculator = behavior == null ? this.makeDamageCalculator(entity) : behavior; } @@ -149,7 +149,7 @@ index e60410d2d1a09f935caffe0cfb9b6232c00b1c8c..0547588fba8cbb7871afd8601c9cb605 + 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) { ++ if (!com.destroystokyo.paper.PaperConfig.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); @@ -175,7 +175,7 @@ index e60410d2d1a09f935caffe0cfb9b6232c00b1c8c..0547588fba8cbb7871afd8601c9cb605 + 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.world.EntitySliceManager entityLookup = ((ServerLevel) this.level.getEntities()).entitySliceManager; + for (int chunkX = minChunkX; chunkX <= maxChunkX; ++chunkX) { + for (int chunkZ = minChunkZ; chunkZ <= maxChunkZ; ++chunkZ) { + io.papermc.paper.world.ChunkEntitySlices chunk = entityLookup.getChunk(chunkX, chunkZ); @@ -205,7 +205,7 @@ index e60410d2d1a09f935caffe0cfb9b6232c00b1c8c..0547588fba8cbb7871afd8601c9cb605 return (ExplosionDamageCalculator) (entity == null ? Explosion.EXPLOSION_DAMAGE_CALCULATOR : new EntityBasedExplosionDamageCalculator(entity)); } -@@ -148,76 +337,34 @@ public class Explosion { +@@ -156,76 +345,34 @@ public class Explosion { int i; int j; @@ -245,10 +245,10 @@ index e60410d2d1a09f935caffe0cfb9b6232c00b1c8c..0547588fba8cbb7871afd8601c9cb605 - 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) { +- if (!com.destroystokyo.paper.PaperConfig.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); +- if (extension instanceof PistonMovingBlockEntity && ((PistonMovingBlockEntity) extension).isSourcePiston()) { +- net.minecraft.core.Direction direction = iblockdata.getValue(PistonHeadBlock.FACING); - set.add(blockposition.relative(direction.getOpposite())); - } - } @@ -266,7 +266,7 @@ index e60410d2d1a09f935caffe0cfb9b6232c00b1c8c..0547588fba8cbb7871afd8601c9cb605 + 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()) { ++ if ((resistance + 0.3f) * 0.3f < (this.radius * 1.3f) && this.blockInteraction != Explosion.BlockInteraction.NONE) { + this.searchForBlocks(); } @@ -298,7 +298,7 @@ index e60410d2d1a09f935caffe0cfb9b6232c00b1c8c..0547588fba8cbb7871afd8601c9cb605 if (!entity.ignoreExplosion()) { double d7 = Math.sqrt(entity.distanceToSqr(vec3d)) / (double) f2; -@@ -243,17 +390,18 @@ public class Explosion { +@@ -253,12 +400,13 @@ public class Explosion { // - Damaging EntityEnderDragon does nothing // - EntityEnderDragon hitbock always covers the other parts and is therefore always present if (entity instanceof EnderDragonPart) { @@ -306,20 +306,15 @@ index e60410d2d1a09f935caffe0cfb9b6232c00b1c8c..0547588fba8cbb7871afd8601c9cb605 + 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))); +- if (list.contains(entityComplexPart)) { ++ if (entityComplexPart.getBoundingBox().intersects(bounds)) { // Sakura - optimise vanilla explosions + entityComplexPart.hurt(this.getDamageSource(), (float) ((int) ((d13 * d13 + d13) / 2.0D * 7.0D * (double) f2 + 1.0D))); } -@@ -264,7 +412,7 @@ public class Explosion { + } +@@ -268,7 +416,7 @@ public class Explosion { CraftEventFactory.entityDamage = null; if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled diff --git a/patches/server/0017-Store-Entity-Data-State.patch b/patches/server/0015-Store-Entity-Data-State.patch similarity index 86% rename from patches/server/0017-Store-Entity-Data-State.patch rename to patches/server/0015-Store-Entity-Data-State.patch index 14a2c8f..5d3bac3 100644 --- a/patches/server/0017-Store-Entity-Data-State.patch +++ b/patches/server/0015-Store-Entity-Data-State.patch @@ -46,10 +46,10 @@ index 0000000000000000000000000000000000000000..5b72f13e6fb5d9999940e640c0341c2e + } +} diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java -index 35c4253e1ee951c31958bb9275a4f497fd5b16bb..106e03e0eae24f47a49d2495e98cb30195b27013 100644 +index 296b7b5a3c5bd80f51a5cea3e37f08dca5df2c53..7e1868bb483adefdab085f753acd71c65cb9c8c5 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -546,6 +546,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -433,6 +433,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 @@ -57,15 +57,15 @@ index 35c4253e1ee951c31958bb9275a4f497fd5b16bb..106e03e0eae24f47a49d2495e98cb301 + private @Nullable me.samsuik.sakura.entity.EntityState entityState = null; + + public final Vec3 stuckSpeedMultiplier() { -+ return stuckSpeedMultiplier; ++ return this.stuckSpeedMultiplier; + } + + public final void storeEntityState() { -+ entityState = me.samsuik.sakura.entity.EntityState.of(this); ++ this.entityState = me.samsuik.sakura.entity.EntityState.of(this); + } + + public final @Nullable me.samsuik.sakura.entity.EntityState entityState() { -+ return entityState; ++ return this.entityState; + } + + public final boolean compareState(Entity to) { @@ -73,13 +73,13 @@ index 35c4253e1ee951c31958bb9275a4f497fd5b16bb..106e03e0eae24f47a49d2495e98cb301 + } + // Sakura end - store entity data/state - public Entity(EntityType type, Level world) { - this.id = Entity.ENTITY_COUNTER.incrementAndGet(); + // Paper start + /** diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index 00ebe6b2e3068a3b9c1c4a7566685191f21ed379..d80cdbbd9cd569e6db31950f05695c1cf476be3c 100644 +index 9c28594590c57ced725f3e0c6fdb9c6a5ab9bfa2..ff6c4664c22aca6a7be44e3ccb7bff543c6a2a1b 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -932,6 +932,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -942,6 +942,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/0016-Merge-Cannon-Entities.patch similarity index 84% rename from patches/server/0018-Merge-Cannon-Entities.patch rename to patches/server/0016-Merge-Cannon-Entities.patch index 2e54a9a..733fa61 100644 --- a/patches/server/0018-Merge-Cannon-Entities.patch +++ b/patches/server/0016-Merge-Cannon-Entities.patch @@ -169,10 +169,10 @@ index 0000000000000000000000000000000000000000..e63935c17e213bf60571d120ad9ce311 + +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 321bd1d6c2cbf8384b08708abb837ed3ad4a0078..1358f800a29ef15163442331100816bb418ae3f6 100644 +index 7908e2f0aef64241db1a030f8ed4dbc85930fee9..536dd6fd0317779e04f133d2ae32a251da9e4394 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1567,6 +1567,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 -@@ -727,6 +728,15 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -670,6 +671,15 @@ public class ServerLevel extends Level implements WorldGenLevel { entity.stopRiding(); } @@ -209,10 +209,10 @@ index 0aea28a20f775b5df2ae2f92e435c84152b4d4be..839ab14b901f7deae5c53626c16ff1e7 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 2946d081032f6d8481643b43420f23b9bd6184d6..33f3a18eb0ef90bc71f1f40c3fd057cc50d22b2b 100644 +index 7e1868bb483adefdab085f753acd71c65cb9c8c5..ff25112e1a270f32faf8b0a885166dc57848b5cf 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -565,6 +565,124 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -452,6 +452,121 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return to.entityState() != null && to.entityState().isCurrentState(this); } // Sakura end - store entity data/state @@ -224,39 +224,36 @@ index 2946d081032f6d8481643b43420f23b9bd6184d6..33f3a18eb0ef90bc71f1f40c3fd057cc + protected int stacked = 1; // default + + public final me.samsuik.sakura.entity.merge.MergeLevel getMergeLevel() { -+ return mergeLevel; ++ return this.mergeLevel; + } + + public final void setMergeLevel(me.samsuik.sakura.entity.merge.MergeLevel level) { -+ mergeLevel = level; ++ this.mergeLevel = level; + } + + public final int getStacked() { -+ return stacked; ++ return this.stacked; + } + + public final void setStacked(int stack) { -+ stacked = stack; ++ this.stacked = stack; + } + + public final List getMergeList() { -+ return mergeList; ++ return this.mergeList; + } + + public final long getPackedOrigin() { -+ var v = getOriginVector(); ++ org.bukkit.util.Vector v = this.getOriginVector(); + if (v == null) return Long.MIN_VALUE; -+ // Note: vector#getBlockN may not be 100% exact -+ // If there's any future issues at let's say 0.999999... -+ // giving an incorrect position change it to Mth instead. + return BlockPos.asLong(v.getBlockX(), v.getBlockY(), v.getBlockZ()); + } + + private boolean isSafeToSpawnMerge(Entity entity) { -+ return tickCount == 1 && originData != null -+ && originData.isAbleToOnSpawnMerge() // on spawn safety delay has passed -+ && originData == entity.originData // make sure it's the same group -+ && originData.isPositionRetained(entity.getPackedOrigin()); ++ return this.tickCount == 1 && this.originData != null ++ && this.originData.isAbleToOnSpawnMerge() // on spawn safety delay has passed ++ && this.originData == entity.originData // make sure it's the same group ++ && this.originData.isPositionRetained(entity.getPackedOrigin()); + } + + public boolean isMergeableType(@Nullable Entity previous) { @@ -264,15 +261,15 @@ index 2946d081032f6d8481643b43420f23b9bd6184d6..33f3a18eb0ef90bc71f1f40c3fd057cc + } + + public final boolean tryMergeInto(@Nullable Entity entity) { -+ if (mergeLevel.atLeast(me.samsuik.sakura.entity.merge.MergeLevel.LENIENT) && tickCount == 0) { -+ originData = level.mergeHistory.retrievePositions(this); ++ if (this.mergeLevel.atLeast(me.samsuik.sakura.entity.merge.MergeLevel.LENIENT) && this.tickCount == 0) { ++ this.originData = this.level.mergeHistory.retrievePositions(this); + } + + Entity mergeEntity = null; + + if (entity == null || entity.getType() != getType()) { + return false; // First entity -+ } else if (mergeLevel.atLeast(me.samsuik.sakura.entity.merge.MergeLevel.SPAWN) && entity.isSafeToSpawnMerge(this)) { ++ } else if (this.mergeLevel.atLeast(me.samsuik.sakura.entity.merge.MergeLevel.SPAWN) && entity.isSafeToSpawnMerge(this)) { + // "SPAWN" merges entities one gametick after they have spawned. Merging is + // only possible after it has been established that the entity is safe to + // merge by collecting information on the entities that merge together over time. @@ -280,20 +277,20 @@ index 2946d081032f6d8481643b43420f23b9bd6184d6..33f3a18eb0ef90bc71f1f40c3fd057cc + } else { + // "STRICT" merges entities with the same properties, position, momentum and OOE. + // This is considered safe to use, and will not break cannon mechanics. -+ if (mergeLevel.atLeast(me.samsuik.sakura.entity.merge.MergeLevel.STRICT) && compareState(entity)) { ++ if (this.mergeLevel.atLeast(me.samsuik.sakura.entity.merge.MergeLevel.STRICT) && this.compareState(entity)) { + mergeEntity = entity; + } + + // "LENIENT" merges entities aggressively by tracking the entities that have + // previously merged. This is a hybrid of "SPAWN" and "STRICT" merging, with the + // visuals of "STRICT" merging and better merging potential of "SPAWN" merging. -+ if (mergeLevel.atLeast(me.samsuik.sakura.entity.merge.MergeLevel.LENIENT) && mergeEntity == null && originData != null) { -+ mergeEntity = originData.findFirstEntityInSamePosition(this); ++ if (this.mergeLevel.atLeast(me.samsuik.sakura.entity.merge.MergeLevel.LENIENT) && mergeEntity == null && this.originData != null) { ++ mergeEntity = this.originData.findFirstEntityInSamePosition(this); + } + } + -+ if (mergeEntity != null && isSafeToMergeInto(mergeEntity)) { -+ mergeInto(mergeEntity); ++ if (mergeEntity != null && this.isSafeToMergeInto(mergeEntity)) { ++ this.mergeInto(mergeEntity); + return true; + } + @@ -310,8 +307,8 @@ index 2946d081032f6d8481643b43420f23b9bd6184d6..33f3a18eb0ef90bc71f1f40c3fd057cc + + private void mergeInto(Entity entity) { + entity.mergeList.add(this); -+ entity.mergeList.addAll(mergeList); -+ entity.stacked += stacked; ++ entity.mergeList.addAll(this.mergeList); ++ entity.stacked += this.stacked; + + for (Entity mergedEntity : this.mergeList) { + mergedEntity.updateEntityHandle(entity); @@ -335,17 +332,17 @@ index 2946d081032f6d8481643b43420f23b9bd6184d6..33f3a18eb0ef90bc71f1f40c3fd057cc + } + // Sakura end - cannon entity merging - public Entity(EntityType type, Level world) { - this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -611,6 +729,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + // Paper start + /** +@@ -548,6 +663,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); -+ this.mergeLevel = level.sakuraConfig().cannons.mergeLevel; // Sakura ++ this.mergeLevel = this.level.sakuraConfig.mergeLevel; // Sakura } public boolean isColliding(BlockPos pos, BlockState state) { -@@ -2317,6 +2436,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2194,6 +2310,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { nbt.putBoolean("Paper.FreezeLock", true); } // Paper end @@ -357,7 +354,7 @@ index 2946d081032f6d8481643b43420f23b9bd6184d6..33f3a18eb0ef90bc71f1f40c3fd057cc return nbt; } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); -@@ -2484,6 +2608,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -2359,6 +2480,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { freezeLocked = nbt.getBoolean("Paper.FreezeLock"); } // Paper end @@ -369,10 +366,10 @@ index 2946d081032f6d8481643b43420f23b9bd6184d6..33f3a18eb0ef90bc71f1f40c3fd057cc } catch (Throwable throwable) { CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); -@@ -4529,6 +4658,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - return; - } - // Paper end - rewrite chunk system +@@ -4306,6 +4432,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + + @Override + public final void setRemoved(Entity.RemovalReason reason) { + // Sakura start + if (reason == RemovalReason.DISCARDED && !mergeList.isEmpty()) { + level.mergeHistory.markPositions(this); @@ -382,10 +379,10 @@ index 2946d081032f6d8481643b43420f23b9bd6184d6..33f3a18eb0ef90bc71f1f40c3fd057cc 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 6b85eecde57a809391d531bb11d189d0a25ccfdc..2965d963ca7eaf7bfd010094c08aa8b80af79a13 100644 +index 39b27750df3c93c3b6481d1663b854750ee646db..229477058eb28798edf684dffe3640aab87bc189 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -129,6 +129,60 @@ public class FallingBlockEntity extends Entity { +@@ -127,6 +127,60 @@ public class FallingBlockEntity extends Entity { return !this.isRemoved(); } @@ -446,7 +443,7 @@ index 6b85eecde57a809391d531bb11d189d0a25ccfdc..2965d963ca7eaf7bfd010094c08aa8b8 @Override public void tick() { // Paper start - fix sand duping -@@ -208,6 +262,7 @@ public class FallingBlockEntity extends Entity { +@@ -206,6 +260,7 @@ public class FallingBlockEntity extends Entity { return; } // CraftBukkit end @@ -455,10 +452,10 @@ index 6b85eecde57a809391d531bb11d189d0a25ccfdc..2965d963ca7eaf7bfd010094c08aa8b8 ((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 c2f04fca63ebef48a3092b60c703277abcb9b586..b9ee3115ea6f2929d8cd66ab189acc1614126574 100644 +index 6a97e77b81359a6722293837088c01b6618a0976..0c75fe840119040898a10a931dcb9b3e51c8cdcf 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -59,6 +59,44 @@ public class PrimedTnt extends Entity { +@@ -62,6 +62,44 @@ public class PrimedTnt extends Entity { return !this.isRemoved(); } @@ -503,7 +500,7 @@ index c2f04fca63ebef48a3092b60c703277abcb9b586..b9ee3115ea6f2929d8cd66ab189acc16 @Override public void tick() { if (level.spigotConfig.maxTntTicksPerTick > 0 && ++level.spigotConfig.currentPrimedTnt > level.spigotConfig.maxTntTicksPerTick) { -@@ -86,6 +124,7 @@ public class PrimedTnt extends Entity { +@@ -89,6 +127,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(); @@ -512,19 +509,19 @@ index c2f04fca63ebef48a3092b60c703277abcb9b586..b9ee3115ea6f2929d8cd66ab189acc16 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 d80cdbbd9cd569e6db31950f05695c1cf476be3c..05ee07f06721b16801ae7420da7705b64db52eed 100644 +index ff6c4664c22aca6a7be44e3ccb7bff543c6a2a1b..894d920305302127b5cf9ee2bfba239475e76144 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -283,6 +283,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - public abstract ResourceKey getTypeKey(); - +@@ -266,6 +266,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + } + // Sakura end 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, 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 + public abstract ResourceKey getTypeKey(); + 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 caa0fbe5cad9cdc11d6e4af92bc627990cd8204c..6923a34e82e49004b29a77e57fea8c2a00180299 100644 +index 9d1d59fe26eff0640906037aba93e73dda433d0d..f44d79ed9f3b93712ce8b40c020955d19ec8fb9d 100644 --- a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java @@ -79,7 +79,7 @@ public abstract class BasePressurePlateBlock extends Block { @@ -536,7 +533,7 @@ index caa0fbe5cad9cdc11d6e4af92bc627990cd8204c..6923a34e82e49004b29a77e57fea8c2a boolean flag = output > 0; boolean flag1 = j > 0; -@@ -158,6 +158,12 @@ public abstract class BasePressurePlateBlock extends Block { +@@ -170,6 +170,12 @@ public abstract class BasePressurePlateBlock extends Block { return PushReaction.DESTROY; } @@ -550,10 +547,10 @@ index caa0fbe5cad9cdc11d6e4af92bc627990cd8204c..6923a34e82e49004b29a77e57fea8c2a 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 e3bcb7fc520abcb1854d89b65ebc947cc885caa6..f9786ba3bead763e4f880b99e0e0cae64fb62613 100644 +index fe343966b9e30ff3487579b46d4b005be3d76b63..6bac29219028a91fa49a79b9bb5513b50d896770 100644 --- a/src/main/java/net/minecraft/world/level/block/WeightedPressurePlateBlock.java +++ b/src/main/java/net/minecraft/world/level/block/WeightedPressurePlateBlock.java -@@ -32,6 +32,11 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock { +@@ -28,6 +28,11 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock { @Override protected int getSignalStrength(Level world, BlockPos pos) { @@ -565,7 +562,7 @@ index e3bcb7fc520abcb1854d89b65ebc947cc885caa6..f9786ba3bead763e4f880b99e0e0cae6 // CraftBukkit start // int i = Math.min(world.getEntitiesOfClass(Entity.class, BlockPressurePlateWeighted.TOUCH_AABB.move(blockposition)).size(), this.maxWeight); int i = 0; -@@ -51,7 +56,7 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock { +@@ -47,7 +52,7 @@ public class WeightedPressurePlateBlock extends BasePressurePlateBlock { // We only want to block turning the plate on if all events are cancelled if (!cancellable.isCancelled()) { diff --git a/patches/server/0019-Replace-explosion-density-cache.patch b/patches/server/0017-Replace-explosion-density-cache.patch similarity index 86% rename from patches/server/0019-Replace-explosion-density-cache.patch rename to patches/server/0017-Replace-explosion-density-cache.patch index 233bcc9..0620771 100644 --- a/patches/server/0019-Replace-explosion-density-cache.patch +++ b/patches/server/0017-Replace-explosion-density-cache.patch @@ -129,10 +129,10 @@ index 0000000000000000000000000000000000000000..d7e24638f07f243502004970ab4ce646 + } +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index 1358f800a29ef15163442331100816bb418ae3f6..f14abf532e9cd80e0a270826143c7489a4f4a5e4 100644 +index 536dd6fd0317779e04f133d2ae32a251da9e4394..532abec1030f28df6ee0629ca3aef2766311bd99 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1568,6 +1568,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 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 + public abstract ResourceKey getTypeKey(); + 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 6923a34e82e49004b29a77e57fea8c2a00180299..56dce65e4d5070f7b08b07c4412ef95a54f3e1c7 100644 +index f44d79ed9f3b93712ce8b40c020955d19ec8fb9d..4c5dbc6a6a03c9504ca7de35462d369305b08edd 100644 --- a/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BasePressurePlateBlock.java @@ -99,6 +99,11 @@ public abstract class BasePressurePlateBlock extends Block { @@ -223,10 +223,10 @@ index 6923a34e82e49004b29a77e57fea8c2a00180299..56dce65e4d5070f7b08b07c4412ef95a 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 004dce26ff073f1de52a84cd425c4f60fdab5e50..89928300608865a2cea6834fa0ac98a0796140e0 100644 +index 5e973eb53b240615e70b7d46ef4dc17b907ecaf9..5655aa0f5c91bb9c65a00d2f8a6fb6426d2a1c5d 100644 --- a/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/src/main/java/net/minecraft/world/level/block/TripWireHookBlock.java -@@ -164,6 +164,11 @@ public class TripWireHookBlock extends Block { +@@ -163,6 +163,11 @@ public class TripWireHookBlock extends Block { blockposition1 = pos.relative(enumdirection, j); Direction enumdirection1 = enumdirection.getOpposite(); @@ -237,7 +237,7 @@ index 004dce26ff073f1de52a84cd425c4f60fdab5e50..89928300608865a2cea6834fa0ac98a0 + // 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); + this.playSound(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 68cc6f2a78a06293a29317fda72ab3ee79b3533a..a142bf12ef0b8c8d41cab846da2e161700f2db2b 100644 --- a/src/main/java/net/minecraft/world/phys/AABB.java diff --git a/patches/server/0020-Optimise-explosions-in-protected-regions.patch b/patches/server/0018-Optimise-explosions-in-protected-regions.patch similarity index 79% rename from patches/server/0020-Optimise-explosions-in-protected-regions.patch rename to patches/server/0018-Optimise-explosions-in-protected-regions.patch index 1b91794..0fc240b 100644 --- a/patches/server/0020-Optimise-explosions-in-protected-regions.patch +++ b/patches/server/0018-Optimise-explosions-in-protected-regions.patch @@ -5,10 +5,10 @@ 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 becf60978e6c13ac5100886be1a6adae4d361207..a12ad5380bfbdba20c1c5e568da7b0cfac5a55db 100644 +index 8ef317a79db184db69b2a699c280b5c7c2663259..cf9dd1ffdacdfe1c26ca15ca17a20fe46a81b20d 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -281,6 +281,22 @@ public class Explosion { +@@ -289,6 +289,22 @@ public class Explosion { } } @@ -16,7 +16,7 @@ index becf60978e6c13ac5100886be1a6adae4d361207..a12ad5380bfbdba20c1c5e568da7b0cf + protected final boolean isRegionUnprotected() { + // As an optimisation, check if a plugin has cancelled or cleared the blockList. + // This is relatively sane on factions and cannon servers, but mileage may vary. -+ if (this.source != null && this.level.sakuraConfig().cannons.explosion.optimiseProtectedRegions) { ++ if (this.source != null && this.level.sakuraConfig.optimiseProtectedRegions) { + Location location = new Location(this.level.getWorld(), this.x, this.y, this.z); + List blocks = new ObjectArrayList<>(1); + blocks.add(location.getBlock()); @@ -31,12 +31,12 @@ index becf60978e6c13ac5100886be1a6adae4d361207..a12ad5380bfbdba20c1c5e568da7b0cf private ExplosionDamageCalculator makeDamageCalculator(@Nullable Entity entity) { if (entity instanceof net.minecraft.world.entity.item.PrimedTnt) { return EXPLOSION_DAMAGE_CALCULATOR; -@@ -350,7 +366,7 @@ public class Explosion { +@@ -358,7 +374,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.interactsWithBlocks()) { -+ if ((resistance + 0.3f) * 0.3f < (this.radius * 1.3f) && this.interactsWithBlocks() && this.isRegionUnprotected()) { // Sakura - optimise protected explosions +- if ((resistance + 0.3f) * 0.3f < (this.radius * 1.3f) && this.blockInteraction != Explosion.BlockInteraction.NONE) { ++ if ((resistance + 0.3f) * 0.3f < (this.radius * 1.3f) && this.blockInteraction != Explosion.BlockInteraction.NONE && this.isRegionUnprotected()) { // Sakura - optimise protected explosions this.searchForBlocks(); } diff --git a/patches/server/0021-Specialised-Explosions.patch b/patches/server/0019-Specialised-Explosions.patch similarity index 93% rename from patches/server/0021-Specialised-Explosions.patch rename to patches/server/0019-Specialised-Explosions.patch index 1d02835..f4f9484 100644 --- a/patches/server/0021-Specialised-Explosions.patch +++ b/patches/server/0019-Specialised-Explosions.patch @@ -205,7 +205,7 @@ index 0000000000000000000000000000000000000000..e654f48386e21e049facb6d90b356117 +} 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..52c1990bd3bcfe0a3f6e70748fca42f3e3994da4 +index 0000000000000000000000000000000000000000..2e46df5cda2dc2812a10cd54ff7b128f9c50b361 --- /dev/null +++ b/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java @@ -0,0 +1,192 @@ @@ -297,7 +297,7 @@ index 0000000000000000000000000000000000000000..52c1990bd3bcfe0a3f6e70748fca42f3 + protected void postExplosion(List foundBlocks, boolean 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) { ++ if (!destroyedBlocks && this.level.sakuraConfig.avoidRedundantBlockSearches) { + this.wrapped++; + } else { + this.wrapped = 7; @@ -402,10 +402,10 @@ index 0000000000000000000000000000000000000000..52c1990bd3bcfe0a3f6e70748fca42f3 + } +} diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java -index 839ab14b901f7deae5c53626c16ff1e74b57a531..ab5472c27f94e196a2747466f8721173cef937fc 100644 +index 451f7facb950c98b67713d6e7d012bf25bb89e31..71f96f0716e6001ea74690d43160c08ca6a3024e 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -1752,6 +1752,12 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1657,6 +1657,12 @@ public class ServerLevel extends Level implements WorldGenLevel { explosion.clearToBlow(); } @@ -418,7 +418,7 @@ index 839ab14b901f7deae5c53626c16ff1e74b57a531..ab5472c27f94e196a2747466f8721173 Iterator iterator = this.players.iterator(); while (iterator.hasNext()) { -@@ -1771,7 +1777,7 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1676,7 +1682,7 @@ public class ServerLevel extends Level implements WorldGenLevel { } } @@ -428,10 +428,10 @@ index 839ab14b901f7deae5c53626c16ff1e74b57a531..ab5472c27f94e196a2747466f8721173 @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 b9ee3115ea6f2929d8cd66ab189acc1614126574..f3330d5219edfac9fd23b10e3f97e999fc3b5b0e 100644 +index 0c75fe840119040898a10a931dcb9b3e51c8cdcf..88f83ef060b818e31bbb636a45048b2cdb1d4fec 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -73,28 +73,7 @@ public class PrimedTnt extends Entity { +@@ -76,28 +76,7 @@ public class PrimedTnt extends Entity { && (tnt.entityState().fallDistance() == fallDistance || tnt.entityState().fallDistance() > 2.5f && fallDistance > 2.5f); } @@ -462,12 +462,12 @@ index b9ee3115ea6f2929d8cd66ab189acc1614126574..f3330d5219edfac9fd23b10e3f97e999 @Override diff --git a/src/main/java/net/minecraft/world/level/Explosion.java b/src/main/java/net/minecraft/world/level/Explosion.java -index 738015f5aa1e405623ad41ea4f039bde9a2ec572..74cd5133a7944ecb7ab76a4d1be3b77214b64161 100644 +index cf9dd1ffdacdfe1c26ca15ca17a20fe46a81b20d..a10d18a7573f9174708be0bf9dd912b8ce7eb0f5 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -55,12 +55,14 @@ public class Explosion { +@@ -59,12 +59,14 @@ public class Explosion { private final Explosion.BlockInteraction blockInteraction; - private final RandomSource random; + private final Random random; private final Level level; - private final double x; - private final double y; @@ -483,11 +483,11 @@ index 738015f5aa1e405623ad41ea4f039bde9a2ec572..74cd5133a7944ecb7ab76a4d1be3b772 + 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 { + private final List toBlow; +@@ -455,7 +457,10 @@ public class Explosion { Player entityhuman = (Player) entity; - if (!entityhuman.isSpectator() && (!entityhuman.isCreative() || !entityhuman.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Disable explosion knockback + if (!entityhuman.isSpectator() && (!entityhuman.isCreative() || !entityhuman.getAbilities().flying) && !level.paperConfig.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 = new Vec3(d8 * d13, d9 * d13, d10 * d13); @@ -496,7 +496,7 @@ index 738015f5aa1e405623ad41ea4f039bde9a2ec572..74cd5133a7944ecb7ab76a4d1be3b772 } } } -@@ -683,7 +688,7 @@ public class Explosion { +@@ -656,7 +661,7 @@ public class Explosion { private BlockInteraction() {} } // Paper start - Optimize explosions @@ -506,22 +506,22 @@ index 738015f5aa1e405623ad41ea4f039bde9a2ec572..74cd5133a7944ecb7ab76a4d1be3b772 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 66eeaa8941b4e10614e79d01bd9601d48aa44eb0..5c3aa8335b47a8ac0956c6caed3569f9244f4bd6 100644 +index b7407df002b7addf854a321f62c26003f7fdc86b..cd770809cc3720b63681d447f3970ff59b6b4c61 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -1004,7 +1004,14 @@ public abstract class Level implements LevelAccessor, AutoCloseable { - } +@@ -982,7 +982,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); + public Explosion explode(@Nullable Entity entity, @Nullable DamageSource damageSource, @Nullable ExplosionDamageCalculator behavior, double x, double y, double z, float power, boolean createFire, Explosion.BlockInteraction destructionType) { +- Explosion explosion = new Explosion(this, entity, damageSource, behavior, x, y, z, power, createFire, destructionType); + // 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); ++ explosion = new me.samsuik.sakura.explosion.special.TntExplosion(this, tnt, damageSource, behavior, x, y, z, power, createFire, destructionType); + } else { -+ explosion = new Explosion(this, entity, damageSource, behavior, x, y, z, power, createFire, explosion_effect1); ++ explosion = new Explosion(this, entity, damageSource, behavior, x, y, z, power, createFire, destructionType); + } + // Sakura end - specialised explosions explosion.explode(); - explosion.finalizeExplosion(particles); + explosion.finalizeExplosion(true); diff --git a/patches/server/0022-Optimise-Fast-Movement.patch b/patches/server/0020-Optimise-Fast-Movement.patch similarity index 91% rename from patches/server/0022-Optimise-Fast-Movement.patch rename to patches/server/0020-Optimise-Fast-Movement.patch index 1aa9fc6..7204e54 100644 --- a/patches/server/0022-Optimise-Fast-Movement.patch +++ b/patches/server/0020-Optimise-Fast-Movement.patch @@ -5,10 +5,10 @@ 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 33f3a18eb0ef90bc71f1f40c3fd057cc50d22b2b..9c12e45314fccc48dc0b64e813afe75aab88c84a 100644 +index ff25112e1a270f32faf8b0a885166dc57848b5cf..09c2513a49fde78e3376f3c62e743fb2b29c82e8 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -1142,6 +1142,92 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1075,6 +1075,92 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } // Paper end - detailed watchdog information @@ -63,7 +63,7 @@ index 33f3a18eb0ef90bc71f1f40c3fd057cc50d22b2b..9c12e45314fccc48dc0b64e813afe75a + } + + this.onGround = this.verticalCollision && movement.y < 0.0D; -+ BlockPos blockposition = this.getOnPosLegacy(); ++ BlockPos blockposition = this.getOnPos(); + BlockState iblockdata = this.level.getBlockState(blockposition); + + this.checkFallDamage(vec3d1.y, this.onGround, iblockdata, blockposition); @@ -101,7 +101,7 @@ index 33f3a18eb0ef90bc71f1f40c3fd057cc50d22b2b..9c12e45314fccc48dc0b64e813afe75a public void move(MoverType movementType, Vec3 movement) { // Paper start - detailed watchdog information io.papermc.paper.util.TickThread.ensureTickThread("Cannot move an entity off-main"); -@@ -1494,6 +1580,88 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1407,6 +1493,88 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return offsetFactor; } @@ -163,7 +163,7 @@ index 33f3a18eb0ef90bc71f1f40c3fd057cc50d22b2b..9c12e45314fccc48dc0b64e813afe75a + // Copied from the collide method below + io.papermc.paper.util.CollisionUtil.getCollisions( + this.level, this, collisionBox, bbList, -+ this.loadChunks, this.level.paperConfig().chunks.preventMovingIntoUnloadedChunks, // Sakura - load chunks on movement ++ this.loadChunks, this.level.paperConfig.preventMovingIntoUnloadedChunks, // Sakura - load chunks on movement + false, this.loadChunks, false, null, null // Sakura - load chunks on movement + ); + } @@ -191,10 +191,10 @@ index 33f3a18eb0ef90bc71f1f40c3fd057cc50d22b2b..9c12e45314fccc48dc0b64e813afe75a // Paper start - optimise collisions // 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 2965d963ca7eaf7bfd010094c08aa8b80af79a13..33a247ac617c17e7c0cf1614ca485398c60ea579 100644 +index 229477058eb28798edf684dffe3640aab87bc189..8f02b04cb3193c3ed164193868d216f7320962f5 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -200,7 +200,7 @@ public class FallingBlockEntity extends Entity { +@@ -198,7 +198,7 @@ public class FallingBlockEntity extends Entity { this.addDeltaMovement(0.0D, -0.04D, 0.0D); // Sakura - reduce movement allocations } @@ -204,15 +204,15 @@ index 2965d963ca7eaf7bfd010094c08aa8b80af79a13..33a247ac617c17e7c0cf1614ca485398 // 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 f3330d5219edfac9fd23b10e3f97e999fc3b5b0e..ab4bcf2383e060a348eb172d1b36310cbbe17f72 100644 +index 88f83ef060b818e31bbb636a45048b2cdb1d4fec..0a130c840a20d357c7375f94d36e83a8ea8a59ee 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -85,7 +85,7 @@ public class PrimedTnt extends Entity { +@@ -88,7 +88,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 entity height nerf - if (this.level.paperConfig().fixes.tntEntityHeightNerf.test(v -> this.getY() > v)) { + if (this.level.paperConfig.entityTNTHeightNerf != 0 && this.getY() > this.level.paperConfig.entityTNTHeightNerf) { this.discard(); diff --git a/patches/server/0024-isPushedByFluid-API.patch b/patches/server/0021-isPushedByFluid-API.patch similarity index 75% rename from patches/server/0024-isPushedByFluid-API.patch rename to patches/server/0021-isPushedByFluid-API.patch index aa9ab08..2091226 100644 --- a/patches/server/0024-isPushedByFluid-API.patch +++ b/patches/server/0021-isPushedByFluid-API.patch @@ -5,18 +5,18 @@ 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 9c12e45314fccc48dc0b64e813afe75aab88c84a..2f8a5f5434bdcf1d992df9cb2a3ee8028f395a53 100644 +index 09c2513a49fde78e3376f3c62e743fb2b29c82e8..587c5e456e47ab67b378800562e21545786957c4 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -683,6 +683,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -567,6 +567,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } } // Sakura end - cannon entity merging + public boolean pushedByFluid = true; // Sakura - entity pushed by fluid api - public Entity(EntityType type, Level world) { - this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -3955,7 +3956,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + // Paper start + /** +@@ -3791,7 +3792,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public boolean isPushedByFluid() { @@ -26,10 +26,10 @@ index 9c12e45314fccc48dc0b64e813afe75aab88c84a..2f8a5f5434bdcf1d992df9cb2a3ee802 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 750ac80eed6ba03e138dd4c03f57ddfe4a123276..b70fb77f360e970c689d7f996d479674f6de0d90 100644 +index a92755211e3d42934b5efaa3f201c6c19ab7d2b4..5704137d5f1d8cf43ecfe383ba1c54267eccdef6 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -@@ -523,6 +523,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -502,6 +502,18 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return this.entity.isInWater(); } diff --git a/patches/server/0025-Cannon-Mechanics.patch b/patches/server/0022-Cannon-Mechanics.patch similarity index 68% rename from patches/server/0025-Cannon-Mechanics.patch rename to patches/server/0022-Cannon-Mechanics.patch index 6eebf7c..6d2d688 100644 --- a/patches/server/0025-Cannon-Mechanics.patch +++ b/patches/server/0022-Cannon-Mechanics.patch @@ -5,10 +5,10 @@ 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 33a247ac617c17e7c0cf1614ca485398c60ea579..ad8a3f5c41bcd2860d6872655b6b2ef25b6d349c 100644 +index 8f02b04cb3193c3ed164193868d216f7320962f5..3498e0dfb457445994f1a1ae20a0a6aaba7c82b5 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -64,6 +64,7 @@ public class FallingBlockEntity extends Entity { +@@ -62,6 +62,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 - Auto expire setting @@ -16,50 +16,50 @@ index 33a247ac617c17e7c0cf1614ca485398c60ea579..ad8a3f5c41bcd2860d6872655b6b2ef2 public FallingBlockEntity(EntityType type, Level world) { super(type, world); -@@ -72,6 +73,7 @@ public class FallingBlockEntity extends Entity { +@@ -70,6 +71,7 @@ public class FallingBlockEntity extends Entity { this.fallDamageMax = 40; this.isFallingBlock = true; // Sakura - this.loadChunks = world.sakuraConfig().cannons.loadChunks; // Sakura - falling blocks load chunks -+ this.heightParity = world.sakuraConfig().cannons.mechanics.fallingBlockParity; // Sakura - configure cannon mechanics + this.loadChunks = world.sakuraConfig.loadChunks; // Sakura - falling blocks load chunks ++ this.heightParity = world.sakuraConfig.fallingBlockParity; // Sakura - configure cannon mechanics } public FallingBlockEntity(Level world, double x, double y, double z, BlockState block) { -@@ -182,6 +184,12 @@ public class FallingBlockEntity extends Entity { +@@ -180,6 +182,12 @@ public class FallingBlockEntity extends Entity { return itemEntity; } // Sakura end + // Sakura start + @Override + public final double getEyeY() { -+ return heightParity ? getY() : super.getEyeY(); ++ return this.heightParity ? this.getY() : super.getEyeY(); + } + // Sakura end @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 ab4bcf2383e060a348eb172d1b36310cbbe17f72..683d44becb21689b95ba4babd235ee9199f4f6d8 100644 +index 0a130c840a20d357c7375f94d36e83a8ea8a59ee..c221dc8c1a271ec5b8ef8489274e9b1484aae03a 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -42,6 +42,12 @@ public class PrimedTnt extends Entity { +@@ -45,6 +45,12 @@ public class PrimedTnt extends Entity { this.yo = y; this.zo = z; this.owner = igniter; + // Sakura start -+ switch (world.sakuraConfig().cannons.mechanics.tntSpread) { -+ case NONE -> multiplyDeltaMovement(0, 0, 0); -+ case Y -> multiplyDeltaMovement(0, 1, 0); ++ switch (world.sakuraConfig.tntSpread) { ++ case NONE -> this.multiplyDeltaMovement(0, 0, 0); ++ case Y -> this.multiplyDeltaMovement(0, 1, 0); + } + // Sakura end } @Override -@@ -199,7 +205,7 @@ public class PrimedTnt extends Entity { +@@ -207,7 +213,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 && this.level.sakuraConfig().cannons.mechanics.tntFlowsInWater && super.isPushedByFluid(); // Sakura - cannon mechanics +- return !level.paperConfig.preventTntFromMovingInWater && super.isPushedByFluid(); ++ return !level.paperConfig.preventTntFromMovingInWater && this.level.sakuraConfig.tntFlowsInWater && super.isPushedByFluid(); // Sakura - cannon mechanics } // Paper end } diff --git a/patches/server/0026-Cache-MovingBlockEntity-collision-shape.patch b/patches/server/0023-Cache-MovingBlockEntity-collision-shape.patch similarity index 89% rename from patches/server/0026-Cache-MovingBlockEntity-collision-shape.patch rename to patches/server/0023-Cache-MovingBlockEntity-collision-shape.patch index c1a7dd9..3fa0b01 100644 --- a/patches/server/0026-Cache-MovingBlockEntity-collision-shape.patch +++ b/patches/server/0023-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 221c5d080d55326e458c1182823d6b49224ef498..26e11fbe0ddeed23d286e83adfa7d2a5e9cf88c8 100644 +index 94bd47212b05f66ebc81966eec3bc0abda76252c..e6361fd5ffd4ad908b6ade9ae7b1b52cc0a7c603 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 -@@ -43,6 +43,11 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -40,6 +40,11 @@ public class PistonMovingBlockEntity extends BlockEntity { private float progressO; private long lastTicked; private int deathTicks; @@ -20,7 +20,7 @@ index 221c5d080d55326e458c1182823d6b49224ef498..26e11fbe0ddeed23d286e83adfa7d2a5 public PistonMovingBlockEntity(BlockPos pos, BlockState state) { super(BlockEntityType.PISTON, pos, state); -@@ -336,6 +341,18 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -332,6 +337,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/0024-Optimise-TNT-fluid-state-and-pushing.patch similarity index 76% rename from patches/server/0027-Optimise-TNT-fluid-state-and-pushing.patch rename to patches/server/0024-Optimise-TNT-fluid-state-and-pushing.patch index 7f30977..91ba85b 100644 --- a/patches/server/0027-Optimise-TNT-fluid-state-and-pushing.patch +++ b/patches/server/0024-Optimise-TNT-fluid-state-and-pushing.patch @@ -5,23 +5,23 @@ 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 2f8a5f5434bdcf1d992df9cb2a3ee8028f395a53..16934f888e0a7609bd803bc988d5307e27eae793 100644 +index 587c5e456e47ab67b378800562e21545786957c4..c07a34f6b2a31f0235fd1b9ac9385b087d14ad57 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -2018,7 +2018,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1918,7 +1918,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return this.isInWater() || flag; } - void updateInWaterStateAndDoWaterCurrentPushing() { + protected void updateInWaterStateAndDoWaterCurrentPushing() { // Sakura - Entity entity = this.getVehicle(); - - if (entity instanceof Boat) { + if (this.getVehicle() instanceof Boat) { + this.wasTouchingWater = false; + } else if (this.updateFluidHeightAndDoFluidPushing(FluidTags.WATER, 0.014D)) { 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 683d44becb21689b95ba4babd235ee9199f4f6d8..bf6d7411716ff73c2f65965ec9bc33f70f719e19 100644 +index c221dc8c1a271ec5b8ef8489274e9b1484aae03a..92fe040d9b43cb2a2ff8118335eaa007c0828115 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -81,6 +81,19 @@ public class PrimedTnt extends Entity { +@@ -84,6 +84,19 @@ public class PrimedTnt extends Entity { } // Sakura - specialised explosions // Sakura end diff --git a/patches/server/0029-Despawn-falling-blocks-inside-moving-pistons.patch b/patches/server/0025-Despawn-falling-blocks-inside-moving-pistons.patch similarity index 78% rename from patches/server/0029-Despawn-falling-blocks-inside-moving-pistons.patch rename to patches/server/0025-Despawn-falling-blocks-inside-moving-pistons.patch index 91c5045..b8ac27e 100644 --- a/patches/server/0029-Despawn-falling-blocks-inside-moving-pistons.patch +++ b/patches/server/0025-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 ad8a3f5c41bcd2860d6872655b6b2ef25b6d349c..e9e65c72f3bdd193ea5acf614c68a11f828ece10 100644 +index 3498e0dfb457445994f1a1ae20a0a6aaba7c82b5..2e7675905e2e826950cd6b4c930dbaa062feec56 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -241,7 +241,7 @@ public class FallingBlockEntity extends Entity { +@@ -239,7 +239,7 @@ public class FallingBlockEntity extends Entity { } } - 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.onGround && !flag1 || this.level.sakuraConfig.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/0026-Configure-Entity-Knockback.patch similarity index 75% rename from patches/server/0030-Configure-Entity-Knockback.patch rename to patches/server/0026-Configure-Entity-Knockback.patch index 766d011..814201e 100644 --- a/patches/server/0030-Configure-Entity-Knockback.patch +++ b/patches/server/0026-Configure-Entity-Knockback.patch @@ -5,33 +5,33 @@ 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 c10c3f46fe29733c4b7fab7dd6d68a76905488eb..3b4ba5c9e2aeab85f79a2d3a583017cd84f3c1cd 100644 +index d6ef140bcc35b10f78f2ec2f10c8a153395fc9df..5c967f9c77e75a84c4f584f729a00c4177082a8d 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -1475,7 +1475,7 @@ public abstract class LivingEntity extends Entity { +@@ -1436,7 +1436,7 @@ public abstract class LivingEntity extends Entity { } 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 +- this.knockback(0.4000000059604645D, d0, d1, entity1); ++ this.knockback((float) this.level.sakuraConfig.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 { +@@ -1483,7 +1483,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); // Paper -+ target.knockback((float) this.level.sakuraConfig().players.knockback.shieldHitKnockback, target.getX() - this.getX(), target.getZ() - this.getZ(), this); // Sakura - configure entity knockback // Paper +- target.knockback(0.5D, target.getX() - this.getX(), target.getZ() - this.getZ(), this); ++ target.knockback((float) this.level.sakuraConfig.shieldHitKnockback, target.getX() - this.getX(), target.getZ() - this.getZ(), this); // Sakura - configure entity knockback } private boolean checkTotemDeathProtection(DamageSource source) { -@@ -1834,13 +1834,26 @@ public abstract class LivingEntity extends Entity { +@@ -1793,13 +1793,26 @@ public abstract class LivingEntity extends Entity { } 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 ++ strength *= 1.0D - this.getAttributeValue(Attributes.KNOCKBACK_RESISTANCE) * this.level.sakuraConfig.knockbackResistanceModifier; // Sakura - configure entity knockback if (strength > 0.0D) { this.hasImpulse = true; Vec3 vec3d = this.getDeltaMovement(); @@ -40,12 +40,12 @@ index c10c3f46fe29733c4b7fab7dd6d68a76905488eb..3b4ba5c9e2aeab85f79a2d3a583017cd - 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 + this.level.sakuraConfig().players.knockback.knockbackVertical.or(strength); ++ double velocityY = vec3d.y / 2.0D + this.level.sakuraConfig.knockbackVertical.orElse(strength); + double velocityZ = vec3d.z / 2.0D - vec3d1.z; + + // this.onGround() ? Math.min(0.4D, vec3d.y / 2.0D + d0) : vec3d.y -+ if (!this.level.sakuraConfig().players.knockback.verticalKnockbackRequireGround || this.onGround) { -+ velocityY = Math.min(this.level.sakuraConfig().players.knockback.knockbackVerticalLimit, velocityY); ++ if (!this.level.sakuraConfig.verticalKnockbackRequireGround || this.onGround) { ++ velocityY = Math.min(this.level.sakuraConfig.knockbackVerticalLimit, velocityY); + } else { + velocityY = vec3d.y; + } @@ -56,27 +56,27 @@ index c10c3f46fe29733c4b7fab7dd6d68a76905488eb..3b4ba5c9e2aeab85f79a2d3a583017cd 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 407401198c21dd5887aa3b7d86cdb112ef369007..0807d9d33131bf36b02f075e2150eaf33774ad27 100644 +index 5c16235115a9233bce1f5b30bb020d105bdca3d1..92a7962edb01d5ef36a9e35cc0b6bacc879ccff2 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 { +@@ -181,6 +181,7 @@ public abstract class Player extends LivingEntity { + // Paper start 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; -@@ -1265,7 +1266,7 @@ public abstract class Player extends LivingEntity { +@@ -1229,7 +1230,7 @@ public abstract class Player extends LivingEntity { byte b0 = 0; int i = b0 + EnchantmentHelper.getKnockbackBonus(this); - if (this.isSprinting() && flag) { -+ if (this.isSprinting() && (!this.level.sakuraConfig().players.knockback.sprinting.requireFullAttack || flag)) { // Sakura ++ if (this.isSprinting() && (!this.level.sakuraConfig.sprintingRequireFullAttack || 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; -@@ -1315,10 +1316,26 @@ public abstract class Player extends LivingEntity { +@@ -1279,10 +1280,26 @@ public abstract class Player extends LivingEntity { if (flag5) { if (i > 0) { @@ -88,8 +88,8 @@ index 407401198c21dd5887aa3b7d86cdb112ef369007..0807d9d33131bf36b02f075e2150eaf3 + 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.sprintingKnockbackDelay.orElse(0)) { ++ knockbackToApply = this.level.sakuraConfig.sprintingExtraKnockback; + this.lastSprintKnockback = millis; + } + // -0.5 is to negate the vanilla sprinting knockback @@ -100,31 +100,31 @@ index 407401198c21dd5887aa3b7d86cdb112ef369007..0807d9d33131bf36b02f075e2150eaf3 + } 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); // 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 -+ target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * extraKnockback), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * extraKnockback), this); // Paper +- 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)); ++ target.push((double) (-Mth.sin(this.getYRot() * 0.017453292F) * extraKnockback), 0.1D, (double) (Mth.cos(this.getYRot() * 0.017453292F) * extraKnockback)); + // Sakura end - configure extra sprinting knockback } this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D)); -@@ -1340,7 +1357,7 @@ public abstract class Player extends LivingEntity { +@@ -1304,7 +1321,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(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 ++ entityliving.knockback((float) this.level.sakuraConfig.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 15fb5ee374b19366ebb23181896fb943e95819f0..70016e105066a16d19ebdf631cc3ef0a03466e3a 100644 +index 3789a0db398766f0fbc9e5ac5bf4228a0a0dac88..5ad727d59f67a49c2ed5cb09be11c86e0b74d9f0 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java -@@ -291,6 +291,12 @@ public class FishingHook extends Projectile { +@@ -290,6 +290,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.fishingHooksApplyKnockback) { + Entity entity = entityHitResult.getEntity(); + entity.hurt(net.minecraft.world.damagesource.DamageSource.thrown(this, this.getOwner()), 0.0f); + } diff --git a/patches/server/0031-Explosion-Durable-Blocks.patch b/patches/server/0027-Explosion-Durable-Blocks.patch similarity index 86% rename from patches/server/0031-Explosion-Durable-Blocks.patch rename to patches/server/0027-Explosion-Durable-Blocks.patch index 9c8a66b..6f6ecf8 100644 --- a/patches/server/0031-Explosion-Durable-Blocks.patch +++ b/patches/server/0027-Explosion-Durable-Blocks.patch @@ -74,10 +74,10 @@ index 0000000000000000000000000000000000000000..c58e52f7cc012babf4235e405e5fb501 + +} diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java -index f14abf532e9cd80e0a270826143c7489a4f4a5e4..bd62b4de0da6f30fa87333889b15857fffc48666 100644 +index 532abec1030f28df6ee0629ca3aef2766311bd99..4a2934ae818292b517e87d2cb7d113fea8ce3491 100644 --- a/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java -@@ -1569,6 +1569,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop= 0.0f && (this.level.sakuraConfig().cannons.explosion.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) { ++ if (material != null && material.resistance() >= 0.0f && (this.level.sakuraConfig.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) { + return Optional.of(material.resistance()); + } + } @@ -159,16 +159,16 @@ index 74cd5133a7944ecb7ab76a4d1be3b77214b64161..411a2eeb6e8fabf0b755e7938396e1e2 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(); +@@ -545,6 +559,16 @@ public class Explosion { + BlockPos blockposition = (BlockPos) iterator.next(); BlockState iblockdata = this.level.getBlockState(blockposition); Block block = iblockdata.getBlock(); + // Sakura start - explosion durable blocks -+ if (this.level.sakuraConfig().cannons.explosion.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt) { ++ if (this.level.sakuraConfig.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt) { + me.samsuik.sakura.explosion.durable.DurableMaterial material = this.level.localConfig().config(blockposition).durableMaterials.get(block); + + if (material != null && material.durability() >= 0 && !this.level.durabilityManager.damage(blockposition, material)) { -+ objectlistiterator.remove(); ++ iterator.remove(); + continue; + } + } @@ -177,14 +177,14 @@ index 74cd5133a7944ecb7ab76a4d1be3b77214b64161..411a2eeb6e8fabf0b755e7938396e1e2 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 562ce3115ff6814f52872eb0e36a95d255ea4187..f22a538e37835c0424b8f87c9bef1e6fd0764718 100644 +index cd770809cc3720b63681d447f3970ff59b6b4c61..4c4c709cf9e4a9d4d8b210e6160652ddbdac3dae 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -285,6 +285,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { +@@ -268,6 +268,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 retrieval methods with search limits - public void getLimitedEntities(Entity except, AABB box, Predicate predicate, List into, int limit, int search) { + public abstract ResourceKey getTypeKey(); + diff --git a/patches/server/0032-Destroy-Waterlogged-Blocks.patch b/patches/server/0028-Destroy-Waterlogged-Blocks.patch similarity index 74% rename from patches/server/0032-Destroy-Waterlogged-Blocks.patch rename to patches/server/0028-Destroy-Waterlogged-Blocks.patch index d077066..a648418 100644 --- a/patches/server/0032-Destroy-Waterlogged-Blocks.patch +++ b/patches/server/0028-Destroy-Waterlogged-Blocks.patch @@ -5,15 +5,15 @@ 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 411a2eeb6e8fabf0b755e7938396e1e239ea1ff4..06d6ed111de0349f4e4f382021f91056ae71fb86 100644 +index 09f6cff6b88e4297bd85e308c596b25bfe58d76a..d1a813d35fa624558b9ef8cc9fa0e1c5fb7c2423 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -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)) { +@@ -315,6 +315,11 @@ public class Explosion { + if (material != null && material.resistance() >= 0.0f && (this.level.sakuraConfig.allowNonTntBreakingDurableBlocks || this.source instanceof net.minecraft.world.entity.item.PrimedTnt)) { return Optional.of(material.resistance()); } + // Sakura start - destroy water logged blocks -+ if (!fluidState.isEmpty() && !(block instanceof net.minecraft.world.level.block.LiquidBlock) && this.level.sakuraConfig().cannons.explosion.destroyWaterloggedBlocks) { ++ if (!fluidState.isEmpty() && !(block instanceof net.minecraft.world.level.block.LiquidBlock) && this.level.sakuraConfig.destroyWaterloggedBlocks) { + return Optional.of(-0.3f); + } + // Sakura end - destroy water logged blocks diff --git a/patches/server/0033-Falling-Block-Stacking-Restrictions.patch b/patches/server/0029-Falling-Block-Stacking-Restrictions.patch similarity index 84% rename from patches/server/0033-Falling-Block-Stacking-Restrictions.patch rename to patches/server/0029-Falling-Block-Stacking-Restrictions.patch index 5507fb2..4016116 100644 --- a/patches/server/0033-Falling-Block-Stacking-Restrictions.patch +++ b/patches/server/0029-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 e9e65c72f3bdd193ea5acf614c68a11f828ece10..abf1ddbb6f8fc6dd7dadf9c7a244863b1b89a473 100644 +index 2e7675905e2e826950cd6b4c930dbaa062feec56..8a55094ae2791707946cf1646eba42887ecce663 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -259,7 +259,7 @@ public class FallingBlockEntity extends Entity { +@@ -257,7 +257,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 && this.level.sakuraConfig().cannons.sand.isFallingBlockInBounds(this)) { // Sakura ++ if (flag2 && flag4 && this.level.sakuraConfig.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/0034-Added-list-of-ItemEntity-s-that-ignore-explosions.patch b/patches/server/0030-Added-list-of-ItemEntity-s-that-ignore-explosions.patch similarity index 67% rename from patches/server/0034-Added-list-of-ItemEntity-s-that-ignore-explosions.patch rename to patches/server/0030-Added-list-of-ItemEntity-s-that-ignore-explosions.patch index eb8e171..83bb740 100644 --- a/patches/server/0034-Added-list-of-ItemEntity-s-that-ignore-explosions.patch +++ b/patches/server/0030-Added-list-of-ItemEntity-s-that-ignore-explosions.patch @@ -5,17 +5,17 @@ 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 f0ccdfbd7d7be8c6e302609accf8fe9cac8885c4..b0b0ccd50276919e799eaa93f75904216e8e98b4 100644 +index 336d753bbd836e2a08207c5e3d41acbe2b72543f..23a9496188fb0b482d170ef906631df0e6e62fd3 100644 --- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java -@@ -87,6 +87,17 @@ public class ItemEntity extends Entity { +@@ -83,6 +83,17 @@ public class ItemEntity extends Entity { this.bobOffs = entity.bobOffs; } + // Sakura start + @Override + public boolean ignoreExplosion() { -+ if (this.level.sakuraConfig().entity.items.explosionResistantItems.contains(this.getItem().getItem())) { ++ if (this.level.sakuraConfig.explosionResistantItems.contains(this.getItem().getItem())) { + return true; + } else { + return super.ignoreExplosion(); @@ -24,5 +24,5 @@ index f0ccdfbd7d7be8c6e302609accf8fe9cac8885c4..b0b0ccd50276919e799eaa93f7590421 + // Sakura end + @Override - public boolean dampensVibrations() { - return this.getItem().is(ItemTags.DAMPENS_VIBRATIONS); + public boolean occludesVibrations() { + return this.getItem().is(ItemTags.OCCLUDES_VIBRATION_SIGNALS); diff --git a/patches/server/0035-Add-option-to-disable-entity-ai.patch b/patches/server/0031-Add-option-to-disable-entity-ai.patch similarity index 71% rename from patches/server/0035-Add-option-to-disable-entity-ai.patch rename to patches/server/0031-Add-option-to-disable-entity-ai.patch index f79ce06..6b461a6 100644 --- a/patches/server/0035-Add-option-to-disable-entity-ai.patch +++ b/patches/server/0031-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 49b983064ea810382b6112f5dc7f93ba4e5710bd..36eeb27679b2d1868cc9dc77f0df0f80e3c7333f 100644 +index e3227a806d9e19923783122ea94ae19e7dbe71da..64837b382bb3a1570b9136a94008e2f8fadaa4b3 100644 --- a/src/main/java/net/minecraft/world/entity/Mob.java +++ b/src/main/java/net/minecraft/world/entity/Mob.java -@@ -860,7 +860,7 @@ public abstract class Mob extends LivingEntity { +@@ -825,7 +825,7 @@ public abstract class Mob extends LivingEntity { @Override protected final void serverAiStep() { ++this.noActionTime; - 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 (!this.aware || this.level.sakuraConfig.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/0032-Consistent-Explosion-Radius.patch similarity index 80% rename from patches/server/0036-Consistent-Explosion-Radius.patch rename to patches/server/0032-Consistent-Explosion-Radius.patch index c827f35..3b9e16e 100644 --- a/patches/server/0036-Consistent-Explosion-Radius.patch +++ b/patches/server/0032-Consistent-Explosion-Radius.patch @@ -5,18 +5,18 @@ 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 +index d1a813d35fa624558b9ef8cc9fa0e1c5fb7c2423..076d353e59757232bc2bb3a19dcb3d7ed70d5edd 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; +@@ -72,6 +72,7 @@ public class Explosion { + private final List 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 { + public Explosion(Level world, @Nullable Entity entity, double x, double y, double z, float power) { + this(world, entity, x, y, z, power, false, Explosion.BlockInteraction.DESTROY); +@@ -104,6 +105,7 @@ public class Explosion { this.blockInteraction = destructionType; this.damageSource = damageSource == null ? DamageSource.explosion(this) : damageSource; this.damageCalculator = behavior == null ? this.makeDamageCalculator(entity) : behavior; @@ -24,7 +24,7 @@ index 06d6ed111de0349f4e4f382021f91056ae71fb86..0157727b9849e40d555460faf33e8a88 } // Sakura start - optimise vanilla explosions -@@ -172,7 +174,7 @@ public class Explosion { +@@ -180,7 +182,7 @@ public class Explosion { double rayY = explosionRays[ray++]; double rayZ = explosionRays[ray++]; diff --git a/patches/server/0037-Remove-spigot-max-tnt-per-tick.patch b/patches/server/0033-Remove-spigot-max-tnt-per-tick.patch similarity index 85% rename from patches/server/0037-Remove-spigot-max-tnt-per-tick.patch rename to patches/server/0033-Remove-spigot-max-tnt-per-tick.patch index 0235526..4d42a42 100644 --- a/patches/server/0037-Remove-spigot-max-tnt-per-tick.patch +++ b/patches/server/0033-Remove-spigot-max-tnt-per-tick.patch @@ -5,10 +5,10 @@ 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 bf6d7411716ff73c2f65965ec9bc33f70f719e19..0aed01b24e17aed7f5f7845ced78f64f57cabac3 100644 +index 92fe040d9b43cb2a2ff8118335eaa007c0828115..e97729f2d8febac1740678840566f8beb4f07cdc 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -97,9 +97,7 @@ public class PrimedTnt extends Entity { +@@ -100,9 +100,7 @@ public class PrimedTnt extends Entity { @Override public void tick() { diff --git a/patches/server/0038-Option-to-configure-entity-water-sensitivity.patch b/patches/server/0034-Option-to-configure-entity-water-sensitivity.patch similarity index 85% rename from patches/server/0038-Option-to-configure-entity-water-sensitivity.patch rename to patches/server/0034-Option-to-configure-entity-water-sensitivity.patch index deb24ae..676075e 100644 --- a/patches/server/0038-Option-to-configure-entity-water-sensitivity.patch +++ b/patches/server/0034-Option-to-configure-entity-water-sensitivity.patch @@ -5,10 +5,10 @@ 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 +index 5c967f9c77e75a84c4f584f729a00c4177082a8d..94a98385742888544815e24ff39338f604d4ca86 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 { +@@ -3371,7 +3371,7 @@ public abstract class LivingEntity extends Entity { } } // Paper end diff --git a/patches/server/0039-Configure-cannon-physics-by-version.patch b/patches/server/0035-Configure-cannon-physics-by-version.patch similarity index 87% rename from patches/server/0039-Configure-cannon-physics-by-version.patch rename to patches/server/0035-Configure-cannon-physics-by-version.patch index 21d0dcd..28f1752 100644 --- a/patches/server/0039-Configure-cannon-physics-by-version.patch +++ b/patches/server/0035-Configure-cannon-physics-by-version.patch @@ -57,7 +57,7 @@ index e654f48386e21e049facb6d90b356117af2bace6..a6b4cae3f04cda71629b5da3a08a8c4c 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 52c1990bd3bcfe0a3f6e70748fca42f3e3994da4..49a698d9e5559aac4943b4b0ae3ced1305717f3c 100644 +index 2e46df5cda2dc2812a10cd54ff7b128f9c50b361..901f49d09886edf6afcb814cd5ab8de2e089b896 100644 --- a/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java +++ b/src/main/java/me/samsuik/sakura/explosion/special/TntExplosion.java @@ -34,6 +34,13 @@ public final class TntExplosion extends SpecialisedExplosion { @@ -75,10 +75,10 @@ index 52c1990bd3bcfe0a3f6e70748fca42f3e3994da4..49a698d9e5559aac4943b4b0ae3ced13 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 16934f888e0a7609bd803bc988d5307e27eae793..4b35f249ee880e07acd0e0b642e86f6486a6ded8 100644 +index c07a34f6b2a31f0235fd1b9ac9385b087d14ad57..2f9a4f0d458edfbff5979f9cde39eae1f8f922fb 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -362,7 +362,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -301,7 +301,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { private final double[] pistonDeltas; private long pistonDeltasGameTime; private EntityDimensions dimensions; @@ -87,7 +87,7 @@ index 16934f888e0a7609bd803bc988d5307e27eae793..4b35f249ee880e07acd0e0b642e86f64 public boolean isInPowderSnow; public boolean wasInPowderSnow; public boolean wasOnFire; -@@ -684,6 +684,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -568,6 +568,13 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } // Sakura end - cannon entity merging public boolean pushedByFluid = true; // Sakura - entity pushed by fluid api @@ -99,9 +99,9 @@ index 16934f888e0a7609bd803bc988d5307e27eae793..4b35f249ee880e07acd0e0b642e86f64 + } + // Sakura end - physics version api - public Entity(EntityType type, Level world) { - this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -1149,7 +1156,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + // Paper start + /** +@@ -1082,7 +1089,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 { @@ -110,7 +110,7 @@ index 16934f888e0a7609bd803bc988d5307e27eae793..4b35f249ee880e07acd0e0b642e86f64 movement = this.limitPistonMovement(movement); if (movement.equals(Vec3.ZERO)) { return; -@@ -1167,8 +1174,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1100,8 +1107,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { Vec3 vec3d1 = this.collideScan(movement); double d0 = vec3d1.lengthSqr(); @@ -121,7 +121,7 @@ index 16934f888e0a7609bd803bc988d5307e27eae793..4b35f249ee880e07acd0e0b642e86f64 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) { -@@ -1204,6 +1211,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1137,6 +1144,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (this.horizontalCollision) { Vec3 vec3d2 = this.getDeltaMovement(); @@ -134,7 +134,7 @@ index 16934f888e0a7609bd803bc988d5307e27eae793..4b35f249ee880e07acd0e0b642e86f64 this.setDeltaMovement(flag ? 0.0D : vec3d2.x, vec3d2.y, flag1 ? 0.0D : vec3d2.z); } -@@ -1244,7 +1257,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1177,7 +1190,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(); @@ -143,7 +143,7 @@ index 16934f888e0a7609bd803bc988d5307e27eae793..4b35f249ee880e07acd0e0b642e86f64 this.activatedTick = Math.max(this.activatedTick, MinecraftServer.currentTick + 20); // Paper this.activatedImmunityTick = Math.max(this.activatedImmunityTick, MinecraftServer.currentTick + 20); // Paper movement = this.limitPistonMovement(movement); -@@ -1271,8 +1284,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1204,8 +1217,8 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { Vec3 vec3d1 = this.collide(movement); double d0 = vec3d1.lengthSqr(); @@ -154,7 +154,7 @@ index 16934f888e0a7609bd803bc988d5307e27eae793..4b35f249ee880e07acd0e0b642e86f64 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) { -@@ -1308,6 +1321,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1241,6 +1254,12 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { if (this.horizontalCollision) { Vec3 vec3d2 = this.getDeltaMovement(); @@ -167,7 +167,7 @@ index 16934f888e0a7609bd803bc988d5307e27eae793..4b35f249ee880e07acd0e0b642e86f64 this.setDeltaMovement(flag ? 0.0D : vec3d2.x, vec3d2.y, flag1 ? 0.0D : vec3d2.z); } -@@ -1596,7 +1615,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1509,7 +1528,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } else { final AABB bb = currBoundingBox.expandTowards(movement.x, movement.y, movement.z); this.collectCollisions(bb, potentialCollisionsBB); @@ -176,7 +176,7 @@ index 16934f888e0a7609bd803bc988d5307e27eae793..4b35f249ee880e07acd0e0b642e86f64 } } -@@ -1605,7 +1624,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1518,7 +1537,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { double y = movement.y; double z = movement.z; @@ -188,7 +188,7 @@ index 16934f888e0a7609bd803bc988d5307e27eae793..4b35f249ee880e07acd0e0b642e86f64 if (y != 0.0) { y = this.scanY(currBoundingBox, y, bbList); -@@ -1708,7 +1730,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -1621,7 +1643,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { io.papermc.paper.util.CollisionUtil.addBoxesToIfIntersects(world.getWorldBorder().getCollisionShape(), collisionBox, potentialCollisions); } @@ -197,25 +197,11 @@ index 16934f888e0a7609bd803bc988d5307e27eae793..4b35f249ee880e07acd0e0b642e86f64 if (stepHeight > 0.0 && (this.onGround || (limitedMoveVector.y != movement.y && movement.y < 0.0)) -@@ -1827,8 +1849,11 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - - protected void checkInsideBlocks() { - AABB axisalignedbb = this.getBoundingBox(); -- 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 = 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)) { - 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 abf1ddbb6f8fc6dd7dadf9c7a244863b1b89a473..05457d0a8fedeb66340486f8c82b2a694fe09378 100644 +index 8a55094ae2791707946cf1646eba42887ecce663..c366486bc65bb331566f5831c0980364b7e00526 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -86,6 +86,8 @@ public class FallingBlockEntity extends Entity { +@@ -84,6 +84,8 @@ public class FallingBlockEntity extends Entity { this.yo = y; this.zo = z; this.setStartPos(this.blockPosition()); @@ -224,7 +210,7 @@ index abf1ddbb6f8fc6dd7dadf9c7a244863b1b89a473..05457d0a8fedeb66340486f8c82b2a69 } public static FallingBlockEntity fall(Level world, BlockPos pos, BlockState state) { -@@ -98,7 +100,11 @@ public class FallingBlockEntity extends Entity { +@@ -96,7 +98,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()).isCancelled()) return entityfallingblock; // CraftBukkit @@ -237,12 +223,8 @@ index abf1ddbb6f8fc6dd7dadf9c7a244863b1b89a473..05457d0a8fedeb66340486f8c82b2a69 world.addFreshEntity(entityfallingblock, spawnReason); // CraftBukkit return entityfallingblock; } -@@ -187,9 +193,46 @@ public class FallingBlockEntity extends Entity { - // Sakura start - @Override - public final double getEyeY() { -- return heightParity ? getY() : super.getEyeY(); -+ return heightParity ? this.getY() : super.getEyeY(); +@@ -188,6 +194,43 @@ public class FallingBlockEntity extends Entity { + return this.heightParity ? this.getY() : super.getEyeY(); } // Sakura end + // Sakura start - physics version api @@ -285,7 +267,7 @@ index abf1ddbb6f8fc6dd7dadf9c7a244863b1b89a473..05457d0a8fedeb66340486f8c82b2a69 @Override public void tick() { -@@ -203,9 +246,15 @@ public class FallingBlockEntity extends Entity { +@@ -201,9 +244,15 @@ public class FallingBlockEntity extends Entity { } else { Block block = this.blockState.getBlock(); @@ -302,7 +284,7 @@ index abf1ddbb6f8fc6dd7dadf9c7a244863b1b89a473..05457d0a8fedeb66340486f8c82b2a69 } this.moveBasic(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise simple entity movement -@@ -226,8 +275,15 @@ public class FallingBlockEntity extends Entity { +@@ -224,8 +273,15 @@ public class FallingBlockEntity extends Entity { return; } // Paper end @@ -319,7 +301,7 @@ index abf1ddbb6f8fc6dd7dadf9c7a244863b1b89a473..05457d0a8fedeb66340486f8c82b2a69 boolean flag = this.blockState.getBlock() instanceof ConcretePowderBlock; boolean flag1 = flag && this.level.getFluidState(blockposition).is(FluidTags.WATER); double d0 = this.getDeltaMovement().lengthSqr(); -@@ -252,8 +308,11 @@ public class FallingBlockEntity extends Entity { +@@ -250,8 +306,11 @@ public class FallingBlockEntity extends Entity { } else { BlockState iblockdata = this.level.getBlockState(blockposition); @@ -333,7 +315,7 @@ index abf1ddbb6f8fc6dd7dadf9c7a244863b1b89a473..05457d0a8fedeb66340486f8c82b2a69 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); -@@ -320,7 +379,12 @@ public class FallingBlockEntity extends Entity { +@@ -318,7 +377,12 @@ public class FallingBlockEntity extends Entity { } } @@ -348,11 +330,11 @@ index abf1ddbb6f8fc6dd7dadf9c7a244863b1b89a473..05457d0a8fedeb66340486f8c82b2a69 } 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 0aed01b24e17aed7f5f7845ced78f64f57cabac3..5f61c5c591ac68e843da22cc1efac7e7308e8d99 100644 +index e97729f2d8febac1740678840566f8beb4f07cdc..ef637b4491a2fc741925fbc896ff3a811ae6308b 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java -@@ -48,6 +48,13 @@ public class PrimedTnt extends Entity { - case Y -> multiplyDeltaMovement(0, 1, 0); +@@ -51,6 +51,13 @@ public class PrimedTnt extends Entity { + case Y -> this.multiplyDeltaMovement(0, 1, 0); } // Sakura end + // Sakura start - physics version api @@ -365,7 +347,7 @@ index 0aed01b24e17aed7f5f7845ced78f64f57cabac3..5f61c5c591ac68e843da22cc1efac7e7 } @Override -@@ -94,12 +101,30 @@ public class PrimedTnt extends Entity { +@@ -97,12 +104,30 @@ public class PrimedTnt extends Entity { } } // Sakura end @@ -397,7 +379,7 @@ index 0aed01b24e17aed7f5f7845ced78f64f57cabac3..5f61c5c591ac68e843da22cc1efac7e7 } this.moveBasic(MoverType.SELF, this.getDeltaMovement()); // Sakura - optimise simple entity movement -@@ -109,15 +134,19 @@ public class PrimedTnt extends Entity { +@@ -112,15 +137,19 @@ public class PrimedTnt extends Entity { return; } // Paper end @@ -420,40 +402,40 @@ index 0aed01b24e17aed7f5f7845ced78f64f57cabac3..5f61c5c591ac68e843da22cc1efac7e7 // 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 -@@ -172,7 +201,10 @@ public class PrimedTnt extends Entity { +@@ -175,7 +204,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(), Explosion.BlockInteraction.BREAK); + // 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); -+ // Sakura end ++ this.level.explode(this, this.getX(), pos, this.getZ(), event.getRadius(), event.getFire(), Explosion.BlockInteraction.BREAK); ++ // Sakura end - physics version api } // CraftBukkit end } -@@ -216,7 +248,7 @@ public class PrimedTnt extends Entity { +@@ -224,7 +256,7 @@ public class PrimedTnt extends Entity { // Paper start - Optional prevent TNT from moving in water @Override public boolean isPushedByFluid() { -- 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 +- return !level.paperConfig.preventTntFromMovingInWater && this.level.sakuraConfig.tntFlowsInWater && super.isPushedByFluid(); // Sakura - cannon mechanics ++ return !level.paperConfig.preventTntFromMovingInWater && !this.physics.isLegacy() && this.level.sakuraConfig.tntFlowsInWater && super.isPushedByFluid(); // Sakura - physics version // Sakura - cannon mechanics } // 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 cd812f9504092b80fbe371e7f8d7a47c8e1565f3..83ce73bbbce9a0b2ee0d2435e7ef3f2c8e628142 100644 +index 076d353e59757232bc2bb3a19dcb3d7ed70d5edd..d59f969f599ad7a76c3277f5ad2ead67572b0f3c 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -69,6 +69,7 @@ public class Explosion { +@@ -73,6 +73,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 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 { + public Explosion(Level world, @Nullable Entity entity, double x, double y, double z, float power) { + this(world, entity, x, y, z, power, false, Explosion.BlockInteraction.DESTROY); +@@ -106,6 +107,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 @@ -461,7 +443,7 @@ index cd812f9504092b80fbe371e7f8d7a47c8e1565f3..83ce73bbbce9a0b2ee0d2435e7ef3f2c } // Sakura start - optimise vanilla explosions -@@ -209,7 +211,12 @@ public class Explosion { +@@ -217,7 +219,12 @@ public class Explosion { } BlockState blockstate = currChunk.getBlockState(blockX, blockY, blockZ); @@ -475,7 +457,7 @@ index cd812f9504092b80fbe371e7f8d7a47c8e1565f3..83ce73bbbce9a0b2ee0d2435e7ef3f2c break; } else { FluidState fluid = blockstate.getFluidState(); -@@ -353,8 +360,13 @@ public class Explosion { +@@ -361,8 +368,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; @@ -490,7 +472,7 @@ index cd812f9504092b80fbe371e7f8d7a47c8e1565f3..83ce73bbbce9a0b2ee0d2435e7ef3f2c } if (hitResult == HitResult.Type.MISS) { // Sakura end - replace density cache -@@ -418,9 +430,15 @@ public class Explosion { +@@ -426,9 +438,15 @@ public class Explosion { if (d7 <= 1.0D) { double d8 = entity.getX() - this.x; @@ -508,13 +490,13 @@ index cd812f9504092b80fbe371e7f8d7a47c8e1565f3..83ce73bbbce9a0b2ee0d2435e7ef3f2c if (d11 != 0.0D) { d8 /= d11; diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java -index f22a538e37835c0424b8f87c9bef1e6fd0764718..3c37eaf12fc256a8edf5a5d060e4ca262ec83108 100644 +index 4c4c709cf9e4a9d4d8b210e6160652ddbdac3dae..bccb6bec25e693dfc60dc24807078768dbf1e6ed 100644 --- a/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java -@@ -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); +@@ -185,6 +185,205 @@ public abstract class Level implements LevelAccessor, AutoCloseable { + public CraftWorld getWorld() { + return this.world; } - // 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. @@ -715,10 +697,10 @@ index f22a538e37835c0424b8f87c9bef1e6fd0764718..3c37eaf12fc256a8edf5a5d060e4ca26 + } + // Sakura end - physics version api - 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 + public CraftServer getCraftServer() { + return (CraftServer) Bukkit.getServer(); 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 6d453d78faa2af7fdb5d49f56909af3284bf0769..830137ef8eb6bab00c47d1dcfa53bdfd83aa9eee 100644 +index 4f0cadec5c9ffb0ae31b2fb9302bc3822f748e59..0a5f56e06b30945213b6a3904f58efe2f613b292 100644 --- a/src/main/java/net/minecraft/world/level/block/FallingBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FallingBlock.java @@ -31,6 +31,15 @@ public class FallingBlock extends Block implements Fallable { @@ -735,13 +717,13 @@ index 6d453d78faa2af7fdb5d49f56909af3284bf0769..830137ef8eb6bab00c47d1dcfa53bdfd + // Sakura end + @Override - public void tick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { + public void tick(BlockState state, ServerLevel world, BlockPos pos, Random 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 a444a335727cf790e63fb9d0fd5d64657675b35c..6b8a61169b324e5b59502e4bf89266ee7f87861a 100644 +index 1224193a35abb8176b509ca8d8053d29c8cc6690..bdbbb45079dc7ef92f81d413ce099619e2ea23df 100644 --- a/src/main/java/net/minecraft/world/level/block/FenceGateBlock.java +++ b/src/main/java/net/minecraft/world/level/block/FenceGateBlock.java -@@ -154,8 +154,13 @@ public class FenceGateBlock extends HorizontalDirectionalBlock { +@@ -140,8 +140,13 @@ public class FenceGateBlock extends HorizontalDirectionalBlock { } // CraftBukkit end @@ -755,8 +737,8 @@ index a444a335727cf790e63fb9d0fd5d64657675b35c..6b8a61169b324e5b59502e4bf89266ee + 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.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); + world.levelEvent((Player) null, flag1 ? 1008 : 1014, pos, 0); + world.gameEvent(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 6bcc83245e8046518921b82d948d45900ae0c8db..cee2e15af942915b4a68cd66e799a2c8b33e6823 100644 --- a/src/main/java/net/minecraft/world/level/block/LadderBlock.java @@ -796,10 +778,10 @@ index 6bcc83245e8046518921b82d948d45900ae0c8db..cee2e15af942915b4a68cd66e799a2c8 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 43e8ef1d6a65d4fd3fe53a587639ffb814368217..28bdb44599a8862d58cfb2e087119b843f25f311 100644 +index 8497adcba2570da8875c322e751fca2fdad057e5..f9ad605334971007efa5bbc122fd2d0ee40ab4c2 100644 --- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java -@@ -154,8 +154,26 @@ public class LiquidBlock extends Block implements BucketPickup { +@@ -155,8 +155,26 @@ public class LiquidBlock extends Block implements BucketPickup { BlockPos blockposition1 = pos.relative(enumdirection.getOpposite()); if (world.getFluidState(blockposition1).is(FluidTags.WATER)) { @@ -829,10 +811,10 @@ index 43e8ef1d6a65d4fd3fe53a587639ffb814368217..28bdb44599a8862d58cfb2e087119b84 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 5ea09cc455bd86beb450f0e0275d7c6c8da98084..002f807d19232f14fe8b195e0404a9bf333a9bdf 100644 +index b2522849d34bbd530c7086b6fbb0582f2d38fef7..5c4aaeac3d184379439925856a4e7b8598a6c8cf 100644 --- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -661,6 +661,10 @@ public class RedStoneWireBlock extends Block { +@@ -669,6 +669,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; @@ -897,10 +879,10 @@ index e09780f6e50e53b488e58aa6907935b3202c91ee..3aa05aae98d8d732529ecced81a972e2 } 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 f456ad8a74464414f69b616a48ee9a2c1cee4d90..bd1ebeccb75408b59cdf8ebe600da1a06f042131 100644 +index 2e5803035a46f890e8bfc59908c0040f9a960703..19edb98c92b27fb4481e4cbdd265f9a601ffb7b1 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 -@@ -157,6 +157,11 @@ public class PistonBaseBlock extends DirectionalBlock { +@@ -156,6 +156,11 @@ public class PistonBaseBlock extends DirectionalBlock { // } // PAIL: checkME - what happened to setTypeAndData? // CraftBukkit end @@ -913,7 +895,7 @@ index f456ad8a74464414f69b616a48ee9a2c1cee4d90..bd1ebeccb75408b59cdf8ebe600da1a0 } 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 6091e3c3adbcc92c9ca438c301a99f646e3cb549..df6e859688c5b45a541b11f2046395474c083c1b 100644 +index 6c400fd706136cd015de57b9ba259b365b33d449..48c2547382f92a4c07ed8d469b0717520ac77f2a 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 @@ -132,6 +132,11 @@ public class PistonHeadBlock extends DirectionalBlock { @@ -928,10 +910,10 @@ index 6091e3c3adbcc92c9ca438c301a99f646e3cb549..df6e859688c5b45a541b11f204639547 return this.isFittingBase(state, blockState) || blockState.is(Blocks.MOVING_PISTON) && blockState.getValue(FACING) == state.getValue(FACING); } -@@ -139,6 +144,10 @@ public class PistonHeadBlock extends DirectionalBlock { - public void neighborChanged(BlockState state, Level world, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { +@@ -140,6 +145,10 @@ public class PistonHeadBlock extends DirectionalBlock { if (state.canSurvive(world, pos)) { - world.neighborChanged(pos.relative(state.getValue(FACING).getOpposite()), sourceBlock, sourcePos); + BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); + world.getBlockState(blockPos).neighborChanged(world, blockPos, block, fromPos, false); + // Sakura start - physics version api + } else if (world.localConfig().config(pos).physicsVersion.before(1_9_0)) { + world.setBlock(pos, Blocks.AIR.defaultBlockState(), 19); @@ -940,10 +922,10 @@ index 6091e3c3adbcc92c9ca438c301a99f646e3cb549..df6e859688c5b45a541b11f204639547 } 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 26e11fbe0ddeed23d286e83adfa7d2a5e9cf88c8..044f6daf4a7d30b6d42a21a12fa409f05121ac91 100644 +index e6361fd5ffd4ad908b6ade9ae7b1b52cc0a7c603..51bd75c4ef5819ece80b820326ef065e14a5baa8 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 -@@ -159,6 +159,12 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -156,6 +156,12 @@ public class PistonMovingBlockEntity extends BlockEntity { double i = 0.0D; @@ -956,7 +938,7 @@ index 26e11fbe0ddeed23d286e83adfa7d2a5e9cf88c8..044f6daf4a7d30b6d42a21a12fa409f0 for(AABB aABB2 : list2) { AABB aABB3 = PistonMath.getMovementArea(moveByPositionAndProgress(pos, aABB2, blockEntity), direction, d); AABB aABB4 = entity.getBoundingBox(); -@@ -280,14 +286,167 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -277,14 +283,167 @@ public class PistonMovingBlockEntity extends BlockEntity { } } @@ -1124,7 +1106,7 @@ index 26e11fbe0ddeed23d286e83adfa7d2a5e9cf88c8..044f6daf4a7d30b6d42a21a12fa409f0 world.removeBlockEntity(pos); blockEntity.setRemoved(); if (world.getBlockState(pos).is(Blocks.MOVING_PISTON)) { -@@ -308,13 +467,23 @@ public class PistonMovingBlockEntity extends BlockEntity { +@@ -305,13 +464,23 @@ public class PistonMovingBlockEntity extends BlockEntity { } } else { float f = blockEntity.progress + 0.5F; @@ -1150,10 +1132,10 @@ index 26e11fbe0ddeed23d286e83adfa7d2a5e9cf88c8..044f6daf4a7d30b6d42a21a12fa409f0 } 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 6a01bfd7aeded9d25eb2a96f2723a2a352f74147..90b4373dd4c0b4c05c69714b10639d20c69f60f9 100644 +index ff40fe323964f173561a6838fb443e79abf9df38..1f267a6815c51cc89e708ca5117bdc9f1955af33 100644 --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java +++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -@@ -517,7 +517,7 @@ public abstract class FlowingFluid extends Fluid { +@@ -505,7 +505,7 @@ public abstract class FlowingFluid extends Fluid { this.spread(world, pos, state); } @@ -1163,7 +1145,7 @@ index 6a01bfd7aeded9d25eb2a96f2723a2a352f74147..90b4373dd4c0b4c05c69714b10639d20 } 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 783e315d92227cbcb5cd207b0a06a12e0778d14b..ad001d4ae5ef5d0efc2c4fd04b1d8331cd40590a 100644 +index 5dfa257e99c778113cfa8ca74f56482285b3a006..769bfaca7bfa7c4e9847a18a9fcefb78a0249b51 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 { @@ -1179,10 +1161,10 @@ index 783e315d92227cbcb5cd207b0a06a12e0778d14b..ad001d4ae5ef5d0efc2c4fd04b1d8331 @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 82e85fbbd45244d02df90fa00c9046e7f51275a2..43df400227429a8a1a18d5ad6fce8a57b198e766 100644 +index 56d50b9310d30e0f81f3d2549ff5c256eb07cc2a..4a476a933fc2ec5aa4192a755af59f99f93c29c9 100644 --- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java +++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java -@@ -104,7 +104,10 @@ public abstract class WaterFluid extends FlowingFluid { +@@ -103,7 +103,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/0040-Allow-water-in-the-nether.patch b/patches/server/0036-Allow-water-in-the-nether.patch similarity index 66% rename from patches/server/0040-Allow-water-in-the-nether.patch rename to patches/server/0036-Allow-water-in-the-nether.patch index c5d892e..b3238c2 100644 --- a/patches/server/0040-Allow-water-in-the-nether.patch +++ b/patches/server/0036-Allow-water-in-the-nether.patch @@ -5,37 +5,37 @@ 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 5c6aa9c464784ad5ee366412d080c72d3d22a76f..4f21231d6ede7bf1b82185f115b2c48b87732c14 100644 +index a3f04f66c66f40068792da3ef0e75e7df102b0e0..99409b4c2fab2a9f068857d9248e8fe6ad76c0ae 100644 --- a/src/main/java/net/minecraft/world/item/BucketItem.java +++ b/src/main/java/net/minecraft/world/item/BucketItem.java @@ -166,7 +166,7 @@ public class BucketItem extends Item implements DispensibleContainerItem { // CraftBukkit end if (!flag1) { - return movingobjectpositionblock != null && this.emptyContents(entityhuman, world, movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection()), (BlockHitResult) null, enumdirection, clicked, itemstack, enumhand); // CraftBukkit + return movingobjectpositionblock != null && this.emptyContents(entityhuman, world, movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection()), (BlockHitResult) null, enumdirection, clicked, itemstack, enumhand); // CraftBukkit // Paper - } 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 ++ } else if (!world.sakuraConfig.allowWaterInTheNether && world.dimensionType().ultraWarm() && this.content.is(FluidTags.WATER)) { // Sakura int i = blockposition.getX(); 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 64206d94a5bf210116d208f9678618b905a61428..ea336c764fa5f0ab9583eff2018c9594bf41b5d1 100644 +index 2676cddca511ea775766cec0001269407599df6e..d14b5b0cb4e57ea68d0ee4950ce48ce1e2bf49c3 100644 --- a/src/main/java/net/minecraft/world/level/block/IceBlock.java +++ b/src/main/java/net/minecraft/world/level/block/IceBlock.java -@@ -31,7 +31,7 @@ public class IceBlock extends HalfTransparentBlock { - public void afterDestroy(Level world, BlockPos pos, ItemStack stack) { - // Paper end +@@ -26,7 +26,7 @@ public class IceBlock extends HalfTransparentBlock { + public void playerDestroy(Level world, Player player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity, ItemStack stack) { + super.playerDestroy(world, player, pos, state, blockEntity, stack); if (EnchantmentHelper.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, stack) == 0) { - if (world.dimensionType().ultraWarm()) { -+ if (!world.sakuraConfig().environment.allowWaterInTheNether && world.dimensionType().ultraWarm()) { // Sakura ++ if (!world.sakuraConfig.allowWaterInTheNether && world.dimensionType().ultraWarm()) { // Sakura world.removeBlock(pos, false); return; } -@@ -59,7 +59,7 @@ public class IceBlock extends HalfTransparentBlock { +@@ -54,7 +54,7 @@ public class IceBlock extends HalfTransparentBlock { return; } // CraftBukkit end - if (world.dimensionType().ultraWarm()) { -+ if (!world.sakuraConfig().environment.allowWaterInTheNether && world.dimensionType().ultraWarm()) { // Sakura ++ if (!world.sakuraConfig.allowWaterInTheNether && world.dimensionType().ultraWarm()) { // Sakura world.removeBlock(pos, false); } else { world.setBlockAndUpdate(pos, Blocks.WATER.defaultBlockState()); diff --git a/patches/server/0041-Configure-concrete-solidifying-in-water.patch b/patches/server/0037-Configure-concrete-solidifying-in-water.patch similarity index 76% rename from patches/server/0041-Configure-concrete-solidifying-in-water.patch rename to patches/server/0037-Configure-concrete-solidifying-in-water.patch index 5121b3d..d3cfa48 100644 --- a/patches/server/0041-Configure-concrete-solidifying-in-water.patch +++ b/patches/server/0037-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 05457d0a8fedeb66340486f8c82b2a694fe09378..358a2a5de2c39bb1b3829af29a4a70f2b720dc24 100644 +index c366486bc65bb331566f5831c0980364b7e00526..599c934dd1bc99e9c2a069c4f5a6050283c4149f 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -284,7 +284,7 @@ public class FallingBlockEntity extends Entity { +@@ -282,7 +282,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 flag = this.level.sakuraConfig.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/0042-Option-for-fast-nether-dimension-lava.patch b/patches/server/0038-Option-for-fast-nether-dimension-lava.patch similarity index 80% rename from patches/server/0042-Option-for-fast-nether-dimension-lava.patch rename to patches/server/0038-Option-for-fast-nether-dimension-lava.patch index 95475ad..32763b2 100644 --- a/patches/server/0042-Option-for-fast-nether-dimension-lava.patch +++ b/patches/server/0038-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 ad001d4ae5ef5d0efc2c4fd04b1d8331cd40590a..2d3d991c826286083377b5e92bf6d807c1836253 100644 +index 769bfaca7bfa7c4e9847a18a9fcefb78a0249b51..ed3b1225bd9e59b2eee64ac4bd03a6fa59f690e0 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 { @@ -13,7 +13,7 @@ index ad001d4ae5ef5d0efc2c4fd04b1d8331cd40590a..2d3d991c826286083377b5e92bf6d807 @Override public int getTickDelay(LevelReader world) { - return world.dimensionType().ultraWarm() ? 10 : 30; -+ return world.dimensionType().ultraWarm() && !(world instanceof Level level && level.sakuraConfig().environment.disableFastNetherLava) ? 10 : 30; // Sakura ++ return world.dimensionType().ultraWarm() && !(world instanceof Level level && level.sakuraConfig.disableFastNetherLava) ? 10 : 30; // Sakura } @Override diff --git a/patches/server/0043-Allow-explosions-to-destroy-lava.patch b/patches/server/0039-Allow-explosions-to-destroy-lava.patch similarity index 75% rename from patches/server/0043-Allow-explosions-to-destroy-lava.patch rename to patches/server/0039-Allow-explosions-to-destroy-lava.patch index b910e46..2c7c1a7 100644 --- a/patches/server/0043-Allow-explosions-to-destroy-lava.patch +++ b/patches/server/0039-Allow-explosions-to-destroy-lava.patch @@ -5,27 +5,27 @@ 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 +index d59f969f599ad7a76c3277f5ad2ead67572b0f3c..c1effe8ecd110ac39103cc7778e7070ac9c33732 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 { +@@ -329,6 +329,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) { ++ if (blockState.is(Blocks.LAVA) && this.level.sakuraConfig.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 { - } +@@ -612,7 +617,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 ++ this.level.setBlock(blockposition, Blocks.AIR.defaultBlockState(), this.level.sakuraConfig.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/0044-Disable-bubble-columns-affecting-cannon-entities.patch b/patches/server/0040-Disable-bubble-columns-affecting-cannon-entities.patch similarity index 78% rename from patches/server/0044-Disable-bubble-columns-affecting-cannon-entities.patch rename to patches/server/0040-Disable-bubble-columns-affecting-cannon-entities.patch index f929afa..8b87b11 100644 --- a/patches/server/0044-Disable-bubble-columns-affecting-cannon-entities.patch +++ b/patches/server/0040-Disable-bubble-columns-affecting-cannon-entities.patch @@ -5,14 +5,14 @@ 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 461288cb56793f11e8dac80720b36cb9b42da518..63ec5bbb3fee17a5a08ec852de60426d0f26d520 100644 +index ee3045133965da67611f180835fa111998f918b4..8de2d8b1474fa45c097ac9964ecfd07c1351f103 100644 --- a/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java +++ b/src/main/java/net/minecraft/world/level/block/BubbleColumnBlock.java @@ -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 -+ if (!world.sakuraConfig().cannons.tntAndSandAffectedByBubbleColumns && (entity.isPrimedTNT || entity.isFallingBlock)) return; // Sakura - configure bubble columns affecting cannon entities ++ if (!world.sakuraConfig.tntAndSandAffectedByBubbleColumns && (entity.isPrimedTNT || entity.isFallingBlock)) return; // Sakura - configure bubble columns affecting cannon entities BlockState blockState = world.getBlockState(pos.above()); if (blockState.isAir()) { entity.onAboveBubbleCol(state.getValue(DRAG_DOWN)); diff --git a/patches/server/0045-Treat-all-collidable-blocks-as-full-while-moving-fas.patch b/patches/server/0041-Treat-all-collidable-blocks-as-full-while-moving-fas.patch similarity index 87% rename from patches/server/0045-Treat-all-collidable-blocks-as-full-while-moving-fas.patch rename to patches/server/0041-Treat-all-collidable-blocks-as-full-while-moving-fas.patch index 10ecb9e..9fbf1d6 100644 --- a/patches/server/0045-Treat-all-collidable-blocks-as-full-while-moving-fas.patch +++ b/patches/server/0041-Treat-all-collidable-blocks-as-full-while-moving-fas.patch @@ -38,19 +38,19 @@ index 93977027caa8c398ca6f0d2bb0890231adf8bf49..07d3aac679ed4a3d85573706bd664e4d 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 4b35f249ee880e07acd0e0b642e86f6486a6ded8..28e1768bdcc2c45643272b759da95452a324a59d 100644 +index 2f9a4f0d458edfbff5979f9cde39eae1f8f922fb..f2dab7d69cd26474de88eae95b47f68414232cf6 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -691,6 +691,18 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -575,6 +575,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)) { ++ if (this.level.sakuraConfig.collideWhenMoving && (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)) { ++ if (horizontalMovementSqr > Math.pow(this.level.sakuraConfig.collideMovingFasterThan, 2.0)) { + return true; + } + } @@ -58,5 +58,5 @@ index 4b35f249ee880e07acd0e0b642e86f6486a6ded8..28e1768bdcc2c45643272b759da95452 + } + // Sakura end - Treat all collidable blocks as full when moving fast - public Entity(EntityType type, Level world) { - this.id = Entity.ENTITY_COUNTER.incrementAndGet(); + // Paper start + /** diff --git a/patches/server/0046-Add-redstone-implementation-API.patch b/patches/server/0042-Add-redstone-implementation-API.patch similarity index 53% rename from patches/server/0046-Add-redstone-implementation-API.patch rename to patches/server/0042-Add-redstone-implementation-API.patch index abd3020..c077893 100644 --- a/patches/server/0046-Add-redstone-implementation-API.patch +++ b/patches/server/0042-Add-redstone-implementation-API.patch @@ -5,69 +5,70 @@ 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 002f807d19232f14fe8b195e0404a9bf333a9bdf..a9f84d594e2adda096d872d4b7ca59e73305544b 100644 +index 5c4aaeac3d184379439925856a4e7b8598a6c8cf..50d96a6e2bcd4e276dbdbf99b55870782f92cc00 100644 --- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -262,7 +262,7 @@ public class RedStoneWireBlock extends Block { +@@ -265,7 +265,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) { -- if (worldIn.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.EIGENCRAFT) { -+ if (worldIn.localConfig().config(pos).redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.EIGENCRAFT) { // Sakura +- if (worldIn.paperConfig.redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.EIGENCRAFT) { ++ if (worldIn.localConfig().config(pos).redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.EIGENCRAFT) { // Sakura turbo.updateSurroundingRedstone(worldIn, pos, state, source); return; } -@@ -286,7 +286,7 @@ public class RedStoneWireBlock extends Block { +@@ -289,7 +289,8 @@ public class RedStoneWireBlock extends Block { int k = worldIn.getBestNeighborSignal(pos1); this.shouldSignal = true; -- if (worldIn.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.VANILLA) { -+ if (worldIn.localConfig().config(pos1).redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.VANILLA) { // Sakura +- if (worldIn.paperConfig.redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.VANILLA) { ++ final com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation redstoneImplementation = worldIn.localConfig().config(pos1).redstoneImplementation; // Sakura ++ if (redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.VANILLA) { // Sakura // This code is totally redundant to if statements just below the loop. if (k > 0 && k > j - 1) { j = k; -@@ -300,7 +300,7 @@ public class RedStoneWireBlock extends Block { +@@ -303,7 +304,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. -- if (worldIn.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.VANILLA || k < 15) { -+ if (worldIn.localConfig().config(pos1).redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.VANILLA || k < 15) { // Sakura +- if (worldIn.paperConfig.redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.VANILLA || k < 15) { ++ if (redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.VANILLA || k < 15) { // Sakura for (Direction enumfacing : Direction.Plane.HORIZONTAL) { BlockPos blockpos = pos1.relative(enumfacing); boolean flag = blockpos.getX() != pos2.getX() || blockpos.getZ() != pos2.getZ(); -@@ -319,7 +319,7 @@ public class RedStoneWireBlock extends Block { +@@ -322,7 +323,7 @@ public class RedStoneWireBlock extends Block { } } -- if (worldIn.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.VANILLA) { -+ if (worldIn.localConfig().config(pos1).redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.VANILLA) { // Sakura +- if (worldIn.paperConfig.redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.VANILLA) { ++ if (redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.VANILLA) { // Sakura // The old code would decrement the wire value only by 1 at a time. if (l > j) { j = l - 1; -@@ -455,7 +455,7 @@ public class RedStoneWireBlock extends Block { +@@ -463,7 +464,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 -- if (world.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { -+ if (world.localConfig().config(pos).redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { // Sakura +- if (world.paperConfig.redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.ALTERNATE_CURRENT) { ++ if (world.localConfig().config(pos).redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.ALTERNATE_CURRENT) { // Sakura world.getWireHandler().onWireAdded(pos); // Alternate Current } else { this.updateSurroundingRedstone(world, pos, state, null); // vanilla/Eigencraft -@@ -488,7 +488,7 @@ public class RedStoneWireBlock extends Block { +@@ -496,7 +497,7 @@ public class RedStoneWireBlock extends Block { } // Paper start - optimize redstone - replace call to updatePowerStrength -- if (world.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { -+ if (world.localConfig().config(pos).redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { // Sakura +- if (world.paperConfig.redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.ALTERNATE_CURRENT) { ++ if (world.localConfig().config(pos).redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.ALTERNATE_CURRENT) { // Sakura world.getWireHandler().onWireRemoved(pos, state); // Alternate Current } else { this.updateSurroundingRedstone(world, pos, state, null); // vanilla/Eigencraft -@@ -529,7 +529,7 @@ public class RedStoneWireBlock extends Block { +@@ -537,7 +538,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. -- if (world.paperConfig().misc.redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { -+ if (world.localConfig().config(pos).redstoneImplementation == io.papermc.paper.configuration.WorldConfiguration.Misc.RedstoneImplementation.ALTERNATE_CURRENT) { // Sakura +- if (world.paperConfig.redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.ALTERNATE_CURRENT) { ++ if (world.localConfig().config(pos).redstoneImplementation == com.destroystokyo.paper.PaperWorldConfig.RedstoneImplementation.ALTERNATE_CURRENT) { // Sakura world.getWireHandler().onWireUpdated(pos); } else // Paper end diff --git a/patches/server/0047-Reduce-entity-tracker-player-updates.patch b/patches/server/0043-Reduce-entity-tracker-player-updates.patch similarity index 90% rename from patches/server/0047-Reduce-entity-tracker-player-updates.patch rename to patches/server/0043-Reduce-entity-tracker-player-updates.patch index 043a11f..b5383b9 100644 --- a/patches/server/0047-Reduce-entity-tracker-player-updates.patch +++ b/patches/server/0043-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 c3b3e984f8a19252b6feabb9ba1f7169dcec2fa2..5e326f26b5166b7ce79bad5724ae63392d53fa45 100644 +index 759ac36b32eaddcc0cff4c2308030b692d6fc7f4..ee7871ddd36b20206ef66372b04861d100601341 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1254,6 +1254,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -2040,6 +2040,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider try { for (TrackedEntity tracker : this.entityMap.values()) { // update tracker entry @@ -16,7 +16,7 @@ index c3b3e984f8a19252b6feabb9ba1f7169dcec2fa2..5e326f26b5166b7ce79bad5724ae6339 tracker.updatePlayers(tracker.entity.getPlayersInTrackRange()); } } finally { -@@ -1501,14 +1502,34 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -2232,14 +2233,34 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider private final int range; SectionPos lastSectionPos; public final Set seenBy = new ReferenceOpenHashSet<>(); // Paper - optimise map impl @@ -27,7 +27,7 @@ index c3b3e984f8a19252b6feabb9ba1f7169dcec2fa2..5e326f26b5166b7ce79bad5724ae6339 this.serverEntity = new ServerEntity(ChunkMap.this.level, entity, j, flag, this::broadcast, this.seenBy); // CraftBukkit this.entity = entity; this.range = i; - this.lastSectionPos = SectionPos.of((EntityAccess) entity); + this.lastSectionPos = SectionPos.of(entity); + // Sakura start - reduce entities looking for nearby players + // Use a maximum of 20 ticks because stationary entities use Integer.MAX_VALUE + // which causes them to turn invisible after untracking. diff --git a/patches/server/0048-Add-option-for-legacy-lava-block-formation.patch b/patches/server/0044-Add-option-for-legacy-lava-block-formation.patch similarity index 78% rename from patches/server/0048-Add-option-for-legacy-lava-block-formation.patch rename to patches/server/0044-Add-option-for-legacy-lava-block-formation.patch index d431e72..3f920cd 100644 --- a/patches/server/0048-Add-option-for-legacy-lava-block-formation.patch +++ b/patches/server/0044-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 28bdb44599a8862d58cfb2e087119b843f25f311..51dc3b81fcb76b1bc185486db26ca2a36ca36e98 100644 +index f9ad605334971007efa5bbc122fd2d0ee40ab4c2..30fd979fb5e375cbe4bacb441d7192b9a20b4a81 100644 --- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java -@@ -161,7 +161,15 @@ public class LiquidBlock extends Block implements BucketPickup { +@@ -162,7 +162,15 @@ public class LiquidBlock extends Block implements BucketPickup { if (fluidState.isSource()) { block = Blocks.OBSIDIAN; } else { @@ -16,7 +16,7 @@ index 28bdb44599a8862d58cfb2e087119b843f25f311..51dc3b81fcb76b1bc185486db26ca2a3 + // Sakura start - legacy block formation + final me.samsuik.sakura.physics.PhysicsVersion physics; + -+ if (world.sakuraConfig().environment.blockGeneration.legacyBlockFormation) { ++ if (world.sakuraConfig.legacyBlockFormation) { + physics = me.samsuik.sakura.physics.PhysicsVersion.v1_12; + } else { + physics = world.localConfig().config(pos).physicsVersion; @@ -26,7 +26,7 @@ index 28bdb44599a8862d58cfb2e087119b843f25f311..51dc3b81fcb76b1bc185486db26ca2a3 // 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 2d3d991c826286083377b5e92bf6d807c1836253..1fb85a64eca4ef8a778f5b8652f774d1cfb707c4 100644 +index ed3b1225bd9e59b2eee64ac4bd03a6fa59f690e0..0f13a5ea286ed42f117dd7473365ec642b46b82d 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 { @@ -34,20 +34,20 @@ index 2d3d991c826286083377b5e92bf6d807c1836253..1fb85a64eca4ef8a778f5b8652f774d1 // Sakura start return state.getHeight(world, pos) >= 0.44444445F && fluid.is(FluidTags.WATER) - && world instanceof Level level && level.localConfig().config(pos).physicsVersion.afterOrEqual(1_13_0); -+ && world instanceof Level level && !level.sakuraConfig().environment.blockGeneration.legacyBlockFormation && level.localConfig().config(pos).physicsVersion.afterOrEqual(1_13_0); ++ && world instanceof Level level && !level.sakuraConfig.legacyBlockFormation && level.localConfig().config(pos).physicsVersion.afterOrEqual(1_13_0); // Sakura end } 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 43df400227429a8a1a18d5ad6fce8a57b198e766..3a955377a13b67e955f90614b975f76f3fcfe9b8 100644 +index 4a476a933fc2ec5aa4192a755af59f99f93c29c9..f9e9332ef573c641e071400f5c8726190b464a56 100644 --- a/src/main/java/net/minecraft/world/level/material/WaterFluid.java +++ b/src/main/java/net/minecraft/world/level/material/WaterFluid.java -@@ -106,7 +106,7 @@ public abstract class WaterFluid extends FlowingFluid { +@@ -105,7 +105,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) - || fluid.is(FluidTags.LAVA) && world instanceof Level level && level.localConfig().config(pos).physicsVersion.before(1_13_0); -+ || fluid.is(FluidTags.LAVA) && world instanceof Level level && (level.sakuraConfig().environment.blockGeneration.legacyBlockFormation || level.localConfig().config(pos).physicsVersion.before(1_13_0)); ++ || fluid.is(FluidTags.LAVA) && world instanceof Level level && (level.sakuraConfig.legacyBlockFormation || level.localConfig().config(pos).physicsVersion.before(1_13_0)); // Sakura end } diff --git a/patches/server/0045-Configure-mob-spawner-defaults.patch b/patches/server/0045-Configure-mob-spawner-defaults.patch new file mode 100644 index 0000000..33db271 --- /dev/null +++ b/patches/server/0045-Configure-mob-spawner-defaults.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik <40902469+Samsuik@users.noreply.github.com> +Date: Thu, 7 Dec 2023 16:30:24 +0000 +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 4bfebbb2e87464cd47a38a5da6275b2c662fa052..c0850e49aa677ecb16ce551ea0268ff9b172b642 100644 +--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java ++++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java +@@ -44,7 +44,16 @@ public abstract class BaseSpawner { + private final Random random = new Random(); + private int tickDelay = 0; // Paper + +- public BaseSpawner() {} ++ // Sakura start - configure spawner defaults ++ public BaseSpawner() { ++ this.minSpawnDelay = me.samsuik.sakura.configuration.SakuraGlobalConfig.get().minSpawnDelay; ++ this.maxSpawnDelay = me.samsuik.sakura.configuration.SakuraGlobalConfig.get().maxSpawnDelay; ++ this.spawnCount = me.samsuik.sakura.configuration.SakuraGlobalConfig.get().spawnCount; ++ this.maxNearbyEntities = me.samsuik.sakura.configuration.SakuraGlobalConfig.get().maxNearbyEntities; ++ this.requiredPlayerRange = me.samsuik.sakura.configuration.SakuraGlobalConfig.get().requiredPlayerRange; ++ this.spawnRange = me.samsuik.sakura.configuration.SakuraGlobalConfig.get().spawnRange; ++ } ++ // Sakura end - configure spawner defaults + + public void setEntityId(EntityType type) { + this.nextSpawnData.getEntityToSpawn().putString("id", Registry.ENTITY_TYPE.getKey(type).toString()); diff --git a/patches/server/0050-Allow-disabling-random-dispenser-item-selection.patch b/patches/server/0046-Allow-disabling-random-dispenser-item-selection.patch similarity index 70% rename from patches/server/0050-Allow-disabling-random-dispenser-item-selection.patch rename to patches/server/0046-Allow-disabling-random-dispenser-item-selection.patch index bb01877..915100b 100644 --- a/patches/server/0050-Allow-disabling-random-dispenser-item-selection.patch +++ b/patches/server/0046-Allow-disabling-random-dispenser-item-selection.patch @@ -5,17 +5,17 @@ Subject: [PATCH] Allow disabling random dispenser item selection diff --git a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java -index 881379681c39230a00b3a1f11cd87498984396c7..73e6fbf818944e73885db9c528114b0ea684de47 100644 +index f74c5bb8e1ba42c77c59d481b871fd992483b128..4c77d0333808324640dfb77246baecf204188579 100644 --- a/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java +++ b/src/main/java/net/minecraft/world/level/block/entity/DispenserBlockEntity.java -@@ -73,8 +73,15 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity { +@@ -75,8 +75,15 @@ public class DispenserBlockEntity extends RandomizableContainerBlockEntity { int j = 1; for (int k = 0; k < this.items.size(); ++k) { -- if (!((ItemStack) this.items.get(k)).isEmpty() && random.nextInt(j++) == 0) { +- if (!((ItemStack) this.items.get(k)).isEmpty() && DispenserBlockEntity.RANDOM.nextInt(j++) == 0) { + // Sakura start - allow disabling dispenser random item selection -+ if (this.level.sakuraConfig().technical.dispenserRandomItemSelection || this instanceof DropperBlockEntity) { -+ if (!((ItemStack) this.items.get(k)).isEmpty() && random.nextInt(j++) == 0) { ++ if (this.level.sakuraConfig.dispenserRandomItemSelection || this instanceof DropperBlockEntity) { ++ if (!((ItemStack) this.items.get(k)).isEmpty() && DispenserBlockEntity.RANDOM.nextInt(j++) == 0) { + i = k; + } + } else if (!this.items.get(k).isEmpty()) { diff --git a/patches/server/0051-Add-instant-mob-death-animation.patch b/patches/server/0047-Add-instant-mob-death-animation.patch similarity index 75% rename from patches/server/0051-Add-instant-mob-death-animation.patch rename to patches/server/0047-Add-instant-mob-death-animation.patch index bcbba57..134ed7f 100644 --- a/patches/server/0051-Add-instant-mob-death-animation.patch +++ b/patches/server/0047-Add-instant-mob-death-animation.patch @@ -5,15 +5,15 @@ 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 691f2c1d00d3cb17af017c997b11525709d6cd15..f2e0f4eb5f07ef4bd31282f3d12b8d8380ce22a0 100644 +index 94a98385742888544815e24ff39338f604d4ca86..3dd0fc22946459679aabb31bfe4ddb0580aa85f0 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -1696,6 +1696,12 @@ public abstract class LivingEntity extends Entity { +@@ -1655,6 +1655,12 @@ public abstract class LivingEntity extends Entity { this.createWitherRose(entityliving); } + // Sakura start -+ if (this.dead && this.level.sakuraConfig().entity.instantDeathAnimation && !(this instanceof Player)) { ++ if (this.dead && this.level.sakuraConfig.instantDeathAnimation && !(this instanceof Player)) { + this.deathTime = 20; + return; + } diff --git a/patches/server/0052-Configure-fluids-breaking-redstone.patch b/patches/server/0048-Configure-fluids-breaking-redstone.patch similarity index 76% rename from patches/server/0052-Configure-fluids-breaking-redstone.patch rename to patches/server/0048-Configure-fluids-breaking-redstone.patch index 9dd581e..0c08c13 100644 --- a/patches/server/0052-Configure-fluids-breaking-redstone.patch +++ b/patches/server/0048-Configure-fluids-breaking-redstone.patch @@ -5,15 +5,15 @@ 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 90b4373dd4c0b4c05c69714b10639d20c69f60f9..5089f51667912627cfeaac79be689aee151110ae 100644 +index 1f267a6815c51cc89e708ca5117bdc9f1955af33..8a23051a6c0dd230fb8ff805638a91aeaf9e9729 100644 --- a/src/main/java/net/minecraft/world/level/material/FlowingFluid.java +++ b/src/main/java/net/minecraft/world/level/material/FlowingFluid.java -@@ -465,6 +465,10 @@ public abstract class FlowingFluid extends Fluid { +@@ -453,6 +453,10 @@ public abstract class FlowingFluid extends 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)) { ++ } else if (world instanceof Level level && !level.sakuraConfig.fluidsBreakRedstone && (state.isSignalSource() || state.getBlock() instanceof net.minecraft.world.level.block.CarpetBlock)) { + return false; + // Sakura end } else if (!(block instanceof DoorBlock) && !state.is(BlockTags.SIGNS) && !state.is(Blocks.LADDER) && !state.is(Blocks.SUGAR_CANE) && !state.is(Blocks.BUBBLE_COLUMN)) { diff --git a/patches/server/0049-Configure-mob-spawner-defaults.patch b/patches/server/0049-Configure-mob-spawner-defaults.patch deleted file mode 100644 index 4d01eab..0000000 --- a/patches/server/0049-Configure-mob-spawner-defaults.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Samsuik <40902469+Samsuik@users.noreply.github.com> -Date: Thu, 7 Dec 2023 16:30:24 +0000 -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 af799b61cec48ca290ed66cb47cfc0b244ac41a7..c7c11747879fecd0e01a4c5de1c396957303f3bc 100644 ---- a/src/main/java/net/minecraft/world/level/BaseSpawner.java -+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java -@@ -47,7 +47,16 @@ public abstract class BaseSpawner { - public int spawnRange = 4; - private int tickDelay = 0; // Paper - -- public BaseSpawner() {} -+ // Sakura start - configure spawner defaults -+ public BaseSpawner() { -+ this.minSpawnDelay = me.samsuik.sakura.configuration.GlobalConfiguration.get().environment.mobSpawnerDefaults.minSpawnDelay; -+ this.maxSpawnDelay = me.samsuik.sakura.configuration.GlobalConfiguration.get().environment.mobSpawnerDefaults.maxSpawnDelay; -+ this.spawnCount = me.samsuik.sakura.configuration.GlobalConfiguration.get().environment.mobSpawnerDefaults.spawnCount; -+ this.maxNearbyEntities = me.samsuik.sakura.configuration.GlobalConfiguration.get().environment.mobSpawnerDefaults.maxNearbyEntities; -+ this.requiredPlayerRange = me.samsuik.sakura.configuration.GlobalConfiguration.get().environment.mobSpawnerDefaults.requiredPlayerRange; -+ this.spawnRange = me.samsuik.sakura.configuration.GlobalConfiguration.get().environment.mobSpawnerDefaults.spawnRange; -+ // Sakura end -+ } - - public void setEntityId(EntityType type, @Nullable Level world, RandomSource random, BlockPos pos) { - this.getOrCreateNextSpawnData(world, random, pos).getEntityToSpawn().putString("id", BuiltInRegistries.ENTITY_TYPE.getKey(type).toString()); diff --git a/patches/server/0053-Option-to-disable-explosions-hurting-players.patch b/patches/server/0049-Option-to-disable-explosions-hurting-players.patch similarity index 80% rename from patches/server/0053-Option-to-disable-explosions-hurting-players.patch rename to patches/server/0049-Option-to-disable-explosions-hurting-players.patch index b6bb20e..6e1c8b6 100644 --- a/patches/server/0053-Option-to-disable-explosions-hurting-players.patch +++ b/patches/server/0049-Option-to-disable-explosions-hurting-players.patch @@ -5,15 +5,15 @@ 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 +index 92a7962edb01d5ef36a9e35cc0b6bacc879ccff2..6bd7e714d3d1242acfad7e701d425b4b456ad73a 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 { +@@ -903,6 +903,11 @@ public abstract class Player extends LivingEntity { @Override public boolean isInvulnerableTo(DamageSource damageSource) { + // Sakura start -+ if (!this.level.sakuraConfig().cannons.explosion.explosionsHurtPlayers && damageSource.isExplosion()) { ++ if (!this.level.sakuraConfig.explosionsHurtPlayers && damageSource.isExplosion()) { + return true; + } + // Sakura end diff --git a/patches/server/0054-Iron-golems-take-fall-damage.patch b/patches/server/0050-Iron-golems-take-fall-damage.patch similarity index 83% rename from patches/server/0054-Iron-golems-take-fall-damage.patch rename to patches/server/0050-Iron-golems-take-fall-damage.patch index 1c1e638..12b0e15 100644 --- a/patches/server/0054-Iron-golems-take-fall-damage.patch +++ b/patches/server/0050-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 e73acfa2f5a4066fa1beee1758082a2fe97a43b3..3249197545ab5597b677c9e698c0aecaf024aeee 100644 +index 8299b48bad7a38d4310ca93b1de37d6c9170fc09..fc2b862d87d97aab1b31d6555cfc4940604f46b4 100644 --- a/src/main/java/net/minecraft/world/entity/animal/IronGolem.java +++ b/src/main/java/net/minecraft/world/entity/animal/IronGolem.java -@@ -249,6 +249,20 @@ public class IronGolem extends AbstractGolem implements NeutralMob { +@@ -237,6 +237,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.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/0055-Add-explosions-dropping-items-config.patch b/patches/server/0051-Add-explosions-dropping-items-config.patch similarity index 71% rename from patches/server/0055-Add-explosions-dropping-items-config.patch rename to patches/server/0051-Add-explosions-dropping-items-config.patch index 1c8d04e..f4d5ca1 100644 --- a/patches/server/0055-Add-explosions-dropping-items-config.patch +++ b/patches/server/0051-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 6f610de34ac165d2e9a2d353eee46f26da2c22c1..4047610d0a01ce58f023da9a810ea3f5320892e7 100644 +index c1effe8ecd110ac39103cc7778e7070ac9c33732..68b9b340b6dddcf29f7c3d80600854dd87b67f65 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -626,6 +626,11 @@ public class Explosion { +@@ -623,6 +623,11 @@ public class Explosion { } } + // Sakura start - config for explosions dropping items -+ if (!this.level.sakuraConfig().cannons.explosion.explosionsDropItems) { ++ if (!this.level.sakuraConfig.explosionsDropItems) { + objectarraylist.clear(); + } + // Sakura end - config for explosions dropping items - objectlistiterator = objectarraylist.iterator(); + ObjectListIterator objectlistiterator = objectarraylist.iterator(); while (objectlistiterator.hasNext()) { diff --git a/patches/server/0056-Optimise-check-inside-blocks-and-fluids.patch b/patches/server/0052-Optimise-check-inside-blocks-and-fluids.patch similarity index 90% rename from patches/server/0056-Optimise-check-inside-blocks-and-fluids.patch rename to patches/server/0052-Optimise-check-inside-blocks-and-fluids.patch index ad6827e..35af41f 100644 --- a/patches/server/0056-Optimise-check-inside-blocks-and-fluids.patch +++ b/patches/server/0052-Optimise-check-inside-blocks-and-fluids.patch @@ -5,12 +5,12 @@ 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 28e1768bdcc2c45643272b759da95452a324a59d..868649a111694e0d0c267f7fdc5ffd3fd01cd748 100644 +index f2dab7d69cd26474de88eae95b47f68414232cf6..80dfd159f8f71f9a6de38334d9ec5a50120ed324 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -1867,14 +1867,34 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { - BlockPos blockposition1 = new BlockPos(axisalignedbb.maxX - offset, axisalignedbb.maxY - offset, axisalignedbb.maxZ - offset); - // Sakura end +@@ -1763,14 +1763,34 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + BlockPos blockposition = new BlockPos(axisalignedbb.minX + 0.001D, axisalignedbb.minY + 0.001D, axisalignedbb.minZ + 0.001D); + BlockPos blockposition1 = new BlockPos(axisalignedbb.maxX - 0.001D, axisalignedbb.maxY - 0.001D, axisalignedbb.maxZ - 0.001D); - if (this.level.hasChunksAt(blockposition, blockposition1)) { + // Sakura start - optimise check inside blocks @@ -47,7 +47,7 @@ index 28e1768bdcc2c45643272b759da95452a324a59d..868649a111694e0d0c267f7fdc5ffd3f try { iblockdata.entityInside(this.level, blockposition_mutableblockposition, this); -@@ -4456,7 +4476,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4245,7 +4265,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { } public boolean updateFluidHeightAndDoFluidPushing(TagKey tag, double speed) { @@ -56,7 +56,7 @@ index 28e1768bdcc2c45643272b759da95452a324a59d..868649a111694e0d0c267f7fdc5ffd3f return false; } else { AABB axisalignedbb = this.getBoundingBox().deflate(0.001D); -@@ -4473,11 +4493,31 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -4262,11 +4282,31 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { int k1 = 0; BlockPos.MutableBlockPos blockposition_mutableblockposition = new BlockPos.MutableBlockPos(); diff --git a/patches/server/0057-Avoid-searching-for-lava-if-throttled-water-flow-spe.patch b/patches/server/0053-Avoid-searching-for-lava-if-throttled-water-flow-spe.patch similarity index 60% rename from patches/server/0057-Avoid-searching-for-lava-if-throttled-water-flow-spe.patch rename to patches/server/0053-Avoid-searching-for-lava-if-throttled-water-flow-spe.patch index 2b282d5..391aae4 100644 --- a/patches/server/0057-Avoid-searching-for-lava-if-throttled-water-flow-spe.patch +++ b/patches/server/0053-Avoid-searching-for-lava-if-throttled-water-flow-spe.patch @@ -6,15 +6,15 @@ Subject: [PATCH] Avoid searching for lava if throttled water flow speed is 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 +index 30fd979fb5e375cbe4bacb441d7192b9a20b4a81..f4f4ae2583bdbca4d9db9f20221d68d1881be2cd 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 { +@@ -114,7 +114,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 (this.material == Material.WATER) { ++ if (this.material == Material.WATER && this.fluid.getTickDelay(world) != world.paperConfig.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 || + world.getMaterialIfLoaded(blockposition.north(1)) == Material.LAVA || + world.getMaterialIfLoaded(blockposition.south(1)) == Material.LAVA || diff --git a/patches/server/0054-Calculate-biome-noise-once-per-chunk-section.patch b/patches/server/0054-Calculate-biome-noise-once-per-chunk-section.patch new file mode 100644 index 0000000..3b1d7b6 --- /dev/null +++ b/patches/server/0054-Calculate-biome-noise-once-per-chunk-section.patch @@ -0,0 +1,29 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik +Date: Mon, 22 Jan 2024 15:52:33 +0000 +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 b11ad90c0956ac1b8ee069fa3f4553a2b4ce88e9..4ec096938dd66966ed3782d4e80bc4173045cd3c 100644 +--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java ++++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunkSection.java +@@ -314,11 +314,17 @@ public class LevelChunkSection { + try { + 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, k + i1, z + j1, sampler)); ++ // Sakura start - calculate biome noise once per chunk section ++ if (biomeHolder == null || !me.samsuik.sakura.configuration.SakuraGlobalConfig.get().calculateBiomeNoiseOncePerChunkSection) { ++ biomeHolder = biomeSupplier.getNoiseBiome(x + l, k + i1, z + j1, sampler); ++ } ++ datapaletteblock.getAndSetUnchecked(l, i1, j1, biomeHolder); ++ // Sakura end - calculate biome noise once per chunk section + } + } + } diff --git a/patches/server/0059-Fix-doEntityDrops-gamerule-preventing-falling-blocks.patch b/patches/server/0055-Fix-doEntityDrops-gamerule-preventing-falling-blocks.patch similarity index 91% rename from patches/server/0059-Fix-doEntityDrops-gamerule-preventing-falling-blocks.patch rename to patches/server/0055-Fix-doEntityDrops-gamerule-preventing-falling-blocks.patch index 439ed7f..d29553a 100644 --- a/patches/server/0059-Fix-doEntityDrops-gamerule-preventing-falling-blocks.patch +++ b/patches/server/0055-Fix-doEntityDrops-gamerule-preventing-falling-blocks.patch @@ -6,10 +6,10 @@ 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 358a2a5de2c39bb1b3829af29a4a70f2b720dc24..d4e8bffc31415663fd3628ad33acc2d59e2036ca 100644 +index 599c934dd1bc99e9c2a069c4f5a6050283c4149f..b1f47ff80ed96c9f3ea1e4af45143c0d148c7226 100644 --- a/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/src/main/java/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -359,10 +359,14 @@ public class FallingBlockEntity extends Entity { +@@ -357,10 +357,14 @@ public class FallingBlockEntity extends Entity { tileentity.setChanged(); } } diff --git a/patches/server/0060-Add-entity-travel-distance-limits.patch b/patches/server/0056-Add-entity-travel-distance-limits.patch similarity index 73% rename from patches/server/0060-Add-entity-travel-distance-limits.patch rename to patches/server/0056-Add-entity-travel-distance-limits.patch index 0b152c2..366b93f 100644 --- a/patches/server/0060-Add-entity-travel-distance-limits.patch +++ b/patches/server/0056-Add-entity-travel-distance-limits.patch @@ -5,10 +5,10 @@ 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 ab5472c27f94e196a2747466f8721173cef937fc..c32140ded7da15123774b2443830528598b982d4 100644 +index 71f96f0716e6001ea74690d43160c08ca6a3024e..7f7aae5c2e14dba493e44778254a45f51fd32ce4 100644 --- a/src/main/java/net/minecraft/server/level/ServerLevel.java +++ b/src/main/java/net/minecraft/server/level/ServerLevel.java -@@ -1219,6 +1219,11 @@ public class ServerLevel extends Level implements WorldGenLevel { +@@ -1143,6 +1143,11 @@ public class ServerLevel extends Level implements WorldGenLevel { if (isActive) { // Paper - EAR 2 TimingHistory.activatedEntityTicks++; entity.tick(); @@ -21,10 +21,10 @@ index ab5472c27f94e196a2747466f8721173cef937fc..c32140ded7da15123774b24438305285 } 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 868649a111694e0d0c267f7fdc5ffd3fd01cd748..13906fc7d31e11d75754fe2c39c5ddf267d5ddb0 100644 +index 80dfd159f8f71f9a6de38334d9ec5a50120ed324..6934dec885c91d44a6c81bd6df75c2f5420e1fc3 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -703,6 +703,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -587,6 +587,19 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { return false; } // Sakura end - Treat all collidable blocks as full when moving fast @@ -42,13 +42,13 @@ index 868649a111694e0d0c267f7fdc5ffd3fd01cd748..13906fc7d31e11d75754fe2c39c5ddf2 + } + // Sakura end - entity travel distance limits - public Entity(EntityType type, Level world) { - this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -750,6 +763,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + // Paper start + /** +@@ -684,6 +697,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 -+ this.travelDistanceLimit = Math.pow(level.sakuraConfig().entity.chunkTravelLimit.getOrDefault(type, Integer.MAX_VALUE) * 16.0, 2); // Sakura - entity travel distance limits + this.mergeLevel = this.level.sakuraConfig.mergeLevel; // Sakura ++ this.travelDistanceLimit = Math.pow(this.level.sakuraConfig.chunkTravelLimit.getOrDefault(type, Integer.MAX_VALUE) * 16.0, 2); // Sakura - entity travel distance limits } public boolean isColliding(BlockPos pos, BlockState state) { diff --git a/patches/server/0061-Configure-potion-speed-and-breaking-inside-entities.patch b/patches/server/0057-Configure-potion-speed-and-breaking-inside-entities.patch similarity index 74% rename from patches/server/0061-Configure-potion-speed-and-breaking-inside-entities.patch rename to patches/server/0057-Configure-potion-speed-and-breaking-inside-entities.patch index 5c6bc89..be3a40d 100644 --- a/patches/server/0061-Configure-potion-speed-and-breaking-inside-entities.patch +++ b/patches/server/0057-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 893975e8587b9036f622e2088c302e33004496d2..b0b96d3e254e96ca5b61ce7faea17baa9f85be23 100644 +index ccaa97956e40c6a79371d813719f65687991ec5b..73a9eb6fa8b33989f6da5e5e2455454528957631 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/Projectile.java +++ b/src/main/java/net/minecraft/world/entity/projectile/Projectile.java -@@ -122,7 +122,7 @@ public abstract class Projectile extends Entity { +@@ -121,7 +121,7 @@ public abstract class Projectile extends Entity { super.tick(); } @@ -18,7 +18,7 @@ index 893975e8587b9036f622e2088c302e33004496d2..b0b96d3e254e96ca5b61ce7faea17baa 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 0524161f7cb414d526e6118258bddd989be6cc9a..ce237e75637d15e2eee70447feb97cbcbc6d384c 100644 +index 0524161f7cb414d526e6118258bddd989be6cc9a..dc02496d6c27290a0f6c49852e95b1014128e2fc 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ProjectileUtil.java @@ -29,7 +29,14 @@ public final class ProjectileUtil { @@ -28,7 +28,7 @@ index 0524161f7cb414d526e6118258bddd989be6cc9a..ce237e75637d15e2eee70447feb97cbc - 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 (level.sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && entity instanceof ThrownPotion) { ++ if (level.sakuraConfig.allowBreakingInsideEntities && entity instanceof ThrownPotion) { + hitResult2 = getEntityHitResult(entity, vec32, vec33, entity.getBoundingBox().expandTowards(vec3).inflate(1.0), predicate, 0.3f); + } else { + hitResult2 = getEntityHitResult(level, entity, vec32, vec33, entity.getBoundingBox().expandTowards(vec3).inflate(1.0), predicate, 0.3f); @@ -38,10 +38,10 @@ index 0524161f7cb414d526e6118258bddd989be6cc9a..ce237e75637d15e2eee70447feb97cbc 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 1f1519c1b33d16eba59546c86f20a099486441d7..22afbd3054875cd769f42a3fbd89b51a2e1d94af 100644 +index fee09e6ff72cf1da389d5811dd005642cd50a5b4..4b51b792d69bb5fa69e21bd9f905a8c67046087f 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java +++ b/src/main/java/net/minecraft/world/entity/projectile/ThrownPotion.java -@@ -60,6 +60,25 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie +@@ -58,6 +58,25 @@ public class ThrownPotion extends ThrowableItemProjectile implements ItemSupplie super(EntityType.POTION, x, y, z, world); } @@ -51,16 +51,16 @@ index 1f1519c1b33d16eba59546c86f20a099486441d7..22afbd3054875cd769f42a3fbd89b51a + super.shoot(x, y, z, speed, divergence); + + net.minecraft.world.phys.Vec3 movement = getDeltaMovement(); -+ 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; ++ double moveX = movement.x * this.level.sakuraConfig.horizontalSpeed; ++ double moveY = movement.y * this.level.sakuraConfig.verticalSpeed; ++ double moveZ = movement.z * this.level.sakuraConfig.horizontalSpeed; + -+ setDeltaMovement(moveX, moveY, moveZ); ++ this.setDeltaMovement(moveX, moveY, moveZ); + } + + @Override + protected final boolean checkLeftOwner() { -+ return super.checkLeftOwner() || this.level.sakuraConfig().entity.thrownPotion.allowBreakingInsideEntities && this.tickCount >= 5; ++ return super.checkLeftOwner() || this.level.sakuraConfig.allowBreakingInsideEntities && this.tickCount >= 5; + } + // Sakura end - configure potion mechanics + diff --git a/patches/server/0062-Add-outline-colliison-to-enderpearls.patch b/patches/server/0058-Add-outline-colliison-to-enderpearls.patch similarity index 87% rename from patches/server/0062-Add-outline-colliison-to-enderpearls.patch rename to patches/server/0058-Add-outline-colliison-to-enderpearls.patch index a4cecc5..3444131 100644 --- a/patches/server/0062-Add-outline-colliison-to-enderpearls.patch +++ b/patches/server/0058-Add-outline-colliison-to-enderpearls.patch @@ -5,7 +5,7 @@ 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 +index dc02496d6c27290a0f6c49852e95b1014128e2fc..92b0c54b88fab59cfb8cf69cb04bbcf2ce8ac6e3 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; @@ -28,17 +28,17 @@ index ce237e75637d15e2eee70447feb97cbcbc6d384c..1736d6c7c5ca0205b7be302a0574a08b 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 +index 94d09b05737679b133ec462815b010b19c01b4fa..74d9b158af6ee5cff046534fd99505102d2de0e4 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 { +@@ -45,7 +45,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) { ++ if (this.level.sakuraConfig.useOutlineForCollision && this instanceof ThrownEnderpearl) { + type = net.minecraft.world.level.ClipContext.Block.OUTLINE; + } else { + type = net.minecraft.world.level.ClipContext.Block.COLLIDER; diff --git a/patches/server/0058-Calculate-biome-noise-once-per-chunk-section.patch b/patches/server/0058-Calculate-biome-noise-once-per-chunk-section.patch deleted file mode 100644 index e1662f3..0000000 --- a/patches/server/0058-Calculate-biome-noise-once-per-chunk-section.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Samsuik -Date: Mon, 22 Jan 2024 15:52:33 +0000 -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 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 -@@ -315,11 +315,17 @@ public class LevelChunkSection { - PalettedContainer> datapaletteblock = this.biomes.recreate(); - 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, k + i1, z + j1, sampler)); -+ // Sakura start - calculate biome noise once per chunk section -+ 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, biomeHolder); -+ // Sakura end - calculate biome noise once per chunk section - } - } - } diff --git a/patches/server/0063-Disable-player-poses-shrinking-collision-box.patch b/patches/server/0059-Disable-player-poses-shrinking-collision-box.patch similarity index 79% rename from patches/server/0063-Disable-player-poses-shrinking-collision-box.patch rename to patches/server/0059-Disable-player-poses-shrinking-collision-box.patch index 7468fc7..93043a5 100644 --- a/patches/server/0063-Disable-player-poses-shrinking-collision-box.patch +++ b/patches/server/0059-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 62b1009b28c28307e2226248181721bf67bfa079..2c36d3c1939ca4185f4143b846c522a0c9f5b460 100644 +index 6bd7e714d3d1242acfad7e701d425b4b456ad73a..371737a38acb4ee5e7712e0e9d9db55f4303dfe1 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -2278,7 +2278,13 @@ public abstract class Player extends LivingEntity { +@@ -2246,7 +2246,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 (!this.level.sakuraConfig().players.posesShrinkCollisionBox && dimensions.height == 0.6f) { ++ if (!this.level.sakuraConfig.posesShrinkCollisionBox && dimensions.height == 0.6f) { + dimensions = Player.STANDING_DIMENSIONS; + } + return dimensions; diff --git a/patches/server/0060-Mob-spawner-behaviour.patch b/patches/server/0060-Mob-spawner-behaviour.patch new file mode 100644 index 0000000..38b38f4 --- /dev/null +++ b/patches/server/0060-Mob-spawner-behaviour.patch @@ -0,0 +1,46 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik +Date: Thu, 28 Mar 2024 15:44:33 +0000 +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 c0850e49aa677ecb16ce551ea0268ff9b172b642..7dac4a9707edc138cebcbf2eac88a82bcb17d120 100644 +--- a/src/main/java/net/minecraft/world/level/BaseSpawner.java ++++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java +@@ -61,7 +61,7 @@ public abstract class BaseSpawner { + } + + public boolean isNearPlayer(Level world, BlockPos pos) { +- return world.isAffectsSpawningPlayerNearby((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, (double) this.requiredPlayerRange); // Paper ++ return !world.sakuraConfig.requireNearbyPlayer || world.isAffectsSpawningPlayerNearby((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, (double) this.requiredPlayerRange); // Sakura - mob spawner behaviour // Paper + } + + public void clientTick(Level world, BlockPos pos) { +@@ -128,7 +128,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; + } +- } else if (!SpawnPlacements.checkSpawnRules((EntityType) optional.get(), world, MobSpawnType.SPAWNER, blockposition1, world.getRandom())) { ++ } else if (world.sakuraConfig.checkSpawnConditions && !SpawnPlacements.checkSpawnRules((EntityType) optional.get(), world, MobSpawnType.SPAWNER, blockposition1, world.getRandom())) { // Sakura - mob spawner behaviour + continue; + } + // Paper start +@@ -163,7 +163,7 @@ public abstract class BaseSpawner { + return; + } + +- 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.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); +@@ -175,7 +175,7 @@ public abstract class BaseSpawner { + if (entity instanceof Mob) { + Mob entityinsentient = (Mob) entity; + +- if (this.nextSpawnData.getCustomSpawnRules().isEmpty() && !entityinsentient.checkSpawnRules(world, MobSpawnType.SPAWNER) || !entityinsentient.checkSpawnObstruction(world)) { ++ if (world.sakuraConfig.checkSpawnConditions && (this.nextSpawnData.getCustomSpawnRules().isEmpty() && !entityinsentient.checkSpawnRules(world, MobSpawnType.SPAWNER) || !entityinsentient.checkSpawnObstruction(world))) { // Sakura - mob spawner behaviour + continue; + } + diff --git a/patches/server/0065-Fix-block-placement-causing-physics-when-cancelled.patch b/patches/server/0061-Fix-block-placement-causing-physics-when-cancelled.patch similarity index 68% rename from patches/server/0065-Fix-block-placement-causing-physics-when-cancelled.patch rename to patches/server/0061-Fix-block-placement-causing-physics-when-cancelled.patch index fda8b55..7e8eea5 100644 --- a/patches/server/0065-Fix-block-placement-causing-physics-when-cancelled.patch +++ b/patches/server/0061-Fix-block-placement-causing-physics-when-cancelled.patch @@ -5,10 +5,10 @@ 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 31eed67d07097c7eb1b06547a9f556bcc709d96c..8970c0f6cf9a62f859e9a2bfd2f29b43bc0e1ac3 100644 +index 6837c965592d4584cfc958a1008b98791a0fc780..f09b1a806750c93b0be97e5a442b914202295665 100644 --- a/src/main/java/net/minecraft/world/item/ItemStack.java +++ b/src/main/java/net/minecraft/world/item/ItemStack.java -@@ -411,9 +411,16 @@ public final class ItemStack { +@@ -390,9 +390,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 @@ -26,10 +26,10 @@ index 31eed67d07097c7eb1b06547a9f556bcc709d96c..8970c0f6cf9a62f859e9a2bfd2f29b43 // 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 3c37eaf12fc256a8edf5a5d060e4ca262ec83108..785f621ab4be55cb6f216bf11731aee2f40198c3 100644 +index bccb6bec25e693dfc60dc24807078768dbf1e6ed..e4a082384a4aacf2fa9c925ff5ebe7afb012c242 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 { +@@ -145,6 +145,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable { public org.bukkit.generator.ChunkGenerator generator; public static final boolean DEBUG_ENTITIES = Boolean.getBoolean("debug.entities"); // Paper @@ -38,10 +38,10 @@ index 3c37eaf12fc256a8edf5a5d060e4ca262ec83108..785f621ab4be55cb6f216bf11731aee2 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 a9f84d594e2adda096d872d4b7ca59e73305544b..42407844fb5af663f03bdcade2fe9c4a9e8058f8 100644 +index 50d96a6e2bcd4e276dbdbf99b55870782f92cc00..f94bcceb7c2749a9176d96c90832b0808de055f6 100644 --- a/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/src/main/java/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -475,7 +475,7 @@ public class RedStoneWireBlock extends Block { +@@ -484,7 +484,7 @@ public class RedStoneWireBlock extends Block { @Override public void onRemove(BlockState state, Level world, BlockPos pos, BlockState newState, boolean moved) { @@ -50,15 +50,3 @@ index a9f84d594e2adda096d872d4b7ca59e73305544b..42407844fb5af663f03bdcade2fe9c4a super.onRemove(state, world, pos, newState, moved); if (!world.isClientSide) { Direction[] aenumdirection = Direction.values(); -diff --git a/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java b/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java -index 19faa8f5f891c1ffbed0af8391dee8202433c447..2f07e1c8fc769a28f235858e1529ab154e0d2247 100644 ---- a/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java -+++ b/src/main/java/net/minecraft/world/level/redstone/NeighborUpdater.java -@@ -52,6 +52,7 @@ public interface NeighborUpdater { - - static void executeUpdate(Level world, BlockState state, BlockPos pos, Block sourceBlock, BlockPos sourcePos, boolean notify) { - try { -+ if (world.preventNeighborUpdates) { return; } // Sakura - fix placement causing physics when event is cancelled - // CraftBukkit start - CraftWorld cworld = ((ServerLevel) world).getWorld(); - if (cworld != null) { diff --git a/patches/server/0062-Use-random-chance-for-crop-growth-instead-of-age.patch b/patches/server/0062-Use-random-chance-for-crop-growth-instead-of-age.patch new file mode 100644 index 0000000..167fab6 --- /dev/null +++ b/patches/server/0062-Use-random-chance-for-crop-growth-instead-of-age.patch @@ -0,0 +1,54 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik +Date: Thu, 16 May 2024 21:20:52 +0100 +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 4323e5cc2054804243e8e2f24fd5447280f218de..7bb9d94d3a7241dcaf8d02f12ef6e698befb289f 100644 +--- a/src/main/java/net/minecraft/world/level/block/CactusBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/CactusBlock.java +@@ -46,6 +46,19 @@ public class CactusBlock extends Block { + + @Override + public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { ++ // Sakura start - use random chance for crop growth ++ if (world.sakuraConfig.useRandomChanceToGrow) { ++ int modifier = world.spigotConfig.cactusModifier; ++ if (random.nextFloat() >= modifier / (100.0f * 16)) { ++ return; ++ } ++ // set crop age to max so it grows right away ++ state = state.setValue(CactusBlock.AGE, AGE.max); ++ } ++ this.ageAndGrow(state, world, pos, random); ++ } ++ private void ageAndGrow(BlockState state, ServerLevel world, BlockPos pos, Random random) { ++ // Sakura end - use random chance for crop growth + BlockPos blockposition1 = pos.above(); + + if (world.isEmptyBlock(blockposition1)) { +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 66c06e0f7c8d223a2b00bab57a15e3a705fe176a..9d0cde1cf6e89ef505010d38686ff540ade55e3c 100644 +--- a/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java ++++ b/src/main/java/net/minecraft/world/level/block/SugarCaneBlock.java +@@ -45,6 +45,19 @@ public class SugarCaneBlock extends Block { + + @Override + public void randomTick(BlockState state, ServerLevel world, BlockPos pos, Random random) { ++ // Sakura start - use random chance for crop growth ++ if (world.sakuraConfig.useRandomChanceToGrow) { ++ int modifier = world.spigotConfig.caneModifier; ++ if (random.nextFloat() >= modifier / (100.0f * 16)) { ++ return; ++ } ++ // set crop age to max so it grows right away ++ state = state.setValue(SugarCaneBlock.AGE, AGE.max); ++ } ++ this.ageAndGrow(state, world, pos, random); ++ } ++ private void ageAndGrow(BlockState state, ServerLevel world, BlockPos pos, Random random) { ++ // Sakura end - use random chance for crop growth + if (world.isEmptyBlock(pos.above())) { + int i; + diff --git a/patches/server/0067-Legacy-player-combat-mechanics.patch b/patches/server/0063-Legacy-player-combat-mechanics.patch similarity index 86% rename from patches/server/0067-Legacy-player-combat-mechanics.patch rename to patches/server/0063-Legacy-player-combat-mechanics.patch index f58419e..108b45e 100644 --- a/patches/server/0067-Legacy-player-combat-mechanics.patch +++ b/patches/server/0063-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 f2e0f4eb5f07ef4bd31282f3d12b8d8380ce22a0..4de9d99999c82854460b08b8b841699132e2f1e9 100644 +index 3dd0fc22946459679aabb31bfe4ddb0580aa85f0..68623284e48a091c47efc78b238fd9a2afd07765 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -279,6 +279,64 @@ public abstract class LivingEntity extends Entity { +@@ -275,6 +275,64 @@ public abstract class LivingEntity extends Entity { ++this.noActionTime; // Above all the floats } // Spigot end @@ -64,7 +64,7 @@ index f2e0f4eb5f07ef4bd31282f3d12b8d8380ce22a0..4de9d99999c82854460b08b8b8416991 + if (attackSpeed != null) { + attackSpeed.removeModifier(LEGACY_ATTACK_SPEED_MODIFIER); + -+ if (this.level.sakuraConfig().players.combat.legacyCombatMechanics) { ++ if (this.level.sakuraConfig.legacyCombatMechanics) { + attackSpeed.addTransientModifier(LEGACY_ATTACK_SPEED_MODIFIER); + } + } @@ -74,7 +74,7 @@ index f2e0f4eb5f07ef4bd31282f3d12b8d8380ce22a0..4de9d99999c82854460b08b8b8416991 + AttributeInstance attackDamage = this.getAttribute(Attributes.ATTACK_DAMAGE); + AttributeModifier legacyModifier = null; + -+ if (this.level.sakuraConfig().players.combat.legacyCombatMechanics) { ++ if (this.level.sakuraConfig.legacyCombatMechanics) { + legacyModifier = this.getLegacyAttackModifier(); + } + @@ -116,12 +116,12 @@ index f2e0f4eb5f07ef4bd31282f3d12b8d8380ce22a0..4de9d99999c82854460b08b8b8416991 protected LivingEntity(EntityType type, Level world) { super(type, world); -@@ -2052,7 +2110,16 @@ public abstract class LivingEntity extends Entity { +@@ -1969,7 +2027,16 @@ public abstract class LivingEntity extends Entity { protected float getDamageAfterArmorAbsorb(DamageSource source, float amount) { 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.legacyCombatMechanics) { amount = CombatRules.getDamageAfterAbsorb(amount, (float) this.getArmorValue(), (float) this.getAttributeValue(Attributes.ARMOR_TOUGHNESS)); + } else { + // See: applyArmorModifier(DamageSource, float) @@ -133,7 +133,7 @@ index f2e0f4eb5f07ef4bd31282f3d12b8d8380ce22a0..4de9d99999c82854460b08b8b8416991 } return amount; -@@ -3142,6 +3209,12 @@ public abstract class LivingEntity extends Entity { +@@ -3070,6 +3137,12 @@ public abstract class LivingEntity extends Entity { if (!itemstack1.isEmpty()) { this.getAttributes().addTransientAttributeModifiers(itemstack1.getAttributeModifiers(enumitemslot)); } @@ -146,7 +146,7 @@ index f2e0f4eb5f07ef4bd31282f3d12b8d8380ce22a0..4de9d99999c82854460b08b8b8416991 } } -@@ -3288,7 +3361,7 @@ public abstract class LivingEntity extends Entity { +@@ -3201,7 +3274,7 @@ public abstract class LivingEntity extends Entity { this.lastArmorItemStacks.set(slot.getIndex(), armor); } @@ -156,24 +156,24 @@ index f2e0f4eb5f07ef4bd31282f3d12b8d8380ce22a0..4de9d99999c82854460b08b8b8416991 } 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 2c36d3c1939ca4185f4143b846c522a0c9f5b460..979c2c8ac3ed68dc2c4741cddb0c4415326a9271 100644 +index 371737a38acb4ee5e7712e0e9d9db55f4303dfe1..77c6b49c89e13a85042bc3dd4d81f8c0a9d14224 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -1251,7 +1251,7 @@ public abstract class Player extends LivingEntity { - if (playerAttackEntityEvent.callEvent() && willAttack) { // Logic moved to willAttack local variable. - { - // Paper end +@@ -1215,7 +1215,7 @@ public abstract class Player extends LivingEntity { + public void attack(Entity target) { + if (target.isAttackable()) { + if (!target.skipAttackInteraction(this)) { - float f = (float) this.getAttributeValue(Attributes.ATTACK_DAMAGE); + float f = this.getAttackDamageFromAttributes(); // Sakura - legacy combat mechanics float f1; if (target instanceof LivingEntity) { -@@ -1262,8 +1262,14 @@ public abstract class Player extends LivingEntity { +@@ -1226,8 +1226,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.legacyCombatMechanics) { f *= 0.2F + f2 * f2 * 0.8F; f1 *= f2; + } else if (f1 != 0.0) { @@ -183,16 +183,16 @@ index 2c36d3c1939ca4185f4143b846c522a0c9f5b460..979c2c8ac3ed68dc2c4741cddb0c4415 // 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; -@@ -1280,7 +1286,7 @@ public abstract class Player extends LivingEntity { +@@ -1244,7 +1250,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 && !level.paperConfig().entities.behavior.disablePlayerCrits; // Paper + flag2 = flag2 && !level.paperConfig.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.legacyCombatMechanics || !this.isSprinting()); // Sakura - legacy combat mechanics if (flag2) { f *= 1.5F; } -@@ -1472,6 +1478,27 @@ public abstract class Player extends LivingEntity { +@@ -1436,6 +1442,27 @@ public abstract class Player extends LivingEntity { } } diff --git a/patches/server/0068-Allow-disabling-sweep-attacks.patch b/patches/server/0064-Allow-disabling-sweep-attacks.patch similarity index 74% rename from patches/server/0068-Allow-disabling-sweep-attacks.patch rename to patches/server/0064-Allow-disabling-sweep-attacks.patch index 2191591..7bb170b 100644 --- a/patches/server/0068-Allow-disabling-sweep-attacks.patch +++ b/patches/server/0064-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 979c2c8ac3ed68dc2c4741cddb0c4415326a9271..c990388f5b0146c9b94c8d825edb723f607d11df 100644 +index 77c6b49c89e13a85042bc3dd4d81f8c0a9d14224..180d561ecc88f2a190f1eb9dbe3cfe426d393be9 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -1357,7 +1357,7 @@ public abstract class Player extends LivingEntity { +@@ -1321,7 +1321,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.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)); Iterator iterator = list.iterator(); diff --git a/patches/server/0064-Mob-spawner-behaviour.patch b/patches/server/0064-Mob-spawner-behaviour.patch deleted file mode 100644 index 6c1ee5b..0000000 --- a/patches/server/0064-Mob-spawner-behaviour.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Samsuik -Date: Thu, 28 Mar 2024 15:44:33 +0000 -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 c7c11747879fecd0e01a4c5de1c396957303f3bc..d97d1aa47590b7c8250f1221f078641e01e430eb 100644 ---- a/src/main/java/net/minecraft/world/level/BaseSpawner.java -+++ b/src/main/java/net/minecraft/world/level/BaseSpawner.java -@@ -64,7 +64,7 @@ public abstract class BaseSpawner { - } - - public boolean isNearPlayer(Level world, BlockPos pos) { -- return world.hasNearbyAlivePlayerThatAffectsSpawning((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, (double) this.requiredPlayerRange); // Paper - Affects Spawning API -+ return !world.sakuraConfig().environment.mobSpawner.requireNearbyPlayer || world.hasNearbyAlivePlayerThatAffectsSpawning((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, (double) this.requiredPlayerRange); // Sakura - mob spawner behaviour // Paper - Affects Spawning API - } - - public void clientTick(Level world, BlockPos pos) { -@@ -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; - } -- } else if (!SpawnPlacements.checkSpawnRules((EntityType) optional.get(), world, MobSpawnType.SPAWNER, blockposition1, world.getRandom())) { -+ } 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 -@@ -170,7 +170,7 @@ public abstract class BaseSpawner { - return; - } - -- 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); -@@ -182,7 +182,7 @@ public abstract class BaseSpawner { - if (entity instanceof Mob) { - Mob entityinsentient = (Mob) entity; - -- if (mobspawnerdata.getCustomSpawnRules().isEmpty() && !entityinsentient.checkSpawnRules(world, MobSpawnType.SPAWNER) || !entityinsentient.checkSpawnObstruction(world)) { -+ if (world.sakuraConfig().environment.mobSpawner.checkSpawnConditions && (mobspawnerdata.getCustomSpawnRules().isEmpty() && !entityinsentient.checkSpawnRules(world, MobSpawnType.SPAWNER) || !entityinsentient.checkSpawnObstruction(world))) { // Sakura - mob spawner behaviour - continue; - } - diff --git a/patches/server/0069-Change-shields-to-reduce-damage.patch b/patches/server/0065-Change-shields-to-reduce-damage.patch similarity index 78% rename from patches/server/0069-Change-shields-to-reduce-damage.patch rename to patches/server/0065-Change-shields-to-reduce-damage.patch index f80fd21..89a092e 100644 --- a/patches/server/0069-Change-shields-to-reduce-damage.patch +++ b/patches/server/0065-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 4de9d99999c82854460b08b8b841699132e2f1e9..659cf60f5a1da5c13ebdf2dc315f538265ba4a39 100644 +index 68623284e48a091c47efc78b238fd9a2afd07765..3e5bb455eb8f3591b564a59438671c8fdfba4996 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -2186,7 +2186,13 @@ public abstract class LivingEntity extends Entity { +@@ -2101,7 +2101,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 (!LivingEntity.this.level.sakuraConfig.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/0070-Old-enchanted-golden-apples.patch b/patches/server/0066-Old-enchanted-golden-apples.patch similarity index 95% rename from patches/server/0070-Old-enchanted-golden-apples.patch rename to patches/server/0066-Old-enchanted-golden-apples.patch index 3e4386d..e3742c2 100644 --- a/patches/server/0070-Old-enchanted-golden-apples.patch +++ b/patches/server/0066-Old-enchanted-golden-apples.patch @@ -5,10 +5,10 @@ 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 659cf60f5a1da5c13ebdf2dc315f538265ba4a39..7cb6e250bd1c14e557c359fe211d8a1f9b4de986 100644 +index 3e5bb455eb8f3591b564a59438671c8fdfba4996..e4cca2f8d39344cbc7987723b09882f591a273d7 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -4411,7 +4411,13 @@ public abstract class LivingEntity extends Entity { +@@ -4308,7 +4308,13 @@ public abstract class LivingEntity extends Entity { Item item = stack.getItem(); if (item.isEdible()) { diff --git a/patches/server/0066-Use-random-chance-for-crop-growth-instead-of-age.patch b/patches/server/0066-Use-random-chance-for-crop-growth-instead-of-age.patch deleted file mode 100644 index 2a087e2..0000000 --- a/patches/server/0066-Use-random-chance-for-crop-growth-instead-of-age.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Samsuik -Date: Thu, 16 May 2024 21:20:52 +0100 -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 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 -@@ -46,6 +46,19 @@ public class CactusBlock extends Block { - - @Override - public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { -+ // Sakura start - use random chance for crop growth -+ if (world.sakuraConfig().environment.crops.useRandomChanceToGrow) { -+ int modifier = world.spigotConfig.cactusModifier; -+ if (random.nextFloat() >= modifier / (100.0f * 16)) { -+ return; -+ } -+ // set crop age to max so it grows right away -+ state = state.setValue(CactusBlock.AGE, AGE.max); -+ } -+ this.ageAndGrow(state, world, pos, random); -+ } -+ private void ageAndGrow(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { -+ // Sakura end - use random chance for crop growth - BlockPos blockposition1 = pos.above(); - - if (world.isEmptyBlock(blockposition1)) { -@@ -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); -- -+ // Sakura start - use random chance for crop growth -+ if (world.sakuraConfig().environment.crops.useRandomChanceToGrow) { -+ world.neighborShapeChanged(Direction.UP, state, blockposition1, pos, 4, 1); -+ } -+ // Sakura end - use random chance for crop growth - world.setBlock(pos, iblockdata1, 4); - 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 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 -@@ -45,6 +45,19 @@ public class SugarCaneBlock extends Block { - - @Override - public void randomTick(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { -+ // Sakura start - use random chance for crop growth -+ if (world.sakuraConfig().environment.crops.useRandomChanceToGrow) { -+ int modifier = world.spigotConfig.caneModifier; -+ if (random.nextFloat() >= modifier / (100.0f * 16)) { -+ return; -+ } -+ // set crop age to max so it grows right away -+ state = state.setValue(SugarCaneBlock.AGE, AGE.max); -+ } -+ this.ageAndGrow(state, world, pos, random); -+ } -+ private void ageAndGrow(BlockState state, ServerLevel world, BlockPos pos, RandomSource random) { -+ // Sakura end - use random chance for crop growth - if (world.isEmptyBlock(pos.above())) { - int i; - -@@ -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); -+ // Sakura - conflict on change - } else if (modifier == 100 || random.nextFloat() < (modifier / (100.0f * 16))) { // Spigot - SPIGOT-7159: Better modifier resolution - world.setBlock(pos, (BlockState) state.setValue(SugarCaneBlock.AGE, j + 1), 4); - } diff --git a/patches/server/0071-Configure-fast-health-regen.patch b/patches/server/0067-Configure-fast-health-regen.patch similarity index 79% rename from patches/server/0071-Configure-fast-health-regen.patch rename to patches/server/0067-Configure-fast-health-regen.patch index 359e2d9..c53ed4f 100644 --- a/patches/server/0071-Configure-fast-health-regen.patch +++ b/patches/server/0067-Configure-fast-health-regen.patch @@ -5,7 +5,7 @@ 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 2934b6de1f1fb914a532ee20184df99d1acd8e65..9b4f0dfb6eea305063e145d45c98f57dd9c136a4 100644 +index 2934b6de1f1fb914a532ee20184df99d1acd8e65..f7c38dc7baf2500f958cab3c06bacdb96e83957c 100644 --- a/src/main/java/net/minecraft/world/food/FoodData.java +++ b/src/main/java/net/minecraft/world/food/FoodData.java @@ -79,7 +79,7 @@ public class FoodData { @@ -13,7 +13,7 @@ index 2934b6de1f1fb914a532ee20184df99d1acd8e65..9b4f0dfb6eea305063e145d45c98f57d 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.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/0072-Add-option-for-fishing-hooks-pulling-entities.patch b/patches/server/0068-Add-option-for-fishing-hooks-pulling-entities.patch similarity index 71% rename from patches/server/0072-Add-option-for-fishing-hooks-pulling-entities.patch rename to patches/server/0068-Add-option-for-fishing-hooks-pulling-entities.patch index 989a133..dc09e9a 100644 --- a/patches/server/0072-Add-option-for-fishing-hooks-pulling-entities.patch +++ b/patches/server/0068-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 70016e105066a16d19ebdf631cc3ef0a03466e3a..35151fa7c8bc8bcafffda6b0292e2c9c50caae43 100644 +index 5ad727d59f67a49c2ed5cb09be11c86e0b74d9f0..7b9a771cd1129963861cad97d49d43ba67b6ce66 100644 --- a/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java +++ b/src/main/java/net/minecraft/world/entity/projectile/FishingHook.java -@@ -581,7 +581,7 @@ public class FishingHook extends Projectile { +@@ -580,7 +580,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.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/0073-Old-combat-sounds-and-particle-effects.patch b/patches/server/0069-Old-combat-sounds-and-particle-effects.patch similarity index 64% rename from patches/server/0073-Old-combat-sounds-and-particle-effects.patch rename to patches/server/0069-Old-combat-sounds-and-particle-effects.patch index 2ae33c7..ef4613c 100644 --- a/patches/server/0073-Old-combat-sounds-and-particle-effects.patch +++ b/patches/server/0069-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 c990388f5b0146c9b94c8d825edb723f607d11df..211d1dff3833bbf23a4d76ce70e8cf2ece2d8ec0 100644 +index 180d561ecc88f2a190f1eb9dbe3cfe426d393be9..618d9d066defa6fe941681e089ad7539f1738464 100644 --- a/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java -@@ -1453,7 +1453,7 @@ public abstract class Player extends LivingEntity { +@@ -1417,7 +1417,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 && !this.level.sakuraConfig.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); -@@ -1937,6 +1937,7 @@ public abstract class Player extends LivingEntity { +@@ -1896,6 +1896,7 @@ public abstract class Player extends LivingEntity { } // 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 ++ if (fromEntity.level.sakuraConfig.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())); + ((ServerPlayer) fromEntity).connection.send(new ClientboundSoundPacket(soundEffect, soundCategory, x, y, z, volume, pitch)); diff --git a/patches/server/0074-Protect-scaffolding-from-creepers.patch b/patches/server/0070-Protect-scaffolding-from-creepers.patch similarity index 72% rename from patches/server/0074-Protect-scaffolding-from-creepers.patch rename to patches/server/0070-Protect-scaffolding-from-creepers.patch index 151c518..a3e3f78 100644 --- a/patches/server/0074-Protect-scaffolding-from-creepers.patch +++ b/patches/server/0070-Protect-scaffolding-from-creepers.patch @@ -5,15 +5,15 @@ 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 4047610d0a01ce58f023da9a810ea3f5320892e7..ea37fb1f7107f38ae2de0c6335d83e4de8587b3b 100644 +index 68b9b340b6dddcf29f7c3d80600854dd87b67f65..edbe7bf8016c0f9d7f0edd960a5b8fa590020feb 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -326,6 +326,11 @@ public class Explosion { +@@ -334,6 +334,11 @@ public class Explosion { return Optional.of(-0.3f); } // Sakura end - allow explosions to destroy lava + // Sakura start - protect scaffolding from creepers -+ if (this.level.sakuraConfig().cannons.explosion.protectScaffoldingFromCreepers && blockState.is(Blocks.SCAFFOLDING) && this.source instanceof net.minecraft.world.entity.monster.Creeper) { ++ if (this.level.sakuraConfig.protectScaffoldingFromCreepers && blockState.is(Blocks.SCAFFOLDING) && this.source instanceof net.minecraft.world.entity.monster.Creeper) { + return Optional.of(Blocks.BARRIER.getExplosionResistance()); + } + // Sakura end - protect scaffolding from creepers diff --git a/patches/server/0075-Entity-tracking-range-modifier.patch b/patches/server/0071-Entity-tracking-range-modifier.patch similarity index 84% rename from patches/server/0075-Entity-tracking-range-modifier.patch rename to patches/server/0071-Entity-tracking-range-modifier.patch index 1193c37..30a354e 100644 --- a/patches/server/0075-Entity-tracking-range-modifier.patch +++ b/patches/server/0071-Entity-tracking-range-modifier.patch @@ -5,10 +5,10 @@ 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 5e326f26b5166b7ce79bad5724ae63392d53fa45..d7b3b3def7ae557dd8420096e8232a7be592ffcb 100644 +index ee7871ddd36b20206ef66372b04861d100601341..ed83c97b4859e1061f09bc6db6a36ae652d45c71 100644 --- a/src/main/java/net/minecraft/server/level/ChunkMap.java +++ b/src/main/java/net/minecraft/server/level/ChunkMap.java -@@ -1620,7 +1620,10 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -2351,7 +2351,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 @@ -21,22 +21,22 @@ index 5e326f26b5166b7ce79bad5724ae63392d53fa45..d7b3b3def7ae557dd8420096e8232a7b double d2 = d0 * d0; 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 5f38f9a7aca3af47dc3454035a7faf1d30d05932..5b876f7ee8f34f553a5e02dd2a6771a374996950 100644 +index 8aea11619f256bcfd91cf9af968bee4daf0f3381..986ff99fe0e4d3dc080159a514044ffe0c846d11 100644 --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java -@@ -269,6 +269,7 @@ public class ServerPlayer extends Player { +@@ -258,6 +258,7 @@ public class ServerPlayer extends Player { + public double lastEntitySpawnRadiusSquared; // Paper - optimise isOutsideRange, this field is in blocks 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) { 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 aaa3b2aa8e8791d88e2fb08342ec8c133cd219d6..f05ede50e07805d2432c7ed6af02f8babb94c506 100644 +index f16ba5860484de0e211d954436d2e5106a651808..3461634deff779307be4e6a94d19cfcb5b3cbaae 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -2562,6 +2562,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -2370,6 +2370,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { return (this.getHandle().clientViewDistance == null) ? Bukkit.getViewDistance() : this.getHandle().clientViewDistance; } diff --git a/patches/server/0076-Set-entity-impulse-on-explosion.patch b/patches/server/0072-Set-entity-impulse-on-explosion.patch similarity index 92% rename from patches/server/0076-Set-entity-impulse-on-explosion.patch rename to patches/server/0072-Set-entity-impulse-on-explosion.patch index c37b7c7..48f2d20 100644 --- a/patches/server/0076-Set-entity-impulse-on-explosion.patch +++ b/patches/server/0072-Set-entity-impulse-on-explosion.patch @@ -17,10 +17,10 @@ index a6b4cae3f04cda71629b5da3a08a8c4c7b51b8a7..b32a86c3b6e9d8b378626901389cf201 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 ea37fb1f7107f38ae2de0c6335d83e4de8587b3b..26f65df8bb684f8f672c755f4c47cf9a64e459de 100644 +index edbe7bf8016c0f9d7f0edd960a5b8fa590020feb..43cca0134a6f609f88b6aab96a150543353bf1b6 100644 --- a/src/main/java/net/minecraft/world/level/Explosion.java +++ b/src/main/java/net/minecraft/world/level/Explosion.java -@@ -490,6 +490,7 @@ public class Explosion { +@@ -494,6 +494,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 } diff --git a/patches/server/0077-Configurable-left-shooting-and-adjusting-limits.patch b/patches/server/0073-Configurable-left-shooting-and-adjusting-limits.patch similarity index 84% rename from patches/server/0077-Configurable-left-shooting-and-adjusting-limits.patch rename to patches/server/0073-Configurable-left-shooting-and-adjusting-limits.patch index 56c0360..6a388cd 100644 --- a/patches/server/0077-Configurable-left-shooting-and-adjusting-limits.patch +++ b/patches/server/0073-Configurable-left-shooting-and-adjusting-limits.patch @@ -5,17 +5,17 @@ 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 13906fc7d31e11d75754fe2c39c5ddf267d5ddb0..8b7cb6929d40db0844b594282cf32d98e54c6217 100644 +index 6934dec885c91d44a6c81bd6df75c2f5420e1fc3..701597d3b809a0c62ad6b7302d55762e393fbcfc 100644 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java -@@ -716,6 +716,24 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { +@@ -600,6 +600,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 + public final void limitLeftShooting() { + Vec3 movement = this.getDeltaMovement(); -+ int threshold = this.level.sakuraConfig().cannons.restrictions.leftShootingThreshold.or(-1); ++ int threshold = this.level.sakuraConfig.leftShootingThreshold.orElse(-1); + if (threshold > 0 && (movement.x != 0.0 || movement.z != 0.0) && this.origin != null) { + double travelledX = Math.abs(this.getX() - this.origin.getX()); + double travelledZ = Math.abs(this.getZ() - this.origin.getZ()); @@ -31,16 +31,16 @@ index 13906fc7d31e11d75754fe2c39c5ddf267d5ddb0..8b7cb6929d40db0844b594282cf32d98 + } + // Sakura end - configurable left shooting and adjusting limits - public Entity(EntityType type, Level world) { - this.id = Entity.ENTITY_COUNTER.incrementAndGet(); -@@ -1654,6 +1672,25 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource { + // Paper start + /** +@@ -1567,6 +1585,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 + // Sakura start - configurable left shooting and adjusting limits + // NOTE: If scanAndCollide is made redundant by paper move this logic into CollisionUtil. + // This is being after xSmaller is intentional, we do not want to change the adjust direction. -+ int adjustDistance = this.level.sakuraConfig().cannons.restrictions.maxAdjustDistance.or(-1); ++ int adjustDistance = this.level.sakuraConfig.maxAdjustDistance.orElse(-1); + if (adjustDistance > 0) { + if (xSmaller) { // adjust z -> x + if (Math.abs(z) > adjustDistance) { @@ -60,10 +60,10 @@ index 13906fc7d31e11d75754fe2c39c5ddf267d5ddb0..8b7cb6929d40db0844b594282cf32d98 if (y != 0.0) { 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 d4e8bffc31415663fd3628ad33acc2d59e2036ca..d38d6c269a5da6ff5b347c8838123d9f3b7593e4 100644 +index b1f47ff80ed96c9f3ea1e4af45143c0d148c7226..a42f0867c0b8eb81a3922da495d8672ef02983cb 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 { +@@ -255,6 +255,7 @@ public class FallingBlockEntity extends Entity { // Sakura end - physics version api } diff --git a/patches/server/0078-Allow-projectiles-to-load-chunks-for-collisions.patch b/patches/server/0074-Allow-projectiles-to-load-chunks-for-collisions.patch similarity index 91% rename from patches/server/0078-Allow-projectiles-to-load-chunks-for-collisions.patch rename to patches/server/0074-Allow-projectiles-to-load-chunks-for-collisions.patch index 7dec15e..1b90eb0 100644 --- a/patches/server/0078-Allow-projectiles-to-load-chunks-for-collisions.patch +++ b/patches/server/0074-Allow-projectiles-to-load-chunks-for-collisions.patch @@ -5,14 +5,14 @@ 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 +index 53d0024daf6963ac4dab575666b0d6a74a39a958..e84bf61502c8c88ff1084ed14b859417736375cc 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 { +@@ -88,6 +88,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 ++ this.loadChunks = this.level.sakuraConfig.projectilesLoadChunksForCollisions; // Sakura - allow projectiles to load chunks for collisions } protected AbstractArrow(EntityType type, double x, double y, double z, Level world) { diff --git a/patches/server/0079-Add-max-armour-durability-damage.patch b/patches/server/0075-Add-max-armour-durability-damage.patch similarity index 80% rename from patches/server/0079-Add-max-armour-durability-damage.patch rename to patches/server/0075-Add-max-armour-durability-damage.patch index c944b7c..019346f 100644 --- a/patches/server/0079-Add-max-armour-durability-damage.patch +++ b/patches/server/0075-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 7cb6e250bd1c14e557c359fe211d8a1f9b4de986..fd7c3b3bd3665a65c8412fd9455c2320878960a7 100644 +index e4cca2f8d39344cbc7987723b09882f591a273d7..4cf618bbdbad5dcc37dbceae891ee7fe67befa86 100644 --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java -@@ -2278,6 +2278,12 @@ public abstract class LivingEntity extends Entity { +@@ -2193,6 +2193,12 @@ public abstract class LivingEntity extends Entity { // Apply damage to 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.maxArmourDamage.orElse(-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/0076-Airplane-Strip-raytracing-for-EntityLiving-hasLineOf.patch similarity index 88% rename from patches/server/0080-Airplane-Strip-raytracing-for-EntityLiving-hasLineOf.patch rename to patches/server/0076-Airplane-Strip-raytracing-for-EntityLiving-hasLineOf.patch index 782a367..61bc534 100644 --- a/patches/server/0080-Airplane-Strip-raytracing-for-EntityLiving-hasLineOf.patch +++ b/patches/server/0076-Airplane-Strip-raytracing-for-EntityLiving-hasLineOf.patch @@ -27,10 +27,10 @@ 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 +index 4cf618bbdbad5dcc37dbceae891ee7fe67befa86..dbe40c2ef967166a6c315053a6a3196c3de94e96 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 { +@@ -3652,7 +3652,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 @@ -64,10 +64,10 @@ index 04d45b2ddc3489c4d0764da1575cb9a373d9a490..5cb899dd7ab92552605e74b2840d57a4 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 +index e4a082384a4aacf2fa9c925ff5ebe7afb012c242..2cae6e4696071586a43b84ea216f02a53a56b11f 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 { +@@ -385,6 +385,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 @@ -156,5 +156,5 @@ index 785f621ab4be55cb6f216bf11731aee2f40198c3..7c8c7f74bbb27ed8f23e2f99062e9502 + } + // 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 + public CraftServer getCraftServer() { + return (CraftServer) Bukkit.getServer(); diff --git a/patches/server/0081-Optimise-explosion-raytracing.patch b/patches/server/0077-Optimise-explosion-raytracing.patch similarity index 92% rename from patches/server/0081-Optimise-explosion-raytracing.patch rename to patches/server/0077-Optimise-explosion-raytracing.patch index f01fb5f..350541c 100644 --- a/patches/server/0081-Optimise-explosion-raytracing.patch +++ b/patches/server/0077-Optimise-explosion-raytracing.patch @@ -25,10 +25,10 @@ index 5cb899dd7ab92552605e74b2840d57a40f4c1434..da60f48e50ecffd5bdd87badaaa7a515 // 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 +index 43cca0134a6f609f88b6aab96a150543353bf1b6..9b58f58ff40dc6952a8f32b6c1226f82a98fc6b8 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 { +@@ -381,6 +381,8 @@ public class Explosion { // Sakura start - physics version api } else if (entity.physics().before(1_14_0)) { hitResult = entity.level.rayTrace(vec3d1, source); @@ -38,18 +38,18 @@ index 26f65df8bb684f8f672c755f4c47cf9a64e459de..8e8688402d27eaf79daf9027ac07e86f 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 +index da7b4783da35bc08f48f2fe31c4d06f9fb5e160f..f678238897402c7fc919b881f49df5d465fdb012 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; +@@ -697,6 +697,7 @@ public abstract class BlockBehaviour { + this.hasPostProcess = blockbase_info.hasPostProcess; + this.emissiveRendering = blockbase_info.emissiveRendering; 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 { +@@ -736,6 +737,12 @@ public abstract class BlockBehaviour { return this.blockCollisionBehavior; } // Paper end @@ -61,7 +61,7 @@ index 25ce337ed266be7bafeacd9eb6f53a9474775fc5..4b3a93feb78dccd33ab7caf792a86816 + // Sakura end - optimise explosion raytracing public void initCache() { - this.fluidState = ((Block) this.owner).getFluidState(this.asState()); + this.fluid = this.getBlock().getFluidState(this.asState()); // Paper - moved from getFluid() 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 diff --git a/patches/server/0082-PAPER-Check-for-block-type-in-SculkSensorBlock-canAc.patch b/patches/server/0078-PAPER-Check-for-block-type-in-SculkSensorBlock-canAc.patch similarity index 86% rename from patches/server/0082-PAPER-Check-for-block-type-in-SculkSensorBlock-canAc.patch rename to patches/server/0078-PAPER-Check-for-block-type-in-SculkSensorBlock-canAc.patch index 140238c..38bfd73 100644 --- a/patches/server/0082-PAPER-Check-for-block-type-in-SculkSensorBlock-canAc.patch +++ b/patches/server/0078-PAPER-Check-for-block-type-in-SculkSensorBlock-canAc.patch @@ -6,10 +6,10 @@ Subject: [PATCH] PAPER - Check for block type in SculkSensorBlock#canActivate Backported https://github.com/PaperMC/Paper/commit/4e6a2a13a3e1f6fa1067a7821d2f018339395533 diff --git a/src/main/java/net/minecraft/world/level/block/SculkSensorBlock.java b/src/main/java/net/minecraft/world/level/block/SculkSensorBlock.java -index b1d86e5e04e762e9ed6136003cb3e05dffd7e8f1..99cf1d14efa76fec86d6502b37d0cb98d6c351d4 100644 +index 4a0e4b9c49f04d63ca0b7d0a6ce71680f911ff29..4a842e2302c1d186639c7e8f9766800e079dd125 100644 --- a/src/main/java/net/minecraft/world/level/block/SculkSensorBlock.java +++ b/src/main/java/net/minecraft/world/level/block/SculkSensorBlock.java -@@ -200,7 +200,7 @@ public class SculkSensorBlock extends BaseEntityBlock implements SimpleWaterlogg +@@ -223,7 +223,7 @@ public class SculkSensorBlock extends BaseEntityBlock implements SimpleWaterlogg } public static boolean canActivate(BlockState state) { diff --git a/patches/server/0083-PAPER-Improve-standard-messenger-logging.patch b/patches/server/0079-PAPER-Improve-standard-messenger-logging.patch similarity index 88% rename from patches/server/0083-PAPER-Improve-standard-messenger-logging.patch rename to patches/server/0079-PAPER-Improve-standard-messenger-logging.patch index 5b5b06b..fb870e3 100644 --- a/patches/server/0083-PAPER-Improve-standard-messenger-logging.patch +++ b/patches/server/0079-PAPER-Improve-standard-messenger-logging.patch @@ -6,10 +6,10 @@ Subject: [PATCH] PAPER Improve standard messenger logging Backported https://github.com/PaperMC/Paper/commit/7c9240f4a63b13be1fdcedbfb0270f9b49b75518 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index f05ede50e07805d2432c7ed6af02f8babb94c506..d5005ed440d5f51d18f30207751007e72eec0855 100644 +index 3461634deff779307be4e6a94d19cfcb5b3cbaae..138c0fd113c2cfd7be9554427a6a8c7c715a706f 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -2129,7 +2129,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { +@@ -1950,7 +1950,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { // Paper end public void addChannel(String channel) { diff --git a/patches/server/0084-PAPER-Break-redstone-on-top-of-trap-doors-early.patch b/patches/server/0080-PAPER-Break-redstone-on-top-of-trap-doors-early.patch similarity index 94% rename from patches/server/0084-PAPER-Break-redstone-on-top-of-trap-doors-early.patch rename to patches/server/0080-PAPER-Break-redstone-on-top-of-trap-doors-early.patch index a496bb3..551ca48 100644 --- a/patches/server/0084-PAPER-Break-redstone-on-top-of-trap-doors-early.patch +++ b/patches/server/0080-PAPER-Break-redstone-on-top-of-trap-doors-early.patch @@ -9,10 +9,10 @@ as a result of redstone powering the trap door. Backported https://github.com/PaperMC/Paper/commit/4f9575eed827007f31ce17da471820fe8bc14573 diff --git a/src/main/java/net/minecraft/world/level/block/TrapDoorBlock.java b/src/main/java/net/minecraft/world/level/block/TrapDoorBlock.java -index 91966d9c90d30738a1912ab6ce81edd914b939ff..65d665aed39063dc799998777a3b562729aca48c 100644 +index c0d232e5ace817d64740ccfcad9880349410f5a1..42b776eaa5ada1fee7957ec82ee95efa7005190b 100644 --- a/src/main/java/net/minecraft/world/level/block/TrapDoorBlock.java +++ b/src/main/java/net/minecraft/world/level/block/TrapDoorBlock.java -@@ -127,7 +127,26 @@ public class TrapDoorBlock extends HorizontalDirectionalBlock implements SimpleW +@@ -129,7 +129,26 @@ public class TrapDoorBlock extends HorizontalDirectionalBlock implements SimpleW flag1 = eventRedstone.getNewCurrent() > 0; } // CraftBukkit end diff --git a/patches/server/0085-PAPER-Make-sure-the-player-didn-t-disconnect-when-pr.patch b/patches/server/0081-PAPER-Make-sure-the-player-didn-t-disconnect-when-pr.patch similarity index 60% rename from patches/server/0085-PAPER-Make-sure-the-player-didn-t-disconnect-when-pr.patch rename to patches/server/0081-PAPER-Make-sure-the-player-didn-t-disconnect-when-pr.patch index 89ff624..7e533f0 100644 --- a/patches/server/0085-PAPER-Make-sure-the-player-didn-t-disconnect-when-pr.patch +++ b/patches/server/0081-PAPER-Make-sure-the-player-didn-t-disconnect-when-pr.patch @@ -7,14 +7,14 @@ Subject: [PATCH] PAPER Make sure the player didn't disconnect when processing Backported https://github.com/PaperMC/Paper/commit/813d0399f9880c4ee5ccd3e60d9e20b358b70df2 diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 60fc19f25245f491c31018ec7cb065ced3516c44..ca0e142503455d7c231627c4aa17337454c99d7d 100644 +index f451ed92f75a6f5553790ca97cabbcdfd0d3d169..ed872d7165982a28f702f258e342c3c681e3f5f4 100644 --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2245,6 +2245,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic - - if (optional.isPresent()) { - this.server.submit(() -> { +@@ -2114,6 +2114,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser + boolean isSync = s.startsWith("/"); + if (isSync) { + try { + if (player.hasDisconnected()) return; // Paper - this.performChatCommand(packet, (LastSeenMessages) optional.get()); - this.detectRateSpam("/" + packet.command()); // Spigot - }); + this.server.server.playerCommandState = true; + this.handleCommand(s); + } finally { diff --git a/patches/server/0087-Improve-paper-biome-cache-locking.patch b/patches/server/0082-Improve-paper-biome-cache-locking.patch similarity index 83% rename from patches/server/0087-Improve-paper-biome-cache-locking.patch rename to patches/server/0082-Improve-paper-biome-cache-locking.patch index febac60..928c971 100644 --- a/patches/server/0087-Improve-paper-biome-cache-locking.patch +++ b/patches/server/0082-Improve-paper-biome-cache-locking.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Improve paper biome cache locking diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java -index 962c950ca9c7e047a3aec215d4faa73676049d36..f9f2119f6d48305641c088f76e2ef878fc776fe0 100644 +index bfe9dc935c87e01fb435d8b46ce413b84ca74856..526c7f4ae3388f5dbb5661f1be04ebb46f533f30 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java -@@ -368,13 +368,28 @@ public class CraftBlock implements Block { +@@ -366,13 +366,29 @@ public class CraftBlock implements Block { return (biome == null) ? Biome.CUSTOM : biome; } @@ -20,8 +20,8 @@ index 962c950ca9c7e047a3aec215d4faa73676049d36..f9f2119f6d48305641c088f76e2ef878 if (bio == null || bio == Biome.CUSTOM) { return null; } -- -- return registry.getHolderOrThrow(BIOME_KEY_CACHE.computeIfAbsent(bio, b -> ResourceKey.create(Registries.BIOME, CraftNamespacedKey.toMinecraft(b.getKey())))); // Paper - cache key + +- return registry.getHolderOrThrow(BIOME_KEY_CACHE.computeIfAbsent(bio, b -> ResourceKey.create(net.minecraft.core.Registry.BIOME_REGISTRY, CraftNamespacedKey.toMinecraft(b.getKey())))); // Paper - cache key + // NOTE: Could get rid of the map by splitting up this patch and storing a reference in Biome (under api) + long stamp = BIOME_KEY_CACHE_LOCK.tryOptimisticRead(); + ResourceKey biomeKey = null; @@ -32,7 +32,7 @@ index 962c950ca9c7e047a3aec215d4faa73676049d36..f9f2119f6d48305641c088f76e2ef878 + } + if (biomeKey == null || !BIOME_KEY_CACHE_LOCK.validate(stamp)) { + stamp = BIOME_KEY_CACHE_LOCK.writeLock(); -+ biomeKey = BIOME_KEY_CACHE.computeIfAbsent(bio, b -> ResourceKey.create(Registries.BIOME, CraftNamespacedKey.toMinecraft(b.getKey()))); // Paper - cache key ++ biomeKey = BIOME_KEY_CACHE.computeIfAbsent(bio, b -> ResourceKey.create(net.minecraft.core.Registry.BIOME_REGISTRY, CraftNamespacedKey.toMinecraft(b.getKey()))); // Paper - cache key + BIOME_KEY_CACHE_LOCK.unlockWrite(stamp); + } + return registry.getHolderOrThrow(biomeKey); diff --git a/patches/server/0088-Add-lava-flow-speed-api.patch b/patches/server/0083-Add-lava-flow-speed-api.patch similarity index 84% rename from patches/server/0088-Add-lava-flow-speed-api.patch rename to patches/server/0083-Add-lava-flow-speed-api.patch index 1aa9342..e677173 100644 --- a/patches/server/0088-Add-lava-flow-speed-api.patch +++ b/patches/server/0083-Add-lava-flow-speed-api.patch @@ -5,11 +5,11 @@ Subject: [PATCH] Add lava flow speed api 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 211f4574c3053487ce689efc5cfc0f6d94b629a8..0a53c34c051e5beb27f3250fdd501d672ea108b7 100644 +index f4f4ae2583bdbca4d9db9f20221d68d1881be2cd..4e54b631477b73c44b268d3a99af2468a9ca6b4f 100644 --- a/src/main/java/net/minecraft/world/level/block/LiquidBlock.java +++ b/src/main/java/net/minecraft/world/level/block/LiquidBlock.java -@@ -123,7 +123,7 @@ public class LiquidBlock extends Block implements BucketPickup { - return world.paperConfig().environment.waterOverLavaFlowSpeed; +@@ -124,7 +124,7 @@ public class LiquidBlock extends Block implements BucketPickup { + return world.paperConfig.waterOverLavaFlowSpeed; } } - return this.fluid.getTickDelay(world); @@ -18,7 +18,7 @@ index 211f4574c3053487ce689efc5cfc0f6d94b629a8..0a53c34c051e5beb27f3250fdd501d67 // Paper end diff --git a/src/main/java/net/minecraft/world/level/material/Fluid.java b/src/main/java/net/minecraft/world/level/material/Fluid.java -index 4a6b0869ac305d181e48d6c592d30af297486df0..e119ad20676dfadf0e575a8959d665e393e91608 100644 +index a961523886702dc7ce34be06f239927b2129476b..89bf13e5e595d0b6ef7661597b2196b757b8d7ee 100644 --- a/src/main/java/net/minecraft/world/level/material/Fluid.java +++ b/src/main/java/net/minecraft/world/level/material/Fluid.java @@ -68,6 +68,12 @@ public abstract class Fluid { @@ -35,7 +35,7 @@ index 4a6b0869ac305d181e48d6c592d30af297486df0..e119ad20676dfadf0e575a8959d665e3 protected boolean isRandomlyTicking() { 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 1fb85a64eca4ef8a778f5b8652f774d1cfb707c4..36d6e7799b9f7e91d39c8080e839ce134034d187 100644 +index 0f13a5ea286ed42f117dd7473365ec642b46b82d..ea748b29cc7c00f0b2ffa9c162a6240989196de9 100644 --- a/src/main/java/net/minecraft/world/level/material/LavaFluid.java +++ b/src/main/java/net/minecraft/world/level/material/LavaFluid.java @@ -181,6 +181,14 @@ public abstract class LavaFluid extends FlowingFluid { @@ -52,7 +52,7 @@ index 1fb85a64eca4ef8a778f5b8652f774d1cfb707c4..36d6e7799b9f7e91d39c8080e839ce13 + @Override public int getTickDelay(LevelReader world) { - return world.dimensionType().ultraWarm() && !(world instanceof Level level && level.sakuraConfig().environment.disableFastNetherLava) ? 10 : 30; // Sakura + return world.dimensionType().ultraWarm() && !(world instanceof Level level && level.sakuraConfig.disableFastNetherLava) ? 10 : 30; // Sakura @@ -188,7 +196,7 @@ public abstract class LavaFluid extends FlowingFluid { @Override diff --git a/patches/server/0084-temp.patch b/patches/server/0084-temp.patch new file mode 100644 index 0000000..e4471c4 --- /dev/null +++ b/patches/server/0084-temp.patch @@ -0,0 +1,22 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samsuik +Date: Fri, 14 Mar 2025 18:37:26 +0000 +Subject: [PATCH] temp + + +diff --git a/build.gradle.kts b/build.gradle.kts +index d1b4eb9088d5780f56d8df2d4542e6d408c61e6c..fb9250a4e904e75604094694e1dc021e678d1389 100644 +--- a/build.gradle.kts ++++ b/build.gradle.kts +@@ -201,7 +201,7 @@ tasks.registerRunTask("runReobf") { + classpath(runtimeClasspathWithoutVanillaServer) + } + +-tasks.registerRunTask("runDev") { +- description = "Spin up a non-relocated Mojang-mapped test server" +- classpath(sourceSets.main.map { it.runtimeClasspath }) +-} ++//tasks.registerRunTask("runDev") { ++// description = "Spin up a non-relocated Mojang-mapped test server" ++// classpath(sourceSets.main.map { it.runtimeClasspath }) ++//} diff --git a/patches/server/0002-Decompile-fixes.patch b/patches/unap-server/removed/1.18.2/0002-Decompile-fixes.patch similarity index 100% rename from patches/server/0002-Decompile-fixes.patch rename to patches/unap-server/removed/1.18.2/0002-Decompile-fixes.patch diff --git a/patches/server/0011-Optimise-New-Liquid-Level.patch b/patches/unap-server/removed/1.18.2/0011-Optimise-New-Liquid-Level.patch similarity index 100% rename from patches/server/0011-Optimise-New-Liquid-Level.patch rename to patches/unap-server/removed/1.18.2/0011-Optimise-New-Liquid-Level.patch diff --git a/patches/server/0023-Limited-Get-Entities.patch b/patches/unap-server/removed/1.18.2/0023-Limited-Get-Entities.patch similarity index 100% rename from patches/server/0023-Limited-Get-Entities.patch rename to patches/unap-server/removed/1.18.2/0023-Limited-Get-Entities.patch diff --git a/patches/server/0028-Optimise-LivingEntity-pushEntities.patch b/patches/unap-server/removed/1.18.2/0028-Optimise-LivingEntity-pushEntities.patch similarity index 100% rename from patches/server/0028-Optimise-LivingEntity-pushEntities.patch rename to patches/unap-server/removed/1.18.2/0028-Optimise-LivingEntity-pushEntities.patch diff --git a/patches/server/0086-Dont-kick-for-out-of-order-chat.patch b/patches/unap-server/removed/1.18.2/0086-Dont-kick-for-out-of-order-chat.patch similarity index 100% rename from patches/server/0086-Dont-kick-for-out-of-order-chat.patch rename to patches/unap-server/removed/1.18.2/0086-Dont-kick-for-out-of-order-chat.patch