From bbcc85fa932a5bdcdc86d9106615654a87f3d39e Mon Sep 17 00:00:00 2001 From: Helvetica Volubi Date: Thu, 18 Dec 2025 09:42:25 +0800 Subject: [PATCH] 1.21.11 Early Access waypoint has force disabled because of some serious bug --- gradle.properties | 11 +- lophine-api/build.gradle.kts.patch | 2 +- .../0002-Leaves-Add-fakeplayer-api.patch | 8 +- .../features/0003-Leaves-Replay-Mod-API.patch | 8 +- lophine-server/build.gradle.kts.patch | 12 +- ...o-allow-generation-of-end-void-rings.patch | 19 -- ...to-disable-some-check-for-operators.patch} | 36 +- ...-to-enable-cross-region-damage-trace.patch | 18 +- ...-config-to-enable-raytracing-tracker.patch | 32 +- ...dd-config-to-enable-function-command.patch | 4 +- ...-config-to-enable-scoreboard-command.patch | 6 +- ...06-Add-config-to-enable-tick-command.patch | 40 +-- ...onfig-to-enable-waypoint-command-bar.patch | 6 +- ...8-Fix-datapack-command-save-function.patch | 10 +- .../0009-Leaves-Base-Protocol-Core.patch | 50 +-- ...s-Configurable-trading-with-the-void.patch | 14 +- .../0011-Leaves-Item-overstack-util.patch | 126 +++---- ...aves-Old-Explosion-Damage-Calculator.patch | 12 +- .../0013-Leaves-Old-raid-behavior.patch | 24 +- .../0015-Leaves-Servux-Protocol.patch | 15 +- ...-for-Raid-Revert-and-Cross-Region-D.patch} | 10 +- ...rpur-Barrels-and-enderchests-6-rows.patch} | 24 +- ...-support.patch => 0019-I18n-support.patch} | 8 +- ...ch => 0020-Old-zombie-reinforcement.patch} | 10 +- ...tch => 0021-Spawn-invulnerable-time.patch} | 10 +- ...yer.patch => 0022-Leaves-Fakeplayer.patch} | 310 ++++++++---------- ... 0023-Modify-merge-ItemEntity-logic.patch} | 4 +- ... => 0024-Leaves-Syncmatica-Protocol.patch} | 4 +- ....patch => 0025-Leaves-BBOR-Protocol.patch} | 4 +- ....patch => 0026-Leaves-Jade-Protocol.patch} | 44 ++- ...h => 0027-Leaves-Xaero-Map-Protocol.patch} | 10 +- ...=> 0028-Leaves-Support-REI-protocol.patch} | 8 +- ... => 0029-Leaves-Wool-Hopper-Counter.patch} | 10 +- ...lternative-block-placement-Protocol.patch} | 41 ++- ...patch => 0031-Leaves-Replay-Mod-API.patch} | 177 +++++----- ...aves-Catch-update-suppression-crash.patch} | 77 +++-- ... 0033-Leaves-CCE-update-suppression.patch} | 6 +- ...aves-Redstone-ignore-upwards-update.patch} | 10 +- .../features/0035-Instant-Block-Updater.patch | 52 +++ .../features/0036-Instant-Block-Updater.patch | 19 -- ...rt-TrapDoorBlock-changes-form-Paper.patch} | 6 +- ...ss-of-item-drops-due-to-update-supp.patch} | 10 +- ...8-Leaves-Old-Block-remove-behaviour.patch} | 124 +++---- ...et-placed-block-on-exception-Do-not.patch} | 6 +- ...tch => 0040-Global-Entities-Counter.patch} | 30 +- ...k-in-RegionizedWorldData-conections.patch} | 0 .../features/0001-Rebrand-to-Lophine.patch | 15 +- ...urpur-Barrels-and-enderchests-6-rows.patch | 4 +- .../0003-Leaves-Leaves-Protocol-Core.patch | 6 +- ...avesHooks.patch => 0004-LeavesHooks.patch} | 0 ...y-task-id-in-FoliaGlobalRegionSched.patch} | 16 +- ...ch => 0006-Leaves-Leaves-Fakeplayer.patch} | 38 +-- ...patch => 0007-Leaves-Replay-Mod-API.patch} | 18 +- .../modules/fixes/EndVoidRingsConfig.java | 15 - .../config/modules/removed/RemovedConfig.java | 2 + .../utils/concurrent/ConcurrentTable.java | 1 + .../concurrent/OptimizedConcurrentTable.java | 1 + .../leavesmc/leaves/bot/BotDataStorage.java | 1 - .../java/org/leavesmc/leaves/bot/BotList.java | 44 +-- .../leavesmc/leaves/bot/BotStatsCounter.java | 5 +- .../leaves/bot/IPlayerDataStorage.java | 6 +- .../org/leavesmc/leaves/bot/ServerBot.java | 31 +- .../bot/agent/actions/ServerMountAction.java | 2 +- .../bot/subcommands/CreateCommand.java | 4 +- .../command/bot/subcommands/ListCommand.java | 6 +- .../leaves/protocol/AppleSkinProtocol.java | 20 +- .../leaves/protocol/BBORProtocol.java | 30 +- .../leaves/protocol/XaeroMapProtocol.java | 14 +- .../protocol/core/LeavesCustomPayload.java | 4 +- .../protocol/core/LeavesProtocolManager.java | 20 +- .../leaves/protocol/core/ProtocolUtils.java | 10 +- .../MinecraftRegisterInvokerHolder.java | 6 +- .../leaves/protocol/jade/JadeProtocol.java | 42 +-- .../protocol/jade/accessor/Accessor.java | 50 ++- .../protocol/jade/accessor/AccessorImpl.java | 77 ----- .../protocol/jade/accessor/BlockAccessor.java | 124 ++++++- .../jade/accessor/BlockAccessorImpl.java | 160 --------- .../jade/accessor/EntityAccessor.java | 104 ++++-- .../jade/accessor/EntityAccessorImpl.java | 129 -------- .../jade/payload/ClientHandshakePayload.java | 4 +- .../jade/payload/ReceiveDataPayload.java | 4 +- .../jade/payload/RequestBlockPayload.java | 15 +- .../jade/payload/RequestEntityPayload.java | 15 +- .../jade/payload/ServerHandshakePayload.java | 16 +- .../ItemStorageExtensionProvider.java | 16 +- .../jade/provider/ItemStorageProvider.java | 12 +- .../{IJadeProvider.java => JadeProvider.java} | 6 +- ...aProvider.java => ServerDataProvider.java} | 2 +- ...ider.java => ServerExtensionProvider.java} | 2 +- .../provider/StreamServerDataProvider.java | 2 +- .../jade/provider/block/BeehiveProvider.java | 6 +- .../provider/block/BlockNameProvider.java | 6 +- .../provider/block/BrewingStandProvider.java | 6 +- .../jade/provider/block/CampfireProvider.java | 19 +- .../block/ChiseledBookshelfProvider.java | 10 +- .../provider/block/CommandBlockProvider.java | 6 +- .../jade/provider/block/FurnaceProvider.java | 6 +- .../provider/block/HopperLockProvider.java | 6 +- .../jade/provider/block/JukeboxProvider.java | 6 +- .../jade/provider/block/LecternProvider.java | 6 +- .../block/MobSpawnerCooldownProvider.java | 6 +- .../jade/provider/block/RedstoneProvider.java | 10 +- .../provider/entity/AnimalOwnerProvider.java | 45 ++- .../provider/entity/MobBreedingProvider.java | 6 +- .../provider/entity/MobGrowthProvider.java | 6 +- .../entity/NextEntityDropProvider.java | 12 +- .../provider/entity/PetArmorProvider.java | 6 +- .../entity/StatusEffectsProvider.java | 6 +- .../entity/ZombieVillagerProvider.java | 8 +- .../leaves/protocol/jade/util/CommonUtil.java | 32 +- .../protocol/jade/util/HierarchyLookup.java | 15 +- .../protocol/jade/util/IHierarchyLookup.java | 14 +- .../protocol/jade/util/ItemCollector.java | 20 +- .../jade/util/LootTableMineableCollector.java | 2 +- .../jade/util/PairHierarchyLookup.java | 14 +- .../leaves/protocol/jade/util/ViewGroup.java | 6 +- .../jade/util/WrappedHierarchyLookup.java | 10 +- .../protocol/rei/PacketTransformer.java | 12 +- .../protocol/rei/REIServerProtocol.java | 46 +-- .../protocol/rei/display/BlastingDisplay.java | 6 +- .../protocol/rei/display/CampfireDisplay.java | 6 +- .../protocol/rei/display/CookingDisplay.java | 10 +- .../protocol/rei/display/CraftingDisplay.java | 4 +- .../protocol/rei/display/CustomDisplay.java | 12 +- .../leaves/protocol/rei/display/Display.java | 32 +- .../protocol/rei/display/ShapedDisplay.java | 14 +- .../rei/display/ShapelessDisplay.java | 16 +- .../protocol/rei/display/SmeltingDisplay.java | 6 +- .../protocol/rei/display/SmithingDisplay.java | 22 +- .../protocol/rei/display/SmokingDisplay.java | 6 +- .../rei/display/StoneCuttingDisplay.java | 14 +- .../rei/ingredient/EntryIngredient.java | 6 +- .../servux/ServuxEntityDataProtocol.java | 6 +- .../servux/ServuxHudDataProtocol.java | 14 +- .../protocol/servux/ServuxProtocol.java | 6 +- .../servux/ServuxStructuresProtocol.java | 6 +- .../litematics/LitematicaSchematic.java | 4 +- .../litematics/ServuxLitematicsProtocol.java | 6 +- .../servux/litematics/utils/EntityUtils.java | 2 +- .../utils/SchematicPlacingUtils.java | 2 +- .../protocol/servux/logger/DataLogger.java | 4 +- .../syncmatica/CommunicationManager.java | 10 +- .../protocol/syncmatica/PacketType.java | 6 +- .../syncmatica/PlayerIdentifierProvider.java | 2 +- .../syncmatica/SyncmaticaPayload.java | 10 +- .../syncmatica/exchange/DownloadExchange.java | 6 +- .../syncmatica/exchange/Exchange.java | 6 +- .../syncmatica/exchange/ExchangeTarget.java | 4 +- .../syncmatica/exchange/FeatureExchange.java | 6 +- .../exchange/ModifyExchangeServer.java | 6 +- .../syncmatica/exchange/UploadExchange.java | 6 +- .../exchange/VersionHandshakeServer.java | 6 +- .../leavesmc/leaves/util/HopperCounter.java | 10 +- .../leaves/util/ShearsWrenchUtil.java | 2 +- .../util/UpdateSuppressionException.java | 2 +- 155 files changed, 1517 insertions(+), 1688 deletions(-) delete mode 100644 lophine-server/minecraft-patches/features/0001-Add-config-to-allow-generation-of-end-void-rings.patch rename lophine-server/minecraft-patches/features/{0019-Disable-some-check-for-operators.patch => 0001-Add-configs-to-disable-some-check-for-operators.patch} (68%) rename lophine-server/minecraft-patches/features/{0018-Compatibility-fix-for-Raid-Revert-and-Cross-Region-D.patch => 0017-Compatibility-fix-for-Raid-Revert-and-Cross-Region-D.patch} (86%) rename lophine-server/minecraft-patches/features/{0017-Purpur-Barrels-and-enderchests-6-rows.patch => 0018-Purpur-Barrels-and-enderchests-6-rows.patch} (90%) rename lophine-server/minecraft-patches/features/{0020-I18n-support.patch => 0019-I18n-support.patch} (90%) rename lophine-server/minecraft-patches/features/{0021-Old-zombie-reinforcement.patch => 0020-Old-zombie-reinforcement.patch} (66%) rename lophine-server/minecraft-patches/features/{0022-Spawn-invulnerable-time.patch => 0021-Spawn-invulnerable-time.patch} (85%) rename lophine-server/minecraft-patches/features/{0023-Leaves-Fakeplayer.patch => 0022-Leaves-Fakeplayer.patch} (74%) rename lophine-server/minecraft-patches/features/{0024-Modify-merge-ItemEntity-logic.patch => 0023-Modify-merge-ItemEntity-logic.patch} (89%) rename lophine-server/minecraft-patches/features/{0025-Leaves-Syncmatica-Protocol.patch => 0024-Leaves-Syncmatica-Protocol.patch} (91%) rename lophine-server/minecraft-patches/features/{0026-Leaves-BBOR-Protocol.patch => 0025-Leaves-BBOR-Protocol.patch} (82%) rename lophine-server/minecraft-patches/features/{0027-Leaves-Jade-Protocol.patch => 0026-Leaves-Jade-Protocol.patch} (71%) rename lophine-server/minecraft-patches/features/{0028-Leaves-Xaero-Map-Protocol.patch => 0027-Leaves-Xaero-Map-Protocol.patch} (63%) rename lophine-server/minecraft-patches/features/{0029-Leaves-Support-REI-protocol.patch => 0028-Leaves-Support-REI-protocol.patch} (83%) rename lophine-server/minecraft-patches/features/{0030-Leaves-Wool-Hopper-Counter.patch => 0029-Leaves-Wool-Hopper-Counter.patch} (93%) rename lophine-server/minecraft-patches/features/{0031-Leaves-Alternative-block-placement-Protocol.patch => 0030-Leaves-Alternative-block-placement-Protocol.patch} (79%) rename lophine-server/minecraft-patches/features/{0032-Leaves-Replay-Mod-API.patch => 0031-Leaves-Replay-Mod-API.patch} (81%) rename lophine-server/minecraft-patches/features/{0033-Leaves-Catch-update-suppression-crash.patch => 0032-Leaves-Catch-update-suppression-crash.patch} (77%) rename lophine-server/minecraft-patches/features/{0034-Leaves-CCE-update-suppression.patch => 0033-Leaves-CCE-update-suppression.patch} (84%) rename lophine-server/minecraft-patches/features/{0035-Leaves-Redstone-ignore-upwards-update.patch => 0034-Leaves-Redstone-ignore-upwards-update.patch} (89%) create mode 100644 lophine-server/minecraft-patches/features/0035-Instant-Block-Updater.patch delete mode 100644 lophine-server/minecraft-patches/features/0036-Instant-Block-Updater.patch rename lophine-server/minecraft-patches/features/{0037-Revert-TrapDoorBlock-changes-form-paperMC.patch => 0036-Revert-TrapDoorBlock-changes-form-Paper.patch} (94%) rename lophine-server/minecraft-patches/features/{0038-Leaves-Prevent-loss-of-item-drops-due-to-update-supp.patch => 0037-Leaves-Prevent-loss-of-item-drops-due-to-update-supp.patch} (85%) rename lophine-server/minecraft-patches/features/{0039-Leaves-Old-Block-remove-behaviour.patch => 0038-Leaves-Old-Block-remove-behaviour.patch} (87%) rename lophine-server/minecraft-patches/features/{0040-Leaves-Do-not-reset-placed-block-on-exception-Do-not.patch => 0039-Leaves-Do-not-reset-placed-block-on-exception-Do-not.patch} (94%) rename lophine-server/minecraft-patches/features/{0041-Global-Entities-Counter.patch => 0040-Global-Entities-Counter.patch} (86%) rename lophine-server/minecraft-patches/features/{0042-Add-null-check-in-RegionizedWorldData-conections.patch => 0041-Add-null-check-in-RegionizedWorldData-conections.patch} (100%) rename lophine-server/paper-patches/features/{0005-LeavesHooks.patch => 0004-LeavesHooks.patch} (100%) rename lophine-server/paper-patches/features/{0007-add-cancel-task-by-task-id-in-FoliaGlobalRegionSched.patch => 0005-Add-cancel-task-by-task-id-in-FoliaGlobalRegionSched.patch} (88%) rename lophine-server/paper-patches/features/{0004-Leaves-Leaves-Fakeplayer.patch => 0006-Leaves-Leaves-Fakeplayer.patch} (85%) rename lophine-server/paper-patches/features/{0006-Leaves-Replay-Mod-API.patch => 0007-Leaves-Replay-Mod-API.patch} (90%) delete mode 100644 lophine-server/src/main/java/fun/bm/lophine/config/modules/fixes/EndVoidRingsConfig.java delete mode 100644 lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/AccessorImpl.java delete mode 100644 lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessorImpl.java delete mode 100644 lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessorImpl.java rename lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/{IJadeProvider.java => JadeProvider.java} (88%) rename lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/{IServerDataProvider.java => ServerDataProvider.java} (91%) rename lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/{IServerExtensionProvider.java => ServerExtensionProvider.java} (93%) diff --git a/gradle.properties b/gradle.properties index 35c054f..00ec12c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,13 @@ group=fun.bm.lophine -version=1.21.8-R0.1-SNAPSHOT -mcVersion=1.21.8 -release=2 +version=1.21.11-R0.1-SNAPSHOT +mcVersion=1.21.11 +# This is the current API version for use in (paper-)plugin.yml files +# During snapshot cycles this should be the anticipated version of the release target +apiVersion=1.21.11 +release=1 # 0 for skip release, 1 for pre-release, 2 for release -luminolRef=e324edacf6651633674a0abce91ffbd290943dd5 +luminolRef=15a752089b6efaf43595f879baab001c5e6f0f66 org.gradle.configuration-cache=true org.gradle.caching=true diff --git a/lophine-api/build.gradle.kts.patch b/lophine-api/build.gradle.kts.patch index 50f4fd3..87b4ec7 100644 --- a/lophine-api/build.gradle.kts.patch +++ b/lophine-api/build.gradle.kts.patch @@ -1,6 +1,6 @@ --- a/luminol-api/build.gradle.kts +++ b/luminol-api/build.gradle.kts -@@ -103,20 +_,24 @@ +@@ -104,20 +_,24 @@ srcDir(generatedDir) srcDir(file("../paper-api/src/main/java")) srcDir(file("../folia-api/src/main/java")) diff --git a/lophine-api/paper-patches/features/0002-Leaves-Add-fakeplayer-api.patch b/lophine-api/paper-patches/features/0002-Leaves-Add-fakeplayer-api.patch index 02c1d91..8c6ebd6 100644 --- a/lophine-api/paper-patches/features/0002-Leaves-Add-fakeplayer-api.patch +++ b/lophine-api/paper-patches/features/0002-Leaves-Add-fakeplayer-api.patch @@ -8,10 +8,10 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index 85b778980e762835ac278528087e91b2e3effb43..89f00f4b6ff64305fa44ebb71f22a113c1296d26 100644 +index b9d34c0b80a5d0c26f43e4959c3a8256a854585a..850f65d764030b09d469e33a69409204503d9ca1 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -3052,4 +3052,15 @@ public final class Bukkit { +@@ -3039,4 +3039,15 @@ public final class Bukkit { public static void restart() { server.restart(); } @@ -28,10 +28,10 @@ index 85b778980e762835ac278528087e91b2e3effb43..89f00f4b6ff64305fa44ebb71f22a113 + // Leaves end - Bot API } diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index a0540d7de5c2536aed5231f9e67b73345817921d..c7ae463fb166750bbd0638a2ccf81753b293a381 100644 +index 1dc5d8c96786950fc98cada5bad981c0c716b154..cb8c4e09511f99558eb5af26c08c5cb1f936780d 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2753,4 +2753,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2791,4 +2791,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ double @Nullable [] getRegionTPS(@NotNull World world, int chunkX, int chunkZ); // Folia end - region TPS API diff --git a/lophine-api/paper-patches/features/0003-Leaves-Replay-Mod-API.patch b/lophine-api/paper-patches/features/0003-Leaves-Replay-Mod-API.patch index e3875ce..d64690b 100644 --- a/lophine-api/paper-patches/features/0003-Leaves-Replay-Mod-API.patch +++ b/lophine-api/paper-patches/features/0003-Leaves-Replay-Mod-API.patch @@ -8,10 +8,10 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index 89f00f4b6ff64305fa44ebb71f22a113c1296d26..e9d20fe8b88aa63fb62effd430b5e22c8dbe1307 100644 +index 850f65d764030b09d469e33a69409204503d9ca1..78b947352aa32ae0c59101459f420bf8e3497707 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java -@@ -3063,4 +3063,10 @@ public final class Bukkit { +@@ -3050,4 +3050,10 @@ public final class Bukkit { return server.getBotManager(); } // Leaves end - Bot API @@ -23,10 +23,10 @@ index 89f00f4b6ff64305fa44ebb71f22a113c1296d26..e9d20fe8b88aa63fb62effd430b5e22c + // Leaves end - Photographer API } diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index c7ae463fb166750bbd0638a2ccf81753b293a381..4caadc8f9b328d978ece84c1480e32f24868531f 100644 +index cb8c4e09511f99558eb5af26c08c5cb1f936780d..b770b6f990d46f5325554f5d73c6a2a6ed361158 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2762,4 +2762,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2800,4 +2800,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ @NotNull org.leavesmc.leaves.entity.bot.BotManager getBotManager(); // Leaves end - Bot API diff --git a/lophine-server/build.gradle.kts.patch b/lophine-server/build.gradle.kts.patch index aafb919..bc13049 100644 --- a/lophine-server/build.gradle.kts.patch +++ b/lophine-server/build.gradle.kts.patch @@ -1,6 +1,6 @@ --- a/luminol-server/build.gradle.kts +++ b/luminol-server/build.gradle.kts -@@ -52,7 +_,23 @@ +@@ -48,7 +_,23 @@ } } @@ -25,7 +25,7 @@ spigot { -@@ -142,12 +_,16 @@ +@@ -139,12 +_,16 @@ resources { srcDir("../paper-server/src/main/resources") } java { srcDir("../folia-server/src/main/java") } resources { srcDir("../folia-server/src/main/resources") } @@ -42,16 +42,16 @@ } } val log4jPlugins = sourceSets.create("log4jPlugins") { -@@ -174,7 +_,7 @@ +@@ -172,7 +_,7 @@ } dependencies { - implementation(project(":luminol-api")) // Luminol + implementation(project(":lophine-api")) // Lophine // Luminol start - Dependenices insert - implementation("com.electronwill.night-config:toml:3.8.2") // Night config + implementation("com.electronwill.night-config:toml:3.8.3") // Night config implementation("com.github.luben:zstd-jni:1.5.4-1") -@@ -275,14 +_,14 @@ +@@ -272,14 +_,14 @@ val gitBranch = git.exec(providers, "rev-parse", "--abbrev-ref", "HEAD").get().trim() attributes( "Main-Class" to "org.bukkit.craftbukkit.Main", @@ -70,7 +70,7 @@ "Build-Number" to (build ?: ""), "Build-Time" to buildTime.toString(), "Git-Branch" to gitBranch, -@@ -446,7 +_,7 @@ +@@ -431,7 +_,7 @@ } fill { diff --git a/lophine-server/minecraft-patches/features/0001-Add-config-to-allow-generation-of-end-void-rings.patch b/lophine-server/minecraft-patches/features/0001-Add-config-to-allow-generation-of-end-void-rings.patch deleted file mode 100644 index 5b69d49..0000000 --- a/lophine-server/minecraft-patches/features/0001-Add-config-to-allow-generation-of-end-void-rings.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Helvetica Volubi -Date: Tue, 26 Aug 2025 02:55:23 +0800 -Subject: [PATCH] Add config to allow generation of end void rings - - -diff --git a/net/minecraft/world/level/levelgen/DensityFunctions.java b/net/minecraft/world/level/levelgen/DensityFunctions.java -index 04527a5c65ad630f794fed9071d485aedd02257a..57e4c6c60f7d012a9de411b07d000f3504c27e6b 100644 ---- a/net/minecraft/world/level/levelgen/DensityFunctions.java -+++ b/net/minecraft/world/level/levelgen/DensityFunctions.java -@@ -528,7 +528,7 @@ public final class DensityFunctions { - int i1 = z / 2; - int i2 = x % 2; - int i3 = z % 2; -- float f = 100.0F - Mth.sqrt((long)x * (long)x + (long)z * (long)z) * 8.0F; // Paper - cast ints to long to avoid integer overflow -+ float f = fun.bm.lophine.config.modules.fixes.EndVoidRingsConfig.enabled ? 100.0F - Mth.sqrt(x * x + z * z) * 8.0F : 100.0F - Mth.sqrt((long)x * (long)x + (long)z * (long)z) * 8.0F; // Paper - cast ints to long to avoid integer overflow // Lophine - customize end void rings generation - f = Mth.clamp(f, -100.0F, 80.0F); - - NoiseCache cache = noiseCache.get().computeIfAbsent(noise, noiseKey -> new NoiseCache()); // Paper - Perf: Optimize end generation diff --git a/lophine-server/minecraft-patches/features/0019-Disable-some-check-for-operators.patch b/lophine-server/minecraft-patches/features/0001-Add-configs-to-disable-some-check-for-operators.patch similarity index 68% rename from lophine-server/minecraft-patches/features/0019-Disable-some-check-for-operators.patch rename to lophine-server/minecraft-patches/features/0001-Add-configs-to-disable-some-check-for-operators.patch index 03261d0..e834744 100644 --- a/lophine-server/minecraft-patches/features/0019-Disable-some-check-for-operators.patch +++ b/lophine-server/minecraft-patches/features/0001-Add-configs-to-disable-some-check-for-operators.patch @@ -1,55 +1,55 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Helvetica Volubi Date: Sun, 3 Aug 2025 14:26:37 +0800 -Subject: [PATCH] Disable some check for operators +Subject: [PATCH] Add configs to disable some check for operators diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index f06b9d8ad9512d35f3f460eb77c869690321c67f..e17f9629369f8653b484b4cc71de4874b5faa4d6 100644 +index 718a10b442997c8225a7de27ff92c1f36b809a9e..5757832ca91c42b417a95a2536a282a24eef0ef7 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -367,7 +367,7 @@ public class ServerGamePacketListenerImpl +@@ -391,7 +391,7 @@ public class ServerGamePacketListenerImpl this.tickCount++; this.knownMovePacketCount = this.receivedMovePacketCount; if (this.clientIsFloating && !this.player.isSleeping() && !this.player.isPassenger() && !this.player.isDeadOrDying()) { - if (++this.aboveGroundTickCount > this.getMaximumFlyingTicks(this.player)) { -+ if (++this.aboveGroundTickCount > this.getMaximumFlyingTicks(this.player) && !(fun.bm.lophine.config.modules.misc.DisableCheckConfig.disableOpFlyCheck && this.player.hasPermissions(2))) { // Lophine - disable fly check for operator - // LOGGER.warn("{} was kicked for floating too long!", this.player.getName().getString()); // Paper - Logging moved to net.minecraft.server.network.ServerCommonPacketListenerImpl.disconnect() ++ if (++this.aboveGroundTickCount > this.getMaximumFlyingTicks(this.player) && !(fun.bm.lophine.config.modules.misc.DisableCheckConfig.disableOpFlyCheck && MinecraftServer.getServer().getPlayerList().isOp(this.player.nameAndId()))) { // Lophine - disable fly check for operator + // LOGGER.warn("{} was kicked for floating too long!", this.player.getPlainTextName()); // Paper - Logging moved to net.minecraft.server.network.ServerCommonPacketListenerImpl.disconnect() this.disconnect(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.flyingPlayer, org.bukkit.event.player.PlayerKickEvent.Cause.FLYING_PLAYER); // Paper - use configurable kick message & kick event cause - return; -@@ -386,7 +386,7 @@ public class ServerGamePacketListenerImpl + return true; +@@ -410,7 +410,7 @@ public class ServerGamePacketListenerImpl this.vehicleLastGoodY = this.lastVehicle.getY(); this.vehicleLastGoodZ = this.lastVehicle.getZ(); if (this.clientVehicleIsFloating && this.lastVehicle.getControllingPassenger() == this.player) { - if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle)) { -+ if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle) && !(fun.bm.lophine.config.modules.misc.DisableCheckConfig.disableOpFlyCheck && this.player.hasPermissions(2))) { // Lophine - disable fly check for operator - // LOGGER.warn("{} was kicked for floating a vehicle too long!", this.player.getName().getString()); // Paper - Logging moved to net.minecraft.server.network.ServerCommonPacketListenerImpl.disconnect() ++ if (++this.aboveGroundVehicleTickCount > this.getMaximumFlyingTicks(this.lastVehicle) && !(fun.bm.lophine.config.modules.misc.DisableCheckConfig.disableOpFlyCheck && MinecraftServer.getServer().getPlayerList().isOp(this.player.nameAndId()))) { // Lophine - disable fly check for operator + // LOGGER.warn("{} was kicked for floating a vehicle too long!", this.player.getPlainTextName()); // Paper - Logging moved to net.minecraft.server.network.ServerCommonPacketListenerImpl.disconnect() this.disconnect(io.papermc.paper.configuration.GlobalConfiguration.get().messages.kick.flyingVehicle, org.bukkit.event.player.PlayerKickEvent.Cause.FLYING_VEHICLE); // Paper - use configurable kick message & kick event cause - return; -@@ -644,7 +644,7 @@ public class ServerGamePacketListenerImpl + return true; +@@ -661,7 +661,7 @@ public class ServerGamePacketListenerImpl d5 = d2 - rootVehicle.getZ(); d7 = d3 * d3 + d4 * d4 + d5 * d5; boolean flag1 = false; - if (!me.earthme.luminol.config.modules.misc.DisableMovedWronglyThreshold.enabled && d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold) { // Spigot -+ if (!me.earthme.luminol.config.modules.misc.DisableMovedWronglyThreshold.enabled && d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !(fun.bm.lophine.config.modules.misc.DisableCheckConfig.disableOpMoveCheck && this.player.hasPermissions(2))) { // Spigot // Lophine - disable move check for operator ++ if (!me.earthme.luminol.config.modules.misc.DisableMovedWronglyThreshold.enabled && d7 > org.spigotmc.SpigotConfig.movedWronglyThreshold && !(fun.bm.lophine.config.modules.misc.DisableCheckConfig.disableOpMoveCheck && MinecraftServer.getServer().getPlayerList().isOp(this.player.nameAndId()))) { // Spigot // Lophine - disable move check for operator flag1 = true; // Paper - diff on change, this should be moved wrongly - LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", rootVehicle.getName().getString(), this.player.getName().getString(), Math.sqrt(d7)); + LOGGER.warn("{} (vehicle of {}) moved wrongly! {}", rootVehicle.getPlainTextName(), this.player.getPlainTextName(), Math.sqrt(d7)); } -@@ -1540,7 +1540,7 @@ public class ServerGamePacketListenerImpl +@@ -1563,7 +1563,7 @@ public class ServerGamePacketListenerImpl // Paper start - Add fail move event io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_TOO_QUICKLY, toX, toY, toZ, toYaw, toPitch, true); - if (!event.isAllowed()) { -+ if (!event.isAllowed() && !(fun.bm.lophine.config.modules.misc.DisableCheckConfig.disableOpMoveCheck && this.player.hasPermissions(2))) { // Lophine - disable move check for operator ++ if (!event.isAllowed() && !(fun.bm.lophine.config.modules.misc.DisableCheckConfig.disableOpMoveCheck && MinecraftServer.getServer().getPlayerList().isOp(this.player.nameAndId()))) { // Lophine - disable move check for operator if (event.getLogWarning()) { - LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getName().getString(), d3, d4, d5); + LOGGER.warn("{} moved too quickly! {},{},{}", this.player.getPlainTextName(), d3, d4, d5); } -@@ -1618,7 +1618,7 @@ public class ServerGamePacketListenerImpl +@@ -1642,7 +1642,7 @@ public class ServerGamePacketListenerImpl // Paper start - Add fail move event io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.MOVED_WRONGLY, toX, toY, toZ, toYaw, toPitch, true); - if (!event.isAllowed()) { -+ if (!event.isAllowed() && !(fun.bm.lophine.config.modules.misc.DisableCheckConfig.disableOpMoveCheck && this.player.hasPermissions(2))) { // Lophine - disable move check for operator ++ if (!event.isAllowed() && !(fun.bm.lophine.config.modules.misc.DisableCheckConfig.disableOpMoveCheck && MinecraftServer.getServer().getPlayerList().isOp(this.player.nameAndId()))) { // Lophine - disable move check for operator movedWrongly = true; if (event.getLogWarning()) // Paper end diff --git a/lophine-server/minecraft-patches/features/0002-Add-config-to-enable-cross-region-damage-trace.patch b/lophine-server/minecraft-patches/features/0002-Add-config-to-enable-cross-region-damage-trace.patch index 5260461..f779d10 100644 --- a/lophine-server/minecraft-patches/features/0002-Add-config-to-enable-cross-region-damage-trace.patch +++ b/lophine-server/minecraft-patches/features/0002-Add-config-to-enable-cross-region-damage-trace.patch @@ -5,12 +5,12 @@ Subject: [PATCH] Add config to enable cross region damage trace diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 11e6197dec541b28733715f0d7eaa4c7b834d632..de1263404395c28209234a556347284fa557f81c 100644 +index 338ad851814e0d15ac2c20c9f13895f52557e130..93bc76af4d0abbe1c526434991e74c4465764ac6 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -1345,6 +1345,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -1447,6 +1447,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc this.awardStat(Stats.ENTITY_KILLED_BY.get(killCredit.getType())); - killCredit.awardKillScore(this, cause); + killCredit.awardKillScore(this, damageSource); this.createWitherRose(killCredit); + // Luminol Start - Cross Region Damage trace + } else if (fun.bm.lophine.config.modules.experiment.EntityDamageSourceTraceConfig.enabled) { @@ -21,8 +21,8 @@ index 11e6197dec541b28733715f0d7eaa4c7b834d632..de1263404395c28209234a556347284f + // Luminol End - Cross Region Damage trace } - this.level().broadcastEntityEvent(this, (byte)3); -@@ -1368,6 +1375,24 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + this.level().broadcastEntityEvent(this, EntityEvent.DEATH); +@@ -1470,6 +1477,24 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc } // Leaves end - exp fix @@ -48,10 +48,10 @@ index 11e6197dec541b28733715f0d7eaa4c7b834d632..de1263404395c28209234a556347284f AABB aabb = new AABB(this.blockPosition()).inflate(32.0, 10.0, 32.0); this.level() diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 0c6d48363cd65cd22b4cc0ab97be977e133b64be..e94687b3aa960f9c630f459fedc17bc01846eaf7 100644 +index 372fb8a7f06e87c5694b972e3b726e52903ef1e3..ad497cc5a01662e86d6c3d0a7d51b86cfc764f53 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -1948,6 +1948,13 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1960,6 +1960,13 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin final LivingEntity killer = this.getKillCredit(); if (killer != null) { killer.awardKillScore(this, damageSource); @@ -65,7 +65,7 @@ index 0c6d48363cd65cd22b4cc0ab97be977e133b64be..e94687b3aa960f9c630f459fedc17bc0 } }); // Paper end this.postDeathDropItems(deathEvent); // Paper -@@ -1958,6 +1965,18 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1970,6 +1977,18 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin return deathEvent; // Paper } @@ -84,7 +84,7 @@ index 0c6d48363cd65cd22b4cc0ab97be977e133b64be..e94687b3aa960f9c630f459fedc17bc0 protected void dropEquipment(ServerLevel level) { } protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) {} // Paper - method for post death logic that cannot be ran before the event is potentially cancelled -@@ -2556,6 +2575,18 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -2597,6 +2616,18 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } } diff --git a/lophine-server/minecraft-patches/features/0003-Add-config-to-enable-raytracing-tracker.patch b/lophine-server/minecraft-patches/features/0003-Add-config-to-enable-raytracing-tracker.patch index 69e15b5..92ffb7c 100644 --- a/lophine-server/minecraft-patches/features/0003-Add-config-to-enable-raytracing-tracker.patch +++ b/lophine-server/minecraft-patches/features/0003-Add-config-to-enable-raytracing-tracker.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add config to enable raytracing tracker diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 6868b915bf3deb85783a638d4441a15fea6da2dc..70740381c6501c1a518c52b24381edd16792507f 100644 +index bca2c5410aa543d2bb421e53893e9163508b3568..fdccb06c918d387e46c29ede7337159db8c5d9ca 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -1278,7 +1278,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1350,7 +1350,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP double d1 = vec3_dx * vec3_dx + vec3_dz * vec3_dz; // Paper double d2 = d * d; // Paper start - Configurable entity tracking range by Y @@ -18,19 +18,19 @@ index 6868b915bf3deb85783a638d4441a15fea6da2dc..70740381c6501c1a518c52b24381edd1 double rangeY = level.paperConfig().entities.trackingRangeY.get(this.entity, -1); if (rangeY != -1) { diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 38092dcc3dedc6c855e5598126be47f892223547..a8b6e89035579557b59a20ddbe9b32943e6b7164 100644 +index 486d492087d870c38eb7a9c2169b842885748510..dddd8757292e8a817b0f697ac9e8f4ea0a74f589 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -147,7 +147,7 @@ import net.minecraft.world.waypoints.WaypointTransmitter; - import org.jetbrains.annotations.Contract; +@@ -152,7 +152,7 @@ import org.jetbrains.annotations.Contract; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; --public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker -+public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity, dev.tr7zw.entityculling.versionless.access.Cullable { // Paper - rewrite chunk system // Paper - optimise entity tracker // Luminol - Ray tracing entity tracker +-public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, SlotProvider, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity { // Paper - rewrite chunk system // Paper - optimise entity tracker ++public abstract class Entity implements SyncedDataHolder, DebugValueSource, Nameable, ItemOwner, SlotProvider, EntityAccess, ScoreHolder, DataComponentGetter, ca.spottedleaf.moonrise.patches.chunk_system.entity.ChunkSystemEntity, ca.spottedleaf.moonrise.patches.entity_tracker.EntityTrackerEntity, dev.tr7zw.entityculling.versionless.access.Cullable { // Paper - rewrite chunk system // Paper - optimise entity tracker // Luminol - Ray tracing entity tracker // CraftBukkit start private static final int CURRENT_LEVEL = 2; - public boolean preserveMotion = true; // Paper - Fix Entity Teleportation and cancel velocity if teleported; keep initial motion on first snapTo -@@ -6463,4 +6463,46 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess + static boolean isLevelAtLeast(ValueInput input, int level) { +@@ -6534,4 +6534,46 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name // Paper end - Expose entity id counter public boolean shouldTickHot() { return this.tickCount > 20 * 10 && this.isAlive(); } // KioCG @@ -78,10 +78,10 @@ index 38092dcc3dedc6c855e5598126be47f892223547..a8b6e89035579557b59a20ddbe9b3294 + } diff --git a/net/minecraft/world/entity/EntityType.java b/net/minecraft/world/entity/EntityType.java -index 6f00ffa05d9597917574357e0069c9b056aa5ce2..5cc7a91e32f17d8d9585ae4844a4ed3b706e3273 100644 +index 0590d5723854a03a59fe9471710802f4e64e50b8..4f8ff2c024d6f2e67c5fa38fe2e660ba39e35499 100644 --- a/net/minecraft/world/entity/EntityType.java +++ b/net/minecraft/world/entity/EntityType.java -@@ -1119,6 +1119,9 @@ public class EntityType implements FeatureElement, EntityTypeT +@@ -1254,6 +1254,9 @@ public class EntityType implements FeatureElement, EntityTypeT public final int passengerTickTimerId; public final int passengerInactiveTickTimerId; // Folia end - profiler @@ -92,10 +92,10 @@ index 6f00ffa05d9597917574357e0069c9b056aa5ce2..5cc7a91e32f17d8d9585ae4844a4ed3b public EntityType( EntityType.EntityFactory factory, diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index 2842314c712449625e9275aff7707c916c3ea767..09b549fa9568aa1ae13b1b975db14a6268fdaa46 100644 +index 5b19dba8c978feafa5d3d956359188e2de2257a5..3a8ac0765b8a988c281a2ded8c40ec044781cda2 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -229,6 +229,25 @@ public abstract class Player extends LivingEntity { +@@ -189,6 +189,25 @@ public abstract class Player extends Avatar implements ContainerUser { return (org.bukkit.craftbukkit.entity.CraftHumanEntity) super.getBukkitEntity(); } // CraftBukkit end @@ -121,7 +121,7 @@ index 2842314c712449625e9275aff7707c916c3ea767..09b549fa9568aa1ae13b1b975db14a62 public Player(Level level, GameProfile gameProfile) { super(EntityType.PLAYER, level); -@@ -287,6 +306,26 @@ public abstract class Player extends LivingEntity { +@@ -245,6 +264,26 @@ public abstract class Player extends Avatar implements ContainerUser { @Override public void tick() { @@ -148,8 +148,8 @@ index 2842314c712449625e9275aff7707c916c3ea767..09b549fa9568aa1ae13b1b975db14a62 this.noPhysics = this.isSpectator(); if (this.isSpectator() || this.isPassenger()) { this.setOnGround(false); -@@ -1426,6 +1465,7 @@ public abstract class Player extends LivingEntity { - if (this.containerMenu != null && this.hasContainerOpen()) { +@@ -1353,6 +1392,7 @@ public abstract class Player extends Avatar implements ContainerUser { + if (this.hasContainerOpen()) { this.doCloseContainer(); } + if (this.cullTask != null) this.cullTask.signalStop(); // Luminol - Ray tracing entity tracker diff --git a/lophine-server/minecraft-patches/features/0004-Add-config-to-enable-function-command.patch b/lophine-server/minecraft-patches/features/0004-Add-config-to-enable-function-command.patch index a7f473c..d7f94e0 100644 --- a/lophine-server/minecraft-patches/features/0004-Add-config-to-enable-function-command.patch +++ b/lophine-server/minecraft-patches/features/0004-Add-config-to-enable-function-command.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add config to enable function command diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java -index 11697e65a7f7871920ca7bad37de07f78a3da1f8..25ccbfa12d57d540195ecc16aa54a144f8ecc0e8 100644 +index b4976ac6a609c24a43375d6c945e2412b00ab627..ddde2c3e7c8d9105202a7ff32e444f85485cdb7f 100644 --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -204,7 +204,9 @@ public class Commands { +@@ -215,7 +215,9 @@ public class Commands { FillCommand.register(this.dispatcher, context); FillBiomeCommand.register(this.dispatcher, context); ForceLoadCommand.register(this.dispatcher); diff --git a/lophine-server/minecraft-patches/features/0005-Add-config-to-enable-scoreboard-command.patch b/lophine-server/minecraft-patches/features/0005-Add-config-to-enable-scoreboard-command.patch index e60758a..eb2ffd2 100644 --- a/lophine-server/minecraft-patches/features/0005-Add-config-to-enable-scoreboard-command.patch +++ b/lophine-server/minecraft-patches/features/0005-Add-config-to-enable-scoreboard-command.patch @@ -5,11 +5,11 @@ Subject: [PATCH] Add config to enable scoreboard command diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java -index 25ccbfa12d57d540195ecc16aa54a144f8ecc0e8..22d211bee83e3ef34d6ac81dd89c0e73924bee90 100644 +index ddde2c3e7c8d9105202a7ff32e444f85485cdb7f..8779f16cde40676fcb441973f53c8648c2a5e405 100644 --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -229,7 +229,11 @@ public class Commands { - //RotateCommand.register(this.dispatcher); // Folia - region threading - TODO later +@@ -241,7 +241,11 @@ public class Commands { + RotateCommand.register(this.dispatcher); // Folia - region threading - TODO later SayCommand.register(this.dispatcher); //ScheduleCommand.register(this.dispatcher); // Folia - region threading - //ScoreboardCommand.register(this.dispatcher, context); // Folia - region threading diff --git a/lophine-server/minecraft-patches/features/0006-Add-config-to-enable-tick-command.patch b/lophine-server/minecraft-patches/features/0006-Add-config-to-enable-tick-command.patch index 2918125..954cd5f 100644 --- a/lophine-server/minecraft-patches/features/0006-Add-config-to-enable-tick-command.patch +++ b/lophine-server/minecraft-patches/features/0006-Add-config-to-enable-tick-command.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add config to enable tick command diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java -index e1842ab8f20271a8b20ab8462b09a4745a612a9a..8405157ec35a443e238fa6866772c839621d73d7 100644 +index b29735af284493a011c0b3c1d07c7accce6fbde3..f7cc53bf3308771ab8d09010452e579485f6f1bc 100644 --- a/io/papermc/paper/threadedregions/RegionizedServer.java +++ b/io/papermc/paper/threadedregions/RegionizedServer.java -@@ -299,6 +299,11 @@ public final class RegionizedServer { +@@ -317,6 +317,11 @@ public final class RegionizedServer { this.randomWalk(); */ ++this.tickCount; @@ -20,7 +20,7 @@ index e1842ab8f20271a8b20ab8462b09a4745a612a9a..8405157ec35a443e238fa6866772c839 // expire invalid click command callbacks io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.ADVENTURE_CLICK_MANAGER.handleQueue((int)this.tickCount); // Paper // Folia - region threading - moved to global tick io.papermc.paper.adventure.providers.ClickCallbackProviderImpl.DIALOG_CLICK_MANAGER.handleQueue((int)this.tickCount); // Paper // Folia - region threading - moved to global tick -@@ -322,6 +327,13 @@ public final class RegionizedServer { +@@ -340,6 +345,13 @@ public final class RegionizedServer { this.globalTick(world, tickCount); } @@ -34,20 +34,20 @@ index e1842ab8f20271a8b20ab8462b09a4745a612a9a..8405157ec35a443e238fa6866772c839 // tick connections this.tickConnections(); -@@ -455,7 +467,7 @@ public final class RegionizedServer { +@@ -473,7 +485,7 @@ public final class RegionizedServer { } private void tickTime(final ServerLevel world, final int tickCount) { - if (world.tickTime) { + if ((!fun.bm.lophine.config.modules.experiment.CommandConfig.tick || world.tickRateManager().runsNormally()) && world.tickTime) { // Luminol - Add a config to enable tick command - if (world.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)) { + if (world.getGameRules().get(GameRules.ADVANCE_TIME)) { world.setDayTime(world.levelData.getDayTime() + (long)tickCount); } diff --git a/io/papermc/paper/threadedregions/TickRegionScheduler.java b/io/papermc/paper/threadedregions/TickRegionScheduler.java -index c485d5b3ba95f2a969bdf0dab9654ac284976f8d..b957585cf7cf7f845e20f59c7b355722880f3b4e 100644 +index 0457f0bd825c2d2287dc5ec9f81f0a266c30a869..5a224c5aba29f982d3650a78c29aeb7491d92a80 100644 --- a/io/papermc/paper/threadedregions/TickRegionScheduler.java +++ b/io/papermc/paper/threadedregions/TickRegionScheduler.java -@@ -31,8 +31,8 @@ public final class TickRegionScheduler { +@@ -33,8 +33,8 @@ public final class TickRegionScheduler { } } @@ -58,7 +58,7 @@ index c485d5b3ba95f2a969bdf0dab9654ac284976f8d..b957585cf7cf7f845e20f59c7b355722 // Folia start - watchdog public static final FoliaWatchdogThread WATCHDOG_THREAD = new FoliaWatchdogThread(); -@@ -394,8 +394,23 @@ public final class TickRegionScheduler { +@@ -389,8 +389,23 @@ public final class TickRegionScheduler { final long cpuStart = MEASURE_CPU_TIME ? THREAD_MX_BEAN.getCurrentThreadCpuTime() : 0L; final long tickStart = System.nanoTime(); @@ -84,7 +84,7 @@ index c485d5b3ba95f2a969bdf0dab9654ac284976f8d..b957585cf7cf7f845e20f59c7b355722 if (!this.tryMarkTicking()) { if (!this.cancelled.get()) { -@@ -435,6 +450,11 @@ public final class TickRegionScheduler { +@@ -431,6 +446,11 @@ public final class TickRegionScheduler { try { // next start isn't updated until the end of this tick this.tickRegion(tickCount, tickStart, scheduledEnd); @@ -97,10 +97,10 @@ index c485d5b3ba95f2a969bdf0dab9654ac284976f8d..b957585cf7cf7f845e20f59c7b355722 this.scheduler.regionFailed(this, false, thr); // regionFailed will schedule a shutdown, so we should avoid letting this region tick further diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java -index 22d211bee83e3ef34d6ac81dd89c0e73924bee90..1fb359073342a657e9e493403263b56be5b3393f 100644 +index 8779f16cde40676fcb441973f53c8648c2a5e405..b9dc7dd77aeb6e3b59b6903cb5094b7eadee4d2d 100644 --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -249,7 +249,11 @@ public class Commands { +@@ -262,7 +262,11 @@ public class Commands { TeleportCommand.register(this.dispatcher); TellRawCommand.register(this.dispatcher, context); //TestCommand.register(this.dispatcher, context); // Folia - region threading @@ -114,23 +114,23 @@ index 22d211bee83e3ef34d6ac81dd89c0e73924bee90..1fb359073342a657e9e493403263b56b TitleCommand.register(this.dispatcher, context); //TriggerCommand.register(this.dispatcher); // Folia - region threading - TODO later diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 75027e73859c955a54034640f905cb5d91a6a2f4..2f4970242c754cfba8ff5656a63af07d9d0a723c 100644 +index a36ed4b368ed9ee41eeb9fdf096aae41963a58cc..2f91e80f8c3df2775a793aa3c648c50007543192 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -267,7 +267,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0L) { this.sprintTickStartTime = System.nanoTime(); @@ -139,7 +139,7 @@ index 40338efd1c0e56d869d03f1d0687e7ff0fcbf11a..d0d90a25a10bbecfffceee1992af88c6 return true; } else { this.finishTickSprint(); -@@ -113,6 +113,12 @@ public class ServerTickRateManager extends TickRateManager { +@@ -114,6 +114,12 @@ public class ServerTickRateManager extends TickRateManager { } } @@ -153,7 +153,7 @@ index 40338efd1c0e56d869d03f1d0687e7ff0fcbf11a..d0d90a25a10bbecfffceee1992af88c6 this.sprintTimeSpend = this.sprintTimeSpend + (System.nanoTime() - this.sprintTickStartTime); } diff --git a/net/minecraft/server/commands/TickCommand.java b/net/minecraft/server/commands/TickCommand.java -index 126685fb266692082b432ed297a499149e921dfb..9d8f6025c420e651611da17e77a362c738228b72 100644 +index 14c46d585fc9bfbf9a57340508ea2e5076ac39d6..99096896a4512eed579b234e7fa0c6e9c3e8c246 100644 --- a/net/minecraft/server/commands/TickCommand.java +++ b/net/minecraft/server/commands/TickCommand.java @@ -14,7 +14,7 @@ import net.minecraft.server.ServerTickRateManager; diff --git a/lophine-server/minecraft-patches/features/0007-Add-config-to-enable-waypoint-command-bar.patch b/lophine-server/minecraft-patches/features/0007-Add-config-to-enable-waypoint-command-bar.patch index bfa6fd7..01e5a80 100644 --- a/lophine-server/minecraft-patches/features/0007-Add-config-to-enable-waypoint-command-bar.patch +++ b/lophine-server/minecraft-patches/features/0007-Add-config-to-enable-waypoint-command-bar.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Add config to enable waypoint command & bar use concurrent method to fix it (now, they are thread safe) diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java -index 1fb359073342a657e9e493403263b56be5b3393f..451a685782da46f5683ea6707289bbaf3193771f 100644 +index b9dc7dd77aeb6e3b59b6903cb5094b7eadee4d2d..b049520cca9f365282493d7c442bbcd3075d78ac 100644 --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -257,7 +257,11 @@ public class Commands { +@@ -270,7 +270,11 @@ public class Commands { TimeCommand.register(this.dispatcher); TitleCommand.register(this.dispatcher, context); //TriggerCommand.register(this.dispatcher); // Folia - region threading - TODO later @@ -23,7 +23,7 @@ index 1fb359073342a657e9e493403263b56be5b3393f..451a685782da46f5683ea6707289bbaf WorldBorderCommand.register(this.dispatcher); if (JvmProfiler.INSTANCE.isAvailable()) { diff --git a/net/minecraft/server/waypoints/ServerWaypointManager.java b/net/minecraft/server/waypoints/ServerWaypointManager.java -index 0f8cacbb8fe55a60e2f0c98bf36c005b29f41a4b..55cb2d16e22e4d8745da539177b636d188ad0489 100644 +index 1cbc46e480cc7d109c6128f109a1a9e38bf1a193..9492698541bfe704a1075a8fb58a9d7624895e48 100644 --- a/net/minecraft/server/waypoints/ServerWaypointManager.java +++ b/net/minecraft/server/waypoints/ServerWaypointManager.java @@ -16,22 +16,31 @@ import net.minecraft.world.waypoints.WaypointManager; diff --git a/lophine-server/minecraft-patches/features/0008-Fix-datapack-command-save-function.patch b/lophine-server/minecraft-patches/features/0008-Fix-datapack-command-save-function.patch index 8f3aa42..1dd038d 100644 --- a/lophine-server/minecraft-patches/features/0008-Fix-datapack-command-save-function.patch +++ b/lophine-server/minecraft-patches/features/0008-Fix-datapack-command-save-function.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix datapack command save function diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 2f4970242c754cfba8ff5656a63af07d9d0a723c..b156b5c635f931a3d4abc0584591f90476d011a6 100644 +index 2f91e80f8c3df2775a793aa3c648c50007543192..6230c08d001aebc119900906aa557247261985a3 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -2353,6 +2353,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop completableFuture = CompletableFuture.supplyAsync( diff --git a/net/minecraft/server/commands/DataPackCommand.java b/net/minecraft/server/commands/DataPackCommand.java -index a5032b34752061d61fd9ddb4db828d35e403f5e7..3eaa9c85d06f6ecc8ed639d8befa861439390eb7 100644 +index bb36fa4559cdfe82079af1c39516239119ff06f4..8c530eef0e416d8b96f190ada358d77d34dbc8ac 100644 --- a/net/minecraft/server/commands/DataPackCommand.java +++ b/net/minecraft/server/commands/DataPackCommand.java @@ -98,7 +98,7 @@ public class DataPackCommand { dispatcher.register( Commands.literal("datapack") - .requires(Commands.hasPermission(2)) + .requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS)) - /*.then( // Luminol - Add back read-only datapack command + .then( Commands.literal("enable") @@ -71,7 +71,7 @@ index a5032b34752061d61fd9ddb4db828d35e403f5e7..3eaa9c85d06f6ecc8ed639d8befa8614 if (selectedPacks.isEmpty()) { source.sendSuccess(() -> Component.translatable("commands.datapack.list.enabled.none"), false); diff --git a/net/minecraft/server/commands/ReloadCommand.java b/net/minecraft/server/commands/ReloadCommand.java -index b540a3c3a02f7242578a63477e34b9063e86f1d2..bc999de32931558d0d8dc26264653dd63c1cad19 100644 +index fcca0babb4e7929cc168fc8b9ad47619e6feb1a5..bac5f4e023f8b73eebea0f31fd253e04c8809918 100644 --- a/net/minecraft/server/commands/ReloadCommand.java +++ b/net/minecraft/server/commands/ReloadCommand.java @@ -16,11 +16,17 @@ public class ReloadCommand { diff --git a/lophine-server/minecraft-patches/features/0009-Leaves-Base-Protocol-Core.patch b/lophine-server/minecraft-patches/features/0009-Leaves-Base-Protocol-Core.patch index be5c6a0..c95b304 100644 --- a/lophine-server/minecraft-patches/features/0009-Leaves-Base-Protocol-Core.patch +++ b/lophine-server/minecraft-patches/features/0009-Leaves-Base-Protocol-Core.patch @@ -8,10 +8,10 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves/blob/ea91106ae57fc4cc1 Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/io/papermc/paper/threadedregions/RegionizedServer.java b/io/papermc/paper/threadedregions/RegionizedServer.java -index 8405157ec35a443e238fa6866772c839621d73d7..67f3454e6479abb241a7d94699d4f7bec22da56b 100644 +index f7cc53bf3308771ab8d09010452e579485f6f1bc..7c8aee6a7052e5a3b30a0a9c8e827ea37d5c81cd 100644 --- a/io/papermc/paper/threadedregions/RegionizedServer.java +++ b/io/papermc/paper/threadedregions/RegionizedServer.java -@@ -334,6 +334,8 @@ public final class RegionizedServer { +@@ -352,6 +352,8 @@ public final class RegionizedServer { } // Luminol end - Add a config to enable tick command @@ -21,7 +21,7 @@ index 8405157ec35a443e238fa6866772c839621d73d7..67f3454e6479abb241a7d94699d4f7be this.tickConnections(); diff --git a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java -index fb263fa1f30a7dfcb7ec2656abfb38e5fe88eac9..56fd1ed7ccaf96e7eedea60fbdbf7f934939d563 100644 +index 1da034752064312962a4144f91be5265a9a08997..081ca42b6a6644eb8c2b5ac9105fecf8ad39d501 100644 --- a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java +++ b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java @@ -40,13 +40,22 @@ public interface CustomPacketPayload { @@ -39,20 +39,20 @@ index fb263fa1f30a7dfcb7ec2656abfb38e5fe88eac9..56fd1ed7ccaf96e7eedea60fbdbf7f93 @Override public CustomPacketPayload decode(B buffer) { - ResourceLocation resourceLocation = buffer.readResourceLocation(); -- return (CustomPacketPayload)this.findCodec(resourceLocation).decode(buffer); + Identifier identifier = buffer.readIdentifier(); +- return (CustomPacketPayload)this.findCodec(identifier).decode(buffer); + // Leaves start - protocol core -+ var payload = org.leavesmc.leaves.protocol.core.LeavesProtocolManager.decode(resourceLocation, buffer); -+ return java.util.Objects.requireNonNullElseGet(payload, () -> this.findCodec(resourceLocation).decode(buffer)); ++ var payload = org.leavesmc.leaves.protocol.core.LeavesProtocolManager.decode(identifier, buffer); ++ return java.util.Objects.requireNonNullElseGet(payload, () -> this.findCodec(identifier).decode(buffer)); + // Leaves end - protocol core } }; } diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index 8150b16c196edcb226be9268ea6e0012e44517fa..c54bf0429c0ca3a35a730658c7b1b3ddc776bf9e 100644 +index 0bf2173c5445de021090c2d0264afc440b005bdc..076bfe7a7b57f8d3b29ef0aaad117707678da7a3 100644 --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -57,6 +57,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -58,6 +58,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack public @Nullable String playerBrand; public final java.util.Set pluginMessagerChannels; // Paper end - retain certain values @@ -60,7 +60,7 @@ index 8150b16c196edcb226be9268ea6e0012e44517fa..c54bf0429c0ca3a35a730658c7b1b3dd public ServerCommonPacketListenerImpl(MinecraftServer server, Connection connection, CommonListenerCookie cookie) { this.server = server; -@@ -70,6 +71,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -71,6 +72,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack this.pluginMessagerChannels = cookie.channels(); this.keepAlive = cookie.keepAlive(); // Paper end @@ -68,7 +68,7 @@ index 8150b16c196edcb226be9268ea6e0012e44517fa..c54bf0429c0ca3a35a730658c7b1b3dd } // Paper start - configuration phase API -@@ -160,6 +162,18 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -161,6 +163,18 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @Override public void handleCustomPayload(ServerboundCustomPayloadPacket packet) { @@ -77,7 +77,7 @@ index 8150b16c196edcb226be9268ea6e0012e44517fa..c54bf0429c0ca3a35a730658c7b1b3dd + org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePayload(org.leavesmc.leaves.protocol.core.ProtocolUtils.createSelector(this), leavesPayload); + return; + } -+ if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.DiscardedPayload(net.minecraft.resources.ResourceLocation id, byte[] data)) { ++ if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.DiscardedPayload(net.minecraft.resources.Identifier id, byte[] data)) { + if (org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleBytebuf(org.leavesmc.leaves.protocol.core.ProtocolUtils.createSelector(this), id, io.netty.buffer.Unpooled.wrappedBuffer(data))) { + return; + } @@ -87,7 +87,7 @@ index 8150b16c196edcb226be9268ea6e0012e44517fa..c54bf0429c0ca3a35a730658c7b1b3dd // Paper start if (!(packet.payload() instanceof final net.minecraft.network.protocol.common.custom.DiscardedPayload discardedPayload)) { return; -@@ -219,10 +233,11 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -220,10 +234,11 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack final String channel = new String(data, from, length, java.nio.charset.StandardCharsets.US_ASCII); if (register) { bridge.addChannel(channel); @@ -100,7 +100,7 @@ index 8150b16c196edcb226be9268ea6e0012e44517fa..c54bf0429c0ca3a35a730658c7b1b3dd } @Override -@@ -385,9 +400,9 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -386,9 +401,9 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack net.minecraft.server.level.ServerPlayer player = serverGamePacketListener.player; org.bukkit.event.player.PlayerKickEvent.Cause cause = disconnectionDetails.disconnectionReason().orElseThrow().game().orElse(org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN); org.bukkit.event.player.PlayerKickEvent event = new org.bukkit.event.player.PlayerKickEvent( @@ -113,7 +113,7 @@ index 8150b16c196edcb226be9268ea6e0012e44517fa..c54bf0429c0ca3a35a730658c7b1b3dd ); -@@ -420,10 +435,10 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -421,10 +436,10 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack private void disconnect0(DisconnectionDetails disconnectionDetails) { this.connection @@ -129,27 +129,27 @@ index 8150b16c196edcb226be9268ea6e0012e44517fa..c54bf0429c0ca3a35a730658c7b1b3dd this.connection.setReadOnly(); // CraftBukkit - Don't wait diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 4ef2816210f06082f2209c51d04aad6bb188232b..593dbcda4b497291eb1ecdc64b947a8d279f8be6 100644 +index faf1f5e62ca1efb917256fb6291ae9c71c5ad92e..a8a034ad5895ad1b833754c91c3a370c3b9b3744 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -423,6 +423,8 @@ public abstract class PlayerList { - //return; // Folia - region threading - must still allow the player to connect, as we must add to chunk map before handling disconnect - } +@@ -315,6 +315,8 @@ public abstract class PlayerList { + //return; // Folia - region threading - must still allow the player to connect, as we must add to chunk map before handling disconnect + } -+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); ++ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); + - final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); + final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); - if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure -@@ -605,6 +607,7 @@ public abstract class PlayerList { + if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure +@@ -511,6 +513,7 @@ public abstract class PlayerList { return this.remove(player, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? player.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName()))); } - public @Nullable net.kyori.adventure.text.Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) { + public net.kyori.adventure.text.@Nullable Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) { + org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerLeave(player); // Leaves - protocol // Paper end - Fix kick event leave message not being sent ServerLevel serverLevel = player.level(); player.awardStat(Stats.LEAVE_GAME); -@@ -1520,6 +1523,7 @@ public abstract class PlayerList { +@@ -1400,6 +1403,7 @@ public abstract class PlayerList { serverPlayer.connection.send(clientboundUpdateRecipesPacket); serverPlayer.getRecipeBook().sendInitialRecipeBook(serverPlayer); } diff --git a/lophine-server/minecraft-patches/features/0010-Leaves-Configurable-trading-with-the-void.patch b/lophine-server/minecraft-patches/features/0010-Leaves-Configurable-trading-with-the-void.patch index 9366645..8016619 100644 --- a/lophine-server/minecraft-patches/features/0010-Leaves-Configurable-trading-with-the-void.patch +++ b/lophine-server/minecraft-patches/features/0010-Leaves-Configurable-trading-with-the-void.patch @@ -8,10 +8,10 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 7584ba257d61bf650d83a2316ff012df928d54f3..4d71cc3b643f6f594c90f2f8f9e5b820ebdff080 100644 +index a60c70550c217bccda6695dc7b7165de8e97e5cd..6aad6024dc121eae63b7fde92a89cbea29fcafb3 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -2901,7 +2901,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -3015,7 +3015,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Spigot start if (entity.getBukkitEntity() instanceof org.bukkit.inventory.InventoryHolder && (!(entity instanceof ServerPlayer) || entity.getRemovalReason() != Entity.RemovalReason.KILLED)) { // SPIGOT-6876: closeInventory clears death message // Paper start - Fix merchant inventory not closing on entity removal @@ -21,20 +21,20 @@ index 7584ba257d61bf650d83a2316ff012df928d54f3..4d71cc3b643f6f594c90f2f8f9e5b820 } // Paper end - Fix merchant inventory not closing on entity removal diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 593dbcda4b497291eb1ecdc64b947a8d279f8be6..6c1f4f943a5be5f2e43a82cca52ca76a98226915 100644 +index a8a034ad5895ad1b833754c91c3a370c3b9b3744..35d51c727ce9229a174c45e9ea838fa9e3c3d80a 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -649,7 +649,7 @@ public abstract class PlayerList { +@@ -555,7 +555,7 @@ public abstract class PlayerList { player.stopRiding(); rootVehicle.getPassengersAndSelf().forEach(entity -> { // Paper start - Fix villager boat exploit -- if (entity instanceof net.minecraft.world.entity.npc.AbstractVillager villager) { -+ if (!fun.bm.lophine.config.modules.function.OldFeatureConfig.villagerVoidTrade && entity instanceof net.minecraft.world.entity.npc.AbstractVillager villager) { // Leaves - Configurable trading with the void +- if (entity instanceof net.minecraft.world.entity.npc.villager.AbstractVillager villager) { ++ if (!fun.bm.lophine.config.modules.function.OldFeatureConfig.villagerVoidTrade && entity instanceof net.minecraft.world.entity.npc.villager.AbstractVillager villager) { // Leaves - Configurable trading with the void final net.minecraft.world.entity.player.Player human = villager.getTradingPlayer(); if (human != null) { villager.setTradingPlayer(null); diff --git a/net/minecraft/world/inventory/MerchantMenu.java b/net/minecraft/world/inventory/MerchantMenu.java -index d59f67ffe34201c63e3d9706a4434f33b6732edb..c635c7211bff9d190b7035b284dda162334fd5c2 100644 +index 6dfee62a46a5882df7f405e59d762647289d7866..1192a6ab33a9481397b84c9cf0a24fbbcb0ed065 100644 --- a/net/minecraft/world/inventory/MerchantMenu.java +++ b/net/minecraft/world/inventory/MerchantMenu.java @@ -74,6 +74,7 @@ public class MerchantMenu extends AbstractContainerMenu { diff --git a/lophine-server/minecraft-patches/features/0011-Leaves-Item-overstack-util.patch b/lophine-server/minecraft-patches/features/0011-Leaves-Item-overstack-util.patch index 20eb284..1bc3507 100644 --- a/lophine-server/minecraft-patches/features/0011-Leaves-Item-overstack-util.patch +++ b/lophine-server/minecraft-patches/features/0011-Leaves-Item-overstack-util.patch @@ -8,7 +8,7 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves/blob/46cccfc39cafbca16 Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/net/minecraft/commands/arguments/item/ItemInput.java b/net/minecraft/commands/arguments/item/ItemInput.java -index 643797124fe5a4489d0b7419b7e600c04f283ef2..04b4100da96aad50f08e8c59200eec934e7e873d 100644 +index 8e08cb90dc94171a8da7126fe18c46eaa49a58f2..a7804a0d099c79c81eb45eb20402a001d8734529 100644 --- a/net/minecraft/commands/arguments/item/ItemInput.java +++ b/net/minecraft/commands/arguments/item/ItemInput.java @@ -39,11 +39,13 @@ public class ItemInput { @@ -28,23 +28,23 @@ index 643797124fe5a4489d0b7419b7e600c04f283ef2..04b4100da96aad50f08e8c59200eec93 public String serialize(HolderLookup.Provider levelRegistry) { diff --git a/net/minecraft/server/commands/GiveCommand.java b/net/minecraft/server/commands/GiveCommand.java -index 7ef109cb9921c25987905149616eddbd0b2f9b9c..70fc9d6c5b226211ff5964464c37e11695d5f745 100644 +index 1281eadb2d0c5b4ce5e3afd51d8205f9a4ef011c..b1446dfb4689174ee9f55cec6080622ec34de250 100644 --- a/net/minecraft/server/commands/GiveCommand.java +++ b/net/minecraft/server/commands/GiveCommand.java -@@ -55,7 +55,7 @@ public class GiveCommand { +@@ -54,7 +54,7 @@ public class GiveCommand { + private static int giveItem(CommandSourceStack source, ItemInput item, Collection targets, int count) throws CommandSyntaxException { ItemStack itemStack = item.createItemStack(1, false); - final Component displayName = itemStack.getDisplayName(); // Paper - get display name early - int maxStackSize = itemStack.getMaxStackSize(); + int maxStackSize = org.leavesmc.leaves.util.ItemOverstackUtils.getItemStackMaxCount(itemStack); // Leaves - item over-stack util int i = maxStackSize * 100; if (count > i) { source.sendFailure(Component.translatable("commands.give.failed.toomanyitems", i, itemStack.getDisplayName())); diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 74ec003486f9362d2bafbad8392b9bbdf0c15882..f06b9d8ad9512d35f3f460eb77c869690321c67f 100644 +index 5757832ca91c42b417a95a2536a282a24eef0ef7..df6ad5831f83fcc869b0b4ed844a73b3cb81c469 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -3079,7 +3079,7 @@ public class ServerGamePacketListenerImpl +@@ -3126,7 +3126,7 @@ public class ServerGamePacketListenerImpl } else if (slot.mayPlace(cursor)) { if (ItemStack.isSameItemSameComponents(clickedItem, cursor)) { int toPlace = packet.buttonNum() == 0 ? cursor.getCount() : 1; @@ -53,7 +53,7 @@ index 74ec003486f9362d2bafbad8392b9bbdf0c15882..f06b9d8ad9512d35f3f460eb77c86969 toPlace = Math.min(toPlace, slot.container.getMaxStackSize() - clickedItem.getCount()); if (toPlace == 1) { action = InventoryAction.PLACE_ONE; -@@ -3115,7 +3115,7 @@ public class ServerGamePacketListenerImpl +@@ -3162,7 +3162,7 @@ public class ServerGamePacketListenerImpl } } else if (ItemStack.isSameItemSameComponents(cursor, clickedItem)) { if (clickedItem.getCount() >= 0) { @@ -62,7 +62,7 @@ index 74ec003486f9362d2bafbad8392b9bbdf0c15882..f06b9d8ad9512d35f3f460eb77c86969 // As of 1.5, this is result slots only action = InventoryAction.PICKUP_ALL; } -@@ -3326,6 +3326,7 @@ public class ServerGamePacketListenerImpl +@@ -3379,6 +3379,7 @@ public class ServerGamePacketListenerImpl this.player.containerMenu.broadcastFullState(); } else { this.player.containerMenu.broadcastChanges(); @@ -70,7 +70,7 @@ index 74ec003486f9362d2bafbad8392b9bbdf0c15882..f06b9d8ad9512d35f3f460eb77c86969 } if (packet.buttonNum() == Inventory.SLOT_OFFHAND && this.player.containerMenu != this.player.inventoryMenu) this.player.containerSynchronizer.sendOffHandSlotChange(); // Paper - update offhand data when the player is clicking in an inventory not their own as the sychronizer does not include offhand slots if (io.papermc.paper.configuration.GlobalConfiguration.get().unsupportedSettings.updateEquipmentOnPlayerActions) this.player.detectEquipmentUpdates(); // Paper - Force update attributes. -@@ -3437,7 +3438,7 @@ public class ServerGamePacketListenerImpl +@@ -3490,7 +3491,7 @@ public class ServerGamePacketListenerImpl } boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45; @@ -79,7 +79,7 @@ index 74ec003486f9362d2bafbad8392b9bbdf0c15882..f06b9d8ad9512d35f3f460eb77c86969 if (flag || (flag1 && !ItemStack.matches(this.player.inventoryMenu.getSlot(packet.slotNum()).getItem(), packet.itemStack()))) { // Insist on valid slot // CraftBukkit start - Call click event org.bukkit.inventory.InventoryView inventory = this.player.inventoryMenu.getBukkitView(); -@@ -3479,6 +3480,7 @@ public class ServerGamePacketListenerImpl +@@ -3532,6 +3533,7 @@ public class ServerGamePacketListenerImpl this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemStack); this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemStack); this.player.inventoryMenu.broadcastChanges(); @@ -88,10 +88,10 @@ index 74ec003486f9362d2bafbad8392b9bbdf0c15882..f06b9d8ad9512d35f3f460eb77c86969 } else if (flag && flag2) { if (this.dropSpamThrottler.isUnderThreshold()) { diff --git a/net/minecraft/world/Container.java b/net/minecraft/world/Container.java -index 2afaf6a3f18af7889f4f3b35cee9bbb5e4ec01f2..da99b4bc7fe8460945070915073be141f9bd6778 100644 +index b63cecafd841b97a694f6d2610141dcdb8f30574..392678778dc2a036c1e3db4b6bb2800e452d3cd0 100644 --- a/net/minecraft/world/Container.java +++ b/net/minecraft/world/Container.java -@@ -32,6 +32,12 @@ public interface Container extends Clearable, Iterable, org.leavesmc. +@@ -37,6 +37,12 @@ public interface Container extends Clearable, SlotProvider, Iterable, return Math.min(this.getMaxStackSize(), stack.getMaxStackSize()); } @@ -105,10 +105,10 @@ index 2afaf6a3f18af7889f4f3b35cee9bbb5e4ec01f2..da99b4bc7fe8460945070915073be141 boolean stillValid(Player player); diff --git a/net/minecraft/world/SimpleContainer.java b/net/minecraft/world/SimpleContainer.java -index d907e24d563e27acab2f2bf9711b1755ea9afd19..75170c8d3be477a6ea2a1d62018a6ab630b0e54e 100644 +index 0233c2b5e40c33330870e598431897a2ff98c2a3..3cf1819a9c82da2d2e0c43187e204353e3643369 100644 --- a/net/minecraft/world/SimpleContainer.java +++ b/net/minecraft/world/SimpleContainer.java -@@ -211,7 +211,7 @@ public class SimpleContainer implements Container, StackedContentsCompatible { +@@ -210,7 +210,7 @@ public class SimpleContainer implements Container, StackedContentsCompatible { @Override public void setItem(int index, ItemStack stack) { this.items.set(index, stack); @@ -117,7 +117,7 @@ index d907e24d563e27acab2f2bf9711b1755ea9afd19..75170c8d3be477a6ea2a1d62018a6ab6 this.setChanged(); } -@@ -286,7 +286,7 @@ public class SimpleContainer implements Container, StackedContentsCompatible { +@@ -285,7 +285,7 @@ public class SimpleContainer implements Container, StackedContentsCompatible { } private void moveItemsBetweenStacks(ItemStack stack, ItemStack other) { @@ -127,10 +127,10 @@ index d907e24d563e27acab2f2bf9711b1755ea9afd19..75170c8d3be477a6ea2a1d62018a6ab6 if (min > 0) { other.grow(min); diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java -index fd4f1e63f980b6959fc80084651991f8f8bc6c34..e5e8c752129a6ebb0dd1315c9b8ec459be11ef07 100644 +index 16c42a5e35c6ee1df640e5831818099fab6338f1..f3f067c62dc024a747d059608ae7a2e8740dbff2 100644 --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -283,10 +283,15 @@ public class ItemEntity extends Entity implements TraceableEntity, ChangePublish +@@ -271,10 +271,15 @@ public class ItemEntity extends Entity implements TraceableEntity, ChangePublish private boolean isMergable() { ItemStack item = this.getItem(); @@ -148,10 +148,10 @@ index fd4f1e63f980b6959fc80084651991f8f8bc6c34..e5e8c752129a6ebb0dd1315c9b8ec459 ItemStack item1 = itemEntity.getItem(); if (Objects.equals(this.target, itemEntity.target) && areMergable(item, item1)) { diff --git a/net/minecraft/world/entity/player/Inventory.java b/net/minecraft/world/entity/player/Inventory.java -index a6bb436dc80daf6901dc027a6011ead4b3ed27e2..71df58ae26325a2d28b6679733c474c0c59f7654 100644 +index 41e59f3739945ca7f6ab710c993b5c0f15fcd529..b849b04f227b43d036f4f6b3ae7accfafc389d9f 100644 --- a/net/minecraft/world/entity/player/Inventory.java +++ b/net/minecraft/world/entity/player/Inventory.java -@@ -165,10 +165,12 @@ public class Inventory implements Container, Nameable { +@@ -166,10 +166,12 @@ public class Inventory implements Container, Nameable { } private boolean hasRemainingSpaceForItem(ItemStack destination, ItemStack origin) { @@ -166,7 +166,7 @@ index a6bb436dc80daf6901dc027a6011ead4b3ed27e2..71df58ae26325a2d28b6679733c474c0 } // CraftBukkit start - Watch method above! :D -@@ -181,7 +183,7 @@ public class Inventory implements Container, Nameable { +@@ -182,7 +184,7 @@ public class Inventory implements Container, Nameable { } if (this.hasRemainingSpaceForItem(itemInSlot, itemStack)) { @@ -175,7 +175,7 @@ index a6bb436dc80daf6901dc027a6011ead4b3ed27e2..71df58ae26325a2d28b6679733c474c0 } if (remains <= 0) { return itemStack.getCount(); -@@ -190,7 +192,7 @@ public class Inventory implements Container, Nameable { +@@ -191,7 +193,7 @@ public class Inventory implements Container, Nameable { ItemStack itemInOffhand = this.equipment.get(EquipmentSlot.OFFHAND); if (this.hasRemainingSpaceForItem(itemInOffhand, itemStack)) { @@ -184,7 +184,7 @@ index a6bb436dc80daf6901dc027a6011ead4b3ed27e2..71df58ae26325a2d28b6679733c474c0 } if (remains <= 0) { return itemStack.getCount(); -@@ -314,7 +316,7 @@ public class Inventory implements Container, Nameable { +@@ -315,7 +317,7 @@ public class Inventory implements Container, Nameable { this.setItem(slot, item); } @@ -193,7 +193,7 @@ index a6bb436dc80daf6901dc027a6011ead4b3ed27e2..71df58ae26325a2d28b6679733c474c0 int min = Math.min(count, i); if (min == 0) { return count; -@@ -420,7 +422,7 @@ public class Inventory implements Container, Nameable { +@@ -421,7 +423,7 @@ public class Inventory implements Container, Nameable { break; } @@ -203,10 +203,10 @@ index a6bb436dc80daf6901dc027a6011ead4b3ed27e2..71df58ae26325a2d28b6679733c474c0 serverPlayer.connection.send(this.createInventoryUpdatePacket(slotWithRemainingSpace)); } diff --git a/net/minecraft/world/entity/player/StackedItemContents.java b/net/minecraft/world/entity/player/StackedItemContents.java -index 83ccde54c625d40dc595e000c533f60aa929bd5a..6779503888e6d311758cffde582b0efbd66a33de 100644 +index 00dbc0d125b2c8c208ffa46f9084c6317efaba90..1f57b3c60fd0cbfdd65e06f8994525ade6dc6bd9 100644 --- a/net/minecraft/world/entity/player/StackedItemContents.java +++ b/net/minecraft/world/entity/player/StackedItemContents.java -@@ -23,7 +23,7 @@ public class StackedItemContents { +@@ -36,7 +36,7 @@ public class StackedItemContents { } public void accountStack(ItemStack stack) { @@ -216,10 +216,10 @@ index 83ccde54c625d40dc595e000c533f60aa929bd5a..6779503888e6d311758cffde582b0efb public void accountStack(ItemStack stack, int maxStackSize) { diff --git a/net/minecraft/world/entity/vehicle/ContainerEntity.java b/net/minecraft/world/entity/vehicle/ContainerEntity.java -index 02d2efef2dc0f0e12eac0c71fa290af706f7694d..99f109e2653eff10c011f380694bd77a76381cee 100644 +index 44276ba9c7aab306cfd12833a834ebe61cf64e7c..0a19a7782f3fa27c41e02393e887ba7cc727012b 100644 --- a/net/minecraft/world/entity/vehicle/ContainerEntity.java +++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java -@@ -163,7 +163,7 @@ public interface ContainerEntity extends Container, MenuProvider { +@@ -162,7 +162,7 @@ public interface ContainerEntity extends Container, MenuProvider { default void setChestVehicleItem(int slot, ItemStack stack) { this.unpackChestVehicleLootTable(null); this.getItemStacks().set(slot, stack); @@ -227,12 +227,12 @@ index 02d2efef2dc0f0e12eac0c71fa290af706f7694d..99f109e2653eff10c011f380694bd77a + stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - item over-stack util } - default SlotAccess getChestVehicleSlot(final int index) { + default @Nullable SlotAccess getChestVehicleSlot(final int slot) { diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java -index 2d6acceffb2cb7e55dd504018a70b05afccd9c11..bdc0ca1f625dc264bef6e5722ec66121ba48625a 100644 +index b090b74c845cd5944c9a8e35e899ad35063770d3..8e28afcfda7b180def81122e35920f6fd57a4574 100644 --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -295,6 +295,13 @@ public abstract class AbstractContainerMenu { +@@ -292,6 +292,13 @@ public abstract class AbstractContainerMenu { this.sendAllDataToRemote(); } @@ -246,7 +246,7 @@ index 2d6acceffb2cb7e55dd504018a70b05afccd9c11..bdc0ca1f625dc264bef6e5722ec66121 private void updateDataSlotListeners(int slotIndex, int value) { for (ContainerListener containerListener : this.containerListeners) { containerListener.dataChanged(this, slotIndex, value); -@@ -451,7 +458,7 @@ public abstract class AbstractContainerMenu { +@@ -448,7 +455,7 @@ public abstract class AbstractContainerMenu { && (this.quickcraftType == 2 || carried1.getCount() >= this.quickcraftSlots.size()) && this.canDragTo(slot1)) { int i2 = slot1.hasItem() ? slot1.getItem().getCount() : 0; @@ -255,7 +255,7 @@ index 2d6acceffb2cb7e55dd504018a70b05afccd9c11..bdc0ca1f625dc264bef6e5722ec66121 int min1 = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemStack) + i2, min); count -= min1 - i2; // slot1.setByPlayer(itemStack.copyWithCount(min1)); -@@ -563,7 +570,7 @@ public abstract class AbstractContainerMenu { +@@ -560,7 +567,7 @@ public abstract class AbstractContainerMenu { slot.setByPlayer(carried2); } } else if (ItemStack.isSameItemSameComponents(carried, carried2)) { @@ -264,16 +264,16 @@ index 2d6acceffb2cb7e55dd504018a70b05afccd9c11..bdc0ca1f625dc264bef6e5722ec66121 optional1.ifPresent(itemStack2 -> { carried2.grow(itemStack2.getCount()); slot.onTake(player, itemStack2); -@@ -625,7 +632,7 @@ public abstract class AbstractContainerMenu { - Slot slot2 = this.slots.get(slotId); +@@ -622,7 +629,7 @@ public abstract class AbstractContainerMenu { + Slot slot2 = this.slots.get(slotIndex); if (slot2.hasItem()) { ItemStack itemStack = slot2.getItem(); - this.setCarried(itemStack.copyWithCount(itemStack.getMaxStackSize())); + this.setCarried(itemStack.copyWithCount(org.leavesmc.leaves.util.ItemOverstackUtils.getItemStackMaxCount(itemStack))); // Leaves - item over-stack util } - } else if (clickType == ClickType.THROW && this.getCarried().isEmpty() && slotId >= 0) { - Slot slot2 = this.slots.get(slotId); -@@ -660,15 +667,15 @@ public abstract class AbstractContainerMenu { + } else if (clickType == ClickType.THROW && this.getCarried().isEmpty() && slotIndex >= 0) { + Slot slot2 = this.slots.get(slotIndex); +@@ -657,15 +664,15 @@ public abstract class AbstractContainerMenu { int maxStackSize = button == 0 ? 1 : -1; for (int i3 = 0; i3 < 2; i3++) { @@ -292,7 +292,7 @@ index 2d6acceffb2cb7e55dd504018a70b05afccd9c11..bdc0ca1f625dc264bef6e5722ec66121 itemStack.grow(itemStack1.getCount()); } } -@@ -770,7 +777,7 @@ public abstract class AbstractContainerMenu { +@@ -767,7 +774,7 @@ public abstract class AbstractContainerMenu { i = endIndex - 1; } @@ -301,7 +301,7 @@ index 2d6acceffb2cb7e55dd504018a70b05afccd9c11..bdc0ca1f625dc264bef6e5722ec66121 while (!stack.isEmpty() && (reverseDirection ? i >= startIndex : i < endIndex)) { Slot slot = this.slots.get(i); ItemStack item = slot.getItem(); -@@ -871,7 +878,7 @@ public abstract class AbstractContainerMenu { +@@ -868,7 +875,7 @@ public abstract class AbstractContainerMenu { public static boolean canItemQuickReplace(@Nullable Slot slot, ItemStack stack, boolean stackSizeMatters) { boolean flag = slot == null || !slot.hasItem(); return !flag && ItemStack.isSameItemSameComponents(stack, slot.getItem()) @@ -310,7 +310,7 @@ index 2d6acceffb2cb7e55dd504018a70b05afccd9c11..bdc0ca1f625dc264bef6e5722ec66121 : flag; } -@@ -879,7 +886,7 @@ public abstract class AbstractContainerMenu { +@@ -876,7 +883,7 @@ public abstract class AbstractContainerMenu { return switch (type) { case 0 -> Mth.floor((float)stack.getCount() / slots.size()); case 1 -> 1; @@ -319,7 +319,7 @@ index 2d6acceffb2cb7e55dd504018a70b05afccd9c11..bdc0ca1f625dc264bef6e5722ec66121 default -> stack.getCount(); }; } -@@ -902,7 +909,7 @@ public abstract class AbstractContainerMenu { +@@ -899,7 +906,7 @@ public abstract class AbstractContainerMenu { for (int i = 0; i < container.getContainerSize(); i++) { ItemStack item = container.getItem(i); if (!item.isEmpty()) { @@ -329,10 +329,10 @@ index 2d6acceffb2cb7e55dd504018a70b05afccd9c11..bdc0ca1f625dc264bef6e5722ec66121 } diff --git a/net/minecraft/world/inventory/MerchantContainer.java b/net/minecraft/world/inventory/MerchantContainer.java -index 1e5dfb1f9e371fa23cdfa9280797aa0e183d4cd2..1a593d5bfc4574fd071604105422cd1d395648b8 100644 +index a4203c416c7a83557055099a9ea8f43ac2b18b21..46c8026876e851ec4a31fd34c9b64623469ffb8d 100644 --- a/net/minecraft/world/inventory/MerchantContainer.java +++ b/net/minecraft/world/inventory/MerchantContainer.java -@@ -109,7 +109,7 @@ public class MerchantContainer implements Container { +@@ -108,7 +108,7 @@ public class MerchantContainer implements Container { @Override public void setItem(int index, ItemStack stack) { this.itemStacks.set(index, stack); @@ -342,7 +342,7 @@ index 1e5dfb1f9e371fa23cdfa9280797aa0e183d4cd2..1a593d5bfc4574fd071604105422cd1d this.updateSellItem(); } diff --git a/net/minecraft/world/inventory/Slot.java b/net/minecraft/world/inventory/Slot.java -index 5ceb8964476b40db4511bec91ff13c4f522a1357..f416d7976e41a06b5a8be93485eaa233ffceda5c 100644 +index 2b7e245ebf3bb471a1d817c4b5d56a64790cbab7..00083df87439ff0fa56e09853931b60579520d0e 100644 --- a/net/minecraft/world/inventory/Slot.java +++ b/net/minecraft/world/inventory/Slot.java @@ -75,7 +75,7 @@ public class Slot { @@ -353,21 +353,21 @@ index 5ceb8964476b40db4511bec91ff13c4f522a1357..f416d7976e41a06b5a8be93485eaa233 + return Math.min(this.getMaxStackSize(), org.leavesmc.leaves.util.ItemOverstackUtils.getItemStackMaxCount(stack)); // Leaves - item over-stack util } - @Nullable + public @Nullable Identifier getNoItemIcon() { diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java -index 33c3a5e39e8e1aa023baab76ef94f8aed481480e..a27e1d53abc2d8b8912226add33510067e10ed52 100644 +index 5489302acb5bceac2cae71079a8356b455cf1304..a688da5bc71799c13548d390ab58645da9128229 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -166,7 +166,7 @@ public final class ItemStack implements DataComponentHolder, ChangePublisher validateStrict(ItemStack stack) { +@@ -200,7 +200,8 @@ public final class ItemStack implements DataComponentHolder, ChangePublisher holder = Item.STREAM_CODEC.decode(buffer); DataComponentPatch dataComponentPatch = codec.decode(buffer); @@ -377,7 +377,7 @@ index 33c3a5e39e8e1aa023baab76ef94f8aed481480e..a27e1d53abc2d8b8912226add3351006 } } -@@ -202,13 +203,15 @@ public final class ItemStack implements DataComponentHolder, ChangePublisher "Item stack with count of " + count + " was larger than maximum: " + maxStackSize); } diff --git a/net/minecraft/world/level/block/CrafterBlock.java b/net/minecraft/world/level/block/CrafterBlock.java -index 38b03c7b02bdfc579e5e126c12de3d878e26d188..caf31218a1aff84367da126ee1dc46b8c8a1e5d1 100644 +index c5fe15844d405a27cdae18c903dd481c25b437de..3faa541c4a4623e915269d6241e1a3a3c6e374ff 100644 --- a/net/minecraft/world/level/block/CrafterBlock.java +++ b/net/minecraft/world/level/block/CrafterBlock.java -@@ -192,7 +192,7 @@ public class CrafterBlock extends BaseEntityBlock { +@@ -191,7 +191,7 @@ public class CrafterBlock extends BaseEntityBlock { Direction direction = state.getValue(ORIENTATION).front(); Container containerAt = HopperBlockEntity.getContainerAt(level, pos.relative(direction)); ItemStack itemStack = stack.copy(); @@ -420,10 +420,10 @@ index 38b03c7b02bdfc579e5e126c12de3d878e26d188..caf31218a1aff84367da126ee1dc46b8 org.bukkit.craftbukkit.inventory.CraftItemStack oitemstack = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack); diff --git a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -index d7a211220d5eba7e34b9083f06f39e9527962599..cef2d6d9a42ae36d6e2a0b31685a7738d2a400cf 100644 +index 8176c0b35852fb0753339a92f1bbae41a5ae6782..9ada04588b8d30d307a91d93c48e6dca25b8d484 100644 --- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -@@ -411,7 +411,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit +@@ -412,7 +412,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit ItemStack itemStack = this.items.get(index); boolean flag = !stack.isEmpty() && ItemStack.isSameItemSameComponents(itemStack, stack); this.items.set(index, stack); @@ -433,10 +433,10 @@ index d7a211220d5eba7e34b9083f06f39e9527962599..cef2d6d9a42ae36d6e2a0b31685a7738 this.cookingTotalTime = getTotalCookTime(serverLevel, this, this.recipeType, this.cookSpeedMultiplier); // Paper - cook speed multiplier API this.cookingTimer = 0; diff --git a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -index 10b2cc20bbf3b70e4e09dbbe14b90506e6366158..1535bb8cec8692e8d26eaff090288f1b8f75c253 100644 +index 8f80c469c309bf61328c4f98037495f47a38c3c1..b4127d4b4386b98205275a9a0ef8067ccf287e67 100644 --- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -@@ -155,7 +155,7 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co +@@ -134,7 +134,7 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co @Override public void setItem(int slot, ItemStack stack) { this.getItems().set(slot, stack); @@ -446,10 +446,10 @@ index 10b2cc20bbf3b70e4e09dbbe14b90506e6366158..1535bb8cec8692e8d26eaff090288f1b } diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index 3fd172f82216fa35c36e5f563819a6f01ffd4ea4..419bc939e19a306b33d4d387007c6acbae73fba3 100644 +index f851e0f7d727cb9dca70c578777d871af424388c..6a51bace3151646afae9de820d9c8977a0221df4 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -@@ -144,7 +144,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -145,7 +145,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen public void setItem(int index, ItemStack stack) { this.unpackLootTable(null); this.getItems().set(index, stack); @@ -458,7 +458,7 @@ index 3fd172f82216fa35c36e5f563819a6f01ffd4ea4..419bc939e19a306b33d4d387007c6acb } @Override -@@ -740,9 +740,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -741,9 +741,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen if (item.isEmpty()) { // Spigot start - SPIGOT-6693, SimpleContainer#setItem ItemStack leftover = ItemStack.EMPTY; // Paper - Make hoppers respect inventory max stack size diff --git a/lophine-server/minecraft-patches/features/0012-Leaves-Old-Explosion-Damage-Calculator.patch b/lophine-server/minecraft-patches/features/0012-Leaves-Old-Explosion-Damage-Calculator.patch index ff8d82d..4ec67d2 100644 --- a/lophine-server/minecraft-patches/features/0012-Leaves-Old-Explosion-Damage-Calculator.patch +++ b/lophine-server/minecraft-patches/features/0012-Leaves-Old-Explosion-Damage-Calculator.patch @@ -8,14 +8,14 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves/blob/3e96b237749a960f2 Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index b3e897a4afee742b5055d652ad7047a660d8ea04..33471f3d0e2cbd54eaf095c19555f8fdaeb55878 100644 +index c8fa9a9ae29ecf9b2d6234e7efee61d05c8bc0ae..336daa3f7e2c957286d245746af47603a98438bc 100644 --- a/net/minecraft/world/level/ServerExplosion.java +++ b/net/minecraft/world/level/ServerExplosion.java -@@ -729,6 +729,7 @@ public class ServerExplosion implements Explosion { +@@ -717,6 +717,7 @@ public class ServerExplosion implements Explosion { public boolean shouldAffectBlocklikeEntities() { - boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); - boolean flag = this.source == null || this.source.getType() != EntityType.BREEZE_WIND_CHARGE && this.source.getType() != EntityType.WIND_CHARGE; -+ if (fun.bm.lophine.config.modules.function.OldFeatureConfig.oldExplosionDamageCalculator) flag = flag && (this.source == null || !this.source.isInWater()); // Leaves - Old MC TNT wet explosion no item damage - return _boolean ? flag : this.blockInteraction.shouldAffectBlocklikeEntities() && flag; + boolean flag = this.level.getGameRules().get(GameRules.MOB_GRIEFING); + boolean flag1 = this.source == null || this.source.getType() != EntityType.BREEZE_WIND_CHARGE && this.source.getType() != EntityType.WIND_CHARGE; ++ if (fun.bm.lophine.config.modules.function.OldFeatureConfig.oldExplosionDamageCalculator) flag1 = flag1 && (this.source == null || !this.source.isInWater()); // Leaves - Old MC TNT wet explosion no item damage + return flag ? flag1 : this.blockInteraction.shouldAffectBlocklikeEntities() && flag1; } diff --git a/lophine-server/minecraft-patches/features/0013-Leaves-Old-raid-behavior.patch b/lophine-server/minecraft-patches/features/0013-Leaves-Old-raid-behavior.patch index 5d72bed..50a9eef 100644 --- a/lophine-server/minecraft-patches/features/0013-Leaves-Old-raid-behavior.patch +++ b/lophine-server/minecraft-patches/features/0013-Leaves-Old-raid-behavior.patch @@ -24,10 +24,10 @@ index 80f17f33f670018240c854df589cf90cdeab6e70..c9af615ff9120c07787f436dbb6024e5 if (raidAt == null || raidAt.getRaidOmenLevel() < raidAt.getMaxRaidOmenLevel()) { serverPlayer.addEffect(new MobEffectInstance(MobEffects.RAID_OMEN, 600, amplifier)); diff --git a/net/minecraft/world/entity/raid/Raid.java b/net/minecraft/world/entity/raid/Raid.java -index 1910bff3f08147bfd63703097e30b9f88c84e337..f45aa44a7a17946aeb406a447f18de34320a4fa2 100644 +index 4deb9e4688a04b25e862572b70bf91e3ace9841e..2f31fae204dbeeeec1d188b6908aec5ad937e62e 100644 --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -263,7 +263,7 @@ public class Raid { +@@ -264,7 +264,7 @@ public class Raid { } public boolean absorbRaidOmen(ServerPlayer player) { @@ -36,7 +36,7 @@ index 1910bff3f08147bfd63703097e30b9f88c84e337..f45aa44a7a17946aeb406a447f18de34 if (effect == null) { return false; } else { -@@ -340,7 +340,13 @@ public class Raid { +@@ -341,7 +341,13 @@ public class Raid { } if (flag1) { @@ -51,7 +51,7 @@ index 1910bff3f08147bfd63703097e30b9f88c84e337..f45aa44a7a17946aeb406a447f18de34 } if (this.raidCooldownTicks == 300 || this.raidCooldownTicks % 20 == 0) { -@@ -375,7 +381,14 @@ public class Raid { +@@ -396,7 +402,14 @@ public class Raid { int i = 0; while (this.shouldSpawnGroup()) { @@ -67,7 +67,7 @@ index 1910bff3f08147bfd63703097e30b9f88c84e337..f45aa44a7a17946aeb406a447f18de34 if (blockPos != null) { this.started = true; this.spawnGroup(level, blockPos); -@@ -387,7 +400,7 @@ public class Raid { +@@ -408,7 +421,7 @@ public class Raid { i++; } @@ -76,7 +76,7 @@ index 1910bff3f08147bfd63703097e30b9f88c84e337..f45aa44a7a17946aeb406a447f18de34 org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(level, this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit this.stop(); break; -@@ -683,7 +696,7 @@ public class Raid { +@@ -702,7 +715,7 @@ public class Raid { int i2 = this.center.getX() + Mth.floor(Mth.cos(f2) * 32.0F * f) + level.random.nextInt(3) * Mth.floor(f); int i3 = this.center.getZ() + Mth.floor(Mth.sin(f2) * 32.0F * f) + level.random.nextInt(3) * Mth.floor(f); int height = level.getHeight(Heightmap.Types.WORLD_SURFACE, i2, i3); @@ -85,7 +85,7 @@ index 1910bff3f08147bfd63703097e30b9f88c84e337..f45aa44a7a17946aeb406a447f18de34 mutableBlockPos.set(i2, height, i3); if (!level.isVillage(mutableBlockPos) || i <= 7) { int i4 = 10; -@@ -702,6 +715,36 @@ public class Raid { +@@ -721,6 +734,36 @@ public class Raid { return null; } @@ -122,7 +122,7 @@ index 1910bff3f08147bfd63703097e30b9f88c84e337..f45aa44a7a17946aeb406a447f18de34 private boolean addWaveMob(ServerLevel level, int wave, Raider raider) { // Folia start - make raids thread-safe if (!this.ownsRaid(level)) { -@@ -864,4 +907,43 @@ public class Raid { +@@ -883,4 +926,43 @@ public class Raid { this.spawnsPerWaveBeforeBonus = spawnsPerWaveBeforeBonus; } } @@ -167,10 +167,10 @@ index 1910bff3f08147bfd63703097e30b9f88c84e337..f45aa44a7a17946aeb406a447f18de34 + // Leaves end - old FindSpawnPosition } diff --git a/net/minecraft/world/entity/raid/Raider.java b/net/minecraft/world/entity/raid/Raider.java -index 3e30989c99cd11c8c94d6fd194d2969e3a7efda6..2d163f3d5eb1af4d539d24c0256855bbec960de4 100644 +index 29ddff87216069cdf423f96f3fe835e0802d9ab5..18c4dffb5942b17dc1f2e9d9124c4f3ba3271360 100644 --- a/net/minecraft/world/entity/raid/Raider.java +++ b/net/minecraft/world/entity/raid/Raider.java -@@ -128,6 +128,43 @@ public abstract class Raider extends PatrollingMonster { +@@ -127,6 +127,43 @@ public abstract class Raider extends PatrollingMonster { currentRaid.removeFromRaid(serverLevel, this, false); } @@ -203,7 +203,7 @@ index 3e30989c99cd11c8c94d6fd194d2969e3a7efda6..2d163f3d5eb1af4d539d24c0256855bb + i = net.minecraft.util.Mth.clamp(i, 0, 4); + net.minecraft.world.effect.MobEffectInstance mobeffect1 = new net.minecraft.world.effect.MobEffectInstance(net.minecraft.world.effect.MobEffects.BAD_OMEN, 120000, i, false, false, true); + -+ if (!serverLevel.getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_DISABLE_RAIDS)) { ++ if (serverLevel.getGameRules().get(net.minecraft.world.level.gamerules.GameRules.RAIDS)) { + entityhuman.addEffect(mobeffect1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN); // CraftBukkit + } + this.setPatrolLeader(false); @@ -213,4 +213,4 @@ index 3e30989c99cd11c8c94d6fd194d2969e3a7efda6..2d163f3d5eb1af4d539d24c0256855bb + // Leaves end - Revert raid changes } - super.die(cause); + super.die(damageSource); diff --git a/lophine-server/minecraft-patches/features/0015-Leaves-Servux-Protocol.patch b/lophine-server/minecraft-patches/features/0015-Leaves-Servux-Protocol.patch index beba988..bc0b2b5 100644 --- a/lophine-server/minecraft-patches/features/0015-Leaves-Servux-Protocol.patch +++ b/lophine-server/minecraft-patches/features/0015-Leaves-Servux-Protocol.patch @@ -8,10 +8,10 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves/blob/ea91106ae57fc4cc1 Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/net/minecraft/server/ServerTickRateManager.java b/net/minecraft/server/ServerTickRateManager.java -index d0d90a25a10bbecfffceee1992af88c60d14fd87..187e48e78e69c80b25710f193813335ec643957f 100644 +index 95f6b1cbd5e33151c326689bc72292ff38a48803..e1974bbebbd10b75ea02955d9ced198d54c8a6f1 100644 --- a/net/minecraft/server/ServerTickRateManager.java +++ b/net/minecraft/server/ServerTickRateManager.java -@@ -134,4 +134,10 @@ public class ServerTickRateManager extends TickRateManager { +@@ -135,4 +135,10 @@ public class ServerTickRateManager extends TickRateManager { player.connection.send(ClientboundTickingStatePacket.from(this)); player.connection.send(ClientboundTickingStepPacket.from(this)); } @@ -23,14 +23,15 @@ index d0d90a25a10bbecfffceee1992af88c60d14fd87..187e48e78e69c80b25710f193813335e + // Leaves end - servux } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 4d71cc3b643f6f594c90f2f8f9e5b820ebdff080..7fb095c544294796768ce19c4409416e2848e296 100644 +index 6aad6024dc121eae63b7fde92a89cbea29fcafb3..90e363a310936830788aee6484a63a989aa316e7 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -2368,6 +2368,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2442,6 +2442,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + this.server.updateEffectiveRespawnData(); } - - this.lastSpawnChunkRadius = i; + // Paper end ++ + org.leavesmc.leaves.protocol.servux.ServuxHudDataProtocol.refreshSpawnMetadata = true; // Leaves - servux } - public LongSet getForceLoadedChunks() { + @Override diff --git a/lophine-server/minecraft-patches/features/0018-Compatibility-fix-for-Raid-Revert-and-Cross-Region-D.patch b/lophine-server/minecraft-patches/features/0017-Compatibility-fix-for-Raid-Revert-and-Cross-Region-D.patch similarity index 86% rename from lophine-server/minecraft-patches/features/0018-Compatibility-fix-for-Raid-Revert-and-Cross-Region-D.patch rename to lophine-server/minecraft-patches/features/0017-Compatibility-fix-for-Raid-Revert-and-Cross-Region-D.patch index b84f28c..6830ca3 100644 --- a/lophine-server/minecraft-patches/features/0018-Compatibility-fix-for-Raid-Revert-and-Cross-Region-D.patch +++ b/lophine-server/minecraft-patches/features/0017-Compatibility-fix-for-Raid-Revert-and-Cross-Region-D.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Compatibility fix for Raid Revert and Cross Region Damage diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index e94687b3aa960f9c630f459fedc17bc01846eaf7..f4f4f886b6558d39d292a45665953f497f84be53 100644 +index ad497cc5a01662e86d6c3d0a7d51b86cfc764f53..67faf1ed52806ee2c1e2ea080b39959ad9ae986d 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -1216,6 +1216,29 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1225,6 +1225,29 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } } @@ -40,13 +40,13 @@ index e94687b3aa960f9c630f459fedc17bc01846eaf7..f4f4f886b6558d39d292a45665953f49 if (this.getType().is(EntityTypeTags.IMMUNE_TO_INFESTED)) { return !effectInstance.is(MobEffects.INFESTED); diff --git a/net/minecraft/world/entity/raid/Raider.java b/net/minecraft/world/entity/raid/Raider.java -index 2d163f3d5eb1af4d539d24c0256855bbec960de4..2cc0a7b5f088c29d9343b369b6e71c8a3ebdef75 100644 +index 18c4dffb5942b17dc1f2e9d9124c4f3ba3271360..2a2078ff7e353f5c94145ae700d58771a602a7ff 100644 --- a/net/minecraft/world/entity/raid/Raider.java +++ b/net/minecraft/world/entity/raid/Raider.java -@@ -158,7 +158,7 @@ public abstract class Raider extends PatrollingMonster { +@@ -157,7 +157,7 @@ public abstract class Raider extends PatrollingMonster { net.minecraft.world.effect.MobEffectInstance mobeffect1 = new net.minecraft.world.effect.MobEffectInstance(net.minecraft.world.effect.MobEffects.BAD_OMEN, 120000, i, false, false, true); - if (!serverLevel.getGameRules().getBoolean(net.minecraft.world.level.GameRules.RULE_DISABLE_RAIDS)) { + if (serverLevel.getGameRules().get(net.minecraft.world.level.gamerules.GameRules.RAIDS)) { - entityhuman.addEffect(mobeffect1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN); // CraftBukkit + entityhuman.addEffect(mobeffect1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN, true, fun.bm.lophine.config.modules.experiment.EntityDamageSourceTraceConfig.enabled); // Lophine - raid revert adapt Cross Region Damage trace } diff --git a/lophine-server/minecraft-patches/features/0017-Purpur-Barrels-and-enderchests-6-rows.patch b/lophine-server/minecraft-patches/features/0018-Purpur-Barrels-and-enderchests-6-rows.patch similarity index 90% rename from lophine-server/minecraft-patches/features/0017-Purpur-Barrels-and-enderchests-6-rows.patch rename to lophine-server/minecraft-patches/features/0018-Purpur-Barrels-and-enderchests-6-rows.patch index 6e32d2a..10b9fad 100644 --- a/lophine-server/minecraft-patches/features/0017-Purpur-Barrels-and-enderchests-6-rows.patch +++ b/lophine-server/minecraft-patches/features/0018-Purpur-Barrels-and-enderchests-6-rows.patch @@ -8,10 +8,10 @@ As part of: Purpur (https://github.com/PurpurMC/Purpur/blob/09f547de09fc5d886f18 Licensed under: MIT (https://github.com/PurpurMC/Purpur/blob/09f547de09fc5d886f18f6d99ff389289766ec9d/LICENSE) diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 6c1f4f943a5be5f2e43a82cca52ca76a98226915..8e2775e873c92beed6a0e4e8ce1304ab8ca6e8d1 100644 +index 35d51c727ce9229a174c45e9ea838fa9e3c3d80a..e4debb1e86f1f325dc17b709c5c9f3c4aa224b83 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -1087,6 +1087,10 @@ public abstract class PlayerList { +@@ -962,6 +962,10 @@ public abstract class PlayerList { player.getBukkitEntity().recalculatePermissions(); // CraftBukkit this.server.getCommands().sendCommands(player); } // Paper - Add sendOpLevel API @@ -23,10 +23,10 @@ index 6c1f4f943a5be5f2e43a82cca52ca76a98226915..8e2775e873c92beed6a0e4e8ce1304ab // Paper start - whitelist verify event / login event diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index 09b549fa9568aa1ae13b1b975db14a6268fdaa46..6c933c27ce155eb516a9ede96fb2c3bd19251bfa 100644 +index 3a8ac0765b8a988c281a2ded8c40ec044781cda2..1e3ac806c3f111ee0a4f8ef47134941ec85fbe6e 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -219,6 +219,7 @@ public abstract class Player extends LivingEntity { +@@ -179,6 +179,7 @@ public abstract class Player extends Avatar implements ContainerUser { private int currentImpulseContextResetGraceTime = 0; public boolean affectsSpawning = true; // Paper - Affects Spawning API public net.kyori.adventure.util.TriState flyingFallDamage = net.kyori.adventure.util.TriState.NOT_SET; // Paper - flying fall damage @@ -35,7 +35,7 @@ index 09b549fa9568aa1ae13b1b975db14a6268fdaa46..6c933c27ce155eb516a9ede96fb2c3bd // CraftBukkit start public boolean fauxSleeping; diff --git a/net/minecraft/world/inventory/ChestMenu.java b/net/minecraft/world/inventory/ChestMenu.java -index 0fffa384f928ab84451331380968fb4650eafe26..d84a10396395939149da88bcb01be59e220c340e 100644 +index 1fb3a34ea872dec73658fac59743e46ef8db5151..41ebe774edfe3c37afecda514a6eb7db978d5aa8 100644 --- a/net/minecraft/world/inventory/ChestMenu.java +++ b/net/minecraft/world/inventory/ChestMenu.java @@ -66,10 +66,30 @@ public class ChestMenu extends AbstractContainerMenu { @@ -70,7 +70,7 @@ index 0fffa384f928ab84451331380968fb4650eafe26..d84a10396395939149da88bcb01be59e return new ChestMenu(MenuType.GENERIC_9x6, containerId, playerInventory, container, 6); } diff --git a/net/minecraft/world/inventory/PlayerEnderChestContainer.java b/net/minecraft/world/inventory/PlayerEnderChestContainer.java -index 51148b7b95c93a9e25da70ac9275c63f1458d84c..dba8acfcacfe9a7b7e0fb9943fba49468214616e 100644 +index 9749909b8253b432bb2f7fba2cd8ff17a8579b30..42df617d7b62af45bd56e9594689974f790f6c19 100644 --- a/net/minecraft/world/inventory/PlayerEnderChestContainer.java +++ b/net/minecraft/world/inventory/PlayerEnderChestContainer.java @@ -26,11 +26,18 @@ public class PlayerEnderChestContainer extends SimpleContainer { @@ -94,7 +94,7 @@ index 51148b7b95c93a9e25da70ac9275c63f1458d84c..dba8acfcacfe9a7b7e0fb9943fba4946 this.activeChest = enderChestBlockEntity; } diff --git a/net/minecraft/world/level/block/EnderChestBlock.java b/net/minecraft/world/level/block/EnderChestBlock.java -index 5077a9ff7b78801bdc53536a37aee07b8d86ee4d..cef29289b7bc7fdf9613c0cd52f2bf4f715f288d 100644 +index 383e8285d366c7f594b0b4ff55b367970c9b69e4..202a986762794da9440365953fcb950c6eefa774 100644 --- a/net/minecraft/world/level/block/EnderChestBlock.java +++ b/net/minecraft/world/level/block/EnderChestBlock.java @@ -85,8 +85,14 @@ public class EnderChestBlock extends AbstractChestBlock i @@ -115,13 +115,13 @@ index 5077a9ff7b78801bdc53536a37aee07b8d86ee4d..cef29289b7bc7fdf9613c0cd52f2bf4f // Paper end - Fix InventoryOpenEvent cancellation - moved up; player.awardStat(Stats.OPEN_ENDERCHEST); diff --git a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java -index de99652629c7301a4bc0e9ec48bed9a26a338f0d..b43445d8313c330a0376aaa4eb872495ebd87b5f 100644 +index dcec63c1c2634a3e83ee3cac26f6e51441c37f6d..e5cfbf41525b0d454bb83691354afb4513723571 100644 --- a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java -@@ -56,7 +56,17 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -59,7 +59,17 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity implemen } // CraftBukkit end - + private static final Component DEFAULT_NAME = Component.translatable("container.barrel"); - private NonNullList items = NonNullList.withSize(27, ItemStack.EMPTY); + // Purpur start - Barrels and enderchests 6 rows + private NonNullList items = NonNullList.withSize(switch (fun.bm.lophine.config.modules.function.ContainerExpansionConfig.barrelRows) { @@ -137,7 +137,7 @@ index de99652629c7301a4bc0e9ec48bed9a26a338f0d..b43445d8313c330a0376aaa4eb872495 public final ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() { @Override protected void onOpen(Level level, BlockPos pos, BlockState state) { -@@ -108,7 +118,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -111,7 +121,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity implemen @Override public int getContainerSize() { @@ -155,7 +155,7 @@ index de99652629c7301a4bc0e9ec48bed9a26a338f0d..b43445d8313c330a0376aaa4eb872495 } @Override -@@ -129,7 +148,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -132,7 +151,16 @@ public class BarrelBlockEntity extends RandomizableContainerBlockEntity implemen @Override protected AbstractContainerMenu createMenu(int id, Inventory player) { diff --git a/lophine-server/minecraft-patches/features/0020-I18n-support.patch b/lophine-server/minecraft-patches/features/0019-I18n-support.patch similarity index 90% rename from lophine-server/minecraft-patches/features/0020-I18n-support.patch rename to lophine-server/minecraft-patches/features/0019-I18n-support.patch index 2b5443a..e90994a 100644 --- a/lophine-server/minecraft-patches/features/0020-I18n-support.patch +++ b/lophine-server/minecraft-patches/features/0019-I18n-support.patch @@ -26,10 +26,10 @@ index 7b9e2a1a208b46a69c16e6afd8b502259893574f..c300ae4363298fecef8fa9bf739f01c0 loadFromJson(resourceAsStream, output); } catch (JsonParseException | IOException var7) { diff --git a/net/minecraft/server/Main.java b/net/minecraft/server/Main.java -index cf72cb8b418239b56c755486b03a321672e16bc3..b69c06607ca900beeebf4892a978442dad2db19b 100644 +index 2d5309cc9386ef1bddf0bd4e153269fea1e75d60..ffa479f3743571bd198b1e3694301d73953a4eaa 100644 --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -155,6 +155,8 @@ public class Main { +@@ -151,6 +151,8 @@ public class Main { return; } @@ -39,10 +39,10 @@ index cf72cb8b418239b56c755486b03a321672e16bc3..b69c06607ca900beeebf4892a978442d String awtException = io.papermc.paper.util.ServerEnvironment.awtDependencyCheck(); if (awtException != null) { diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java -index 392d75548f7eb271a6320ac30eb301a61071d465..0e278f7b9ed85ce8c3cedd9154f817b30ff1e48a 100644 +index 4abfcaae4fe024296961987704e2a11a03ee518b..5fbcb5eac1d5449247da77b6120edbe2f2dd1d58 100644 --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -172,6 +172,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -262,6 +262,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface this.paperConfigurations.initializeWorldDefaultsConfiguration(this.registryAccess()); // Paper end - initialize global and world-defaults configuration me.earthme.luminol.config.ConfigManager.loadConfigFiles(); // Luminol - load config file diff --git a/lophine-server/minecraft-patches/features/0021-Old-zombie-reinforcement.patch b/lophine-server/minecraft-patches/features/0020-Old-zombie-reinforcement.patch similarity index 66% rename from lophine-server/minecraft-patches/features/0021-Old-zombie-reinforcement.patch rename to lophine-server/minecraft-patches/features/0020-Old-zombie-reinforcement.patch index 1e039f7..83864bf 100644 --- a/lophine-server/minecraft-patches/features/0021-Old-zombie-reinforcement.patch +++ b/lophine-server/minecraft-patches/features/0020-Old-zombie-reinforcement.patch @@ -4,11 +4,11 @@ Date: Mon, 19 May 2025 00:42:17 +0800 Subject: [PATCH] Old zombie reinforcement -diff --git a/net/minecraft/world/entity/monster/Zombie.java b/net/minecraft/world/entity/monster/Zombie.java -index 14d0758aca54d9a25e369dfa8c89c930f27946c9..1324f2c8c0d6571bac36855f08354a84e0f08b70 100644 ---- a/net/minecraft/world/entity/monster/Zombie.java -+++ b/net/minecraft/world/entity/monster/Zombie.java -@@ -341,7 +341,7 @@ public class Zombie extends Monster { +diff --git a/net/minecraft/world/entity/monster/zombie/Zombie.java b/net/minecraft/world/entity/monster/zombie/Zombie.java +index 1f359cf31dfd1a7bb9e1a9c8c830a4a4aa88ed00..206b725c9d1dffb185a466746544324135b14f23 100644 +--- a/net/minecraft/world/entity/monster/zombie/Zombie.java ++++ b/net/minecraft/world/entity/monster/zombie/Zombie.java +@@ -314,7 +314,7 @@ public class Zombie extends Monster { int floor = Mth.floor(this.getX()); int floor1 = Mth.floor(this.getY()); int floor2 = Mth.floor(this.getZ()); diff --git a/lophine-server/minecraft-patches/features/0022-Spawn-invulnerable-time.patch b/lophine-server/minecraft-patches/features/0021-Spawn-invulnerable-time.patch similarity index 85% rename from lophine-server/minecraft-patches/features/0022-Spawn-invulnerable-time.patch rename to lophine-server/minecraft-patches/features/0021-Spawn-invulnerable-time.patch index 0ee5c94..84bb5ab 100644 --- a/lophine-server/minecraft-patches/features/0022-Spawn-invulnerable-time.patch +++ b/lophine-server/minecraft-patches/features/0021-Spawn-invulnerable-time.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Spawn invulnerable time diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index de1263404395c28209234a556347284fa557f81c..44f0e3a675c612e9ca2bc40cc3898bdbca0f6718 100644 +index 93bc76af4d0abbe1c526434991e74c4465764ac6..1a43bdcb4c37df4ad1c4dfe6ebb84470832e910f 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -232,6 +232,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -240,6 +240,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc private int lastSentFood = -99999999; private boolean lastFoodSaturationZero = true; public int lastSentExp = -99999999; @@ -16,15 +16,15 @@ index de1263404395c28209234a556347284fa557f81c..44f0e3a675c612e9ca2bc40cc3898bdb private ChatVisiblity chatVisibility = ChatVisiblity.FULL; public ParticleStatus particleStatus = ParticleStatus.ALL; private boolean canChatColor = true; -@@ -925,6 +926,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc - this.tickClientLoadTimeout(); +@@ -898,6 +899,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + this.connection.tickClientLoadTimeout(); this.gameMode.tick(); this.wardenSpawnTracker.tick(); + if (this.spawnInvulnerableTime > 0) --this.spawnInvulnerableTime; // Lophine - spawn invulnerable time if (this.invulnerableTime > 0) { this.invulnerableTime--; } -@@ -1435,6 +1437,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -1538,6 +1540,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc if (this.isInvulnerableTo(level, damageSource)) { return false; } else { diff --git a/lophine-server/minecraft-patches/features/0023-Leaves-Fakeplayer.patch b/lophine-server/minecraft-patches/features/0022-Leaves-Fakeplayer.patch similarity index 74% rename from lophine-server/minecraft-patches/features/0023-Leaves-Fakeplayer.patch rename to lophine-server/minecraft-patches/features/0022-Leaves-Fakeplayer.patch index 9ca642d..bf7a7cb 100644 --- a/lophine-server/minecraft-patches/features/0023-Leaves-Fakeplayer.patch +++ b/lophine-server/minecraft-patches/features/0022-Leaves-Fakeplayer.patch @@ -7,10 +7,10 @@ Co-authored by: violetc <58360096+s-yh-china@users.noreply.github.com> As a part of : Leaves (https://github.com/LeavesMC/Leaves) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -diff --git a/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java b/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java -index a82d84283632342bd30bc3449983431ba43583e0..f59526f6bfa1b4af5b474f0b438513c96afb491c 100644 ---- a/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java -+++ b/net/minecraft/advancements/critereon/SimpleCriterionTrigger.java +diff --git a/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java b/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java +index 368a9d33f93c2e85abe4cf10df5a85c09fb03dd6..2b78040daeb3b09c08494cbc1d4a9d36080895f9 100644 +--- a/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java ++++ b/net/minecraft/advancements/criterion/SimpleCriterionTrigger.java @@ -39,6 +39,7 @@ public abstract class SimpleCriterionTrigger> set = (Set) advancements.criterionData.get(this); // Paper - fix PlayerAdvancements leak if (set != null && !set.isEmpty()) { diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java -index 66ec0424a46dcd49cf44467357d80b1a2d84d3b2..58694e28b3ff85ef038fe2ada2672e6d3b074fa4 100644 +index b4d6ddf02e72378022cc0a7cb6f8137fff3fa4f9..cb2ba07516ab931812987eaf5bb9222e9d279522 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -96,7 +96,7 @@ public class Connection extends SimpleChannelInboundHandler> { - @Nullable - private volatile PacketListener disconnectListener; - @Nullable -- private volatile PacketListener packetListener; -+ public volatile PacketListener packetListener; // Leaves - private -> protected // Lophine protected -> public - @Nullable - private DisconnectionDetails disconnectionDetails; +@@ -74,7 +74,7 @@ public class Connection extends SimpleChannelInboundHandler> { + public boolean preparing = true; + // Spigot end + private volatile @Nullable PacketListener disconnectListener; +- private volatile @Nullable PacketListener packetListener; ++ public volatile @Nullable PacketListener packetListener; // Leaves - private -> protected // Lophine protected -> public + private @Nullable DisconnectionDetails disconnectionDetails; private boolean encrypted; + private final java.util.concurrent.atomic.AtomicBoolean disconnectionHandled = new java.util.concurrent.atomic.AtomicBoolean(false); // Folia - region threading - may be called concurrently during configuration stage diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index b156b5c635f931a3d4abc0584591f90476d011a6..81726e5782d25ff35a2bea8820a62786e46148b1 100644 +index 6230c08d001aebc119900906aa557247261985a3..c6ff3d2a2e22be141e7a7a6999162a8ff74fa94a 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -347,6 +347,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop S spin(Function threadFunction) { ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry.init(); // Paper - rewrite data converter system AtomicReference atomicReference = new AtomicReference<>(); -@@ -1038,6 +1040,11 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0) { // Folia - region threading - this is complicated to implement, and even if done correctly is messy - if (this.playerList.getPlayerCount() == 0 && !this.tickRateManager.isSprinting() && this.pluginsBlockingSleep.isEmpty()) { // Paper - API to allow/disallow tick sleeping @@ -66,7 +66,7 @@ index b156b5c635f931a3d4abc0584591f90476d011a6..81726e5782d25ff35a2bea8820a62786 this.emptyTicks++; } else { this.emptyTicks = 0; -@@ -1912,6 +1919,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop gameProfiles, @Nullable Component reason) throws CommandSyntaxException { +@@ -45,7 +45,15 @@ public class BanPlayerCommands { UserBanList bans = source.getServer().getPlayerList().getBans(); int i = 0; -- + + boolean hasBot = false; // Leaves - disable kick - for (GameProfile gameProfile : gameProfiles) { + for (NameAndId nameAndId : players) { + // Leaves start - disable ban -+ if (gameProfile instanceof org.leavesmc.leaves.bot.BotList.CustomGameProfile) { ++ if (org.leavesmc.leaves.bot.BotList.INSTANCE.getBot(nameAndId.id()) != null) { + source.sendFailure(Component.literal("Permission denied")); + hasBot = true; + continue; + } + // Leaves end - disable ban -+ ServerPlayer player = source.getServer().getPlayerList().getPlayer(gameProfile.getId()); - if (!bans.isBanned(gameProfile)) { + if (!bans.isBanned(nameAndId)) { UserBanListEntry userBanListEntry = new UserBanListEntry( - gameProfile, null, source.getTextName(), null, reason == null ? null : reason.getString() -@@ -55,7 +63,6 @@ public class BanPlayerCommands { - source.sendSuccess( - () -> Component.translatable("commands.ban.success", Component.literal(gameProfile.getName()), userBanListEntry.getReason()), true - ); -- ServerPlayer player = source.getServer().getPlayerList().getPlayer(gameProfile.getId()); - if (player != null) { - player.connection.disconnect(Component.translatable("multiplayer.disconnect.banned"), org.bukkit.event.player.PlayerKickEvent.Cause.BANNED); // Paper - kick event cause - } -@@ -63,7 +70,13 @@ public class BanPlayerCommands { + nameAndId, null, source.getTextName(), null, reason == null ? null : reason.getString() +@@ -63,7 +71,13 @@ public class BanPlayerCommands { } if (i == 0) { @@ -170,7 +160,7 @@ index ac3ba9d0ea344fa189912d359b718fbe05e7aa49..61a4db144f721b47ac1000df72263bce return i; } diff --git a/net/minecraft/server/commands/KickCommand.java b/net/minecraft/server/commands/KickCommand.java -index 14e2e0fcf20c8fa875bbefb97a673be4928d099a..8af40a77dc3da1599da2793168488f88686b8785 100644 +index 5f78d629bab84acb2fa43a9fcc1cec52b4e91ae3..1c6059bd23afdd555d2dc8c533a5b027957c7b3a 100644 --- a/net/minecraft/server/commands/KickCommand.java +++ b/net/minecraft/server/commands/KickCommand.java @@ -46,9 +46,17 @@ public class KickCommand { @@ -188,7 +178,7 @@ index 14e2e0fcf20c8fa875bbefb97a673be4928d099a..8af40a77dc3da1599da2793168488f88 + continue; + } + // Leaves end - disable kick - if (!source.getServer().isSingleplayerOwner(serverPlayer.getGameProfile())) { + if (!source.getServer().isSingleplayerOwner(serverPlayer.nameAndId())) { serverPlayer.connection.disconnect(reason, org.bukkit.event.player.PlayerKickEvent.Cause.KICK_COMMAND); // Paper - kick event cause source.sendSuccess(() -> Component.translatable("commands.kick.success", serverPlayer.getDisplayName(), reason), true); @@ -57,7 +65,13 @@ public class KickCommand { @@ -207,22 +197,22 @@ index 14e2e0fcf20c8fa875bbefb97a673be4928d099a..8af40a77dc3da1599da2793168488f88 return i; } diff --git a/net/minecraft/server/commands/OpCommand.java b/net/minecraft/server/commands/OpCommand.java -index f2286b96b8f40b4588f817913c42ae7b4a92340f..e6c7bbb023000b9de90c1256274ff5aba4a6478a 100644 +index 07332a86e6e0441bafacb020f27ec36a277f1486..3798c1ea92ead20b3b7e67d88d2405f29e324d2c 100644 --- a/net/minecraft/server/commands/OpCommand.java +++ b/net/minecraft/server/commands/OpCommand.java @@ -43,6 +43,7 @@ public class OpCommand { int i = 0; - for (GameProfile gameProfile : gameProfiles) { -+ if (gameProfile instanceof org.leavesmc.leaves.bot.BotList.CustomGameProfile) continue; // Leaves - disable op - if (!playerList.isOp(gameProfile)) { - playerList.op(gameProfile); + for (NameAndId nameAndId : players) { ++ if (org.leavesmc.leaves.bot.BotList.INSTANCE.getBot(nameAndId.id()) != null) continue; // Leaves - disable op + if (!playerList.isOp(nameAndId)) { + playerList.op(nameAndId); i++; diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java -index 0e278f7b9ed85ce8c3cedd9154f817b30ff1e48a..09d4b1d68c3f046ef304016a1afe7a3038dfae3e 100644 +index 5fbcb5eac1d5449247da77b6120edbe2f2dd1d58..00285e2e68b00d627e91f292da46e9058255ea52 100644 --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -162,6 +162,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -252,6 +252,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface } // Spigot start @@ -230,7 +220,7 @@ index 0e278f7b9ed85ce8c3cedd9154f817b30ff1e48a..09d4b1d68c3f046ef304016a1afe7a30 this.setPlayerList(new DedicatedPlayerList(this, this.registries(), this.playerDataStorage)); org.spigotmc.SpigotConfig.init((java.io.File) this.options.valueOf("spigot-settings")); org.spigotmc.SpigotConfig.registerCommands(); -@@ -173,6 +174,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -263,6 +264,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface // Paper end - initialize global and world-defaults configuration me.earthme.luminol.config.ConfigManager.loadConfigFiles(); // Luminol - load config file fun.bm.lophine.utils.ServerI18nUtil.init(); // Lophine - I18n support @@ -239,13 +229,13 @@ index 0e278f7b9ed85ce8c3cedd9154f817b30ff1e48a..09d4b1d68c3f046ef304016a1afe7a30 // Paper start - fix converting txt to json file; convert old users earlier after PlayerList creation but before file load/save if (this.convertOldUsers()) { diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 70740381c6501c1a518c52b24381edd16792507f..8ad6d5a2522cfbe316fec2c3b918e2e1b9af3d1b 100644 +index fdccb06c918d387e46c29ede7337159db8c5d9ca..4cd5c5659ac098c3b7ff95efb94b1987e2dd40d0 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -1309,6 +1309,13 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -1386,6 +1386,13 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } - } else if (this.seenBy.remove(player.connection)) { - this.serverEntity.removePairing(player); + } else { + this.removePlayer(player); + // Leaves start - render bot + if (entity instanceof org.leavesmc.leaves.bot.ServerBot bot) { + if (bot.needSendFakeData(player)) { @@ -257,18 +247,18 @@ index 70740381c6501c1a518c52b24381edd16792507f..8ad6d5a2522cfbe316fec2c3b918e2e1 } } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 7fb095c544294796768ce19c4409416e2848e296..3393fb585747aaf3fa270c4bfe06ed4e9174d519 100644 +index 90e363a310936830788aee6484a63a989aa316e7..c09af6b81987df8e681689ecce9932a2e39af1a3 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -207,6 +207,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - private final StructureCheck structureCheck; +@@ -220,6 +220,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public final boolean tickTime; // Folia - region threading private final RandomSequences randomSequences; + final LevelDebugSynchronizers debugSynchronizers = new LevelDebugSynchronizers(this); + final List realPlayers; // Leaves - skip // CraftBukkit start public final LevelStorageSource.LevelStorageAccess levelStorageAccess; -@@ -635,6 +636,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -669,6 +670,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper end - rewrite chunk system this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit this.updateTickData(); // Folia - region threading - make sure it is initialised before ticked @@ -276,7 +266,7 @@ index 7fb095c544294796768ce19c4409416e2848e296..3393fb585747aaf3fa270c4bfe06ed4e } // Folia start - region threading -@@ -2389,6 +2391,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2469,6 +2471,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe return this.players; } @@ -289,7 +279,7 @@ index 7fb095c544294796768ce19c4409416e2848e296..3393fb585747aaf3fa270c4bfe06ed4e @Override public void updatePOIOnBlockStateChange(BlockPos pos, BlockState oldState, BlockState newState) { Optional> optional = PoiTypes.forState(oldState); -@@ -2827,6 +2835,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2942,6 +2950,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // ServerLevel.this.getChunkSource().addEntity(entity); // Paper - ignore and warn about illegal addEntity calls instead of crashing server; moved down below valid=true if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.add(serverPlayer); @@ -301,7 +291,7 @@ index 7fb095c544294796768ce19c4409416e2848e296..3393fb585747aaf3fa270c4bfe06ed4e if (serverPlayer.isReceivingWaypoints()) { ServerLevel.this.getWaypointManager().addPlayer(serverPlayer); } -@@ -2914,6 +2927,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -3029,6 +3042,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.remove(serverPlayer); @@ -314,10 +304,10 @@ index 7fb095c544294796768ce19c4409416e2848e296..3393fb585747aaf3fa270c4bfe06ed4e ServerLevel.this.updateSleepingPlayerList(); } diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 44f0e3a675c612e9ca2bc40cc3898bdbca0f6718..4b2dba8b30b72fb3acc00957b3e19d6fc178c99e 100644 +index 1a43bdcb4c37df4ad1c4dfe6ebb84470832e910f..daff493e4ea944afa91ce99a3596931a487304a3 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -219,7 +219,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -227,7 +227,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc private static final boolean DEFAULT_SPAWN_EXTRA_PARTICLES_ON_FALL = false; public ServerGamePacketListenerImpl connection; private final MinecraftServer server; @@ -326,7 +316,7 @@ index 44f0e3a675c612e9ca2bc40cc3898bdbca0f6718..4b2dba8b30b72fb3acc00957b3e19d6f private final PlayerAdvancements advancements; private final ServerStatsCounter stats; private float lastRecordedHealthAndAbsorption = Float.MIN_VALUE; -@@ -232,7 +232,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -240,7 +240,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc private int lastSentFood = -99999999; private boolean lastFoodSaturationZero = true; public int lastSentExp = -99999999; @@ -335,16 +325,16 @@ index 44f0e3a675c612e9ca2bc40cc3898bdbca0f6718..4b2dba8b30b72fb3acc00957b3e19d6f private ChatVisiblity chatVisibility = ChatVisiblity.FULL; public ParticleStatus particleStatus = ParticleStatus.ALL; private boolean canChatColor = true; -@@ -241,7 +241,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc - private Entity camera; +@@ -248,7 +248,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + private @Nullable Entity camera; public boolean isChangingDimension; public boolean seenCredits = false; - private final ServerRecipeBook recipeBook; + protected ServerRecipeBook recipeBook; // Leaves - not final and private -> protected - @Nullable - private Vec3 levitationStartPos; + private @Nullable Vec3 levitationStartPos; private int levitationStartTime; -@@ -436,6 +436,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + private boolean disconnected; +@@ -440,6 +440,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc // Paper start - rewrite chunk system private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader; private final ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder viewDistanceHolder = new ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder(); @@ -355,15 +345,15 @@ index 44f0e3a675c612e9ca2bc40cc3898bdbca0f6718..4b2dba8b30b72fb3acc00957b3e19d6f @Override public final boolean moonrise$isRealPlayer() { -@@ -924,6 +928,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -897,6 +901,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc } // CraftBukkit end - this.tickClientLoadTimeout(); + this.connection.tickClientLoadTimeout(); + this.resetOperationCountPerTick(); // Leaves - player operation limiter this.gameMode.tick(); this.wardenSpawnTracker.tick(); if (this.spawnInvulnerableTime > 0) --this.spawnInvulnerableTime; // Lophine - spawn invulnerable time -@@ -2029,6 +2034,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -2134,6 +2139,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc this.lastSentHealth = -1.0F; this.lastSentFood = -1; this.teleportSpectators(teleportTransition, serverLevel); @@ -375,7 +365,7 @@ index 44f0e3a675c612e9ca2bc40cc3898bdbca0f6718..4b2dba8b30b72fb3acc00957b3e19d6f // CraftBukkit start org.bukkit.event.player.PlayerChangedWorldEvent changeEvent = new org.bukkit.event.player.PlayerChangedWorldEvent(this.getBukkitEntity(), serverLevel.getWorld()); this.level().getCraftServer().getPluginManager().callEvent(changeEvent); -@@ -3577,4 +3587,31 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -3728,4 +3738,31 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc return (org.bukkit.craftbukkit.entity.CraftPlayer) super.getBukkitEntity(); } // CraftBukkit end @@ -407,50 +397,33 @@ index 44f0e3a675c612e9ca2bc40cc3898bdbca0f6718..4b2dba8b30b72fb3acc00957b3e19d6f + } + // Leaves end - player operation limiter } -diff --git a/net/minecraft/server/players/GameProfileCache.java b/net/minecraft/server/players/GameProfileCache.java -index 144a2644c15f276f02bb3be859dc5d05a677ac55..c6a89e8936cffa49b3de153ed3c40e3cc9b8ae61 100644 ---- a/net/minecraft/server/players/GameProfileCache.java -+++ b/net/minecraft/server/players/GameProfileCache.java -@@ -125,6 +125,12 @@ public class GameProfileCache { - // Paper end - - public Optional get(String name) { -+ // Leaves start - fix bot -+ org.leavesmc.leaves.bot.ServerBot bot = org.leavesmc.leaves.bot.BotList.INSTANCE.getBotByName(name); -+ if (bot != null) { -+ return Optional.of(bot.getGameProfile()); -+ } -+ // Leaves end - fix bot - String string = name.toLowerCase(Locale.ROOT); - boolean stateLocked = true; try { this.stateLock.lock(); // Paper - Fix GameProfileCache concurrency - GameProfileCache.GameProfileInfo gameProfileInfo = this.profilesByName.get(string); diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 8e2775e873c92beed6a0e4e8ce1304ab8ca6e8d1..580f114fd99b017403c61e994d0c947d00e5115d 100644 +index e4debb1e86f1f325dc17b709c5c9f3c4aa224b83..b78edaae1693c96b6b114348ef0c6198c04ab3bd 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -425,6 +425,19 @@ public abstract class PlayerList { +@@ -317,6 +317,19 @@ public abstract class PlayerList { - org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); + org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); -+ // Leaves start - bot support -+ if (fun.bm.lophine.config.modules.function.FakeplayerConfig.enable) { -+ org.leavesmc.leaves.bot.ServerBot bot = this.server.getBotList().getBotByName(player.getScoreboardName()); -+ if (bot != null) { -+ this.server.getBotList().removeBot(bot, org.leavesmc.leaves.event.bot.BotRemoveEvent.RemoveReason.INTERNAL, player.getBukkitEntity(), false, true); -+ } -+ this.server.getBotList().bots.forEach(bot1 -> { -+ bot1.sendPlayerInfo(player); -+ bot1.sendFakeDataIfNeed(player, true); -+ }); // Leaves - render bot ++ // Leaves start - bot support ++ if (fun.bm.lophine.config.modules.function.FakeplayerConfig.enable) { ++ org.leavesmc.leaves.bot.ServerBot bot = this.server.getBotList().getBotByName(player.getScoreboardName()); ++ if (bot != null) { ++ this.server.getBotList().removeBot(bot, org.leavesmc.leaves.event.bot.BotRemoveEvent.RemoveReason.INTERNAL, player.getBukkitEntity(), false, true); + } -+ // Leaves end - bot support ++ this.server.getBotList().bots.forEach(bot1 -> { ++ bot1.sendPlayerInfo(player); ++ bot1.sendFakeDataIfNeed(player, true); ++ }); // Leaves - render bot ++ } ++ // Leaves end - bot support + - final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); + final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); - if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure -@@ -922,6 +935,12 @@ public abstract class PlayerList { - } - // Paper end - Add PlayerPostRespawnEvent + if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure +@@ -790,6 +803,13 @@ public abstract class PlayerList { + ).callEvent(); + // Paper end + // Leaves start - bot support + if (fun.bm.lophine.config.modules.function.FakeplayerConfig.enable) { @@ -458,10 +431,11 @@ index 8e2775e873c92beed6a0e4e8ce1304ab8ca6e8d1..580f114fd99b017403c61e994d0c947d + } + // Leaves end - bot support + - // CraftBukkit end - ++ return serverPlayer; -@@ -1026,11 +1045,16 @@ public abstract class PlayerList { + } + +@@ -891,11 +911,16 @@ public abstract class PlayerList { public String[] getPlayerNamesArray() { List players = new java.util.ArrayList<>(this.players); // Folia - region threading @@ -469,20 +443,20 @@ index 8e2775e873c92beed6a0e4e8ce1304ab8ca6e8d1..580f114fd99b017403c61e994d0c947d + String[] strings = new String[this.players.size() + this.server.getBotList().bots.size()]; // Leaves - fakeplayer support for (int i = 0; i < players.size(); i++) { // Folia - region threading - strings[i] = players.get(i).getGameProfile().getName(); // Folia - region threading + strings[i] = players.get(i).getGameProfile().name(); // Folia - region threading } + // Leaves start - fakeplayer support + for (int i = this.players.size(); i < strings.length; ++i) { -+ strings[i] = this.server.getBotList().bots.get(i - this.players.size()).getGameProfile().getName(); ++ strings[i] = this.server.getBotList().bots.get(i - this.players.size()).getGameProfile().name(); + } + // Leaves end - fakeplayer support return strings; } -@@ -1141,7 +1165,14 @@ public abstract class PlayerList { +@@ -1015,7 +1040,14 @@ public abstract class PlayerList { + } - @Nullable - public ServerPlayer getPlayerByName(String username) { + public @Nullable ServerPlayer getPlayerByName(String username) { - return this.playersByName.get(username.toLowerCase(java.util.Locale.ROOT)); // Spigot + // Leaves start - fakeplayer support + username = username.toLowerCase(java.util.Locale.ROOT); @@ -495,10 +469,10 @@ index 8e2775e873c92beed6a0e4e8ce1304ab8ca6e8d1..580f114fd99b017403c61e994d0c947d } public void broadcast(@Nullable Player except, double x, double y, double z, double radius, ResourceKey dimension, Packet packet) { -@@ -1482,7 +1513,13 @@ public abstract class PlayerList { +@@ -1352,7 +1384,13 @@ public abstract class PlayerList { + } - @Nullable - public ServerPlayer getPlayer(UUID playerUUID) { + public @Nullable ServerPlayer getPlayer(UUID playerUUID) { - return this.playersByUUID.get(playerUUID); + // Leaves start - fakeplayer support + ServerPlayer player = this.playersByUUID.get(playerUUID); @@ -509,9 +483,9 @@ index 8e2775e873c92beed6a0e4e8ce1304ab8ca6e8d1..580f114fd99b017403c61e994d0c947d + // Leaves start - fakeplayer support } - public boolean canBypassPlayerLimit(GameProfile profile) { + public @Nullable ServerPlayer getPlayer(String name) { diff --git a/net/minecraft/server/waypoints/ServerWaypointManager.java b/net/minecraft/server/waypoints/ServerWaypointManager.java -index 55cb2d16e22e4d8745da539177b636d188ad0489..ce0942793c4098a1274b8ef5736e824a6eec0152 100644 +index 9492698541bfe704a1075a8fb58a9d7624895e48..5d304c468c99322e5ef6ea1c597fbbb1831e4020 100644 --- a/net/minecraft/server/waypoints/ServerWaypointManager.java +++ b/net/minecraft/server/waypoints/ServerWaypointManager.java @@ -24,6 +24,11 @@ public class ServerWaypointManager implements WaypointManager ((1L + this.totalEatTimeTicks) * 50L * (1000L * 1000L)); -- if ((--this.useItemRemaining == 0 || shouldLagCompensate) && !this.level().isClientSide && !usingItem.useOnRelease()) { -+ if ((--this.useItemRemaining == 0 || shouldLagCompensate) && !(this instanceof org.leavesmc.leaves.bot.ServerBot) && !this.level().isClientSide && !usingItem.useOnRelease()) { // Leaves - Fakeplayer skip this check +- if ((--this.useItemRemaining == 0 || shouldLagCompensate) && !this.level().isClientSide() && !usingItem.useOnRelease()) { ++ if ((--this.useItemRemaining == 0 || shouldLagCompensate) && !(this instanceof org.leavesmc.leaves.bot.ServerBot) && !this.level().isClientSide() && !usingItem.useOnRelease()) { // Leaves - Fakeplayer skip this check this.useItemRemaining = 0; // Paper end - lag compensate eating this.completeUsingItem(); -@@ -4239,6 +4239,23 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -4397,6 +4397,23 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin this.stopUsingItem(); } @@ -604,13 +578,13 @@ index f4f4f886b6558d39d292a45665953f497f84be53..12466e0294123a5922ee7694984d4d27 + // Leaves end - Fakeplayer + public void stopUsingItem() { - if (!this.level().isClientSide) { + if (!this.level().isClientSide()) { boolean isUsingItem = this.isUsingItem(); diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index 6c933c27ce155eb516a9ede96fb2c3bd19251bfa..6e0784af90aab5c25100613f97d4492fa7d1b277 100644 +index 1e3ac806c3f111ee0a4f8ef47134941ec85fbe6e..52c41d1e526dc0d42dde3773ab20ee7252737e5d 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -205,7 +205,7 @@ public abstract class Player extends LivingEntity { +@@ -168,7 +168,7 @@ public abstract class Player extends Avatar implements ContainerUser { private int lastLevelUpTime; public GameProfile gameProfile; private boolean reducedDebugInfo; @@ -618,8 +592,8 @@ index 6c933c27ce155eb516a9ede96fb2c3bd19251bfa..6e0784af90aab5c25100613f97d4492f + protected ItemStack lastItemInMainHand = ItemStack.EMPTY; private final ItemCooldowns cooldowns = this.createItemCooldowns(); private Optional lastDeathLocation = Optional.empty(); - @Nullable -@@ -412,6 +412,12 @@ public abstract class Player extends LivingEntity { + public @Nullable FishingHook fishing; +@@ -349,6 +349,12 @@ public abstract class Player extends Avatar implements ContainerUser { } } @@ -632,8 +606,8 @@ index 6c933c27ce155eb516a9ede96fb2c3bd19251bfa..6e0784af90aab5c25100613f97d4492f @Override protected float getMaxHeadRotationRelativeToBody() { return this.isBlocking() ? 15.0F : super.getMaxHeadRotationRelativeToBody(); -@@ -714,7 +720,7 @@ public abstract class Player extends LivingEntity { - } +@@ -574,7 +580,7 @@ public abstract class Player extends Avatar implements ContainerUser { + public void removeEntitiesOnShoulder() { } - private void touch(Entity entity) { @@ -641,17 +615,17 @@ index 6c933c27ce155eb516a9ede96fb2c3bd19251bfa..6e0784af90aab5c25100613f97d4492f entity.playerTouch(this); } -@@ -1339,7 +1345,7 @@ public abstract class Player extends LivingEntity { - this.sweepAttack(); - } +@@ -1251,7 +1257,7 @@ public abstract class Player extends Avatar implements ContainerUser { + // Paper end - Configurable sprint interruption on attack + } -- if (target instanceof ServerPlayer && target.hurtMarked) { -+ if ((target instanceof ServerPlayer && !(target instanceof org.leavesmc.leaves.bot.ServerBot)) && target.hurtMarked) { // Leaves - bot knockback - // CraftBukkit start - Add Velocity Event - boolean cancelled = false; - org.bukkit.entity.Player player = (org.bukkit.entity.Player) target.getBukkitEntity(); +- if (target instanceof ServerPlayer && target.hurtMarked) { ++ if ((target instanceof ServerPlayer && !(target instanceof org.leavesmc.leaves.bot.ServerBot)) && target.hurtMarked) { // Leaves - bot knockback + // CraftBukkit start - Add Velocity Event + boolean cancelled = false; + org.bukkit.entity.Player player = (org.bukkit.entity.Player) target.getBukkitEntity(); diff --git a/net/minecraft/world/entity/projectile/FishingHook.java b/net/minecraft/world/entity/projectile/FishingHook.java -index 7760ab1fe365b4bf1ab6c2ff953e8659a28008a8..76f6b0932633bc5670a1cdc76ff78b3bc725401d 100644 +index 71f6acc07d222fe512bf8d9fbaad35cb36bcf2d6..a9f5d503fbe50e54f2f44be2ca6d414430f4481e 100644 --- a/net/minecraft/world/entity/projectile/FishingHook.java +++ b/net/minecraft/world/entity/projectile/FishingHook.java @@ -58,7 +58,7 @@ public class FishingHook extends Projectile { @@ -663,11 +637,11 @@ index 7760ab1fe365b4bf1ab6c2ff953e8659a28008a8..76f6b0932633bc5670a1cdc76ff78b3b public int timeUntilLured; public int timeUntilHooked; public float fishAngle; -diff --git a/net/minecraft/world/entity/vehicle/AbstractBoat.java b/net/minecraft/world/entity/vehicle/AbstractBoat.java -index 91ac54fb0ae9a06945476cbd1caa20be32c4a9fe..be380db0cb2f243b4a3cf8bd1b06d38debc5f6fd 100644 ---- a/net/minecraft/world/entity/vehicle/AbstractBoat.java -+++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java -@@ -271,6 +271,11 @@ public abstract class AbstractBoat extends VehicleEntity implements Leashable { +diff --git a/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java b/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java +index fc1b3501114108d0166256c514a225337955e461..56bc87fefc82c77077bfed50accbde778c0059ea 100644 +--- a/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java ++++ b/net/minecraft/world/entity/vehicle/boat/AbstractBoat.java +@@ -270,6 +270,11 @@ public abstract class AbstractBoat extends VehicleEntity implements Leashable { } this.move(MoverType.SELF, this.getDeltaMovement()); @@ -679,7 +653,7 @@ index 91ac54fb0ae9a06945476cbd1caa20be32c4a9fe..be380db0cb2f243b4a3cf8bd1b06d38d } else { this.setDeltaMovement(Vec3.ZERO); } -@@ -383,6 +388,13 @@ public abstract class AbstractBoat extends VehicleEntity implements Leashable { +@@ -380,6 +385,13 @@ public abstract class AbstractBoat extends VehicleEntity implements Leashable { } } @@ -690,22 +664,22 @@ index 91ac54fb0ae9a06945476cbd1caa20be32c4a9fe..be380db0cb2f243b4a3cf8bd1b06d38d + } + // Leaves end - Fakeplayer + - @Nullable - protected SoundEvent getPaddleSound() { + protected @Nullable SoundEvent getPaddleSound() { return switch (this.getStatus()) { + case IN_WATER, UNDER_WATER, UNDER_FLOWING_WATER -> SoundEvents.BOAT_PADDLE_WATER; diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java -index bdc0ca1f625dc264bef6e5722ec66121ba48625a..525610be29d5077a3199287347b1b71cf9fd8abf 100644 +index 8e28afcfda7b180def81122e35920f6fd57a4574..f42697374461ab2e1c610b8c3250d3c03c0821b4 100644 --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -407,6 +407,7 @@ public abstract class AbstractContainerMenu { +@@ -404,6 +404,7 @@ public abstract class AbstractContainerMenu { - private void doClick(int slotId, int button, ClickType clickType, Player player) { + private void doClick(int slotIndex, int button, ClickType clickType, Player player) { Inventory inventory = player.getInventory(); -+ if (!doClickCheck(slotId, button, clickType, player)) return; // Leaves - doClick check ++ if (!doClickCheck(slotIndex, button, clickType, player)) return; // Leaves - doClick check if (clickType == ClickType.QUICK_CRAFT) { int i = this.quickcraftStatus; this.quickcraftStatus = getQuickcraftHeader(button); -@@ -685,6 +686,22 @@ public abstract class AbstractContainerMenu { +@@ -682,6 +683,22 @@ public abstract class AbstractContainerMenu { } } @@ -729,10 +703,10 @@ index bdc0ca1f625dc264bef6e5722ec66121ba48625a..525610be29d5077a3199287347b1b71c FeatureFlagSet featureFlagSet = player.level().enabledFeatures(); return carriedItem.isItemEnabled(featureFlagSet) && carriedItem.overrideStackedOnOther(slot, action, player) diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java -index a27e1d53abc2d8b8912226add33510067e10ed52..be0a267e5564a30c16f408cb311a448f354d60b4 100644 +index a688da5bc71799c13548d390ab58645da9128229..e63cca6f7f63a2b5f249ae01033167186e710fdb 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -450,7 +450,7 @@ public final class ItemStack implements DataComponentHolder, ChangePublisher As a part of : Leaves (https://github.com/LeavesMC/Leaves) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) +diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java +index daff493e4ea944afa91ce99a3596931a487304a3..f79735abf21b6eecc02e5b5f1ce3140dfef3ede9 100644 +--- a/net/minecraft/server/level/ServerPlayer.java ++++ b/net/minecraft/server/level/ServerPlayer.java +@@ -1458,7 +1458,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + } else if (fun.bm.lophine.config.modules.experiment.EntityDamageSourceTraceConfig.enabled) { + final LivingEntity entitylivingnew = this.getKillCreditOrigin(); + if (entitylivingnew != null) { +- this.damageTransferToAsync(entitylivingnew, cause); ++ this.damageTransferToAsync(entitylivingnew, damageSource); + } + // Luminol End - Cross Region Damage trace + } +diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index 5c81be29f7ecc3389b5b578f85774035def96e26..98d641b2e8ca340cb10fe0448f8a8b4f8446f616 100644 +--- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -3798,7 +3798,7 @@ public class ServerGamePacketListenerImpl + } else if (this.clientLoadedTimeoutTimer == 1) markClientLoaded(); // Paper - Add PlayerLoadedWorldEvent - decrement by calling #markClientLoaded which will set the value to 0 *and* call the event. + } + +- private void markClientLoaded() { ++ public void markClientLoaded() { // Lophine - private -> public + // Paper start - Add PlayerLoadedWorldEvent + if (!hasClientLoaded()) { + final io.papermc.paper.event.player.PlayerClientLoadedWorldEvent event = new io.papermc.paper.event.player.PlayerClientLoadedWorldEvent(this.player.getBukkitEntity(), true); diff --git a/net/minecraft/world/entity/animal/armadillo/Armadillo.java b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -index c1798db2972c8f2a343cf6e16fd9354ff212d906..a8d617b16ab2b2c0cdb289a0aa05fa171940cd7e 100644 +index 901e4e9897e76cd4158d7f8bb8ec829df8ff8196..59b9373c7a14e42d9e5f691354a7616d16856215 100644 --- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -@@ -63,7 +63,7 @@ public class Armadillo extends Animal { +@@ -64,7 +64,7 @@ public class Armadillo extends Animal { public final AnimationState rollOutAnimationState = new AnimationState(); public final AnimationState rollUpAnimationState = new AnimationState(); public final AnimationState peekAnimationState = new AnimationState(); @@ -20,12 +46,12 @@ index c1798db2972c8f2a343cf6e16fd9354ff212d906..a8d617b16ab2b2c0cdb289a0aa05fa17 + public int scuteTime; // Leaves - private -> public private boolean peekReceivedClient = false; - public Armadillo(EntityType entityType, Level level) { + public Armadillo(EntityType type, Level level) { diff --git a/net/minecraft/world/entity/animal/frog/Tadpole.java b/net/minecraft/world/entity/animal/frog/Tadpole.java -index 17f58246849ed407821a987b200cc765eb7943f9..ac27df3ba0ce9bbdf2f32ea87171fbb9407008d6 100644 +index f65cfb908aac16e6df4d209c6b5c3ee5065289d3..9afada8ca16775752468e1b14cd97daf26325fc4 100644 --- a/net/minecraft/world/entity/animal/frog/Tadpole.java +++ b/net/minecraft/world/entity/animal/frog/Tadpole.java -@@ -254,7 +254,7 @@ public class Tadpole extends AbstractFish { +@@ -244,7 +244,7 @@ public class Tadpole extends AbstractFish { } } @@ -35,7 +61,7 @@ index 17f58246849ed407821a987b200cc765eb7943f9..ac27df3ba0ce9bbdf2f32ea87171fbb9 } diff --git a/net/minecraft/world/level/storage/loot/LootPool.java b/net/minecraft/world/level/storage/loot/LootPool.java -index 6901e629d941e22e64d83eed4e8cfee3165a96a1..fdc26c8d8c82c20534c57af2a0281b99998cc9f6 100644 +index 43b8f4674602532f0273ebc5a0233476d10f6735..2ed995e68cf7812c74c3ba15b49450b2b5f3f0f8 100644 --- a/net/minecraft/world/level/storage/loot/LootPool.java +++ b/net/minecraft/world/level/storage/loot/LootPool.java @@ -37,7 +37,7 @@ public class LootPool { @@ -48,13 +74,13 @@ index 6901e629d941e22e64d83eed4e8cfee3165a96a1..fdc26c8d8c82c20534c57af2a0281b99 private final Predicate compositeCondition; private final List functions; diff --git a/net/minecraft/world/level/storage/loot/LootTable.java b/net/minecraft/world/level/storage/loot/LootTable.java -index 8612cdf7161f8ddff60a6478cc901318b8f958ba..07a962d647baa99b0e1bf3898a07cc914e91397e 100644 +index 35b5154473a3021dcae1f2ad016a77bcfb058c58..3d338b354c3d558a1c4ec20c149e8f26ed27da1e 100644 --- a/net/minecraft/world/level/storage/loot/LootTable.java +++ b/net/minecraft/world/level/storage/loot/LootTable.java @@ -50,7 +50,7 @@ public class LootTable { public static final LootTable EMPTY = new LootTable(LootContextParamSets.EMPTY, Optional.empty(), List.of(), List.of()); private final ContextKeySet paramSet; - private final Optional randomSequence; + private final Optional randomSequence; - private final List pools; + public final List pools; // Leaves - private -> public private final List functions; @@ -74,7 +100,7 @@ index eeaa49e9f70a18b5d39493aeff73f31b05ac2faa..8cd0403d7873c4c37caef75935b06b05 protected CompositeEntryBase(List children, List conditions) { diff --git a/net/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer.java b/net/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer.java -index 65e27bce9e59ef97bc8b914d646fba924d0f0877..a49bdcdf37b351436e0ba6d7865f10827c4e6ab4 100644 +index cfa05e882d2987cfab4c9d555a2de065b29fdf7e..4bacc9e2fb94d1b24887e7f0e9ce628814393209 100644 --- a/net/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer.java +++ b/net/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer.java @@ -14,7 +14,7 @@ import net.minecraft.world.level.storage.loot.predicates.ConditionUserBuilder; diff --git a/lophine-server/minecraft-patches/features/0028-Leaves-Xaero-Map-Protocol.patch b/lophine-server/minecraft-patches/features/0027-Leaves-Xaero-Map-Protocol.patch similarity index 63% rename from lophine-server/minecraft-patches/features/0028-Leaves-Xaero-Map-Protocol.patch rename to lophine-server/minecraft-patches/features/0027-Leaves-Xaero-Map-Protocol.patch index 786785a..551e90b 100644 --- a/lophine-server/minecraft-patches/features/0028-Leaves-Xaero-Map-Protocol.patch +++ b/lophine-server/minecraft-patches/features/0027-Leaves-Xaero-Map-Protocol.patch @@ -8,13 +8,13 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 580f114fd99b017403c61e994d0c947d00e5115d..11c1eb6995ec3aa896815efa59477096c39089d1 100644 +index b78edaae1693c96b6b114348ef0c6198c04ab3bd..70113b7d5cb2462f132f58ab60bea048ad219b41 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -1247,6 +1247,7 @@ public abstract class PlayerList { - player.connection.send(new ClientboundInitializeBorderPacket(worldBorder)); - player.connection.send(new ClientboundSetTimePacket(level.getGameTime(), level.getDayTime(), level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); - player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getSharedSpawnPos(), level.getSharedSpawnAngle())); +@@ -1126,6 +1126,7 @@ public abstract class PlayerList { + player.connection.send(new ClientboundSetChunkCacheRadiusPacket(level.spigotConfig.viewDistance)); + player.connection.send(new ClientboundSetSimulationDistancePacket(level.spigotConfig.simulationDistance)); + // Paper end + org.leavesmc.leaves.protocol.XaeroMapProtocol.onSendWorldInfo(player); // Leaves - xaero map protocol if (level.isRaining()) { // CraftBukkit start - handle player weather diff --git a/lophine-server/minecraft-patches/features/0029-Leaves-Support-REI-protocol.patch b/lophine-server/minecraft-patches/features/0028-Leaves-Support-REI-protocol.patch similarity index 83% rename from lophine-server/minecraft-patches/features/0029-Leaves-Support-REI-protocol.patch rename to lophine-server/minecraft-patches/features/0028-Leaves-Support-REI-protocol.patch index 4b067ae..bd0a6c0 100644 --- a/lophine-server/minecraft-patches/features/0029-Leaves-Support-REI-protocol.patch +++ b/lophine-server/minecraft-patches/features/0028-Leaves-Support-REI-protocol.patch @@ -8,10 +8,10 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -index 9bc0a9c3577d63a0ad5489bfd4c07d5006245c5f..bb2e891539b7eb49dc7925630695149aa531f672 100644 +index d02609198253b51f632db46c40afd737d686c520..7296e0b73f1c8e32374f39238d1dfac62bc41afb 100644 --- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java -@@ -83,6 +83,12 @@ public class SmithingTransformRecipe implements SmithingRecipe { +@@ -82,6 +82,12 @@ public class SmithingTransformRecipe implements SmithingRecipe { ); } @@ -25,10 +25,10 @@ index 9bc0a9c3577d63a0ad5489bfd4c07d5006245c5f..bb2e891539b7eb49dc7925630695149a @Override public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) { diff --git a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -index c324896afc2ee28ebb4d426ce4a469ee847ce24d..d5b26ff7be916e07e1162536cb2ddf5674c82f46 100644 +index 6582370cfa3d58a7ac08d574e26e7a93d243bdaa..07501a27e6032e578b823d9b617166a9e78fcb20 100644 --- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java -@@ -85,6 +85,12 @@ public class SmithingTrimRecipe implements SmithingRecipe { +@@ -84,6 +84,12 @@ public class SmithingTrimRecipe implements SmithingRecipe { return Optional.of(this.addition); } diff --git a/lophine-server/minecraft-patches/features/0030-Leaves-Wool-Hopper-Counter.patch b/lophine-server/minecraft-patches/features/0029-Leaves-Wool-Hopper-Counter.patch similarity index 93% rename from lophine-server/minecraft-patches/features/0030-Leaves-Wool-Hopper-Counter.patch rename to lophine-server/minecraft-patches/features/0029-Leaves-Wool-Hopper-Counter.patch index 2082017..817fc7a 100644 --- a/lophine-server/minecraft-patches/features/0030-Leaves-Wool-Hopper-Counter.patch +++ b/lophine-server/minecraft-patches/features/0029-Leaves-Wool-Hopper-Counter.patch @@ -10,10 +10,10 @@ Licensed under: MIT This patch is Powered by fabric-carpet(https://github.com/gnembon/fabric-carpet) diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index 419bc939e19a306b33d4d387007c6acbae73fba3..96445438c5b4202e3fc93bece778ad0d7312d41c 100644 +index 6a51bace3151646afae9de820d9c8977a0221df4..8dd50507bbc9f61c9ae019eecc5e9338d20addff 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -@@ -228,8 +228,30 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -229,8 +229,30 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen flag |= validator.getAsBoolean(); // Paper - note: this is not a validator, it's what adds/sucks in items } @@ -44,7 +44,7 @@ index 419bc939e19a306b33d4d387007c6acbae73fba3..96445438c5b4202e3fc93bece778ad0d setChanged(level, pos, state); // Leaves start - Lithium Sleeping Block Entity if (me.earthme.luminol.config.modules.optimizations.LeavesSleepingBlockEntityConfig.enabled -@@ -461,6 +483,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -462,6 +484,13 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen // Paper end - Perf: Optimize Hoppers private static boolean ejectItems(Level level, BlockPos pos, HopperBlockEntity blockEntity) { @@ -58,7 +58,7 @@ index 419bc939e19a306b33d4d387007c6acbae73fba3..96445438c5b4202e3fc93bece778ad0d Container attachedContainer = me.earthme.luminol.config.modules.optimizations.LeavesSleepingBlockEntityConfig.enabled ? blockEntity.getInsertInventory(level) : getAttachedContainer(level, pos, blockEntity); // Leaves - Lithium Sleeping Block Entity if (attachedContainer == null) { return false; -@@ -536,6 +565,26 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -537,6 +566,26 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } } @@ -85,7 +85,7 @@ index 419bc939e19a306b33d4d387007c6acbae73fba3..96445438c5b4202e3fc93bece778ad0d private static int[] getSlots(Container container, Direction direction) { if (container instanceof WorldlyContainer worldlyContainer) { return worldlyContainer.getSlotsForFace(direction); -@@ -680,6 +729,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -681,6 +730,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } public static boolean addItem(Container container, ItemEntity item) { diff --git a/lophine-server/minecraft-patches/features/0031-Leaves-Alternative-block-placement-Protocol.patch b/lophine-server/minecraft-patches/features/0030-Leaves-Alternative-block-placement-Protocol.patch similarity index 79% rename from lophine-server/minecraft-patches/features/0031-Leaves-Alternative-block-placement-Protocol.patch rename to lophine-server/minecraft-patches/features/0030-Leaves-Alternative-block-placement-Protocol.patch index 3b725c7..c7e3f76 100644 --- a/lophine-server/minecraft-patches/features/0031-Leaves-Alternative-block-placement-Protocol.patch +++ b/lophine-server/minecraft-patches/features/0030-Leaves-Alternative-block-placement-Protocol.patch @@ -13,11 +13,11 @@ MasaGadget(https://github.com/plusls/MasaGadget) litematica(https://github.com/maruohon/litematica) diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 9be4bc9e78c22c12ba594b16dac6901023f0fd47..3d9c26bc8cc14e98310f557f351871b082e5023e 100644 +index 98d641b2e8ca340cb10fe0448f8a8b4f8446f616..878f5c5801b68e3a6d01d63caf44737841387600 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2087,7 +2087,7 @@ public class ServerGamePacketListenerImpl - if (ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.player.level(), blockPos.getX() >> 4, blockPos.getZ() >> 4, 8) && this.player.canInteractWithBlock(blockPos, 1.0)) { // Folia - do not allow players to interact with blocks outside the current region +@@ -2128,7 +2128,7 @@ public class ServerGamePacketListenerImpl + if (ca.spottedleaf.moonrise.common.util.TickThread.isTickThreadFor(this.player.level(), blockPos.getX() >> 4, blockPos.getZ() >> 4, 8) && this.player.isWithinBlockInteractionRange(blockPos, 1.0)) { // Folia - do not allow players to interact with blocks outside the current region Vec3 vec3 = location.subtract(Vec3.atCenterOf(blockPos)); double d = 1.0000001; - if (Math.abs(vec3.x()) < 1.0000001 && Math.abs(vec3.y()) < 1.0000001 && Math.abs(vec3.z()) < 1.0000001) { @@ -26,26 +26,26 @@ index 9be4bc9e78c22c12ba594b16dac6901023f0fd47..3d9c26bc8cc14e98310f557f351871b0 this.player.resetLastActionTime(); int maxY = this.player.level().getMaxY(); diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java -index 6db566adf2d0df1d26221eda04aa01738df6d3d2..8f112f382190d606a87f38da8bcdf8dd5f31d1c5 100644 +index 73ce7c82c0bd28c2e43ca40ba35c4603b21375ad..a5d3caab2072b2c9bf8fdcbdb7c52c2dee16cfaf 100644 --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -149,7 +149,7 @@ public class BlockItem extends Item { +@@ -147,7 +147,7 @@ public class BlockItem extends Item { + } - @Nullable - protected BlockState getPlacementState(BlockPlaceContext context) { + protected @Nullable BlockState getPlacementState(BlockPlaceContext context) { - BlockState stateForPlacement = this.getBlock().getStateForPlacement(context); + BlockState stateForPlacement = this.getBlock().getRealStateForPlacement(context); // Leaves - alternativeBlockPlacement return stateForPlacement != null && this.canPlace(context, stateForPlacement) ? stateForPlacement : null; } diff --git a/net/minecraft/world/item/StandingAndWallBlockItem.java b/net/minecraft/world/item/StandingAndWallBlockItem.java -index 12c6c8aeec89a0a55633c62fe98f5a3aa75fd476..1f0e7c391d02b18e2c89700025713ec3d759f2ea 100644 +index d75c95d728efc0b4064f562ca80b68b23883feaf..be685383b8e7c8111e976fc560f16d43d6545a34 100644 --- a/net/minecraft/world/item/StandingAndWallBlockItem.java +++ b/net/minecraft/world/item/StandingAndWallBlockItem.java -@@ -27,14 +27,14 @@ public class StandingAndWallBlockItem extends BlockItem { - @Nullable +@@ -26,14 +26,14 @@ public class StandingAndWallBlockItem extends BlockItem { + @Override - protected BlockState getPlacementState(BlockPlaceContext context) { + protected @Nullable BlockState getPlacementState(BlockPlaceContext context) { - BlockState stateForPlacement = this.wallBlock.getStateForPlacement(context); + BlockState stateForPlacement = this.wallBlock.getRealStateForPlacement(context); // Leaves - alternativeBlockPlacement BlockState blockState = null; @@ -60,33 +60,32 @@ index 12c6c8aeec89a0a55633c62fe98f5a3aa75fd476..1f0e7c391d02b18e2c89700025713ec3 blockState = blockState1; break; diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java -index 644b9fab1d6729bf3964ebee0d6e9c46f89b8c46..634bdb554dfe757c3c9f13a79c3f644d8be4e3ea 100644 +index 13f06f1fbdf77b88493333b481b951d729579f11..e0ab4f7372ed11c9d17b341c8a24a82350c714fa 100644 --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -439,6 +439,33 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -489,6 +489,32 @@ public class Block extends BlockBehaviour implements ItemLike { public void stepOn(Level level, BlockPos pos, BlockState state, Entity entity) { } + // Leaves start - alternativeBlockPlacement -+ @Nullable -+ public BlockState getRealStateForPlacement(BlockPlaceContext ctx) { -+ BlockState vanillaState = this.getStateForPlacement(ctx); ++ public @Nullable BlockState getRealStateForPlacement(BlockPlaceContext context) { ++ BlockState vanillaState = this.getStateForPlacement(context); + switch (fun.bm.lophine.config.modules.function.protocol.AlternativeBlockPlacementProtocolConfig.alternativeBlockPlacement) { + case fun.bm.lophine.enums.EnumAlternativePlaceType.CARPET -> { -+ BlockState tryState = org.leavesmc.leaves.protocol.CarpetAlternativeBlockPlacement.alternativeBlockPlacement(this, ctx); ++ BlockState tryState = org.leavesmc.leaves.protocol.CarpetAlternativeBlockPlacement.alternativeBlockPlacement(this, context); + if (tryState != null) { + return tryState; + } + } + case fun.bm.lophine.enums.EnumAlternativePlaceType.CARPET_FIX -> { -+ BlockState tryState = org.leavesmc.leaves.protocol.CarpetAlternativeBlockPlacement.alternativeBlockPlacementFix(this, ctx); ++ BlockState tryState = org.leavesmc.leaves.protocol.CarpetAlternativeBlockPlacement.alternativeBlockPlacementFix(this, context); + if (tryState != null) { + return tryState; + } + } + case fun.bm.lophine.enums.EnumAlternativePlaceType.LITEMATICA -> { + if (vanillaState != null) { -+ return org.leavesmc.leaves.protocol.LitematicaEasyPlaceProtocol.applyPlacementProtocol(vanillaState, ctx); ++ return org.leavesmc.leaves.protocol.LitematicaEasyPlaceProtocol.applyPlacementProtocol(vanillaState, context); + } + } + } @@ -94,6 +93,6 @@ index 644b9fab1d6729bf3964ebee0d6e9c46f89b8c46..634bdb554dfe757c3c9f13a79c3f644d + } + // Leaves end - alternativeBlockPlacement + - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext context) { + public @Nullable BlockState getStateForPlacement(BlockPlaceContext context) { return this.defaultBlockState(); + } diff --git a/lophine-server/minecraft-patches/features/0032-Leaves-Replay-Mod-API.patch b/lophine-server/minecraft-patches/features/0031-Leaves-Replay-Mod-API.patch similarity index 81% rename from lophine-server/minecraft-patches/features/0032-Leaves-Replay-Mod-API.patch rename to lophine-server/minecraft-patches/features/0031-Leaves-Replay-Mod-API.patch index 5fb0f7b..102b423 100644 --- a/lophine-server/minecraft-patches/features/0032-Leaves-Replay-Mod-API.patch +++ b/lophine-server/minecraft-patches/features/0031-Leaves-Replay-Mod-API.patch @@ -10,23 +10,23 @@ Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) This patch is Powered by ReplayMod (https://github.com/ReplayMod) diff --git a/net/minecraft/commands/CommandSourceStack.java b/net/minecraft/commands/CommandSourceStack.java -index 8c005a7b9480da7c124c5bd5bfccd5ca83abbcb1..a814a67f321662f05e2c5f81666f75e128bf4ea7 100644 +index f046aca874eb3376696baaad3719a6987afbfe22..268b2c6b981c8164fb829eb8a33beb213fe60bcf 100644 --- a/net/minecraft/commands/CommandSourceStack.java +++ b/net/minecraft/commands/CommandSourceStack.java -@@ -580,7 +580,7 @@ public class CommandSourceStack implements ExecutionCommandSource getOnlinePlayerNames() { -- return this.entity instanceof ServerPlayer sourcePlayer && !sourcePlayer.getBukkitEntity().hasPermission("paper.bypass-visibility.tab-completion") ? this.getServer().getPlayerList().getPlayers().stream().filter(serverPlayer -> sourcePlayer.getBukkitEntity().canSee(serverPlayer.getBukkitEntity())).map(serverPlayer -> serverPlayer.getGameProfile().getName()).toList() : Lists.newArrayList(this.server.getPlayerNames()); // Paper - Make CommandSourceStack respect hidden players -+ return this.entity instanceof ServerPlayer sourcePlayer && !(sourcePlayer instanceof org.leavesmc.leaves.replay.ServerPhotographer) && !sourcePlayer.getBukkitEntity().hasPermission("paper.bypass-visibility.tab-completion") ? this.getServer().getPlayerList().getPlayers().stream().filter(serverPlayer -> sourcePlayer.getBukkitEntity().canSee(serverPlayer.getBukkitEntity())).map(serverPlayer -> serverPlayer.getGameProfile().getName()).toList() : Lists.newArrayList(this.server.getPlayerNames()); // Paper - Make CommandSourceStack respect hidden players // Leaves - only real player +- return this.entity instanceof ServerPlayer sourcePlayer && !sourcePlayer.getBukkitEntity().hasPermission("paper.bypass-visibility.tab-completion") ? this.getServer().getPlayerList().getPlayers().stream().filter(serverPlayer -> sourcePlayer.getBukkitEntity().canSee(serverPlayer.getBukkitEntity())).map(serverPlayer -> serverPlayer.getGameProfile().name()).toList() : Lists.newArrayList(this.server.getPlayerNames()); // Paper - Make CommandSourceStack respect hidden players ++ return this.entity instanceof ServerPlayer sourcePlayer && !(sourcePlayer instanceof org.leavesmc.leaves.replay.ServerPhotographer) && !sourcePlayer.getBukkitEntity().hasPermission("paper.bypass-visibility.tab-completion") ? this.getServer().getPlayerList().getPlayers().stream().filter(serverPlayer -> sourcePlayer.getBukkitEntity().canSee(serverPlayer.getBukkitEntity())).map(serverPlayer -> serverPlayer.getGameProfile().name()).toList() : Lists.newArrayList(this.server.getPlayerNames()); // Paper - Make CommandSourceStack respect hidden players // Leaves - only real player } @Override diff --git a/net/minecraft/commands/arguments/selector/EntitySelector.java b/net/minecraft/commands/arguments/selector/EntitySelector.java -index 514f8fbdeb776087608665c35de95294aadf5cf0..b75772897cabc3e7c59301d451685378fa55b6c3 100644 +index af71e0e1eb1c93745f3e4954ecc8fbd2ad4808a3..f3829564681faff3ae8971ed90b947b4a082a636 100644 --- a/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java -@@ -128,11 +128,12 @@ public class EntitySelector { +@@ -126,11 +126,12 @@ public class EntitySelector { return this.findPlayers(source); } else if (this.playerName != null) { ServerPlayer playerByName = source.getServer().getPlayerList().getPlayerByName(this.playerName); @@ -40,7 +40,7 @@ index 514f8fbdeb776087608665c35de95294aadf5cf0..b75772897cabc3e7c59301d451685378 if (entity.getType().isEnabled(source.enabledFeatures())) { return List.of(entity); } -@@ -146,7 +147,7 @@ public class EntitySelector { +@@ -144,7 +145,7 @@ public class EntitySelector { AABB absoluteAabb = this.getAbsoluteAabb(vec3); if (this.currentEntity) { Predicate predicate = this.getPredicate(vec3, absoluteAabb, null); @@ -49,7 +49,7 @@ index 514f8fbdeb776087608665c35de95294aadf5cf0..b75772897cabc3e7c59301d451685378 } else { Predicate predicate = this.getPredicate(vec3, absoluteAabb, source.enabledFeatures()); List list = new ObjectArrayList<>(); -@@ -157,6 +158,7 @@ public class EntitySelector { +@@ -155,6 +156,7 @@ public class EntitySelector { this.addEntities(list, serverLevel1, absoluteAabb, predicate); } } @@ -57,7 +57,7 @@ index 514f8fbdeb776087608665c35de95294aadf5cf0..b75772897cabc3e7c59301d451685378 return this.sortAndLimit(vec3, list); } -@@ -192,9 +194,11 @@ public class EntitySelector { +@@ -190,9 +192,11 @@ public class EntitySelector { this.checkPermissions(source); if (this.playerName != null) { ServerPlayer playerByName = source.getServer().getPlayerList().getPlayerByName(this.playerName); @@ -69,7 +69,7 @@ index 514f8fbdeb776087608665c35de95294aadf5cf0..b75772897cabc3e7c59301d451685378 return playerByName == null ? List.of() : List.of(playerByName); } else { Vec3 vec3 = this.position.apply(source.getPosition()); -@@ -206,11 +210,11 @@ public class EntitySelector { +@@ -204,11 +208,11 @@ public class EntitySelector { int resultLimit = this.getResultLimit(); List players; if (this.isWorldLimited()) { @@ -84,10 +84,10 @@ index 514f8fbdeb776087608665c35de95294aadf5cf0..b75772897cabc3e7c59301d451685378 players.add(serverPlayer1); if (players.size() >= resultLimit) { diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 81726e5782d25ff35a2bea8820a62786e46148b1..3c94631f468f4ee1b46de9981c17171e5901d745 100644 +index c6ff3d2a2e22be141e7a7a6999162a8ff74fa94a..367759edd3bd76345bc8cb46342abfd9f37cb2e9 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1800,7 +1800,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { // Folia - region threading + // Paper start - Expand PlayerGameModeChangeEvent + org.bukkit.event.player.PlayerGameModeChangeEvent event = player.setGameMode(gameMode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, null); // Folia - region threading +@@ -2492,7 +2492,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> startTrackingPackets = this.getStartTrackingPackets(objective); @@ -149,7 +158,7 @@ index fc1c377ad05edcefacd407671801ae605f3fc31a..5635f0940b4b70f27c8dfdc1aa666fcb if (serverPlayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board for (Packet packet : startTrackingPackets) { serverPlayer.connection.send(packet); -@@ -268,7 +268,7 @@ public class ServerScoreboard extends Scoreboard { +@@ -275,7 +275,7 @@ public class ServerScoreboard extends Scoreboard { public void stopTrackingObjective(Objective objective) { List> stopTrackingPackets = this.getStopTrackingPackets(objective); @@ -158,21 +167,8 @@ index fc1c377ad05edcefacd407671801ae605f3fc31a..5635f0940b4b70f27c8dfdc1aa666fcb if (serverPlayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board for (Packet packet : stopTrackingPackets) { serverPlayer.connection.send(packet); -diff --git a/net/minecraft/server/commands/DefaultGameModeCommands.java b/net/minecraft/server/commands/DefaultGameModeCommands.java -index c2ab47bb97c4fbbbc48a8ff0538ab8fd38532a88..2b7d11195f96e68a004e0e060e19d4004bb8a154 100644 ---- a/net/minecraft/server/commands/DefaultGameModeCommands.java -+++ b/net/minecraft/server/commands/DefaultGameModeCommands.java -@@ -27,7 +27,7 @@ public class DefaultGameModeCommands { - server.setDefaultGameType(gamemode); - GameType forcedGameType = server.getForcedGameType(); - if (forcedGameType != null) { -- for (ServerPlayer serverPlayer : server.getPlayerList().getPlayers()) { -+ for (ServerPlayer serverPlayer : server.getPlayerList().realPlayers) { // Leaves - only real players - serverPlayer.getBukkitEntity().taskScheduler.schedule((ServerPlayer player) -> { // Folia - region threading - // Paper start - Expand PlayerGameModeChangeEvent - org.bukkit.event.player.PlayerGameModeChangeEvent event = player.setGameMode(gamemode, org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, net.kyori.adventure.text.Component.empty()); // Folia - region threading diff --git a/net/minecraft/server/commands/ListPlayersCommand.java b/net/minecraft/server/commands/ListPlayersCommand.java -index c6ae34f91b3629990294fc5e69237a1e600ef038..2109b0a2d4099e64c34cd1c45b83f72654d3b615 100644 +index e7c778a7f292fd0749cbd5e6586ad1b93ac7f29e..024b56405bb58801b17a6adad7fec7a461d12a5c 100644 --- a/net/minecraft/server/commands/ListPlayersCommand.java +++ b/net/minecraft/server/commands/ListPlayersCommand.java @@ -33,7 +33,7 @@ public class ListPlayersCommand { @@ -185,7 +181,7 @@ index c6ae34f91b3629990294fc5e69237a1e600ef038..2109b0a2d4099e64c34cd1c45b83f726 org.bukkit.entity.Player sender = (org.bukkit.entity.Player) source.getBukkitSender(); playersTemp = playersTemp.stream().filter((ep) -> sender.canSee(ep.getBukkitEntity())).collect(java.util.stream.Collectors.toList()); diff --git a/net/minecraft/server/commands/OpCommand.java b/net/minecraft/server/commands/OpCommand.java -index e6c7bbb023000b9de90c1256274ff5aba4a6478a..98f8804d58616592332e2a968282be6ad8903ea8 100644 +index 3798c1ea92ead20b3b7e67d88d2405f29e324d2c..922383a284c8fb3c183d8a15dc41d813451adfb3 100644 --- a/net/minecraft/server/commands/OpCommand.java +++ b/net/minecraft/server/commands/OpCommand.java @@ -25,7 +25,7 @@ public class OpCommand { @@ -195,10 +191,10 @@ index e6c7bbb023000b9de90c1256274ff5aba4a6478a..98f8804d58616592332e2a968282be6a - playerList.getPlayers() + playerList.realPlayers // Leaves - only real player .stream() - .filter(serverPlayer -> !playerList.isOp(serverPlayer.getGameProfile())) - .map(serverPlayer -> serverPlayer.getGameProfile().getName()), + .filter(serverPlayer -> !playerList.isOp(serverPlayer.nameAndId())) + .map(serverPlayer -> serverPlayer.getGameProfile().name()), diff --git a/net/minecraft/server/commands/ParticleCommand.java b/net/minecraft/server/commands/ParticleCommand.java -index 33d96239f4b72a5587dc70f9602847a870d6d6a5..a83ce2cd112fca02cf3545f8c38e5cafae2c7c0e 100644 +index b5cb0fd45c1e33f40ff38e86772c9e6cc06c10a0..e9ac6ee47fd9c3d73e55a3467bb1c53f931609d0 100644 --- a/net/minecraft/server/commands/ParticleCommand.java +++ b/net/minecraft/server/commands/ParticleCommand.java @@ -36,7 +36,7 @@ public class ParticleCommand { @@ -247,7 +243,7 @@ index 33d96239f4b72a5587dc70f9602847a870d6d6a5..a83ce2cd112fca02cf3545f8c38e5caf ) .then( diff --git a/net/minecraft/server/commands/TeamMsgCommand.java b/net/minecraft/server/commands/TeamMsgCommand.java -index 134d7b1a9d5a5a47ebf4aabff110dde914cd6fe1..894dd1d048904b8a775416ea6cb3112215c567bc 100644 +index 0ae4d68dfe42004839a0c5ad457de592f6b4af8b..1d1e396e4b29f33669872fb39e3a7f1d474a49f7 100644 --- a/net/minecraft/server/commands/TeamMsgCommand.java +++ b/net/minecraft/server/commands/TeamMsgCommand.java @@ -40,7 +40,7 @@ public class TeamMsgCommand { @@ -260,20 +256,20 @@ index 134d7b1a9d5a5a47ebf4aabff110dde914cd6fe1..894dd1d048904b8a775416ea6cb31122 .filter(player -> player == entityOrException || player.getTeam() == team) .toList(); diff --git a/net/minecraft/server/commands/WhitelistCommand.java b/net/minecraft/server/commands/WhitelistCommand.java -index 763a51d9a0859296eb4ea52b6879d6c7703db673..25b4fcf79dbf3e227451b3321d8fd38bab55ffe9 100644 +index 305273583b3d2ad233c6cd67883baad15fe572eb..ce2939eac9c66e0c6eaac1570c4da19d908662ad 100644 --- a/net/minecraft/server/commands/WhitelistCommand.java +++ b/net/minecraft/server/commands/WhitelistCommand.java -@@ -43,7 +43,7 @@ public class WhitelistCommand { +@@ -44,7 +44,7 @@ public class WhitelistCommand { (commandContext, suggestionsBuilder) -> { PlayerList playerList = commandContext.getSource().getServer().getPlayerList(); return SharedSuggestionProvider.suggest( - playerList.getPlayers() + playerList.realPlayers // Leaves - only real player .stream() - .filter(serverPlayer -> !playerList.getWhiteList().isWhiteListed(serverPlayer.getGameProfile())) - .map(serverPlayer -> serverPlayer.getGameProfile().getName()), + .map(Player::nameAndId) + .filter(nameAndId -> !playerList.getWhiteList().isWhiteListed(nameAndId)) diff --git a/net/minecraft/server/gui/PlayerListComponent.java b/net/minecraft/server/gui/PlayerListComponent.java -index f5ba0c9a4c3f9eaa38eeb689de915c25c7165433..24bbc32bc17802edbd9cc14310fe8141c0ad85b0 100644 +index 5a8cd3e6b448a4472092690cf589bca10b142126..158593b1a6384db635a1f224919b24c174944b10 100644 --- a/net/minecraft/server/gui/PlayerListComponent.java +++ b/net/minecraft/server/gui/PlayerListComponent.java @@ -17,8 +17,8 @@ public class PlayerListComponent extends JList { @@ -281,17 +277,17 @@ index f5ba0c9a4c3f9eaa38eeb689de915c25c7165433..24bbc32bc17802edbd9cc14310fe8141 Vector list = new Vector<>(); - for (int i = 0; i < this.server.getPlayerList().getPlayers().size(); i++) { -- list.add(this.server.getPlayerList().getPlayers().get(i).getGameProfile().getName()); -+ for (int i = 0; i < this.server.getPlayerList().realPlayers.size(); i++) { // Leaves - only real players -+ list.add(this.server.getPlayerList().realPlayers.get(i).getGameProfile().getName()); // Leaves - only real players +- list.add(this.server.getPlayerList().getPlayers().get(i).getGameProfile().name()); ++ for (int i = 0; i < this.server.getPlayerList().realPlayers.size(); i++) { ++ list.add(this.server.getPlayerList().realPlayers.get(i).getGameProfile().name()); } this.setListData(list); diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 3393fb585747aaf3fa270c4bfe06ed4e9174d519..c58b88f09e6f08d178fcb17a13dd790c3cb62aae 100644 +index c09af6b81987df8e681689ecce9932a2e39af1a3..b3c593474e889d254f59813e7f42299b7b77d9ce 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -2836,7 +2836,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2951,7 +2951,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.add(serverPlayer); // Leaves start - skip @@ -300,7 +296,7 @@ index 3393fb585747aaf3fa270c4bfe06ed4e9174d519..c58b88f09e6f08d178fcb17a13dd790c ServerLevel.this.realPlayers.add(serverPlayer); } // Leaves end - skip -@@ -2928,7 +2928,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -3043,7 +3043,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.remove(serverPlayer); // Leaves start - skip @@ -310,10 +306,10 @@ index 3393fb585747aaf3fa270c4bfe06ed4e9174d519..c58b88f09e6f08d178fcb17a13dd790c } // Leaves end - skip diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 4b2dba8b30b72fb3acc00957b3e19d6fc178c99e..afd607df83fda3de6f53f55ad305c8f69fe6ddb6 100644 +index f79735abf21b6eecc02e5b5f1ce3140dfef3ede9..04a600d96f4ae7c08d06dc4fb8f71b3f0eb1be07 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -194,7 +194,7 @@ import net.minecraft.world.scores.criteria.ObjectiveCriteria; +@@ -202,7 +202,7 @@ import org.jspecify.annotations.Nullable; import org.slf4j.Logger; public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patches.chunk_system.player.ChunkSystemServerPlayer { // Paper - rewrite chunk system @@ -322,19 +318,28 @@ index 4b2dba8b30b72fb3acc00957b3e19d6fc178c99e..afd607df83fda3de6f53f55ad305c8f6 public static final long LAST_SAVE_ABSENT = Long.MIN_VALUE; public long lastSave = LAST_SAVE_ABSENT; // Paper // Folia - threaded regions - changed to nanoTime private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_XZ = 32; private static final int NEUTRAL_MOB_DEATH_NOTIFICATION_RADII_Y = 10; +@@ -673,7 +673,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + // Paper start - Expand PlayerGameModeChangeEvent + this.loadGameTypes(input); + } +- private void loadGameTypes(ValueInput input) { ++ public void loadGameTypes(ValueInput input) { // Lophine - private -> public + if (this.server.getForcedGameType() != null && this.server.getForcedGameType() != readPlayerMode(input, "playerGameType")) { + if (new org.bukkit.event.player.PlayerGameModeChangeEvent(this.getBukkitEntity(), org.bukkit.GameMode.getByValue(this.server.getDefaultGameType().getId()), org.bukkit.event.player.PlayerGameModeChangeEvent.Cause.DEFAULT_GAMEMODE, null).callEvent()) { + this.gameMode.setGameModeForPlayer(this.server.getForcedGameType(), GameType.DEFAULT_MODE); diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 11c1eb6995ec3aa896815efa59477096c39089d1..762728e490a152d159684324e200ab0d2852ac7f 100644 +index 70113b7d5cb2462f132f58ab60bea048ad219b41..eb0ec68a93e1bd81b32d0c309a56c95e265c977f 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -130,6 +130,7 @@ public abstract class PlayerList { + private int simulationDistance; private boolean allowCommandsForAllPlayers; - private static final boolean ALLOW_LOGOUTIVATOR = false; private int sendAllPlayerInfoIn; + public final List realPlayers = new java.util.concurrent.CopyOnWriteArrayList(); // Leaves - replay api // CraftBukkit start private org.bukkit.craftbukkit.CraftServer cserver; -@@ -213,6 +214,123 @@ public abstract class PlayerList { +@@ -218,6 +219,123 @@ public abstract class PlayerList { abstract public void loadAndSaveFiles(); // Paper - fix converting txt to json file; moved from DedicatedPlayerList constructor @@ -354,9 +359,9 @@ index 11c1eb6995ec3aa896815efa59477096c39089d1..762728e490a152d159684324e200ab0d + player.loadGameTypes(null); + ServerGamePacketListenerImpl playerconnection = new ServerGamePacketListenerImpl(this.server, connection, player, CommonListenerCookie.createInitial(player.gameProfile, false)); + GameRules gamerules = worldserver1.getGameRules(); -+ boolean flag = gamerules.getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN); -+ boolean flag1 = gamerules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO); -+ boolean flag2 = gamerules.getBoolean(GameRules.RULE_LIMITED_CRAFTING); ++ boolean flag = gamerules.get(GameRules.IMMEDIATE_RESPAWN); ++ boolean flag1 = gamerules.get(GameRules.REDUCED_DEBUG_INFO); ++ boolean flag2 = gamerules.get(GameRules.LIMITED_CRAFTING); + + playerconnection.send(new ClientboundLoginPacket(player.getId(), worlddata.isHardcore(), this.server.levelKeys(), this.getMaxPlayers(), worldserver1.getWorld().getSendViewDistance(), worldserver1.getWorld().getSimulationDistance(), flag1, !flag, flag2, player.createCommonSpawnInfo(worldserver1), this.server.enforceSecureProfile())); // Paper - replace old player chunk management + player.getBukkitEntity().sendSupportedChannels(); // CraftBukkit @@ -383,7 +388,7 @@ index 11c1eb6995ec3aa896815efa59477096c39089d1..762728e490a152d159684324e200ab0d + this.playersByName.put(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT), player); // Spigot + this.playersByUUID.put(player.getUUID(), player); + -+ player.supressTrackerForLogin = true; ++ player.suppressTrackerForLogin = true; + worldserver1.getCurrentWorldData().connections.add(player.connection.connection); + worldserver1.addNewPlayer(player); + this.server.getCustomBossEvents().onPlayerConnect(player); @@ -429,7 +434,7 @@ index 11c1eb6995ec3aa896815efa59477096c39089d1..762728e490a152d159684324e200ab0d + } + + player.sentListPacket = true; -+ player.supressTrackerForLogin = false; ++ player.suppressTrackerForLogin = false; + player.level().getChunkSource().chunkMap.addEntity(player); + + this.sendLevelInfo(player, worldserver1); @@ -455,18 +460,18 @@ index 11c1eb6995ec3aa896815efa59477096c39089d1..762728e490a152d159684324e200ab0d + } + // Leaves end - replay mod api + - public void loadSpawnForNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie cookie, org.apache.commons.lang3.mutable.MutableObject scopedCollectorStore, org.apache.commons.lang3.mutable.MutableObject data, org.apache.commons.lang3.mutable.MutableObject lastKnownName, ca.spottedleaf.concurrentutil.completable.CallbackCompletable toComplete) { // Folia - region threading - rewrite login process + public void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie cookie) { player.isRealPlayer = true; // Paper player.loginTime = System.currentTimeMillis(); // Paper - Replace OfflinePlayer#getLastPlayed -@@ -398,6 +516,7 @@ public abstract class PlayerList { +@@ -292,6 +410,7 @@ public abstract class PlayerList { - // player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players)); // CraftBukkit - replaced with loop below - this.players.add(player); -+ this.realPlayers.add(player); // Leaves - replay api - this.playersByName.put(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT), player); // Spigot - this.playersByUUID.put(player.getUUID(), player); - // this.broadcastAll(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(player))); // CraftBukkit - replaced with loop below -@@ -601,6 +720,7 @@ public abstract class PlayerList { + // player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players)); // CraftBukkit - replaced with loop below + this.players.add(player); ++ this.realPlayers.add(player); // Leaves - replay api + this.playersByName.put(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT), player); // Spigot + this.playersByUUID.put(player.getUUID(), player); + // this.broadcastAll(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(player))); // CraftBukkit - replaced with loop below +@@ -507,6 +626,7 @@ public abstract class PlayerList { } protected void save(ServerPlayer player) { @@ -474,7 +479,7 @@ index 11c1eb6995ec3aa896815efa59477096c39089d1..762728e490a152d159684324e200ab0d if (!player.getBukkitEntity().isPersistent()) return; // CraftBukkit player.lastSave = System.nanoTime(); // Folia - region threading - changed to nanoTime tracking this.playerIo.save(player); -@@ -615,6 +735,44 @@ public abstract class PlayerList { +@@ -521,6 +641,44 @@ public abstract class PlayerList { } } @@ -516,10 +521,10 @@ index 11c1eb6995ec3aa896815efa59477096c39089d1..762728e490a152d159684324e200ab0d + } + // Leaves stop - replay mod api + - public @Nullable net.kyori.adventure.text.Component remove(ServerPlayer player) { // CraftBukkit - return string // Paper - return Component + public net.kyori.adventure.text.@Nullable Component remove(ServerPlayer player) { // CraftBukkit - return string // Paper - return Component // Paper start - Fix kick event leave message not being sent return this.remove(player, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? player.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName()))); -@@ -688,6 +846,7 @@ public abstract class PlayerList { +@@ -594,6 +752,7 @@ public abstract class PlayerList { player.retireScheduler(); // Paper - Folia schedulers player.getAdvancements().stopListening(); this.players.remove(player); @@ -527,7 +532,7 @@ index 11c1eb6995ec3aa896815efa59477096c39089d1..762728e490a152d159684324e200ab0d this.playersByName.remove(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot this.server.getCustomBossEvents().onPlayerDisconnect(player); UUID uuid = player.getUUID(); -@@ -1044,15 +1203,15 @@ public abstract class PlayerList { +@@ -910,15 +1069,15 @@ public abstract class PlayerList { } public String[] getPlayerNamesArray() { @@ -536,29 +541,27 @@ index 11c1eb6995ec3aa896815efa59477096c39089d1..762728e490a152d159684324e200ab0d + List players = new java.util.ArrayList<>(this.realPlayers); // Folia - region threading + String[] strings = new String[players.size() + this.server.getBotList().bots.size()]; // Leaves - fakeplayer support, and skip photographer -- for (int i = 0; i < players.size(); i++) { // Folia - region threading -- strings[i] = players.get(i).getGameProfile().getName(); // Folia - region threading -+ for (int i = 0; i < players.size(); i++) { // Folia - region threading // Leaves - only real players -+ strings[i] = players.get(i).getGameProfile().getName(); // Folia - region threading // Leaves - only real players + for (int i = 0; i < players.size(); i++) { // Folia - region threading + strings[i] = players.get(i).getGameProfile().name(); // Folia - region threading } // Leaves start - fakeplayer support - for (int i = this.players.size(); i < strings.length; ++i) { -- strings[i] = this.server.getBotList().bots.get(i - this.players.size()).getGameProfile().getName(); +- strings[i] = this.server.getBotList().bots.get(i - this.players.size()).getGameProfile().name(); + for (int i = players.size(); i < strings.length; ++i) { // Leaves - only real players -+ strings[i] = this.server.getBotList().bots.get(i - players.size()).getGameProfile().getName(); // Leaves - only real players ++ strings[i] = this.server.getBotList().bots.get(i - players.size()).getGameProfile().name(); // Leaves - only real players } // Leaves end - fakeplayer support diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 12466e0294123a5922ee7694984d4d277a390ddd..205e2648569b7c18f488aa4d3d9ec944bb1babf4 100644 +index f80f5533c1c3c64ee1b8b2c43e2bc2dea8ab567f..aa9cbb5f02b87789fd94521792aefac5c840c95a 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -257,7 +257,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - protected ItemStack useItem = ItemStack.EMPTY; +@@ -262,7 +262,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin public int useItemRemaining; protected int fallFlyTicks; + private long lastKineticHitFeedbackTime = -2147483648L; - private BlockPos lastPos; + protected BlockPos lastPos; private Optional lastClimbablePos = Optional.empty(); - @Nullable - private DamageSource lastDamageSource; + private @Nullable DamageSource lastDamageSource; + private long lastDamageStamp = Long.MIN_VALUE; // Folia - region threading diff --git a/lophine-server/minecraft-patches/features/0033-Leaves-Catch-update-suppression-crash.patch b/lophine-server/minecraft-patches/features/0032-Leaves-Catch-update-suppression-crash.patch similarity index 77% rename from lophine-server/minecraft-patches/features/0033-Leaves-Catch-update-suppression-crash.patch rename to lophine-server/minecraft-patches/features/0032-Leaves-Catch-update-suppression-crash.patch index 26c2a40..e27524e 100644 --- a/lophine-server/minecraft-patches/features/0033-Leaves-Catch-update-suppression-crash.patch +++ b/lophine-server/minecraft-patches/features/0032-Leaves-Catch-update-suppression-crash.patch @@ -7,36 +7,49 @@ Co-authored by: violetc <58360096+s-yh-china@users.noreply.github.com> As a part of : Leaves (https://github.com/LeavesMC/Leaves) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -diff --git a/net/minecraft/network/protocol/PacketUtils.java b/net/minecraft/network/protocol/PacketUtils.java -index 7280ca2250ade4166a1a883b205bbc89f4e00d1a..06268ac3420fc03a798a20bb617ba89a032df527 100644 ---- a/net/minecraft/network/protocol/PacketUtils.java -+++ b/net/minecraft/network/protocol/PacketUtils.java -@@ -30,7 +30,20 @@ public class PacketUtils { - final int packetTimerId = profiler.getOrCreateTimerAndStart(() -> "Packet Handler: ".concat(io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(packet.getClass().getName()))); try { // Folia - profiler - packet.handle(processor); - } finally { profiler.stopTimer(packetTimerId); } // Folia - profiler +diff --git a/net/minecraft/network/PacketProcessor.java b/net/minecraft/network/PacketProcessor.java +index 758cb258a7e0478bfaacfc1b6c93ce8a501b0e6c..8624b8462742907d5be9f010f465f0e118fa2d6c 100644 +--- a/net/minecraft/network/PacketProcessor.java ++++ b/net/minecraft/network/PacketProcessor.java +@@ -107,7 +107,20 @@ public class PacketProcessor implements AutoCloseable { + final int packetTimerId = profiler.getOrCreateTimerAndStart(() -> "Packet Handler: ".concat(io.papermc.paper.util.ObfHelper.INSTANCE.deobfClassName(ListenerAndPacket.this.packet.getClass().getName()))); try { // Folia - profiler + this.packet.handle(this.listener); + } finally { profiler.stopTimer(packetTimerId); } // Folia - profiler +- } catch (Exception var3) { + // Leaves start - update suppression crash fix + } catch (org.leavesmc.leaves.util.UpdateSuppressionException exception) { -+ if (processor instanceof net.minecraft.server.network.ServerGamePacketListenerImpl gamePacketListener) { ++ if (this.listener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl gamePacketListener) { + exception.providePlayer(gamePacketListener.player); + } + exception.consume(); - } catch (Exception var4) { -+ if (var4.getCause() instanceof org.leavesmc.leaves.util.UpdateSuppressionException exception) { -+ if (processor instanceof net.minecraft.server.network.ServerGamePacketListenerImpl gamePacketListener) { ++ } catch (Exception var3) { ++ if (var3.getCause() instanceof org.leavesmc.leaves.util.UpdateSuppressionException exception) { ++ if (this.listener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl gamePacketListener) { + exception.providePlayer(gamePacketListener.player); + } + exception.consume(); + } -+ // Leaves end - update suppression crash fix - if (var4 instanceof ReportedException reportedException && reportedException.getCause() instanceof OutOfMemoryError) { - throw makeReportedException(var4, packet, processor); - } ++ // Leaves end - update suppression crash fix + if (var3 instanceof ReportedException reportedException && reportedException.getCause() instanceof OutOfMemoryError) { + throw PacketUtils.makeReportedException(var3, this.packet, this.listener); + } +diff --git a/net/minecraft/network/protocol/PacketUtils.java b/net/minecraft/network/protocol/PacketUtils.java +index 760e7c579410432776ae8b1d6f70f0747da0460b..f29b639693615df29908a14716e394d7a62eb828 100644 +--- a/net/minecraft/network/protocol/PacketUtils.java ++++ b/net/minecraft/network/protocol/PacketUtils.java +@@ -36,6 +36,7 @@ public class PacketUtils { + } + + public static ReportedException makeReportedException(Exception exception, Packet packet, T packetListener) { ++ + if (exception instanceof ReportedException reportedException) { + fillCrashReport(reportedException.getReport(), packetListener, packet); + return reportedException; diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 3c94631f468f4ee1b46de9981c17171e5901d745..f7a2a19c0832ca90536d09de23f4ec9a7d4a1521 100644 +index 367759edd3bd76345bc8cb46342abfd9f37cb2e9..323c5557984bd1361a0bb2de9e446b2e6b2cb301 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1878,8 +1878,17 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ca.spottedleaf.moonrise.patch @@ -168,10 +181,10 @@ index 9b9842462b210b0407279ee8a8e9ccecf3ead005..1057f3bd32ff4c8f93f09251341c2439 } diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index 1f44a59e46f86ca055e89631d831a38f4c3e238e..39c075173b77b5197af5d4ad3fe235ea0d2df756 100644 +index b2694cb60505766877398fa526b9bfe60e6b6404..7c354894f48a5540eb2554d8b1428306e8929066 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -378,7 +378,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -383,7 +383,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot if (blockState == state) { return null; } else { @@ -180,7 +193,7 @@ index 1f44a59e46f86ca055e89631d831a38f4c3e238e..39c075173b77b5197af5d4ad3fe235ea this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING).update(i, y, i2, state); this.heightmaps.get(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES).update(i, y, i2, state); this.heightmaps.get(Heightmap.Types.OCEAN_FLOOR).update(i, y, i2, state); -@@ -450,6 +450,7 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -457,6 +457,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot this.markUnsaved(); return blockState; } @@ -189,7 +202,7 @@ index 1f44a59e46f86ca055e89631d831a38f4c3e238e..39c075173b77b5197af5d4ad3fe235ea } } diff --git a/net/minecraft/world/level/redstone/NeighborUpdater.java b/net/minecraft/world/level/redstone/NeighborUpdater.java -index 714e291b17856aacdac7db992fc18e6ae662f659..01285691a2e0bf72b94969e9045f7ab42a9161bf 100644 +index af21821513f11011e7bf3841d2f79cb99e4cd517..32488203ff074b675f5c8831d157b1d91bae48a9 100644 --- a/net/minecraft/world/level/redstone/NeighborUpdater.java +++ b/net/minecraft/world/level/redstone/NeighborUpdater.java @@ -63,9 +63,22 @@ public interface NeighborUpdater { diff --git a/lophine-server/minecraft-patches/features/0034-Leaves-CCE-update-suppression.patch b/lophine-server/minecraft-patches/features/0033-Leaves-CCE-update-suppression.patch similarity index 84% rename from lophine-server/minecraft-patches/features/0034-Leaves-CCE-update-suppression.patch rename to lophine-server/minecraft-patches/features/0033-Leaves-CCE-update-suppression.patch index 7dd7788..f64d61d 100644 --- a/lophine-server/minecraft-patches/features/0034-Leaves-CCE-update-suppression.patch +++ b/lophine-server/minecraft-patches/features/0033-Leaves-CCE-update-suppression.patch @@ -8,11 +8,11 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/net/minecraft/world/level/block/ShulkerBoxBlock.java b/net/minecraft/world/level/block/ShulkerBoxBlock.java -index a26cd86aedcaf7ab606f8543e08360cbe9f2d1e6..27ccce4b4d8b4cb8be48bfe5d55366abe4ea3a38 100644 +index 46d6c6e3befc70a6878e12a4d75575e6d48d10ca..77840814806c7d07b58cd716cf7ec095e894498a 100644 --- a/net/minecraft/world/level/block/ShulkerBoxBlock.java +++ b/net/minecraft/world/level/block/ShulkerBoxBlock.java -@@ -185,7 +185,9 @@ public class ShulkerBoxBlock extends BaseEntityBlock { - protected int getAnalogOutputSignal(BlockState blockState, Level level, BlockPos pos) { +@@ -183,7 +183,9 @@ public class ShulkerBoxBlock extends BaseEntityBlock { + protected int getAnalogOutputSignal(BlockState state, Level level, BlockPos pos, Direction direction) { // Leaves start - update suppression crash fix try { - return AbstractContainerMenu.getRedstoneSignalFromBlockEntity(level.getBlockEntity(pos)); diff --git a/lophine-server/minecraft-patches/features/0035-Leaves-Redstone-ignore-upwards-update.patch b/lophine-server/minecraft-patches/features/0034-Leaves-Redstone-ignore-upwards-update.patch similarity index 89% rename from lophine-server/minecraft-patches/features/0035-Leaves-Redstone-ignore-upwards-update.patch rename to lophine-server/minecraft-patches/features/0034-Leaves-Redstone-ignore-upwards-update.patch index 0a64d10..02b1518 100644 --- a/lophine-server/minecraft-patches/features/0035-Leaves-Redstone-ignore-upwards-update.patch +++ b/lophine-server/minecraft-patches/features/0034-Leaves-Redstone-ignore-upwards-update.patch @@ -8,7 +8,7 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/net/minecraft/world/level/block/ComparatorBlock.java b/net/minecraft/world/level/block/ComparatorBlock.java -index afecf6bb6152b4d9dfee4cd8c5b1d798cbf723b3..a5bbe83b079276a3ab497e8a725713721db83aa1 100644 +index 578e7c8dc601f53cf2a068685c6901bfaf47e763..0686aa5425c00e10beb381f3c3ff3c554603cd49 100644 --- a/net/minecraft/world/level/block/ComparatorBlock.java +++ b/net/minecraft/world/level/block/ComparatorBlock.java @@ -58,6 +58,7 @@ public class ComparatorBlock extends DiodeBlock implements EntityBlock { @@ -20,10 +20,10 @@ index afecf6bb6152b4d9dfee4cd8c5b1d798cbf723b3..a5bbe83b079276a3ab497e8a72571372 ? Blocks.AIR.defaultBlockState() : super.updateShape(state, level, scheduledTickAccess, pos, direction, neighborPos, neighborState, random); diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index 4b37335e91a51b9a58ce0bce94b61ab5afbc6486..555a00e402da3d9126925135d030b7bccd8e5327 100644 +index ba253a9af6141d8ea99c064e3cc0c6486c221098..48f9e234e4025633cbc41d334d88ada36c2e0d7b 100644 --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -179,7 +179,7 @@ public class RedStoneWireBlock extends Block { +@@ -178,7 +178,7 @@ public class RedStoneWireBlock extends Block { RandomSource random ) { if (direction == Direction.DOWN) { @@ -32,7 +32,7 @@ index 4b37335e91a51b9a58ce0bce94b61ab5afbc6486..555a00e402da3d9126925135d030b7bc } else if (direction == Direction.UP) { return this.getConnectionState(level, state, pos); } else { -@@ -239,7 +239,7 @@ public class RedStoneWireBlock extends Block { +@@ -238,7 +238,7 @@ public class RedStoneWireBlock extends Block { BlockPos blockPos = pos.relative(direction); BlockState blockState = level.getBlockState(blockPos); if (nonNormalCubeAbove) { @@ -42,7 +42,7 @@ index 4b37335e91a51b9a58ce0bce94b61ab5afbc6486..555a00e402da3d9126925135d030b7bc if (blockState.isFaceSturdy(level, blockPos, direction.getOpposite())) { return RedstoneSide.UP; diff --git a/net/minecraft/world/level/block/RepeaterBlock.java b/net/minecraft/world/level/block/RepeaterBlock.java -index 1d45564253258eebdf10470dd7eefa644a4151ae..4b8a0f7353984d8997ab3b702227ae8d46863d7e 100644 +index 87e1a32376adc5a15f035b62bc1f672c507cd230..26c10c1fecb976f3ef0338aa78603d454d1b3fe8 100644 --- a/net/minecraft/world/level/block/RepeaterBlock.java +++ b/net/minecraft/world/level/block/RepeaterBlock.java @@ -68,6 +68,7 @@ public class RepeaterBlock extends DiodeBlock { diff --git a/lophine-server/minecraft-patches/features/0035-Instant-Block-Updater.patch b/lophine-server/minecraft-patches/features/0035-Instant-Block-Updater.patch new file mode 100644 index 0000000..031a0ba --- /dev/null +++ b/lophine-server/minecraft-patches/features/0035-Instant-Block-Updater.patch @@ -0,0 +1,52 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Helvetica Volubi +Date: Mon, 17 Nov 2025 18:41:08 +0800 +Subject: [PATCH] Instant Block Updater + + +diff --git a/io/papermc/paper/threadedregions/RegionizedWorldData.java b/io/papermc/paper/threadedregions/RegionizedWorldData.java +index 918bd1f48156940bc85bfb399adf593b9805bb08..3b39b8f7ccb278cf910e3cc4e00da29790465a81 100644 +--- a/io/papermc/paper/threadedregions/RegionizedWorldData.java ++++ b/io/papermc/paper/threadedregions/RegionizedWorldData.java +@@ -467,7 +467,7 @@ public final class RegionizedWorldData { + public long lastMidTickExecuteFailure; + // From Level + public boolean populating; +- public final CollectingNeighborUpdater neighborUpdater; ++ public final NeighborUpdater neighborUpdater; + public boolean captureBlockStates = false; + public boolean captureTreeGeneration = false; + public final Map capturedBlockStates = new java.util.LinkedHashMap<>(); // Paper +@@ -524,7 +524,7 @@ public final class RegionizedWorldData { + this.world = world; + this.blockLevelTicks = new LevelTicks<>(world::isPositionTickingWithEntitiesLoaded, world, true); + this.fluidLevelTicks = new LevelTicks<>(world::isPositionTickingWithEntitiesLoaded, world, false); +- this.neighborUpdater = new CollectingNeighborUpdater(world, world.neighbourUpdateMax); ++ this.neighborUpdater = fun.bm.lophine.config.modules.experiment.RedStoneConfig.instantBlockUpdater ? new net.minecraft.world.level.redstone.InstantNeighborUpdater(world) : new CollectingNeighborUpdater(world, world.neighbourUpdateMax); // Lophine - Instant Block Updater + this.nearbyPlayers = new NearbyPlayers(world); + this.wireHandler = new alternate.current.wire.WireHandler(world); + this.turbo = new io.papermc.paper.redstone.RedstoneWireTurbo((RedStoneWireBlock)Blocks.REDSTONE_WIRE); +diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java +index b878f5a8316dfee582180a6bbe7122a78581fae2..a906e7a34d048369f9357b0371339b4cccac5f25 100644 +--- a/net/minecraft/server/level/ServerLevel.java ++++ b/net/minecraft/server/level/ServerLevel.java +@@ -911,12 +911,16 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + // Paper - rewrite chunk system + profilerFiller.pop(); + profilerFiller.push("debugSynchronizers"); ++ // Lophine start - instant neighbor updates ++ if (regionizedWorldData.neighborUpdater instanceof net.minecraft.world.level.redstone.CollectingNeighborUpdater neighborUpdater) { + if (this.debugSynchronizers.hasAnySubscriberFor(DebugSubscriptions.NEIGHBOR_UPDATES)) { +- regionizedWorldData.neighborUpdater // Folia - region threading +- .setDebugListener(blockPos -> this.debugSynchronizers.broadcastEventToTracking(blockPos, DebugSubscriptions.NEIGHBOR_UPDATES, blockPos)); ++ neighborUpdater // Folia - region threading ++ .setDebugListener(blockPos -> this.debugSynchronizers.broadcastEventToTracking(blockPos, DebugSubscriptions.NEIGHBOR_UPDATES, blockPos)); + } else { +- regionizedWorldData.neighborUpdater.setDebugListener(null); // Folia - region threading ++ neighborUpdater.setDebugListener(null); // Folia - region threading + } ++ } ++ // Lophine end - instant neighbor updates + + this.debugSynchronizers.tick(this.server.debugSubscribers()); + profilerFiller.pop(); diff --git a/lophine-server/minecraft-patches/features/0036-Instant-Block-Updater.patch b/lophine-server/minecraft-patches/features/0036-Instant-Block-Updater.patch deleted file mode 100644 index 3c1ab36..0000000 --- a/lophine-server/minecraft-patches/features/0036-Instant-Block-Updater.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Helvetica Volubi -Date: Mon, 17 Nov 2025 18:41:08 +0800 -Subject: [PATCH] Instant Block Updater - - -diff --git a/io/papermc/paper/threadedregions/RegionizedWorldData.java b/io/papermc/paper/threadedregions/RegionizedWorldData.java -index d0de3b22f6cef6eb213b7ff688a514a67f84fbcf..3b39b8f7ccb278cf910e3cc4e00da29790465a81 100644 ---- a/io/papermc/paper/threadedregions/RegionizedWorldData.java -+++ b/io/papermc/paper/threadedregions/RegionizedWorldData.java -@@ -524,7 +524,7 @@ public final class RegionizedWorldData { - this.world = world; - this.blockLevelTicks = new LevelTicks<>(world::isPositionTickingWithEntitiesLoaded, world, true); - this.fluidLevelTicks = new LevelTicks<>(world::isPositionTickingWithEntitiesLoaded, world, false); -- this.neighborUpdater = new CollectingNeighborUpdater(world, world.neighbourUpdateMax); -+ this.neighborUpdater = fun.bm.lophine.config.modules.experiment.RedStoneConfig.instantBlockUpdater ? new net.minecraft.world.level.redstone.InstantNeighborUpdater(world) : new CollectingNeighborUpdater(world, world.neighbourUpdateMax); // Lophine - Instant Block Updater - this.nearbyPlayers = new NearbyPlayers(world); - this.wireHandler = new alternate.current.wire.WireHandler(world); - this.turbo = new io.papermc.paper.redstone.RedstoneWireTurbo((RedStoneWireBlock)Blocks.REDSTONE_WIRE); diff --git a/lophine-server/minecraft-patches/features/0037-Revert-TrapDoorBlock-changes-form-paperMC.patch b/lophine-server/minecraft-patches/features/0036-Revert-TrapDoorBlock-changes-form-Paper.patch similarity index 94% rename from lophine-server/minecraft-patches/features/0037-Revert-TrapDoorBlock-changes-form-paperMC.patch rename to lophine-server/minecraft-patches/features/0036-Revert-TrapDoorBlock-changes-form-Paper.patch index c08d776..a86521f 100644 --- a/lophine-server/minecraft-patches/features/0037-Revert-TrapDoorBlock-changes-form-paperMC.patch +++ b/lophine-server/minecraft-patches/features/0036-Revert-TrapDoorBlock-changes-form-Paper.patch @@ -1,15 +1,15 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Helvetica Volubi Date: Tue, 18 Nov 2025 00:24:32 +0800 -Subject: [PATCH] Revert TrapDoorBlock changes form paperMC +Subject: [PATCH] Revert TrapDoorBlock changes form Paper diff --git a/net/minecraft/world/level/block/TrapDoorBlock.java b/net/minecraft/world/level/block/TrapDoorBlock.java -index a2140d22dc58aa2df1afbeb5170d04fd65739d55..ea79c471c03b6908710d5943f2ff378eaba4099e 100644 +index b45ae50db32c4156b8f8008335673d20c570c72d..af78831441f362b0129aa864854ce5a64d544640 100644 --- a/net/minecraft/world/level/block/TrapDoorBlock.java +++ b/net/minecraft/world/level/block/TrapDoorBlock.java @@ -128,37 +128,7 @@ public class TrapDoorBlock extends HorizontalDirectionalBlock implements SimpleW - if (!level.isClientSide) { + if (!level.isClientSide()) { boolean hasNeighborSignal = level.hasNeighborSignal(pos); if (hasNeighborSignal != state.getValue(POWERED)) { - // CraftBukkit start diff --git a/lophine-server/minecraft-patches/features/0038-Leaves-Prevent-loss-of-item-drops-due-to-update-supp.patch b/lophine-server/minecraft-patches/features/0037-Leaves-Prevent-loss-of-item-drops-due-to-update-supp.patch similarity index 85% rename from lophine-server/minecraft-patches/features/0038-Leaves-Prevent-loss-of-item-drops-due-to-update-supp.patch rename to lophine-server/minecraft-patches/features/0037-Leaves-Prevent-loss-of-item-drops-due-to-update-supp.patch index f04104d..090da75 100644 --- a/lophine-server/minecraft-patches/features/0038-Leaves-Prevent-loss-of-item-drops-due-to-update-supp.patch +++ b/lophine-server/minecraft-patches/features/0037-Leaves-Prevent-loss-of-item-drops-due-to-update-supp.patch @@ -9,10 +9,10 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves/blob/ea91106ae57fc4cc1 Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java -index ee7bdc3adbeb04cf6ca630282f31a21e52bdb215..58f6c3e83c80b4b419ba22da81a7880be5b5d551 100644 +index 8d28b29348c255c901375af161210a2041de1985..86f7cfd5816917bd03aca0a796f1eaca938d65aa 100644 --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -369,7 +369,18 @@ public class ServerPlayerGameMode { +@@ -386,7 +386,18 @@ public class ServerPlayerGameMode { this.level.getCurrentWorldData().captureDrops = new java.util.ArrayList<>(); // Folia - region threading // CraftBukkit end BlockState blockState1 = block.playerWillDestroy(this.level, pos, blockState, this.player); @@ -29,10 +29,10 @@ index ee7bdc3adbeb04cf6ca630282f31a21e52bdb215..58f6c3e83c80b4b419ba22da81a7880b + flag = false; + } + // Leaves end - Prevent loss of item drops due to update suppression when breaking blocks - if (flag) { - block.destroy(this.level, pos, blockState1); + if (SharedConstants.DEBUG_BLOCK_BREAK) { + LOGGER.info("server broke {} {} -> {}", pos, blockState1, this.level.getBlockState(pos)); } -@@ -397,6 +408,7 @@ public class ServerPlayerGameMode { +@@ -418,6 +429,7 @@ public class ServerPlayerGameMode { if (event.isDropItems()) { org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockDropItemEvent(bblock, state, this.player, itemsToDrop); // Paper - capture all item additions to the world } diff --git a/lophine-server/minecraft-patches/features/0039-Leaves-Old-Block-remove-behaviour.patch b/lophine-server/minecraft-patches/features/0038-Leaves-Old-Block-remove-behaviour.patch similarity index 87% rename from lophine-server/minecraft-patches/features/0039-Leaves-Old-Block-remove-behaviour.patch rename to lophine-server/minecraft-patches/features/0038-Leaves-Old-Block-remove-behaviour.patch index 9ebf71c..5f2e63d 100644 --- a/lophine-server/minecraft-patches/features/0039-Leaves-Old-Block-remove-behaviour.patch +++ b/lophine-server/minecraft-patches/features/0038-Leaves-Old-Block-remove-behaviour.patch @@ -28,7 +28,7 @@ index da10ca5ef12be1a834adda9243c082dadde24ec0..f682930f765d04f0a278b0648c2773ab + // Leaves end - behaviour 1.21.1- } diff --git a/net/minecraft/world/level/block/AbstractFurnaceBlock.java b/net/minecraft/world/level/block/AbstractFurnaceBlock.java -index d52eeff0d564a24bddb873750c81e3fe999f16f0..aa2597d825f93b0b0623ab7fae29e45de3f3ebcc 100644 +index dcc1bb4fcee9646212a424c03f77370ffa577fee..ca5cf7526082b9d3a7887dd77313e2c0012efebb 100644 --- a/net/minecraft/world/level/block/AbstractFurnaceBlock.java +++ b/net/minecraft/world/level/block/AbstractFurnaceBlock.java @@ -51,6 +51,26 @@ public abstract class AbstractFurnaceBlock extends BaseEntityBlock { @@ -59,7 +59,7 @@ index d52eeff0d564a24bddb873750c81e3fe999f16f0..aa2597d825f93b0b0623ab7fae29e45d protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { Containers.updateNeighboursAfterDestroy(state, level, pos); diff --git a/net/minecraft/world/level/block/BarrelBlock.java b/net/minecraft/world/level/block/BarrelBlock.java -index f7820265f10b78674acd13e6204b9212fd27b038..700bd0f6a4f4fd6cd85b3e666fff1b3fd0a96b8e 100644 +index 8139799a24274cfb70a99d301c2688c0360720c6..b224d3756120cd82d1381c55a95ad63c18c123b7 100644 --- a/net/minecraft/world/level/block/BarrelBlock.java +++ b/net/minecraft/world/level/block/BarrelBlock.java @@ -49,6 +49,14 @@ public class BarrelBlock extends BaseEntityBlock { @@ -78,7 +78,7 @@ index f7820265f10b78674acd13e6204b9212fd27b038..700bd0f6a4f4fd6cd85b3e666fff1b3f protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { Containers.updateNeighboursAfterDestroy(state, level, pos); diff --git a/net/minecraft/world/level/block/BasePressurePlateBlock.java b/net/minecraft/world/level/block/BasePressurePlateBlock.java -index 42ee3f32fe44c1f0680c994a69201f7bd7792673..19214c236bca4e454e3bbe7dc50e00b66398c119 100644 +index 7135a6bc87f90fafa94d0783aaf7b42d66449010..afd06de092a75c6c4f7b8848055e314b0c241029 100644 --- a/net/minecraft/world/level/block/BasePressurePlateBlock.java +++ b/net/minecraft/world/level/block/BasePressurePlateBlock.java @@ -125,6 +125,19 @@ public abstract class BasePressurePlateBlock extends Block { @@ -102,7 +102,7 @@ index 42ee3f32fe44c1f0680c994a69201f7bd7792673..19214c236bca4e454e3bbe7dc50e00b6 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { if (!movedByPiston && this.getSignalForState(state) > 0) { diff --git a/net/minecraft/world/level/block/BaseRailBlock.java b/net/minecraft/world/level/block/BaseRailBlock.java -index 5f99e18244501ed2d85be77b71f48cc93058cdb7..6bf50d9c3921b15f40b4fba273abeb4c2e0f30b3 100644 +index 504f38ce16f6a5d2b748a5c71c69f5be5886ceb5..db0b38db5675cb248e31e7a5988c35496561ad6f 100644 --- a/net/minecraft/world/level/block/BaseRailBlock.java +++ b/net/minecraft/world/level/block/BaseRailBlock.java @@ -121,6 +121,23 @@ public abstract class BaseRailBlock extends Block implements SimpleWaterloggedBl @@ -130,7 +130,7 @@ index 5f99e18244501ed2d85be77b71f48cc93058cdb7..6bf50d9c3921b15f40b4fba273abeb4c protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { if (!movedByPiston) { diff --git a/net/minecraft/world/level/block/BrewingStandBlock.java b/net/minecraft/world/level/block/BrewingStandBlock.java -index f563f8ea63e67f808802baa4c6a700e803c045a0..0cc4479d9d3f6aea280c9f88997d141dc24917a9 100644 +index bd6dc109fd9c37666f23ccd17c0eab8aff95e777..e25103c62a41e3fb0a8f7e84496cacc73ed71a74 100644 --- a/net/minecraft/world/level/block/BrewingStandBlock.java +++ b/net/minecraft/world/level/block/BrewingStandBlock.java @@ -78,6 +78,14 @@ public class BrewingStandBlock extends BaseEntityBlock { @@ -149,7 +149,7 @@ index f563f8ea63e67f808802baa4c6a700e803c045a0..0cc4479d9d3f6aea280c9f88997d141d protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { Containers.updateNeighboursAfterDestroy(state, level, pos); diff --git a/net/minecraft/world/level/block/ButtonBlock.java b/net/minecraft/world/level/block/ButtonBlock.java -index 66c589bc633d32ebf36b1ab55ba6250ca2ddd6f6..f96d3c7b7ec15973aca3aabe056608fd5efb856b 100644 +index 27ca29f1d3e0e68229edef3b32634ce9b054824a..ea2c5d79fc41f58b263ec34b53df436e0043ef53 100644 --- a/net/minecraft/world/level/block/ButtonBlock.java +++ b/net/minecraft/world/level/block/ButtonBlock.java @@ -132,6 +132,19 @@ public class ButtonBlock extends FaceAttachedHorizontalDirectionalBlock { @@ -173,7 +173,7 @@ index 66c589bc633d32ebf36b1ab55ba6250ca2ddd6f6..f96d3c7b7ec15973aca3aabe056608fd protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { if (!movedByPiston && state.getValue(POWERED)) { diff --git a/net/minecraft/world/level/block/CampfireBlock.java b/net/minecraft/world/level/block/CampfireBlock.java -index 028e2ad8bcb23b3f9f80a5ec551204bb2d7db1ae..c9e2becc0644de707e0bd251318813c50fc82be2 100644 +index b9e11a361e91cf3d5c929330fc0ba59cfe903198..4985fcfef75abbe2be9cd5e6111de4d60237bafa 100644 --- a/net/minecraft/world/level/block/CampfireBlock.java +++ b/net/minecraft/world/level/block/CampfireBlock.java @@ -105,6 +105,20 @@ public class CampfireBlock extends BaseEntityBlock implements SimpleWaterloggedB @@ -195,14 +195,14 @@ index 028e2ad8bcb23b3f9f80a5ec551204bb2d7db1ae..c9e2becc0644de707e0bd251318813c5 + // Leaves end - behaviour 1.21.1- + @Override - protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier) { + protected void entityInside(BlockState state, Level level, BlockPos pos, Entity entity, InsideBlockEffectApplier effectApplier, boolean pastEdges) { if (!new io.papermc.paper.event.entity.EntityInsideBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(level, pos)).callEvent()) { return; } // Paper - Add EntityInsideBlockEvent diff --git a/net/minecraft/world/level/block/ChestBlock.java b/net/minecraft/world/level/block/ChestBlock.java -index c4937d1b482e2ec60961bda62ad6cc155f0ce8f7..818b1a5df0e9a0566210e4b3512ad856515e385f 100644 +index fa2dce759419f62825000718361f47c6f208cdb2..64c0616c294bd7c7b62ae376d50369500b948390 100644 --- a/net/minecraft/world/level/block/ChestBlock.java +++ b/net/minecraft/world/level/block/ChestBlock.java -@@ -244,6 +244,14 @@ public class ChestBlock extends AbstractChestBlock implements - return blockState.is(this) && blockState.getValue(TYPE) == ChestType.SINGLE ? blockState.getValue(FACING) : null; +@@ -280,6 +280,14 @@ public class ChestBlock extends AbstractChestBlock implements + return this.chestCanConnectTo(blockState) && blockState.getValue(TYPE) == ChestType.SINGLE ? blockState.getValue(FACING) : null; } + // Leaves start - behaviour 1.21.1- @@ -217,10 +217,10 @@ index c4937d1b482e2ec60961bda62ad6cc155f0ce8f7..818b1a5df0e9a0566210e4b3512ad856 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { Containers.updateNeighboursAfterDestroy(state, level, pos); diff --git a/net/minecraft/world/level/block/ChiseledBookShelfBlock.java b/net/minecraft/world/level/block/ChiseledBookShelfBlock.java -index eb315a50a83dc7230d7ad66f4daeb0d632679941..7bccf15310f6851875bfd77d4c66f4ce863b65e1 100644 +index cea0f015290137a5284f4a3021c954272b3db543..53d983505b4c92824083ecd123901874d04704c5 100644 --- a/net/minecraft/world/level/block/ChiseledBookShelfBlock.java +++ b/net/minecraft/world/level/block/ChiseledBookShelfBlock.java -@@ -180,6 +180,27 @@ public class ChiseledBookShelfBlock extends BaseEntityBlock { +@@ -149,6 +149,27 @@ public class ChiseledBookShelfBlock extends BaseEntityBlock implements Selectabl SLOT_OCCUPIED_PROPERTIES.forEach(property -> builder.add(property)); } @@ -249,10 +249,10 @@ index eb315a50a83dc7230d7ad66f4daeb0d632679941..7bccf15310f6851875bfd77d4c66f4ce protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { Containers.updateNeighboursAfterDestroy(state, level, pos); diff --git a/net/minecraft/world/level/block/CrafterBlock.java b/net/minecraft/world/level/block/CrafterBlock.java -index caf31218a1aff84367da126ee1dc46b8c8a1e5d1..59272e7223aff61d44c86776091ca74891839a45 100644 +index 3faa541c4a4623e915269d6241e1a3a3c6e374ff..18c660893a33ecf70c3d225525505852e4449182 100644 --- a/net/minecraft/world/level/block/CrafterBlock.java +++ b/net/minecraft/world/level/block/CrafterBlock.java -@@ -129,6 +129,14 @@ public class CrafterBlock extends BaseEntityBlock { +@@ -128,6 +128,14 @@ public class CrafterBlock extends BaseEntityBlock { } } @@ -268,7 +268,7 @@ index caf31218a1aff84367da126ee1dc46b8c8a1e5d1..59272e7223aff61d44c86776091ca748 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { Containers.updateNeighboursAfterDestroy(state, level, pos); diff --git a/net/minecraft/world/level/block/CreakingHeartBlock.java b/net/minecraft/world/level/block/CreakingHeartBlock.java -index 73885449a3316face50292756de2a3f298d3d111..333e18e4ead0bb6ef9681ce27ec156f79821af7c 100644 +index dfb9a10622ba2a0c2759bb563fefd729f1109865..c735e7de1b88de531dd00a2cc2dd4a1394b808e6 100644 --- a/net/minecraft/world/level/block/CreakingHeartBlock.java +++ b/net/minecraft/world/level/block/CreakingHeartBlock.java @@ -152,6 +152,16 @@ public class CreakingHeartBlock extends BaseEntityBlock { @@ -289,10 +289,10 @@ index 73885449a3316face50292756de2a3f298d3d111..333e18e4ead0bb6ef9681ce27ec156f7 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { Containers.updateNeighboursAfterDestroy(state, level, pos); diff --git a/net/minecraft/world/level/block/DecoratedPotBlock.java b/net/minecraft/world/level/block/DecoratedPotBlock.java -index f1570f1f4f7e43aacbcffef8bcf8ef27d46899da..6afd1c618112234ce4940105582a4399e20ab34c 100644 +index dd20e3c57352859ab931692445c83669da94f629..e8c216831b66cd0f4e989797030119388a3378a5 100644 --- a/net/minecraft/world/level/block/DecoratedPotBlock.java +++ b/net/minecraft/world/level/block/DecoratedPotBlock.java -@@ -165,6 +165,14 @@ public class DecoratedPotBlock extends BaseEntityBlock implements SimpleWaterlog +@@ -164,6 +164,14 @@ public class DecoratedPotBlock extends BaseEntityBlock implements SimpleWaterlog return new DecoratedPotBlockEntity(pos, state); } @@ -308,7 +308,7 @@ index f1570f1f4f7e43aacbcffef8bcf8ef27d46899da..6afd1c618112234ce4940105582a4399 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { Containers.updateNeighboursAfterDestroy(state, level, pos); diff --git a/net/minecraft/world/level/block/DiodeBlock.java b/net/minecraft/world/level/block/DiodeBlock.java -index 0ab376b4207b695e92c324b8a5f9818d3f4accde..bcceb8f17294fb9f275ab6b3a28c75cb423394f2 100644 +index b34e051b4a672d44872a74e810f978373e73af05..4525d718016fe125e3cdb1c1798fe9483213ba49 100644 --- a/net/minecraft/world/level/block/DiodeBlock.java +++ b/net/minecraft/world/level/block/DiodeBlock.java @@ -176,6 +176,16 @@ public abstract class DiodeBlock extends HorizontalDirectionalBlock { @@ -329,7 +329,7 @@ index 0ab376b4207b695e92c324b8a5f9818d3f4accde..bcceb8f17294fb9f275ab6b3a28c75cb protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { if (!movedByPiston) { diff --git a/net/minecraft/world/level/block/DispenserBlock.java b/net/minecraft/world/level/block/DispenserBlock.java -index 7ff6255fcd50344cd6ac7f8a67d61fd59c85e413..7a23d27ce76ae6b90d01c4dc7af416bb6b6516ea 100644 +index 2ef2861041f3aaf85ea64458c43c5d83fdab9bfc..0828d663647f7c3267a4a9392a3b0b8e6e54928c 100644 --- a/net/minecraft/world/level/block/DispenserBlock.java +++ b/net/minecraft/world/level/block/DispenserBlock.java @@ -147,6 +147,14 @@ public class DispenserBlock extends BaseEntityBlock { @@ -348,10 +348,10 @@ index 7ff6255fcd50344cd6ac7f8a67d61fd59c85e413..7a23d27ce76ae6b90d01c4dc7af416bb protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { Containers.updateNeighboursAfterDestroy(state, level, pos); diff --git a/net/minecraft/world/level/block/HopperBlock.java b/net/minecraft/world/level/block/HopperBlock.java -index 912d1ba98809b4469e1468e4855bb1bc91bb4540..0f2b344b385b7726c3c23b68da8a2329180fe034 100644 +index 3c349b4216d934068c26017820884593662f471e..4c5a12784e97e599891d40d5ce784b4f8c1e5b15 100644 --- a/net/minecraft/world/level/block/HopperBlock.java +++ b/net/minecraft/world/level/block/HopperBlock.java -@@ -137,6 +137,14 @@ public class HopperBlock extends BaseEntityBlock implements org.leavesmc.leaves. +@@ -133,6 +133,14 @@ public class HopperBlock extends BaseEntityBlock implements org.leavesmc.leaves. } } @@ -367,7 +367,7 @@ index 912d1ba98809b4469e1468e4855bb1bc91bb4540..0f2b344b385b7726c3c23b68da8a2329 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { Containers.updateNeighboursAfterDestroy(state, level, pos); diff --git a/net/minecraft/world/level/block/JukeboxBlock.java b/net/minecraft/world/level/block/JukeboxBlock.java -index 56cf6528f0cd9b8528490d7cee9a1f0e54108ef9..955854e5b3a18b8f1441145554a97c5454a65d12 100644 +index a4b824dab307705559a76b954a3e47d30dd65889..bc036d8e9d241ea9178808fce39c4e5115d5f753 100644 --- a/net/minecraft/world/level/block/JukeboxBlock.java +++ b/net/minecraft/world/level/block/JukeboxBlock.java @@ -73,6 +73,19 @@ public class JukeboxBlock extends BaseEntityBlock { @@ -391,10 +391,10 @@ index 56cf6528f0cd9b8528490d7cee9a1f0e54108ef9..955854e5b3a18b8f1441145554a97c54 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { Containers.updateNeighboursAfterDestroy(state, level, pos); diff --git a/net/minecraft/world/level/block/LecternBlock.java b/net/minecraft/world/level/block/LecternBlock.java -index 5a9b601b7bf7e80b04ebd8f5c8b7d121031132c7..b714d3c7649384a8fdbe0a713e2193e241c80618 100644 +index 52b9bd310c731c407fc4264559084debec81d3d9..0b991825d48ad64c1c68fd7c6bded7583572dded 100644 --- a/net/minecraft/world/level/block/LecternBlock.java +++ b/net/minecraft/world/level/block/LecternBlock.java -@@ -197,6 +197,36 @@ public class LecternBlock extends BaseEntityBlock { +@@ -198,6 +198,36 @@ public class LecternBlock extends BaseEntityBlock { changePowered(level, pos, state, false); } @@ -432,10 +432,10 @@ index 5a9b601b7bf7e80b04ebd8f5c8b7d121031132c7..b714d3c7649384a8fdbe0a713e2193e2 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { if (state.getValue(POWERED)) { diff --git a/net/minecraft/world/level/block/LeverBlock.java b/net/minecraft/world/level/block/LeverBlock.java -index 76f2a29f37187344324d68941307d58e6343b6ae..3645ca9589aa1a74134180c9918a6f67bc64ce7a 100644 +index 5f03e9fed3d4a8c3b72ca05be0b62ef45ac291f7..359fe5d611bcebe4cb98b9d8cea26b255adb167e 100644 --- a/net/minecraft/world/level/block/LeverBlock.java +++ b/net/minecraft/world/level/block/LeverBlock.java -@@ -125,6 +125,19 @@ public class LeverBlock extends FaceAttachedHorizontalDirectionalBlock { +@@ -124,6 +124,19 @@ public class LeverBlock extends FaceAttachedHorizontalDirectionalBlock { } } @@ -456,7 +456,7 @@ index 76f2a29f37187344324d68941307d58e6343b6ae..3645ca9589aa1a74134180c9918a6f67 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { if (!movedByPiston && state.getValue(POWERED)) { diff --git a/net/minecraft/world/level/block/LightningRodBlock.java b/net/minecraft/world/level/block/LightningRodBlock.java -index d702d234111c2a34585f3532b5bb4bdb1501b82a..d9bedb99590a860a7ebb1d68861dc175ca3f4a2b 100644 +index dbfe086123c4b3cdc866111e1b6ec37d8d38d394..adad6e538b128729b72b7d44cabbd0cfba7417f9 100644 --- a/net/minecraft/world/level/block/LightningRodBlock.java +++ b/net/minecraft/world/level/block/LightningRodBlock.java @@ -120,6 +120,18 @@ public class LightningRodBlock extends RodBlock implements SimpleWaterloggedBloc @@ -479,7 +479,7 @@ index d702d234111c2a34585f3532b5bb4bdb1501b82a..d9bedb99590a860a7ebb1d68861dc175 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { if (state.getValue(POWERED)) { diff --git a/net/minecraft/world/level/block/ObserverBlock.java b/net/minecraft/world/level/block/ObserverBlock.java -index bd2aa00ce8b78c16f6107064dd00bfbb072df0df..6db3a21bcc37ae79f82b19ee0a851f539d4a654d 100644 +index 3c12d8e23f20b666b0005e597ba2e803c02d5d78..17c371f4c24e8a81705bdd322b1de5de4b8be8b7 100644 --- a/net/minecraft/world/level/block/ObserverBlock.java +++ b/net/minecraft/world/level/block/ObserverBlock.java @@ -127,6 +127,17 @@ public class ObserverBlock extends DirectionalBlock { @@ -501,10 +501,10 @@ index bd2aa00ce8b78c16f6107064dd00bfbb072df0df..6db3a21bcc37ae79f82b19ee0a851f53 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { if (state.getValue(POWERED) && level.getBlockTicks().hasScheduledTick(pos, this)) { diff --git a/net/minecraft/world/level/block/RedStoneWireBlock.java b/net/minecraft/world/level/block/RedStoneWireBlock.java -index 555a00e402da3d9126925135d030b7bccd8e5327..20cec51bcead34f95ed6195a7762cea7ce280914 100644 +index 48f9e234e4025633cbc41d334d88ada36c2e0d7b..5c154d15e5aa45988436722595c7fca74e166c9a 100644 --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -369,6 +369,27 @@ public class RedStoneWireBlock extends Block { +@@ -368,6 +368,27 @@ public class RedStoneWireBlock extends Block { } } @@ -533,7 +533,7 @@ index 555a00e402da3d9126925135d030b7bccd8e5327..20cec51bcead34f95ed6195a7762cea7 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { if (!movedByPiston) { diff --git a/net/minecraft/world/level/block/RedstoneTorchBlock.java b/net/minecraft/world/level/block/RedstoneTorchBlock.java -index df4f1b18deb8bb4a04e740bbbeb6a89cb1ff8e71..7f165a4e2935cf4638b14379a0d1aca1b65ef84a 100644 +index d1dbfc821f068f14bf975842f66251816ea5c985..fe13504a7d2d685e43183dd7b3219f1605570adb 100644 --- a/net/minecraft/world/level/block/RedstoneTorchBlock.java +++ b/net/minecraft/world/level/block/RedstoneTorchBlock.java @@ -53,6 +53,15 @@ public class RedstoneTorchBlock extends BaseTorchBlock { @@ -553,10 +553,10 @@ index df4f1b18deb8bb4a04e740bbbeb6a89cb1ff8e71..7f165a4e2935cf4638b14379a0d1aca1 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { if (!movedByPiston) { diff --git a/net/minecraft/world/level/block/SculkSensorBlock.java b/net/minecraft/world/level/block/SculkSensorBlock.java -index f0101e88140f480c1a94f899744991f78c9e3756..fa9cb4c40a41eea7fd63a4513d0b0f39067de9ba 100644 +index 5ef593a61c74af7077d02f4b18d936bf9b2507b9..a94d69927b78089b2e9eb0ee74f693821c3d93fc 100644 --- a/net/minecraft/world/level/block/SculkSensorBlock.java +++ b/net/minecraft/world/level/block/SculkSensorBlock.java -@@ -129,6 +129,18 @@ public class SculkSensorBlock extends BaseEntityBlock implements SimpleWaterlogg +@@ -128,6 +128,18 @@ public class SculkSensorBlock extends BaseEntityBlock implements SimpleWaterlogg } } @@ -576,7 +576,7 @@ index f0101e88140f480c1a94f899744991f78c9e3756..fa9cb4c40a41eea7fd63a4513d0b0f39 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { if (getPhase(state) == SculkSensorPhase.ACTIVE) { diff --git a/net/minecraft/world/level/block/SculkShriekerBlock.java b/net/minecraft/world/level/block/SculkShriekerBlock.java -index 757f8453e147875ab9f14d9726bb734ef27447c9..d0558d0e33f3d6e25af2dd71650d723e8997dae6 100644 +index 2815fb48530de3a2f9ef0f472a0fd0a2c32140b6..6b5e5bbbeb11bd8ce100ef3c215dfcf4b387e595 100644 --- a/net/minecraft/world/level/block/SculkShriekerBlock.java +++ b/net/minecraft/world/level/block/SculkShriekerBlock.java @@ -68,6 +68,16 @@ public class SculkShriekerBlock extends BaseEntityBlock implements SimpleWaterlo @@ -597,10 +597,10 @@ index 757f8453e147875ab9f14d9726bb734ef27447c9..d0558d0e33f3d6e25af2dd71650d723e protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (state.getValue(SHRIEKING)) { diff --git a/net/minecraft/world/level/block/ShulkerBoxBlock.java b/net/minecraft/world/level/block/ShulkerBoxBlock.java -index 27ccce4b4d8b4cb8be48bfe5d55366abe4ea3a38..2e6d462fb27ad1e538164934417ce07cc0e603c2 100644 +index 77840814806c7d07b58cd716cf7ec095e894498a..e820cd03e695649a8f83e23ae822524a8f78e23b 100644 --- a/net/minecraft/world/level/block/ShulkerBoxBlock.java +++ b/net/minecraft/world/level/block/ShulkerBoxBlock.java -@@ -152,6 +152,19 @@ public class ShulkerBoxBlock extends BaseEntityBlock { +@@ -150,6 +150,19 @@ public class ShulkerBoxBlock extends BaseEntityBlock { // Paper end - re-set loot table if it was cleared } @@ -621,7 +621,7 @@ index 27ccce4b4d8b4cb8be48bfe5d55366abe4ea3a38..2e6d462fb27ad1e538164934417ce07c protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { Containers.updateNeighboursAfterDestroy(state, level, pos); diff --git a/net/minecraft/world/level/block/TripWireBlock.java b/net/minecraft/world/level/block/TripWireBlock.java -index c8f793d1cdeef7e3e0d5fceb45a4507d542e4b33..27f382f6c663b2954a6fb966ece05ba021fcd6b1 100644 +index 9d005c3db8f0c784cdd7217e7b110daa703a9cf3..190d7cd818f768bd44fc1b4e62af2c9b3aacbe4d 100644 --- a/net/minecraft/world/level/block/TripWireBlock.java +++ b/net/minecraft/world/level/block/TripWireBlock.java @@ -108,6 +108,16 @@ public class TripWireBlock extends Block { @@ -642,10 +642,10 @@ index c8f793d1cdeef7e3e0d5fceb45a4507d542e4b33..27f382f6c663b2954a6fb966ece05ba0 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { if (io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates) return; // Paper - prevent adjacent tripwires from updating diff --git a/net/minecraft/world/level/block/TripWireHookBlock.java b/net/minecraft/world/level/block/TripWireHookBlock.java -index 3f412b08e7d40d577efb7be291dd14826ba21f0e..30c65a0906646fc12cd842336ec4f3e2aaf31717 100644 +index 42a5e9a7f5d604e4821a116ba13319df052faf97..e90e142cfb15335522a48ad82aa90018ed8ec349 100644 --- a/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/net/minecraft/world/level/block/TripWireHookBlock.java -@@ -245,6 +245,25 @@ public class TripWireHookBlock extends Block { +@@ -244,6 +244,25 @@ public class TripWireHookBlock extends Block { level.updateNeighborsAt(pos.relative(opposite), block, orientation); } @@ -672,10 +672,10 @@ index 3f412b08e7d40d577efb7be291dd14826ba21f0e..30c65a0906646fc12cd842336ec4f3e2 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { if (!movedByPiston) { diff --git a/net/minecraft/world/level/block/entity/BlockEntityType.java b/net/minecraft/world/level/block/entity/BlockEntityType.java -index 7b8631abf8adcdb889d412b30eca10faf044032a..13134dfe9f548b87fd6be4683bf3386c522aba6a 100644 +index 6a9d23d25a79c73d5792011faf0e5a1c4c25bc64..84e0d3cd3c349f0d588a4b4c2d6844480a92b4ca 100644 --- a/net/minecraft/world/level/block/entity/BlockEntityType.java +++ b/net/minecraft/world/level/block/entity/BlockEntityType.java -@@ -267,7 +267,7 @@ public class BlockEntityType { +@@ -306,7 +306,7 @@ public class BlockEntityType { } public boolean isValid(BlockState state) { @@ -685,10 +685,10 @@ index 7b8631abf8adcdb889d412b30eca10faf044032a..13134dfe9f548b87fd6be4683bf3386c @Deprecated diff --git a/net/minecraft/world/level/block/piston/MovingPistonBlock.java b/net/minecraft/world/level/block/piston/MovingPistonBlock.java -index 05bbc2e59384702439548a988e128a85f1adbe82..af516d5b6bd31de2c6a388ec8001126e2a351cf3 100644 +index 58b78e6b9a43605940420d8cb0f1163ee3f0a5ff..eebf03ece11052f07702951b9335bc151e160848 100644 --- a/net/minecraft/world/level/block/piston/MovingPistonBlock.java +++ b/net/minecraft/world/level/block/piston/MovingPistonBlock.java -@@ -67,6 +67,18 @@ public class MovingPistonBlock extends BaseEntityBlock { +@@ -65,6 +65,18 @@ public class MovingPistonBlock extends BaseEntityBlock { return createTickerHelper(blockEntityType, BlockEntityType.PISTON, PistonMovingBlockEntity::tick); } @@ -708,7 +708,7 @@ index 05bbc2e59384702439548a988e128a85f1adbe82..af516d5b6bd31de2c6a388ec8001126e public void destroy(LevelAccessor level, BlockPos pos, BlockState state) { BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); diff --git a/net/minecraft/world/level/block/piston/PistonHeadBlock.java b/net/minecraft/world/level/block/piston/PistonHeadBlock.java -index 6c789e56f21f01252c21786cfeb48d88485b5636..e24a61a4e2dac0159d52f07c93ddf860f4bfb8f7 100644 +index b369e80a4fc371a3762e34e7d4d180b86d1d190f..0b412e360b090dc85d1726eb8f51c69b47061276 100644 --- a/net/minecraft/world/level/block/piston/PistonHeadBlock.java +++ b/net/minecraft/world/level/block/piston/PistonHeadBlock.java @@ -78,6 +78,19 @@ public class PistonHeadBlock extends DirectionalBlock { @@ -732,10 +732,10 @@ index 6c789e56f21f01252c21786cfeb48d88485b5636..e24a61a4e2dac0159d52f07c93ddf860 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { BlockPos blockPos = pos.relative(state.getValue(FACING).getOpposite()); diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java -index e9749b66239d7562ecf22002bfbaa95df197050f..6e3841ed012eee16dcaa61f70edfc1d870374a56 100644 +index 10f9f617123e7ef582707038230f43350d5c5810..d96385dc19b7d6409d65ae37549b6d8f3f955cd2 100644 --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -172,6 +172,15 @@ public abstract class BlockBehaviour implements FeatureElement, org.leavesmc.lea +@@ -171,6 +171,15 @@ public abstract class BlockBehaviour implements FeatureElement, org.leavesmc.lea org.spigotmc.AsyncCatcher.catchOp("block onPlace"); // Spigot } @@ -751,7 +751,7 @@ index e9749b66239d7562ecf22002bfbaa95df197050f..6e3841ed012eee16dcaa61f70edfc1d8 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { } -@@ -868,6 +877,12 @@ public abstract class BlockBehaviour implements FeatureElement, org.leavesmc.lea +@@ -866,6 +875,12 @@ public abstract class BlockBehaviour implements FeatureElement, org.leavesmc.lea // CraftBukkit end } @@ -765,22 +765,22 @@ index e9749b66239d7562ecf22002bfbaa95df197050f..6e3841ed012eee16dcaa61f70edfc1d8 this.getBlock().affectNeighborsAfterRemoval(this.asState(), level, pos, movedByPiston); } diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index 39c075173b77b5197af5d4ad3fe235ea0d2df756..b8a2ac505d121b46c33db2fbf4d02c5bc60c6c0f 100644 +index 7c354894f48a5540eb2554d8b1428306e8929066..de82e9a7f0cc190f8cf8c66eee9dc178241f6a27 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -401,20 +401,26 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -406,22 +406,28 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot boolean flag = !blockState.is(block); - boolean flag1 = (flags & 64) != 0; - boolean flag2 = (flags & 256) == 0; -- if (flag && blockState.hasBlockEntity()) { -- if (!this.level.isClientSide && flag2) { + boolean flag1 = (flags & Block.UPDATE_MOVE_BY_PISTON) != 0; + boolean flag2 = (flags & Block.UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS) == 0; +- if (flag && blockState.hasBlockEntity() && !state.shouldChangedStateKeepBlockEntity(blockState)) { +- if (!this.level.isClientSide() && flag2) { - BlockEntity blockEntity = this.level.getBlockEntity(pos); - if (blockEntity != null) { - blockEntity.preRemoveSideEffects(pos, blockState); + // Leaves start - behaviour 1.21.1- + if (!fun.bm.lophine.config.modules.experiment.RedStoneConfig.oldBlockRemoveBehaviour) { -+ if (flag && blockState.hasBlockEntity()) { -+ if (!this.level.isClientSide && flag2) { ++ if (flag && blockState.hasBlockEntity() && !state.shouldChangedStateKeepBlockEntity(blockState)) { ++ if (!this.level.isClientSide() && flag2) { + BlockEntity blockEntity = this.level.getBlockEntity(pos); + if (blockEntity != null) { + blockEntity.preRemoveSideEffects(pos, blockState); @@ -790,12 +790,16 @@ index 39c075173b77b5197af5d4ad3fe235ea0d2df756..b8a2ac505d121b46c33db2fbf4d02c5b - this.removeBlockEntity(pos); - } -+ this.removeBlockEntity(pos); -+ } ++ this.removeBlockEntity(pos); ++ } -- if ((flag || block instanceof BaseRailBlock) && this.level instanceof ServerLevel serverLevel && ((flags & 1) != 0 || flag1)) { +- if ((flag || block instanceof BaseRailBlock) +- && this.level instanceof ServerLevel serverLevel +- && ((flags & Block.UPDATE_NEIGHBORS) != 0 || flag1)) { - blockState.affectNeighborsAfterRemoval(serverLevel, pos, flag1); -+ if ((flag || block instanceof BaseRailBlock) && this.level instanceof ServerLevel serverLevel && ((flags & 1) != 0 || flag1)) { ++ if ((flag || block instanceof BaseRailBlock) ++ && this.level instanceof ServerLevel serverLevel ++ && ((flags & Block.UPDATE_NEIGHBORS) != 0 || flag1)) { + blockState.affectNeighborsAfterRemoval(serverLevel, pos, flag1); + } + } else { diff --git a/lophine-server/minecraft-patches/features/0040-Leaves-Do-not-reset-placed-block-on-exception-Do-not.patch b/lophine-server/minecraft-patches/features/0039-Leaves-Do-not-reset-placed-block-on-exception-Do-not.patch similarity index 94% rename from lophine-server/minecraft-patches/features/0040-Leaves-Do-not-reset-placed-block-on-exception-Do-not.patch rename to lophine-server/minecraft-patches/features/0039-Leaves-Do-not-reset-placed-block-on-exception-Do-not.patch index c55a077..c731e62 100644 --- a/lophine-server/minecraft-patches/features/0040-Leaves-Do-not-reset-placed-block-on-exception-Do-not.patch +++ b/lophine-server/minecraft-patches/features/0039-Leaves-Do-not-reset-placed-block-on-exception-Do-not.patch @@ -9,7 +9,7 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java -index 8f112f382190d606a87f38da8bcdf8dd5f31d1c5..f27915e43df8e627000cda1cb213a95300c98038 100644 +index a5d3caab2072b2c9bf8fdcbdb7c52c2dee16cfaf..4bb36d2965785fadf628a9bfac4fa2aa305aaf65 100644 --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java @@ -77,20 +77,22 @@ public class BlockItem extends Item { @@ -46,10 +46,10 @@ index 8f112f382190d606a87f38da8bcdf8dd5f31d1c5..f27915e43df8e627000cda1cb213a953 // CraftBukkit start if (bukkitState != null) { diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index b8a2ac505d121b46c33db2fbf4d02c5bc60c6c0f..7a8ceb00eb5845a1d5011a518f63a9cabf131f3c 100644 +index de82e9a7f0cc190f8cf8c66eee9dc178241f6a27..f5b128a993fab7af71a098b2128537ac749edc2f 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -971,12 +971,14 @@ public class LevelChunk extends ChunkAccess implements ca.spottedleaf.moonrise.p +@@ -1001,12 +1001,14 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot profilerFiller.pop(); } catch (Throwable var5) { diff --git a/lophine-server/minecraft-patches/features/0041-Global-Entities-Counter.patch b/lophine-server/minecraft-patches/features/0040-Global-Entities-Counter.patch similarity index 86% rename from lophine-server/minecraft-patches/features/0041-Global-Entities-Counter.patch rename to lophine-server/minecraft-patches/features/0040-Global-Entities-Counter.patch index c2ebe88..a93726f 100644 --- a/lophine-server/minecraft-patches/features/0041-Global-Entities-Counter.patch +++ b/lophine-server/minecraft-patches/features/0040-Global-Entities-Counter.patch @@ -35,10 +35,10 @@ index 3b39b8f7ccb278cf910e3cc4e00da29790465a81..7cc41630a39c1e29840d70eee78473d0 this.updateTickData(); } diff --git a/net/minecraft/server/level/ServerChunkCache.java b/net/minecraft/server/level/ServerChunkCache.java -index 05bad0366bd36b8134290a0cceb4d4dfcbbd0544..604681c8fda696dcc824b1b36b53c0d8434ec5c2 100644 +index f4c9c551fc39bae38e283ccbbc3cd116f0536a64..db13211b24208d8addd3c210155bc244b58f3942 100644 --- a/net/minecraft/server/level/ServerChunkCache.java +++ b/net/minecraft/server/level/ServerChunkCache.java -@@ -516,6 +516,25 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -506,6 +506,25 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon this.chunkMap.tick(hasTimeLeft); profilerFiller.pop(); this.clearCache(); @@ -64,7 +64,7 @@ index 05bad0366bd36b8134290a0cceb4d4dfcbbd0544..604681c8fda696dcc824b1b36b53c0d8 } private void tickChunks() { -@@ -580,7 +599,13 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -570,7 +589,13 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon } spawnState = NaturalSpawner.createState(naturalSpawnChunkCount, regionizedWorldData.getLoadedEntities(), this::getFullChunk, null, true); // Folia - region threading - note: function only cares about loaded entities, doesn't need all } else { @@ -78,16 +78,16 @@ index 05bad0366bd36b8134290a0cceb4d4dfcbbd0544..604681c8fda696dcc824b1b36b53c0d8 } } finally { foliaProfiler.stopTimer(ca.spottedleaf.leafprofiler.LProfilerRegistry.MOB_SPAWN_ENTITY_COUNT); } // Folia - profiler // Paper end - Optional per player mob spawns -@@ -589,7 +614,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon - boolean _boolean = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING) && !this.level.getLocalPlayers().isEmpty(); // CraftBukkit // Folia - region threading - int _int = this.level.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); +@@ -578,7 +603,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon + boolean flag = this.level.getGameRules().get(GameRules.SPAWN_MOBS) && !this.level.getLocalPlayers().isEmpty(); // CraftBukkit // Folia - region threading + int i = this.level.getGameRules().get(GameRules.RANDOM_TICK_SPEED); List filteredSpawningCategories; -- if (_boolean && (this.spawnEnemies || this.spawnFriendlies)) { -+ if (spawnState != null && _boolean && (this.spawnEnemies || this.spawnFriendlies)) { // Lophine - Global Entities Counter +- if (flag && (this.spawnEnemies || this.spawnFriendlies)) { // Paper ++ if (spawnState != null && flag && (this.spawnEnemies || this.spawnFriendlies)) { // Paper // Lophine - Global Entities Counter // Paper start - PlayerNaturallySpawnCreaturesEvent for (ServerPlayer entityPlayer : this.level.getLocalPlayers()) { // Folia - region threading int chunkRange = Math.min(level.spigotConfig.mobSpawnRange, entityPlayer.getBukkitEntity().getViewDistance()); -@@ -646,7 +671,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon +@@ -636,7 +661,7 @@ public class ServerChunkCache extends ChunkSource implements ca.spottedleaf.moon this.level.tickThunder(chunk); } @@ -97,10 +97,10 @@ index 05bad0366bd36b8134290a0cceb4d4dfcbbd0544..604681c8fda696dcc824b1b36b53c0d8 NaturalSpawner.spawnForChunk(this.level, chunk, spawnState, spawnCategories); } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index c0ba36849da0983117901f0cd04b2c785df0010b..0b0d9322632ef1a751add633bdcb87ec84f82704 100644 +index a906e7a34d048369f9357b0371339b4cccac5f25..b5be74243607fb34812dcbad26aad76e44bf0b19 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -729,6 +729,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -763,6 +763,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } public void tick(BooleanSupplier hasTimeLeft, io.papermc.paper.threadedregions.TickRegions.TickRegionData region) { // Folia - regionised ticking @@ -113,10 +113,10 @@ index c0ba36849da0983117901f0cd04b2c785df0010b..0b0d9322632ef1a751add633bdcb87ec final ca.spottedleaf.leafprofiler.RegionizedProfiler.Handle profiler = io.papermc.paper.threadedregions.TickRegionScheduler.getProfiler(); // Folia - profiler ProfilerFiller profilerFiller = Profiler.get(); diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java -index 81f4707cf1a7cbdfcfc519cfbe1052cde77aa755..5c53e2d61ce8483d5d9e93e9f3112074c704a546 100644 +index 91f0fbd75bc93355dc872390d91af83c76dc1dce..e7223540a7cef20b661bdb857ffba962d0f5d348 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -113,7 +113,7 @@ public final class NaturalSpawner { +@@ -116,7 +116,7 @@ public final class NaturalSpawner { return new NaturalSpawner.SpawnState(spawnableChunkCount, map, potentialCalculator, calculator); } @@ -125,8 +125,8 @@ index 81f4707cf1a7cbdfcfc519cfbe1052cde77aa755..5c53e2d61ce8483d5d9e93e9f3112074 return chunk.getNoiseBiome(QuartPos.fromBlock(pos.getX()), QuartPos.fromBlock(pos.getY()), QuartPos.fromBlock(pos.getZ())).value(); } -@@ -584,7 +584,7 @@ public final class NaturalSpawner { - private EntityType lastCheckedType; +@@ -585,7 +585,7 @@ public final class NaturalSpawner { + private @Nullable EntityType lastCheckedType; private double lastCharge; - SpawnState( diff --git a/lophine-server/minecraft-patches/features/0042-Add-null-check-in-RegionizedWorldData-conections.patch b/lophine-server/minecraft-patches/features/0041-Add-null-check-in-RegionizedWorldData-conections.patch similarity index 100% rename from lophine-server/minecraft-patches/features/0042-Add-null-check-in-RegionizedWorldData-conections.patch rename to lophine-server/minecraft-patches/features/0041-Add-null-check-in-RegionizedWorldData-conections.patch diff --git a/lophine-server/paper-patches/features/0001-Rebrand-to-Lophine.patch b/lophine-server/paper-patches/features/0001-Rebrand-to-Lophine.patch index 88ab735..314ae75 100644 --- a/lophine-server/paper-patches/features/0001-Rebrand-to-Lophine.patch +++ b/lophine-server/paper-patches/features/0001-Rebrand-to-Lophine.patch @@ -8,7 +8,7 @@ Helvetica Volubi bdlvl diff --git a/src/main/java/com/destroystokyo/paper/Metrics.java b/src/main/java/com/destroystokyo/paper/Metrics.java -index 22c038e6556d9911e1eaedf71d7b86843af89c16..f5574eb883b1ee8747acc42832bc88ae03e27b67 100644 +index fcdfd4f6de5e1c2d5e80c7f3d8cb0b33a62d257d..6eaa4e9bd1ecbfa531313ce1f470d55edf31b467 100644 --- a/src/main/java/com/destroystokyo/paper/Metrics.java +++ b/src/main/java/com/destroystokyo/paper/Metrics.java @@ -593,7 +593,7 @@ public class Metrics { @@ -90,19 +90,6 @@ index 4ada790812957657d580cb748077c4961987d0cb..3a539df860305e777e85ed6dc72b5eff } @Override -diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java -index 9699d7dcca5cf67f50ad05c0e875de424a4e00c5..2c546d470013d4daf3ddf427ab4bda1b51d6e641 100644 ---- a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java -+++ b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java -@@ -11,7 +11,7 @@ public final class Versioning { - public static String getBukkitVersion() { - String result = "Unknown-Version"; - -- InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/me.earthme.luminol/luminol-api/pom.properties"); // Folia //Luminol -+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/fun.bm.lophine/lophine-api/pom.properties"); // Folia //Luminol - Properties properties = new Properties(); - - if (stream != null) { diff --git a/src/main/resources/logo.png b/src/main/resources/logo.png index 2b6037aab645e303df6edbbc8af34dc4b4a55bc5..76ea89f23e6d2a42806c5d5d29b415d325e1ee82 100644 GIT binary patch diff --git a/lophine-server/paper-patches/features/0002-Purpur-Barrels-and-enderchests-6-rows.patch b/lophine-server/paper-patches/features/0002-Purpur-Barrels-and-enderchests-6-rows.patch index df7408d..4b592a3 100644 --- a/lophine-server/paper-patches/features/0002-Purpur-Barrels-and-enderchests-6-rows.patch +++ b/lophine-server/paper-patches/features/0002-Purpur-Barrels-and-enderchests-6-rows.patch @@ -41,10 +41,10 @@ index 2f41a92465b9da28e026297cc3528898bb1c8412..168301a2f1c3081ae15d3695c2dcc72b case DROPPER: this.delegate = new DispenserMenu(windowId, bottom, top); diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java -index f850e6cea92edc87ed54cf54488b5ebb606913ed..f4db38de4348fb03db0b769bd5b5993184dd4abb 100644 +index 9d5fe6fc727948955d89f9ed5e181185393a9611..1343972a3a230dcef7349f014a80362ffcb0fe94 100644 --- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftInventory.java -@@ -84,7 +84,7 @@ public class CraftInventory implements Inventory { +@@ -85,7 +85,7 @@ public class CraftInventory implements Inventory { @Override public void setContents(ItemStack[] items) { diff --git a/lophine-server/paper-patches/features/0003-Leaves-Leaves-Protocol-Core.patch b/lophine-server/paper-patches/features/0003-Leaves-Leaves-Protocol-Core.patch index 99604af..10bacbe 100644 --- a/lophine-server/paper-patches/features/0003-Leaves-Leaves-Protocol-Core.patch +++ b/lophine-server/paper-patches/features/0003-Leaves-Leaves-Protocol-Core.patch @@ -8,10 +8,10 @@ As a part of : Leaves (https://github.com/LeavesMC/Leaves/blob/ea91106ae57fc4cc1 Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 4dde33c872d463bf17ba03e926de90e6988444b2..de72f36bd22e2c7452b9c3ee40657f6119ca70b3 100644 +index 92de192c7b420ebb4510354f347003127595e141..e28c7043c04a4df34733b9bfc5fd55ee6082d010 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -497,6 +497,7 @@ public final class CraftServer implements Server { +@@ -485,6 +485,7 @@ public final class CraftServer implements Server { this.potionBrewer = new io.papermc.paper.potion.PaperPotionBrewer(console); // Paper - custom potion mixes datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper if (false) this.spark = new io.papermc.paper.SparksFly(this); // Paper - spark // Luminol - Force disable builtin spark @@ -19,7 +19,7 @@ index 4dde33c872d463bf17ba03e926de90e6988444b2..de72f36bd22e2c7452b9c3ee40657f61 } public boolean getCommandBlockOverride(String command) { -@@ -1115,6 +1116,7 @@ public final class CraftServer implements Server { +@@ -1059,6 +1060,7 @@ public final class CraftServer implements Server { if (false) this.spark.registerCommandBeforePlugins(this); // Paper - spark // Luminol - Force disable builtin spark this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*"); this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions"); diff --git a/lophine-server/paper-patches/features/0005-LeavesHooks.patch b/lophine-server/paper-patches/features/0004-LeavesHooks.patch similarity index 100% rename from lophine-server/paper-patches/features/0005-LeavesHooks.patch rename to lophine-server/paper-patches/features/0004-LeavesHooks.patch diff --git a/lophine-server/paper-patches/features/0007-add-cancel-task-by-task-id-in-FoliaGlobalRegionSched.patch b/lophine-server/paper-patches/features/0005-Add-cancel-task-by-task-id-in-FoliaGlobalRegionSched.patch similarity index 88% rename from lophine-server/paper-patches/features/0007-add-cancel-task-by-task-id-in-FoliaGlobalRegionSched.patch rename to lophine-server/paper-patches/features/0005-Add-cancel-task-by-task-id-in-FoliaGlobalRegionSched.patch index e7f4dfc..8d0b163 100644 --- a/lophine-server/paper-patches/features/0007-add-cancel-task-by-task-id-in-FoliaGlobalRegionSched.patch +++ b/lophine-server/paper-patches/features/0005-Add-cancel-task-by-task-id-in-FoliaGlobalRegionSched.patch @@ -1,14 +1,14 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Helvetica Volubi Date: Sat, 22 Nov 2025 01:43:26 +0800 -Subject: [PATCH] add cancel task by task id in FoliaGlobalRegionScheduler +Subject: [PATCH] Add cancel task by task id in FoliaGlobalRegionScheduler diff --git a/src/main/java/io/papermc/paper/threadedregions/scheduler/FoliaGlobalRegionScheduler.java b/src/main/java/io/papermc/paper/threadedregions/scheduler/FoliaGlobalRegionScheduler.java -index d306f911757a4d556c82c0070d4837db87afc497..7c9d3e4c399b2ea246a76b4550ba12e45e75078e 100644 +index 14ffbcb66006878eacf310547dad53718f8308eb..6c108bc7d93196803daeef4751d06cafa6eeec1a 100644 --- a/src/main/java/io/papermc/paper/threadedregions/scheduler/FoliaGlobalRegionScheduler.java +++ b/src/main/java/io/papermc/paper/threadedregions/scheduler/FoliaGlobalRegionScheduler.java -@@ -17,6 +17,8 @@ public class FoliaGlobalRegionScheduler implements GlobalRegionScheduler { +@@ -16,6 +16,8 @@ public class FoliaGlobalRegionScheduler implements GlobalRegionScheduler { private long tickCount = 0L; private final Object stateLock = new Object(); private final Long2ObjectOpenHashMap> tasksByDeadline = new Long2ObjectOpenHashMap<>(); @@ -17,7 +17,7 @@ index d306f911757a4d556c82c0070d4837db87afc497..7c9d3e4c399b2ea246a76b4550ba12e4 public void tick() { final List run; -@@ -65,7 +67,7 @@ public class FoliaGlobalRegionScheduler implements GlobalRegionScheduler { +@@ -64,7 +66,7 @@ public class FoliaGlobalRegionScheduler implements GlobalRegionScheduler { throw new IllegalPluginAccessException("Plugin attempted to register task while disabled"); } @@ -26,7 +26,7 @@ index d306f911757a4d556c82c0070d4837db87afc497..7c9d3e4c399b2ea246a76b4550ba12e4 this.scheduleInternal(ret, delayTicks); -@@ -92,7 +94,7 @@ public class FoliaGlobalRegionScheduler implements GlobalRegionScheduler { +@@ -91,7 +93,7 @@ public class FoliaGlobalRegionScheduler implements GlobalRegionScheduler { throw new IllegalPluginAccessException("Plugin attempted to register task while disabled"); } @@ -35,7 +35,7 @@ index d306f911757a4d556c82c0070d4837db87afc497..7c9d3e4c399b2ea246a76b4550ba12e4 this.scheduleInternal(ret, initialDelayTicks); -@@ -134,7 +136,33 @@ public class FoliaGlobalRegionScheduler implements GlobalRegionScheduler { +@@ -133,7 +135,33 @@ public class FoliaGlobalRegionScheduler implements GlobalRegionScheduler { } } @@ -70,7 +70,7 @@ index d306f911757a4d556c82c0070d4837db87afc497..7c9d3e4c399b2ea246a76b4550ba12e4 private static final int STATE_IDLE = 0; private static final int STATE_EXECUTING = 1; -@@ -146,13 +174,15 @@ public class FoliaGlobalRegionScheduler implements GlobalRegionScheduler { +@@ -145,13 +173,15 @@ public class FoliaGlobalRegionScheduler implements GlobalRegionScheduler { private final long repeatDelay; // in ticks private Consumer run; private volatile int state; @@ -87,7 +87,7 @@ index d306f911757a4d556c82c0070d4837db87afc497..7c9d3e4c399b2ea246a76b4550ba12e4 } private final int getStateVolatile() { -@@ -263,5 +293,11 @@ public class FoliaGlobalRegionScheduler implements GlobalRegionScheduler { +@@ -262,5 +292,11 @@ public class FoliaGlobalRegionScheduler implements GlobalRegionScheduler { } } } diff --git a/lophine-server/paper-patches/features/0004-Leaves-Leaves-Fakeplayer.patch b/lophine-server/paper-patches/features/0006-Leaves-Leaves-Fakeplayer.patch similarity index 85% rename from lophine-server/paper-patches/features/0004-Leaves-Leaves-Fakeplayer.patch rename to lophine-server/paper-patches/features/0006-Leaves-Leaves-Fakeplayer.patch index f830bf0..5792036 100644 --- a/lophine-server/paper-patches/features/0004-Leaves-Leaves-Fakeplayer.patch +++ b/lophine-server/paper-patches/features/0006-Leaves-Leaves-Fakeplayer.patch @@ -41,22 +41,22 @@ index 9180f23529a31b6b0a5b38bb7cda3e32d487f691..e1f456b31ffda9370b63e51f343847d6 if (!registration.getPlugin().isEnabled()) { continue; diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java -index 0a10f49ee410d93e95ceb90108200a1a9d12b54b..d2eee37d810a6d5cf514bc71dea66a4d2b0d09e2 100644 +index 21d594a39d09b2d17f05c40ce5323d57949d0b0b..46859fc70795097366f02dba48fdaab8b9c85013 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java -@@ -423,6 +423,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { +@@ -374,6 +374,7 @@ public abstract class CraftRegionAccessor implements RegionAccessor { @SuppressWarnings("unchecked") public T addEntity(T entity) { Preconditions.checkArgument(!entity.isInWorld(), "Entity has already been added to a world"); + Preconditions.checkState(!(entity instanceof org.leavesmc.leaves.entity.bot.CraftBot), "[Leaves] Fakeplayers do not support changing world, Please use leaves fakeplayer-api instead!"); net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle(); if (nmsEntity.level() != this.getHandle().getLevel()) { - nmsEntity = nmsEntity.teleport(new TeleportTransition(this.getHandle().getLevel(), nmsEntity, TeleportTransition.DO_NOTHING)); + throw new IllegalArgumentException(entity + " wasn't created with this world, you must create the entity with the world you want to add it to."); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index de72f36bd22e2c7452b9c3ee40657f6119ca70b3..0a96721797b9bbc643f68677bbb1d10c3c89e815 100644 +index e28c7043c04a4df34733b9bfc5fd55ee6082d010..3b179b11441a9295698fa55cc4a020b4c1652616 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -316,6 +316,7 @@ public final class CraftServer implements Server { +@@ -305,6 +305,7 @@ public final class CraftServer implements Server { private final io.papermc.paper.potion.PaperPotionBrewer potionBrewer; public io.papermc.paper.SparksFly spark; // Paper - spark // Luminol - Force disable builtin spark private final ServerConfiguration serverConfig = new PaperServerConfiguration(); @@ -64,7 +64,7 @@ index de72f36bd22e2c7452b9c3ee40657f6119ca70b3..0a96721797b9bbc643f68677bbb1d10c // Paper start - Folia region threading API private final io.papermc.paper.threadedregions.scheduler.FoliaRegionScheduler regionizedScheduler = new io.papermc.paper.threadedregions.scheduler.FoliaRegionScheduler(); // Folia - region threading -@@ -498,6 +499,7 @@ public final class CraftServer implements Server { +@@ -486,6 +487,7 @@ public final class CraftServer implements Server { datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper if (false) this.spark = new io.papermc.paper.SparksFly(this); // Paper - spark // Luminol - Force disable builtin spark org.leavesmc.leaves.protocol.core.LeavesProtocolManager.init(); // Leaves - protocol @@ -72,7 +72,7 @@ index de72f36bd22e2c7452b9c3ee40657f6119ca70b3..0a96721797b9bbc643f68677bbb1d10c } public boolean getCommandBlockOverride(String command) { -@@ -1482,7 +1484,7 @@ public final class CraftServer implements Server { +@@ -1379,7 +1381,7 @@ public final class CraftServer implements Server { return false; } @@ -81,7 +81,7 @@ index de72f36bd22e2c7452b9c3ee40657f6119ca70b3..0a96721797b9bbc643f68677bbb1d10c return false; } -@@ -3260,6 +3262,13 @@ public final class CraftServer implements Server { +@@ -3041,6 +3043,13 @@ public final class CraftServer implements Server { this.console.addPluginAllowingSleep(plugin.getName(), value); } @@ -96,7 +96,7 @@ index de72f36bd22e2c7452b9c3ee40657f6119ca70b3..0a96721797b9bbc643f68677bbb1d10c /** * Gets the TPS from the region which owns the specified location, or {@code null} if no region owns diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 9b9eea4babcd67a088e9400b369d168d11c06ac1..3177db282013e6dc3c7215fc2a851e2630a29409 100644 +index a1a79a18673c94218288f32345195b80139ad879..acddc62380f65f50779786296dec265de4a647db 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -249,7 +249,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @@ -108,7 +108,7 @@ index 9b9eea4babcd67a088e9400b369d168d11c06ac1..3177db282013e6dc3c7215fc2a851e26 } @Override -@@ -1279,9 +1279,9 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1122,9 +1122,9 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public List getPlayers() { @@ -120,7 +120,7 @@ index 9b9eea4babcd67a088e9400b369d168d11c06ac1..3177db282013e6dc3c7215fc2a851e26 HumanEntity bukkitEntity = human.getBukkitEntity(); if ((bukkitEntity != null) && (bukkitEntity instanceof Player)) { -@@ -1988,7 +1988,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1626,7 +1626,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { public void playSound(final net.kyori.adventure.sound.Sound sound) { org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper final long seed = sound.seed().orElseGet(this.world.getRandom()::nextLong); @@ -129,7 +129,7 @@ index 9b9eea4babcd67a088e9400b369d168d11c06ac1..3177db282013e6dc3c7215fc2a851e26 player.connection.send(io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, player.getX(), player.getY(), player.getZ(), seed, null)); } } -@@ -2016,7 +2016,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1654,7 +1654,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { org.spigotmc.AsyncCatcher.catchOp("play sound"); // Paper final long seed = sound.seed().orElseGet(this.getHandle().getRandom()::nextLong); if (emitter == net.kyori.adventure.sound.Sound.Emitter.self()) { @@ -138,20 +138,20 @@ index 9b9eea4babcd67a088e9400b369d168d11c06ac1..3177db282013e6dc3c7215fc2a851e26 player.connection.send(io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, player, seed, null)); } } else if (emitter instanceof CraftEntity craftEntity) { -@@ -2248,7 +2248,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1795,7 +1795,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { Preconditions.checkArgument(particle.getDataType().isInstance(data), "data (%s) should be %s", data.getClass(), particle.getDataType()); } this.getHandle().sendParticlesSource( -- receivers == null ? this.getHandle().players() : receivers.stream().map(player -> ((CraftPlayer) player).getHandle()).collect(java.util.stream.Collectors.toList()), // Paper - Particle API -+ receivers == null ? this.getHandle().realPlayers() : receivers.stream().map(player -> ((CraftPlayer) player).getHandle()).collect(java.util.stream.Collectors.toList()), // Paper - Particle API // Leaves - skip +- receivers == null ? this.getHandle().players() : Lists.transform(receivers, player -> ((CraftPlayer) player).getHandle()), // Paper - Particle API ++ receivers == null ? this.getHandle().realPlayers() : Lists.transform(receivers, player -> ((CraftPlayer) player).getHandle()), // Paper - Particle API // Leaves - skip sender != null ? ((CraftPlayer) sender).getHandle() : null, // Sender // Paper - Particle API CraftParticle.createParticleParam(particle, data), // Particle force, diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 852e1ffef6a022caad7c8eff34091e50112a2290..8eb5d014d9ed688ffebaffb4ce0bb40896961a04 100644 +index e6cd1c4a50b32b74f70a264e869b1ab4ac9b9eb0..6867064de52d810f1fd3869463ae27868ed0fb07 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -@@ -126,6 +126,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -127,6 +127,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return new CraftHumanEntity(server, (net.minecraft.world.entity.player.Player) entity); } @@ -161,10 +161,10 @@ index 852e1ffef6a022caad7c8eff34091e50112a2290..8eb5d014d9ed688ffebaffb4ce0bb408 if (entity instanceof EnderDragonPart complexPart) { if (complexPart.parentMob instanceof EnderDragon) { diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 317837a2a9b3b511b5cac4df4db248d4652816dc..a8253d1a3129c8258e9ead7c430e1bcf82f735d7 100644 +index 3d465c857b3560a2cd57825c9cbd0a3c9029e6d3..a41b5eeb1e82725948c448c7c3c4f5b2d1e06af6 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -897,7 +897,11 @@ public class CraftEventFactory { +@@ -1014,7 +1014,11 @@ public class CraftEventFactory { event.setKeepInventory(keepInventory); event.setKeepLevel(victim.keepLevel); // SPIGOT-2222: pre-set keepLevel populateFields(victim, event); // Paper - make cancellable diff --git a/lophine-server/paper-patches/features/0006-Leaves-Replay-Mod-API.patch b/lophine-server/paper-patches/features/0007-Leaves-Replay-Mod-API.patch similarity index 90% rename from lophine-server/paper-patches/features/0006-Leaves-Replay-Mod-API.patch rename to lophine-server/paper-patches/features/0007-Leaves-Replay-Mod-API.patch index ec5a2b5..0939e43 100644 --- a/lophine-server/paper-patches/features/0006-Leaves-Replay-Mod-API.patch +++ b/lophine-server/paper-patches/features/0007-Leaves-Replay-Mod-API.patch @@ -21,10 +21,10 @@ index e1f456b31ffda9370b63e51f343847d6f9f62263..8a0f85241cc1530aacccc8b6ea24b9de } // Leaves end - skip bot diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 0a96721797b9bbc643f68677bbb1d10c3c89e815..7e2d870dc8b77c58270542f8916b9c9b88588809 100644 +index 3b179b11441a9295698fa55cc4a020b4c1652616..2326fda32f279aa391a98943984ccb78e69ac686 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -317,6 +317,7 @@ public final class CraftServer implements Server { +@@ -306,6 +306,7 @@ public final class CraftServer implements Server { public io.papermc.paper.SparksFly spark; // Paper - spark // Luminol - Force disable builtin spark private final ServerConfiguration serverConfig = new PaperServerConfiguration(); private final org.leavesmc.leaves.entity.bot.CraftBotManager botManager; // Leaves @@ -32,7 +32,7 @@ index 0a96721797b9bbc643f68677bbb1d10c3c89e815..7e2d870dc8b77c58270542f8916b9c9b // Paper start - Folia region threading API private final io.papermc.paper.threadedregions.scheduler.FoliaRegionScheduler regionizedScheduler = new io.papermc.paper.threadedregions.scheduler.FoliaRegionScheduler(); // Folia - region threading -@@ -411,7 +412,7 @@ public final class CraftServer implements Server { +@@ -400,7 +401,7 @@ public final class CraftServer implements Server { public CraftServer(DedicatedServer console, PlayerList playerList) { this.console = console; this.playerList = (DedicatedPlayerList) playerList; @@ -41,7 +41,7 @@ index 0a96721797b9bbc643f68677bbb1d10c3c89e815..7e2d870dc8b77c58270542f8916b9c9b @Override public CraftPlayer apply(ServerPlayer player) { return player.getBukkitEntity(); -@@ -3333,4 +3334,11 @@ public final class CraftServer implements Server { +@@ -3114,4 +3115,11 @@ public final class CraftServer implements Server { } } // Folia end - region TPS API @@ -54,10 +54,10 @@ index 0a96721797b9bbc643f68677bbb1d10c3c89e815..7e2d870dc8b77c58270542f8916b9c9b + // Leaves end - replay mod api } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -index 8eb5d014d9ed688ffebaffb4ce0bb40896961a04..634bd74449c6991ad72330d10f42ddbb7f59c164 100644 +index 6867064de52d810f1fd3869463ae27868ed0fb07..69a0de762cfde089e8aaa6e6be79a8c8298d7778 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -@@ -127,6 +127,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -128,6 +128,7 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { } if (entity instanceof org.leavesmc.leaves.bot.ServerBot bot) { return new org.leavesmc.leaves.entity.bot.CraftBot(server, bot); } @@ -66,10 +66,10 @@ index 8eb5d014d9ed688ffebaffb4ce0bb40896961a04..634bd74449c6991ad72330d10f42ddbb // Special case complex part, since there is no extra entity type for them if (entity instanceof EnderDragonPart complexPart) { diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index 7883b7973570b5f275a03c6aac4d3b4392e7fa6e..18d066c605f8027d9b1170b64ef1428fb969631b 100644 +index aa06b3cbea3e50c6a2567fb6a98d499648617517..948cdbe2883628c4583e3c1228a51fd0d9227c2b 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -@@ -2214,7 +2214,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa +@@ -2064,7 +2064,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player, PluginMessa @Override public boolean canSee(Player player) { @@ -79,7 +79,7 @@ index 7883b7973570b5f275a03c6aac4d3b4392e7fa6e..18d066c605f8027d9b1170b64ef1428f @Override diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index 7334422a6e0e7faec675cf038ccbca0e284f61b5..7fee749197b6c6a8890567a7a7819f45b290012b 100644 +index dcec69554213bfb8608b77341819b09e31a96e09..5dce7416f42902de34bff6398cf402c610be600c 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java @@ -338,7 +338,7 @@ public final class CraftMagicNumbers implements UnsafeValues { diff --git a/lophine-server/src/main/java/fun/bm/lophine/config/modules/fixes/EndVoidRingsConfig.java b/lophine-server/src/main/java/fun/bm/lophine/config/modules/fixes/EndVoidRingsConfig.java deleted file mode 100644 index 7a53b16..0000000 --- a/lophine-server/src/main/java/fun/bm/lophine/config/modules/fixes/EndVoidRingsConfig.java +++ /dev/null @@ -1,15 +0,0 @@ -package fun.bm.lophine.config.modules.fixes; - -import me.earthme.luminol.config.IConfigModule; -import me.earthme.luminol.config.flags.ConfigClassInfo; -import me.earthme.luminol.config.flags.ConfigInfo; -import me.earthme.luminol.config.flags.TransformedConfig; -import me.earthme.luminol.enums.EnumConfigCategory; - -@ConfigClassInfo(category = EnumConfigCategory.FIXES, name = "end-void-ring") -public class EndVoidRingsConfig implements IConfigModule { - @TransformedConfig(name = "enabled", directory = {"gameplay", "end_void_rings"}) - @ConfigInfo(name = "enabled", comments = """ - If enabled, it will generate end void rings, like MC-159283.""") - public static boolean enabled = false; -} diff --git a/lophine-server/src/main/java/fun/bm/lophine/config/modules/removed/RemovedConfig.java b/lophine-server/src/main/java/fun/bm/lophine/config/modules/removed/RemovedConfig.java index 0cf7317..fa8434c 100644 --- a/lophine-server/src/main/java/fun/bm/lophine/config/modules/removed/RemovedConfig.java +++ b/lophine-server/src/main/java/fun/bm/lophine/config/modules/removed/RemovedConfig.java @@ -8,6 +8,8 @@ import me.earthme.luminol.enums.EnumConfigCategory; @ConfigClassInfo(category = EnumConfigCategory.REMOVED, name = "removed_config") public class RemovedConfig implements IConfigModule { + @TransformedConfig(name = "enabled", directory = {"fixes", "end-void-ring"}, transform = false) + @TransformedConfig(name = "enabled", directory = {"gameplay", "end_void_rings"}, transform = false) @TransformedConfig(name = "datapack_command_enabled", directory = {"experiment", "command"}, transform = false) @TransformedConfig(name = "disable_end_crystal_check", directory = {"fixes", "end_crystal"}, transform = false) @TransformedConfig(name = "disable_end_crystal_check", directory = {"misc", "end_crystal"}, transform = false) diff --git a/lophine-server/src/main/java/fun/bm/lophine/utils/concurrent/ConcurrentTable.java b/lophine-server/src/main/java/fun/bm/lophine/utils/concurrent/ConcurrentTable.java index f400994..5733c83 100644 --- a/lophine-server/src/main/java/fun/bm/lophine/utils/concurrent/ConcurrentTable.java +++ b/lophine-server/src/main/java/fun/bm/lophine/utils/concurrent/ConcurrentTable.java @@ -12,6 +12,7 @@ public class ConcurrentTable extends AbstractConcurrentTable { @Override public void put(X x, Y y, Z z) { + if (true) return; // TODO: because of some bug, we disabled it data.add(new TableEntry<>(x, y, z)); } diff --git a/lophine-server/src/main/java/fun/bm/lophine/utils/concurrent/OptimizedConcurrentTable.java b/lophine-server/src/main/java/fun/bm/lophine/utils/concurrent/OptimizedConcurrentTable.java index a64ab8a..b8168b2 100644 --- a/lophine-server/src/main/java/fun/bm/lophine/utils/concurrent/OptimizedConcurrentTable.java +++ b/lophine-server/src/main/java/fun/bm/lophine/utils/concurrent/OptimizedConcurrentTable.java @@ -12,6 +12,7 @@ public class OptimizedConcurrentTable extends ConcurrentTable @Override public void put(X x, Y y, Z z) { + if (true) return; // TODO: because of some bug, we disabled it super.put(x, y, z); xyIndex.computeIfAbsent(x, k -> new ConcurrentHashMap<>()) .computeIfAbsent(y, k -> ConcurrentHashMap.newKeySet()).add(z); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/bot/BotDataStorage.java b/lophine-server/src/main/java/org/leavesmc/leaves/bot/BotDataStorage.java index 5eca881..066a47c 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/bot/BotDataStorage.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/bot/BotDataStorage.java @@ -93,7 +93,6 @@ public class BotDataStorage implements IPlayerDataStorage { } } - @Override public Optional load(Player player, ProblemReporter reporter) { return this.load(player.getScoreboardName(), player.getStringUUID()).map(nbt -> { ValueInput valueInput = TagValueInput.create(reporter, player.registryAccess(), nbt); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/bot/BotList.java b/lophine-server/src/main/java/org/leavesmc/leaves/bot/BotList.java index 454a4bf..62d6712 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/bot/BotList.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/bot/BotList.java @@ -21,9 +21,11 @@ import ca.spottedleaf.moonrise.common.util.TickThread; import com.google.common.collect.Maps; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; +import com.mojang.authlib.properties.PropertyMap; import com.mojang.logging.LogUtils; import fun.bm.lophine.config.modules.function.FakeplayerConfig; import io.papermc.paper.adventure.PaperAdventure; +import io.papermc.paper.profile.MutablePropertyMap; import io.papermc.paper.threadedregions.RegionizedServer; import io.papermc.paper.threadedregions.scheduler.FoliaGlobalRegionScheduler; import net.kyori.adventure.text.format.NamedTextColor; @@ -37,9 +39,9 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.ProblemReporter; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.npc.AbstractVillager; +import net.minecraft.world.entity.npc.villager.AbstractVillager; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.entity.projectile.ThrownEnderpearl; +import net.minecraft.world.entity.projectile.throwableitemprojectile.ThrownEnderpearl; import net.minecraft.world.level.Level; import net.minecraft.world.level.storage.ValueInput; import org.bukkit.Bukkit; @@ -92,7 +94,7 @@ public class BotList { Location location = event.getCreateLocation(); ServerLevel world = ((CraftWorld) location.getWorld()).getHandle(); - CustomGameProfile profile = new CustomGameProfile(BotUtil.getBotUUID(state), state.name(), state.skin()); + GameProfile profile = setProfile(BotUtil.getBotUUID(state), state.name(), state.skin()); ServerBot bot = new ServerBot(this.server, world, profile); bot.createState = state; if (event.getCreator() instanceof org.bukkit.entity.Player player) { @@ -122,11 +124,16 @@ public class BotList { ServerBot bot = new ServerBot(this.server, this.server.getLevel(Level.OVERWORLD), new GameProfile(uuid, realName)); bot.connection = new ServerBotPacketListenerImpl(this.server, bot, new ServerBotPacketListenerImpl.BotConnection()); + bot.connection.markClientLoaded(); Optional optional; - try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(bot.problemPath(), LOGGER)) { - optional = playerIO.load(bot, scopedCollector); - } catch (Exception e) { - throw new RuntimeException(e); + if (playerIO instanceof BotDataStorage botIO) { + try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(bot.problemPath(), LOGGER)) { + optional = botIO.load(bot, scopedCollector); + } catch (Exception e) { + throw new RuntimeException(e); + } + } else { + optional = Optional.empty(); } if (optional.isEmpty()) { @@ -155,6 +162,7 @@ public class BotList { bot.isRealPlayer = true; bot.loginTime = System.currentTimeMillis(); bot.connection = new ServerBotPacketListenerImpl(this.server, bot, new ServerBotPacketListenerImpl.BotConnection()); + bot.connection.markClientLoaded(); bot.setServerLevel(world); BotSpawnLocationEvent event = new BotSpawnLocationEvent(bot.getBukkitEntity(), location); @@ -173,7 +181,7 @@ public class BotList { this.botsByName.put(bot.getScoreboardName().toLowerCase(Locale.ROOT), bot); this.botsByUUID.put(bot.getUUID(), bot); - bot.supressTrackerForLogin = true; + bot.suppressTrackerForLogin = true; optional.ifPresent(nbt -> { bot.loadAndSpawnEnderPearls(nbt); @@ -204,7 +212,7 @@ public class BotList { } bot.renderInfo(); - bot.supressTrackerForLogin = false; + bot.suppressTrackerForLogin = false; bot.level().getChunkSource().chunkMap.addEntity(bot); bot.renderData(); @@ -415,17 +423,11 @@ public class BotList { return this.dataStorage.getSavedBotList(); } - public static class CustomGameProfile extends GameProfile { - - public CustomGameProfile(UUID uuid, String name, String[] skin) { - super(uuid, name); - this.setSkin(skin); - } - - public void setSkin(String[] skin) { - if (skin != null) { - this.getProperties().put("textures", new Property("textures", skin[0], skin[1])); - } - } + public GameProfile setProfile(UUID uuid, String name, String[] skin) { + GameProfile profile = new GameProfile(uuid, name); + if (skin == null) return profile; + PropertyMap profileMap = new MutablePropertyMap(profile.properties()); + profileMap.put("textures", new Property("textures", skin[0], skin[1])); + return new GameProfile(uuid, name, profileMap); } } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java b/lophine-server/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java index fee7dd9..7296d14 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java @@ -17,6 +17,7 @@ package org.leavesmc.leaves.bot; +import com.google.gson.JsonElement; import com.mojang.datafixers.DataFixer; import net.minecraft.server.MinecraftServer; import net.minecraft.stats.ServerStatsCounter; @@ -31,7 +32,7 @@ public class BotStatsCounter extends ServerStatsCounter { private static final File UNKOWN_FILE = new File("BOT_STATS_REMOVE_THIS"); public BotStatsCounter(MinecraftServer server) { - super(server, UNKOWN_FILE); + super(server, UNKOWN_FILE.toPath()); } @Override @@ -43,7 +44,7 @@ public class BotStatsCounter extends ServerStatsCounter { } @Override - public void parseLocal(@NotNull DataFixer dataFixer, @NotNull String json) { + public void parse(@NotNull DataFixer dataFixer, @NotNull JsonElement json) { } @Override diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/bot/IPlayerDataStorage.java b/lophine-server/src/main/java/org/leavesmc/leaves/bot/IPlayerDataStorage.java index ff903a0..dd4c9e5 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/bot/IPlayerDataStorage.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/bot/IPlayerDataStorage.java @@ -17,15 +17,11 @@ package org.leavesmc.leaves.bot; -import net.minecraft.util.ProblemReporter; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.storage.ValueInput; - -import java.util.Optional; public interface IPlayerDataStorage { void save(Player player); - Optional load(Player player, ProblemReporter reporter); +// Optional load(Player player, ProblemReporter reporter); } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java b/lophine-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java index b68ecc1..7744140 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java @@ -53,12 +53,12 @@ import net.minecraft.world.entity.item.ItemEntity; import net.minecraft.world.entity.player.Input; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.ProjectileUtil; -import net.minecraft.world.entity.vehicle.AbstractBoat; +import net.minecraft.world.entity.vehicle.boat.AbstractBoat; import net.minecraft.world.inventory.ChestMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeHolder; -import net.minecraft.world.level.GameRules; import net.minecraft.world.level.gameevent.GameEvent; +import net.minecraft.world.level.gamerules.GameRules; import net.minecraft.world.level.portal.TeleportTransition; import net.minecraft.world.level.storage.ValueInput; import net.minecraft.world.level.storage.ValueOutput; @@ -122,7 +122,6 @@ public class ServerBot extends ServerPlayer { this.notSleepTicks = 0; this.fauxSleeping = FakeplayerConfig.canSkipSleep; this.getBukkitEntity().setSimulationDistance(FakeplayerConfig.getSimulationDistance(this)); - this.setClientLoaded(true); } @Override @@ -201,7 +200,7 @@ public class ServerBot extends ServerPlayer { this.notSleepTicks = 0; } - if (!this.level().isClientSide && this.level().isBrightOutside()) { + if (!this.level().isClientSide() && this.level().isBrightOutside()) { this.stopSleepInBed(false, true); } } else if (this.sleepCounter > 0) { @@ -351,7 +350,7 @@ public class ServerBot extends ServerPlayer { if (FakeplayerConfig.canOpenInventory) { if (player instanceof ServerPlayer player1 && player.getMainHandItem().isEmpty()) { BotInventoryOpenEvent event = new BotInventoryOpenEvent(this.getBukkitEntity(), player1.getBukkitEntity()); - this.getServer().server.getPluginManager().callEvent(event); + MinecraftServer.getServer().server.getPluginManager().callEvent(event); if (!event.isCancelled()) { player.openMenu(new SimpleMenuProvider((i, inventory, p) -> ChestMenu.sixRows(i, inventory, this.container), this.getDisplayName())); return InteractionResult.SUCCESS; @@ -423,7 +422,7 @@ public class ServerBot extends ServerPlayer { createBuilder.createReason(BotCreateEvent.CreateReason.INTERNAL).creator(null); this.createState = createBuilder.build(); - this.gameProfile = new BotList.CustomGameProfile(this.getUUID(), this.createState.name(), this.createState.skin()); + this.gameProfile = BotList.INSTANCE.setProfile(this.getUUID(), this.createState.name(), this.createState.skin()); if (nbt.list("actions", CompoundTag.CODEC).isPresent()) { @@ -480,22 +479,22 @@ public class ServerBot extends ServerPlayer { } public void renderInfo() { - this.getServer().getPlayerList().getPlayers().forEach(this::sendPlayerInfo); + MinecraftServer.getServer().getPlayerList().getPlayers().forEach(this::sendPlayerInfo); } public void renderData() { - this.getServer().getPlayerList().getPlayers().forEach( + MinecraftServer.getServer().getPlayerList().getPlayers().forEach( player -> this.sendFakeDataIfNeed(player, false) ); } private void sendPacket(Packet packet) { - this.getServer().getPlayerList().getPlayers().forEach(player -> player.connection.send(packet)); + MinecraftServer.getServer().getPlayerList().getPlayers().forEach(player -> player.connection.send(packet)); } @Override public void die(@NotNull DamageSource damageSource) { - boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_SHOWDEATHMESSAGES); + boolean flag = this.level().getGameRules().get(GameRules.SHOW_DEATH_MESSAGES); Component defaultMessage = this.getCombatTracker().getDeathMessage(); BotDeathEvent event = new BotDeathEvent(this.getBukkitEntity(), PaperAdventure.asAdventure(defaultMessage), flag); @@ -512,18 +511,18 @@ public class ServerBot extends ServerPlayer { net.kyori.adventure.text.Component deathMessage = event.deathMessage(); if (event.isSendDeathMessage() && deathMessage != null && !deathMessage.equals(net.kyori.adventure.text.Component.empty())) { - this.getServer().getPlayerList().broadcastSystemMessage(PaperAdventure.asVanilla(deathMessage), false); + MinecraftServer.getServer().getPlayerList().broadcastSystemMessage(PaperAdventure.asVanilla(deathMessage), false); } - this.getServer().getBotList().removeBot(this, BotRemoveEvent.RemoveReason.DEATH, null, false); + MinecraftServer.getServer().getBotList().removeBot(this, BotRemoveEvent.RemoveReason.DEATH, null, false); } @Override - public boolean startRiding(@NotNull Entity vehicle, boolean force) { - if (super.startRiding(vehicle, force)) { - if (vehicle.getControllingPassenger() == this) { // see net.minecraft.server.networkServerGamePacketListenerImpl#handleMoveVehicle + public boolean startRiding(Entity entity, boolean force, boolean triggerEvents) { + if (super.startRiding(entity, force, triggerEvents)) { + if (entity.getControllingPassenger() == this) { // see net.minecraft.server.networkServerGamePacketListenerImpl#handleMoveVehicle this.setDeltaMovement(Vec3.ZERO); - this.setYRot(vehicle.yRotO); + this.setYRot(entity.yRotO); } return true; } else { diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerMountAction.java b/lophine-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerMountAction.java index 286ee10..b879e46 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerMountAction.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerMountAction.java @@ -46,7 +46,7 @@ public class ServerMountAction extends AbstractBotAction { )).toList(); for (Vehicle vehicle : vehicles) { - if (bot.startRiding(((CraftEntity) vehicle).getHandle(), false)) { + if (bot.startRiding(((CraftEntity) vehicle).getHandle(), false, true)) { return true; } } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/CreateCommand.java b/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/CreateCommand.java index 2b60582..68d7b56 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/CreateCommand.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/CreateCommand.java @@ -25,7 +25,7 @@ import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.arguments.DimensionArgument; import net.minecraft.commands.arguments.coordinates.Coordinates; import net.minecraft.commands.arguments.coordinates.Vec3Argument; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.phys.Vec3; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -141,7 +141,7 @@ public class CreateCommand extends BotSubcommand { } } - private static class WorldArgument extends ArgumentNode { + private static class WorldArgument extends ArgumentNode { private WorldArgument() { super("world", DimensionArgument.dimension()); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/ListCommand.java b/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/ListCommand.java index 57d6ac1..5008032 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/ListCommand.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/ListCommand.java @@ -22,7 +22,7 @@ import fun.bm.lophine.config.modules.function.FakeplayerConfig; import io.papermc.paper.adventure.PaperAdventure; import net.kyori.adventure.text.Component; import net.minecraft.commands.arguments.DimensionArgument; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.player.Player; import org.bukkit.Bukkit; @@ -85,7 +85,7 @@ public class ListCommand extends BotSubcommand { .map(PaperAdventure::asAdventure) .reduce((a, b) -> a.append(text(", ", GRAY)).append(b)) .get(); - String worldLocation = ((CraftWorld) world).getHandle().dimension().location().toString(); + String worldLocation = ((CraftWorld) world).getHandle().dimension().identifier().toString(); return join(noSeparators(), text(world.getName(), AQUA).hoverEvent(showText(text(worldLocation))), text(" (" + botsInLevel.size() + ")\n", GRAY), @@ -93,7 +93,7 @@ public class ListCommand extends BotSubcommand { ); } - private static class WorldArgument extends ArgumentNode { + private static class WorldArgument extends ArgumentNode { private WorldArgument() { super("world", DimensionArgument.dimension()); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java index c51ebf5..5cad2ca 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java @@ -18,11 +18,11 @@ package org.leavesmc.leaves.protocol; import fun.bm.lophine.config.modules.function.protocol.AppleSkinProtocolConfig; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.food.FoodData; -import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.gamerules.GameRules; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.core.Context; @@ -41,9 +41,9 @@ public class AppleSkinProtocol implements LeavesProtocol { public static final String PROTOCOL_ID = "appleskin"; - private static final ResourceLocation SATURATION_KEY = id("saturation"); - private static final ResourceLocation EXHAUSTION_KEY = id("exhaustion"); - private static final ResourceLocation NATURAL_REGENERATION_KEY = id("natural_regeneration"); + private static final Identifier SATURATION_KEY = id("saturation"); + private static final Identifier EXHAUSTION_KEY = id("exhaustion"); + private static final Identifier NATURAL_REGENERATION_KEY = id("natural_regeneration"); private static final float MINIMUM_EXHAUSTION_CHANGE_THRESHOLD = 0.01F; @@ -54,8 +54,8 @@ public class AppleSkinProtocol implements LeavesProtocol { private static final Map> subscribedChannels = new ConcurrentHashMap<>(); @Contract("_ -> new") - public static ResourceLocation id(String path) { - return ResourceLocation.tryBuild(PROTOCOL_ID, path); + public static Identifier id(String path) { + return Identifier.tryBuild(PROTOCOL_ID, path); } @ProtocolHandler.PlayerJoin @@ -70,8 +70,8 @@ public class AppleSkinProtocol implements LeavesProtocol { } @ProtocolHandler.MinecraftRegister(onlyNamespace = true) - public static void onPlayerSubscribed(@NotNull Context context, ResourceLocation id) { - subscribedChannels.computeIfAbsent(context.profile().getId(), k -> new HashSet<>()).add(id.getPath()); + public static void onPlayerSubscribed(@NotNull Context context, Identifier id) { + subscribedChannels.computeIfAbsent(context.profile().id(), k -> new HashSet<>()).add(id.getPath()); } @ProtocolHandler.Ticker @@ -104,7 +104,7 @@ public class AppleSkinProtocol implements LeavesProtocol { } case "natural_regeneration" -> { - boolean regeneration = player.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION); + boolean regeneration = player.level().getGameRules().get(GameRules.NATURAL_HEALTH_REGENERATION); Boolean previousRegeneration = previousNaturalRegeneration.get(player); if (previousRegeneration == null || regeneration != previousRegeneration) { ProtocolUtils.sendBytebufPacket(player, NATURAL_REGENERATION_KEY, buf -> buf.writeBoolean(regeneration)); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/BBORProtocol.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/BBORProtocol.java index 5aba3f1..d5bb51d 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/BBORProtocol.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/BBORProtocol.java @@ -22,7 +22,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; import net.minecraft.core.registries.Registries; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -50,19 +50,19 @@ public class BBORProtocol implements LeavesProtocol { public static final String PROTOCOL_ID = "bbor"; // send - private static final ResourceLocation INITIALIZE_CLIENT = id("initialize"); - private static final ResourceLocation ADD_BOUNDING_BOX = id("add_bounding_box_v2"); - private static final ResourceLocation STRUCTURE_LIST_SYNC = id("structure_list_sync_v1"); + private static final Identifier INITIALIZE_CLIENT = id("initialize"); + private static final Identifier ADD_BOUNDING_BOX = id("add_bounding_box_v2"); + private static final Identifier STRUCTURE_LIST_SYNC = id("structure_list_sync_v1"); // call private static final Map players = new ConcurrentHashMap<>(); private static final Map> playerBoundingBoxesCache = new ConcurrentHashMap<>(); - private static final Map>> dimensionCache = new ConcurrentHashMap<>(); + private static final Map>> dimensionCache = new ConcurrentHashMap<>(); private static boolean initialized = false; @Contract("_ -> new") - public static ResourceLocation id(String path) { - return ResourceLocation.tryBuild(PROTOCOL_ID, path); + public static Identifier id(String path) { + return Identifier.tryBuild(PROTOCOL_ID, path); } @ProtocolHandler.Ticker @@ -86,8 +86,8 @@ public class BBORProtocol implements LeavesProtocol { ServerLevel overworld = MinecraftServer.getServer().overworld(); ProtocolUtils.sendBytebufPacket(player, INITIALIZE_CLIENT, buf -> { buf.writeLong(overworld.getSeed()); - buf.writeInt(overworld.levelData.getSpawnPos().getX()); - buf.writeInt(overworld.levelData.getSpawnPos().getZ()); + buf.writeInt(overworld.levelData.getRespawnData().pos().getX()); + buf.writeInt(overworld.levelData.getRespawnData().pos().getZ()); }); sendStructureList(player); } @@ -114,14 +114,14 @@ public class BBORProtocol implements LeavesProtocol { final Registry structureFeatureRegistry = chunk.getLevel().registryAccess().lookupOrThrow(Registries.STRUCTURE); for (var es : chunk.getAllStarts().entrySet()) { final var optional = structureFeatureRegistry.getResourceKey(es.getKey()); - optional.ifPresent(key -> structures.put(key.location().toString(), es.getValue())); + optional.ifPresent(key -> structures.put(key.identifier().toString(), es.getValue())); } if (!structures.isEmpty()) { - onStructuresLoaded(chunk.getLevel().dimension().location(), structures); + onStructuresLoaded(chunk.getLevel().dimension().identifier(), structures); } } - public static void onStructuresLoaded(@NotNull ResourceLocation dimensionID, @NotNull Map structures) { + public static void onStructuresLoaded(@NotNull Identifier dimensionID, @NotNull Map structures) { Map> cache = getOrCreateCache(dimensionID); for (var entry : structures.entrySet()) { StructureStart structureStart = entry.getValue(); @@ -155,7 +155,7 @@ public class BBORProtocol implements LeavesProtocol { private static void sendStructureList(@NotNull ServerPlayer player) { final Registry structureRegistry = MinecraftServer.getServer().registryAccess().lookupOrThrow(Registries.STRUCTURE); final Set structureIds = structureRegistry.entrySet().stream() - .map(e -> e.getKey().location().toString()).collect(Collectors.toSet()); + .map(e -> e.getKey().identifier().toString()).collect(Collectors.toSet()); ProtocolUtils.sendBytebufPacket(player, STRUCTURE_LIST_SYNC, buf -> { buf.writeVarInt(structureIds.size()); structureIds.forEach(buf::writeUtf); @@ -177,7 +177,7 @@ public class BBORProtocol implements LeavesProtocol { Set boundingBoxes = boundingBoxMap.get(key); ProtocolUtils.sendBytebufPacket(player, ADD_BOUNDING_BOX, buf -> { - buf.writeResourceLocation(entry.getKey()); + buf.writeIdentifier(entry.getKey()); key.serialize(buf); if (boundingBoxes != null && boundingBoxes.size() > 1) { for (BBoundingBox box : boundingBoxes) { @@ -206,7 +206,7 @@ public class BBORProtocol implements LeavesProtocol { dimensionCache.clear(); } - private static Map> getOrCreateCache(ResourceLocation dimensionId) { + private static Map> getOrCreateCache(Identifier dimensionId) { return dimensionCache.computeIfAbsent(dimensionId, dt -> new ConcurrentHashMap<>()); } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java index c379fa2..a40f3e5 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java @@ -18,7 +18,7 @@ package org.leavesmc.leaves.protocol; import fun.bm.lophine.config.modules.function.protocol.XaeroMapProtocolConfig; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -31,17 +31,17 @@ public class XaeroMapProtocol implements LeavesProtocol { public static final String PROTOCOL_ID_MINI = "xaerominimap"; public static final String PROTOCOL_ID_WORLD = "xaeroworldmap"; - private static final ResourceLocation MINIMAP_KEY = idMini("main"); - private static final ResourceLocation WORLDMAP_KEY = idWorld("main"); + private static final Identifier MINIMAP_KEY = idMini("main"); + private static final Identifier WORLDMAP_KEY = idWorld("main"); @Contract("_ -> new") - public static ResourceLocation idMini(String path) { - return ResourceLocation.tryBuild(PROTOCOL_ID_MINI, path); + public static Identifier idMini(String path) { + return Identifier.tryBuild(PROTOCOL_ID_MINI, path); } @Contract("_ -> new") - public static ResourceLocation idWorld(String path) { - return ResourceLocation.tryBuild(PROTOCOL_ID_WORLD, path); + public static Identifier idWorld(String path) { + return Identifier.tryBuild(PROTOCOL_ID_WORLD, path); } public static void onSendWorldInfo(@NotNull ServerPlayer player) { diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java index e2901ac..be5e1b6 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java @@ -19,7 +19,7 @@ package org.leavesmc.leaves.protocol.core; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.NotNull; import java.lang.annotation.ElementType; @@ -29,7 +29,7 @@ import java.lang.annotation.Target; public interface LeavesCustomPayload extends CustomPacketPayload { - Type LEAVES_TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath("leaves", "custom_payload")); + Type LEAVES_TYPE = new Type<>(Identifier.fromNamespaceAndPath("leaves", "custom_payload")); @Override default @NotNull Type type() { diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java index 334658f..09da6c6 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java @@ -23,7 +23,7 @@ import io.netty.buffer.ByteBuf; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import org.leavesmc.leaves.protocol.core.invoker.*; import org.slf4j.Logger; @@ -46,9 +46,9 @@ public class LeavesProtocolManager { private static final Logger LOGGER = LogUtils.getClassLogger(); private static final Map, PayloadReceiverInvokerHolder> PAYLOAD_RECEIVERS = new HashMap<>(); - private static final Map, ResourceLocation> IDS = new HashMap<>(); + private static final Map, Identifier> IDS = new HashMap<>(); private static final Map, StreamCodec> CODECS = new HashMap<>(); - private static final Map> ID2CODEC = new HashMap<>(); + private static final Map> ID2CODEC = new HashMap<>(); private static final Map STRICT_BYTEBUF_RECEIVERS = new HashMap<>(); private static final Map NAMESPACED_BYTEBUF_RECEIVERS = new HashMap<>(); @@ -78,8 +78,8 @@ public class LeavesProtocolManager { } try { final LeavesCustomPayload.ID id = field.getAnnotation(LeavesCustomPayload.ID.class); - if (id != null && field.getType().equals(ResourceLocation.class)) { - IDS.put((Class) clazz, (ResourceLocation) field.get(null)); + if (id != null && field.getType().equals(Identifier.class)) { + IDS.put((Class) clazz, (Identifier) field.get(null)); } final LeavesCustomPayload.Codec codec = field.getAnnotation(LeavesCustomPayload.Codec.class); if (codec != null && field.getType().equals(StreamCodec.class)) { @@ -208,7 +208,7 @@ public class LeavesProtocolManager { } } - public static LeavesCustomPayload decode(ResourceLocation location, FriendlyByteBuf buf) { + public static LeavesCustomPayload decode(Identifier location, FriendlyByteBuf buf) { var codec = ID2CODEC.get(location); if (codec == null) { return null; @@ -222,7 +222,7 @@ public class LeavesProtocolManager { if (location == null || codec == null) { throw new IllegalArgumentException("Payload " + payload.getClass() + " is not configured correctly " + location + " " + codec); } - buf.writeResourceLocation(location); + buf.writeIdentifier(location); codec.encode(ProtocolUtils.decorate(buf), payload); } @@ -233,7 +233,7 @@ public class LeavesProtocolManager { } } - public static boolean handleBytebuf(IdentifierSelector selector, ResourceLocation location, ByteBuf buf) { + public static boolean handleBytebuf(IdentifierSelector selector, Identifier location, ByteBuf buf) { RegistryFriendlyByteBuf buf1 = ProtocolUtils.decorate(buf); BytebufReceiverInvokerHolder holder; if ((holder = STRICT_BYTEBUF_RECEIVERS.get(location.toString())) != null) { @@ -290,7 +290,7 @@ public class LeavesProtocolManager { } public static void handleMinecraftRegister(String channelId, IdentifierSelector selector) { - ResourceLocation location = ResourceLocation.tryParse(channelId); + Identifier location = Identifier.tryParse(channelId); if (location == null) { return; } @@ -320,7 +320,7 @@ public class LeavesProtocolManager { set.add(key); } }); - ProtocolUtils.sendBytebufPacket(player, ResourceLocation.fromNamespaceAndPath("minecraft", "register"), buf -> { + ProtocolUtils.sendBytebufPacket(player, Identifier.fromNamespaceAndPath("minecraft", "register"), buf -> { for (String channel : set) { buf.writeBytes(channel.getBytes(StandardCharsets.US_ASCII)); buf.writeByte(0); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java index 594a073..6fc1ee7 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java @@ -26,7 +26,7 @@ import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; import net.minecraft.network.protocol.common.custom.DiscardedPayload; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.network.ServerCommonPacketListenerImpl; @@ -46,11 +46,11 @@ public class ProtocolUtils { return protocol + "-lophine-" + ServerBuildInfo.buildInfo().asString(ServerBuildInfo.StringRepresentation.VERSION_SIMPLE); } - public static void sendEmptyPacket(ServerPlayer player, ResourceLocation id) { + public static void sendEmptyPacket(ServerPlayer player, Identifier id) { player.connection.send(new ClientboundCustomPayloadPacket(new DiscardedPayload(id, EMPTY))); } - public static void sendBytebufPacket(@NotNull ServerPlayer player, ResourceLocation id, Consumer consumer) { + public static void sendBytebufPacket(@NotNull ServerPlayer player, Identifier id, Consumer consumer) { RegistryFriendlyByteBuf buf = decorate(Unpooled.buffer()); consumer.accept(buf); player.connection.send(new ClientboundCustomPayloadPacket(new DiscardedPayload(id, ByteBufUtil.getBytes(buf)))); @@ -60,11 +60,11 @@ public class ProtocolUtils { player.connection.send(new ClientboundCustomPayloadPacket(payload)); } - public static void sendEmptyPacket(Context context, ResourceLocation id) { + public static void sendEmptyPacket(Context context, Identifier id) { context.connection().send(new ClientboundCustomPayloadPacket(new DiscardedPayload(id, EMPTY))); } - public static void sendBytebufPacket(@NotNull Context context, ResourceLocation id, Consumer consumer) { + public static void sendBytebufPacket(@NotNull Context context, Identifier id, Consumer consumer) { RegistryFriendlyByteBuf buf = decorate(Unpooled.buffer()); consumer.accept(buf); context.connection().send(new ClientboundCustomPayloadPacket(new DiscardedPayload(id, ByteBufUtil.getBytes(buf)))); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/MinecraftRegisterInvokerHolder.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/MinecraftRegisterInvokerHolder.java index c2bf7de..58e7ce4 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/MinecraftRegisterInvokerHolder.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/MinecraftRegisterInvokerHolder.java @@ -17,7 +17,7 @@ package org.leavesmc.leaves.protocol.core.invoker; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.leavesmc.leaves.protocol.core.IdentifierSelector; import org.leavesmc.leaves.protocol.core.LeavesProtocol; import org.leavesmc.leaves.protocol.core.ProtocolHandler; @@ -26,10 +26,10 @@ import java.lang.reflect.Method; public class MinecraftRegisterInvokerHolder extends AbstractInvokerHolder { public MinecraftRegisterInvokerHolder(LeavesProtocol owner, Method invoker, ProtocolHandler.MinecraftRegister handler) { - super(owner, invoker, handler, null, handler.stage().identifier(), ResourceLocation.class); + super(owner, invoker, handler, null, handler.stage().identifier(), Identifier.class); } - public void invoke(IdentifierSelector selector, ResourceLocation id) { + public void invoke(IdentifierSelector selector, Identifier id) { invoke0(false, selector.select(handler.stage()), id); } } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java index 9901608..bed9ccd 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java @@ -25,7 +25,7 @@ import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -35,12 +35,12 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.animal.Animal; -import net.minecraft.world.entity.animal.Chicken; import net.minecraft.world.entity.animal.allay.Allay; import net.minecraft.world.entity.animal.armadillo.Armadillo; +import net.minecraft.world.entity.animal.chicken.Chicken; import net.minecraft.world.entity.animal.frog.Tadpole; import net.minecraft.world.entity.animal.sniffer.Sniffer; -import net.minecraft.world.entity.monster.ZombieVillager; +import net.minecraft.world.entity.monster.zombie.ZombieVillager; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; @@ -68,31 +68,31 @@ import java.util.Set; @LeavesProtocol.Register(namespace = "jade") public class JadeProtocol implements LeavesProtocol { - private static final Logger LOGGER = LogUtils.getLogger(); + public static final Logger LOGGER = LogUtils.getLogger(); public static final String PROTOCOL_ID = "jade"; - public static final String PROTOCOL_VERSION = "8"; - public static final HierarchyLookup> entityDataProviders = new HierarchyLookup<>(Entity.class); - public static final PairHierarchyLookup> blockDataProviders = new PairHierarchyLookup<>(new HierarchyLookup<>(Block.class), new HierarchyLookup<>(BlockEntity.class)); - public static final WrappedHierarchyLookup> itemStorageProviders = WrappedHierarchyLookup.forAccessor(); + public static final String PROTOCOL_VERSION = "9"; + public static final HierarchyLookup> entityDataProviders = new HierarchyLookup<>(Entity.class); + public static final PairHierarchyLookup> blockDataProviders = new PairHierarchyLookup<>(new HierarchyLookup<>(Block.class), new HierarchyLookup<>(BlockEntity.class)); + public static final WrappedHierarchyLookup> itemStorageProviders = WrappedHierarchyLookup.forAccessor(); private static final Set enabledPlayers = new HashSet<>(); - public static PriorityStore priorities; + public static PriorityStore priorities; private static List shearableBlocks = null; @Contract("_ -> new") - public static ResourceLocation id(String path) { - return ResourceLocation.tryBuild(PROTOCOL_ID, path); + public static Identifier id(String path) { + return Identifier.fromNamespaceAndPath(PROTOCOL_ID, path); } @Contract("_ -> new") - public static @NotNull ResourceLocation mc_id(String path) { - return ResourceLocation.withDefaultNamespace(path); + public static @NotNull Identifier mc_id(String path) { + return Identifier.withDefaultNamespace(path); } @ProtocolHandler.Init public static void init() { - priorities = new PriorityStore<>(IJadeProvider::getDefaultPriority, IJadeProvider::getUid); + priorities = new PriorityStore<>(JadeProvider::getDefaultPriority, JadeProvider::getUid); // core plugin blockDataProviders.register(BlockEntity.class, BlockNameProvider.INSTANCE); @@ -178,20 +178,20 @@ public class JadeProtocol implements LeavesProtocol { return; } - List> providers = entityDataProviders.get(entity); + List> providers = entityDataProviders.get(entity); if (providers.isEmpty()) { return; } CompoundTag tag = new CompoundTag(); - for (IServerDataProvider provider : providers) { + for (ServerDataProvider provider : providers) { if (!payload.dataProviders().contains(provider)) { continue; } try { provider.appendServerData(tag, accessor); } catch (Exception e) { - LOGGER.warn("Error while saving data for entity " + entity); + LOGGER.warn("Error while saving data for entity {}", entity); } } tag.putInt("EntityId", entity.getId()); @@ -217,7 +217,7 @@ public class JadeProtocol implements LeavesProtocol { return; } - List> providers; + List> providers; if (blockEntity != null) { providers = blockDataProviders.getMerged(block, blockEntity); } else { @@ -229,14 +229,14 @@ public class JadeProtocol implements LeavesProtocol { } CompoundTag tag = new CompoundTag(); - for (IServerDataProvider provider : providers) { + for (ServerDataProvider provider : providers) { if (!payload.dataProviders().contains(provider)) { continue; } try { provider.appendServerData(tag, accessor); } catch (Exception e) { - LOGGER.warn("Error while saving data for block " + accessor.getBlockState()); + LOGGER.warn("Error while saving data for block {}", accessor.getBlockState()); } } NbtUtils.writeBlockPosToTag(pos, tag); @@ -264,7 +264,7 @@ public class JadeProtocol implements LeavesProtocol { )); } catch (Throwable ignore) { shearableBlocks = List.of(); - LOGGER.warn("Failed to collect shearable blocks"); + LOGGER.error("Failed to collect shearable blocks"); } } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/Accessor.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/Accessor.java index e8a9d7d..24b053d 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/Accessor.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/Accessor.java @@ -17,23 +17,61 @@ package org.leavesmc.leaves.protocol.jade.accessor; +import io.netty.buffer.Unpooled; +import net.minecraft.nbt.ByteArrayTag; import net.minecraft.nbt.Tag; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamEncoder; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.player.Player; import net.minecraft.world.phys.HitResult; +import org.apache.commons.lang3.ArrayUtils; import org.jetbrains.annotations.Nullable; -public interface Accessor { - ServerLevel getLevel(); +import java.util.function.Supplier; - Player getPlayer(); +public abstract class Accessor { - Tag encodeAsNbt(StreamEncoder codec, D value); + private final ServerLevel level; + private final Player player; + private final Supplier hit; + protected boolean verify; + private RegistryFriendlyByteBuf buffer; - T getHitResult(); + public Accessor(ServerLevel level, Player player, Supplier hit) { + this.level = level; + this.player = player; + this.hit = hit; + } + + public ServerLevel getLevel() { + return level; + } + + public Player getPlayer() { + return player; + } + + private RegistryFriendlyByteBuf buffer() { + if (buffer == null) { + buffer = new RegistryFriendlyByteBuf(Unpooled.buffer(), level.registryAccess()); + } + buffer.clear(); + return buffer; + } + + public Tag encodeAsNbt(StreamEncoder streamCodec, D value) { + RegistryFriendlyByteBuf buffer = buffer(); + streamCodec.encode(buffer, value); + ByteArrayTag tag = new ByteArrayTag(ArrayUtils.subarray(buffer.array(), 0, buffer.readableBytes())); + buffer.clear(); + return tag; + } + + public T getHitResult() { + return hit.get(); + } @Nullable - Object getTarget(); + public abstract Object getTarget(); } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/AccessorImpl.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/AccessorImpl.java deleted file mode 100644 index 058ecbe..0000000 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/AccessorImpl.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * This file is part of Leaves (https://github.com/LeavesMC/Leaves) - * - * Leaves is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Leaves is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Leaves. If not, see . - */ - -package org.leavesmc.leaves.protocol.jade.accessor; - -import io.netty.buffer.Unpooled; -import net.minecraft.nbt.ByteArrayTag; -import net.minecraft.nbt.Tag; -import net.minecraft.network.RegistryFriendlyByteBuf; -import net.minecraft.network.codec.StreamEncoder; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.phys.HitResult; -import org.apache.commons.lang3.ArrayUtils; - -import java.util.function.Supplier; - -public abstract class AccessorImpl implements Accessor { - - private final ServerLevel level; - private final Player player; - private final Supplier hit; - protected boolean verify; - private RegistryFriendlyByteBuf buffer; - - public AccessorImpl(ServerLevel level, Player player, Supplier hit) { - this.level = level; - this.player = player; - this.hit = hit; - } - - @Override - public ServerLevel getLevel() { - return level; - } - - @Override - public Player getPlayer() { - return player; - } - - private RegistryFriendlyByteBuf buffer() { - if (buffer == null) { - buffer = new RegistryFriendlyByteBuf(Unpooled.buffer(), level.registryAccess()); - } - buffer.clear(); - return buffer; - } - - @Override - public Tag encodeAsNbt(StreamEncoder streamCodec, D value) { - RegistryFriendlyByteBuf buffer = buffer(); - streamCodec.encode(buffer, value); - ByteArrayTag tag = new ByteArrayTag(ArrayUtils.subarray(buffer.array(), 0, buffer.readableBytes())); - buffer.clear(); - return tag; - } - - @Override - public T getHitResult() { - return hit.get(); - } -} diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessor.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessor.java index e5bdbe6..4dc9d8b 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessor.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessor.java @@ -17,45 +17,135 @@ package org.leavesmc.leaves.protocol.jade.accessor; +import com.google.common.base.Suppliers; import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; -import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Nullable; import java.util.function.Supplier; -public interface BlockAccessor extends Accessor { +/** + * Class to get information of block target and context. + */ +public class BlockAccessor extends Accessor { - Block getBlock(); + private final BlockState blockState; + @Nullable + private final Supplier blockEntity; - BlockState getBlockState(); + private BlockAccessor(Builder builder) { + super(builder.level, builder.player, Suppliers.ofInstance(builder.hit)); + blockState = builder.blockState; + blockEntity = builder.blockEntity; + } - BlockEntity getBlockEntity(); + public Block getBlock() { + return getBlockState().getBlock(); + } - BlockPos getPosition(); + public BlockState getBlockState() { + return blockState; + } - @ApiStatus.NonExtendable - interface Builder { - Builder level(ServerLevel level); + public BlockEntity getBlockEntity() { + return blockEntity == null ? null : blockEntity.get(); + } - Builder player(Player player); + public BlockPos getPosition() { + return getHitResult().getBlockPos(); + } - Builder hit(BlockHitResult hit); + @Nullable + @Override + public Object getTarget() { + return getBlockEntity(); + } - Builder blockState(BlockState state); + public static class Builder { + private ServerLevel level; + private Player player; + private BlockHitResult hit; + private BlockState blockState = Blocks.AIR.defaultBlockState(); + private Supplier blockEntity; - default Builder blockEntity(BlockEntity blockEntity) { - return blockEntity(() -> blockEntity); + public Builder level(ServerLevel level) { + this.level = level; + return this; } - Builder blockEntity(Supplier blockEntity); + public Builder player(Player player) { + this.player = player; + return this; + } - Builder from(BlockAccessor accessor); + public Builder hit(BlockHitResult hit) { + this.hit = hit; + return this; + } - BlockAccessor build(); + public Builder blockState(BlockState blockState) { + this.blockState = blockState; + return this; + } + + public Builder blockEntity(Supplier blockEntity) { + this.blockEntity = blockEntity; + return this; + } + + public Builder from(BlockAccessor accessor) { + level = accessor.getLevel(); + player = accessor.getPlayer(); + hit = accessor.getHitResult(); + blockEntity = accessor::getBlockEntity; + blockState = accessor.getBlockState(); + return this; + } + + public BlockAccessor build() { + return new BlockAccessor(this); + } + } + + public record SyncData(boolean showDetails, BlockHitResult hit, ItemStack serversideRep, CompoundTag data) { + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + ByteBufCodecs.BOOL, + SyncData::showDetails, + StreamCodec.of(FriendlyByteBuf::writeBlockHitResult, FriendlyByteBuf::readBlockHitResult), + SyncData::hit, + ItemStack.OPTIONAL_STREAM_CODEC, + SyncData::serversideRep, + ByteBufCodecs.COMPOUND_TAG, + SyncData::data, + SyncData::new + ); + + public BlockAccessor unpack(ServerPlayer player) { + Supplier blockEntity = null; + BlockState blockState = player.level().getBlockState(hit.getBlockPos()); + if (blockState.hasBlockEntity()) { + blockEntity = Suppliers.memoize(() -> player.level().getBlockEntity(hit.getBlockPos())); + } + return new Builder() + .level(player.level()) + .player(player) + .hit(hit) + .blockState(blockState) + .blockEntity(blockEntity) + .build(); + } } } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessorImpl.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessorImpl.java deleted file mode 100644 index 425603e..0000000 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessorImpl.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * This file is part of Leaves (https://github.com/LeavesMC/Leaves) - * - * Leaves is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Leaves is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Leaves. If not, see . - */ - -package org.leavesmc.leaves.protocol.jade.accessor; - -import com.google.common.base.Suppliers; -import net.minecraft.core.BlockPos; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.RegistryFriendlyByteBuf; -import net.minecraft.network.codec.ByteBufCodecs; -import net.minecraft.network.codec.StreamCodec; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.BlockHitResult; -import org.jetbrains.annotations.Nullable; - -import java.util.function.Supplier; - -/** - * Class to get information of block target and context. - */ -public class BlockAccessorImpl extends AccessorImpl implements BlockAccessor { - - private final BlockState blockState; - @Nullable - private final Supplier blockEntity; - - private BlockAccessorImpl(Builder builder) { - super(builder.level, builder.player, Suppliers.ofInstance(builder.hit)); - blockState = builder.blockState; - blockEntity = builder.blockEntity; - } - - @Override - public Block getBlock() { - return getBlockState().getBlock(); - } - - @Override - public BlockState getBlockState() { - return blockState; - } - - @Override - public BlockEntity getBlockEntity() { - return blockEntity == null ? null : blockEntity.get(); - } - - @Override - public BlockPos getPosition() { - return getHitResult().getBlockPos(); - } - - @Nullable - @Override - public Object getTarget() { - return getBlockEntity(); - } - - public static class Builder implements BlockAccessor.Builder { - private ServerLevel level; - private Player player; - private BlockHitResult hit; - private BlockState blockState = Blocks.AIR.defaultBlockState(); - private Supplier blockEntity; - - @Override - public Builder level(ServerLevel level) { - this.level = level; - return this; - } - - @Override - public Builder player(Player player) { - this.player = player; - return this; - } - - @Override - public Builder hit(BlockHitResult hit) { - this.hit = hit; - return this; - } - - @Override - public Builder blockState(BlockState blockState) { - this.blockState = blockState; - return this; - } - - @Override - public Builder blockEntity(Supplier blockEntity) { - this.blockEntity = blockEntity; - return this; - } - - @Override - public Builder from(BlockAccessor accessor) { - level = accessor.getLevel(); - player = accessor.getPlayer(); - hit = accessor.getHitResult(); - blockEntity = accessor::getBlockEntity; - blockState = accessor.getBlockState(); - return this; - } - - @Override - public BlockAccessor build() { - return new BlockAccessorImpl(this); - } - } - - public record SyncData(boolean showDetails, BlockHitResult hit, BlockState blockState, ItemStack fakeBlock) { - public static final StreamCodec STREAM_CODEC = StreamCodec.composite( - ByteBufCodecs.BOOL, - SyncData::showDetails, - StreamCodec.of(FriendlyByteBuf::writeBlockHitResult, FriendlyByteBuf::readBlockHitResult), - SyncData::hit, - ByteBufCodecs.idMapper(Block.BLOCK_STATE_REGISTRY), - SyncData::blockState, - ItemStack.OPTIONAL_STREAM_CODEC, - SyncData::fakeBlock, - SyncData::new - ); - - public BlockAccessor unpack(ServerPlayer player) { - Supplier blockEntity = null; - if (blockState.hasBlockEntity()) { - blockEntity = Suppliers.memoize(() -> player.level().getBlockEntity(hit.getBlockPos())); - } - return new Builder() - .level(player.level()) - .player(player) - .hit(hit) - .blockState(blockState) - .blockEntity(blockEntity) - .build(); - } - } -} diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessor.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessor.java index e4f89f4..5210ebd 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessor.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessor.java @@ -17,43 +17,107 @@ package org.leavesmc.leaves.protocol.jade.accessor; +import com.google.common.base.Suppliers; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraft.world.phys.EntityHitResult; -import org.jetbrains.annotations.ApiStatus; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; +import org.leavesmc.leaves.protocol.jade.util.CommonUtil; import java.util.function.Supplier; -public interface EntityAccessor extends Accessor { +public class EntityAccessor extends Accessor { - Entity getEntity(); + private final Supplier entity; - /** - * For part entity like ender dragon's, getEntity() will return the parent entity. - */ - Entity getRawEntity(); + public EntityAccessor(Builder builder) { + super(builder.level, builder.player, builder.hit); + entity = builder.entity; + } - @ApiStatus.NonExtendable - interface Builder { - Builder level(ServerLevel level); + public Entity getEntity() { + return CommonUtil.wrapPartEntityParent(getRawEntity()); + } - Builder player(Player player); + public Entity getRawEntity() { + return entity.get(); + } - default Builder hit(EntityHitResult hit) { - return hit(() -> hit); + @NotNull + @Override + public Object getTarget() { + return getEntity(); + } + + public static class Builder { + private ServerLevel level; + private Player player; + private Supplier hit; + private Supplier entity; + + public Builder level(ServerLevel level) { + this.level = level; + return this; } - Builder hit(Supplier hit); - - default Builder entity(Entity entity) { - return entity(() -> entity); + public Builder player(Player player) { + this.player = player; + return this; } - Builder entity(Supplier entity); + public Builder hit(Supplier hit) { + this.hit = hit; + return this; + } - Builder from(EntityAccessor accessor); + public Builder entity(Supplier entity) { + this.entity = entity; + return this; + } - EntityAccessor build(); + public Builder from(EntityAccessor accessor) { + level = accessor.getLevel(); + player = accessor.getPlayer(); + hit = accessor::getHitResult; + entity = accessor::getEntity; + return this; + } + + public EntityAccessor build() { + return new EntityAccessor(this); + } + } + + public record SyncData(boolean showDetails, int id, int partIndex, Vec3 hitVec, CompoundTag data) { + public static final StreamCodec STREAM_CODEC = StreamCodec.composite( + ByteBufCodecs.BOOL, + SyncData::showDetails, + ByteBufCodecs.VAR_INT, + SyncData::id, + ByteBufCodecs.VAR_INT, + SyncData::partIndex, + ByteBufCodecs.VECTOR3F.map(Vec3::new, Vec3::toVector3f), + SyncData::hitVec, + ByteBufCodecs.COMPOUND_TAG, + SyncData::data, + SyncData::new + ); + + public EntityAccessor unpack(ServerPlayer player) { + Supplier entity = Suppliers.memoize(() -> CommonUtil.getPartEntity(player.level().getEntity(id), partIndex)); + return new Builder() + .level(player.level()) + .player(player) + .entity(entity) + .hit(Suppliers.memoize(() -> new EntityHitResult(entity.get(), hitVec))) + .build(); + } } } \ No newline at end of file diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessorImpl.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessorImpl.java deleted file mode 100644 index 6b1ccb6..0000000 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessorImpl.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * This file is part of Leaves (https://github.com/LeavesMC/Leaves) - * - * Leaves is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Leaves is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Leaves. If not, see . - */ - -package org.leavesmc.leaves.protocol.jade.accessor; - -import com.google.common.base.Suppliers; -import net.minecraft.network.RegistryFriendlyByteBuf; -import net.minecraft.network.codec.ByteBufCodecs; -import net.minecraft.network.codec.StreamCodec; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.phys.EntityHitResult; -import net.minecraft.world.phys.Vec3; -import org.jetbrains.annotations.NotNull; -import org.leavesmc.leaves.protocol.jade.util.CommonUtil; - -import java.util.function.Supplier; - -public class EntityAccessorImpl extends AccessorImpl implements EntityAccessor { - - private final Supplier entity; - - public EntityAccessorImpl(Builder builder) { - super(builder.level, builder.player, builder.hit); - entity = builder.entity; - } - - @Override - public Entity getEntity() { - return CommonUtil.wrapPartEntityParent(getRawEntity()); - } - - @Override - public Entity getRawEntity() { - return entity.get(); - } - - @NotNull - @Override - public Object getTarget() { - return getEntity(); - } - - public static class Builder implements EntityAccessor.Builder { - private ServerLevel level; - private Player player; - private Supplier hit; - private Supplier entity; - - @Override - public Builder level(ServerLevel level) { - this.level = level; - return this; - } - - @Override - public Builder player(Player player) { - this.player = player; - return this; - } - - - @Override - public Builder hit(Supplier hit) { - this.hit = hit; - return this; - } - - @Override - public Builder entity(Supplier entity) { - this.entity = entity; - return this; - } - - @Override - public Builder from(EntityAccessor accessor) { - level = accessor.getLevel(); - player = accessor.getPlayer(); - hit = accessor::getHitResult; - entity = accessor::getEntity; - return this; - } - - @Override - public EntityAccessor build() { - return new EntityAccessorImpl(this); - } - } - - public record SyncData(boolean showDetails, int id, int partIndex, Vec3 hitVec) { - public static final StreamCodec STREAM_CODEC = StreamCodec.composite( - ByteBufCodecs.BOOL, - SyncData::showDetails, - ByteBufCodecs.VAR_INT, - SyncData::id, - ByteBufCodecs.VAR_INT, - SyncData::partIndex, - ByteBufCodecs.VECTOR3F.map(Vec3::new, Vec3::toVector3f), - SyncData::hitVec, - SyncData::new - ); - - public EntityAccessor unpack(ServerPlayer player) { - Supplier entity = Suppliers.memoize(() -> CommonUtil.getPartEntity(player.level().getEntity(id), partIndex)); - return new EntityAccessorImpl.Builder() - .level(player.level()) - .player(player) - .entity(entity) - .hit(Suppliers.memoize(() -> new EntityHitResult(entity.get(), hitVec))) - .build(); - } - } -} \ No newline at end of file diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java index bfeabeb..edd83a8 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java @@ -20,14 +20,14 @@ package org.leavesmc.leaves.protocol.jade.payload; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; import org.leavesmc.leaves.protocol.jade.JadeProtocol; public record ClientHandshakePayload(String protocolVersion) implements LeavesCustomPayload { @ID - private static final ResourceLocation PACKET_CLIENT_HANDSHAKE = JadeProtocol.id("client_handshake"); + private static final Identifier PACKET_CLIENT_HANDSHAKE = JadeProtocol.id("client_handshake"); @Codec private static final StreamCodec CODEC = StreamCodec.composite( diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ReceiveDataPayload.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ReceiveDataPayload.java index 50b6666..ebb882f 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ReceiveDataPayload.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ReceiveDataPayload.java @@ -21,14 +21,14 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; import org.leavesmc.leaves.protocol.jade.JadeProtocol; public record ReceiveDataPayload(CompoundTag tag) implements LeavesCustomPayload { @ID - private static final ResourceLocation PACKET_RECEIVE_DATA = JadeProtocol.id("receive_data"); + private static final Identifier PACKET_RECEIVE_DATA = JadeProtocol.id("receive_data"); @Codec private static final StreamCodec CODEC = StreamCodec.composite( diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java index 8a85dd9..b85cf0d 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java @@ -21,30 +21,29 @@ import io.netty.buffer.ByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; import org.leavesmc.leaves.protocol.jade.JadeProtocol; import org.leavesmc.leaves.protocol.jade.accessor.BlockAccessor; -import org.leavesmc.leaves.protocol.jade.accessor.BlockAccessorImpl; -import org.leavesmc.leaves.protocol.jade.provider.IServerDataProvider; +import org.leavesmc.leaves.protocol.jade.provider.ServerDataProvider; import java.util.List; import java.util.Objects; import static org.leavesmc.leaves.protocol.jade.JadeProtocol.blockDataProviders; -public record RequestBlockPayload(BlockAccessorImpl.SyncData data, - List<@Nullable IServerDataProvider> dataProviders) implements LeavesCustomPayload { +public record RequestBlockPayload(BlockAccessor.SyncData data, + List<@Nullable ServerDataProvider> dataProviders) implements LeavesCustomPayload { @ID - private static final ResourceLocation PACKET_REQUEST_BLOCK = JadeProtocol.id("request_block"); + private static final Identifier PACKET_REQUEST_BLOCK = JadeProtocol.id("request_block"); @Codec private static final StreamCodec CODEC = StreamCodec.composite( - BlockAccessorImpl.SyncData.STREAM_CODEC, + BlockAccessor.SyncData.STREAM_CODEC, RequestBlockPayload::data, - ByteBufCodecs.>list() + ByteBufCodecs.>list() .apply(ByteBufCodecs.idMapper( $ -> Objects.requireNonNull(blockDataProviders.idMapper()).byId($), $ -> Objects.requireNonNull(blockDataProviders.idMapper()).getIdOrThrow($))), diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java index a15a120..3924c2e 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java @@ -21,30 +21,29 @@ import io.netty.buffer.ByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; import org.leavesmc.leaves.protocol.jade.JadeProtocol; import org.leavesmc.leaves.protocol.jade.accessor.EntityAccessor; -import org.leavesmc.leaves.protocol.jade.accessor.EntityAccessorImpl; -import org.leavesmc.leaves.protocol.jade.provider.IServerDataProvider; +import org.leavesmc.leaves.protocol.jade.provider.ServerDataProvider; import java.util.List; import java.util.Objects; import static org.leavesmc.leaves.protocol.jade.JadeProtocol.entityDataProviders; -public record RequestEntityPayload(EntityAccessorImpl.SyncData data, - List<@Nullable IServerDataProvider> dataProviders) implements LeavesCustomPayload { +public record RequestEntityPayload(EntityAccessor.SyncData data, + List<@Nullable ServerDataProvider> dataProviders) implements LeavesCustomPayload { @ID - private static final ResourceLocation PACKET_REQUEST_ENTITY = JadeProtocol.id("request_entity"); + private static final Identifier PACKET_REQUEST_ENTITY = JadeProtocol.id("request_entity"); @Codec private static final StreamCodec CODEC = StreamCodec.composite( - EntityAccessorImpl.SyncData.STREAM_CODEC, + EntityAccessor.SyncData.STREAM_CODEC, RequestEntityPayload::data, - ByteBufCodecs.>list() + ByteBufCodecs.>list() .apply(ByteBufCodecs.idMapper( $ -> Objects.requireNonNull(entityDataProviders.idMapper()).byId($), $ -> Objects.requireNonNull(entityDataProviders.idMapper()).getIdOrThrow($) diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java index 742a54a..e5c088f 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java @@ -24,7 +24,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.block.Block; import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; import org.leavesmc.leaves.protocol.jade.JadeProtocol; @@ -35,24 +35,24 @@ import java.util.Map; import static org.leavesmc.leaves.protocol.jade.util.JadeCodec.PRIMITIVE_STREAM_CODEC; public record ServerHandshakePayload( - Map serverConfig, + Map serverConfig, List shearableBlocks, - List blockProviderIds, - List entityProviderIds + List blockProviderIds, + List entityProviderIds ) implements LeavesCustomPayload { @ID - private static final ResourceLocation PACKET_SERVER_HANDSHAKE = JadeProtocol.id("server_handshake"); + private static final Identifier PACKET_SERVER_HANDSHAKE = JadeProtocol.id("server_handshake"); @Codec private static final StreamCodec CODEC = StreamCodec.composite( - ByteBufCodecs.map(Maps::newHashMapWithExpectedSize, ResourceLocation.STREAM_CODEC, PRIMITIVE_STREAM_CODEC), + ByteBufCodecs.map(Maps::newHashMapWithExpectedSize, Identifier.STREAM_CODEC, PRIMITIVE_STREAM_CODEC), ServerHandshakePayload::serverConfig, ByteBufCodecs.registry(Registries.BLOCK).apply(ByteBufCodecs.list()), ServerHandshakePayload::shearableBlocks, - ByteBufCodecs.list().apply(ResourceLocation.STREAM_CODEC), + ByteBufCodecs.list().apply(Identifier.STREAM_CODEC), ServerHandshakePayload::blockProviderIds, - ByteBufCodecs.list().apply(ResourceLocation.STREAM_CODEC), + ByteBufCodecs.list().apply(Identifier.STREAM_CODEC), ServerHandshakePayload::entityProviderIds, ServerHandshakePayload::new ); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java index 098422e..aa495ef 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java @@ -19,13 +19,12 @@ package org.leavesmc.leaves.protocol.jade.provider; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import com.mojang.logging.LogUtils; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.Container; import net.minecraft.world.LockCode; import net.minecraft.world.RandomizableContainer; import net.minecraft.world.WorldlyContainerHolder; -import net.minecraft.world.entity.animal.horse.AbstractHorse; +import net.minecraft.world.entity.animal.equine.AbstractHorse; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.vehicle.ContainerEntity; import net.minecraft.world.inventory.PlayerEnderChestContainer; @@ -42,20 +41,17 @@ import org.leavesmc.leaves.protocol.jade.accessor.BlockAccessor; import org.leavesmc.leaves.protocol.jade.util.ItemCollector; import org.leavesmc.leaves.protocol.jade.util.ItemIterator; import org.leavesmc.leaves.protocol.jade.util.ViewGroup; -import org.slf4j.Logger; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -public enum ItemStorageExtensionProvider implements IServerExtensionProvider { +public enum ItemStorageExtensionProvider implements ServerExtensionProvider { INSTANCE; public static final Cache> targetCache = CacheBuilder.newBuilder().weakKeys().expireAfterAccess(60, TimeUnit.SECONDS).build(); - private static final ResourceLocation UNIVERSAL_ITEM_STORAGE = JadeProtocol.mc_id("item_storage.default"); - - private static final Logger LOGGER = LogUtils.getLogger(); + private static final Identifier UNIVERSAL_ITEM_STORAGE = JadeProtocol.mc_id("item_storage.default"); public static ItemCollector createItemCollector(Accessor request) { if (request.getTarget() instanceof AbstractHorse) { @@ -146,7 +142,7 @@ public enum ItemStorageExtensionProvider implements IServerExtensionProvider createItemCollector(request)); } catch (ExecutionException e) { - LOGGER.warn("Failed to get item collector for " + target); + JadeProtocol.LOGGER.error("Failed to get item collector for {}", target); return null; } @@ -154,7 +150,7 @@ public enum ItemStorageExtensionProvider implements IServerExtensionProvider> implements IServerDataProvider { +public abstract class ItemStorageProvider> implements ServerDataProvider { - private static final StreamCodec>>> STREAM_CODEC = ViewGroup.listCodec(ItemStack.OPTIONAL_STREAM_CODEC); + private static final StreamCodec>>> STREAM_CODEC = ViewGroup.listCodec(ItemStack.OPTIONAL_STREAM_CODEC); - private static final ResourceLocation UNIVERSAL_ITEM_STORAGE = JadeProtocol.mc_id("item_storage"); + private static final Identifier UNIVERSAL_ITEM_STORAGE = JadeProtocol.mc_id("item_storage"); public static ForBlock getBlock() { return ForBlock.INSTANCE; @@ -56,7 +56,7 @@ public abstract class ItemStorageProvider> implements ISer public static void putData(CompoundTag tag, @NotNull Accessor accessor) { Object target = accessor.getTarget(); Player player = accessor.getPlayer(); - Map.Entry>> entry = CommonUtil.getServerExtensionData(accessor, JadeProtocol.itemStorageProviders); + Map.Entry>> entry = CommonUtil.getServerExtensionData(accessor, JadeProtocol.itemStorageProviders); if (entry != null) { List> groups = entry.getValue(); for (ViewGroup group : groups) { @@ -77,7 +77,7 @@ public abstract class ItemStorageProvider> implements ISer } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return UNIVERSAL_ITEM_STORAGE; } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IJadeProvider.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/JadeProvider.java similarity index 88% rename from lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IJadeProvider.java rename to lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/JadeProvider.java index 391fd21..2d12e2a 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IJadeProvider.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/JadeProvider.java @@ -17,11 +17,11 @@ package org.leavesmc.leaves.protocol.jade.provider; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; -public interface IJadeProvider { +public interface JadeProvider { - ResourceLocation getUid(); + Identifier getUid(); default int getDefaultPriority() { return 0; diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IServerDataProvider.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ServerDataProvider.java similarity index 91% rename from lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IServerDataProvider.java rename to lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ServerDataProvider.java index 11b37b0..3c9ca54 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IServerDataProvider.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ServerDataProvider.java @@ -20,6 +20,6 @@ package org.leavesmc.leaves.protocol.jade.provider; import net.minecraft.nbt.CompoundTag; import org.leavesmc.leaves.protocol.jade.accessor.Accessor; -public interface IServerDataProvider> extends IJadeProvider { +public interface ServerDataProvider> extends JadeProvider { void appendServerData(CompoundTag data, T accessor); } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IServerExtensionProvider.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ServerExtensionProvider.java similarity index 93% rename from lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IServerExtensionProvider.java rename to lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ServerExtensionProvider.java index 0cffe35..bbd3b9b 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IServerExtensionProvider.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ServerExtensionProvider.java @@ -22,6 +22,6 @@ import org.leavesmc.leaves.protocol.jade.util.ViewGroup; import java.util.List; -public interface IServerExtensionProvider extends IJadeProvider { +public interface ServerExtensionProvider extends JadeProvider { List> getGroups(Accessor request); } \ No newline at end of file diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/StreamServerDataProvider.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/StreamServerDataProvider.java index d007151..4e192c4 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/StreamServerDataProvider.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/StreamServerDataProvider.java @@ -23,7 +23,7 @@ import net.minecraft.network.codec.StreamCodec; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.protocol.jade.accessor.Accessor; -public interface StreamServerDataProvider, D> extends IServerDataProvider { +public interface StreamServerDataProvider, D> extends ServerDataProvider { @Override default void appendServerData(CompoundTag data, T accessor) { diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BeehiveProvider.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BeehiveProvider.java index c48c7dc..7cec4fa 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BeehiveProvider.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BeehiveProvider.java @@ -20,7 +20,7 @@ package org.leavesmc.leaves.protocol.jade.provider.block; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.block.entity.BeehiveBlockEntity; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.jade.JadeProtocol; @@ -30,7 +30,7 @@ import org.leavesmc.leaves.protocol.jade.provider.StreamServerDataProvider; public enum BeehiveProvider implements StreamServerDataProvider { INSTANCE; - private static final ResourceLocation MC_BEEHIVE = JadeProtocol.mc_id("beehive"); + private static final Identifier MC_BEEHIVE = JadeProtocol.mc_id("beehive"); @Override public @NotNull StreamCodec streamCodec() { @@ -45,7 +45,7 @@ public enum BeehiveProvider implements StreamServerDataProvider { INSTANCE; - private static final ResourceLocation CORE_OBJECT_NAME = JadeProtocol.id("object_name"); + private static final Identifier CORE_OBJECT_NAME = JadeProtocol.id("object_name"); @Override @Nullable @@ -66,7 +66,7 @@ public enum BlockNameProvider implements StreamServerDataProvider { INSTANCE; - private static final ResourceLocation MC_BREWING_STAND = JadeProtocol.mc_id("brewing_stand"); + private static final Identifier MC_BREWING_STAND = JadeProtocol.mc_id("brewing_stand"); @Override public @NotNull Data streamData(@NotNull BlockAccessor accessor) { @@ -45,7 +45,7 @@ public enum BrewingStandProvider implements StreamServerDataProvider { +public enum CampfireProvider implements ServerExtensionProvider { INSTANCE; - private static final MapCodec COOKING_TIME_CODEC = Codec.INT.fieldOf("jade:cooking"); - private static final ResourceLocation MC_CAMPFIRE = JadeProtocol.mc_id("campfire"); + private static final Identifier MC_CAMPFIRE = JadeProtocol.mc_id("campfire"); @Override public @Nullable @Unmodifiable List> getGroups(@NotNull Accessor request) { @@ -53,9 +49,8 @@ public enum CampfireProvider implements IServerExtensionProvider { } stack = stack.copy(); - CustomData customData = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY) - .update(NbtOps.INSTANCE, COOKING_TIME_CODEC, campfire.cookingTime[i] - campfire.cookingProgress[i]) - .getOrThrow(); + int time = campfire.cookingTime[i] - campfire.cookingProgress[i]; + CustomData customData = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).update(tag -> tag.putInt("jade:cooking", time)); stack.set(DataComponents.CUSTOM_DATA, customData); list.add(stack); @@ -66,7 +61,7 @@ public enum CampfireProvider implements IServerExtensionProvider { } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_CAMPFIRE; } } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java index 4d0a9b9..dbd38a8 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java @@ -19,7 +19,7 @@ package org.leavesmc.leaves.protocol.jade.provider.block; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.ChiseledBookShelfBlock; import net.minecraft.world.level.block.entity.ChiseledBookShelfBlockEntity; @@ -30,14 +30,16 @@ import org.leavesmc.leaves.protocol.jade.accessor.BlockAccessor; import org.leavesmc.leaves.protocol.jade.provider.ItemStorageProvider; import org.leavesmc.leaves.protocol.jade.provider.StreamServerDataProvider; +import static net.minecraft.world.level.block.CampfireBlock.FACING; + public enum ChiseledBookshelfProvider implements StreamServerDataProvider { INSTANCE; - private static final ResourceLocation MC_CHISELED_BOOKSHELF = JadeProtocol.mc_id("chiseled_bookshelf"); + private static final Identifier MC_CHISELED_BOOKSHELF = JadeProtocol.mc_id("shelf"); @Override public @Nullable ItemStack streamData(@NotNull BlockAccessor accessor) { - int slot = ((ChiseledBookShelfBlock) accessor.getBlock()).getHitSlot(accessor.getHitResult(), accessor.getBlockState()).orElse(-1); + int slot = ((ChiseledBookShelfBlock) accessor.getBlock()).getHitSlot(accessor.getHitResult(), accessor.getBlockState().getValue(FACING)).orElse(-1); if (slot == -1) { return null; } @@ -50,7 +52,7 @@ public enum ChiseledBookshelfProvider implements StreamServerDataProvider { INSTANCE; - private static final ResourceLocation MC_COMMAND_BLOCK = JadeProtocol.mc_id("command_block"); + private static final Identifier MC_COMMAND_BLOCK = JadeProtocol.mc_id("command_block"); @Nullable public String streamData(@NotNull BlockAccessor accessor) { @@ -51,7 +51,7 @@ public enum CommandBlockProvider implements StreamServerDataProvider { INSTANCE; - private static final ResourceLocation MC_FURNACE = JadeProtocol.mc_id("furnace"); + private static final Identifier MC_FURNACE = JadeProtocol.mc_id("furnace"); @Override public @NotNull Data streamData(@NotNull BlockAccessor accessor) { @@ -51,7 +51,7 @@ public enum FurnaceProvider implements StreamServerDataProvider { INSTANCE; - private static final ResourceLocation MC_HOPPER_LOCK = JadeProtocol.mc_id("hopper_lock"); + private static final Identifier MC_HOPPER_LOCK = JadeProtocol.mc_id("hopper_lock"); @Override public Boolean streamData(@NotNull BlockAccessor accessor) { @@ -43,7 +43,7 @@ public enum HopperLockProvider implements StreamServerDataProvider { INSTANCE; - private static final ResourceLocation MC_JUKEBOX = JadeProtocol.mc_id("jukebox"); + private static final Identifier MC_JUKEBOX = JadeProtocol.mc_id("jukebox"); @Override public @NotNull ItemStack streamData(BlockAccessor accessor) { @@ -43,7 +43,7 @@ public enum JukeboxProvider implements StreamServerDataProvider { INSTANCE; - private static final ResourceLocation MC_LECTERN = JadeProtocol.mc_id("lectern"); + private static final Identifier MC_LECTERN = JadeProtocol.mc_id("lectern"); @Override public @NotNull ItemStack streamData(@NotNull BlockAccessor accessor) { @@ -44,7 +44,7 @@ public enum LecternProvider implements StreamServerDataProvider { INSTANCE; - private static final ResourceLocation MC_MOB_SPAWNER_COOLDOWN = JadeProtocol.mc_id("mob_spawner.cooldown"); + private static final Identifier MC_MOB_SPAWNER_COOLDOWN = JadeProtocol.mc_id("mob_spawner.cooldown"); @Override public @Nullable Integer streamData(@NotNull BlockAccessor accessor) { @@ -53,7 +53,7 @@ public enum MobSpawnerCooldownProvider implements StreamServerDataProvider { +public enum RedstoneProvider implements ServerDataProvider { INSTANCE; - private static final ResourceLocation MC_REDSTONE = JadeProtocol.mc_id("redstone"); + private static final Identifier MC_REDSTONE = JadeProtocol.mc_id("redstone"); @Override public void appendServerData(CompoundTag data, @NotNull BlockAccessor accessor) { @@ -47,7 +47,7 @@ public enum RedstoneProvider implements IServerDataProvider { } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_REDSTONE; } } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/AnimalOwnerProvider.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/AnimalOwnerProvider.java index eee70fa..78e895b 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/AnimalOwnerProvider.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/AnimalOwnerProvider.java @@ -17,26 +17,31 @@ package org.leavesmc.leaves.protocol.jade.provider.entity; +import com.mojang.authlib.GameProfile; import net.minecraft.network.RegistryFriendlyByteBuf; -import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.ComponentSerialization; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; +import net.minecraft.server.Services; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.players.NameAndId; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityReference; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.OwnableEntity; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.protocol.jade.JadeProtocol; import org.leavesmc.leaves.protocol.jade.accessor.EntityAccessor; import org.leavesmc.leaves.protocol.jade.provider.StreamServerDataProvider; -import org.leavesmc.leaves.protocol.jade.util.CommonUtil; import java.util.UUID; -public enum AnimalOwnerProvider implements StreamServerDataProvider { +public enum AnimalOwnerProvider implements StreamServerDataProvider { INSTANCE; - private static final ResourceLocation MC_ANIMAL_OWNER = JadeProtocol.mc_id("animal_owner"); + private static final Identifier MC_ANIMAL_OWNER = JadeProtocol.mc_id("animal_owner"); public static UUID getOwnerUUID(Entity entity) { if (entity instanceof OwnableEntity ownableEntity) { @@ -49,17 +54,37 @@ public enum AnimalOwnerProvider implements StreamServerDataProvider streamCodec() { - return ByteBufCodecs.STRING_UTF8.cast(); + public @NotNull StreamCodec streamCodec() { + return ComponentSerialization.STREAM_CODEC; } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_ANIMAL_OWNER; } } \ No newline at end of file diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/MobBreedingProvider.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/MobBreedingProvider.java index be53df3..301b917 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/MobBreedingProvider.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/MobBreedingProvider.java @@ -20,7 +20,7 @@ package org.leavesmc.leaves.protocol.jade.provider.entity; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.animal.Animal; import net.minecraft.world.entity.animal.allay.Allay; @@ -33,7 +33,7 @@ import org.leavesmc.leaves.protocol.jade.provider.StreamServerDataProvider; public enum MobBreedingProvider implements StreamServerDataProvider { INSTANCE; - private static final ResourceLocation MC_MOB_BREEDING = JadeProtocol.mc_id("mob_breeding"); + private static final Identifier MC_MOB_BREEDING = JadeProtocol.mc_id("mob_breeding"); @Override public @Nullable Integer streamData(@NotNull EntityAccessor accessor) { @@ -55,7 +55,7 @@ public enum MobBreedingProvider implements StreamServerDataProvider { INSTANCE; - private static final ResourceLocation MC_MOB_GROWTH = JadeProtocol.mc_id("mob_growth"); + private static final Identifier MC_MOB_GROWTH = JadeProtocol.mc_id("mob_growth"); @Override public @Nullable Integer streamData(@NotNull EntityAccessor accessor) { @@ -54,7 +54,7 @@ public enum MobGrowthProvider implements StreamServerDataProvider { +public enum NextEntityDropProvider implements ServerDataProvider { INSTANCE; - private static final ResourceLocation MC_NEXT_ENTITY_DROP = JadeProtocol.mc_id("next_entity_drop"); + private static final Identifier MC_NEXT_ENTITY_DROP = JadeProtocol.mc_id("next_entity_drop"); @Override public void appendServerData(CompoundTag tag, @NotNull EntityAccessor accessor) { @@ -53,7 +53,7 @@ public enum NextEntityDropProvider implements IServerDataProvider { INSTANCE; - private static final ResourceLocation MC_PET_ARMOR = JadeProtocol.mc_id("pet_armor"); + private static final Identifier MC_PET_ARMOR = JadeProtocol.mc_id("pet_armor"); @Nullable @Override @@ -46,7 +46,7 @@ public enum PetArmorProvider implements StreamServerDataProvider> STREAM_CODEC = ByteBufCodecs.list() .apply(MobEffectInstance.STREAM_CODEC); - private static final ResourceLocation MC_POTION_EFFECTS = JadeProtocol.mc_id("potion_effects"); + private static final Identifier MC_POTION_EFFECTS = JadeProtocol.mc_id("potion_effects"); @Override @Nullable @@ -56,7 +56,7 @@ public enum StatusEffectsProvider implements StreamServerDataProvider { INSTANCE; - private static final ResourceLocation MC_ZOMBIE_VILLAGER = JadeProtocol.mc_id("zombie_villager"); + private static final Identifier MC_ZOMBIE_VILLAGER = JadeProtocol.mc_id("zombie_villager"); @Override public @Nullable Integer streamData(@NotNull EntityAccessor accessor) { @@ -45,7 +45,7 @@ public enum ZombieVillagerProvider implements StreamServerDataProvider optional = SkullBlockEntity.fetchGameProfile(String.valueOf(uuid)).getNow(Optional.empty()); - return optional.map(GameProfile::getName).orElse(null); - } - - - public static Map.Entry>> getServerExtensionData( + public static Map.Entry>> getServerExtensionData( Accessor accessor, - WrappedHierarchyLookup> lookup) { + WrappedHierarchyLookup> lookup) { for (var provider : lookup.wrappedGet(accessor)) { List> groups; try { groups = provider.getGroups(accessor); } catch (Exception e) { - LOGGER.warn(e.toString()); + JadeProtocol.LOGGER.error(e.toString()); continue; } if (groups != null) { diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java index 592b4ed..191bd4d 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java @@ -21,20 +21,17 @@ import com.google.common.base.Preconditions; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.collect.*; -import com.mojang.logging.LogUtils; import net.minecraft.core.IdMapper; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.protocol.jade.JadeProtocol; -import org.leavesmc.leaves.protocol.jade.provider.IJadeProvider; -import org.slf4j.Logger; +import org.leavesmc.leaves.protocol.jade.provider.JadeProvider; import java.util.*; import java.util.concurrent.ExecutionException; import java.util.stream.Stream; -public class HierarchyLookup implements IHierarchyLookup { - private static final Logger LOGGER = LogUtils.getLogger(); +public class HierarchyLookup implements IHierarchyLookup { private final Class baseClass; private final Cache, List> resultCache = CacheBuilder.newBuilder().build(); private final boolean singleton; @@ -89,7 +86,7 @@ public class HierarchyLookup implements IHierarchyLooku return list; }); } catch (ExecutionException e) { - LOGGER.warn("HierarchyLookup error", e); + JadeProtocol.LOGGER.warn("HierarchyLookup error", e); } return List.of(); } @@ -117,12 +114,12 @@ public class HierarchyLookup implements IHierarchyLooku } @Override - public void loadComplete(PriorityStore priorityStore) { + public void loadComplete(PriorityStore priorityStore) { objects.asMap().forEach((clazz, list) -> { if (list.size() < 2) { return; } - Set set = Sets.newHashSetWithExpectedSize(list.size()); + Set set = Sets.newHashSetWithExpectedSize(list.size()); for (T provider : list) { if (set.contains(provider.getUid())) { throw new IllegalStateException("Duplicate UID: %s for %s".formatted(provider.getUid(), list.stream() diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java index 7279f46..b350f90 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java @@ -19,17 +19,17 @@ package org.leavesmc.leaves.protocol.jade.util; import com.google.common.collect.Streams; import net.minecraft.core.IdMapper; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.protocol.jade.JadeProtocol; -import org.leavesmc.leaves.protocol.jade.provider.IJadeProvider; +import org.leavesmc.leaves.protocol.jade.provider.JadeProvider; import java.util.*; import java.util.stream.Stream; -public interface IHierarchyLookup { +public interface IHierarchyLookup { - Comparator COMPARATOR = Comparator.comparingInt(provider -> JadeProtocol.priorities.byValue(provider)); + Comparator COMPARATOR = Comparator.comparingInt(provider -> JadeProtocol.priorities.byValue(provider)); default IHierarchyLookup cast() { return this; @@ -40,9 +40,9 @@ public interface IHierarchyLookup { @Nullable IdMapper idMapper(); - default List mappedIds() { + default List mappedIds() { return Streams.stream(Objects.requireNonNull(idMapper())) - .map(IJadeProvider::getUid) + .map(JadeProvider::getUid) .toList(); } @@ -65,7 +65,7 @@ public interface IHierarchyLookup { void invalidate(); - void loadComplete(PriorityStore priorityStore); + void loadComplete(PriorityStore priorityStore); default IdMapper createIdMapper() { List list = entries().flatMap(entry -> entry.getValue().stream()).toList(); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemCollector.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemCollector.java index 281f30e..e67639b 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemCollector.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemCollector.java @@ -28,13 +28,13 @@ import net.minecraft.world.item.component.TooltipDisplay; import org.leavesmc.leaves.protocol.jade.accessor.Accessor; import java.util.List; -import java.util.Locale; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Predicate; public class ItemCollector { public static final int MAX_SIZE = 54; public static final ItemCollector EMPTY = new ItemCollector<>(null); + private static final CompoundTag IGNORED_TAG = new CompoundTag(); private static final Predicate SHOWN = stack -> { if (stack.isEmpty()) { return false; @@ -43,12 +43,8 @@ public class ItemCollector { return false; } if (stack.hasNonDefault(DataComponents.CUSTOM_MODEL_DATA) || stack.hasNonDefault(DataComponents.ITEM_MODEL)) { - CompoundTag tag = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).copyTag(); - for (String key : tag.keySet()) { - if (key.toLowerCase(Locale.ENGLISH).endsWith("clear") && tag.getBooleanOr(key, true)) { - return false; - } - } + CustomData data = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY); + return !data.matchedBy(IGNORED_TAG); } return true; }; @@ -59,6 +55,10 @@ public class ItemCollector { public boolean lastTimeIsEmpty; public List> mergedResult; + static { + IGNORED_TAG.putBoolean("__JadeClear", true); + } + public ItemCollector(ItemIterator iterator) { this.iterator = iterator; } @@ -72,12 +72,12 @@ public class ItemCollector { return null; } long currentVersion = iterator.getVersion(container); - long gameTimeReforged = System.currentTimeMillis() / 50; + long gameTime = request.getLevel().getServer().getTickCount(); if (mergedResult != null && iterator.isFinished()) { if (version == currentVersion) { return mergedResult; // content not changed } - if (lastTimeFinished + 5 > gameTimeReforged) { + if (lastTimeFinished + 5 > gameTime) { return mergedResult; // avoid update too frequently } iterator.reset(); @@ -104,7 +104,7 @@ public class ItemCollector { mergedResult = groups; lastTimeIsEmpty = mergedResult.getFirst().views.isEmpty(); version = currentVersion; - lastTimeFinished = gameTimeReforged; + lastTimeFinished = gameTime; items.clear(); } return groups; diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/LootTableMineableCollector.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/LootTableMineableCollector.java index d359f4c..cd11ac5 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/LootTableMineableCollector.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/LootTableMineableCollector.java @@ -18,7 +18,7 @@ package org.leavesmc.leaves.protocol.jade.util; import com.google.common.collect.Lists; -import net.minecraft.advancements.critereon.ItemPredicate; +import net.minecraft.advancements.criterion.ItemPredicate; import net.minecraft.core.Holder; import net.minecraft.core.HolderGetter; import net.minecraft.core.registries.BuiltInRegistries; diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java index 2d8ca38..0197ae4 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java @@ -21,13 +21,12 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; -import com.mojang.logging.LogUtils; import net.minecraft.core.IdMapper; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.Nullable; -import org.leavesmc.leaves.protocol.jade.provider.IJadeProvider; -import org.slf4j.Logger; +import org.leavesmc.leaves.protocol.jade.JadeProtocol; +import org.leavesmc.leaves.protocol.jade.provider.JadeProvider; import java.util.Collection; import java.util.List; @@ -36,8 +35,7 @@ import java.util.Objects; import java.util.concurrent.ExecutionException; import java.util.stream.Stream; -public class PairHierarchyLookup implements IHierarchyLookup { - private static final Logger LOGGER = LogUtils.getLogger(); +public class PairHierarchyLookup implements IHierarchyLookup { public final IHierarchyLookup first; public final IHierarchyLookup second; private final Cache, Class>, List> mergedCache = CacheBuilder.newBuilder().build(); @@ -66,7 +64,7 @@ public class PairHierarchyLookup implements IHierarchyL return ImmutableList.sortedCopyOf(COMPARATOR, Iterables.concat(firstList, secondList)); }); } catch (ExecutionException e) { - LOGGER.warn(e.toString()); + JadeProtocol.LOGGER.error(e.toString()); } return List.of(); } @@ -124,7 +122,7 @@ public class PairHierarchyLookup implements IHierarchyL } @Override - public void loadComplete(PriorityStore priorityStore) { + public void loadComplete(PriorityStore priorityStore) { first.loadComplete(priorityStore); second.loadComplete(priorityStore); if (idMapped) { diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java index 9133b9c..f25b9d6 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java @@ -21,7 +21,7 @@ import io.netty.buffer.ByteBuf; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.Nullable; import java.util.List; @@ -57,9 +57,9 @@ public class ViewGroup { ViewGroup::new); } - public static StreamCodec>>> listCodec(StreamCodec viewCodec) { + public static StreamCodec>>> listCodec(StreamCodec viewCodec) { return StreamCodec.composite( - ResourceLocation.STREAM_CODEC, + Identifier.STREAM_CODEC, Map.Entry::getKey, ByteBufCodecs.>list().apply(codec(viewCodec)), Map.Entry::getValue, diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java index 66d8427..3522ef4 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java @@ -20,14 +20,14 @@ package org.leavesmc.leaves.protocol.jade.util; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; import com.google.common.collect.Sets; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.level.block.Block; import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.protocol.jade.accessor.Accessor; import org.leavesmc.leaves.protocol.jade.accessor.BlockAccessor; -import org.leavesmc.leaves.protocol.jade.provider.IJadeProvider; +import org.leavesmc.leaves.protocol.jade.provider.JadeProvider; import java.util.Collection; import java.util.List; @@ -36,7 +36,7 @@ import java.util.Set; import java.util.function.Function; import java.util.stream.Stream; -public class WrappedHierarchyLookup extends HierarchyLookup { +public class WrappedHierarchyLookup extends HierarchyLookup { public final List, Function, @Nullable Object>>> overrides = Lists.newArrayList(); private boolean empty = true; @@ -45,7 +45,7 @@ public class WrappedHierarchyLookup extends HierarchyLo } @NotNull - public static WrappedHierarchyLookup forAccessor() { + public static WrappedHierarchyLookup forAccessor() { WrappedHierarchyLookup lookup = new WrappedHierarchyLookup<>(); lookup.overrides.add(Pair.of( new HierarchyLookup<>(Block.class), accessor -> { @@ -101,7 +101,7 @@ public class WrappedHierarchyLookup extends HierarchyLo } @Override - public void loadComplete(PriorityStore priorityStore) { + public void loadComplete(PriorityStore priorityStore) { for (var override : overrides) { override.getLeft().loadComplete(priorityStore); } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/PacketTransformer.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/PacketTransformer.java index 14fafe9..ac1edad 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/PacketTransformer.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/PacketTransformer.java @@ -24,7 +24,7 @@ import io.netty.buffer.Unpooled; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.protocol.common.custom.DiscardedPayload; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import org.slf4j.Logger; @@ -43,13 +43,13 @@ public class PacketTransformer { private final Map cache = Collections.synchronizedMap(new HashMap<>()); - public static DiscardedPayload wrapRei(ResourceLocation location, FriendlyByteBuf buf) { + public static DiscardedPayload wrapRei(Identifier location, FriendlyByteBuf buf) { FriendlyByteBuf newBuf = new FriendlyByteBuf(Unpooled.buffer()); newBuf.writeByteArray(ByteBufUtil.getBytes(buf)); return new DiscardedPayload(location, ByteBufUtil.getBytes(newBuf)); } - public void inbound(ResourceLocation id, RegistryFriendlyByteBuf buf, ServerPlayer player, BiConsumer consumer) { + public void inbound(Identifier id, RegistryFriendlyByteBuf buf, ServerPlayer player, BiConsumer consumer) { UUID key = player.getUUID(); PartData data; buf.readVarInt(); @@ -120,7 +120,7 @@ public class PacketTransformer { } } - public void outbound(ResourceLocation id, RegistryFriendlyByteBuf buf, BiConsumer consumer) { + public void outbound(Identifier id, RegistryFriendlyByteBuf buf, BiConsumer consumer) { int maxSize = 1048576 - 1 - 20 - id.toString().getBytes(StandardCharsets.UTF_8).length; if (buf.readableBytes() <= maxSize) { ByteBuf stateBuf = Unpooled.buffer(1); @@ -150,11 +150,11 @@ public class PacketTransformer { } private static class PartData { - private final ResourceLocation id; + private final Identifier id; private final int partsNum; private final List parts; - public PartData(ResourceLocation id, int partsNum) { + public PartData(Identifier id, int partsNum) { this.id = id; this.partsNum = partsNum; this.parts = new ArrayList<>(); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/REIServerProtocol.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/REIServerProtocol.java index af1fb96..d1df8ae 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/REIServerProtocol.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/REIServerProtocol.java @@ -23,7 +23,6 @@ import com.mojang.logging.LogUtils; import fun.bm.lophine.config.modules.function.protocol.REIServerProtocolConfig; import io.netty.buffer.Unpooled; import net.minecraft.ChatFormatting; -import net.minecraft.Util; import net.minecraft.core.RegistryAccess; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; @@ -33,10 +32,11 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.Mth; +import net.minecraft.util.Util; import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.*; @@ -73,17 +73,17 @@ public class REIServerProtocol implements LeavesProtocol { public static final String PROTOCOL_ID = "roughlyenoughitems"; public static final String CHEAT_PERMISSION = "leaves.protocol.rei.cheat"; - public static final ResourceLocation DELETE_ITEMS_PACKET = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "delete_item"); - public static final ResourceLocation CREATE_ITEMS_PACKET = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "create_item"); - public static final ResourceLocation CREATE_ITEMS_HOTBAR_PACKET = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "create_item_hotbar"); - public static final ResourceLocation CREATE_ITEMS_GRAB_PACKET = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "create_item_grab"); - public static final ResourceLocation CREATE_ITEMS_MESSAGE_PACKET = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "ci_msg"); - public static final ResourceLocation MOVE_ITEMS_NEW_PACKET = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "move_items_new"); - public static final ResourceLocation NOT_ENOUGH_ITEMS_PACKET = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "og_not_enough"); // this pack is under to-do at rei-client, so we don't handle it - public static final ResourceLocation SYNC_DISPLAYS_PACKET = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "sync_displays"); + public static final Identifier DELETE_ITEMS_PACKET = Identifier.fromNamespaceAndPath("roughlyenoughitems", "delete_item"); + public static final Identifier CREATE_ITEMS_PACKET = Identifier.fromNamespaceAndPath("roughlyenoughitems", "create_item"); + public static final Identifier CREATE_ITEMS_HOTBAR_PACKET = Identifier.fromNamespaceAndPath("roughlyenoughitems", "create_item_hotbar"); + public static final Identifier CREATE_ITEMS_GRAB_PACKET = Identifier.fromNamespaceAndPath("roughlyenoughitems", "create_item_grab"); + public static final Identifier CREATE_ITEMS_MESSAGE_PACKET = Identifier.fromNamespaceAndPath("roughlyenoughitems", "ci_msg"); + public static final Identifier MOVE_ITEMS_NEW_PACKET = Identifier.fromNamespaceAndPath("roughlyenoughitems", "move_items_new"); + public static final Identifier NOT_ENOUGH_ITEMS_PACKET = Identifier.fromNamespaceAndPath("roughlyenoughitems", "og_not_enough"); // this pack is under to-do at rei-client, so we don't handle it + public static final Identifier SYNC_DISPLAYS_PACKET = Identifier.fromNamespaceAndPath("roughlyenoughitems", "sync_displays"); - public static final Map TRANSFORMERS = Util.make(() -> { - ImmutableMap.Builder builder = ImmutableMap.builder(); + public static final Map TRANSFORMERS = Util.make(() -> { + ImmutableMap.Builder builder = ImmutableMap.builder(); builder.put(SYNC_DISPLAYS_PACKET, new PacketTransformer()); builder.put(DELETE_ITEMS_PACKET, new PacketTransformer()); builder.put(CREATE_ITEMS_PACKET, new PacketTransformer()); @@ -108,8 +108,8 @@ public class REIServerProtocol implements LeavesProtocol { } @Contract("_ -> new") - public static ResourceLocation id(String path) { - return ResourceLocation.tryBuild(PROTOCOL_ID, path); + public static Identifier id(String path) { + return Identifier.tryBuild(PROTOCOL_ID, path); } public static void onConfigModify(boolean enabled) { @@ -194,7 +194,7 @@ public class REIServerProtocol implements LeavesProtocol { } @ProtocolHandler.MinecraftRegister(onlyNamespace = true, stage = ProtocolHandler.Stage.GAME) - public static void onPlayerSubscribed(@NotNull ServerPlayer player, ResourceLocation location) { + public static void onPlayerSubscribed(@NotNull ServerPlayer player, Identifier location) { enabledPlayers.add(player); String channel = location.getPath(); if (channel.equals("sync_displays")) { @@ -203,7 +203,7 @@ public class REIServerProtocol implements LeavesProtocol { } } else if (channel.equals("ci_msg")) { // cheat rei-client into using "delete_item" packet - if (MinecraftServer.getServer().getProfilePermissions(player.getGameProfile()) < 1) { + if (MinecraftServer.getServer().getProfilePermissions(player.nameAndId()).level().id() < 1) { player.getBukkitEntity().sendOpLevel((byte) 1); } } @@ -229,7 +229,7 @@ public class REIServerProtocol implements LeavesProtocol { if (!hasCheatPermission(player)) { return; } - BiConsumer consumer = (ignored, c2sWholeBuf) -> { + BiConsumer consumer = (ignored, c2sWholeBuf) -> { FriendlyByteBuf tmpBuf = new FriendlyByteBuf(Unpooled.buffer()).writeBytes(c2sWholeBuf.readByteArray()); ItemStack itemStack = tmpBuf.readLenientJsonWithCodec(ItemStack.OPTIONAL_CODEC); if (player.getInventory().add(itemStack.copy())) { @@ -254,7 +254,7 @@ public class REIServerProtocol implements LeavesProtocol { if (!hasCheatPermission(player)) { return; } - BiConsumer consumer = (ignored, c2sWholeBuf) -> { + BiConsumer consumer = (ignored, c2sWholeBuf) -> { FriendlyByteBuf tmpBuf = new FriendlyByteBuf(Unpooled.buffer()).writeBytes(c2sWholeBuf.readByteArray()); ItemStack itemStack = tmpBuf.readLenientJsonWithCodec(ItemStack.OPTIONAL_CODEC); ItemStack stack = itemStack.copy(); @@ -284,7 +284,7 @@ public class REIServerProtocol implements LeavesProtocol { if (!hasCheatPermission(player)) { return; } - BiConsumer consumer = (ignored, c2sWholeBuf) -> { + BiConsumer consumer = (ignored, c2sWholeBuf) -> { FriendlyByteBuf tmpBuf = new FriendlyByteBuf(Unpooled.buffer()).writeBytes(c2sWholeBuf.readByteArray()); ItemStack stack = tmpBuf.readLenientJsonWithCodec(ItemStack.OPTIONAL_CODEC); int hotbarSlotId = tmpBuf.readVarInt(); @@ -310,10 +310,10 @@ public class REIServerProtocol implements LeavesProtocol { @ProtocolHandler.BytebufReceiver(key = "move_items_new") public static void handleMoveItem(ServerPlayer player, RegistryFriendlyByteBuf buf) { - BiConsumer consumer = (ignored, c2sWholeBuf) -> { + BiConsumer consumer = (ignored, c2sWholeBuf) -> { FriendlyByteBuf tmpBuf = new FriendlyByteBuf(Unpooled.buffer()).writeBytes(c2sWholeBuf.readByteArray()); AbstractContainerMenu container = player.containerMenu; - tmpBuf.readResourceLocation(); + tmpBuf.readIdentifier(); try { boolean shift = tmpBuf.readBoolean(); try { @@ -354,7 +354,7 @@ public class REIServerProtocol implements LeavesProtocol { inboundTransform(player, MOVE_ITEMS_NEW_PACKET, buf, consumer); } - private static void inboundTransform(ServerPlayer player, ResourceLocation id, RegistryFriendlyByteBuf buf, BiConsumer consumer) { + private static void inboundTransform(ServerPlayer player, Identifier id, RegistryFriendlyByteBuf buf, BiConsumer consumer) { PacketTransformer transformer = TRANSFORMERS.get(id); if (transformer != null) { transformer.inbound(id, buf, player, consumer); @@ -363,7 +363,7 @@ public class REIServerProtocol implements LeavesProtocol { } } - private static void outboundTransform(RegistryFriendlyByteBuf buf, BiConsumer consumer) { + private static void outboundTransform(RegistryFriendlyByteBuf buf, BiConsumer consumer) { PacketTransformer transformer = TRANSFORMERS.get(SYNC_DISPLAYS_PACKET); if (transformer != null) { transformer.outbound(SYNC_DISPLAYS_PACKET, buf, consumer); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/BlastingDisplay.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/BlastingDisplay.java index 23cb77c..890a4aa 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/BlastingDisplay.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/BlastingDisplay.java @@ -17,19 +17,19 @@ package org.leavesmc.leaves.protocol.rei.display; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.crafting.AbstractCookingRecipe; import net.minecraft.world.item.crafting.RecipeHolder; public class BlastingDisplay extends CookingDisplay { - private static final ResourceLocation SERIALIZER_ID = ResourceLocation.tryBuild("minecraft", "default/blasting"); + private static final Identifier SERIALIZER_ID = Identifier.tryBuild("minecraft", "default/blasting"); public BlastingDisplay(RecipeHolder recipe) { super(recipe); } @Override - public ResourceLocation getSerializerId() { + public Identifier getSerializerId() { return SERIALIZER_ID; } } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CampfireDisplay.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CampfireDisplay.java index ca68d7b..49b1628 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CampfireDisplay.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CampfireDisplay.java @@ -17,19 +17,19 @@ package org.leavesmc.leaves.protocol.rei.display; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.crafting.CampfireCookingRecipe; import net.minecraft.world.item.crafting.RecipeHolder; public class CampfireDisplay extends CookingDisplay { - private static final ResourceLocation SERIALIZER_ID = ResourceLocation.tryBuild("minecraft", "default/campfire"); + private static final Identifier SERIALIZER_ID = Identifier.tryBuild("minecraft", "default/campfire"); public CampfireDisplay(RecipeHolder recipe) { super(recipe); } @Override - public ResourceLocation getSerializerId() { + public Identifier getSerializerId() { return SERIALIZER_ID; } } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CookingDisplay.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CookingDisplay.java index 534f992..3996fdf 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CookingDisplay.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CookingDisplay.java @@ -20,7 +20,7 @@ package org.leavesmc.leaves.protocol.rei.display; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.AbstractCookingRecipe; import net.minecraft.world.item.crafting.RecipeHolder; @@ -38,7 +38,7 @@ public abstract class CookingDisplay extends Display { CookingDisplay::getInputEntries, EntryIngredient.CODEC.apply(ByteBufCodecs.list()), CookingDisplay::getOutputEntries, - ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC), + ByteBufCodecs.optional(Identifier.STREAM_CODEC), CookingDisplay::getOptionalLocation, ByteBufCodecs.FLOAT, CookingDisplay::getXp, @@ -49,7 +49,7 @@ public abstract class CookingDisplay extends Display { protected float xp; protected double cookTime; - private CookingDisplay(@NotNull List inputs, @NotNull List outputs, @NotNull ResourceLocation id, float xp, double cookTime) { + private CookingDisplay(@NotNull List inputs, @NotNull List outputs, @NotNull Identifier id, float xp, double cookTime) { super(inputs, outputs, id); this.xp = xp; this.cookTime = cookTime; @@ -59,14 +59,14 @@ public abstract class CookingDisplay extends Display { this( List.of(EntryIngredient.ofIngredient(recipe.value().input())), List.of(EntryIngredient.of(recipe.value().assemble(new SingleRecipeInput(ItemStack.EMPTY), CraftRegistry.getMinecraftRegistry()))), - recipe.id().location(), + recipe.id().identifier(), recipe.value().experience(), recipe.value().cookingTime() ); } @SuppressWarnings("OptionalUsedAsFieldOrParameterType") - private static CookingDisplay of(@NotNull List inputs, @NotNull List outputs, @NotNull Optional id, float xp, double cookTime) { + private static CookingDisplay of(@NotNull List inputs, @NotNull List outputs, @NotNull Optional id, float xp, double cookTime) { throw new UnsupportedOperationException(); } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CraftingDisplay.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CraftingDisplay.java index 44a7d8a..43c813b 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CraftingDisplay.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CraftingDisplay.java @@ -17,7 +17,7 @@ package org.leavesmc.leaves.protocol.rei.display; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.rei.ingredient.EntryIngredient; @@ -27,7 +27,7 @@ public abstract class CraftingDisplay extends Display { public CraftingDisplay(@NotNull List inputs, @NotNull List outputs, - @NotNull ResourceLocation location) { + @NotNull Identifier location) { super(inputs, outputs, location); } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CustomDisplay.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CustomDisplay.java index e52ca20..582119f 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CustomDisplay.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CustomDisplay.java @@ -20,7 +20,7 @@ package org.leavesmc.leaves.protocol.rei.display; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.rei.ingredient.EntryIngredient; @@ -34,18 +34,18 @@ public class CustomDisplay extends CraftingDisplay { CustomDisplay::getInputEntries, EntryIngredient.CODEC.apply(ByteBufCodecs.list()), CustomDisplay::getOutputEntries, - ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC), + ByteBufCodecs.optional(Identifier.STREAM_CODEC), CustomDisplay::getOptionalLocation, CustomDisplay::of ); - private static final ResourceLocation SERIALIZER_ID = ResourceLocation.tryBuild("minecraft", "default/crafting/custom"); + private static final Identifier SERIALIZER_ID = Identifier.tryBuild("minecraft", "default/crafting/custom"); private final int width; private final int height; /** * see me.shedaniel.rei.plugin.common.displays.crafting.DefaultCustomDisplay#DefaultCustomDisplay */ - public CustomDisplay(@NotNull List inputs, @NotNull List outputs, @NotNull ResourceLocation location) { + public CustomDisplay(@NotNull List inputs, @NotNull List outputs, @NotNull Identifier location) { super(inputs, outputs, location); BitSet row = new BitSet(3); BitSet column = new BitSet(3); @@ -63,7 +63,7 @@ public class CustomDisplay extends CraftingDisplay { } @SuppressWarnings("OptionalUsedAsFieldOrParameterType") - private static CustomDisplay of(@NotNull List inputs, @NotNull List outputs, @NotNull Optional id) { + private static CustomDisplay of(@NotNull List inputs, @NotNull List outputs, @NotNull Optional id) { throw new UnsupportedOperationException(); } @@ -78,7 +78,7 @@ public class CustomDisplay extends CraftingDisplay { } @Override - public ResourceLocation getSerializerId() { + public Identifier getSerializerId() { return SERIALIZER_ID; } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/Display.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/Display.java index a52bd5f..9f27dd9 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/Display.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/Display.java @@ -24,7 +24,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.tags.TagKey; import net.minecraft.util.context.ContextMap; @@ -51,7 +51,7 @@ import java.util.stream.Stream; */ public abstract class Display { - protected ResourceLocation id; + protected Identifier id; protected List inputs; @@ -59,7 +59,7 @@ public abstract class Display { public Display(@NotNull List inputs, @NotNull List outputs, - @NotNull ResourceLocation id) { + @NotNull Identifier id) { this.inputs = inputs; this.outputs = outputs; this.id = id; @@ -76,7 +76,7 @@ public abstract class Display { @Override public void encode(@NotNull RegistryFriendlyByteBuf buffer, @NotNull Display display) { - new FriendlyByteBuf(buffer).writeResourceLocation(display.getSerializerId()); + new FriendlyByteBuf(buffer).writeIdentifier(display.getSerializerId()); ((StreamCodec) display.streamCodec()).encode(buffer, display); } }; @@ -89,9 +89,9 @@ public abstract class Display { if (!displays.isEmpty()) { RecipeDisplay recipeDisplay = displays.getFirst(); if (recipeDisplay instanceof ShapelessCraftingRecipeDisplay shapelessRecipeDisplay) { - displayList.add(new ShapelessDisplay(shapelessRecipeDisplay, recipeHolder.id().location())); + displayList.add(new ShapelessDisplay(shapelessRecipeDisplay, recipeHolder.id().identifier())); } else if (recipeDisplay instanceof ShapedCraftingRecipeDisplay shapelessRecipe) { - displayList.add(new ShapedDisplay(shapelessRecipe, recipeHolder.id().location())); + displayList.add(new ShapedDisplay(shapelessRecipe, recipeHolder.id().identifier())); } } return displayList; @@ -103,7 +103,7 @@ public abstract class Display { @NotNull public static Collection ofTippedArrowRecipe(@NotNull RecipeHolder recipeHolder) { EntryIngredient arrowIngredient = EntryIngredient.of(Items.ARROW); - Set registeredPotions = new HashSet<>(); + Set registeredPotions = new HashSet<>(); List displays = new ArrayList<>(); MinecraftServer.getServer().registryAccess().lookup(Registries.POTION).stream() .flatMap(Registry::listElements) @@ -113,7 +113,7 @@ public abstract class Display { if (potion == null || potion.potion().isEmpty()) { return; } - if (potion.potion().get().unwrapKey().isPresent() && registeredPotions.add(potion.potion().get().unwrapKey().get().location())) { + if (potion.potion().get().unwrapKey().isPresent() && registeredPotions.add(potion.potion().get().unwrapKey().get().identifier())) { List input = new ArrayList<>(); for (int i = 0; i < 4; i++) { input.add(arrowIngredient); @@ -124,7 +124,7 @@ public abstract class Display { } ItemStack outputStack = new ItemStack(Items.TIPPED_ARROW, 8); outputStack.set(DataComponents.POTION_CONTENTS, potion); - displays.add(new CustomDisplay(input, List.of(EntryIngredient.of(outputStack)), recipeHolder.id().location())); + displays.add(new CustomDisplay(input, List.of(EntryIngredient.of(outputStack)), recipeHolder.id().identifier())); } }); return displays; @@ -145,7 +145,7 @@ public abstract class Display { outputs[i] = new ItemStack(Items.FIREWORK_ROCKET, 3); outputs[i].set(DataComponents.FIREWORKS, new Fireworks(i + 1, List.of())); } - return Collections.singleton(new ShapelessDisplay(List.of(inputs), List.of(EntryIngredient.of(outputs)), recipeHolder.id().location())); + return Collections.singleton(new ShapelessDisplay(List.of(inputs), List.of(EntryIngredient.of(outputs)), recipeHolder.id().identifier())); } /** @@ -157,7 +157,7 @@ public abstract class Display { new ShapelessDisplay( List.of(EntryIngredient.of(Items.FILLED_MAP), EntryIngredient.of(Items.MAP)), List.of(EntryIngredient.of(new ItemStack(Items.FILLED_MAP, 2))), - recipeHolder.id().location()) + recipeHolder.id().identifier()) ); } @@ -174,7 +174,7 @@ public abstract class Display { ), List.of(ofSlotDisplay(recipeHolder.value().getResult())), SmithingDisplay.SmithingRecipeType.TRANSFORM, - recipeHolder.id().location() + recipeHolder.id().identifier() ); } @@ -198,7 +198,7 @@ public abstract class Display { recipe.templateIngredient().map(EntryIngredient::ofIngredient).orElse(EntryIngredient.empty()), baseIngredient, EntryIngredient.ofItemHolder(additionStack) - ), List.of(baseIngredient), SmithingDisplay.SmithingRecipeType.TRIM, recipeHolder.id().location(), recipe.pattern())); + ), List.of(baseIngredient), SmithingDisplay.SmithingRecipeType.TRIM, recipeHolder.id().identifier(), recipe.pattern())); } return displays; @@ -283,15 +283,15 @@ public abstract class Display { return outputs; } - public ResourceLocation getDisplayLocation() { + public Identifier getDisplayLocation() { return id; } - public Optional getOptionalLocation() { + public Optional getOptionalLocation() { return Optional.ofNullable(id); } - public abstract ResourceLocation getSerializerId(); + public abstract Identifier getSerializerId(); public abstract StreamCodec streamCodec(); } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapedDisplay.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapedDisplay.java index d205fbc..88079f2 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapedDisplay.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapedDisplay.java @@ -20,7 +20,7 @@ package org.leavesmc.leaves.protocol.rei.display; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.CraftingInput; import net.minecraft.world.item.crafting.RecipeHolder; @@ -42,7 +42,7 @@ public class ShapedDisplay extends CraftingDisplay { CraftingDisplay::getInputEntries, EntryIngredient.CODEC.apply(ByteBufCodecs.list()), CraftingDisplay::getOutputEntries, - ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC), + ByteBufCodecs.optional(Identifier.STREAM_CODEC), CraftingDisplay::getOptionalLocation, ByteBufCodecs.INT, CraftingDisplay::getWidth, @@ -50,7 +50,7 @@ public class ShapedDisplay extends CraftingDisplay { CraftingDisplay::getHeight, ShapedDisplay::of ); - private static final ResourceLocation SERIALIZER_ID = ResourceLocation.tryBuild("minecraft", "default/crafting/shaped"); + private static final Identifier SERIALIZER_ID = Identifier.tryBuild("minecraft", "default/crafting/shaped"); private final int width; private final int height; @@ -58,13 +58,13 @@ public class ShapedDisplay extends CraftingDisplay { super( ofIngredient(recipeHolder.value()), List.of(EntryIngredient.of(recipeHolder.value().assemble(CraftingInput.EMPTY, CraftRegistry.getMinecraftRegistry()))), - recipeHolder.id().location() + recipeHolder.id().identifier() ); this.width = recipeHolder.value().getWidth(); this.height = recipeHolder.value().getHeight(); } - public ShapedDisplay(@NotNull ShapedCraftingRecipeDisplay recipeDisplay, ResourceLocation id) { + public ShapedDisplay(@NotNull ShapedCraftingRecipeDisplay recipeDisplay, Identifier id) { super( Display.ofSlotDisplays(recipeDisplay.ingredients()), List.of(ofSlotDisplay(recipeDisplay.result())), @@ -75,7 +75,7 @@ public class ShapedDisplay extends CraftingDisplay { } @SuppressWarnings("OptionalUsedAsFieldOrParameterType") - private static CraftingDisplay of(List inputs, List outputs, Optional location, int width, int height) { + private static CraftingDisplay of(List inputs, List outputs, Optional location, int width, int height) { throw new UnsupportedOperationException(); } @@ -102,7 +102,7 @@ public class ShapedDisplay extends CraftingDisplay { } @Override - public ResourceLocation getSerializerId() { + public Identifier getSerializerId() { return SERIALIZER_ID; } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapelessDisplay.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapelessDisplay.java index fdfea54..7e99fb9 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapelessDisplay.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapelessDisplay.java @@ -20,7 +20,7 @@ package org.leavesmc.leaves.protocol.rei.display; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.crafting.CraftingInput; import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.item.crafting.ShapelessRecipe; @@ -39,16 +39,16 @@ public class ShapelessDisplay extends CraftingDisplay { CraftingDisplay::getInputEntries, EntryIngredient.CODEC.apply(ByteBufCodecs.list()), CraftingDisplay::getOutputEntries, - ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC), + ByteBufCodecs.optional(Identifier.STREAM_CODEC), CraftingDisplay::getOptionalLocation, ShapelessDisplay::of ); - private static final ResourceLocation SERIALIZER_ID = ResourceLocation.tryBuild("minecraft", "default/crafting/shapeless"); + private static final Identifier SERIALIZER_ID = Identifier.tryBuild("minecraft", "default/crafting/shapeless"); public ShapelessDisplay(@NotNull List inputs, @NotNull List outputs, - @NotNull ResourceLocation location) { + @NotNull Identifier location) { super(inputs, outputs, location); } @@ -56,11 +56,11 @@ public class ShapelessDisplay extends CraftingDisplay { this( recipeHolder.value().placementInfo().ingredients().stream().map(EntryIngredient::ofIngredient).toList(), List.of(EntryIngredient.of(recipeHolder.value().assemble(CraftingInput.EMPTY, CraftRegistry.getMinecraftRegistry()))), - recipeHolder.id().location() + recipeHolder.id().identifier() ); } - public ShapelessDisplay(@NotNull ShapelessCraftingRecipeDisplay recipeDisplay, ResourceLocation id) { + public ShapelessDisplay(@NotNull ShapelessCraftingRecipeDisplay recipeDisplay, Identifier id) { this( ofSlotDisplays(recipeDisplay.ingredients()), List.of(ofSlotDisplay(recipeDisplay.result())), @@ -69,7 +69,7 @@ public class ShapelessDisplay extends CraftingDisplay { } @SuppressWarnings("OptionalUsedAsFieldOrParameterType") - private static CraftingDisplay of(List inputs, List outputs, Optional location) { + private static CraftingDisplay of(List inputs, List outputs, Optional location) { throw new NotImplementedException(); } @@ -84,7 +84,7 @@ public class ShapelessDisplay extends CraftingDisplay { } @Override - public ResourceLocation getSerializerId() { + public Identifier getSerializerId() { return SERIALIZER_ID; } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmeltingDisplay.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmeltingDisplay.java index 6152766..3dbbe36 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmeltingDisplay.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmeltingDisplay.java @@ -17,19 +17,19 @@ package org.leavesmc.leaves.protocol.rei.display; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.item.crafting.SmeltingRecipe; public class SmeltingDisplay extends CookingDisplay { - private static final ResourceLocation SERIALIZER_ID = ResourceLocation.tryBuild("minecraft", "default/smelting"); + private static final Identifier SERIALIZER_ID = Identifier.tryBuild("minecraft", "default/smelting"); public SmeltingDisplay(RecipeHolder recipe) { super(recipe); } @Override - public ResourceLocation getSerializerId() { + public Identifier getSerializerId() { return SERIALIZER_ID; } } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmithingDisplay.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmithingDisplay.java index 303f290..2022774 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmithingDisplay.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmithingDisplay.java @@ -23,7 +23,7 @@ import net.minecraft.core.Holder; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.util.ByIdMap; import net.minecraft.world.item.equipment.trim.TrimPattern; import org.jetbrains.annotations.NotNull; @@ -41,12 +41,12 @@ public class SmithingDisplay extends Display { SmithingDisplay::getOutputEntries, ByteBufCodecs.optional(SmithingRecipeType.STREAM_CODEC), SmithingDisplay::getOptionalType, - ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC), + ByteBufCodecs.optional(Identifier.STREAM_CODEC), SmithingDisplay::getOptionalLocation, SmithingDisplay::of ); - private static final ResourceLocation SERIALIZER_ID = ResourceLocation.tryBuild("minecraft", "default/smithing"); + private static final Identifier SERIALIZER_ID = Identifier.tryBuild("minecraft", "default/smithing"); private final SmithingRecipeType type; @@ -54,14 +54,14 @@ public class SmithingDisplay extends Display { @NotNull List inputs, @NotNull List outputs, @NotNull SmithingRecipeType type, - @NotNull ResourceLocation location + @NotNull Identifier location ) { super(inputs, outputs, location); this.type = type; } @SuppressWarnings("OptionalUsedAsFieldOrParameterType") - private static SmithingDisplay of(List inputs, List outputs, Optional type, Optional location) { + private static SmithingDisplay of(List inputs, List outputs, Optional type, Optional location) { throw new UnsupportedOperationException(); } @@ -70,7 +70,7 @@ public class SmithingDisplay extends Display { } @Override - public ResourceLocation getSerializerId() { + public Identifier getSerializerId() { return SERIALIZER_ID; } @@ -97,14 +97,14 @@ public class SmithingDisplay extends Display { SmithingDisplay.Trimming::getOutputEntries, ByteBufCodecs.optional(SmithingRecipeType.STREAM_CODEC), SmithingDisplay.Trimming::getOptionalType, - ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC), + ByteBufCodecs.optional(Identifier.STREAM_CODEC), SmithingDisplay.Trimming::getOptionalLocation, TrimPattern.STREAM_CODEC, SmithingDisplay.Trimming::pattern, SmithingDisplay.Trimming::of ); - private static final ResourceLocation SERIALIZER_ID = ResourceLocation.tryBuild("minecraft", "default/smithing/trimming"); + private static final Identifier SERIALIZER_ID = Identifier.tryBuild("minecraft", "default/smithing/trimming"); private final Holder pattern; @@ -112,7 +112,7 @@ public class SmithingDisplay extends Display { @NotNull List inputs, @NotNull List outputs, @NotNull SmithingRecipeType type, - @NotNull ResourceLocation location, + @NotNull Identifier location, @NotNull Holder pattern ) { super(inputs, outputs, type, location); @@ -120,12 +120,12 @@ public class SmithingDisplay extends Display { } @SuppressWarnings("OptionalUsedAsFieldOrParameterType") - public static Trimming of(List inputs, List outputs, Optional type, Optional location, Holder pattern) { + public static Trimming of(List inputs, List outputs, Optional type, Optional location, Holder pattern) { throw new UnsupportedOperationException(); } @Override - public ResourceLocation getSerializerId() { + public Identifier getSerializerId() { return SERIALIZER_ID; } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmokingDisplay.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmokingDisplay.java index 7ece342..794896f 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmokingDisplay.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmokingDisplay.java @@ -17,19 +17,19 @@ package org.leavesmc.leaves.protocol.rei.display; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.crafting.AbstractCookingRecipe; import net.minecraft.world.item.crafting.RecipeHolder; public class SmokingDisplay extends CookingDisplay { - private static final ResourceLocation SERIALIZER_ID = ResourceLocation.tryBuild("minecraft", "default/smoking"); + private static final Identifier SERIALIZER_ID = Identifier.tryBuild("minecraft", "default/smoking"); public SmokingDisplay(RecipeHolder recipe) { super(recipe); } @Override - public ResourceLocation getSerializerId() { + public Identifier getSerializerId() { return SERIALIZER_ID; } } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/StoneCuttingDisplay.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/StoneCuttingDisplay.java index 4180494..3d666ed 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/StoneCuttingDisplay.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/StoneCuttingDisplay.java @@ -20,7 +20,7 @@ package org.leavesmc.leaves.protocol.rei.display; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.item.crafting.SingleRecipeInput; @@ -41,14 +41,14 @@ public class StoneCuttingDisplay extends Display { StoneCuttingDisplay::getInputEntries, EntryIngredient.CODEC.apply(ByteBufCodecs.list()), StoneCuttingDisplay::getOutputEntries, - ByteBufCodecs.optional(ResourceLocation.STREAM_CODEC), + ByteBufCodecs.optional(Identifier.STREAM_CODEC), StoneCuttingDisplay::getOptionalLocation, StoneCuttingDisplay::of ); - private static final ResourceLocation SERIALIZER_ID = ResourceLocation.tryBuild("minecraft", "default/stone_cutting"); + private static final Identifier SERIALIZER_ID = Identifier.tryBuild("minecraft", "default/stone_cutting"); - public StoneCuttingDisplay(@NotNull List inputs, @NotNull List outputs, @NotNull ResourceLocation id) { + public StoneCuttingDisplay(@NotNull List inputs, @NotNull List outputs, @NotNull Identifier id) { super(inputs, outputs, id); } @@ -56,17 +56,17 @@ public class StoneCuttingDisplay extends Display { this( List.of(EntryIngredient.ofIngredient(recipeHolder.value().input())), List.of(EntryIngredient.of(recipeHolder.value().assemble(new SingleRecipeInput(ItemStack.EMPTY), CraftRegistry.getMinecraftRegistry()))), - recipeHolder.id().location() + recipeHolder.id().identifier() ); } @SuppressWarnings("OptionalUsedAsFieldOrParameterType") - private static StoneCuttingDisplay of(@NotNull List inputs, @NotNull List outputs, @NotNull Optional id) { + private static StoneCuttingDisplay of(@NotNull List inputs, @NotNull List outputs, @NotNull Optional id) { throw new UnsupportedOperationException(); } @Override - public ResourceLocation getSerializerId() { + public Identifier getSerializerId() { return SERIALIZER_ID; } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/ingredient/EntryIngredient.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/ingredient/EntryIngredient.java index e2f6654..785ae6e 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/ingredient/EntryIngredient.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/rei/ingredient/EntryIngredient.java @@ -23,7 +23,7 @@ import net.minecraft.core.registries.Registries; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.Ingredient; @@ -36,7 +36,7 @@ import java.util.stream.Stream; public class EntryIngredient { private static final StreamCodec> ITEM_STREAM_CODEC = ByteBufCodecs.holderRegistry(Registries.ITEM); - private static final ResourceLocation ITEM_ID = ResourceLocation.withDefaultNamespace("item"); + private static final Identifier ITEM_ID = Identifier.withDefaultNamespace("item"); public static final StreamCodec CODEC = new StreamCodec<>() { @NotNull @Override @@ -48,7 +48,7 @@ public class EntryIngredient { public void encode(@NotNull RegistryFriendlyByteBuf buffer, @NotNull EntryIngredient value) { ByteBufCodecs.writeCount(buffer, value.size(), Integer.MAX_VALUE); value.stream().forEach(itemStack -> { - buffer.writeResourceLocation(ITEM_ID); + buffer.writeIdentifier(ITEM_ID); if (itemStack.isEmpty()) { buffer.writeVarInt(0); } else { diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxEntityDataProtocol.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxEntityDataProtocol.java index 40f6c0f..334bde6 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxEntityDataProtocol.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxEntityDataProtocol.java @@ -21,14 +21,14 @@ import ca.spottedleaf.moonrise.common.util.TickThread; import com.mojang.logging.LogUtils; import fun.bm.lophine.config.modules.function.protocol.ServuxProtocolConfig; import io.netty.buffer.Unpooled; -import net.minecraft.Util; import net.minecraft.core.BlockPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import net.minecraft.util.RandomSource; +import net.minecraft.util.Util; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.block.entity.BlockEntity; @@ -186,7 +186,7 @@ public class ServuxEntityDataProtocol implements LeavesProtocol { public static class EntityDataPayload implements LeavesCustomPayload { @ID - public static final ResourceLocation CHANNEL = ServuxProtocol.id("entity_data"); + public static final Identifier CHANNEL = ServuxProtocol.id("entity_data"); @Codec public static final StreamCodec CODEC = StreamCodec.of( diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxHudDataProtocol.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxHudDataProtocol.java index 04138b1..735f968 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxHudDataProtocol.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxHudDataProtocol.java @@ -30,13 +30,13 @@ import net.minecraft.nbt.Tag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.item.crafting.Recipe; import net.minecraft.world.item.crafting.RecipeHolder; -import net.minecraft.world.level.GameRules; +import net.minecraft.world.level.gamerules.GameRules; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; import org.leavesmc.leaves.protocol.core.LeavesProtocol; @@ -137,7 +137,7 @@ public class ServuxHudDataProtocol implements LeavesProtocol { if (dr.result().isPresent()) { CompoundTag entry = new CompoundTag(); entry.putString("id_reg", recipeEntry.id().registry().toString()); - entry.putString("id_value", recipeEntry.id().location().toString()); + entry.putString("id_value", recipeEntry.id().identifier().toString()); entry.put("recipe", dr.result().get()); list.add(entry); } @@ -149,7 +149,7 @@ public class ServuxHudDataProtocol implements LeavesProtocol { public static void refreshWeatherData(ServerPlayer player) { ServerLevel level = MinecraftServer.getServer().overworld(); - if (!level.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE)) { + if (!level.getGameRules().get(GameRules.ADVANCE_WEATHER)) { return; } @@ -180,11 +180,11 @@ public class ServuxHudDataProtocol implements LeavesProtocol { private static void putWorldData(@NotNull CompoundTag metadata) { ServerLevel level = MinecraftServer.getServer().overworld(); - BlockPos spawnPos = level.levelData.getSpawnPos(); + BlockPos spawnPos = level.serverLevelData.getRespawnData().pos(); metadata.putInt("spawnPosX", spawnPos.getX()); metadata.putInt("spawnPosY", spawnPos.getY()); metadata.putInt("spawnPosZ", spawnPos.getZ()); - metadata.putInt("spawnChunkRadius", level.getGameRules().getInt(GameRules.RULE_SPAWN_CHUNK_RADIUS)); + metadata.putInt("spawnChunkRadius", level.getGameRules().get(GameRules.RESPAWN_RADIUS)); if (ServuxProtocolConfig.hudMetadataShareSeed) { metadata.putLong("worldSeed", level.getSeed()); @@ -331,7 +331,7 @@ public class ServuxHudDataProtocol implements LeavesProtocol { FriendlyByteBuf buffer) implements LeavesCustomPayload { @ID - public static final ResourceLocation CHANNEL = ServuxProtocol.id("hud_metadata"); + public static final Identifier CHANNEL = ServuxProtocol.id("hud_metadata"); @Codec public static final StreamCodec CODEC = StreamCodec.of( diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxProtocol.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxProtocol.java index 23c2a9a..f75b273 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxProtocol.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxProtocol.java @@ -17,7 +17,7 @@ package org.leavesmc.leaves.protocol.servux; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.Contract; import org.leavesmc.leaves.protocol.core.ProtocolUtils; import org.slf4j.Logger; @@ -30,7 +30,7 @@ public class ServuxProtocol { public static final String SERVUX_STRING = ProtocolUtils.buildProtocolVersion(PROTOCOL_ID); @Contract("_ -> new") - public static ResourceLocation id(String path) { - return ResourceLocation.tryBuild(PROTOCOL_ID, path); + public static Identifier id(String path) { + return Identifier.tryBuild(PROTOCOL_ID, path); } } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxStructuresProtocol.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxStructuresProtocol.java index 33045a2..3dbae19 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxStructuresProtocol.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxStructuresProtocol.java @@ -27,7 +27,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -93,7 +93,7 @@ public class ServuxStructuresProtocol implements LeavesProtocol { } public static void onStartedWatchingChunk(ServerPlayer player, LevelChunk chunk) { - MinecraftServer server = player.getServer(); + MinecraftServer server = MinecraftServer.getServer(); if (players.containsKey(player.getId()) && server != null) { addChunkTimeoutIfHasReferences(player.getUUID(), chunk, System.currentTimeMillis() / 50); } @@ -367,7 +367,7 @@ public class ServuxStructuresProtocol implements LeavesProtocol { FriendlyByteBuf buffer) implements LeavesCustomPayload { @ID - public static final ResourceLocation CHANNEL = ServuxProtocol.id("structures"); + public static final Identifier CHANNEL = ServuxProtocol.id("structures"); @Codec public static final StreamCodec CODEC = StreamCodec.of( diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/LitematicaSchematic.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/LitematicaSchematic.java index 55e47c6..1048b28 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/LitematicaSchematic.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/LitematicaSchematic.java @@ -27,7 +27,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.LongArrayTag; import net.minecraft.nbt.Tag; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.util.Mth; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; @@ -198,7 +198,7 @@ public record LitematicaSchematic(Map subRegions, SchematicMe continue; } T target; - ResourceLocation resourceLocation = ResourceLocation.tryParse(tag.getStringOr(tagName, "")); + Identifier resourceLocation = Identifier.tryParse(tag.getStringOr(tagName, "")); if (resourceLocation == null) { continue; } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/ServuxLitematicsProtocol.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/ServuxLitematicsProtocol.java index d7be4b0..73a17c5 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/ServuxLitematicsProtocol.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/ServuxLitematicsProtocol.java @@ -28,7 +28,7 @@ import net.minecraft.nbt.NbtAccounter; import net.minecraft.nbt.Tag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -180,7 +180,7 @@ public class ServuxLitematicsProtocol implements LeavesProtocol { ServuxLitematicaPayload payload = new ServuxLitematicaPayload(ServuxLitematicaPayloadType.PACKET_S2C_ENTITY_NBT_RESPONSE_SIMPLE); payload.entityId = entityId; if (entity instanceof net.minecraft.world.entity.player.Player) { - ResourceLocation loc = EntityType.getKey(entity.getType()); + Identifier loc = EntityType.getKey(entity.getType()); tag = TagUtil.saveEntity(entity); tag.putString("id", loc.toString()); payload.nbt = tag; @@ -313,7 +313,7 @@ public class ServuxLitematicsProtocol implements LeavesProtocol { public static class ServuxLitematicaPayload implements LeavesCustomPayload { @ID - public static final ResourceLocation CHANNEL = ServuxProtocol.id("litematics"); + public static final Identifier CHANNEL = ServuxProtocol.id("litematics"); @Codec public static final StreamCodec CODEC = StreamCodec.of( diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/utils/EntityUtils.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/utils/EntityUtils.java index 1a1c46f..a95d5b2 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/utils/EntityUtils.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/utils/EntityUtils.java @@ -70,7 +70,7 @@ public class EntityUtils { Entity passenger = createEntityAndPassengersFromNBT(tagList.getCompoundOrEmpty(i), world); if (passenger != null) { - passenger.startRiding(entity, true); + passenger.startRiding(entity, true, true); } } } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/utils/SchematicPlacingUtils.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/utils/SchematicPlacingUtils.java index bb5728a..43982c9 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/utils/SchematicPlacingUtils.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/utils/SchematicPlacingUtils.java @@ -28,7 +28,7 @@ import net.minecraft.world.entity.Display; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.decoration.ItemFrame; -import net.minecraft.world.entity.decoration.Painting; +import net.minecraft.world.entity.decoration.painting.Painting; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/logger/DataLogger.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/logger/DataLogger.java index 28f0761..369bce7 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/logger/DataLogger.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/logger/DataLogger.java @@ -119,7 +119,7 @@ public abstract class DataLogger { ServerTickRateManager tickManager = server.tickRateManager(); boolean frozen = tickManager.isFrozen(); boolean sprinting = tickManager.isSprinting(); - io.papermc.paper.threadedregions.TickData.TickReportData tickData = TickRegionScheduler.getCurrentRegion().getData().getRegionSchedulingHandle().getTickReport5s(System.nanoTime()); + ca.spottedleaf.moonrise.common.time.TickData.TickReportData tickData = TickRegionScheduler.getCurrentRegion().getData().getRegionSchedulingHandle().getTickReport5s(System.nanoTime()); final double tps = tickData.tpsData().segmentAll().average(); final double mspt = tickData.timePerTickData().segmentAll().average() / 1.0E6; @@ -163,7 +163,7 @@ public abstract class DataLogger { } try { - nbt.put(nmsEntity.level().dimension().location().toString(), MobCapData.CODEC.encodeStart(player.level().registryAccess().createSerializationContext(NbtOps.INSTANCE), mobCapData).getPartialOrThrow()); + nbt.put(nmsEntity.level().dimension().identifier().toString(), MobCapData.CODEC.encodeStart(player.level().registryAccess().createSerializationContext(NbtOps.INSTANCE), mobCapData).getPartialOrThrow()); protocol.applyData(Type.MOB_CAPS, (ServerPlayer) nmsEntity, nbt); } catch (Exception ignored) { } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java index ebb9c73..e22aeda 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java @@ -23,7 +23,7 @@ import io.netty.buffer.Unpooled; import net.minecraft.core.BlockPos; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.block.Mirror; import net.minecraft.world.level.block.Rotation; @@ -63,7 +63,7 @@ public class CommunicationManager implements LeavesProtocol { final VersionHandshakeServer hi = new VersionHandshakeServer(newPlayer); playerMap.put(newPlayer, player); final GameProfile profile = player.getGameProfile(); - SyncmaticaProtocol.getPlayerIdentifierProvider().updateName(profile.getId(), profile.getName()); + SyncmaticaProtocol.getPlayerIdentifierProvider().updateName(profile.id(), profile.name()); startExchangeUnchecked(hi); } @@ -86,7 +86,7 @@ public class CommunicationManager implements LeavesProtocol { onPacket(player.connection.exchangeTarget, payload.packetType(), payload.data()); } - public static void onPacket(final @NotNull ExchangeTarget source, final ResourceLocation id, final FriendlyByteBuf packetBuf) { + public static void onPacket(final @NotNull ExchangeTarget source, final Identifier id, final FriendlyByteBuf packetBuf) { Exchange handler = null; final Collection potentialMessageTarget = source.getExchanges(); if (potentialMessageTarget != null) { @@ -105,7 +105,7 @@ public class CommunicationManager implements LeavesProtocol { } } - protected static void handle(ExchangeTarget source, @NotNull ResourceLocation id, FriendlyByteBuf packetBuf) { + protected static void handle(ExchangeTarget source, @NotNull Identifier id, FriendlyByteBuf packetBuf) { if (id.equals(PacketType.REQUEST_LITEMATIC.identifier)) { final UUID syncmaticaId = packetBuf.readUUID(); final ServerPlacement placement = SyncmaticaProtocol.getSyncmaticManager().getPlacement(syncmaticaId); @@ -157,7 +157,7 @@ public class CommunicationManager implements LeavesProtocol { final UUID placementId = packetBuf.readUUID(); final ServerPlacement placement = SyncmaticaProtocol.getSyncmaticManager().getPlacement(placementId); if (placement != null) { - if (!getGameProfile(source).getId().equals(placement.getOwner().uuid)) { + if (!getGameProfile(source).id().equals(placement.getOwner().uuid)) { return; } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PacketType.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PacketType.java index 8f109cf..52b1553 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PacketType.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PacketType.java @@ -17,7 +17,7 @@ package org.leavesmc.leaves.protocol.syncmatica; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; public enum PacketType { REGISTER_METADATA("register_metadata"), @@ -39,9 +39,9 @@ public enum PacketType { MODIFY_FINISH("modify_finish"), MESSAGE("mesage"); - public final ResourceLocation identifier; + public final Identifier identifier; PacketType(final String id) { - identifier = ResourceLocation.tryBuild(SyncmaticaProtocol.PROTOCOL_ID, id); + identifier = Identifier.tryBuild(SyncmaticaProtocol.PROTOCOL_ID, id); } } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java index 4db924e..cc97178 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java @@ -39,7 +39,7 @@ public class PlayerIdentifierProvider { } public PlayerIdentifier createOrGet(final @NotNull GameProfile gameProfile) { - return createOrGet(gameProfile.getId(), gameProfile.getName()); + return createOrGet(gameProfile.id(), gameProfile.name()); } public PlayerIdentifier createOrGet(final UUID uuid, final String playerName) { diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java index 7251e3a..1777c08 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java @@ -19,17 +19,17 @@ package org.leavesmc.leaves.protocol.syncmatica; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; -public record SyncmaticaPayload(ResourceLocation packetType, FriendlyByteBuf data) implements LeavesCustomPayload { +public record SyncmaticaPayload(Identifier packetType, FriendlyByteBuf data) implements LeavesCustomPayload { @ID - private static final ResourceLocation NETWORK_ID = ResourceLocation.tryBuild(SyncmaticaProtocol.PROTOCOL_ID, "main"); + private static final Identifier NETWORK_ID = Identifier.tryBuild(SyncmaticaProtocol.PROTOCOL_ID, "main"); @Codec private static final StreamCodec CODEC = StreamCodec.of( - (buf, payload) -> buf.writeResourceLocation(payload.packetType()).writeBytes(payload.data()), - buf -> new SyncmaticaPayload(buf.readResourceLocation(), new FriendlyByteBuf(buf.readBytes(buf.readableBytes()))) + (buf, payload) -> buf.writeIdentifier(payload.packetType()).writeBytes(payload.data()), + buf -> new SyncmaticaPayload(buf.readIdentifier(), new FriendlyByteBuf(buf.readBytes(buf.readableBytes()))) ); } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java index 30dc6dd..802d0a6 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java @@ -19,7 +19,7 @@ package org.leavesmc.leaves.protocol.syncmatica.exchange; import io.netty.buffer.Unpooled; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.syncmatica.*; @@ -50,7 +50,7 @@ public class DownloadExchange extends AbstractExchange { } @Override - public boolean checkPacket(final @NotNull ResourceLocation id, final FriendlyByteBuf packetBuf) { + public boolean checkPacket(final @NotNull Identifier id, final FriendlyByteBuf packetBuf) { if (id.equals(PacketType.SEND_LITEMATIC.identifier) || id.equals(PacketType.FINISHED_LITEMATIC.identifier) || id.equals(PacketType.CANCEL_LITEMATIC.identifier)) { @@ -60,7 +60,7 @@ public class DownloadExchange extends AbstractExchange { } @Override - public void handle(final @NotNull ResourceLocation id, final @NotNull FriendlyByteBuf packetBuf) { + public void handle(final @NotNull Identifier id, final @NotNull FriendlyByteBuf packetBuf) { packetBuf.readUUID(); if (id.equals(PacketType.SEND_LITEMATIC.identifier)) { final int size = packetBuf.readInt(); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java index 7d8b2d9..ae6810f 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java @@ -18,14 +18,14 @@ package org.leavesmc.leaves.protocol.syncmatica.exchange; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; public interface Exchange { ExchangeTarget getPartner(); - boolean checkPacket(ResourceLocation id, FriendlyByteBuf packetBuf); + boolean checkPacket(Identifier id, FriendlyByteBuf packetBuf); - void handle(ResourceLocation id, FriendlyByteBuf packetBuf); + void handle(Identifier id, FriendlyByteBuf packetBuf); boolean isFinished(); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java index 981414c..8c9280f 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java @@ -18,7 +18,7 @@ package org.leavesmc.leaves.protocol.syncmatica.exchange; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.network.ServerGamePacketListenerImpl; import org.leavesmc.leaves.protocol.core.ProtocolUtils; import org.leavesmc.leaves.protocol.syncmatica.FeatureSet; @@ -38,7 +38,7 @@ public class ExchangeTarget { this.client = client; } - public void sendPacket(final ResourceLocation id, final FriendlyByteBuf packetBuf) { + public void sendPacket(final Identifier id, final FriendlyByteBuf packetBuf) { ProtocolUtils.sendPayloadPacket(client.player, new SyncmaticaPayload(id, packetBuf)); } diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java index 4aa8f2d..e872d2b 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java @@ -19,7 +19,7 @@ package org.leavesmc.leaves.protocol.syncmatica.exchange; import io.netty.buffer.Unpooled; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.syncmatica.FeatureSet; import org.leavesmc.leaves.protocol.syncmatica.PacketType; @@ -32,13 +32,13 @@ public abstract class FeatureExchange extends AbstractExchange { } @Override - public boolean checkPacket(final @NotNull ResourceLocation id, final FriendlyByteBuf packetBuf) { + public boolean checkPacket(final @NotNull Identifier id, final FriendlyByteBuf packetBuf) { return id.equals(PacketType.FEATURE_REQUEST.identifier) || id.equals(PacketType.FEATURE.identifier); } @Override - public void handle(final @NotNull ResourceLocation id, final FriendlyByteBuf packetBuf) { + public void handle(final @NotNull Identifier id, final FriendlyByteBuf packetBuf) { if (id.equals(PacketType.FEATURE_REQUEST.identifier)) { sendFeatures(); } else if (id.equals(PacketType.FEATURE.identifier)) { diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java index 7aaf882..347d5c9 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java @@ -19,7 +19,7 @@ package org.leavesmc.leaves.protocol.syncmatica.exchange; import io.netty.buffer.Unpooled; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.syncmatica.*; @@ -37,12 +37,12 @@ public class ModifyExchangeServer extends AbstractExchange { } @Override - public boolean checkPacket(final @NotNull ResourceLocation id, final FriendlyByteBuf packetBuf) { + public boolean checkPacket(final @NotNull Identifier id, final FriendlyByteBuf packetBuf) { return id.equals(PacketType.MODIFY_FINISH.identifier) && checkUUID(packetBuf, placement.getId()); } @Override - public void handle(final @NotNull ResourceLocation id, final @NotNull FriendlyByteBuf packetBuf) { + public void handle(final @NotNull Identifier id, final @NotNull FriendlyByteBuf packetBuf) { packetBuf.readUUID(); if (id.equals(PacketType.MODIFY_FINISH.identifier)) { CommunicationManager.receivePositionData(placement, packetBuf, getPartner()); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java index ad170d5..2e7ec8f 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java @@ -19,7 +19,7 @@ package org.leavesmc.leaves.protocol.syncmatica.exchange; import io.netty.buffer.Unpooled; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.syncmatica.PacketType; import org.leavesmc.leaves.protocol.syncmatica.ServerPlacement; @@ -41,7 +41,7 @@ public class UploadExchange extends AbstractExchange { } @Override - public boolean checkPacket(final @NotNull ResourceLocation id, final FriendlyByteBuf packetBuf) { + public boolean checkPacket(final @NotNull Identifier id, final FriendlyByteBuf packetBuf) { if (id.equals(PacketType.RECEIVED_LITEMATIC.identifier) || id.equals(PacketType.CANCEL_LITEMATIC.identifier)) { return checkUUID(packetBuf, toUpload.getId()); @@ -50,7 +50,7 @@ public class UploadExchange extends AbstractExchange { } @Override - public void handle(final @NotNull ResourceLocation id, final @NotNull FriendlyByteBuf packetBuf) { + public void handle(final @NotNull Identifier id, final @NotNull FriendlyByteBuf packetBuf) { packetBuf.readUUID(); if (id.equals(PacketType.RECEIVED_LITEMATIC.identifier)) { send(); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java index e6d1a6f..c4a6a06 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java @@ -19,7 +19,7 @@ package org.leavesmc.leaves.protocol.syncmatica.exchange; import io.netty.buffer.Unpooled; import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.syncmatica.*; @@ -32,13 +32,13 @@ public class VersionHandshakeServer extends FeatureExchange { } @Override - public boolean checkPacket(final @NotNull ResourceLocation id, final FriendlyByteBuf packetBuf) { + public boolean checkPacket(final @NotNull Identifier id, final FriendlyByteBuf packetBuf) { return id.equals(PacketType.REGISTER_VERSION.identifier) || super.checkPacket(id, packetBuf); } @Override - public void handle(final @NotNull ResourceLocation id, final FriendlyByteBuf packetBuf) { + public void handle(final @NotNull Identifier id, final FriendlyByteBuf packetBuf) { if (id.equals(PacketType.REGISTER_VERSION.identifier)) { String partnerVersion = packetBuf.readUtf(); if (partnerVersion.equals("0.0.1")) { diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java b/lophine-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java index a3cdb14..917fdf5 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java @@ -31,8 +31,8 @@ import net.minecraft.core.Registry; import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.util.context.ContextMap; import net.minecraft.world.item.*; @@ -251,7 +251,7 @@ public class HopperCounter { return direct; } - ResourceLocation id = registryAccess.lookupOrThrow(Registries.ITEM).getKey(item); + Identifier id = registryAccess.lookupOrThrow(Registries.ITEM).getKey(item); if (id == null) { return null; } @@ -269,13 +269,13 @@ public class HopperCounter { } @NotNull - public static List> getRecipesForOutput(@NotNull RecipeManager recipeManager, ResourceLocation id, Level level) { + public static List> getRecipesForOutput(@NotNull RecipeManager recipeManager, Identifier id, Level level) { List> results = new ArrayList<>(); ContextMap context = SlotDisplayContext.fromLevel(level); recipeManager.getRecipes().forEach(recipe -> { for (RecipeDisplay recipeDisplay : recipe.value().display()) { recipeDisplay.result().resolveForStacks(context).forEach(stack -> { - if (BuiltInRegistries.ITEM.wrapAsHolder(stack.getItem()).unwrapKey().map(ResourceKey::location).orElseThrow(IllegalStateException::new).equals(id)) { + if (BuiltInRegistries.ITEM.wrapAsHolder(stack.getItem()).unwrapKey().map(ResourceKey::identifier).orElseThrow(IllegalStateException::new).equals(id)) { results.add(recipe.value()); } }); @@ -296,7 +296,7 @@ public class HopperCounter { Block block = null; final Registry itemRegistry = registryAccess.lookupOrThrow(Registries.ITEM); final Registry blockRegistry = registryAccess.lookupOrThrow(Registries.BLOCK); - ResourceLocation id = itemRegistry.getKey(item); + Identifier id = itemRegistry.getKey(item); if (item instanceof BlockItem blockItem) { block = blockItem.getBlock(); } else if (blockRegistry.getOptional(id).isPresent()) { diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/util/ShearsWrenchUtil.java b/lophine-server/src/main/java/org/leavesmc/leaves/util/ShearsWrenchUtil.java index c2afc92..fe2a6da 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/util/ShearsWrenchUtil.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/util/ShearsWrenchUtil.java @@ -1,10 +1,10 @@ package org.leavesmc.leaves.util; import fun.bm.lophine.config.modules.function.RedStoneConfig; -import net.minecraft.Util; import net.minecraft.core.BlockPos; import net.minecraft.network.chat.Component; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.util.Util; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/util/UpdateSuppressionException.java b/lophine-server/src/main/java/org/leavesmc/leaves/util/UpdateSuppressionException.java index dc02760..77e71fc 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/util/UpdateSuppressionException.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/util/UpdateSuppressionException.java @@ -115,7 +115,7 @@ public class UpdateSuppressionException extends RuntimeException { messages.add("at [x:%d,y:%d,z:%d]".formatted(pos.getX(), pos.getY(), pos.getZ())); } if (level != null) { - messages.add("in %s".formatted(level.dimension().location())); + messages.add("in %s".formatted(level.dimension().identifier().getPath())); } if (player != null) { if (player instanceof ServerBot) {