diff --git a/gradle.properties b/gradle.properties index 2e26bff55..c0dda2a54 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,14 @@ group=org.leavesmc.leaves -version=1.21.10-R0.1-SNAPSHOT -mcVersion=1.21.10 -paperRef=af06383701d3c02e3e3cbd2ef5c5b55e2bbd0742 +version=1.21.11-R0.1-SNAPSHOT +mcVersion=1.21.11 +paperRef=c5a2736aaa33a6447badd2ed294fbf5940cb014b preVersion=true paper.runDisableWatchdog=true +# This is the current API version for use in (paper-/leaves-)plugin.yml files +# During snapshot cycles this should be the anticipated version of the release target +apiVersion=1.21.11 + org.gradle.configuration-cache=false org.gradle.caching=true org.gradle.parallel=true diff --git a/leaves-api/build.gradle.kts.patch b/leaves-api/build.gradle.kts.patch index 0fcd25ba9..5f611ce9d 100644 --- a/leaves-api/build.gradle.kts.patch +++ b/leaves-api/build.gradle.kts.patch @@ -1,6 +1,6 @@ --- a/paper-api/build.gradle.kts +++ b/paper-api/build.gradle.kts -@@ -89,19 +_,33 @@ +@@ -91,19 +_,33 @@ testRuntimeOnly("org.junit.platform:junit-platform-launcher") } @@ -35,7 +35,7 @@ val outgoingVariants = arrayOf("runtimeElements", "apiElements", "sourcesElements", "javadocElements") val mainCapability = "${project.group}:${project.name}:${project.version}" -@@ -146,6 +_,16 @@ +@@ -138,6 +_,16 @@ } } @@ -49,10 +49,10 @@ +} +// Leaves end - hide irrelevant compilation warnings + - tasks.jar { - from(generateApiVersioningFile.map { it.outputs.files.singleFile }) { - into("META-INF/maven/${project.group}/${project.name}") -@@ -165,7 +_,7 @@ + abstract class GenerateApiVersioningFile : DefaultTask() { + @get:OutputFile + abstract val outputFile: RegularFileProperty +@@ -183,7 +_,7 @@ tasks.withType().configureEach { val options = options as StandardJavadocDocletOptions @@ -61,7 +61,7 @@ options.use() options.isDocFilesSubDirs = true options.links( -@@ -198,16 +_,18 @@ +@@ -217,16 +_,18 @@ } // workaround for https://github.com/gradle/gradle/issues/4046 diff --git a/leaves-api/paper-patches/features/0001-Delete-Timings.patch b/leaves-api/paper-patches/features/0001-Delete-Timings.patch index b52444323..92813ef96 100644 --- a/leaves-api/paper-patches/features/0001-Delete-Timings.patch +++ b/leaves-api/paper-patches/features/0001-Delete-Timings.patch @@ -2859,7 +2859,7 @@ index 3e61a926620a67daec3af54b72a1b911eaef2ed4..00000000000000000000000000000000 - } -} diff --git a/src/main/java/org/bukkit/command/Command.java b/src/main/java/org/bukkit/command/Command.java -index e387ba67f0b6cde8ee2be7acba8f791792802ad4..06402e9d811b62ea59c67ecbffe9272c73f2040d 100644 +index 3171a20c8fcff10a8da3dd822c8bba3f58f59e02..9fd50b3ffaa7edebf5d975b35475e451bc8de8d8 100644 --- a/src/main/java/org/bukkit/command/Command.java +++ b/src/main/java/org/bukkit/command/Command.java @@ -32,16 +32,6 @@ public abstract class Command { diff --git a/leaves-api/paper-patches/features/0002-Add-isShrink-to-EntityResurrectEvent.patch b/leaves-api/paper-patches/features/0002-Add-isShrink-to-EntityResurrectEvent.patch index 203559834..d44fa2751 100644 --- a/leaves-api/paper-patches/features/0002-Add-isShrink-to-EntityResurrectEvent.patch +++ b/leaves-api/paper-patches/features/0002-Add-isShrink-to-EntityResurrectEvent.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Add isShrink to EntityResurrectEvent diff --git a/src/main/java/org/bukkit/event/entity/EntityResurrectEvent.java b/src/main/java/org/bukkit/event/entity/EntityResurrectEvent.java -index fa60c0ce5c79757952ad39932e1c5fac8b068811..71fd070aaebfd9fa0fbfd6eb7cd26c8b34120203 100644 +index b3e4c6b3c882888b4bc2b93dc4ed2ae0c149ec19..a8d36f0b120740b4c6ea5fbf205b28aba1473206 100644 --- a/src/main/java/org/bukkit/event/entity/EntityResurrectEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntityResurrectEvent.java @@ -17,22 +17,46 @@ public class EntityResurrectEvent extends EntityEvent implements Cancellable { diff --git a/leaves-api/paper-patches/features/0003-Add-fakeplayer-api.patch b/leaves-api/paper-patches/features/0003-Add-fakeplayer-api.patch index 8ad1b2daa..4d3785373 100644 --- a/leaves-api/paper-patches/features/0003-Add-fakeplayer-api.patch +++ b/leaves-api/paper-patches/features/0003-Add-fakeplayer-api.patch @@ -25,10 +25,10 @@ index 14d81c7b138ebf999d5812d26fbf869209c100f3..3b0513fbbf46e7cbb1790264eebaed98 + // Leaves end - Bot API } diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 964b57bb240151ddf4f11c203b67e8be6469e473..865842a857e5371bd82133a018582c7b88566403 100644 +index 0ec885b97d655c03371840d739b47063494ed36f..bc9bdaadf6b6bb7cc7a8cf2d4e9b8e7724f36445 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2760,4 +2760,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2761,4 +2761,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ void allowPausing(@NotNull org.bukkit.plugin.Plugin plugin, boolean value); // Paper end - API to check if the server is sleeping diff --git a/leaves-api/paper-patches/features/0004-Replay-Mod-API.patch b/leaves-api/paper-patches/features/0004-Replay-Mod-API.patch index 11cd9e02c..d285ac1fa 100644 --- a/leaves-api/paper-patches/features/0004-Replay-Mod-API.patch +++ b/leaves-api/paper-patches/features/0004-Replay-Mod-API.patch @@ -20,15 +20,13 @@ index 3b0513fbbf46e7cbb1790264eebaed9862d48eb5..44ee8036e2f813e947c2c166e1876030 + // Leaves end - Photographer API } diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 865842a857e5371bd82133a018582c7b88566403..74f704d4245199205afff5a992805f40a365cc81 100644 +index bc9bdaadf6b6bb7cc7a8cf2d4e9b8e7724f36445..f2d616b896ac7998c75c9ded8dd28cf2b49dd416 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2769,4 +2769,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2770,4 +2770,6 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi */ @NotNull org.leavesmc.leaves.entity.bot.BotManager getBotManager(); // Leaves end - Bot API + -+ // Leaves start - Photographer API -+ @NotNull org.leavesmc.leaves.entity.photographer.PhotographerManager getPhotographerManager(); -+ // Leaves end - Photographer API ++ @NotNull org.leavesmc.leaves.entity.photographer.PhotographerManager getPhotographerManager(); // Leaves - Photographer API } diff --git a/leaves-api/paper-patches/features/0005-Bytebuf-API.patch b/leaves-api/paper-patches/features/0005-Bytebuf-API.patch index ebea3a338..815a8644b 100644 --- a/leaves-api/paper-patches/features/0005-Bytebuf-API.patch +++ b/leaves-api/paper-patches/features/0005-Bytebuf-API.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Bytebuf API diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index 44ee8036e2f813e947c2c166e1876030cabf86ff..c25729882f87a904e59680967f3d20b02df50eae 100644 +index 44ee8036e2f813e947c2c166e1876030cabf86ff..29570b8bcf34806af2f8d3dfdd656319176a61e5 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -3020,4 +3020,10 @@ public final class Bukkit { @@ -14,38 +14,32 @@ index 44ee8036e2f813e947c2c166e1876030cabf86ff..c25729882f87a904e59680967f3d20b0 // Leaves end - Photographer API + + // Leaves start - Bytebuf API -+ public static org.leavesmc.leaves.bytebuf.BytebufManager getBytebufManager() { -+ return server.getBytebufManager(); ++ public static org.leavesmc.leaves.bytebuf.BytebufAllocator getBytebufManager() { ++ return server.getBytebufAllocator(); + } + // Leaves end - Bytebuf API } diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 74f704d4245199205afff5a992805f40a365cc81..9f9051214c81e1fc4a6f1a0b0d18ea98bdf2fe92 100644 +index f2d616b896ac7998c75c9ded8dd28cf2b49dd416..9544b376e457b3b62f6c025bd31f2bb2a5318269 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2773,4 +2773,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi - // Leaves start - Photographer API - @NotNull org.leavesmc.leaves.entity.photographer.PhotographerManager getPhotographerManager(); - // Leaves end - Photographer API +@@ -2772,4 +2772,6 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi + // Leaves end - Bot API + + @NotNull org.leavesmc.leaves.entity.photographer.PhotographerManager getPhotographerManager(); // Leaves - Photographer API + -+ // Leaves start - Bytebuf API -+ org.leavesmc.leaves.bytebuf.BytebufManager getBytebufManager(); -+ // Leaves end - Bytebuf API ++ org.leavesmc.leaves.bytebuf.BytebufAllocator getBytebufAllocator(); // Leaves - Bytebuf API } diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java -index 3eef8d533c2aa65d66fbd58f2260b4764a964ebe..73285735653a3aec90df4866b3f97f8ca38a5394 100644 +index 26d9139886d851824829734228e0bcceabba92d5..3b3a5072fda47ee483e6e7c73263ffc321ea9a6b 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java -@@ -3931,6 +3931,12 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM - boolean isChunkSent(long chunkKey); - // Paper end +@@ -66,7 +66,7 @@ import org.jspecify.annotations.Nullable; + * Represents a player, connected or not + */ + @NullMarked +-public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, net.kyori.adventure.bossbar.BossBarViewer, com.destroystokyo.paper.network.NetworkClient { // Paper ++public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginMessageRecipient, net.kyori.adventure.identity.Identified, net.kyori.adventure.bossbar.BossBarViewer, com.destroystokyo.paper.network.NetworkClient, org.leavesmc.leaves.bytebuf.PacketAudience { // Paper // Leaves - Bytbuf API -+ // Leaves start - Bytebuf API -+ void sendPacket(org.leavesmc.leaves.bytebuf.packet.Packet packet); -+ -+ void sendPacket(org.leavesmc.leaves.bytebuf.Bytebuf buf, org.leavesmc.leaves.bytebuf.packet.PacketType type); -+ // Leaves end - Bytebuf API -+ + // Paper start @Override - Spigot spigot(); - // Spigot end diff --git a/leaves-api/paper-patches/features/0006-Revert-raid-changes.patch b/leaves-api/paper-patches/features/0006-Revert-raid-changes.patch index 32048e025..be2deacfd 100644 --- a/leaves-api/paper-patches/features/0006-Revert-raid-changes.patch +++ b/leaves-api/paper-patches/features/0006-Revert-raid-changes.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Revert raid changes diff --git a/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java b/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java -index 22e14ba522510d659c191d72536cde895458d9ed..253f937dbd130fac064963b4af7572e1302fee8f 100644 +index 61ff80a91c392e9e3c8eb393356b40721d28b6ec..57a24231962883affbcc5b46c0b952470398acb8 100644 --- a/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java +++ b/src/main/java/org/bukkit/event/entity/EntityPotionEffectEvent.java -@@ -221,9 +221,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable +@@ -225,9 +225,7 @@ public class EntityPotionEffectEvent extends EntityEvent implements Cancellable /** * When a player gets bad omen after killing a patrol captain. * diff --git a/leaves-api/paper-patches/features/0007-Fix-SculkCatalyst-exp-skip.patch b/leaves-api/paper-patches/features/0007-Fix-SculkCatalyst-exp-skip.patch index 97f865c06..c2ad7b4c5 100644 --- a/leaves-api/paper-patches/features/0007-Fix-SculkCatalyst-exp-skip.patch +++ b/leaves-api/paper-patches/features/0007-Fix-SculkCatalyst-exp-skip.patch @@ -64,7 +64,7 @@ index 76c08499b704a6cb0cb95ce69b9a9248d69cc127..316bbf8c95e4803190897d66a0c7d8b4 public boolean isCancelled() { return this.cancelled; diff --git a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java -index 6316a2f1d2dc0314397e33e6dbd354fb8bc50541..16d4e3d42710be5eb87372d31c0ea9935d441de0 100644 +index 78497c423edaff9550315610ccc2f3d4d3614dce..6e9f3b0dc789103e208a806cbecaea7ee1790ff4 100644 --- a/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java +++ b/src/main/java/org/bukkit/event/entity/PlayerDeathEvent.java @@ -23,6 +23,7 @@ public class PlayerDeathEvent extends EntityDeathEvent { diff --git a/leaves-api/paper-patches/features/0008-Leaves-Config-API.patch b/leaves-api/paper-patches/features/0008-Leaves-Config-API.patch index 170f6c937..6a9e3307d 100644 --- a/leaves-api/paper-patches/features/0008-Leaves-Config-API.patch +++ b/leaves-api/paper-patches/features/0008-Leaves-Config-API.patch @@ -5,11 +5,11 @@ Subject: [PATCH] Leaves Config API diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index c25729882f87a904e59680967f3d20b02df50eae..5cc913f9e903ea5ef51c2e2b8cc18fdad8838c1e 100644 +index 29570b8bcf34806af2f8d3dfdd656319176a61e5..786546ba9503a6fc7762589059b998afc62d8e22 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -3026,4 +3026,10 @@ public final class Bukkit { - return server.getBytebufManager(); + return server.getBytebufAllocator(); } // Leaves end - Bytebuf API + @@ -20,15 +20,13 @@ index c25729882f87a904e59680967f3d20b02df50eae..5cc913f9e903ea5ef51c2e2b8cc18fda + // Leaves end - Config API } diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 9f9051214c81e1fc4a6f1a0b0d18ea98bdf2fe92..95621c3b4279f4d1b7786772cc035f3747e9d84f 100644 +index 9544b376e457b3b62f6c025bd31f2bb2a5318269..bd84c7725effc55b00510d0b7a050343e2ff0361 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2777,4 +2777,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi - // Leaves start - Bytebuf API - org.leavesmc.leaves.bytebuf.BytebufManager getBytebufManager(); - // Leaves end - Bytebuf API +@@ -2774,4 +2774,6 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi + @NotNull org.leavesmc.leaves.entity.photographer.PhotographerManager getPhotographerManager(); // Leaves - Photographer API + + org.leavesmc.leaves.bytebuf.BytebufAllocator getBytebufAllocator(); // Leaves - Bytebuf API + -+ // Leaves start - Config API -+ org.leavesmc.leaves.config.LeavesConfigProvider getLeavesConfig(); -+ // Leaves End - Config API ++ org.leavesmc.leaves.config.LeavesConfigProvider getLeavesConfig(); // Leaves - Config API } diff --git a/leaves-api/paper-patches/features/0009-Leaves-Plugin.patch b/leaves-api/paper-patches/features/0009-Leaves-Plugin.patch index 8b209602b..d0d4134bd 100644 --- a/leaves-api/paper-patches/features/0009-Leaves-Plugin.patch +++ b/leaves-api/paper-patches/features/0009-Leaves-Plugin.patch @@ -23,10 +23,10 @@ index 5cc913f9e903ea5ef51c2e2b8cc18fdad8838c1e..554b8977c9b358f177e29907bcebaed8 /** * Returns a bot manager. diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 95621c3b4279f4d1b7786772cc035f3747e9d84f..cdc5295db1dbbd4b20a0acc99fdcc9013d6a5489 100644 +index 0a52d9cffa58c922079bf97deb32dd4f057da097..23b878d9cfe4bdc0ddbd1d2d0663efecc7e5e8fb 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java -@@ -2761,6 +2761,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi +@@ -2762,6 +2762,10 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi void allowPausing(@NotNull org.bukkit.plugin.Plugin plugin, boolean value); // Paper end - API to check if the server is sleeping diff --git a/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/Bytebuf.java b/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/Bytebuf.java index fc34d446c..7577593e0 100644 --- a/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/Bytebuf.java +++ b/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/Bytebuf.java @@ -23,6 +23,8 @@ static Bytebuf of(byte[] bytes) { byte[] toArray(); + Bytebuf clear(); + Bytebuf skipBytes(int i); int readerIndex(); diff --git a/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/BytebufAllocator.java b/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/BytebufAllocator.java new file mode 100644 index 000000000..14e4bbc8b --- /dev/null +++ b/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/BytebufAllocator.java @@ -0,0 +1,8 @@ +package org.leavesmc.leaves.bytebuf; + +public interface BytebufAllocator { + + Bytebuf newBytebuf(int size); + + Bytebuf toBytebuf(byte[] bytes); +} diff --git a/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/BytebufManager.java b/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/BytebufManager.java deleted file mode 100644 index f659eb342..000000000 --- a/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/BytebufManager.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.leavesmc.leaves.bytebuf; - -import org.bukkit.plugin.Plugin; -import org.leavesmc.leaves.bytebuf.packet.PacketListener; - -public interface BytebufManager { - - @Deprecated - void registerListener(Plugin plugin, PacketListener listener); - - @Deprecated - void unregisterListener(Plugin plugin, PacketListener listener); - - Bytebuf newBytebuf(int size); - - Bytebuf toBytebuf(byte[] bytes); -} diff --git a/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/PacketAudience.java b/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/PacketAudience.java new file mode 100644 index 000000000..3c5f2c1f3 --- /dev/null +++ b/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/PacketAudience.java @@ -0,0 +1,16 @@ +package org.leavesmc.leaves.bytebuf; + +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public interface PacketAudience { + + void send(PacketType packetType, Bytebuf bytebuf); + + @Nullable Player getPlayer(); + + @Nullable String getName(); + + @NotNull Object getChannel(); +} diff --git a/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/PacketFlow.java b/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/PacketFlow.java new file mode 100644 index 000000000..c23b0d828 --- /dev/null +++ b/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/PacketFlow.java @@ -0,0 +1,5 @@ +package org.leavesmc.leaves.bytebuf; + +public enum PacketFlow { + SERVERBOUND, CLIENTBOUND +} diff --git a/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/PacketType.java b/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/PacketType.java new file mode 100644 index 000000000..b1f38e4b9 --- /dev/null +++ b/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/PacketType.java @@ -0,0 +1,272 @@ +package org.leavesmc.leaves.bytebuf; + +public interface PacketType { + + String id(); + + PacketFlow bound(); + + enum Clientbound implements PacketType { + CLEAR_DIALOG("clientbound/clear_dialog"), + CUSTOM_PAYLOAD("clientbound/custom_payload"), + CUSTOM_REPORT_DETAILS("clientbound/custom_report_details"), + DISCONNECT("clientbound/disconnect"), + KEEP_ALIVE("clientbound/keep_alive"), + PING("clientbound/ping"), + RESOURCE_PACK_POP("clientbound/resource_pack_pop"), + RESOURCE_PACK_PUSH("clientbound/resource_pack_push"), + SERVER_LINKS("clientbound/server_links"), + SHOW_DIALOG("clientbound/show_dialog"), + STORE_COOKIE("clientbound/store_cookie"), + TRANSFER("clientbound/transfer"), + UPDATE_TAGS("clientbound/update_tags"), + CODE_OF_CONDUCT("clientbound/code_of_conduct"), + FINISH_CONFIGURATION("clientbound/finish_configuration"), + REGISTRY_DATA("clientbound/registry_data"), + RESET_CHAT("clientbound/reset_chat"), + SELECT_KNOWN_PACKS("clientbound/select_known_packs"), + UPDATE_ENABLED_FEATURES("clientbound/update_enabled_features"), + COOKIE_REQUEST("clientbound/cookie_request"), + BUNDLE("clientbound/bundle"), + BUNDLE_DELIMITER("clientbound/bundle_delimiter"), + ADD_ENTITY("clientbound/add_entity"), + ANIMATE("clientbound/animate"), + AWARD_STATS("clientbound/award_stats"), + BLOCK_CHANGED_ACK("clientbound/block_changed_ack"), + BLOCK_DESTRUCTION("clientbound/block_destruction"), + BLOCK_ENTITY_DATA("clientbound/block_entity_data"), + BLOCK_EVENT("clientbound/block_event"), + BLOCK_UPDATE("clientbound/block_update"), + BOSS_EVENT("clientbound/boss_event"), + CHANGE_DIFFICULTY("clientbound/change_difficulty"), + CHUNK_BATCH_FINISHED("clientbound/chunk_batch_finished"), + CHUNK_BATCH_START("clientbound/chunk_batch_start"), + CHUNKS_BIOMES("clientbound/chunks_biomes"), + CLEAR_TITLES("clientbound/clear_titles"), + COMMAND_SUGGESTIONS("clientbound/command_suggestions"), + COMMANDS("clientbound/commands"), + CONTAINER_CLOSE("clientbound/container_close"), + CONTAINER_SET_CONTENT("clientbound/container_set_content"), + CONTAINER_SET_DATA("clientbound/container_set_data"), + CONTAINER_SET_SLOT("clientbound/container_set_slot"), + COOLDOWN("clientbound/cooldown"), + CUSTOM_CHAT_COMPLETIONS("clientbound/custom_chat_completions"), + DAMAGE_EVENT("clientbound/damage_event"), + DEBUG_BLOCK_VALUE("clientbound/debug/block_value"), + DEBUG_CHUNK_VALUE("clientbound/debug/chunk_value"), + DEBUG_ENTITY_VALUE("clientbound/debug/entity_value"), + DEBUG_EVENT("clientbound/debug/event"), + DEBUG_SAMPLE("clientbound/debug_sample"), + DELETE_CHAT("clientbound/delete_chat"), + DISGUISED_CHAT("clientbound/disguised_chat"), + ENTITY_EVENT("clientbound/entity_event"), + ENTITY_POSITION_SYNC("clientbound/entity_position_sync"), + EXPLODE("clientbound/explode"), + FORGET_LEVEL_CHUNK("clientbound/forget_level_chunk"), + GAME_EVENT("clientbound/game_event"), + GAME_TEST_HIGHLIGHT_POS("clientbound/game_test_highlight_pos"), + MOUNT_SCREEN_OPEN("clientbound/mount_screen_open"), + HURT_ANIMATION("clientbound/hurt_animation"), + INITIALIZE_BORDER("clientbound/initialize_border"), + LEVEL_CHUNK_WITH_LIGHT("clientbound/level_chunk_with_light"), + LEVEL_EVENT("clientbound/level_event"), + LEVEL_PARTICLES("clientbound/level_particles"), + LIGHT_UPDATE("clientbound/light_update"), + LOGIN("clientbound/login"), + MAP_ITEM_DATA("clientbound/map_item_data"), + MERCHANT_OFFERS("clientbound/merchant_offers"), + MOVE_ENTITY_POS("clientbound/move_entity_pos"), + MOVE_ENTITY_POS_ROT("clientbound/move_entity_pos_rot"), + MOVE_MINECART_ALONG_TRACK("clientbound/move_minecart_along_track"), + MOVE_ENTITY_ROT("clientbound/move_entity_rot"), + MOVE_VEHICLE("clientbound/move_vehicle"), + OPEN_BOOK("clientbound/open_book"), + OPEN_SCREEN("clientbound/open_screen"), + OPEN_SIGN_EDITOR("clientbound/open_sign_editor"), + PLACE_GHOST_RECIPE("clientbound/place_ghost_recipe"), + PLAYER_ABILITIES("clientbound/player_abilities"), + PLAYER_CHAT("clientbound/player_chat"), + PLAYER_COMBAT_END("clientbound/player_combat_end"), + PLAYER_COMBAT_ENTER("clientbound/player_combat_enter"), + PLAYER_COMBAT_KILL("clientbound/player_combat_kill"), + PLAYER_INFO_REMOVE("clientbound/player_info_remove"), + PLAYER_INFO_UPDATE("clientbound/player_info_update"), + PLAYER_LOOK_AT("clientbound/player_look_at"), + PLAYER_POSITION("clientbound/player_position"), + PLAYER_ROTATION("clientbound/player_rotation"), + RECIPE_BOOK_ADD("clientbound/recipe_book_add"), + RECIPE_BOOK_REMOVE("clientbound/recipe_book_remove"), + RECIPE_BOOK_SETTINGS("clientbound/recipe_book_settings"), + REMOVE_ENTITIES("clientbound/remove_entities"), + REMOVE_MOB_EFFECT("clientbound/remove_mob_effect"), + RESPAWN("clientbound/respawn"), + ROTATE_HEAD("clientbound/rotate_head"), + SECTION_BLOCKS_UPDATE("clientbound/section_blocks_update"), + SELECT_ADVANCEMENTS_TAB("clientbound/select_advancements_tab"), + SERVER_DATA("clientbound/server_data"), + SET_ACTION_BAR_TEXT("clientbound/set_action_bar_text"), + SET_BORDER_CENTER("clientbound/set_border_center"), + SET_BORDER_LERP_SIZE("clientbound/set_border_lerp_size"), + SET_BORDER_SIZE("clientbound/set_border_size"), + SET_BORDER_WARNING_DELAY("clientbound/set_border_warning_delay"), + SET_BORDER_WARNING_DISTANCE("clientbound/set_border_warning_distance"), + SET_CAMERA("clientbound/set_camera"), + SET_CHUNK_CACHE_CENTER("clientbound/set_chunk_cache_center"), + SET_CHUNK_CACHE_RADIUS("clientbound/set_chunk_cache_radius"), + SET_DEFAULT_SPAWN_POSITION("clientbound/set_default_spawn_position"), + SET_DISPLAY_OBJECTIVE("clientbound/set_display_objective"), + SET_ENTITY_DATA("clientbound/set_entity_data"), + SET_ENTITY_LINK("clientbound/set_entity_link"), + SET_ENTITY_MOTION("clientbound/set_entity_motion"), + SET_EQUIPMENT("clientbound/set_equipment"), + SET_EXPERIENCE("clientbound/set_experience"), + SET_HEALTH("clientbound/set_health"), + SET_HELD_SLOT("clientbound/set_held_slot"), + SET_OBJECTIVE("clientbound/set_objective"), + SET_PASSENGERS("clientbound/set_passengers"), + SET_PLAYER_TEAM("clientbound/set_player_team"), + SET_SCORE("clientbound/set_score"), + SET_SIMULATION_DISTANCE("clientbound/set_simulation_distance"), + SET_SUBTITLE_TEXT("clientbound/set_subtitle_text"), + SET_TIME("clientbound/set_time"), + SET_TITLE_TEXT("clientbound/set_title_text"), + SET_TITLES_ANIMATION("clientbound/set_titles_animation"), + SOUND_ENTITY("clientbound/sound_entity"), + SOUND("clientbound/sound"), + START_CONFIGURATION("clientbound/start_configuration"), + STOP_SOUND("clientbound/stop_sound"), + SYSTEM_CHAT("clientbound/system_chat"), + TAB_LIST("clientbound/tab_list"), + TAG_QUERY("clientbound/tag_query"), + TAKE_ITEM_ENTITY("clientbound/take_item_entity"), + TELEPORT_ENTITY("clientbound/teleport_entity"), + TEST_INSTANCE_BLOCK_STATUS("clientbound/test_instance_block_status"), + UPDATE_ADVANCEMENTS("clientbound/update_advancements"), + UPDATE_ATTRIBUTES("clientbound/update_attributes"), + UPDATE_MOB_EFFECT("clientbound/update_mob_effect"), + UPDATE_RECIPES("clientbound/update_recipes"), + PROJECTILE_POWER("clientbound/projectile_power"), + WAYPOINT("clientbound/waypoint"), + RESET_SCORE("clientbound/reset_score"), + TICKING_STATE("clientbound/ticking_state"), + TICKING_STEP("clientbound/ticking_step"), + SET_CURSOR_ITEM("clientbound/set_cursor_item"), + SET_PLAYER_INVENTORY("clientbound/set_player_inventory"), + CUSTOM_QUERY("clientbound/custom_query"), + LOGIN_FINISHED("clientbound/login_finished"), + HELLO("clientbound/hello"), + LOGIN_COMPRESSION("clientbound/login_compression"), + LOGIN_DISCONNECT("clientbound/login_disconnect"), + PONG_RESPONSE("clientbound/pong_response"), + STATUS_RESPONSE("clientbound/status_response"); + + private final String id; + + Clientbound(String id) { + this.id = id; + } + + @Override + public String id() { + return id; + } + + @Override + public PacketFlow bound() { + return PacketFlow.CLIENTBOUND; + } + } + + enum Serverbound implements PacketType { + CLIENT_INFORMATION("serverbound/client_information"), + CUSTOM_PAYLOAD("serverbound/custom_payload"), + KEEP_ALIVE("serverbound/keep_alive"), + PONG("serverbound/pong"), + RESOURCE_PACK("serverbound/resource_pack"), + CUSTOM_CLICK_ACTION("serverbound/custom_click_action"), + ACCEPT_CODE_OF_CONDUCT("serverbound/accept_code_of_conduct"), + FINISH_CONFIGURATION("serverbound/finish_configuration"), + SELECT_KNOWN_PACKS("serverbound/select_known_packs"), + COOKIE_RESPONSE("serverbound/cookie_response"), + ACCEPT_TELEPORTATION("serverbound/accept_teleportation"), + BLOCK_ENTITY_TAG_QUERY("serverbound/block_entity_tag_query"), + BUNDLE_ITEM_SELECTED("serverbound/bundle_item_selected"), + CHANGE_DIFFICULTY("serverbound/change_difficulty"), + CHANGE_GAME_MODE("serverbound/change_game_mode"), + CHAT_ACK("serverbound/chat_ack"), + CHAT_COMMAND("serverbound/chat_command"), + CHAT_COMMAND_SIGNED("serverbound/chat_command_signed"), + CHAT("serverbound/chat"), + CHAT_SESSION_UPDATE("serverbound/chat_session_update"), + CHUNK_BATCH_RECEIVED("serverbound/chunk_batch_received"), + CLIENT_COMMAND("serverbound/client_command"), + CLIENT_TICK_END("serverbound/client_tick_end"), + COMMAND_SUGGESTION("serverbound/command_suggestion"), + CONFIGURATION_ACKNOWLEDGED("serverbound/configuration_acknowledged"), + CONTAINER_BUTTON_CLICK("serverbound/container_button_click"), + CONTAINER_CLICK("serverbound/container_click"), + CONTAINER_CLOSE("serverbound/container_close"), + CONTAINER_SLOT_STATE_CHANGED("serverbound/container_slot_state_changed"), + DEBUG_SUBSCRIPTION_REQUEST("serverbound/debug_subscription_request"), + EDIT_BOOK("serverbound/edit_book"), + ENTITY_TAG_QUERY("serverbound/entity_tag_query"), + INTERACT("serverbound/interact"), + JIGSAW_GENERATE("serverbound/jigsaw_generate"), + LOCK_DIFFICULTY("serverbound/lock_difficulty"), + MOVE_PLAYER_POS("serverbound/move_player_pos"), + MOVE_PLAYER_POS_ROT("serverbound/move_player_pos_rot"), + MOVE_PLAYER_ROT("serverbound/move_player_rot"), + MOVE_PLAYER_STATUS_ONLY("serverbound/move_player_status_only"), + MOVE_VEHICLE("serverbound/move_vehicle"), + PADDLE_BOAT("serverbound/paddle_boat"), + PICK_ITEM_FROM_BLOCK("serverbound/pick_item_from_block"), + PICK_ITEM_FROM_ENTITY("serverbound/pick_item_from_entity"), + PLACE_RECIPE("serverbound/place_recipe"), + PLAYER_ABILITIES("serverbound/player_abilities"), + PLAYER_ACTION("serverbound/player_action"), + PLAYER_COMMAND("serverbound/player_command"), + PLAYER_INPUT("serverbound/player_input"), + PLAYER_LOADED("serverbound/player_loaded"), + RECIPE_BOOK_CHANGE_SETTINGS("serverbound/recipe_book_change_settings"), + RECIPE_BOOK_SEEN_RECIPE("serverbound/recipe_book_seen_recipe"), + RENAME_ITEM("serverbound/rename_item"), + SEEN_ADVANCEMENTS("serverbound/seen_advancements"), + SELECT_TRADE("serverbound/select_trade"), + SET_BEACON("serverbound/set_beacon"), + SET_CARRIED_ITEM("serverbound/set_carried_item"), + SET_COMMAND_BLOCK("serverbound/set_command_block"), + SET_COMMAND_MINECART("serverbound/set_command_minecart"), + SET_CREATIVE_MODE_SLOT("serverbound/set_creative_mode_slot"), + SET_JIGSAW_BLOCK("serverbound/set_jigsaw_block"), + SET_STRUCTURE_BLOCK("serverbound/set_structure_block"), + SET_TEST_BLOCK("serverbound/set_test_block"), + TEST_INSTANCE_BLOCK_ACTION("serverbound/test_instance_block_action"), + SIGN_UPDATE("serverbound/sign_update"), + SWING("serverbound/swing"), + TELEPORT_TO_ENTITY("serverbound/teleport_to_entity"), + USE_ITEM_ON("serverbound/use_item_on"), + USE_ITEM("serverbound/use_item"), + CUSTOM_QUERY_ANSWER("serverbound/custom_query_answer"), + HELLO("serverbound/hello"), + KEY("serverbound/key"), + LOGIN_ACKNOWLEDGED("serverbound/login_acknowledged"), + PING_REQUEST("serverbound/ping_request"), + STATUS_REQUEST("serverbound/status_request"); + + private final String id; + + Serverbound(String id) { + this.id = id; + } + + @Override + public String id() { + return id; + } + + @Override + public PacketFlow bound() { + return PacketFlow.SERVERBOUND; + } + } +} diff --git a/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/packet/Packet.java b/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/packet/Packet.java deleted file mode 100644 index 9342a7ded..000000000 --- a/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/packet/Packet.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.leavesmc.leaves.bytebuf.packet; - -import org.leavesmc.leaves.bytebuf.Bytebuf; - -@Deprecated -public record Packet(PacketType type, Bytebuf bytebuf) { -} diff --git a/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketListener.java b/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketListener.java deleted file mode 100644 index ba76b26a0..000000000 --- a/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketListener.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.leavesmc.leaves.bytebuf.packet; - -import org.bukkit.entity.Player; - -@Deprecated -public interface PacketListener { - - Packet onPacketIn(Player player, Packet packet); - - Packet onPacketOut(Player player, Packet packet); -} diff --git a/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketType.java b/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketType.java deleted file mode 100644 index 63f95dfb9..000000000 --- a/leaves-api/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketType.java +++ /dev/null @@ -1,196 +0,0 @@ -package org.leavesmc.leaves.bytebuf.packet; - -@Deprecated -public enum PacketType { - // ClientboundBundle, - // ClientboundBundleDelimiter, - ClientboundAddEntity, - ClientboundAddExperienceOrb, - ClientboundAnimate, - ClientboundAwardStats, - ClientboundBlockChangedAck, - ClientboundBlockDestruction, - ClientboundBlockEntityData, - ClientboundBlockEvent, - ClientboundBlockUpdate, - ClientboundBossEvent, - ClientboundChangeDifficulty, - ClientboundChunkBatchFinished, - ClientboundChunkBatchStart, - ClientboundChunksBiomes, - ClientboundClearTitles, - ClientboundCommandSuggestions, - ClientboundCommands, - ClientboundContainerClose, - ClientboundContainerSetContent, - ClientboundContainerSetData, - ClientboundContainerSetSlot, - ClientboundCooldown, - ClientboundCustomChatCompletions, - ClientboundDamageEvent, - ClientboundDebugSample, - ClientboundDeleteChat, - ClientboundDisguisedChat, - ClientboundEntityEvent, - ClientboundExplode, - ClientboundForgetLevelChunk, - ClientboundGameEvent, - ClientboundHorseScreenOpen, - ClientboundHurtAnimation, - ClientboundInitializeBorder, - ClientboundLevelChunkWithLight, - ClientboundLevelEvent, - ClientboundLevelParticles, - ClientboundLightUpdate, - ClientboundLogin, - ClientboundMapItemData, - ClientboundMerchantOffers, - ClientboundMoveEntityPos, - ClientboundMoveEntityPosRot, - ClientboundMoveEntityRot, - ClientboundMoveVehicle, - ClientboundOpenBook, - ClientboundOpenScreen, - ClientboundOpenSignEditor, - ClientboundPlaceGhostRecipe, - ClientboundPlayerAbilities, - ClientboundPlayerChat, - ClientboundPlayerCombatEnd, - ClientboundPlayerCombatEnter, - ClientboundPlayerCombatKill, - ClientboundPlayerInfoRemove, - ClientboundPlayerInfoUpdate, - ClientboundPlayerLookAt, - ClientboundPlayerPosition, - ClientboundRecipe, - ClientboundRemoveEntities, - ClientboundRemoveMobEffect, - ClientboundRespawn, - ClientboundRotateHead, - ClientboundSectionBlocksUpdate, - ClientboundSelectAdvancementsTab, - ClientboundServerData, - ClientboundSetActionBarText, - ClientboundSetBorderCenter, - ClientboundSetBorderLerpSize, - ClientboundSetBorderSize, - ClientboundSetBorderWarningDelay, - ClientboundSetBorderWarningDistance, - ClientboundSetCamera, - ClientboundSetCarriedItem, - ClientboundSetChunkCacheCenter, - ClientboundSetChunkCacheRadius, - ClientboundSetDefaultSpawnPosition, - ClientboundSetDisplayObjective, - ClientboundSetEntityData, - ClientboundSetEntityLink, - ClientboundSetEntityMotion, - ClientboundSetEquipment, - ClientboundSetExperience, - ClientboundSetHealth, - ClientboundSetObjective, - ClientboundSetPassengers, - ClientboundSetPlayerTeam, - ClientboundSetScore, - ClientboundSetSimulationDistance, - ClientboundSetSubtitleText, - ClientboundSetTime, - ClientboundSetTitleText, - ClientboundSetTitlesAnimation, - ClientboundSoundEntity, - ClientboundSound, - ClientboundStartConfiguration, - ClientboundStopSound, - ClientboundSystemChat, - ClientboundTabList, - ClientboundTagQuery, - ClientboundTakeItemEntity, - ClientboundTeleportEntity, - ClientboundUpdateAdvancements, - ClientboundUpdateAttributes, - ClientboundUpdateMobEffect, - ClientboundUpdateRecipes, - ClientboundProjectilePower, - ServerboundAcceptTeleportation, - ServerboundBlockEntityTagQuery, - ServerboundChangeDifficulty, - ServerboundChatAck, - ServerboundChatCommand, - ServerboundChatCommandSigned, - ServerboundChat, - ServerboundChatSessionUpdate, - ServerboundChunkBatchReceived, - ServerboundClientCommand, - ServerboundCommandSuggestion, - ServerboundConfigurationAcknowledged, - ServerboundContainerButtonClick, - ServerboundContainerClick, - ServerboundContainerClose, - ServerboundContainerSlotStateChanged, - ServerboundDebugSampleSubscription, - ServerboundEditBook, - ServerboundEntityTagQuery, - ServerboundInteract, - ServerboundJigsawGenerate, - ServerboundLockDifficulty, - ServerboundMovePlayerPos, - ServerboundMovePlayerPosRot, - ServerboundMovePlayerRot, - ServerboundMovePlayerStatusOnly, - ServerboundMoveVehicle, - ServerboundPaddleBoat, - ServerboundPickItem, - ServerboundPickItemFromBlock, - ServerboundPickItemFromEntity, - ServerboundPlaceRecipe, - ServerboundPlayerAbilities, - ServerboundPlayerAction, - ServerboundPlayerCommand, - ServerboundPlayerInput, - ServerboundRecipeBookChangeSettings, - ServerboundRecipeBookSeenRecipe, - ServerboundRenameItem, - ServerboundSeenAdvancements, - ServerboundSelectTrade, - ServerboundSetBeacon, - ServerboundSetCarriedItem, - ServerboundSetCommandBlock, - ServerboundSetCommandMinecart, - ServerboundSetCreativeModeSlot, - ServerboundSetJigsawBlock, - ServerboundSetStructureBlock, - ServerboundSignUpdate, - ServerboundSwing, - ServerboundTeleportToEntity, - ServerboundUseItemOn, - ServerboundUseItem, - ClientboundResetScore, - ClientboundTickingState, - ClientboundTickingStep, - ClientboundCustomPayload, - ClientboundCustomDetails, - ClientboundRecipeBookAdd, - ServerboundClientTickEnd, - ClientboundSetHeldSlot, - ServerboundSelectBundleItem, - ClientboundSetPlayerInventory, - ClientboundSetCursorItem, - ClientboundDisconnect, - ClientboundKeepAlive, - ClientboundPing, - ClientboundResourcePackPop, - ClientboundResourcePackPush, - ClientboundServerLinks, - ClientboundStoreCookie, - ClientboundTransfer, - ClientboundUpdateTags, - ServerboundClientInformation, - ServerboundCustomPayload, - ServerboundKeepAlive, - ServerboundPong, - ServerboundResourcePack, - ServerboundPingRequest, - ClientboundPongResponse, - ClientboundShowDialog, - ClientboundClearDialog -} diff --git a/leaves-api/src/main/java/org/leavesmc/leaves/event/bytebuf/PacketEvent.java b/leaves-api/src/main/java/org/leavesmc/leaves/event/bytebuf/PacketEvent.java new file mode 100644 index 000000000..ec6320fdf --- /dev/null +++ b/leaves-api/src/main/java/org/leavesmc/leaves/event/bytebuf/PacketEvent.java @@ -0,0 +1,49 @@ +package org.leavesmc.leaves.event.bytebuf; + +import org.bukkit.event.Cancellable; +import org.bukkit.event.Event; +import org.leavesmc.leaves.bytebuf.Bytebuf; +import org.leavesmc.leaves.bytebuf.PacketAudience; +import org.leavesmc.leaves.bytebuf.PacketType; + +public abstract class PacketEvent extends Event implements Cancellable { + + private final PacketAudience audience; + private final PacketType type; + private Bytebuf bytebuf; + + private boolean isCancelled = false; + + public PacketEvent(PacketAudience audience, PacketType type, Bytebuf bytebuf) { + super(true); + this.audience = audience; + this.type = type; + this.bytebuf = bytebuf; + } + + public PacketType getPacketType() { + return type; + } + + public Bytebuf getBytebuf() { + return bytebuf; + } + + public void setBytebuf(Bytebuf bytebuf) { + this.bytebuf = bytebuf; + } + + public PacketAudience getAudience() { + return audience; + } + + @Override + public void setCancelled(boolean cancelled) { + isCancelled = cancelled; + } + + @Override + public boolean isCancelled() { + return isCancelled; + } +} diff --git a/leaves-api/src/main/java/org/leavesmc/leaves/event/bytebuf/PacketInEvent.java b/leaves-api/src/main/java/org/leavesmc/leaves/event/bytebuf/PacketInEvent.java new file mode 100644 index 000000000..7d68dbcf2 --- /dev/null +++ b/leaves-api/src/main/java/org/leavesmc/leaves/event/bytebuf/PacketInEvent.java @@ -0,0 +1,26 @@ +package org.leavesmc.leaves.event.bytebuf; + +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.leavesmc.leaves.bytebuf.Bytebuf; +import org.leavesmc.leaves.bytebuf.PacketAudience; +import org.leavesmc.leaves.bytebuf.PacketType; + +public class PacketInEvent extends PacketEvent implements Cancellable { + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + public PacketInEvent(PacketAudience audience, PacketType packetType, Bytebuf bytebuf) { + super(audience, packetType, bytebuf); + } + + @Override + public @NotNull HandlerList getHandlers() { + return HANDLER_LIST; + } + + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } +} diff --git a/leaves-api/src/main/java/org/leavesmc/leaves/event/bytebuf/PacketOutEvent.java b/leaves-api/src/main/java/org/leavesmc/leaves/event/bytebuf/PacketOutEvent.java new file mode 100644 index 000000000..4371a5e3b --- /dev/null +++ b/leaves-api/src/main/java/org/leavesmc/leaves/event/bytebuf/PacketOutEvent.java @@ -0,0 +1,26 @@ +package org.leavesmc.leaves.event.bytebuf; + +import org.bukkit.event.Cancellable; +import org.bukkit.event.HandlerList; +import org.jetbrains.annotations.NotNull; +import org.leavesmc.leaves.bytebuf.Bytebuf; +import org.leavesmc.leaves.bytebuf.PacketAudience; +import org.leavesmc.leaves.bytebuf.PacketType; + +public class PacketOutEvent extends PacketEvent implements Cancellable { + + private static final HandlerList HANDLER_LIST = new HandlerList(); + + public PacketOutEvent(PacketAudience audience, PacketType packetType, Bytebuf bytebuf) { + super(audience, packetType, bytebuf); + } + + @Override + public @NotNull HandlerList getHandlers() { + return HANDLER_LIST; + } + + public static HandlerList getHandlerList() { + return HANDLER_LIST; + } +} diff --git a/leaves-server/build.gradle.kts.patch b/leaves-server/build.gradle.kts.patch index 2d67a3ef4..c750453b0 100644 --- a/leaves-server/build.gradle.kts.patch +++ b/leaves-server/build.gradle.kts.patch @@ -5,12 +5,12 @@ import io.papermc.paperweight.attribute.DevBundleOutput import io.papermc.paperweight.util.* import java.time.Instant -@@ -7,22 +_,34 @@ +@@ -7,21 +_,33 @@ `java-library` `maven-publish` idea - id("io.papermc.paperweight.core") -- id("io.papermc.fill.gradle") version "1.0.9" +- id("io.papermc.fill.gradle") version "1.0.10" + id("org.leavesmc.leavesweight.core") // Leaves - build change } @@ -18,10 +18,9 @@ +val leavesMavenPublicUrl = "https://repo.leavesmc.com/snapshots/" // Leaves - build change dependencies { - mache("io.papermc:mache:1.21.10+build.9") + mache("io.papermc:mache:1.21.11+build.1") - paperclip("io.papermc:paperclip:3.0.3") + leavesclip("org.leavesmc:leavesclip:3.0.10") // Leaves - build change - testRuntimeOnly("org.junit.platform:junit-platform-launcher") } paperweight { @@ -43,8 +42,18 @@ + spigot { enabled = true - buildDataRef = "42d18d4c4653ffc549778dbe223f6994a031d69e" -@@ -46,6 +_,7 @@ + buildDataRef = "17f77cee7117ab9d6175f088ae8962bfd04e61a9" +@@ -39,16 +_,13 @@ + "org.bukkit.craftbukkit", + "org.spigotmc", + ) +- +- updatingMinecraft { +- // oldPaperCommit = "c82b438b5b4ea0b230439b8e690e34708cd11ab3" +- } + } + + tasks.generateDevelopmentBundle { libraryRepositories.addAll( "https://repo.maven.apache.org/maven2/", paperMavenPublicUrl, @@ -52,7 +61,7 @@ ) } -@@ -104,7 +_,22 @@ +@@ -104,7 +_,21 @@ } } @@ -72,20 +81,18 @@ + java { srcDir("../paper-server/src/log4jPlugins/java") } +} +// Leaves end - build change -+ configurations.named(log4jPlugins.compileClasspathConfigurationName) { extendsFrom(configurations.compileClasspath.get()) } -@@ -127,7 +_,19 @@ +@@ -127,7 +_,18 @@ } dependencies { - implementation(project(":paper-api")) + implementation(project(":leaves-api")) // Leaves - build change -+ implementation("commons-lang:commons-lang:2.6") // Leaves - build change + // Leaves start - linear + implementation("com.github.luben:zstd-jni:1.5.4-1") -+ implementation("org.lz4:lz4-java:1.8.0") ++ implementation("at.yawk.lz4:lz4-java:1.8.1") + implementation("net.openhft:zero-allocation-hashing:0.16") + // Leaves end - linear + // Leaves start - leaves plugin @@ -94,18 +101,10 @@ + exclude(group = "com.google.guava", module = "guava") + } + // Leaves end - leaves plugin - implementation("ca.spottedleaf:concurrentutil:0.0.7") + implementation("ca.spottedleaf:concurrentutil:0.0.8") implementation("org.jline:jline-terminal-ffm:3.27.1") // use ffm on java 22+ implementation("org.jline:jline-terminal-jni:3.27.1") // fall back to jni on java 21 -@@ -154,7 +_,6 @@ - implementation("org.spongepowered:configurate-yaml:4.2.0") - - // Deps that were previously in the API but have now been moved here for backwards compat, eventually to be removed -- runtimeOnly("commons-lang:commons-lang:2.6") - runtimeOnly("org.xerial:sqlite-jdbc:3.49.1.0") - runtimeOnly("com.mysql:mysql-connector-j:9.2.0") - runtimeOnly("com.lmax:disruptor:3.4.4") -@@ -185,26 +_,36 @@ +@@ -186,26 +_,36 @@ implementation("me.lucko:spark-paper:1.10.152") } @@ -148,7 +147,7 @@ "Build-Number" to (build ?: ""), "Build-Time" to buildTime.toString(), "Git-Branch" to gitBranch, -@@ -263,7 +_,7 @@ +@@ -264,7 +_,7 @@ jvmArgumentProviders.add(provider) } @@ -157,7 +156,7 @@ idea { module { generatedSourceDirs.add(generatedDir.toFile()) -@@ -300,6 +_,10 @@ +@@ -301,6 +_,10 @@ } args("--nogui") @@ -168,7 +167,7 @@ systemProperty("net.kyori.adventure.text.warnWhenLegacyFormattingDetected", true) if (providers.gradleProperty("paper.runDisableWatchdog").getOrElse("false") == "true") { systemProperty("disable.watchdog", true) -@@ -344,30 +_,26 @@ +@@ -345,30 +_,24 @@ classpath(tasks.createReobfBundlerJar.flatMap { it.outputZip }) mainClass.set(null as String?) } @@ -199,7 +198,6 @@ - } - } -} -+ +// Leaves start - build change +tasks.registerRunTask("runLeavesclip") { + description = "Spin up a test server from the Mojang mapped Leavesclip jar" @@ -214,7 +212,6 @@ + mainClass.set(null as String?) +} +// Leaves end - build change -+ +// Leaves start - create config file +tasks.registerRunTask("createLeavesConfig") { + description = "Create a new leaves.yml" diff --git a/leaves-server/minecraft-patches/features/0001-Build-changes.patch b/leaves-server/minecraft-patches/features/0001-Build-changes.patch index a521d1bbf..00e0b0427 100644 --- a/leaves-server/minecraft-patches/features/0001-Build-changes.patch +++ b/leaves-server/minecraft-patches/features/0001-Build-changes.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Build changes diff --git a/ca/spottedleaf/moonrise/paper/PaperHooks.java b/ca/spottedleaf/moonrise/paper/PaperHooks.java -index 4b87e48309323faee2bf5cc65428a28d8646ef7a..d129f160acf0da81cadeacab9587d86dcc49dc6a 100644 +index 31e34721f48a5d88379f50104abcf0fc63ebd194..e1f7e61fb9b6075d933fac5995236db4e1912b25 100644 --- a/ca/spottedleaf/moonrise/paper/PaperHooks.java +++ b/ca/spottedleaf/moonrise/paper/PaperHooks.java @@ -29,7 +29,7 @@ import net.minecraft.world.phys.AABB; @@ -18,10 +18,10 @@ index 4b87e48309323faee2bf5cc65428a28d8646ef7a..d129f160acf0da81cadeacab9587d86d private static final org.slf4j.Logger LOGGER = com.mojang.logging.LogUtils.getLogger(); diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index f63a5567a2e845de904c2dacfbb875049e3e0c65..e82584a516af3b08ca4b11ed2aaf28cfbf345825 100644 +index ca2caace6aab0dfcb0ab7a0fd28e66555c62fdc5..501e3ba63c0c262028aade6ee802a71cbe14c9fe 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1283,7 +1283,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop +Date: Sat, 1 Feb 2025 14:21:05 +0800 +Subject: [PATCH] Leaves Server Config And Command + + +diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java +index 501e3ba63c0c262028aade6ee802a71cbe14c9fe..ec2a71fce91b9897bda2686d187c71c10fb9500c 100644 +--- a/net/minecraft/server/MinecraftServer.java ++++ b/net/minecraft/server/MinecraftServer.java +@@ -2297,6 +2297,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop { + io.papermc.paper.command.brigadier.PaperBrigadier.moveBukkitCommands(this.resources.managers().getCommands(), reloadableResources.managers().commands); // Paper ++ org.leavesmc.leaves.command.RootNode.reloadLeavesCommands(); // Leaves - command + this.resources.close(); + this.resources = reloadableResources; + this.packRepository.setSelected(selectedIds, false); // Paper - add pendingReload flag to determine required pack loading - false as this is *after* a reload (see above) +diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java +index 2fbc8efbd12e9adbabc47b9f81a71271e0daeca1..2e6af078b8713cccf4dd51df53ce580a26553ae1 100644 +--- a/net/minecraft/server/dedicated/DedicatedServer.java ++++ b/net/minecraft/server/dedicated/DedicatedServer.java +@@ -274,6 +274,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface + this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark + com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now + ++ org.leavesmc.leaves.LeavesConfig.init((java.io.File) options.valueOf("leaves-settings")); // Leaves - Server Config ++ + com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics // Leaves - down + + // this.worldData.setGameType(properties.gameMode.get()); // CraftBukkit - moved to world loading diff --git a/leaves-server/minecraft-patches/features/0002-Leaves-Server-Config.patch b/leaves-server/minecraft-patches/features/0002-Leaves-Server-Config.patch deleted file mode 100644 index 81b8ba526..000000000 --- a/leaves-server/minecraft-patches/features/0002-Leaves-Server-Config.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Sat, 1 Feb 2025 14:21:05 +0800 -Subject: [PATCH] Leaves Server Config - - -diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java -index 4693330ebbd1540559caa4ef5494e75b69351c24..ecdb937f08a437a1d2398e49ca835071015844f2 100644 ---- a/net/minecraft/server/dedicated/DedicatedServer.java -+++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -277,6 +277,8 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface - this.server.spark.registerCommandBeforePlugins(this.server); // Paper - spark - com.destroystokyo.paper.VersionHistoryManager.INSTANCE.getClass(); // Paper - load version history now - -+ org.leavesmc.leaves.LeavesConfig.init((java.io.File) options.valueOf("leaves-settings")); // Leaves - Server Config -+ - com.destroystokyo.paper.Metrics.PaperMetrics.startMetrics(); // Paper - start metrics // Leaves - down - - // this.worldData.setGameType(properties.gameMode.get()); // CraftBukkit - moved to world loading diff --git a/leaves-server/minecraft-patches/features/0003-Leaves-Utils.patch b/leaves-server/minecraft-patches/features/0003-Leaves-Utils.patch index 8c096dd6e..1173e8d35 100644 --- a/leaves-server/minecraft-patches/features/0003-Leaves-Utils.patch +++ b/leaves-server/minecraft-patches/features/0003-Leaves-Utils.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Leaves Utils diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 2e3e038874757049445a91bf590d5a1a427a3f6d..9b122a3dc18c6dbc84683ab54e5a503d0a5b7e4b 100644 +index 3bf618f1d756bad7755a87803132bd731e7c41be..bbf0100341dfd50cfe76bf4f47225e6b43dc17bd 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -373,6 +373,8 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -374,6 +374,8 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name public boolean isTemporarilyActive; public long activatedImmunityTick = Integer.MIN_VALUE; @@ -17,7 +17,7 @@ index 2e3e038874757049445a91bf590d5a1a427a3f6d..9b122a3dc18c6dbc84683ab54e5a503d public void inactiveTick() { } // Paper end - EAR 2 -@@ -2634,6 +2636,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -2659,6 +2661,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name output.putBoolean("Paper.FreezeLock", true); } // Paper end @@ -25,7 +25,7 @@ index 2e3e038874757049445a91bf590d5a1a427a3f6d..9b122a3dc18c6dbc84683ab54e5a503d } catch (Throwable var7) { CrashReport crashReport = CrashReport.forThrowable(var7, "Saving entity NBT"); CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being saved"); -@@ -2754,6 +2757,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -2779,6 +2782,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } freezeLocked = input.getBooleanOr("Paper.FreezeLock", false); // Paper end @@ -33,16 +33,7 @@ index 2e3e038874757049445a91bf590d5a1a427a3f6d..9b122a3dc18c6dbc84683ab54e5a503d } catch (Throwable var7) { CrashReport crashReport = CrashReport.forThrowable(var7, "Loading entity NBT"); CrashReportCategory crashReportCategory = crashReport.addCategory("Entity being loaded"); -@@ -4512,7 +4516,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name - return this.getType().is(EntityTypeTags.DEFLECTS_PROJECTILES) ? ProjectileDeflection.REVERSE : ProjectileDeflection.NONE; - } - -- @Nullable -+ @org.jetbrains.annotations.NotNull // Leaves - notnull - public net.minecraft.world.entity.LivingEntity getControllingPassenger() { - return null; - } -@@ -5402,4 +5406,9 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -5429,4 +5433,9 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name return ((ServerLevel) this.level()).isPositionEntityTicking(this.blockPosition()); } // Paper end - Expose entity id counter @@ -53,36 +44,36 @@ index 2e3e038874757049445a91bf590d5a1a427a3f6d..9b122a3dc18c6dbc84683ab54e5a503d + // Leaves end - leaves ex data } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index d225267b1b07854b76c88ce461d7817a86d023a0..01e0dc28ef63456a45b800e72d76180b40811a72 100644 +index 579bbba4e823d4d0318e58759ca732b7c8e4d865..ac1ca945fcea0997d837e7c5586d86a709f52d47 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -916,7 +916,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - return this.isClientSide; +@@ -969,7 +969,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl } + // Paper start - if loaded - @Nullable + @org.jetbrains.annotations.NotNull // Leaves - notnull @Override - public MinecraftServer getServer() { - return null; + public final ChunkAccess getChunkIfLoadedImmediately(int x, int z) { + return ((ServerLevel)this).chunkSource.getChunkAtIfLoadedImmediately(x, z); diff --git a/net/minecraft/world/level/LevelAccessor.java b/net/minecraft/world/level/LevelAccessor.java -index e4a9e59661f5b51caf5b4fb12b0c90b14c1f9647..f5e9e395f04d5335d5d9a220f94962a72e38577d 100644 +index 21d5042282a4eeaadfbb1057f5995e90acc7388e..b3af6fa78eaca16f094e404bf86c05d496b6a5f1 100644 --- a/net/minecraft/world/level/LevelAccessor.java +++ b/net/minecraft/world/level/LevelAccessor.java -@@ -46,7 +46,7 @@ public interface LevelAccessor extends CommonLevelAccessor, LevelTimeAccess, Sch - - DifficultyInstance getCurrentDifficultyAt(BlockPos pos); +@@ -42,7 +42,7 @@ public interface LevelAccessor extends CommonLevelAccessor, LevelReader, Schedul + return this.getLevelData().getGameTime(); + } -- @Nullable -+ @org.jetbrains.annotations.NotNull // Leaves - notnull - MinecraftServer getServer(); +- @Nullable MinecraftServer getServer(); ++ @org.jetbrains.annotations.NotNull MinecraftServer getServer(); // Leaves - notnull default Difficulty getDifficulty() { + return this.getLevelData().getDifficulty(); diff --git a/net/minecraft/world/level/block/Block.java b/net/minecraft/world/level/block/Block.java -index 572fcb33b14d16334e2ab92ddf8699f1ba975aff..c431d0c45e71e0c8b880784181c92967e40779bd 100644 +index 94b4143449c99ee35db44ab8e2a766d924aa6410..6d0cdbd52a3bb4e09fd480fa08fa825e987d2a2c 100644 --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -649,6 +649,13 @@ public class Block extends BlockBehaviour implements ItemLike { +@@ -659,6 +659,13 @@ public class Block extends BlockBehaviour implements ItemLike { } // CraftBukkit end @@ -97,10 +88,10 @@ index 572fcb33b14d16334e2ab92ddf8699f1ba975aff..c431d0c45e71e0c8b880784181c92967 @Override public boolean equals(Object other) { diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java -index d31da50baeb7f47f0e1d81ee3c05023370df8cd3..a38618c28819405f0fb35aa686d1f3f0e94e5da2 100644 +index c5953d5751e655e121e459aaab35e7719948e69e..b1f1ea03072c63bc3032c9f023a8fb4ede34b34b 100644 --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -766,7 +766,7 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -762,7 +762,7 @@ public abstract class BlockBehaviour implements FeatureElement { } public PushReaction getPistonPushReaction() { diff --git a/leaves-server/minecraft-patches/features/0004-Leaves-Protocol-Core.patch b/leaves-server/minecraft-patches/features/0004-Leaves-Protocol-Core.patch index a714dd740..890257943 100644 --- a/leaves-server/minecraft-patches/features/0004-Leaves-Protocol-Core.patch +++ b/leaves-server/minecraft-patches/features/0004-Leaves-Protocol-Core.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Leaves Protocol Core 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 { @@ -23,30 +23,30 @@ 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/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index e82584a516af3b08ca4b11ed2aaf28cfbf345825..2493722c47b92cbcd13c08af0caf38a543ac7e37 100644 +index ec2a71fce91b9897bda2686d187c71c10fb9500c..d3a128db1e2a91111a6fd736f0b9ff5e5ee5ee31 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1830,6 +1830,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop Date: Wed, 26 Jan 2022 17:20:54 +0800 -Subject: [PATCH] Configurable trading with the void +Subject: [PATCH] Configurable void trade diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index c0ed4e023b35a076b554fa387e9a2324166b2fae..0c9002b6ceaf5f11a059db356976215d5acf5cce 100644 +index dc65503a2d785d64d37b76b0303f51cf66d9769a..9cb40d4f0ceabadb95f473e96029bd57a2b09204 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -2794,7 +2794,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2846,7 +2846,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 @@ -18,15 +18,15 @@ index c0ed4e023b35a076b554fa387e9a2324166b2fae..0c9002b6ceaf5f11a059db356976215d } // 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 d9fbc5dc6665fd13cc2aa9978ea6edef4c736548..4abf4ea7f86955351b5e4da2c89a707003802d2e 100644 +index d9c49cb3394891b824dc2a77c5e8d50366643fef..c5dac6310dc82d4e5d9cc9df79f943bfb235c083 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -468,7 +468,7 @@ public abstract class PlayerList { +@@ -474,7 +474,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 (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.voidTrade && 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 (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.voidTrade && entity instanceof net.minecraft.world.entity.npc.villager.AbstractVillager villager) { // Leaves - configurable void trade final net.minecraft.world.entity.player.Player human = villager.getTradingPlayer(); if (human != null) { villager.setTradingPlayer(null); diff --git a/leaves-server/minecraft-patches/features/0006-Make-snowball-and-egg-can-knockback-player.patch b/leaves-server/minecraft-patches/features/0006-Make-snowball-and-egg-can-knockback-player.patch index c2b8bf2c6..399277dfd 100644 --- a/leaves-server/minecraft-patches/features/0006-Make-snowball-and-egg-can-knockback-player.patch +++ b/leaves-server/minecraft-patches/features/0006-Make-snowball-and-egg-can-knockback-player.patch @@ -4,10 +4,10 @@ Date: Fri, 28 Jan 2022 18:34:29 +0800 Subject: [PATCH] Make snowball and egg can knockback player -diff --git a/net/minecraft/world/entity/projectile/Snowball.java b/net/minecraft/world/entity/projectile/Snowball.java -index cd36d3a988ae871fe93157c24c26f36308c71fbf..f8da22e77547916076056ea7202dd499fefd8f9f 100644 ---- a/net/minecraft/world/entity/projectile/Snowball.java -+++ b/net/minecraft/world/entity/projectile/Snowball.java +diff --git a/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java b/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java +index 89a061cd0a2b39fc05ea96ac0f5d5a8c26582f97..ce57bc82ff31f50d86a5707de3957b10435937b7 100644 +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/Snowball.java @@ -55,6 +55,12 @@ public class Snowball extends ThrowableItemProjectile { Entity entity = result.getEntity(); int i = entity instanceof Blaze ? 3 : 0; @@ -21,10 +21,10 @@ index cd36d3a988ae871fe93157c24c26f36308c71fbf..f8da22e77547916076056ea7202dd499 } @Override -diff --git a/net/minecraft/world/entity/projectile/ThrownEgg.java b/net/minecraft/world/entity/projectile/ThrownEgg.java -index bbb364be2af16a3c200d2197166bb3ad28e5e35d..34deb006b1a81e8c6f65150ac7ab80f037ffa0c7 100644 ---- a/net/minecraft/world/entity/projectile/ThrownEgg.java -+++ b/net/minecraft/world/entity/projectile/ThrownEgg.java +diff --git a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java +index c7db74ccc3f8c46e97c24857f297fe5fb5f45e36..44d9fe980a8ab0b747626f12c23d44e0360a5059 100644 +--- a/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java ++++ b/net/minecraft/world/entity/projectile/throwableitemprojectile/ThrownEgg.java @@ -56,6 +56,12 @@ public class ThrownEgg extends ThrowableItemProjectile { protected void onHitEntity(EntityHitResult result) { super.onHitEntity(result); diff --git a/leaves-server/minecraft-patches/features/0007-Leaves-Fakeplayer.patch b/leaves-server/minecraft-patches/features/0007-Leaves-Fakeplayer.patch index 72ac5eef7..919bffe63 100644 --- a/leaves-server/minecraft-patches/features/0007-Leaves-Fakeplayer.patch +++ b/leaves-server/minecraft-patches/features/0007-Leaves-Fakeplayer.patch @@ -4,10 +4,10 @@ Date: Sun, 2 Feb 2025 15:28:11 +0800 Subject: [PATCH] Leaves Fakeplayer -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 14addbaf68b7ad80490187d12d9c9b00891e2ce1..b186b5e0d3b32d7b51b2f58f0ef4b2bf36ae5c13 100644 +index 19ec939529eb638bdc4d7fd9260f161fae118314..ab6255937577008689c25ba1474ecc2c961079da 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -95,7 +95,7 @@ public class Connection extends SimpleChannelInboundHandler> { - @Nullable - private volatile PacketListener disconnectListener; - @Nullable -- private volatile PacketListener packetListener; -+ protected volatile PacketListener packetListener; // Leaves - private -> protected - @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; ++ protected volatile @Nullable PacketListener packetListener; // Leaves - private -> protected + private @Nullable DisconnectionDetails disconnectionDetails; private boolean encrypted; + private boolean disconnectionHandled; diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 2493722c47b92cbcd13c08af0caf38a543ac7e37..9ae09e08afbc99cd2f54d55f8822bc92d317f960 100644 +index d3a128db1e2a91111a6fd736f0b9ff5e5ee5ee31..f45ad308fc4bcf5647580ad3d46de9a966985790 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -378,6 +378,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<>(); -@@ -1013,6 +1015,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0) { @@ -59,7 +59,7 @@ index 2493722c47b92cbcd13c08af0caf38a543ac7e37..9ae09e08afbc99cd2f54d55f8822bc92 this.emptyTicks++; } else { this.emptyTicks = 0; -@@ -1634,6 +1637,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0) { this.playerList.saveAll(playerSaveInterval); @@ -67,7 +67,7 @@ index 2493722c47b92cbcd13c08af0caf38a543ac7e37..9ae09e08afbc99cd2f54d55f8822bc92 } for (final ServerLevel level : this.getAllLevels()) { if (level.paperConfig().chunks.autoSaveInterval.value() > 0) { -@@ -1857,6 +1861,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> optional = PoiTypes.forState(oldState); -@@ -2728,6 +2736,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2780,6 +2788,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); @@ -293,7 +293,7 @@ index 0c9002b6ceaf5f11a059db356976215d5acf5cce..2bab1246cf658508228c7f662175692b if (serverPlayer.isReceivingWaypoints()) { ServerLevel.this.getWaypointManager().addPlayer(serverPlayer); } -@@ -2806,6 +2819,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2858,6 +2871,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.remove(serverPlayer); @@ -306,10 +306,10 @@ index 0c9002b6ceaf5f11a059db356976215d5acf5cce..2bab1246cf658508228c7f662175692b ServerLevel.this.updateSleepingPlayerList(); } diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index b4a996ac6c570e988b38237a32f90ec5042cbc17..04ea4e33504703c4074aef6e74ec06dc772b1bb9 100644 +index 79c804245c7f41a5a7f062e1c5e01760adde7d84..8c38a1b97203661454c099746472206a7954b5bc 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -228,7 +228,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; @@ -318,17 +318,17 @@ index b4a996ac6c570e988b38237a32f90ec5042cbc17..04ea4e33504703c4074aef6e74ec06dc private final PlayerAdvancements advancements; private final ServerStatsCounter stats; private float lastRecordedHealthAndAbsorption = Float.MIN_VALUE; -@@ -249,7 +249,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc - private Entity camera; +@@ -247,7 +247,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; -@@ -1250,7 +1250,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc - this.setClientLoaded(false); + private boolean disconnected; +@@ -1247,7 +1247,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + this.connection.markClientUnloadedAfterDeath(); } - private void tellNeutralMobsThatIDied() { @@ -336,7 +336,7 @@ index b4a996ac6c570e988b38237a32f90ec5042cbc17..04ea4e33504703c4074aef6e74ec06dc AABB aabb = new AABB(this.blockPosition()).inflate(32.0, 10.0, 32.0); this.level() .getEntitiesOfClass(Mob.class, aabb, EntitySelector.NO_SPECTATORS) -@@ -1562,6 +1562,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -1560,6 +1560,11 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc this.lastSentHealth = -1.0F; this.lastSentFood = -1; this.teleportSpectators(teleportTransition, serverLevel); @@ -349,10 +349,10 @@ index b4a996ac6c570e988b38237a32f90ec5042cbc17..04ea4e33504703c4074aef6e74ec06dc org.bukkit.event.player.PlayerChangedWorldEvent changeEvent = new org.bukkit.event.player.PlayerChangedWorldEvent(this.getBukkitEntity(), serverLevel.getWorld()); this.level().getCraftServer().getPluginManager().callEvent(changeEvent); diff --git a/net/minecraft/server/players/CachedUserNameToIdResolver.java b/net/minecraft/server/players/CachedUserNameToIdResolver.java -index 3dc78b91cc853cfa6dce69979273b5f35b5f87f1..97bf1895a1235d1fc6b8e1de4a965b12f74a9d8f 100644 +index 6d3f496881492ac67465746984d6ef8302750305..da1344437875f38a77d85cc6f255ff855957efaa 100644 --- a/net/minecraft/server/players/CachedUserNameToIdResolver.java +++ b/net/minecraft/server/players/CachedUserNameToIdResolver.java -@@ -121,6 +121,12 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { +@@ -122,6 +122,12 @@ public class CachedUserNameToIdResolver implements UserNameToIdResolver { @Override public Optional get(String name) { @@ -366,12 +366,12 @@ index 3dc78b91cc853cfa6dce69979273b5f35b5f87f1..97bf1895a1235d1fc6b8e1de4a965b12 boolean stateLocked = true; try { this.stateLock.lock(); // Paper - Fix GameProfileCache concurrency CachedUserNameToIdResolver.GameProfileInfo gameProfileInfo = this.profilesByName.get(string); diff --git a/net/minecraft/server/players/NameAndId.java b/net/minecraft/server/players/NameAndId.java -index fdcc23c618b5db59e384a38f9ef91b6d2e922a8a..ccb56f29e79805f3286bbb80ce6c4d4b36a6e9e8 100644 +index 05b4a75f6597e8613c91344d100bb7f005d169a7..9a5006362c12e972d031c48be4d30362d88d1c00 100644 --- a/net/minecraft/server/players/NameAndId.java +++ b/net/minecraft/server/players/NameAndId.java @@ -8,18 +8,22 @@ import java.util.UUID; - import javax.annotation.Nullable; import net.minecraft.core.UUIDUtil; + import org.jspecify.annotations.Nullable; -public record NameAndId(UUID id, String name) { +public record NameAndId(UUID id, String name, boolean isBot) { // Leaves - fakeplayer @@ -394,8 +394,8 @@ index fdcc23c618b5db59e384a38f9ef91b6d2e922a8a..ccb56f29e79805f3286bbb80ce6c4d4b + this(uuid, name, false); // Leaves - fakeplayer } - @Nullable -@@ -34,7 +38,7 @@ public record NameAndId(UUID id, String name) { + public static @Nullable NameAndId fromJson(JsonObject json) { +@@ -33,7 +37,7 @@ public record NameAndId(UUID id, String name) { return null; } @@ -404,7 +404,7 @@ index fdcc23c618b5db59e384a38f9ef91b6d2e922a8a..ccb56f29e79805f3286bbb80ce6c4d4b } else { return null; } -@@ -47,7 +51,7 @@ public record NameAndId(UUID id, String name) { +@@ -46,7 +50,7 @@ public record NameAndId(UUID id, String name) { public static NameAndId createOffline(String name) { UUID uuid = UUIDUtil.createOfflinePlayerUUID(name); @@ -414,10 +414,10 @@ index fdcc23c618b5db59e384a38f9ef91b6d2e922a8a..ccb56f29e79805f3286bbb80ce6c4d4b // Paper start - utility method for common conversion back to the game profile diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 65a2d77bc2e740c7f7777a801607dd7a2b2845f0..5d1d71858c730c431120d4a66244969ebf2a5164 100644 +index c5dac6310dc82d4e5d9cc9df79f943bfb235c083..8baca1186179d49e1f8dc0e3acb39816bd61967d 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -241,6 +241,19 @@ public abstract class PlayerList { +@@ -246,6 +246,19 @@ public abstract class PlayerList { org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); @@ -437,7 +437,7 @@ index 65a2d77bc2e740c7f7777a801607dd7a2b2845f0..5d1d71858c730c431120d4a66244969e final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure -@@ -700,6 +713,12 @@ public abstract class PlayerList { +@@ -706,6 +719,12 @@ public abstract class PlayerList { respawnReason ).callEvent(); // Paper end @@ -450,7 +450,7 @@ index 65a2d77bc2e740c7f7777a801607dd7a2b2845f0..5d1d71858c730c431120d4a66244969e return serverPlayer; } -@@ -802,11 +821,16 @@ public abstract class PlayerList { +@@ -808,11 +827,16 @@ public abstract class PlayerList { } public String[] getPlayerNamesArray() { @@ -468,10 +468,10 @@ index 65a2d77bc2e740c7f7777a801607dd7a2b2845f0..5d1d71858c730c431120d4a66244969e return strings; } -@@ -919,7 +943,14 @@ public abstract class PlayerList { +@@ -922,7 +946,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); @@ -484,10 +484,10 @@ index 65a2d77bc2e740c7f7777a801607dd7a2b2845f0..5d1d71858c730c431120d4a66244969e } public void broadcast(@Nullable Player except, double x, double y, double z, double radius, ResourceKey dimension, Packet packet) { -@@ -1226,7 +1257,13 @@ public abstract class PlayerList { +@@ -1234,7 +1265,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); @@ -498,9 +498,9 @@ index 65a2d77bc2e740c7f7777a801607dd7a2b2845f0..5d1d71858c730c431120d4a66244969e + // Leaves start - fakeplayer support } - @Nullable + public @Nullable ServerPlayer getPlayer(String name) { diff --git a/net/minecraft/server/waypoints/ServerWaypointManager.java b/net/minecraft/server/waypoints/ServerWaypointManager.java -index f9e7532f86122a379692561a639a209a126e8bba..2412f46837e967694222730e68e7d25ac32225cf 100644 +index 471e558a609c9e457720660b90fe57322b860461..ac09b59b9b49badcec0922e3013809f041cc2919 100644 --- a/net/minecraft/server/waypoints/ServerWaypointManager.java +++ b/net/minecraft/server/waypoints/ServerWaypointManager.java @@ -22,6 +22,11 @@ public class ServerWaypointManager implements WaypointManager ((1L + this.totalEatTimeTicks) * 50L * (1000L * 1000L)); @@ -571,7 +571,7 @@ index 025ef0b83e5d481c8b2ef25206cafd30897caabd..c18b0155edd695524246e5c2134de940 this.useItemRemaining = 0; // Paper end - lag compensate eating this.completeUsingItem(); -@@ -4183,6 +4183,23 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -4315,6 +4315,23 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin this.stopUsingItem(); } @@ -596,10 +596,10 @@ index 025ef0b83e5d481c8b2ef25206cafd30897caabd..c18b0155edd695524246e5c2134de940 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 e95e259e5be5bb14a4ba2473d6ce850ebbedcb6d..e4c7262ded690e56ba2eef71bb7d46f9cd99b8b7 100644 +index e4240fa38fb8513c7e320a4b30e6dcbb7e015310..54bf31d2f6ac925abd6c13756eba05301343ac3f 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -167,7 +167,7 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -168,7 +168,7 @@ public abstract class Player extends Avatar implements ContainerUser { private int lastLevelUpTime; public GameProfile gameProfile; private boolean reducedDebugInfo; @@ -607,7 +607,7 @@ index e95e259e5be5bb14a4ba2473d6ce850ebbedcb6d..e4c7262ded690e56ba2eef71bb7d46f9 + protected ItemStack lastItemInMainHand = ItemStack.EMPTY; private final ItemCooldowns cooldowns = this.createItemCooldowns(); private Optional lastDeathLocation = Optional.empty(); - @Nullable + public @Nullable FishingHook fishing; @@ -309,6 +309,12 @@ public abstract class Player extends Avatar implements ContainerUser { } } @@ -621,7 +621,7 @@ index e95e259e5be5bb14a4ba2473d6ce850ebbedcb6d..e4c7262ded690e56ba2eef71bb7d46f9 @Override protected float getMaxHeadRotationRelativeToBody() { return this.isBlocking() ? 15.0F : super.getMaxHeadRotationRelativeToBody(); -@@ -537,7 +543,7 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -534,7 +540,7 @@ public abstract class Player extends Avatar implements ContainerUser { public void removeEntitiesOnShoulder() { } @@ -630,20 +630,20 @@ index e95e259e5be5bb14a4ba2473d6ce850ebbedcb6d..e4c7262ded690e56ba2eef71bb7d46f9 entity.playerTouch(this); } -@@ -1148,7 +1154,7 @@ public abstract class Player extends Avatar implements ContainerUser { - this.sweepAttack(); - } +@@ -1211,7 +1217,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 207e30f822f286a6358055fcd5bc3af6ee7a553d..2c79332e148375c2f277df94b16ce7dd2422c004 100644 +index 4a7abf4ae0c1f4c22c1c77d5ce9e67418b274365..30e3c19adcdc55fa468257037ca49275c09de324 100644 --- a/net/minecraft/world/entity/projectile/FishingHook.java +++ b/net/minecraft/world/entity/projectile/FishingHook.java -@@ -59,7 +59,7 @@ public class FishingHook extends Projectile { +@@ -58,7 +58,7 @@ public class FishingHook extends Projectile { public static final EntityDataAccessor DATA_HOOKED_ENTITY = SynchedEntityData.defineId(FishingHook.class, EntityDataSerializers.INT); private static final EntityDataAccessor DATA_BITING = SynchedEntityData.defineId(FishingHook.class, EntityDataSerializers.BOOLEAN); private int life; @@ -652,11 +652,11 @@ index 207e30f822f286a6358055fcd5bc3af6ee7a553d..2c79332e148375c2f277df94b16ce7dd 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 adab5dc640a7a0299c04020225a68317282aebe9..e127a670935186ba3d96a8d85640cf465ef52b7e 100644 ---- a/net/minecraft/world/entity/vehicle/AbstractBoat.java -+++ b/net/minecraft/world/entity/vehicle/AbstractBoat.java -@@ -269,6 +269,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 6b337848d91cc4f24655d053bc69b0cd22447dda..cc16a8a2fd05d472d777b7a5f812d900b49e57ed 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()); @@ -668,7 +668,7 @@ index adab5dc640a7a0299c04020225a68317282aebe9..e127a670935186ba3d96a8d85640cf46 } else { this.setDeltaMovement(Vec3.ZERO); } -@@ -377,6 +382,13 @@ public abstract class AbstractBoat extends VehicleEntity implements Leashable { +@@ -378,6 +383,13 @@ public abstract class AbstractBoat extends VehicleEntity implements Leashable { } } @@ -679,14 +679,14 @@ index adab5dc640a7a0299c04020225a68317282aebe9..e127a670935186ba3d96a8d85640cf46 + } + // 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 670090c4466d6472a83263e1769f19e3e491c927..c097bfe559c648bc279a9dffe874f3180ff80e27 100644 +index f51dbc45204c2727122aeb6b5002216e3200680d..b5837ee5e291ae23bd8613c4c1856c14dd9e152b 100644 --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -400,6 +400,7 @@ public abstract class AbstractContainerMenu { +@@ -397,6 +397,7 @@ public abstract class AbstractContainerMenu { private void doClick(int slotIndex, int button, ClickType clickType, Player player) { Inventory inventory = player.getInventory(); @@ -694,7 +694,7 @@ index 670090c4466d6472a83263e1769f19e3e491c927..c097bfe559c648bc279a9dffe874f318 if (clickType == ClickType.QUICK_CRAFT) { int i = this.quickcraftStatus; this.quickcraftStatus = getQuickcraftHeader(button); -@@ -674,6 +675,22 @@ public abstract class AbstractContainerMenu { +@@ -671,6 +672,22 @@ public abstract class AbstractContainerMenu { } } @@ -718,10 +718,10 @@ index 670090c4466d6472a83263e1769f19e3e491c927..c097bfe559c648bc279a9dffe874f318 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 47862c00e9e01c7cdd5fcd808cc1b76740b85a57..14c74eb71b5bfb67d0fcf9d660f748c7b1dba63d 100644 +index ed06cffe8a5eba2ca4a34ade81f8185e21d7b651..3a719a98118c275422f4fc61b07d471dd503656f 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -443,7 +443,7 @@ public final class ItemStack implements DataComponentHolder { +@@ -448,7 +448,7 @@ public final class ItemStack implements DataComponentHolder { placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(serverLevel, player, hand, blocks.getFirst(), clickedPos); } @@ -730,7 +730,7 @@ index 47862c00e9e01c7cdd5fcd808cc1b76740b85a57..14c74eb71b5bfb67d0fcf9d660f748c7 interactionResult = InteractionResult.FAIL; // cancel placement // PAIL: Remove this when MC-99075 fixed player.containerMenu.forceHeldSlot(hand); -@@ -939,6 +939,20 @@ public final class ItemStack implements DataComponentHolder { +@@ -979,6 +979,20 @@ public final class ItemStack implements DataComponentHolder { } } @@ -752,7 +752,7 @@ index 47862c00e9e01c7cdd5fcd808cc1b76740b85a57..14c74eb71b5bfb67d0fcf9d660f748c7 return this.getItem().useOnRelease(this); } diff --git a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -index 59a002711531f8337a86d85b6e8b11b5fad8ced7..0a76cf42aaaaf210a4e43ed9bd3d177f0003ba57 100644 +index bc42a6c678987a39b0a70a1a3e96eb90340ffea5..7223cd393c4ef9408ab22c2e4d16458c19f29423 100644 --- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java @@ -135,7 +135,7 @@ public class PistonMovingBlockEntity extends BlockEntity { @@ -765,7 +765,7 @@ index 59a002711531f8337a86d85b6e8b11b5fad8ced7..0a76cf42aaaaf210a4e43ed9bd3d177f double d1 = deltaMovement.x; double d2 = deltaMovement.y; diff --git a/net/minecraft/world/level/levelgen/PhantomSpawner.java b/net/minecraft/world/level/levelgen/PhantomSpawner.java -index 801a50ba4d202df0289339f26968e7f6bb9ca767..196f5dd260701d520cc8a037a896f34c87f74934 100644 +index 135e8cc1b423d5a2a96ede693a306534ea45686b..7ac57cdaa05e9ccf053a7060b42e91904bb9ad2b 100644 --- a/net/minecraft/world/level/levelgen/PhantomSpawner.java +++ b/net/minecraft/world/level/levelgen/PhantomSpawner.java @@ -48,6 +48,11 @@ public class PhantomSpawner implements CustomSpawner { diff --git a/leaves-server/minecraft-patches/features/0009-Redstone-Shears-Wrench.patch b/leaves-server/minecraft-patches/features/0009-Redstone-Shears-Wrench.patch index 6967f23aa..f1a1e6960 100644 --- a/leaves-server/minecraft-patches/features/0009-Redstone-Shears-Wrench.patch +++ b/leaves-server/minecraft-patches/features/0009-Redstone-Shears-Wrench.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Redstone Shears Wrench diff --git a/net/minecraft/world/item/ShearsItem.java b/net/minecraft/world/item/ShearsItem.java -index 8cf3e51e12f9cf98836657e722edb23943f9e866..5fd5e9fd4e1a79dd1a9d62a5cf0c308805979420 100644 +index 5e25ddf78f72ada318ef28d29199de9b93fe667e..6f48162a25e20d2439935e8995cede9497626322 100644 --- a/net/minecraft/world/item/ShearsItem.java +++ b/net/minecraft/world/item/ShearsItem.java @@ -80,7 +80,10 @@ public class ShearsItem extends Item { diff --git a/leaves-server/minecraft-patches/features/0010-Add-isShrink-to-EntityResurrectEvent.patch b/leaves-server/minecraft-patches/features/0010-Add-isShrink-to-EntityResurrectEvent.patch index c06998f93..430aad72b 100644 --- a/leaves-server/minecraft-patches/features/0010-Add-isShrink-to-EntityResurrectEvent.patch +++ b/leaves-server/minecraft-patches/features/0010-Add-isShrink-to-EntityResurrectEvent.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add isShrink to EntityResurrectEvent diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index c18b0155edd695524246e5c2134de94008d8a023..f4a45a39afae0befa5c6048bb5f2001395d5cbfc 100644 +index 8968ca0dffc42bd74c5159e5d602361dd016ef88..96b9e04867a44a2f92120ab69562b956c8c021b7 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -1741,14 +1741,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1752,14 +1752,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } final org.bukkit.inventory.EquipmentSlot handSlot = (hand != null) ? org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand) : null; diff --git a/leaves-server/minecraft-patches/features/0011-Movable-Budding-Amethyst.patch b/leaves-server/minecraft-patches/features/0011-Movable-Budding-Amethyst.patch index d5300a6f3..4972d201f 100644 --- a/leaves-server/minecraft-patches/features/0011-Movable-Budding-Amethyst.patch +++ b/leaves-server/minecraft-patches/features/0011-Movable-Budding-Amethyst.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Movable Budding Amethyst diff --git a/net/minecraft/world/level/block/BuddingAmethystBlock.java b/net/minecraft/world/level/block/BuddingAmethystBlock.java -index 9fc8e9e2b168954c8377bd1a8cf57f49fa137213..2f16d8ff58d3cbadeb210d75d60e46e9ed1f02f7 100644 +index 02326847187f5940751fda00a03856060ae8ae29..bb728c904bd401c2a681ca5d02d246b777ad8053 100644 --- a/net/minecraft/world/level/block/BuddingAmethystBlock.java +++ b/net/minecraft/world/level/block/BuddingAmethystBlock.java @@ -58,4 +58,12 @@ public class BuddingAmethystBlock extends AmethystBlock { diff --git a/leaves-server/minecraft-patches/features/0012-Spectator-dont-get-Advancement.patch b/leaves-server/minecraft-patches/features/0012-Spectator-dont-get-Advancement.patch index c7930a349..277974c6c 100644 --- a/leaves-server/minecraft-patches/features/0012-Spectator-dont-get-Advancement.patch +++ b/leaves-server/minecraft-patches/features/0012-Spectator-dont-get-Advancement.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Spectator dont get Advancement diff --git a/net/minecraft/server/PlayerAdvancements.java b/net/minecraft/server/PlayerAdvancements.java -index 5c0e338dc1b0eb5724d10a73d6fc7975f9d2e5e5..a14401edec04964e6c596c16ba58643b835ef9c1 100644 +index cd968c6971d054d9b66a0eaea4753a51ebb75b02..80d7227cb889fd3ef5d8563a00af5f3219b4496a 100644 --- a/net/minecraft/server/PlayerAdvancements.java +++ b/net/minecraft/server/PlayerAdvancements.java -@@ -167,6 +167,11 @@ public class PlayerAdvancements { +@@ -166,6 +166,11 @@ public class PlayerAdvancements { } public boolean award(AdvancementHolder advancement, String criterionKey) { diff --git a/leaves-server/minecraft-patches/features/0013-Stick-can-change-ArmorStand-arm-status.patch b/leaves-server/minecraft-patches/features/0013-Stick-can-change-ArmorStand-arm-status.patch index a380eaa2b..361a3eba2 100644 --- a/leaves-server/minecraft-patches/features/0013-Stick-can-change-ArmorStand-arm-status.patch +++ b/leaves-server/minecraft-patches/features/0013-Stick-can-change-ArmorStand-arm-status.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Stick can change ArmorStand arm status diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java -index 15479a9fc47cca3d6627b42c31ba8ff114bbe362..9420ca7e32ae71ce9cecf8afd808ae6e9f8f4258 100644 +index 79ae039d1908830e81912d230b3540a4920e2017..a35415dced4c15ece829cea74010f42f0cb00441 100644 --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java @@ -229,6 +229,13 @@ public class ArmorStand extends LivingEntity { diff --git a/leaves-server/minecraft-patches/features/0014-Configurable-MC-59471.patch b/leaves-server/minecraft-patches/features/0014-Configurable-MC-59471.patch index 716f3a4fe..9f1a03e6f 100644 --- a/leaves-server/minecraft-patches/features/0014-Configurable-MC-59471.patch +++ b/leaves-server/minecraft-patches/features/0014-Configurable-MC-59471.patch @@ -5,24 +5,24 @@ Subject: [PATCH] Configurable MC-59471 diff --git a/net/minecraft/world/level/block/TripWireHookBlock.java b/net/minecraft/world/level/block/TripWireHookBlock.java -index 8a3a8b0fdf9545a41501dc992c6982d9c8ce7b66..a92462c76a648e6c175b8c2ef3e925aba81ba774 100644 +index 292fe41967db74884e5937cb125f1e022ccfb6bd..599f62a108a943f4f4d566ebefa3647515f74c50 100644 --- a/net/minecraft/world/level/block/TripWireHookBlock.java +++ b/net/minecraft/world/level/block/TripWireHookBlock.java -@@ -200,10 +200,17 @@ public class TripWireHookBlock extends Block { +@@ -199,10 +199,17 @@ public class TripWireHookBlock extends Block { BlockPos blockPos1 = pos.relative(direction, i2); BlockState blockState2 = blockStates[i2]; if (blockState2 != null) { - BlockState blockState3 = level.getBlockState(blockPos1); - if (blockState3.is(Blocks.TRIPWIRE) || blockState3.is(Blocks.TRIPWIRE_HOOK)) { -- if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates || !blockState3.is(Blocks.TRIPWIRE)) level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, flag2), 3); // Paper - prevent tripwire from updating +- if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates || !blockState3.is(Blocks.TRIPWIRE)) level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, flag2), Block.UPDATE_ALL); // Paper - prevent tripwire from updating + // Leaves start - MC-59471 + if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.tripwire.stringTripwireHookDuplicate) { -+ level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, flag2), 3); ++ level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, flag2), Block.UPDATE_ALL); + level.getBlockState(blockPos1); + } else { + BlockState blockState3 = level.getBlockState(blockPos1); + if (blockState3.is(Blocks.TRIPWIRE) || blockState3.is(Blocks.TRIPWIRE_HOOK)) { -+ if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates || !blockState3.is(Blocks.TRIPWIRE)) level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, flag2), 3); // Paper - prevent tripwire from updating ++ if (!io.papermc.paper.configuration.GlobalConfiguration.get().blockUpdates.disableTripwireUpdates || !blockState3.is(Blocks.TRIPWIRE)) level.setBlock(blockPos1, blockState2.trySetValue(ATTACHED, flag2), Block.UPDATE_ALL); // Paper - prevent tripwire from updating + } } + // Leaves end - MC-59471 diff --git a/leaves-server/minecraft-patches/features/0015-No-chat-sign.patch b/leaves-server/minecraft-patches/features/0015-No-chat-sign.patch index 083a694ef..46170fdf7 100644 --- a/leaves-server/minecraft-patches/features/0015-No-chat-sign.patch +++ b/leaves-server/minecraft-patches/features/0015-No-chat-sign.patch @@ -5,7 +5,7 @@ Subject: [PATCH] No chat sign diff --git a/net/minecraft/commands/arguments/ArgumentSignatures.java b/net/minecraft/commands/arguments/ArgumentSignatures.java -index 47cb25aa9c37bd84d156288c397321009f1d9ae2..a94981882ac37ea215df3a71117d4a9b1ab79fcd 100644 +index b61d120f112be90d94e9c545f26c4941a1a49d7d..58a92516bf540d1cd909d6a52a3b130a8ca09af8 100644 --- a/net/minecraft/commands/arguments/ArgumentSignatures.java +++ b/net/minecraft/commands/arguments/ArgumentSignatures.java @@ -13,10 +13,17 @@ public record ArgumentSignatures(List entries) { @@ -28,7 +28,7 @@ index 47cb25aa9c37bd84d156288c397321009f1d9ae2..a94981882ac37ea215df3a71117d4a9b buffer.writeCollection(this.entries, (buffer1, entry) -> entry.write(buffer1)); } diff --git a/net/minecraft/network/protocol/game/ServerboundChatPacket.java b/net/minecraft/network/protocol/game/ServerboundChatPacket.java -index b5afc05924ae899e020c303c8b86398e1d4ab8a0..4479634e577913372faf87138b5ba26ba02ea4f7 100644 +index 11d18c1c13e25c01c5e8f2e3363932d1fce16236..3b51297de087c52d92fa8457bb0792e3a4f436e2 100644 --- a/net/minecraft/network/protocol/game/ServerboundChatPacket.java +++ b/net/minecraft/network/protocol/game/ServerboundChatPacket.java @@ -16,7 +16,7 @@ public record ServerboundChatPacket(String message, Instant timeStamp, long salt @@ -106,10 +106,10 @@ index 88447fc2108126ccfad2fb7eb79ac94537f132d3..1bca4150c63da064bd2d1ee8f504f2eb private static final String PREFIX = "data:image/png;base64,"; public static final Codec CODEC = Codec.STRING.comapFlatMap(string -> { diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java -index 8d73fffb41346851d088ca0dee206661ff85ec29..4fdc743f56cdc4f92bfa8004c33e2f34cc9e9c70 100644 +index 6817fe059655ea93030aea69dfbe4fd6714fe1e4..16ea8a00470943904ae167b7a670cd26c599f024 100644 --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -781,7 +781,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -772,7 +772,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface // Paper start - Add setting for proxy online mode status return properties.enforceSecureProfile && io.papermc.paper.configuration.GlobalConfiguration.get().proxies.isProxyOnlineMode() @@ -119,7 +119,7 @@ index 8d73fffb41346851d088ca0dee206661ff85ec29..4fdc743f56cdc4f92bfa8004c33e2f34 } diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index adb26ae4dfd5dc111cc55000b71c15f95239b090..20b9dfe68dfbcd5bb999ee4ec0500bdf6bc7fdd5 100644 +index 8bacc1779e540c32dad9c547f941c5767729420c..cb9a4f669ae2ff772206bffde9255d239f47e1ea 100644 --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java @@ -323,10 +323,24 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack @@ -148,10 +148,10 @@ index adb26ae4dfd5dc111cc55000b71c15f95239b090..20b9dfe68dfbcd5bb999ee4ec0500bdf if (packet == null || this.processedDisconnect) { // Spigot return; diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 5d1d71858c730c431120d4a66244969ebf2a5164..73f8562658d30ba17d5ecf2c778622e5e75ae135 100644 +index 8baca1186179d49e1f8dc0e3acb39816bd61967d..ffc04a2e30b407df64bba4a887b14932c02c0caa 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -1185,7 +1185,7 @@ public abstract class PlayerList { +@@ -1187,7 +1187,7 @@ public abstract class PlayerList { } public boolean verifyChatTrusted(PlayerChatMessage message) { diff --git a/leaves-server/minecraft-patches/features/0016-Dont-send-useless-entity-packets.patch b/leaves-server/minecraft-patches/features/0016-Dont-send-useless-entity-packets.patch index 3c6cdcd73..c94e64c9b 100644 --- a/leaves-server/minecraft-patches/features/0016-Dont-send-useless-entity-packets.patch +++ b/leaves-server/minecraft-patches/features/0016-Dont-send-useless-entity-packets.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Dont send useless entity packets This patch is Powered by Purpur(https://github.com/PurpurMC/Purpur) diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index 638432a2e6506d3db6a25c068a33eeafb13cf0d6..1099280bd8e28c167702b74041928f260695ba7c 100644 +index 3a817c92147bb78c60238f3ddc1644b721aed7a2..8f6b7ec2f2294ac5845b8f6fb94959e9a11d6329 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java @@ -188,6 +188,11 @@ public class ServerEntity { diff --git a/leaves-server/minecraft-patches/features/0017-Optimize-suffocation.patch b/leaves-server/minecraft-patches/features/0017-Optimize-suffocation.patch index 5616a405c..7c80615c9 100644 --- a/leaves-server/minecraft-patches/features/0017-Optimize-suffocation.patch +++ b/leaves-server/minecraft-patches/features/0017-Optimize-suffocation.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Optimize suffocation This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index f4a45a39afae0befa5c6048bb5f2001395d5cbfc..ccc6900644f666729dc47cc0cfcdef66dd65b90a 100644 +index 96b9e04867a44a2f92120ab69562b956c8c021b7..7620938ea69b6a77a8ff6a64661658a7c52ac760 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -440,7 +440,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin @@ -18,7 +18,7 @@ index f4a45a39afae0befa5c6048bb5f2001395d5cbfc..ccc6900644f666729dc47cc0cfcdef66 this.hurtServer(serverLevel1, this.damageSources().inWall(), 1.0F); } else if (flag && !serverLevel1.getWorldBorder().isWithinBounds(this.getBoundingBox())) { double d = serverLevel1.getWorldBorder().getDistanceToBorder(this) + serverLevel1.getWorldBorder().getSafeZone(); -@@ -1411,6 +1411,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1423,6 +1423,12 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin return this.getHealth() <= 0.0F; } diff --git a/leaves-server/minecraft-patches/features/0019-Config-to-disable-method-profiler.patch b/leaves-server/minecraft-patches/features/0018-Config-to-disable-method-profiler.patch similarity index 77% rename from leaves-server/minecraft-patches/features/0019-Config-to-disable-method-profiler.patch rename to leaves-server/minecraft-patches/features/0018-Config-to-disable-method-profiler.patch index 687127667..e5820e0cd 100644 --- a/leaves-server/minecraft-patches/features/0019-Config-to-disable-method-profiler.patch +++ b/leaves-server/minecraft-patches/features/0018-Config-to-disable-method-profiler.patch @@ -6,23 +6,23 @@ Subject: [PATCH] Config to disable method profiler This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 309ff4c55b2a4ccf3d18951b51c2e10d0ff39bfc..19b89c3d0a21c0223bac1844081099d2bf8296ab 100644 +index f45ad308fc4bcf5647580ad3d46de9a966985790..98f5813f404874a861b31758e74072c31dc2fef2 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1333,7 +1333,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop -Date: Sun, 14 Aug 2022 10:35:42 +0800 -Subject: [PATCH] Only check for spooky season once an hour - -This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) - -diff --git a/net/minecraft/world/entity/ambient/Bat.java b/net/minecraft/world/entity/ambient/Bat.java -index c0198c0b6d00667c9591a5cd254b0bfedc3fb627..ec713dd16a842119c02b760ed45f7de2a839cb3b 100644 ---- a/net/minecraft/world/entity/ambient/Bat.java -+++ b/net/minecraft/world/entity/ambient/Bat.java -@@ -246,12 +246,30 @@ public class Bat extends AmbientCreature { - } - } - -+ // Leaves start - only check for spooky season once an hour -+ private static boolean isSpookySeason = false; -+ private static final int ONE_HOUR = 20 * 60 * 60; -+ private static int lastSpookyCheck = -ONE_HOUR; -+ - private static boolean isHalloween() { -- LocalDate localDate = LocalDate.now(); -- int i = localDate.get(ChronoField.DAY_OF_MONTH); -- int i1 = localDate.get(ChronoField.MONTH_OF_YEAR); -- return i1 == 10 && i >= 20 || i1 == 11 && i <= 3; -+ if (org.leavesmc.leaves.LeavesConfig.performance.checkSpookySeasonOnceAnHour) { -+ if (net.minecraft.server.MinecraftServer.currentTick - lastSpookyCheck > ONE_HOUR) { -+ LocalDate localdate = LocalDate.now(); -+ int i = localdate.getDayOfMonth(); -+ int j = localdate.getMonth().getValue(); -+ -+ isSpookySeason = j == 10 && i >= 20 || j == 11 && i <= 3; -+ lastSpookyCheck = net.minecraft.server.MinecraftServer.currentTick; -+ } -+ return isSpookySeason; -+ } else { -+ LocalDate localDate = LocalDate.now(); -+ int i = localDate.get(ChronoField.DAY_OF_MONTH); -+ int i1 = localDate.get(ChronoField.MONTH_OF_YEAR); -+ return i1 == 10 && i >= 20 || i1 == 11 && i <= 3; -+ } - } -+ // Leaves end - only check for spooky season once an hour - - private void setupAnimationStates() { - if (this.isResting()) { diff --git a/leaves-server/minecraft-patches/features/0020-Throttle-goal-selector-during-inactive-ticking.patch b/leaves-server/minecraft-patches/features/0019-Throttle-goal-selector-during-inactive-ticking.patch similarity index 93% rename from leaves-server/minecraft-patches/features/0020-Throttle-goal-selector-during-inactive-ticking.patch rename to leaves-server/minecraft-patches/features/0019-Throttle-goal-selector-during-inactive-ticking.patch index fb746f77a..c5f8190dc 100644 --- a/leaves-server/minecraft-patches/features/0020-Throttle-goal-selector-during-inactive-ticking.patch +++ b/leaves-server/minecraft-patches/features/0019-Throttle-goal-selector-during-inactive-ticking.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Throttle goal selector during inactive ticking This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java -index 4994dcb209dd82d60559cfc453198b75cbfa1511..37ad911648aa88bdb5132a819806a5a303438dbf 100644 +index 92175cc019750e829fcad7691a937024c2649882..0e58de4eef841606b5fb26ad8267c5736c2b807c 100644 --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java @@ -217,11 +217,13 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab diff --git a/leaves-server/minecraft-patches/features/0021-Reduce-entity-allocations.patch b/leaves-server/minecraft-patches/features/0020-Reduce-entity-allocations.patch similarity index 89% rename from leaves-server/minecraft-patches/features/0021-Reduce-entity-allocations.patch rename to leaves-server/minecraft-patches/features/0020-Reduce-entity-allocations.patch index c808d27aa..afd3ab05f 100644 --- a/leaves-server/minecraft-patches/features/0021-Reduce-entity-allocations.patch +++ b/leaves-server/minecraft-patches/features/0020-Reduce-entity-allocations.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Reduce entity allocations This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/net/minecraft/world/entity/ai/attributes/AttributeMap.java b/net/minecraft/world/entity/ai/attributes/AttributeMap.java -index fdb02fc40579866167e8cc9bcefbd961588b53a6..05c4a98966f7ed86dd658166caf0256566fd2985 100644 +index 92b7f4cbd276dad49cba78514db3552af8cdd80c..d977c8d5fb2b04da8fb07abc40cb6b5d2b2b1a03 100644 --- a/net/minecraft/world/entity/ai/attributes/AttributeMap.java +++ b/net/minecraft/world/entity/ai/attributes/AttributeMap.java @@ -18,9 +18,11 @@ public class AttributeMap { @@ -21,10 +21,10 @@ index fdb02fc40579866167e8cc9bcefbd961588b53a6..05c4a98966f7ed86dd658166caf02565 } private void onAttributeModified(AttributeInstance instance) { -@@ -44,7 +46,13 @@ public class AttributeMap { +@@ -43,7 +45,13 @@ public class AttributeMap { + } - @Nullable - public AttributeInstance getInstance(Holder attribute) { + public @Nullable AttributeInstance getInstance(Holder attribute) { - return this.attributes.computeIfAbsent(attribute, holder -> this.supplier.createInstance(this::onAttributeModified, (Holder)holder)); + // Leaves start - cache lambda, as for some reason java allocates it anyways + if (org.leavesmc.leaves.LeavesConfig.performance.reduceEntityAllocations) { diff --git a/leaves-server/minecraft-patches/features/0022-Remove-lambda-from-ticking-guard.patch b/leaves-server/minecraft-patches/features/0021-Remove-lambda-from-ticking-guard.patch similarity index 94% rename from leaves-server/minecraft-patches/features/0022-Remove-lambda-from-ticking-guard.patch rename to leaves-server/minecraft-patches/features/0021-Remove-lambda-from-ticking-guard.patch index ad3f17fc9..d6a7b6306 100644 --- a/leaves-server/minecraft-patches/features/0022-Remove-lambda-from-ticking-guard.patch +++ b/leaves-server/minecraft-patches/features/0021-Remove-lambda-from-ticking-guard.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Remove lambda from ticking guard This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 868ebe0fd5bde694fe8bef95ebf78051a9187672..9c3362e52def414c553fbac22bb8d8304fc3bfd2 100644 +index 1d5a815b87b2ec9d535658f9e5ad8febbfa9b19a..b00a8b969c273001c9eabe2409239dce9bd1896f 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -838,7 +838,24 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -853,7 +853,24 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } profilerFiller.push("tick"); diff --git a/leaves-server/minecraft-patches/features/0023-Cache-climbing-check-for-activation.patch b/leaves-server/minecraft-patches/features/0022-Cache-climbing-check-for-activation.patch similarity index 89% rename from leaves-server/minecraft-patches/features/0023-Cache-climbing-check-for-activation.patch rename to leaves-server/minecraft-patches/features/0022-Cache-climbing-check-for-activation.patch index fb475b2fc..3d95e2de9 100644 --- a/leaves-server/minecraft-patches/features/0023-Cache-climbing-check-for-activation.patch +++ b/leaves-server/minecraft-patches/features/0022-Cache-climbing-check-for-activation.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Cache climbing check for activation This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/io/papermc/paper/entity/activation/ActivationRange.java b/io/papermc/paper/entity/activation/ActivationRange.java -index ae2bb9a73106febfe5f0d090abd4252bbb5fd27e..b3e536400efa41ba754e52f1ee224365b69dcdab 100644 +index c18823746ab2edcab536cb1589b7720e3af07e0f..e2af98578ad100a121fac6bb1ebde963d666161e 100644 --- a/io/papermc/paper/entity/activation/ActivationRange.java +++ b/io/papermc/paper/entity/activation/ActivationRange.java @@ -221,7 +221,7 @@ public final class ActivationRange { @@ -19,10 +19,10 @@ index ae2bb9a73106febfe5f0d090abd4252bbb5fd27e..b3e536400efa41ba754e52f1ee224365 } if (entity instanceof final Mob mob && mob.getTarget() != null) { diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index ccc6900644f666729dc47cc0cfcdef66dd65b90a..ce4c8e14d3d7b5837dcce006fa67722f3f430fa4 100644 +index 7620938ea69b6a77a8ff6a64661658a7c52ac760..6657cc6dd1fa32aafa65e79a2b2b439ffba889c6 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -2164,6 +2164,22 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -2179,6 +2179,22 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin return this.lastClimbablePos; } diff --git a/leaves-server/minecraft-patches/features/0024-Reduce-chunk-loading-lookups.patch b/leaves-server/minecraft-patches/features/0023-Reduce-chunk-loading-lookups.patch similarity index 92% rename from leaves-server/minecraft-patches/features/0024-Reduce-chunk-loading-lookups.patch rename to leaves-server/minecraft-patches/features/0023-Reduce-chunk-loading-lookups.patch index 3a57794d2..963403bcd 100644 --- a/leaves-server/minecraft-patches/features/0024-Reduce-chunk-loading-lookups.patch +++ b/leaves-server/minecraft-patches/features/0023-Reduce-chunk-loading-lookups.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Reduce chunk loading & lookups This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish) diff --git a/net/minecraft/world/entity/monster/EnderMan.java b/net/minecraft/world/entity/monster/EnderMan.java -index dcb49e8305aa8b9215da9f77fa147f701fdbbef0..0732709d0ca78f59ad6b7f8ac5e7bfbe5506f60b 100644 +index 6516cccada06a9a7d3d743929712970fe0a2b8c8..916a15dda74c1a68bdcb4c890ec56e4a60befb9f 100644 --- a/net/minecraft/world/entity/monster/EnderMan.java +++ b/net/minecraft/world/entity/monster/EnderMan.java -@@ -302,11 +302,28 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -300,11 +300,28 @@ public class EnderMan extends Monster implements NeutralMob { private boolean teleport(double x, double y, double z) { BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(x, y, z); diff --git a/leaves-server/minecraft-patches/features/0025-InstantBlockUpdater-Reintroduced.patch b/leaves-server/minecraft-patches/features/0024-InstantBlockUpdater-Reintroduced.patch similarity index 91% rename from leaves-server/minecraft-patches/features/0025-InstantBlockUpdater-Reintroduced.patch rename to leaves-server/minecraft-patches/features/0024-InstantBlockUpdater-Reintroduced.patch index 4dc3130b5..70dd94df2 100644 --- a/leaves-server/minecraft-patches/features/0025-InstantBlockUpdater-Reintroduced.patch +++ b/leaves-server/minecraft-patches/features/0024-InstantBlockUpdater-Reintroduced.patch @@ -6,10 +6,10 @@ Subject: [PATCH] InstantBlockUpdater Reintroduced This patch is Powered by Carpet-TIS-Addition(https://github.com/plusls/Carpet-TIS-Addition) diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 145c8e1791638c78b81222181e9f3679a33795a9..015c49c8170ba8d73b2bc9386192681a8ececb3f 100644 +index b00a8b969c273001c9eabe2409239dce9bd1896f..a8c54d7e6c95fd3dd83e119f01bf6d13378abf3b 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -871,12 +871,14 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -886,12 +886,14 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper - rewrite chunk system profilerFiller.pop(); profilerFiller.push("debugSynchronizers"); @@ -31,7 +31,7 @@ index 145c8e1791638c78b81222181e9f3679a33795a9..015c49c8170ba8d73b2bc9386192681a this.debugSynchronizers.tick(this.server.debugSubscribers()); profilerFiller.pop(); diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 01e0dc28ef63456a45b800e72d76180b40811a72..feafaaeca7ffa6fda5af9897c448b61ee1760290 100644 +index ac1ca945fcea0997d837e7c5586d86a709f52d47..16ea2b070207c7aece5cb80fe713a07d01b18f84 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -113,7 +113,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @@ -43,7 +43,7 @@ index 01e0dc28ef63456a45b800e72d76180b40811a72..feafaaeca7ffa6fda5af9897c448b61e private final List pendingBlockEntityTickers = Lists.newArrayList(); private boolean tickingBlockEntities; public final Thread thread; -@@ -863,7 +863,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -861,7 +861,13 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl this.thread = Thread.currentThread(); this.biomeManager = new BiomeManager(this, biomeZoomSeed); this.isDebug = isDebug; diff --git a/leaves-server/minecraft-patches/features/0026-Random-flatten-triangular-distribution.patch b/leaves-server/minecraft-patches/features/0025-Random-flatten-triangular-distribution.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0026-Random-flatten-triangular-distribution.patch rename to leaves-server/minecraft-patches/features/0025-Random-flatten-triangular-distribution.patch diff --git a/leaves-server/minecraft-patches/features/0027-BBOR-Protocol.patch b/leaves-server/minecraft-patches/features/0026-BBOR-Protocol.patch similarity index 82% rename from leaves-server/minecraft-patches/features/0027-BBOR-Protocol.patch rename to leaves-server/minecraft-patches/features/0026-BBOR-Protocol.patch index 6f11c44bf..7201f6a31 100644 --- a/leaves-server/minecraft-patches/features/0027-BBOR-Protocol.patch +++ b/leaves-server/minecraft-patches/features/0026-BBOR-Protocol.patch @@ -5,10 +5,10 @@ Subject: [PATCH] BBOR Protocol diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index de59760d27280555a334bda4f436164568cffbd6..bdc564c24982c196f151121fb769c7cfad4a08b0 100644 +index 3acc1374a7ef968d88e9f566ce7b812fb8d580af..e7fa4e132e88b24789ed30eb3248994f21ffd6bd 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -759,6 +759,11 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot +@@ -753,6 +753,11 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot public void setLoaded(boolean loaded) { this.loaded = loaded; diff --git a/leaves-server/minecraft-patches/features/0028-PCA-sync-protocol.patch b/leaves-server/minecraft-patches/features/0027-PCA-sync-protocol.patch similarity index 85% rename from leaves-server/minecraft-patches/features/0028-PCA-sync-protocol.patch rename to leaves-server/minecraft-patches/features/0027-PCA-sync-protocol.patch index b64ee0891..ceaf8a7d2 100644 --- a/leaves-server/minecraft-patches/features/0028-PCA-sync-protocol.patch +++ b/leaves-server/minecraft-patches/features/0027-PCA-sync-protocol.patch @@ -5,11 +5,11 @@ Subject: [PATCH] PCA sync protocol This patch is Powered by plusls-carpet-addition(https://github.com/plusls/plusls-carpet-addition) -diff --git a/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/net/minecraft/world/entity/animal/horse/AbstractHorse.java -index c87a1a5e3696e40f9f0d6f4d93e102e73325d4f8..b01f53af58afdde22f062e6d16888bf09ee98805 100644 ---- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java -+++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java -@@ -306,6 +306,13 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory +diff --git a/net/minecraft/world/entity/animal/equine/AbstractHorse.java b/net/minecraft/world/entity/animal/equine/AbstractHorse.java +index e837c63631c637238b9fe0ba05984af5e0d2b833..9faecf72b8622b57e99c71abcae19c2c38488a1c 100644 +--- a/net/minecraft/world/entity/animal/equine/AbstractHorse.java ++++ b/net/minecraft/world/entity/animal/equine/AbstractHorse.java +@@ -301,6 +301,13 @@ public abstract class AbstractHorse extends Animal implements HasCustomInventory public void createInventory() { SimpleContainer simpleContainer = this.inventory; this.inventory = new SimpleContainer(this.getInventorySize(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit @@ -23,11 +23,11 @@ index c87a1a5e3696e40f9f0d6f4d93e102e73325d4f8..b01f53af58afdde22f062e6d16888bf0 if (simpleContainer != null) { int min = Math.min(simpleContainer.getContainerSize(), this.inventory.getContainerSize()); -diff --git a/net/minecraft/world/entity/npc/AbstractVillager.java b/net/minecraft/world/entity/npc/AbstractVillager.java -index 6bb17ecbd93f6ced5436cf75f3695f44eedd4bd9..ea7364f3cc9f339578232ba1103008a9ed50234a 100644 ---- a/net/minecraft/world/entity/npc/AbstractVillager.java -+++ b/net/minecraft/world/entity/npc/AbstractVillager.java -@@ -48,6 +48,15 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa +diff --git a/net/minecraft/world/entity/npc/villager/AbstractVillager.java b/net/minecraft/world/entity/npc/villager/AbstractVillager.java +index fa8f1ea38192f9ad0a961a53399f295d83af7721..e6b79e6877b31253c065864e38b1ed62be0b0efb 100644 +--- a/net/minecraft/world/entity/npc/villager/AbstractVillager.java ++++ b/net/minecraft/world/entity/npc/villager/AbstractVillager.java +@@ -49,6 +49,15 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa super(type, level); this.setPathfindingMalus(PathType.DANGER_FIRE, 16.0F); this.setPathfindingMalus(PathType.DAMAGE_FIRE, -1.0F); @@ -43,10 +43,10 @@ index 6bb17ecbd93f6ced5436cf75f3695f44eedd4bd9..ea7364f3cc9f339578232ba1103008a9 } @Override -diff --git a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -index 0f9bfcd1eab023c1772e9fafcda85d110904bd1c..8fdde0cc090c80b65b4c0d679bf4b412b6b761ee 100644 ---- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -+++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java +diff --git a/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java b/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java +index 79541b56a07d10de450f63945d0849a7f320da6c..da1cfc043e261e7ed7bc85fa1e5e7ee2e2078630 100644 +--- a/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java ++++ b/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java @@ -65,6 +65,11 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme @Override @@ -60,7 +60,7 @@ index 0f9bfcd1eab023c1772e9fafcda85d110904bd1c..8fdde0cc090c80b65b4c0d679bf4b412 @Override diff --git a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -index d8176f1f36f12fe179b5a63e6bf8f290a7a7461d..37bbd8d2cf412983fc4eb89737b3343f17364cae 100644 +index c8bfa1eeb847d6d9972d2f6625cc1f60063713d4..580741eb999662726bb9a11022600b78e44417ea 100644 --- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java @@ -430,6 +430,16 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit @@ -102,10 +102,10 @@ index 75c09a2079c89f9346391abdd01ef8790b9cbb13..6741fe3abc4396236dc0ca31074e36d6 protected Component getDefaultName() { return DEFAULT_NAME; diff --git a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -index f0673167d6273c7689cd58ac8f51e51649cb3ad0..03c9a2d253ba6fec39a0322eb74ac611fdc8b7f0 100644 +index c989b7d52e16d93e65afb0f921d514c68b814921..17096a9ba33ecaddb50bfe2bccb505d0f0110e7e 100644 --- a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -@@ -149,6 +149,11 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -150,6 +150,11 @@ public class BeehiveBlockEntity extends BlockEntity { super.setChanged(); } @@ -117,7 +117,7 @@ index f0673167d6273c7689cd58ac8f51e51649cb3ad0..03c9a2d253ba6fec39a0322eb74ac611 return list; } -@@ -206,6 +211,11 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -207,6 +212,11 @@ public class BeehiveBlockEntity extends BlockEntity { this.level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(bee, this.getBlockState())); } @@ -129,7 +129,7 @@ index f0673167d6273c7689cd58ac8f51e51649cb3ad0..03c9a2d253ba6fec39a0322eb74ac611 bee.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.ENTER_BLOCK); // CraftBukkit - add Bukkit remove cause super.setChanged(); } -@@ -327,6 +337,11 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -328,6 +338,11 @@ public class BeehiveBlockEntity extends BlockEntity { if (releaseOccupant(level, pos, state, beeData.toOccupant(), null, beeReleaseStatus, savedFlowerPos)) { flag = true; iterator.remove(); @@ -141,7 +141,7 @@ index f0673167d6273c7689cd58ac8f51e51649cb3ad0..03c9a2d253ba6fec39a0322eb74ac611 } // Paper start - Fix bees aging inside; use exitTickCounter to keep actual bee life else if (level.paperConfig().entities.behavior.cooldownFailedBeehiveReleases) { -@@ -358,6 +373,11 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -359,6 +374,11 @@ public class BeehiveBlockEntity extends BlockEntity { input.read("bees", BeehiveBlockEntity.Occupant.LIST_CODEC).orElse(List.of()).forEach(this::storeBee); this.savedFlowerPos = input.read("flower_pos", BlockPos.CODEC).orElse(null); this.maxBees = input.getIntOr("Bukkit.MaxEntities", MAX_OCCUPANTS); // Paper - persist max bukkit occupants @@ -154,7 +154,7 @@ index f0673167d6273c7689cd58ac8f51e51649cb3ad0..03c9a2d253ba6fec39a0322eb74ac611 @Override diff --git a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -index 5b28e257982c911f4d8ffe286dc125b3f9b64ee4..a4d3d5b6830d156c76e381c5437867c0ed104016 100644 +index 74577d6523db1cce6413317c016887f2a7bb9977..5c51ecca91cfbe86bf815f7c3a1d26a23381a7da 100644 --- a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java @@ -334,4 +334,14 @@ public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements @@ -236,7 +236,7 @@ index b4a155cc914092dad83977df714fbbc033c69d19..2fbfe925c81126cb99a4330a232d7d1b protected Component getDefaultName() { return DEFAULT_NAME; diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index 28348e3881c3c8591053a01b193fb2a956f79726..ab88bca97fe275528a2feb22e5da89252be683c3 100644 +index 12f8105d6b12c5d63cb6e5e79435c7fd22655475..59a92e77244f45a58f61919519fc57f6c0bed8ee 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -123,6 +123,16 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @@ -269,10 +269,10 @@ index 28348e3881c3c8591053a01b193fb2a956f79726..ab88bca97fe275528a2feb22e5da8925 } } diff --git a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -index 4d268864656ad67e6971b74534e25ac47d922cbd..68fcb64d13bbd61ad78137f101ab20264f402df8 100644 +index 61b99c895c0e248f0e7c4c634644dcff54a964d9..fa11a17186e590cdc7b7902b91db701592a2f6b7 100644 --- a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -@@ -268,6 +268,16 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl +@@ -267,6 +267,16 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl this.itemStacks = items; } diff --git a/leaves-server/minecraft-patches/features/0029-Alternative-block-placement-Protocol.patch b/leaves-server/minecraft-patches/features/0028-Alternative-block-placement-Protocol.patch similarity index 81% rename from leaves-server/minecraft-patches/features/0029-Alternative-block-placement-Protocol.patch rename to leaves-server/minecraft-patches/features/0028-Alternative-block-placement-Protocol.patch index c786b8683..71b4022c6 100644 --- a/leaves-server/minecraft-patches/features/0029-Alternative-block-placement-Protocol.patch +++ b/leaves-server/minecraft-patches/features/0028-Alternative-block-placement-Protocol.patch @@ -9,26 +9,26 @@ MasaGadget(https://github.com/plusls/MasaGadget) litematica(https://github.com/maruohon/litematica) diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java -index dceb2b683064bbf4286c3fe71e0fd0c5a644cb07..19649f75889d1c4243519eb8ccb46f4b9abd0f68 100644 +index 73ce7c82c0bd28c2e43ca40ba35c4603b21375ad..a5d3caab2072b2c9bf8fdcbdb7c52c2dee16cfaf 100644 --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -148,7 +148,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; @@ -43,16 +43,15 @@ 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 57574f93763ab98a4bc109f56cfc3af08962a878..c9318bda7ea2cb25939516fb1c3cc90488bb8e6c 100644 +index 6d0cdbd52a3bb4e09fd480fa08fa825e987d2a2c..8dd0ddb5fbb43cb0b3d8eb2c715b883d86299dae 100644 --- a/net/minecraft/world/level/block/Block.java +++ b/net/minecraft/world/level/block/Block.java -@@ -478,6 +478,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) { ++ public @Nullable BlockState getRealStateForPlacement(BlockPlaceContext ctx) { + BlockState vanillaState = this.getStateForPlacement(ctx); + switch (org.leavesmc.leaves.LeavesConfig.protocol.alternativeBlockPlacement) { + case CARPET -> { @@ -77,6 +76,6 @@ index 57574f93763ab98a4bc109f56cfc3af08962a878..c9318bda7ea2cb25939516fb1c3cc904 + } + // Leaves end - alternativeBlockPlacement + - @Nullable - public BlockState getStateForPlacement(BlockPlaceContext context) { + public @Nullable BlockState getStateForPlacement(BlockPlaceContext context) { return this.defaultBlockState(); + } diff --git a/leaves-server/minecraft-patches/features/0030-Jade-Protocol.patch b/leaves-server/minecraft-patches/features/0029-Jade-Protocol.patch similarity index 91% rename from leaves-server/minecraft-patches/features/0030-Jade-Protocol.patch rename to leaves-server/minecraft-patches/features/0029-Jade-Protocol.patch index 07a108b20..f9ba8cc74 100644 --- a/leaves-server/minecraft-patches/features/0030-Jade-Protocol.patch +++ b/leaves-server/minecraft-patches/features/0029-Jade-Protocol.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Jade Protocol This patch is Powered by Jade(https://github.com/Snownee/Jade) diff --git a/net/minecraft/world/entity/animal/armadillo/Armadillo.java b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -index b5ce8de41b087812b02f22d538d5ca18eee60694..7b63c9aa70f070208e9a161fbee8d913204a2394 100644 +index 901e4e9897e76cd4158d7f8bb8ec829df8ff8196..59b9373c7a14e42d9e5f691354a7616d16856215 100644 --- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java @@ -64,7 +64,7 @@ public class Armadillo extends Animal { @@ -19,10 +19,10 @@ index b5ce8de41b087812b02f22d538d5ca18eee60694..7b63c9aa70f070208e9a161fbee8d913 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 3ce172c1bdaf8b8a8ad774dd37498e8e379c68bb..5736d20494d2aaad1d5ac3403d4a923199bdbf13 100644 +index f65cfb908aac16e6df4d209c6b5c3ee5065289d3..9afada8ca16775752468e1b14cd97daf26325fc4 100644 --- a/net/minecraft/world/entity/animal/frog/Tadpole.java +++ b/net/minecraft/world/entity/animal/frog/Tadpole.java -@@ -247,7 +247,7 @@ public class Tadpole extends AbstractFish { +@@ -244,7 +244,7 @@ public class Tadpole extends AbstractFish { } } @@ -32,7 +32,7 @@ index 3ce172c1bdaf8b8a8ad774dd37498e8e379c68bb..5736d20494d2aaad1d5ac3403d4a9231 } 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 { @@ -45,13 +45,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; @@ -71,7 +71,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/leaves-server/minecraft-patches/features/0031-Player-operation-limiter.patch b/leaves-server/minecraft-patches/features/0030-Player-operation-limiter.patch similarity index 87% rename from leaves-server/minecraft-patches/features/0031-Player-operation-limiter.patch rename to leaves-server/minecraft-patches/features/0030-Player-operation-limiter.patch index 58a6d28bc..ed4284ec8 100644 --- a/leaves-server/minecraft-patches/features/0031-Player-operation-limiter.patch +++ b/leaves-server/minecraft-patches/features/0030-Player-operation-limiter.patch @@ -6,13 +6,13 @@ Subject: [PATCH] Player operation limiter This patch is Powered by plusls-carpet-addition(https://github.com/plusls/plusls-carpet-addition) diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 04ea4e33504703c4074aef6e74ec06dc772b1bb9..0110db0b1002b2007892e5c57b74de567d901d7b 100644 +index 8c38a1b97203661454c099746472206a7954b5bc..59cd1c64037148e9db403360755663aeda43e729 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -443,6 +443,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -433,6 +433,10 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc public boolean isRealPlayer; // Paper - public @Nullable com.destroystokyo.paper.event.entity.PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent - public @Nullable org.bukkit.event.player.PlayerQuitEvent.QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event + public com.destroystokyo.paper.event.entity.@Nullable PlayerNaturallySpawnCreaturesEvent playerNaturallySpawnedEvent; // Paper - PlayerNaturallySpawnCreaturesEvent + public org.bukkit.event.player.PlayerQuitEvent.@Nullable QuitReason quitReason = null; // Paper - Add API for quit reason; there are a lot of changes to do if we change all methods leading to the event + // Leaves start - player operation limiter + private int instaBreakCountPerTick = 0; + private int placeBlockCountPerTick = 0; @@ -20,15 +20,15 @@ index 04ea4e33504703c4074aef6e74ec06dc772b1bb9..0110db0b1002b2007892e5c57b74de56 // Paper start - rewrite chunk system private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader; -@@ -723,6 +727,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -720,6 +724,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.invulnerableTime > 0) { -@@ -3103,4 +3108,31 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -3131,4 +3136,31 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc return (org.bukkit.craftbukkit.entity.CraftPlayer) super.getBukkitEntity(); } // CraftBukkit end @@ -61,10 +61,10 @@ index 04ea4e33504703c4074aef6e74ec06dc772b1bb9..0110db0b1002b2007892e5c57b74de56 + // Leaves end - player operation limiter } diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java -index 7166889bce8065508030ecd5b1400ee9be031bf3..65e2edf39857b2e03c5a32dfb3b822b5cb4ce93c 100644 +index 84d19d79e77cec6a5d64f59fbcce703e467b2407..1039bbcfccb851f9bb557b6d55656d51d8821647 100644 --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -320,6 +320,19 @@ public class ServerPlayerGameMode { +@@ -317,6 +317,19 @@ public class ServerPlayerGameMode { } public void destroyAndAck(BlockPos pos, int sequence, String message) { @@ -85,10 +85,10 @@ index 7166889bce8065508030ecd5b1400ee9be031bf3..65e2edf39857b2e03c5a32dfb3b822b5 this.debugLogging(pos, true, sequence, message); } else { diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java -index 7bca36dd26afb02524022df74147f628edf51460..58ec8a43265ebf50fdd71f2cbb7dedf4762bc5b4 100644 +index a5d3caab2072b2c9bf8fdcbdb7c52c2dee16cfaf..b647172cda155a5e704565c8c4819c20758bd3f3 100644 --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -64,6 +64,21 @@ public class BlockItem extends Item { +@@ -65,6 +65,21 @@ public class BlockItem extends Item { final org.bukkit.block.BlockState oldBukkitState = bukkitState != null ? bukkitState : org.bukkit.craftbukkit.block.CraftBlockStates.getBlockState(blockPlaceContext.getLevel(), blockPlaceContext.getClickedPos()); // Paper - Reset placed block on exception // CraftBukkit end diff --git a/leaves-server/minecraft-patches/features/0032-Renewable-Elytra.patch b/leaves-server/minecraft-patches/features/0031-Renewable-Elytra.patch similarity index 89% rename from leaves-server/minecraft-patches/features/0032-Renewable-Elytra.patch rename to leaves-server/minecraft-patches/features/0031-Renewable-Elytra.patch index 31f0e3c2a..ba46d88c7 100644 --- a/leaves-server/minecraft-patches/features/0032-Renewable-Elytra.patch +++ b/leaves-server/minecraft-patches/features/0031-Renewable-Elytra.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Renewable Elytra This patch is Powered by Carpet-TIS-Addition(https://github.com/plusls/Carpet-TIS-Addition) diff --git a/net/minecraft/world/entity/monster/Phantom.java b/net/minecraft/world/entity/monster/Phantom.java -index b0f0a70ef6d708917ac8278c7eebd81d1fd7df6a..25c02ce8a613adae374bf85ed282399d44fba2ef 100644 +index 62c40a04a105eff471599c4535239fee9726dbd1..6d2c12897b7ffd0aa02f607a53684e7d529778f3 100644 --- a/net/minecraft/world/entity/monster/Phantom.java +++ b/net/minecraft/world/entity/monster/Phantom.java -@@ -242,6 +242,20 @@ public class Phantom extends Mob implements Enemy { +@@ -238,6 +238,20 @@ public class Phantom extends Mob implements Enemy { return targetingConditions.test(level, this, entity); } diff --git a/leaves-server/minecraft-patches/features/0033-MC-Technical-Survival-Mode.patch b/leaves-server/minecraft-patches/features/0032-MC-Technical-Survival-Mode.patch similarity index 83% rename from leaves-server/minecraft-patches/features/0033-MC-Technical-Survival-Mode.patch rename to leaves-server/minecraft-patches/features/0032-MC-Technical-Survival-Mode.patch index ee11ad678..fc15fc084 100644 --- a/leaves-server/minecraft-patches/features/0033-MC-Technical-Survival-Mode.patch +++ b/leaves-server/minecraft-patches/features/0032-MC-Technical-Survival-Mode.patch @@ -6,20 +6,20 @@ Subject: [PATCH] MC Technical Survival Mode Will automatically overwrite some configuration after startup diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 0110db0b1002b2007892e5c57b74de567d901d7b..d4df6ca7360d4bc605a51061444191d7929c7778 100644 +index 59cd1c64037148e9db403360755663aeda43e729..e162ae0779ff613faf1def076fb2267408a9d414 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -1747,7 +1747,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -1755,7 +1755,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc public boolean isInvulnerableTo(ServerLevel level, DamageSource damageSource) { return (super.isInvulnerableTo(level, damageSource) // Paper - disable player cramming; || this.isChangingDimension() && !damageSource.is(DamageTypes.ENDER_PEARL) -- || !this.hasClientLoaded()) || (!this.level().paperConfig().collisions.allowPlayerCrammingDamage && damageSource.is(DamageTypes.CRAMMING)); // Paper - disable player cramming; -+ || !this.hasClientLoaded()) || (!org.leavesmc.leaves.LeavesConfig.modify.mcTechnicalMode && !this.level().paperConfig().collisions.allowPlayerCrammingDamage && damageSource.is(DamageTypes.CRAMMING)); // Paper - disable player cramming; // Leaves - mc technical survival mode +- || !this.connection.hasClientLoaded()) || (!this.level().paperConfig().collisions.allowPlayerCrammingDamage && damageSource.is(DamageTypes.CRAMMING)); // Paper - disable player cramming; ++ || !this.connection.hasClientLoaded()) || (!org.leavesmc.leaves.LeavesConfig.modify.mcTechnicalMode && !this.level().paperConfig().collisions.allowPlayerCrammingDamage && damageSource.is(DamageTypes.CRAMMING)); // Paper - disable player cramming; // Leaves - mc technical survival mode } @Override diff --git a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java -index ffc960a4e66ed03a358b363a4ce1dcee0b29ac36..c1671664618428d5b82df721b559ce7280b9e8b7 100644 +index 278addb7dbe4f57e99fb91ce1cd1bf3559e239a3..b7e790d05e2f15dc073f8ca55f17bd6fcaea9cf1 100644 --- a/net/minecraft/world/entity/ai/behavior/AcquirePoi.java +++ b/net/minecraft/world/entity/ai/behavior/AcquirePoi.java @@ -69,7 +69,7 @@ public class AcquirePoi { @@ -32,7 +32,7 @@ index ffc960a4e66ed03a358b363a4ce1dcee0b29ac36..c1671664618428d5b82df721b559ce72 map.long2ObjectEntrySet().removeIf(entry -> !entry.getValue().isStillValid(time)); Predicate predicate1 = pos -> { diff --git a/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java b/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java -index 4fc773a0cb9d68e22e4d6cc7d819196a6cabf4f1..af87a79c58b41e625a83665ff0893c9a29386a35 100644 +index c095f42aa103b7874fb5d8dcece1b1484c2e2968..0b3f757a3de694589a070f6b02594aca06828043 100644 --- a/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java +++ b/net/minecraft/world/entity/boss/enderdragon/EndCrystal.java @@ -65,7 +65,7 @@ public class EndCrystal extends Entity { @@ -45,10 +45,10 @@ index 4fc773a0cb9d68e22e4d6cc7d819196a6cabf4f1..af87a79c58b41e625a83665ff0893c9a || ((ServerLevel) this.level()).getDragonFight() == null || ((ServerLevel) this.level()).getDragonFight().respawnStage == null diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java -index c685b5123c88fc73c26a3ba31225ab1226e52702..d36ce16724e9f5a79960f0aa265a0354f5240abc 100644 +index 910e7739aea98d6dfa603072acf5e9936dbb2c5e..9ceec84368cc24bc43b90a82150c9abf7db758e1 100644 --- a/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java -@@ -100,7 +100,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -99,7 +99,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { @Override public void tick() { @@ -58,10 +58,10 @@ index c685b5123c88fc73c26a3ba31225ab1226e52702..d36ce16724e9f5a79960f0aa265a0354 this.applyGravity(); this.move(MoverType.SELF, this.getDeltaMovement()); diff --git a/net/minecraft/world/level/NaturalSpawner.java b/net/minecraft/world/level/NaturalSpawner.java -index 911c5099a2bbb3e955c9314219114873642c7355..74d5ef7e0a63661f8b314846b8985c5f04cae87e 100644 +index 4e5078495037078922ab6350a500acdabe177ca5..05686d5b79412fdd2934fb16936f1f3b1c7d50c1 100644 --- a/net/minecraft/world/level/NaturalSpawner.java +++ b/net/minecraft/world/level/NaturalSpawner.java -@@ -84,7 +84,7 @@ public final class NaturalSpawner { +@@ -85,7 +85,7 @@ public final class NaturalSpawner { MobCategory category = entity.getType().getCategory(); if (category != MobCategory.MISC) { // Paper start - Only count natural spawns @@ -71,10 +71,10 @@ index 911c5099a2bbb3e955c9314219114873642c7355..74d5ef7e0a63661f8b314846b8985c5f entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN)) { continue; diff --git a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -index 03c9a2d253ba6fec39a0322eb74ac611fdc8b7f0..7ffcc21a6c4d679e860e845492429af838491444 100644 +index 17096a9ba33ecaddb50bfe2bccb505d0f0110e7e..86e4cf0631e809615c8d975c0f411be5897ce76f 100644 --- a/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BeehiveBlockEntity.java -@@ -344,7 +344,7 @@ public class BeehiveBlockEntity extends BlockEntity { +@@ -345,7 +345,7 @@ public class BeehiveBlockEntity extends BlockEntity { // Leaves end - pca } // Paper start - Fix bees aging inside; use exitTickCounter to keep actual bee life @@ -84,7 +84,7 @@ index 03c9a2d253ba6fec39a0322eb74ac611fdc8b7f0..7ffcc21a6c4d679e860e845492429af8 } // Paper end - Fix bees aging inside; use exitTickCounter to keep actual bee life diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index ab88bca97fe275528a2feb22e5da89252be683c3..ca5707060e415a32fdb50509c24e79494d3ad28f 100644 +index 59a92e77244f45a58f61919519fc57f6c0bed8ee..cb6a11673d19266925c87b0254a7f66d8e4fb7ca 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -276,7 +276,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen diff --git a/leaves-server/minecraft-patches/features/0034-Item-overstack-util.patch b/leaves-server/minecraft-patches/features/0033-Item-overstack-util.patch similarity index 81% rename from leaves-server/minecraft-patches/features/0034-Item-overstack-util.patch rename to leaves-server/minecraft-patches/features/0033-Item-overstack-util.patch index 1625fe649..2fb8a5831 100644 --- a/leaves-server/minecraft-patches/features/0034-Item-overstack-util.patch +++ b/leaves-server/minecraft-patches/features/0033-Item-overstack-util.patch @@ -3,10 +3,10 @@ From: violetc <58360096+s-yh-china@users.noreply.github.com> Date: Wed, 14 Dec 2022 14:47:06 +0800 Subject: [PATCH] Item overstack util -This patch is Powered by fabric-carpet(https://github.com/gnembon/fabric-carpet) and plusls-carpet-addition(https://github.com/plusls/plusls-carpet-addition) +Part of this patch is Powered by fabric-carpet(https://github.com/gnembon/fabric-carpet) and plusls-carpet-addition(https://github.com/plusls/plusls-carpet-addition) 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 { @@ -26,23 +26,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 4f56cdcf658234b1ca92d38c3df3d31e9be34a15..f6e18d62db18616a422ae74d6f329d1b3a96300b 100644 +index 0fc63717af24ca37497db8ea5a2395548d9d8491..21c85da896e0896eb0f8a7a6a5570ece368168a2 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 ef7d44ea1c1582bbf1d544819825778c414fe40d..a77a7b77c27a0d1257f4eaa071b1c5934aff0f47 100644 +index e158d614abed8d16e80192c0c9abd8537c92b9dc..41642a09940b7805dcd456b52f26922692eee4c4 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2998,7 +2998,7 @@ public class ServerGamePacketListenerImpl +@@ -3070,7 +3070,7 @@ public class ServerGamePacketListenerImpl } else if (slot.mayPlace(cursor)) { if (ItemStack.isSameItemSameComponents(clickedItem, cursor)) { int toPlace = packet.buttonNum() == 0 ? cursor.getCount() : 1; @@ -51,7 +51,7 @@ index ef7d44ea1c1582bbf1d544819825778c414fe40d..a77a7b77c27a0d1257f4eaa071b1c593 toPlace = Math.min(toPlace, slot.container.getMaxStackSize() - clickedItem.getCount()); if (toPlace == 1) { action = InventoryAction.PLACE_ONE; -@@ -3034,7 +3034,7 @@ public class ServerGamePacketListenerImpl +@@ -3106,7 +3106,7 @@ public class ServerGamePacketListenerImpl } } else if (ItemStack.isSameItemSameComponents(cursor, clickedItem)) { if (clickedItem.getCount() >= 0) { @@ -60,7 +60,7 @@ index ef7d44ea1c1582bbf1d544819825778c414fe40d..a77a7b77c27a0d1257f4eaa071b1c593 // As of 1.5, this is result slots only action = InventoryAction.PICKUP_ALL; } -@@ -3251,6 +3251,7 @@ public class ServerGamePacketListenerImpl +@@ -3323,6 +3323,7 @@ public class ServerGamePacketListenerImpl this.player.containerMenu.broadcastFullState(); } else { this.player.containerMenu.broadcastChanges(); @@ -68,7 +68,7 @@ index ef7d44ea1c1582bbf1d544819825778c414fe40d..a77a7b77c27a0d1257f4eaa071b1c593 } 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. -@@ -3362,7 +3363,7 @@ public class ServerGamePacketListenerImpl +@@ -3434,7 +3435,7 @@ public class ServerGamePacketListenerImpl } boolean flag1 = packet.slotNum() >= 1 && packet.slotNum() <= 45; @@ -77,7 +77,7 @@ index ef7d44ea1c1582bbf1d544819825778c414fe40d..a77a7b77c27a0d1257f4eaa071b1c593 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(); -@@ -3404,6 +3405,7 @@ public class ServerGamePacketListenerImpl +@@ -3476,6 +3477,7 @@ public class ServerGamePacketListenerImpl this.player.inventoryMenu.getSlot(packet.slotNum()).setByPlayer(itemStack); this.player.inventoryMenu.setRemoteSlot(packet.slotNum(), itemStack); this.player.inventoryMenu.broadcastChanges(); @@ -86,10 +86,10 @@ index ef7d44ea1c1582bbf1d544819825778c414fe40d..a77a7b77c27a0d1257f4eaa071b1c593 } else if (flag && flag2) { if (this.dropSpamThrottler.isUnderThreshold()) { diff --git a/net/minecraft/world/Container.java b/net/minecraft/world/Container.java -index 8e6f097b4d17aaaf8eccc16e11ce2bd01ad63322..5493576c54e87823f68bbf8a18441b373aae0461 100644 +index 6489b47810b0431c350098d574469bbe0adcd726..61646fe4b3476017a175a5d30fde53f13538ad9e 100644 --- a/net/minecraft/world/Container.java +++ b/net/minecraft/world/Container.java -@@ -34,6 +34,12 @@ public interface Container extends Clearable, Iterable { +@@ -37,6 +37,12 @@ public interface Container extends Clearable, SlotProvider, Iterable return Math.min(this.getMaxStackSize(), stack.getMaxStackSize()); } @@ -103,10 +103,10 @@ index 8e6f097b4d17aaaf8eccc16e11ce2bd01ad63322..5493576c54e87823f68bbf8a18441b37 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); @@ -115,7 +115,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) { @@ -125,10 +125,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 6be576368695c902a0d6da74b1d77d3018b4585a..e198e4c1ee267c6738117959e71cf4018bf6ef1d 100644 +index e82bb8f2d2b0e771dc371fd7e709116e1f5f204f..6d522eac417e6d0e21626f412ba5e90d241f0406 100644 --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -270,10 +270,15 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -267,10 +267,15 @@ public class ItemEntity extends Entity implements TraceableEntity { private boolean isMergable() { ItemStack item = this.getItem(); @@ -145,6 +145,29 @@ index 6be576368695c902a0d6da74b1d77d3018b4585a..e198e4c1ee267c6738117959e71cf401 ItemStack item = this.getItem(); ItemStack item1 = itemEntity.getItem(); if (Objects.equals(this.target, itemEntity.target) && areMergable(item, item1)) { +diff --git a/net/minecraft/world/entity/npc/InventoryCarrier.java b/net/minecraft/world/entity/npc/InventoryCarrier.java +index 585644a1339b477cb38fec7e06848e1a45c1516b..3d7e05bcc7e0c8c108f81a12a7f77b5d3a0b1d40 100644 +--- a/net/minecraft/world/entity/npc/InventoryCarrier.java ++++ b/net/minecraft/world/entity/npc/InventoryCarrier.java +@@ -31,7 +31,17 @@ public interface InventoryCarrier { + + mob.onItemPickup(itemEntity); + int count = item.getCount(); +- ItemStack itemStack = inventory.addItem(item); ++ // Leaves start - item over-stack util ++ int restoreCount = 0; ++ if (org.leavesmc.leaves.util.ItemOverstackUtils.isStackable(item)) { ++ int vanillaMax = item.getMaxStackSize(); ++ restoreCount = Math.max(0, count - vanillaMax); ++ item.setCount(count - restoreCount); ++ } ++ ItemStack itemStack = item.copy(); ++ itemStack.setCount(inventory.addItem(item).getCount()); ++ itemStack.setCount(itemStack.getCount() + restoreCount); ++ // Leaves end - item over-stack util + mob.take(itemEntity, count - itemStack.getCount()); + if (itemStack.isEmpty()) { + itemEntity.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause diff --git a/net/minecraft/world/entity/player/Inventory.java b/net/minecraft/world/entity/player/Inventory.java index 41e59f3739945ca7f6ab710c993b5c0f15fcd529..b849b04f227b43d036f4f6b3ae7accfafc389d9f 100644 --- a/net/minecraft/world/entity/player/Inventory.java @@ -201,10 +224,10 @@ index 41e59f3739945ca7f6ab710c993b5c0f15fcd529..b849b04f227b43d036f4f6b3ae7accfa 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) { @@ -214,10 +237,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 6e756ed4a811d9fe7d78d7dc89b3b5a735e0e857..358de981544b220bde770410c24e5f6b10520d91 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); @@ -225,12 +248,12 @@ index 6e756ed4a811d9fe7d78d7dc89b3b5a735e0e857..358de981544b220bde770410c24e5f6b + stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - item over-stack util } - default SlotAccess getChestVehicleSlot(final int slot) { + default @Nullable SlotAccess getChestVehicleSlot(final int slot) { diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java -index 4e53e7c05af11cae2ce8cf313c69a83336e22ba6..e78baa9433b6f5cb32142fe583fe95831b173d5a 100644 +index b5837ee5e291ae23bd8613c4c1856c14dd9e152b..38af11add6b97a34c406e86278008c2652c241a1 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(); } @@ -244,7 +267,7 @@ index 4e53e7c05af11cae2ce8cf313c69a83336e22ba6..e78baa9433b6f5cb32142fe583fe9583 private void updateDataSlotListeners(int slotIndex, int value) { for (ContainerListener containerListener : this.containerListeners) { containerListener.dataChanged(this, slotIndex, value); -@@ -452,7 +459,7 @@ public abstract class AbstractContainerMenu { +@@ -449,7 +456,7 @@ public abstract class AbstractContainerMenu { && (this.quickcraftType == 2 || carried1.getCount() >= this.quickcraftSlots.size()) && this.canDragTo(slot1)) { int i2 = slot1.hasItem() ? slot1.getItem().getCount() : 0; @@ -253,7 +276,7 @@ index 4e53e7c05af11cae2ce8cf313c69a83336e22ba6..e78baa9433b6f5cb32142fe583fe9583 int min1 = Math.min(getQuickCraftPlaceCount(this.quickcraftSlots, this.quickcraftType, itemStack) + i2, min); count -= min1 - i2; // slot1.setByPlayer(itemStack.copyWithCount(min1)); -@@ -564,7 +571,7 @@ public abstract class AbstractContainerMenu { +@@ -557,7 +564,7 @@ public abstract class AbstractContainerMenu { slot.setByPlayer(carried2); } } else if (ItemStack.isSameItemSameComponents(carried, carried2)) { @@ -262,7 +285,7 @@ index 4e53e7c05af11cae2ce8cf313c69a83336e22ba6..e78baa9433b6f5cb32142fe583fe9583 optional1.ifPresent(itemStack2 -> { carried2.grow(itemStack2.getCount()); slot.onTake(player, itemStack2); -@@ -626,7 +633,7 @@ public abstract class AbstractContainerMenu { +@@ -619,7 +626,7 @@ public abstract class AbstractContainerMenu { Slot slot2 = this.slots.get(slotIndex); if (slot2.hasItem()) { ItemStack itemStack = slot2.getItem(); @@ -271,7 +294,7 @@ index 4e53e7c05af11cae2ce8cf313c69a83336e22ba6..e78baa9433b6f5cb32142fe583fe9583 } } else if (clickType == ClickType.THROW && this.getCarried().isEmpty() && slotIndex >= 0) { Slot slot2 = this.slots.get(slotIndex); -@@ -657,15 +664,15 @@ public abstract class AbstractContainerMenu { +@@ -654,15 +661,15 @@ public abstract class AbstractContainerMenu { int maxStackSize = button == 0 ? 1 : -1; for (int i3 = 0; i3 < 2; i3++) { @@ -290,7 +313,7 @@ index 4e53e7c05af11cae2ce8cf313c69a83336e22ba6..e78baa9433b6f5cb32142fe583fe9583 itemStack.grow(itemStack1.getCount()); } } -@@ -783,7 +790,7 @@ public abstract class AbstractContainerMenu { +@@ -780,7 +787,7 @@ public abstract class AbstractContainerMenu { i = endIndex - 1; } @@ -299,7 +322,7 @@ index 4e53e7c05af11cae2ce8cf313c69a83336e22ba6..e78baa9433b6f5cb32142fe583fe9583 while (!stack.isEmpty() && (reverseDirection ? i >= startIndex : i < endIndex)) { Slot slot = this.slots.get(i); ItemStack item = slot.getItem(); -@@ -884,7 +891,7 @@ public abstract class AbstractContainerMenu { +@@ -881,7 +888,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()) @@ -308,7 +331,7 @@ index 4e53e7c05af11cae2ce8cf313c69a83336e22ba6..e78baa9433b6f5cb32142fe583fe9583 : flag; } -@@ -892,7 +899,7 @@ public abstract class AbstractContainerMenu { +@@ -889,7 +896,7 @@ public abstract class AbstractContainerMenu { return switch (type) { case 0 -> Mth.floor((float)stack.getCount() / slots.size()); case 1 -> 1; @@ -317,7 +340,7 @@ index 4e53e7c05af11cae2ce8cf313c69a83336e22ba6..e78baa9433b6f5cb32142fe583fe9583 default -> stack.getCount(); }; } -@@ -914,7 +921,7 @@ public abstract class AbstractContainerMenu { +@@ -911,7 +918,7 @@ public abstract class AbstractContainerMenu { for (int i = 0; i < container.getContainerSize(); i++) { ItemStack item = container.getItem(i); if (!item.isEmpty()) { @@ -327,10 +350,10 @@ index 4e53e7c05af11cae2ce8cf313c69a83336e22ba6..e78baa9433b6f5cb32142fe583fe9583 } 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); @@ -340,7 +363,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 { @@ -351,21 +374,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 14c74eb71b5bfb67d0fcf9d660f748c7b1dba63d..695f377155018d2b919086f0c29bdfb0abe1a2b2 100644 +index 3a719a98118c275422f4fc61b07d471dd503656f..c59dec418f94b468f0465d0375809031f10bac39 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -164,7 +164,7 @@ public final class ItemStack implements DataComponentHolder { +@@ -170,7 +170,7 @@ public final class ItemStack implements DataComponentHolder { + private int popTime; @Deprecated - @Nullable - private Item item; + private @Nullable Item item; - PatchedDataComponentMap components; + public PatchedDataComponentMap components; // Leaves - item over-stack util - @Nullable - private Entity entityRepresentation; + private @Nullable Entity entityRepresentation; -@@ -191,7 +191,8 @@ public final class ItemStack implements DataComponentHolder { + public static DataResult validateStrict(ItemStack stack) { +@@ -196,7 +196,8 @@ public final class ItemStack implements DataComponentHolder { } else { Holder holder = Item.STREAM_CODEC.decode(buffer); DataComponentPatch dataComponentPatch = codec.decode(buffer); @@ -375,7 +398,7 @@ index 14c74eb71b5bfb67d0fcf9d660f748c7b1dba63d..695f377155018d2b919086f0c29bdfb0 } } -@@ -200,13 +201,15 @@ public final class ItemStack implements DataComponentHolder { +@@ -205,13 +206,15 @@ public final class ItemStack implements DataComponentHolder { if (value.isEmpty() || value.getItem() == null) { // CraftBukkit - NPE fix itemstack.getItem() buffer.writeVarInt(0); } else { @@ -395,7 +418,7 @@ index 14c74eb71b5bfb67d0fcf9d660f748c7b1dba63d..695f377155018d2b919086f0c29bdfb0 } finally { net.minecraft.network.chat.ComponentSerialization.DONT_RENDER_TRANSLATABLES.set(prev); } -@@ -300,7 +303,7 @@ public final class ItemStack implements DataComponentHolder { +@@ -305,7 +308,7 @@ public final class ItemStack implements DataComponentHolder { for (ItemStack itemStack : itemContainerContents.nonEmptyItems()) { int count = itemStack.getCount(); @@ -405,10 +428,10 @@ index 14c74eb71b5bfb67d0fcf9d660f748c7b1dba63d..695f377155018d2b919086f0c29bdfb0 return DataResult.error(() -> "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 a132883d85d515edb131049714915902444e4c3e..59cea0d226829267e9a5dff9f81789673bd3f062 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(); @@ -418,7 +441,7 @@ index a132883d85d515edb131049714915902444e4c3e..59cea0d226829267e9a5dff9f8178967 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 37bbd8d2cf412983fc4eb89737b3343f17364cae..8a93c4b9571b3088dc92317544d209603880d3fa 100644 +index 0503feadad8ff9ff0112199ccd65cdfd433a647e..5b6baeabc4b09ca59a7a9965692d9307a4d3f397 100644 --- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java @@ -410,7 +410,7 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit @@ -431,10 +454,10 @@ index 37bbd8d2cf412983fc4eb89737b3343f17364cae..8a93c4b9571b3088dc92317544d20960 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 1b2f8c4e1e362dc63fde2c7139039f0ce7eb762f..701a12db0c342c9ff2c974e581b112182dec2ea6 100644 +index edf3bc4adc9b1700b73f06ea940f17cd55b16860..b1be97f37398240ce564aba6c700319243be215c 100644 --- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -@@ -149,7 +149,7 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co +@@ -124,7 +124,7 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co @Override public void setItem(int slot, ItemStack stack) { this.getItems().set(slot, stack); @@ -444,7 +467,7 @@ index 1b2f8c4e1e362dc63fde2c7139039f0ce7eb762f..701a12db0c342c9ff2c974e581b11218 } diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index ca5707060e415a32fdb50509c24e79494d3ad28f..a1799e2646569bf9db4fcdd3a9758f486f96f56e 100644 +index cb6a11673d19266925c87b0254a7f66d8e4fb7ca..84e4733ab85808d3aa65d8573ea8a99096789d76 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -114,7 +114,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @@ -456,7 +479,36 @@ index ca5707060e415a32fdb50509c24e79494d3ad28f..a1799e2646569bf9db4fcdd3a9758f48 } @Override -@@ -693,9 +693,9 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -645,7 +645,18 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + // CraftBukkit end + } // Paper - Perf: Optimize Hoppers + ItemStack itemStack = item.getItem().copy(); +- ItemStack itemStack1 = addItem(null, container, itemStack, null); ++ // Leaves start - item over-stack util ++ int restoreCount = 0; ++ ItemStack itemStack1 = itemStack.copy(); ++ if (org.leavesmc.leaves.util.ItemOverstackUtils.isStackable(item.getItem())) { ++ // We need the hopper suck in the item with the vanilla max stack size each time ++ int vanillaMax = itemStack.getMaxStackSize(); ++ restoreCount = Math.max(0, itemStack.getCount() - vanillaMax); ++ itemStack.setCount(itemStack.getCount() - restoreCount); ++ } ++ itemStack1.setCount(addItem(null, container, itemStack, null).getCount()); ++ itemStack1.setCount(itemStack1.getCount() + restoreCount); ++ // Leaves end - item over-stack util + if (itemStack1.isEmpty()) { + flag = true; + item.setItem(ItemStack.EMPTY); +@@ -654,7 +665,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + item.setItem(itemStack1); + } + +- return flag; ++ return flag || (restoreCount != 0); // Leaves - item over-stack util + } + + public static ItemStack addItem(@Nullable Container source, Container destination, ItemStack stack, @Nullable Direction direction) { +@@ -693,9 +704,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/leaves-server/minecraft-patches/features/0035-Return-nether-portal-fix.patch b/leaves-server/minecraft-patches/features/0034-Return-nether-portal-fix.patch similarity index 84% rename from leaves-server/minecraft-patches/features/0035-Return-nether-portal-fix.patch rename to leaves-server/minecraft-patches/features/0034-Return-nether-portal-fix.patch index abe1b24ef..aefaae4fa 100644 --- a/leaves-server/minecraft-patches/features/0035-Return-nether-portal-fix.patch +++ b/leaves-server/minecraft-patches/features/0034-Return-nether-portal-fix.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Return nether portal fix This patch is powered by NetherPortalFix(https://github.com/TwelveIterationMods/NetherPortalFix) diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index d4df6ca7360d4bc605a51061444191d7929c7778..134f6eba6655b7294ebcdf5cf5d9e2183e2ecf5b 100644 +index e162ae0779ff613faf1def076fb2267408a9d414..a369af5337126fcaebafcb1d1643a6c18b252f00 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -1576,6 +1576,21 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -1574,6 +1574,21 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc org.bukkit.event.player.PlayerChangedWorldEvent changeEvent = new org.bukkit.event.player.PlayerChangedWorldEvent(this.getBukkitEntity(), serverLevel.getWorld()); this.level().getCraftServer().getPluginManager().callEvent(changeEvent); // CraftBukkit end @@ -32,10 +32,10 @@ index d4df6ca7360d4bc605a51061444191d7929c7778..134f6eba6655b7294ebcdf5cf5d9e218 if (this.isBlocking()) { this.stopUsingItem(); diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 73f8562658d30ba17d5ecf2c778622e5e75ae135..cf3c9f2a19377f2d446f6220180f63557ef8a901 100644 +index ffc04a2e30b407df64bba4a887b14932c02c0caa..fce0114134eb1ffee558f6ce072e793eafbd6779 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -700,6 +700,20 @@ public abstract class PlayerList { +@@ -706,6 +706,20 @@ public abstract class PlayerList { // It's possible for respawn to be in a diff dimension if (fromLevel != level) { new org.bukkit.event.player.PlayerChangedWorldEvent(serverPlayer.getBukkitEntity(), fromLevel.getWorld()).callEvent(); @@ -57,26 +57,26 @@ index 73f8562658d30ba17d5ecf2c778622e5e75ae135..cf3c9f2a19377f2d446f6220180f6355 } diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index ce4c8e14d3d7b5837dcce006fa67722f3f430fa4..759c320fc331704efe5df10d3f1f33aa87262290 100644 +index 6657cc6dd1fa32aafa65e79a2b2b439ffba889c6..8adf7835f71688ba319f053208d02b810097b06e 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -259,7 +259,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; + public BlockPos lastPos; // Leaves - private -> public private Optional lastClimbablePos = Optional.empty(); - @Nullable - private DamageSource lastDamageSource; + private @Nullable DamageSource lastDamageSource; + private long lastDamageStamp; diff --git a/net/minecraft/world/level/block/NetherPortalBlock.java b/net/minecraft/world/level/block/NetherPortalBlock.java -index d3f0a61c0c91d3a6a1dc4e59d57743ba89a9c19a..3d006562b2ba6f9a2059a8b534fbee3288067f78 100644 +index 653b72855197733b33e310b0ccd4fbf04e22e95f..2688d5b86a77e1552e6322e7b80a0217a441afd4 100644 --- a/net/minecraft/world/level/block/NetherPortalBlock.java +++ b/net/minecraft/world/level/block/NetherPortalBlock.java -@@ -179,7 +179,18 @@ public class NetherPortalBlock extends Block implements Portal { - - @Nullable - private TeleportTransition getExitPortal(ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, WorldBorder worldBorder, org.bukkit.craftbukkit.event.PortalEventResult result) { // CraftBukkit +@@ -176,7 +176,18 @@ public class NetherPortalBlock extends Block implements Portal { + private @Nullable TeleportTransition getExitPortal( + ServerLevel level, Entity entity, BlockPos pos, BlockPos exitPos, WorldBorder worldBorder, org.bukkit.craftbukkit.event.PortalEventResult result // CraftBukkit + ) { - Optional optional = level.getPortalForcer().findClosestPortalPosition(exitPos, worldBorder, result.searchRadius()); // CraftBukkit + // Leaves start - fix return portal + Optional optional = Optional.empty(); diff --git a/leaves-server/minecraft-patches/features/0036-Leaves-Extra-Yggdrasil-Service.patch b/leaves-server/minecraft-patches/features/0035-Leaves-Extra-Yggdrasil-Service.patch similarity index 88% rename from leaves-server/minecraft-patches/features/0036-Leaves-Extra-Yggdrasil-Service.patch rename to leaves-server/minecraft-patches/features/0035-Leaves-Extra-Yggdrasil-Service.patch index 83a462331..d8c9f7167 100644 --- a/leaves-server/minecraft-patches/features/0036-Leaves-Extra-Yggdrasil-Service.patch +++ b/leaves-server/minecraft-patches/features/0035-Leaves-Extra-Yggdrasil-Service.patch @@ -18,10 +18,10 @@ index 9e5757391ea32e37b2aac52cc1bb38259a2cc497..b85593aea7a347a5c2c50464d2146f96 private final String baseUrl; private final URL joinUrl; diff --git a/net/minecraft/server/Main.java b/net/minecraft/server/Main.java -index 8d299a75c80fddc61a2aa4dc5b0dc5948aef5a0d..30b681bc234eac8dc44ce3bf6e228171f5a71a7a 100644 +index 094d2d528cb74b8f1d277cd780bba7f438dbe764..b946df218837f424c5f6fcdc43f6fa106aae4edf 100644 --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -176,7 +176,7 @@ public class Main { +@@ -174,7 +174,7 @@ public class Main { file = new File(bukkitConfiguration.getString("settings.world-container", ".")); } // Paper end - fix SPIGOT-5824 @@ -31,15 +31,15 @@ index 8d299a75c80fddc61a2aa4dc5b0dc5948aef5a0d..30b681bc234eac8dc44ce3bf6e228171 String string = Optional.ofNullable((String) optionSet.valueOf("world")).orElse(dedicatedServerSettings.getProperties().levelName); LevelStorageSource levelStorageSource = LevelStorageSource.createDefault(file.toPath()); diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 5ad76e6483b589d6695ad086755cc9dc0edd9235..c3c93caab5981d509dd5471419f3d79cdd045f1d 100644 +index db16841b42ff4b3e2ac8df6c15561367b35d977a..cb7b19fe33acf7ad0f287cdf7f5fe1882d993306 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -242,7 +242,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop public private final NotificationManager notificationManager; + private final ServerActivityMonitor serverActivityMonitor; private long lastServerStatus; - public final Thread serverThread; diff --git a/leaves-server/minecraft-patches/features/0037-Configurable-vanilla-random.patch b/leaves-server/minecraft-patches/features/0036-Configurable-vanilla-random.patch similarity index 78% rename from leaves-server/minecraft-patches/features/0037-Configurable-vanilla-random.patch rename to leaves-server/minecraft-patches/features/0036-Configurable-vanilla-random.patch index f5a05e14c..0b3c3d639 100644 --- a/leaves-server/minecraft-patches/features/0037-Configurable-vanilla-random.patch +++ b/leaves-server/minecraft-patches/features/0036-Configurable-vanilla-random.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Configurable vanilla random diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index c6815ffef7fb2fd2e5ef2769c2c93135b52558f5..f6dd8e81f6881400c3278ea53e2ed248625744e1 100644 +index 47851ec2ee99aa7f42fa1baee0fab36dee3f6e7b..044d8a7175abe573ff08b4c6a0be3a0c19efd5a6 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -282,7 +282,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -283,7 +283,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name public double yOld; public double zOld; public boolean noPhysics; @@ -17,11 +17,11 @@ index c6815ffef7fb2fd2e5ef2769c2c93135b52558f5..f6dd8e81f6881400c3278ea53e2ed248 public int tickCount; private int remainingFireTicks; public boolean wasTouchingWater; -diff --git a/net/minecraft/world/entity/animal/Bee.java b/net/minecraft/world/entity/animal/Bee.java -index e94c6c1ee969a7d0953b933fb0633cebb510a68c..97fbdb90db218c6f2f81487cc30430d7c90afa8e 100644 ---- a/net/minecraft/world/entity/animal/Bee.java -+++ b/net/minecraft/world/entity/animal/Bee.java -@@ -808,7 +808,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { +diff --git a/net/minecraft/world/entity/animal/bee/Bee.java b/net/minecraft/world/entity/animal/bee/Bee.java +index 0cbcf23b6edba2305dfbbc95abb06a90a6edd42b..46d72345de78053d0da689c7ae83d8cb1c2cdd4f 100644 +--- a/net/minecraft/world/entity/animal/bee/Bee.java ++++ b/net/minecraft/world/entity/animal/bee/Bee.java +@@ -801,7 +801,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { @VisibleForDebug public class BeeGoToHiveGoal extends Bee.BaseBeeGoal { public static final int MAX_TRAVELLING_TICKS = 2400; @@ -29,8 +29,8 @@ index e94c6c1ee969a7d0953b933fb0633cebb510a68c..97fbdb90db218c6f2f81487cc30430d7 + int travellingTicks; // TODO: int travellingTicks = org.leavesmc.leaves.LeavesConfig.modify.useVanillaRandom ? Bee.this.level().random.nextInt(10) : Bee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues // Leaves - why no vanilla private static final int MAX_BLACKLISTED_TARGETS = 3; final List blacklistedTargets = Lists.newArrayList(); - @Nullable -@@ -924,7 +924,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { + private @Nullable Path lastPath; +@@ -916,7 +916,7 @@ public class Bee extends Animal implements NeutralMob, FlyingAnimal { public class BeeGoToKnownFlowerGoal extends Bee.BaseBeeGoal { private static final int MAX_TRAVELLING_TICKS = 2400; @@ -39,11 +39,11 @@ index e94c6c1ee969a7d0953b933fb0633cebb510a68c..97fbdb90db218c6f2f81487cc30430d7 BeeGoToKnownFlowerGoal() { this.setFlags(EnumSet.of(Goal.Flag.MOVE)); -diff --git a/net/minecraft/world/entity/animal/Squid.java b/net/minecraft/world/entity/animal/Squid.java -index 8313ea146ba6910d92653c29887c94b75f68cce4..9b8775a9069db99605ac5367804923d537320d68 100644 ---- a/net/minecraft/world/entity/animal/Squid.java -+++ b/net/minecraft/world/entity/animal/Squid.java -@@ -47,7 +47,7 @@ public class Squid extends AgeableWaterCreature { +diff --git a/net/minecraft/world/entity/animal/squid/Squid.java b/net/minecraft/world/entity/animal/squid/Squid.java +index 0e13879ce2802ff8ef0ee9b745a23396727c3e30..cd16be399d70ef5782806798a695a56beed29f2c 100644 +--- a/net/minecraft/world/entity/animal/squid/Squid.java ++++ b/net/minecraft/world/entity/animal/squid/Squid.java +@@ -48,7 +48,7 @@ public class Squid extends AgeableWaterCreature { public Squid(EntityType type, Level level) { super(type, level); @@ -53,10 +53,10 @@ index 8313ea146ba6910d92653c29887c94b75f68cce4..9b8775a9069db99605ac5367804923d5 } diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java -index e198e4c1ee267c6738117959e71cf4018bf6ef1d..671ae6195c86b44dfb2df4414a35287e3acd954f 100644 +index 6d522eac417e6d0e21626f412ba5e90d241f0406..41050491bde33981448b3da0290f8edfaee82c30 100644 --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -66,7 +66,13 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -64,7 +64,13 @@ public class ItemEntity extends Entity implements TraceableEntity { // Paper start - Don't use level random in entity constructors (to make them thread-safe) this(EntityType.ITEM, level); this.setPos(posX, posY, posZ); @@ -72,10 +72,10 @@ index e198e4c1ee267c6738117959e71cf4018bf6ef1d..671ae6195c86b44dfb2df4414a35287e // Paper end - Don't use level random in entity constructors } diff --git a/net/minecraft/world/entity/item/PrimedTnt.java b/net/minecraft/world/entity/item/PrimedTnt.java -index d36ce16724e9f5a79960f0aa265a0354f5240abc..8230b42919bd8888acf656c5846601bead39598f 100644 +index 9ceec84368cc24bc43b90a82150c9abf7db758e1..97d106e19095a501bf9e9176bfb6acc77f0a63d9 100644 --- a/net/minecraft/world/entity/item/PrimedTnt.java +++ b/net/minecraft/world/entity/item/PrimedTnt.java -@@ -68,7 +68,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { +@@ -67,7 +67,7 @@ public class PrimedTnt extends Entity implements TraceableEntity { public PrimedTnt(Level level, double x, double y, double z, @Nullable LivingEntity owner) { this(EntityType.TNT, level); this.setPos(x, y, z); diff --git a/leaves-server/minecraft-patches/features/0038-Catch-update-suppression-crash.patch b/leaves-server/minecraft-patches/features/0037-Catch-update-suppression-crash.patch similarity index 89% rename from leaves-server/minecraft-patches/features/0038-Catch-update-suppression-crash.patch rename to leaves-server/minecraft-patches/features/0037-Catch-update-suppression-crash.patch index 243980f4f..821b014ea 100644 --- a/leaves-server/minecraft-patches/features/0038-Catch-update-suppression-crash.patch +++ b/leaves-server/minecraft-patches/features/0037-Catch-update-suppression-crash.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Catch update suppression crash diff --git a/net/minecraft/network/PacketProcessor.java b/net/minecraft/network/PacketProcessor.java -index 3e4241976fdfe65bc0aae90a9097770745c0ddf1..8e3e9a8aaee8fd4fbe986f9f079945179017c4f3 100644 +index d501168e40f951ee37efcbc464c3ab1307051060..8bf21ede4d7d7c1b05acd05b4b3d3dfcb36b2fb6 100644 --- a/net/minecraft/network/PacketProcessor.java +++ b/net/minecraft/network/PacketProcessor.java @@ -97,7 +97,20 @@ public class PacketProcessor implements AutoCloseable { @@ -30,10 +30,10 @@ index 3e4241976fdfe65bc0aae90a9097770745c0ddf1..8e3e9a8aaee8fd4fbe986f9f07994517 throw PacketUtils.makeReportedException(var3, this.packet, this.listener); } diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 2c9451bb024a6d185729e9b1fad508883401e468..cef816d3526cec1b7cb5b03e62454609eec876bb 100644 +index b148841f83e33646dc2bf56218a1c25f5407f695..9ff3d51bf0af60d6ea9ca658cc1f0c988cf91a6c 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1809,7 +1809,16 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop implements ca.spottedleaf.moonrise.patch @@ -154,10 +154,10 @@ index 040919c61ed29b3eda73b5d0f8ed905011e969a4..9cedf0f7433d33f303463906d59c3238 } diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index bdc564c24982c196f151121fb769c7cfad4a08b0..7c5f827134e0fa81031660a78d4d404c21840cb6 100644 +index e7fa4e132e88b24789ed30eb3248994f21ffd6bd..670459abcc6f32bdc6d4742f6710585fda83ac83 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -380,7 +380,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot +@@ -378,7 +378,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot if (blockState == state) { return null; } else { @@ -166,7 +166,7 @@ index bdc564c24982c196f151121fb769c7cfad4a08b0..7c5f827134e0fa81031660a78d4d404c 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); -@@ -454,6 +454,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot +@@ -452,6 +452,7 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot this.markUnsaved(); return blockState; } @@ -175,7 +175,7 @@ index bdc564c24982c196f151121fb769c7cfad4a08b0..7c5f827134e0fa81031660a78d4d404c } } diff --git a/net/minecraft/world/level/redstone/NeighborUpdater.java b/net/minecraft/world/level/redstone/NeighborUpdater.java -index f45cf0136e77ed5a903d033a7b0611e5edc23db9..77ed7a6a4bea3dfc77d060c49f77f4e080da200b 100644 +index 87512434ccd8d46d8db718228c790465c64b2c20..b867a58eb2c954c49f80acfda7575114dfccecd4 100644 --- a/net/minecraft/world/level/redstone/NeighborUpdater.java +++ b/net/minecraft/world/level/redstone/NeighborUpdater.java @@ -60,9 +60,22 @@ public interface NeighborUpdater { diff --git a/leaves-server/minecraft-patches/features/0039-Bedrock-break-list.patch b/leaves-server/minecraft-patches/features/0038-Bedrock-break-list.patch similarity index 87% rename from leaves-server/minecraft-patches/features/0039-Bedrock-break-list.patch rename to leaves-server/minecraft-patches/features/0038-Bedrock-break-list.patch index 89a183613..ac6b3aec7 100644 --- a/leaves-server/minecraft-patches/features/0039-Bedrock-break-list.patch +++ b/leaves-server/minecraft-patches/features/0038-Bedrock-break-list.patch @@ -5,22 +5,22 @@ Subject: [PATCH] Bedrock break list diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index cef816d3526cec1b7cb5b03e62454609eec876bb..d9d661f72c90d04a3fca0d5698cc38a004717581 100644 +index 9ff3d51bf0af60d6ea9ca658cc1f0c988cf91a6c..5a46df87c6af968c583bbfc2bdf365ad7779d90d 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1844,6 +1844,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0.512F) { + // Leaves start - noFeatherFallingTrample + if (org.leavesmc.leaves.LeavesConfig.modify.noFeatherFallingTrample) { diff --git a/leaves-server/minecraft-patches/features/0043-Disable-packet-limit.patch b/leaves-server/minecraft-patches/features/0042-Disable-packet-limit.patch similarity index 78% rename from leaves-server/minecraft-patches/features/0043-Disable-packet-limit.patch rename to leaves-server/minecraft-patches/features/0042-Disable-packet-limit.patch index 44adf94d1..cfb51e250 100644 --- a/leaves-server/minecraft-patches/features/0043-Disable-packet-limit.patch +++ b/leaves-server/minecraft-patches/features/0042-Disable-packet-limit.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Disable packet limit diff --git a/net/minecraft/network/Connection.java b/net/minecraft/network/Connection.java -index b186b5e0d3b32d7b51b2f58f0ef4b2bf36ae5c13..c6fa04cc5e0352fef675baff93300b7e33fdfca5 100644 +index ab6255937577008689c25ba1474ecc2c961079da..e83f69bcd8057a42123e21da60d6301c2a41e0b3 100644 --- a/net/minecraft/network/Connection.java +++ b/net/minecraft/network/Connection.java -@@ -245,8 +245,8 @@ public class Connection extends SimpleChannelInboundHandler> { +@@ -221,8 +221,8 @@ public class Connection extends SimpleChannelInboundHandler> { if (this.stopReadingPackets) { return; } @@ -20,10 +20,10 @@ index b186b5e0d3b32d7b51b2f58f0ef4b2bf36ae5c13..c6fa04cc5e0352fef675baff93300b7e synchronized (PACKET_LIMIT_LOCK) { if (this.allPacketCounts != null) { diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 28fe3e0c8bb743237ddf324f633e986fb91bb405..55374283f8cb1e7f3485eae7dc1da2db3cc98a0c 100644 +index d0613418faa02508a728d98fd0b85e9640c493fc..b734e22651d338f5234c901d7c2f07643068f51c 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -828,7 +828,7 @@ public class ServerGamePacketListenerImpl +@@ -832,7 +832,7 @@ public class ServerGamePacketListenerImpl public void handleCustomCommandSuggestions(ServerboundCommandSuggestionPacket packet) { // PacketUtils.ensureRunningOnSameThread(packet, this, this.player.level()); // Paper - AsyncTabCompleteEvent; run this async // CraftBukkit start @@ -32,23 +32,23 @@ index 28fe3e0c8bb743237ddf324f633e986fb91bb405..55374283f8cb1e7f3485eae7dc1da2db this.disconnectAsync(Component.translatable("disconnect.spam"), org.bukkit.event.player.PlayerKickEvent.Cause.SPAM); // Paper - Kick event cause // Paper - add proper async disconnect return; } -@@ -2010,6 +2010,7 @@ public class ServerGamePacketListenerImpl - private static int getSpamThreshold() { return io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.incomingPacketThreshold; } // Paper - Configurable threshold +@@ -2043,6 +2043,7 @@ public class ServerGamePacketListenerImpl + private long lastLimitedPacket = -1; private boolean checkLimit(long timestamp) { -+ if (org.leavesmc.leaves.LeavesConfig.modify.disablePacketLimit) return true; // Leaves - disable - if (this.lastLimitedPacket != -1 && timestamp - this.lastLimitedPacket < getSpamThreshold() && this.limitedPackets++ >= 8) { // Paper - Configurable threshold; raise packet limit to 8 - return false; ++ if (org.leavesmc.leaves.LeavesConfig.modify.disablePacketLimit) return true; // Leaves - disable packet limit + if (!io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.incomingPacketThreshold.enabled()) { + return true; } -@@ -2544,6 +2545,7 @@ public class ServerGamePacketListenerImpl +@@ -2598,6 +2599,7 @@ public class ServerGamePacketListenerImpl // Spigot start - spam exclusions private void detectRateSpam(String message) { -+ if (org.leavesmc.leaves.LeavesConfig.modify.disablePacketLimit) return; // Leaves - disable ++ if (org.leavesmc.leaves.LeavesConfig.modify.disablePacketLimit) return; // Leaves - disable packet limit // CraftBukkit start - replaced with thread safe throttle if (org.spigotmc.SpigotConfig.enableSpamExclusions) { for (String exclude : org.spigotmc.SpigotConfig.spamExclusions) { -@@ -3263,7 +3265,7 @@ public class ServerGamePacketListenerImpl +@@ -3335,7 +3337,7 @@ public class ServerGamePacketListenerImpl @Override public void handlePlaceRecipe(ServerboundPlaceRecipePacket packet) { // Paper start - auto recipe limit diff --git a/leaves-server/minecraft-patches/features/0044-Syncmatica-Protocol.patch b/leaves-server/minecraft-patches/features/0043-Syncmatica-Protocol.patch similarity index 90% rename from leaves-server/minecraft-patches/features/0044-Syncmatica-Protocol.patch rename to leaves-server/minecraft-patches/features/0043-Syncmatica-Protocol.patch index 3ffa8ada4..9fe5614ff 100644 --- a/leaves-server/minecraft-patches/features/0044-Syncmatica-Protocol.patch +++ b/leaves-server/minecraft-patches/features/0043-Syncmatica-Protocol.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Syncmatica Protocol This patch is Powered by Syncmatica(https://github.com/End-Tech/syncmatica) diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 55374283f8cb1e7f3485eae7dc1da2db3cc98a0c..ea9e98313c25e7ce94b011f5bc74a4318145c6f6 100644 +index 2617ef7f8011368294f90baa71107b5353151564..03e16b029329f6bf63500b585d74c1aec3702398 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -326,9 +326,12 @@ public class ServerGamePacketListenerImpl +@@ -331,9 +331,12 @@ public class ServerGamePacketListenerImpl this.signedMessageDecoder = SignedMessageChain.Decoder.unsigned(player.getUUID(), server::enforceSecureProfile); this.chatMessageChain = new FutureChain(server.chatExecutor); // CraftBukkit - async chat this.tickEndEvent = new io.papermc.paper.event.packet.ClientTickEndEvent(player.getBukkitEntity()); // Paper - add client tick end event diff --git a/leaves-server/minecraft-patches/features/0045-Shared-villager-discounts.patch b/leaves-server/minecraft-patches/features/0044-Shared-villager-discounts.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0045-Shared-villager-discounts.patch rename to leaves-server/minecraft-patches/features/0044-Shared-villager-discounts.patch diff --git a/leaves-server/minecraft-patches/features/0046-Redstone-ignore-upwards-update.patch b/leaves-server/minecraft-patches/features/0045-Redstone-ignore-upwards-update.patch similarity index 88% rename from leaves-server/minecraft-patches/features/0046-Redstone-ignore-upwards-update.patch rename to leaves-server/minecraft-patches/features/0045-Redstone-ignore-upwards-update.patch index 3d02f0f40..ef1a316c2 100644 --- a/leaves-server/minecraft-patches/features/0046-Redstone-ignore-upwards-update.patch +++ b/leaves-server/minecraft-patches/features/0045-Redstone-ignore-upwards-update.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Redstone ignore upwards update diff --git a/net/minecraft/world/level/block/ComparatorBlock.java b/net/minecraft/world/level/block/ComparatorBlock.java -index afecf6bb6152b4d9dfee4cd8c5b1d798cbf723b3..0e51c10987a7b1964d1be3b2942c28aa6b0eb8d9 100644 +index 578e7c8dc601f53cf2a068685c6901bfaf47e763..25c435923233ce5073710028d9e87dad374cd7e0 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 { @@ -17,10 +17,10 @@ index afecf6bb6152b4d9dfee4cd8c5b1d798cbf723b3..0e51c10987a7b1964d1be3b2942c28aa ? 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 1943a6aad888647953e2d9dbbeedb0bd81c6f9df..35dc47d5ba1a2659304ccc08010611438ccf04d8 100644 +index 6d98bc37d88459d1e0a171b52bbff5810d775c38..fe5a571e2ef6e505ba2ea8ccebd2f7b34395fd81 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) { @@ -29,7 +29,7 @@ index 1943a6aad888647953e2d9dbbeedb0bd81c6f9df..35dc47d5ba1a2659304ccc0801061143 } else if (direction == Direction.UP) { return this.getConnectionState(level, state, pos); } else { -@@ -238,7 +238,7 @@ public class RedStoneWireBlock extends Block { +@@ -237,7 +237,7 @@ public class RedStoneWireBlock extends Block { BlockPos blockPos = pos.relative(direction); BlockState blockState = level.getBlockState(blockPos); if (nonNormalCubeAbove) { @@ -39,7 +39,7 @@ index 1943a6aad888647953e2d9dbbeedb0bd81c6f9df..35dc47d5ba1a2659304ccc0801061143 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..13c1974dd368579f5c3d11b87e1c3eff02d69ac7 100644 +index 87e1a32376adc5a15f035b62bc1f672c507cd230..b519c39ea2078a11adb7cc1fe4252c5678e66882 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/leaves-server/minecraft-patches/features/0047-Disable-check-out-of-order-command.patch b/leaves-server/minecraft-patches/features/0046-Disable-check-out-of-order-command.patch similarity index 90% rename from leaves-server/minecraft-patches/features/0047-Disable-check-out-of-order-command.patch rename to leaves-server/minecraft-patches/features/0046-Disable-check-out-of-order-command.patch index 7560d4dff..1f8dc994c 100644 --- a/leaves-server/minecraft-patches/features/0047-Disable-check-out-of-order-command.patch +++ b/leaves-server/minecraft-patches/features/0046-Disable-check-out-of-order-command.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Disable check out-of-order command diff --git a/net/minecraft/network/chat/SignedMessageChain.java b/net/minecraft/network/chat/SignedMessageChain.java -index f6eed34b2fd72ab74cc9dc4b99ca184d512c0a66..a0c6b998bdf0477f524aa70e353f51e4fa37883c 100644 +index 67b2f87f8424c5642010b3d9852b55c40d4947e1..a5a6f9dba5e524809da9e70085cb1a4b8dc97ca2 100644 --- a/net/minecraft/network/chat/SignedMessageChain.java +++ b/net/minecraft/network/chat/SignedMessageChain.java -@@ -45,7 +45,7 @@ public class SignedMessageChain { +@@ -44,7 +44,7 @@ public class SignedMessageChain { SignedMessageLink signedMessageLink = SignedMessageChain.this.nextLink; if (signedMessageLink == null) { throw new SignedMessageChain.DecodeException(SignedMessageChain.DecodeException.CHAIN_BROKEN); diff --git a/leaves-server/minecraft-patches/features/0048-Despawn-enderman-with-block.patch b/leaves-server/minecraft-patches/features/0047-Despawn-enderman-with-block.patch similarity index 84% rename from leaves-server/minecraft-patches/features/0048-Despawn-enderman-with-block.patch rename to leaves-server/minecraft-patches/features/0047-Despawn-enderman-with-block.patch index 4c862c677..0f873bc45 100644 --- a/leaves-server/minecraft-patches/features/0048-Despawn-enderman-with-block.patch +++ b/leaves-server/minecraft-patches/features/0047-Despawn-enderman-with-block.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Despawn enderman with block diff --git a/net/minecraft/world/entity/monster/EnderMan.java b/net/minecraft/world/entity/monster/EnderMan.java -index 0732709d0ca78f59ad6b7f8ac5e7bfbe5506f60b..b314fb8819388facf664060fc0d1a091543aac68 100644 +index 916a15dda74c1a68bdcb4c890ec56e4a60befb9f..0c251d07e206a687a8d7d34a06075747e3a4fc65 100644 --- a/net/minecraft/world/entity/monster/EnderMan.java +++ b/net/minecraft/world/entity/monster/EnderMan.java -@@ -454,7 +454,7 @@ public class EnderMan extends Monster implements NeutralMob { +@@ -451,7 +451,7 @@ public class EnderMan extends Monster implements NeutralMob { @Override public boolean requiresCustomPersistence() { diff --git a/leaves-server/minecraft-patches/features/0049-Optimized-dragon-respawn.patch b/leaves-server/minecraft-patches/features/0048-Optimized-dragon-respawn.patch similarity index 86% rename from leaves-server/minecraft-patches/features/0049-Optimized-dragon-respawn.patch rename to leaves-server/minecraft-patches/features/0048-Optimized-dragon-respawn.patch index a1dfb6e06..bcc191a14 100644 --- a/leaves-server/minecraft-patches/features/0049-Optimized-dragon-respawn.patch +++ b/leaves-server/minecraft-patches/features/0048-Optimized-dragon-respawn.patch @@ -5,23 +5,23 @@ Subject: [PATCH] Optimized dragon respawn diff --git a/net/minecraft/world/level/block/state/pattern/BlockPattern.java b/net/minecraft/world/level/block/state/pattern/BlockPattern.java -index f7bb979f08634a7e1b77c59040f59fb5e11aafa5..3cad7d6bca9af77bace18bfd7cc013ac22be4075 100644 +index f834d487136627c07c893b8d68a6929ed46f20b9..7278bd208552b860145dc2d68fe84014c3508610 100644 --- a/net/minecraft/world/level/block/state/pattern/BlockPattern.java +++ b/net/minecraft/world/level/block/state/pattern/BlockPattern.java -@@ -59,7 +59,7 @@ public class BlockPattern { +@@ -57,7 +57,7 @@ public class BlockPattern { + return this.matches(pos, finger, thumb, loadingCache); } - @Nullable -- private BlockPattern.BlockPatternMatch matches(BlockPos pos, Direction finger, Direction thumb, LoadingCache cache) { -+ public BlockPattern.BlockPatternMatch matches(BlockPos pos, Direction finger, Direction thumb, LoadingCache cache) { // Leaves - private -> public +- private BlockPattern.@Nullable BlockPatternMatch matches(BlockPos pos, Direction finger, Direction thumb, LoadingCache cache) { ++ public BlockPattern.@Nullable BlockPatternMatch matches(BlockPos pos, Direction finger, Direction thumb, LoadingCache cache) { // Leaves - private -> public for (int i = 0; i < this.width; i++) { for (int i1 = 0; i1 < this.height; i1++) { for (int i2 = 0; i2 < this.depth; i2++) { diff --git a/net/minecraft/world/level/dimension/end/EndDragonFight.java b/net/minecraft/world/level/dimension/end/EndDragonFight.java -index fcb0fb9ca663ec40e1541d099bc3d710963f6c9d..d2e49f8490bff739a3726e73a303b2c24c47617f 100644 +index 04b03940a8c7d0d1e04298d7bcbe245a4174f7d8..82d40effe5e8dafec60c25b97f45c1188d0e6d28 100644 --- a/net/minecraft/world/level/dimension/end/EndDragonFight.java +++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java -@@ -274,8 +274,68 @@ public class EndDragonFight { +@@ -270,7 +270,67 @@ public class EndDragonFight { return false; } @@ -30,8 +30,7 @@ index fcb0fb9ca663ec40e1541d099bc3d710963f6c9d..d2e49f8490bff739a3726e73a303b2c2 + private int cachePortalChunkIteratorZ = -8; + private int cachePortalOriginIteratorY = -1; + - @Nullable - public BlockPattern.BlockPatternMatch findExitPortal() { + public BlockPattern.@Nullable BlockPatternMatch findExitPortal() { + if (org.leavesmc.leaves.LeavesConfig.performance.optimizedDragonRespawn) { + int i, j; + for (i = cachePortalChunkIteratorX; i <= 8; ++i) { @@ -90,7 +89,7 @@ index fcb0fb9ca663ec40e1541d099bc3d710963f6c9d..d2e49f8490bff739a3726e73a303b2c2 ChunkPos chunkPos = new ChunkPos(this.origin); for (int i = -8 + chunkPos.x; i <= 8 + chunkPos.x; i++) { -@@ -573,6 +633,11 @@ public class EndDragonFight { +@@ -567,6 +627,11 @@ public class EndDragonFight { } public boolean respawnDragon(List crystals) { // CraftBukkit - return boolean diff --git a/leaves-server/minecraft-patches/features/0050-Creative-fly-no-clip.patch b/leaves-server/minecraft-patches/features/0049-Creative-fly-no-clip.patch similarity index 90% rename from leaves-server/minecraft-patches/features/0050-Creative-fly-no-clip.patch rename to leaves-server/minecraft-patches/features/0049-Creative-fly-no-clip.patch index bfc3162aa..24673fe76 100644 --- a/leaves-server/minecraft-patches/features/0050-Creative-fly-no-clip.patch +++ b/leaves-server/minecraft-patches/features/0049-Creative-fly-no-clip.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Creative fly no clip diff --git a/net/minecraft/world/entity/ExperienceOrb.java b/net/minecraft/world/entity/ExperienceOrb.java -index 85c5a8497ee45de232a87c3f152e7ca67c1821ee..47bdbf9c73f19ff85ae93f3e31e45d35fe8c0a92 100644 +index f2ec0bd8cca3c08d558790537e17a8a2f95f1953..29d904b02a2c7b3d25261ca26c7c0479b00999ef 100644 --- a/net/minecraft/world/entity/ExperienceOrb.java +++ b/net/minecraft/world/entity/ExperienceOrb.java -@@ -202,7 +202,7 @@ public class ExperienceOrb extends Entity { +@@ -199,7 +199,7 @@ public class ExperienceOrb extends Entity { Player prevTarget = this.followingPlayer; // CraftBukkit - store old target if (this.followingPlayer == null || this.followingPlayer.isSpectator() || this.followingPlayer.distanceToSqr(this) > 64.0) { Player nearestPlayer = this.level().getNearestPlayer(this, 8.0); @@ -18,10 +18,10 @@ index 85c5a8497ee45de232a87c3f152e7ca67c1821ee..47bdbf9c73f19ff85ae93f3e31e45d35 } else { this.followingPlayer = null; diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index e4c7262ded690e56ba2eef71bb7d46f9cd99b8b7..7b0fdecf7ca4a5b6dd910369d6546a909926dff2 100644 +index 5bd617cd5ad73c7c06f72f2c77fb0169deab8f41..edf2f188e3547e92413e74862788945441f25b4c 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -247,8 +247,8 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -245,8 +245,8 @@ public abstract class Player extends Avatar implements ContainerUser { @Override public void tick() { @@ -41,7 +41,7 @@ index e4c7262ded690e56ba2eef71bb7d46f9cd99b8b7..7b0fdecf7ca4a5b6dd910369d6546a90 pose = desiredPose; } else if (this.canPlayerFitWithinBlocksAndEntitiesWhen(Pose.CROUCHING)) { pose = Pose.CROUCHING; -@@ -507,7 +507,7 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -504,7 +504,7 @@ public abstract class Player extends Avatar implements ContainerUser { this.updateSwingTime(); this.yHeadRot = this.getYRot(); this.setSpeed((float)this.getAttributeValue(Attributes.MOVEMENT_SPEED)); @@ -50,7 +50,7 @@ index e4c7262ded690e56ba2eef71bb7d46f9cd99b8b7..7b0fdecf7ca4a5b6dd910369d6546a90 AABB aabb; if (this.isPassenger() && !this.getVehicle().isRemoved()) { aabb = this.getBoundingBox().minmax(this.getVehicle().getBoundingBox()).inflate(1.0, 0.0, 1.0); -@@ -1733,9 +1733,29 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -1821,9 +1821,29 @@ public abstract class Player extends Avatar implements ContainerUser { return this.gameMode() == GameType.SPECTATOR; } @@ -82,10 +82,10 @@ index e4c7262ded690e56ba2eef71bb7d46f9cd99b8b7..7b0fdecf7ca4a5b6dd910369d6546a90 @Override diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java -index 58ec8a43265ebf50fdd71f2cbb7dedf4762bc5b4..c269fd74bb2157f5c5f38d9dd6e1a0a032c9f29c 100644 +index b647172cda155a5e704565c8c4819c20758bd3f3..85416c58bd447a7129f2b021f93690e3fdda62c8 100644 --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -184,8 +184,9 @@ public class BlockItem extends Item { +@@ -183,8 +183,9 @@ public class BlockItem extends Item { protected boolean canPlace(BlockPlaceContext context, BlockState state) { Player player = context.getPlayer(); // CraftBukkit start @@ -97,10 +97,10 @@ index 58ec8a43265ebf50fdd71f2cbb7dedf4762bc5b4..c269fd74bb2157f5c5f38d9dd6e1a0a0 org.bukkit.event.block.BlockCanBuildEvent event = new org.bukkit.event.block.BlockCanBuildEvent( diff --git a/net/minecraft/world/item/StandingAndWallBlockItem.java b/net/minecraft/world/item/StandingAndWallBlockItem.java -index 1f0e7c391d02b18e2c89700025713ec3d759f2ea..300ee12ca9584e53e9d72e3ebfd039beb3fab3b2 100644 +index be685383b8e7c8111e976fc560f16d43d6545a34..b96d2475c06f395fc5090eca23bdfcd6e51c3a3e 100644 --- a/net/minecraft/world/item/StandingAndWallBlockItem.java +++ b/net/minecraft/world/item/StandingAndWallBlockItem.java -@@ -45,7 +45,7 @@ public class StandingAndWallBlockItem extends BlockItem { +@@ -44,7 +44,7 @@ public class StandingAndWallBlockItem extends BlockItem { // return blockState != null && level.isUnobstructed(blockState, clickedPos, CollisionContext.empty()) ? blockState : null; // CraftBukkit start if (blockState != null) { @@ -110,10 +110,10 @@ index 1f0e7c391d02b18e2c89700025713ec3d759f2ea..300ee12ca9584e53e9d72e3ebfd039be org.bukkit.event.block.BlockCanBuildEvent event = new org.bukkit.event.block.BlockCanBuildEvent(org.bukkit.craftbukkit.block.CraftBlock.at(context.getLevel(), clickedPos), player, org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(blockState), defaultReturn, org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(context.getHand())); // Paper - Expose hand in BlockCanBuildEvent diff --git a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -index 68fcb64d13bbd61ad78137f101ab20264f402df8..7e8ca373a48f89d30d4efdfcfe2acdc903a1fed9 100644 +index fa11a17186e590cdc7b7902b91db701592a2f6b7..feab1f0d6f89035f6fcc7a568bd287821eb70a5e 100644 --- a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -@@ -153,7 +153,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl +@@ -152,7 +152,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl List entities = level.getEntities(null, progressDeltaAabb); if (!entities.isEmpty()) { for (Entity entity : entities) { @@ -123,7 +123,7 @@ index 68fcb64d13bbd61ad78137f101ab20264f402df8..7e8ca373a48f89d30d4efdfcfe2acdc9 MoverType.SHULKER_BOX, new Vec3( diff --git a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java -index 0a76cf42aaaaf210a4e43ed9bd3d177f0003ba57..13bd8dc66ad1a6f882d13dc0cbc3f6ae710fab90 100644 +index 7223cd393c4ef9408ab22c2e4d16458c19f29423..9314fdec86c7d01a6c9a155082d72cf62dffefd8 100644 --- a/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +++ b/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java @@ -151,7 +151,7 @@ public class PistonMovingBlockEntity extends BlockEntity { diff --git a/leaves-server/minecraft-patches/features/0051-Shave-snow-layers.patch b/leaves-server/minecraft-patches/features/0050-Shave-snow-layers.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0051-Shave-snow-layers.patch rename to leaves-server/minecraft-patches/features/0050-Shave-snow-layers.patch diff --git a/leaves-server/minecraft-patches/features/0052-Elytra-aeronautics-no-chunk-load.patch b/leaves-server/minecraft-patches/features/0051-Elytra-aeronautics-no-chunk-load.patch similarity index 84% rename from leaves-server/minecraft-patches/features/0052-Elytra-aeronautics-no-chunk-load.patch rename to leaves-server/minecraft-patches/features/0051-Elytra-aeronautics-no-chunk-load.patch index a53cc38a8..7122f66de 100644 --- a/leaves-server/minecraft-patches/features/0052-Elytra-aeronautics-no-chunk-load.patch +++ b/leaves-server/minecraft-patches/features/0051-Elytra-aeronautics-no-chunk-load.patch @@ -5,20 +5,20 @@ Subject: [PATCH] Elytra aeronautics no chunk load diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 1993907c606b231b879a7279d3880876f5307b1c..85c957c547b8a90157308dccbcfb961caa0b9201 100644 +index 03aaf6d85f578f1a73dfe41d1d9fb49c7b16aa2f..240fb718b2fe5e06cd7aa9c4fcf97743837fa372 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java -@@ -862,7 +862,8 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -897,7 +897,8 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } private boolean skipPlayer(ServerPlayer player) { -- return player.isSpectator() && !this.level.getGameRules().getBoolean(GameRules.RULE_SPECTATORSGENERATECHUNKS); -+ return (player.isSpectator() && !this.level.getGameRules().getBoolean(GameRules.RULE_SPECTATORSGENERATECHUNKS)) -+ || (org.leavesmc.leaves.LeavesConfig.modify.elytraAeronautics.enableNoChunkLoad && player.elytraAeronauticsNoChunk); // Leaves - Elytra aeronautics +- return player.isSpectator() && !this.level.getGameRules().get(GameRules.SPECTATORS_GENERATE_CHUNKS); ++ return (player.isSpectator() && !this.level.getGameRules().get(GameRules.SPECTATORS_GENERATE_CHUNKS) ++ || (org.leavesmc.leaves.LeavesConfig.modify.elytraAeronautics.enableNoChunkLoad && player.elytraAeronauticsNoChunk)); // Leaves - Elytra aeronautics } void updatePlayerStatus(ServerPlayer player, boolean track) { -@@ -896,6 +897,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider +@@ -931,6 +932,7 @@ public class ChunkMap extends SimpleRegionStorage implements ChunkHolder.PlayerP } public void move(ServerPlayer player) { @@ -27,10 +27,10 @@ index 1993907c606b231b879a7279d3880876f5307b1c..85c957c547b8a90157308dccbcfb961c SectionPos lastSectionPos = player.getLastSectionPos(); diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index b4000881962db5fe9c6de38f406647d95a395ec3..b4edd659a77139c1771b0714eaa35b6810d96d78 100644 +index a26ecb47170a8fb3189f9a468ac7db21f7cbb077..b06e7dd6f1ce735d4ea9b4c3f75c004adc296487 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -868,6 +868,9 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -883,6 +883,9 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } ); profilerFiller.popPush("blockEntities"); @@ -41,10 +41,10 @@ index b4000881962db5fe9c6de38f406647d95a395ec3..b4edd659a77139c1771b0714eaa35b68 profilerFiller.pop(); } diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index ea9e98313c25e7ce94b011f5bc74a4318145c6f6..8d3151a6cc4d3a53601d41abce9d61323ce86a8c 100644 +index 3e7c6eceddf36dd38dcd9713dfefe0ada85815f8..051e3bac4f406df379ec1fc335f351b1089bda8b 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -591,7 +591,7 @@ public class ServerGamePacketListenerImpl +@@ -602,7 +602,7 @@ public class ServerGamePacketListenerImpl speed *= 2f; // TODO: Get the speed of the vehicle instead of the player // Paper start - Prevent moving into unloaded chunks @@ -53,7 +53,7 @@ index ea9e98313c25e7ce94b011f5bc74a4318145c6f6..8d3151a6cc4d3a53601d41abce9d6132 !serverLevel.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(this.player.position()))) || !serverLevel.areChunksLoadedForMove(rootVehicle.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(rootVehicle.position()))) )) { -@@ -1603,6 +1603,7 @@ public class ServerGamePacketListenerImpl +@@ -1622,6 +1622,7 @@ public class ServerGamePacketListenerImpl allowMovement = !this.hasNewCollision(serverLevel, this.player, boundingBox, newBox); } // else: no collision at all detected, why do we care? } @@ -62,10 +62,10 @@ index ea9e98313c25e7ce94b011f5bc74a4318145c6f6..8d3151a6cc4d3a53601d41abce9d6132 if (!allowMovement) { io.papermc.paper.event.player.PlayerFailMoveEvent event = fireFailMove(io.papermc.paper.event.player.PlayerFailMoveEvent.FailReason.CLIPPED_INTO_BLOCK, diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 0129274ab88a151600f4fdde92dae73bec352fb2..37f6e22d9f8f0fffede79b1d273d65a69f8d675c 100644 +index 0e5210ee87e31c9d23488d80eb832d9a1bcf91b9..38bb637d2392268037be4facffc669546a1847b8 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -1127,7 +1127,13 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -1142,7 +1142,13 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name return; } } @@ -80,7 +80,7 @@ index 0129274ab88a151600f4fdde92dae73bec352fb2..37f6e22d9f8f0fffede79b1d273d65a6 ProfilerFiller profilerFiller = Profiler.get(); profilerFiller.push("move"); if (this.stuckSpeedMultiplier.lengthSqr() > 1.0E-7) { -@@ -2193,6 +2199,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -2211,6 +2217,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name this.yo = y; this.zo = d1; this.setPos(d, y, d1); @@ -89,10 +89,10 @@ index 0129274ab88a151600f4fdde92dae73bec352fb2..37f6e22d9f8f0fffede79b1d273d65a6 } diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 759c320fc331704efe5df10d3f1f33aa87262290..545e9c5f46dd4f8e016ed0a93f2049d1b687dd3c 100644 +index 8adf7835f71688ba319f053208d02b810097b06e..c2442d69ce547719467dd94fcf6fd209a3612ac2 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -3368,6 +3368,11 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3443,6 +3443,11 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin this.fallFlyTicks++; } else { this.fallFlyTicks = 0; @@ -105,10 +105,10 @@ index 759c320fc331704efe5df10d3f1f33aa87262290..545e9c5f46dd4f8e016ed0a93f2049d1 if (this.isSleeping()) { diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index 7b0fdecf7ca4a5b6dd910369d6546a909926dff2..4e7e8b8f4004cab2cf5af0dafe81e72df78f7258 100644 +index e3d09f67195f467a685c740407bd2487cfbeeb52..6bd3cd6b1a4807b0f2acee9087bcbbf9dd0bde05 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -181,6 +181,7 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -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 @@ -117,10 +117,10 @@ index 7b0fdecf7ca4a5b6dd910369d6546a909926dff2..4e7e8b8f4004cab2cf5af0dafe81e72d // CraftBukkit start public boolean fauxSleeping; diff --git a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -index 145ed3c5f5823c7505767b6d7f4f4d16cc863948..e2662b4574366dd734f5e68db3bf5505ff4e4767 100644 +index 1b633d2eb77704fd9a6358f09ed368fab2a5b212..6a5bc21eda925f0c2c41e3a63d9060b526ece472 100644 --- a/net/minecraft/world/entity/projectile/FireworkRocketEntity.java +++ b/net/minecraft/world/entity/projectile/FireworkRocketEntity.java -@@ -325,7 +325,7 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { +@@ -324,7 +324,7 @@ public class FireworkRocketEntity extends Projectile implements ItemSupplier { this.spawningEntity = input.read("SpawningEntity", net.minecraft.core.UUIDUtil.CODEC).orElse(null); // Paper } @@ -130,10 +130,10 @@ index 145ed3c5f5823c7505767b6d7f4f4d16cc863948..e2662b4574366dd734f5e68db3bf5505 Fireworks fireworks = itemStack.get(DataComponents.FIREWORKS); return fireworks != null ? fireworks.explosions() : List.of(); diff --git a/net/minecraft/world/item/FireworkRocketItem.java b/net/minecraft/world/item/FireworkRocketItem.java -index f86b0579e707ecfa5c2074ea22bbe383b5e11841..0e4335bb2469a4698b303b598ec773b5c7cc73ce 100644 +index 2c597e20c1ff587f2eadef600bedb9e01b999bbf..7ccf76e938280216def8df55fe397a433b521d29 100644 --- a/net/minecraft/world/item/FireworkRocketItem.java +++ b/net/minecraft/world/item/FireworkRocketItem.java -@@ -64,6 +64,24 @@ public class FireworkRocketItem extends Item implements ProjectileItem { +@@ -65,6 +65,24 @@ public class FireworkRocketItem extends Item implements ProjectileItem { if (player.isFallFlying()) { ItemStack itemInHand = player.getItemInHand(hand); if (level instanceof ServerLevel serverLevel) { diff --git a/leaves-server/minecraft-patches/features/0053-Cache-ignite-odds.patch b/leaves-server/minecraft-patches/features/0052-Cache-ignite-odds.patch similarity index 65% rename from leaves-server/minecraft-patches/features/0053-Cache-ignite-odds.patch rename to leaves-server/minecraft-patches/features/0052-Cache-ignite-odds.patch index dd419aae2..98ae670f5 100644 --- a/leaves-server/minecraft-patches/features/0053-Cache-ignite-odds.patch +++ b/leaves-server/minecraft-patches/features/0052-Cache-ignite-odds.patch @@ -5,27 +5,27 @@ Subject: [PATCH] Cache ignite odds diff --git a/net/minecraft/world/level/block/FireBlock.java b/net/minecraft/world/level/block/FireBlock.java -index c03ad7be16fbb9f98c28bc09de59bf33d4edf5d7..8c0b2eb643ccaaa921a90dc2963ce4abcede854d 100644 +index 14a4189166b862b66a8383046f2abfe02ccbccd8..d9092edd3df19a8392cc49f314cbfa624179d44a 100644 --- a/net/minecraft/world/level/block/FireBlock.java +++ b/net/minecraft/world/level/block/FireBlock.java -@@ -205,6 +205,7 @@ public class FireBlock extends BaseFireBlock { - this.checkBurnOut(level, pos.south(), 300 + i, random, ageValue, pos); - // CraftBukkit end - BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); +@@ -202,6 +202,7 @@ public class FireBlock extends BaseFireBlock { + this.checkBurnOut(level, pos.south(), 300 + i, random, ageValue, pos); + // CraftBukkit end - add source blockPos to burn calls + BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + Object2IntOpenHashMap blockPositionIgniteCache = new Object2IntOpenHashMap<>(); // Leaves - cache ignite odds - for (int i1 = -1; i1 <= 1; i1++) { - for (int i2 = -1; i2 <= 1; i2++) { -@@ -216,7 +217,7 @@ public class FireBlock extends BaseFireBlock { - } + for (int i1 = -1; i1 <= 1; i1++) { + for (int i2 = -1; i2 <= 1; i2++) { +@@ -213,7 +214,7 @@ public class FireBlock extends BaseFireBlock { + } - mutableBlockPos.setWithOffset(pos, i1, i3, i2); -- int igniteOdds = this.getIgniteOdds(level, mutableBlockPos); + mutableBlockPos.setWithOffset(pos, i1, i3, i2); +- int igniteOdds = this.getIgniteOdds(level, mutableBlockPos); + int igniteOdds = this.getIgniteOdds(level, mutableBlockPos, org.leavesmc.leaves.LeavesConfig.performance.cacheIgniteOdds ? blockPositionIgniteCache : null); // Leaves - cache ignite odds - if (igniteOdds > 0) { - int i5 = (igniteOdds + 40 + level.getDifficulty().getId() * 7) / (ageValue + 30); - if (isIncreasedFireBurnout) { -@@ -319,20 +320,33 @@ public class FireBlock extends BaseFireBlock { + if (igniteOdds > 0) { + int i5 = (igniteOdds + 40 + level.getDifficulty().getId() * 7) / (ageValue + 30); + if (value) { +@@ -315,20 +316,33 @@ public class FireBlock extends BaseFireBlock { return false; } diff --git a/leaves-server/minecraft-patches/features/0054-Lava-riptide.patch b/leaves-server/minecraft-patches/features/0053-Lava-riptide.patch similarity index 94% rename from leaves-server/minecraft-patches/features/0054-Lava-riptide.patch rename to leaves-server/minecraft-patches/features/0053-Lava-riptide.patch index 910467eb1..a6d9916fa 100644 --- a/leaves-server/minecraft-patches/features/0054-Lava-riptide.patch +++ b/leaves-server/minecraft-patches/features/0053-Lava-riptide.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Lava riptide diff --git a/net/minecraft/world/item/TridentItem.java b/net/minecraft/world/item/TridentItem.java -index fac4c58ea5d467a8686e42676e2323fbddeb8c7b..0afe875e003704a53856fac72d2feb8b664c1207 100644 +index d029fda2e8bac95fb75f75666a55b0c3aa3bb12d..d524a83c16dcf67d6498e1494bffe6ad378f7d1c 100644 --- a/net/minecraft/world/item/TridentItem.java +++ b/net/minecraft/world/item/TridentItem.java @@ -70,7 +70,7 @@ public class TridentItem extends Item implements ProjectileItem { diff --git a/leaves-server/minecraft-patches/features/0055-No-block-update-command.patch b/leaves-server/minecraft-patches/features/0054-No-block-update-command.patch similarity index 82% rename from leaves-server/minecraft-patches/features/0055-No-block-update-command.patch rename to leaves-server/minecraft-patches/features/0054-No-block-update-command.patch index 759211b3d..2a1f2f72a 100644 --- a/leaves-server/minecraft-patches/features/0055-No-block-update-command.patch +++ b/leaves-server/minecraft-patches/features/0054-No-block-update-command.patch @@ -5,10 +5,10 @@ Subject: [PATCH] No block update command diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java -index 65e2edf39857b2e03c5a32dfb3b822b5cb4ce93c..1a680c491ae2ed764d3f24b465de72372b65f68d 100644 +index 1039bbcfccb851f9bb557b6d55656d51d8821647..24632205303bbcb2240a851b9d8baf8bbdfe4622 100644 --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -401,7 +401,7 @@ public class ServerPlayerGameMode { +@@ -398,7 +398,7 @@ public class ServerPlayerGameMode { org.bukkit.block.BlockState state = bblock.getState(); this.level.captureDrops = new java.util.ArrayList<>(); // CraftBukkit end @@ -18,13 +18,13 @@ index 65e2edf39857b2e03c5a32dfb3b822b5cb4ce93c..1a680c491ae2ed764d3f24b465de7237 if (SharedConstants.DEBUG_BLOCK_BREAK) { LOGGER.info("server broke {} {} -> {}", pos, blockState1, this.level.getBlockState(pos)); diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index feafaaeca7ffa6fda5af9897c448b61ee1760290..48eca978dc58c3c2045c5746aac5d7f5b732ff89 100644 +index 16ea2b070207c7aece5cb80fe713a07d01b18f84..6c60317613df508b593cc1cfa4f62b0ca303ed93 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -1043,6 +1043,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1049,6 +1049,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl @Override - public boolean setBlock(BlockPos pos, BlockState state, int flags, int recursionLeft) { + public boolean setBlock(BlockPos pos, BlockState state, @Block.UpdateFlags int flags, int recursionLeft) { + // Leaves start - no block update + if (org.leavesmc.leaves.command.leaves.subcommands.BlockUpdateCommand.isNoBlockUpdate()) { + flags = flags & ~1 | net.minecraft.world.level.block.Block.UPDATE_SKIP_ON_PLACE; @@ -33,7 +33,7 @@ index feafaaeca7ffa6fda5af9897c448b61ee1760290..48eca978dc58c3c2045c5746aac5d7f5 // CraftBukkit start - tree generation if (this.captureTreeGeneration) { // Paper start - Protect Bedrock and End Portal/Frames from being destroyed -@@ -1144,6 +1149,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1150,6 +1155,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl BlockState state = newState; BlockState blockState = oldState; BlockState blockState1 = currentState; @@ -45,22 +45,21 @@ index feafaaeca7ffa6fda5af9897c448b61ee1760290..48eca978dc58c3c2045c5746aac5d7f5 if (blockState1 == state) { if (blockState != blockState1) { this.setBlocksDirty(pos, blockState, blockState1); -@@ -1162,7 +1172,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1167,6 +1177,12 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + } - if ((flags & 16) == 0 && recursionLeft > 0) { - int i = flags & -34; -- + if ((flags & Block.UPDATE_KNOWN_SHAPE) == 0 && recursionLeft > 0) { + // Leaves start - no block update + if (org.leavesmc.leaves.command.leaves.subcommands.BlockUpdateCommand.isNoBlockUpdate()) { + this.updatePOIOnBlockStateChange(pos, blockState, blockState1); + return; + } + // Leaves end - no block update + int i = flags & ~(Block.UPDATE_SUPPRESS_DROPS | Block.UPDATE_NEIGHBORS); + // CraftBukkit start - blockState.updateIndirectNeighbourShapes(this, pos, i, recursionLeft - 1); // Don't call an event for the old block to limit event spam - boolean cancelledUpdates = false; // Paper - Fix block place logic diff --git a/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/net/minecraft/world/level/block/piston/PistonBaseBlock.java -index 114aa0f1ac9feefdb856bfc821489b864aba18f3..295357c842a4a4e9e18de68c570168b1cae9593a 100644 +index 74d9b13400f6401fd88884a8e6e82eb235d9d1a1..4fa357fa06bb522ab3a8a5c776acad0c5e6a6e3e 100644 --- a/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/net/minecraft/world/level/block/piston/PistonBaseBlock.java @@ -106,6 +106,7 @@ public class PistonBaseBlock extends DirectionalBlock { @@ -72,12 +71,12 @@ index 114aa0f1ac9feefdb856bfc821489b864aba18f3..295357c842a4a4e9e18de68c570168b1 boolean neighborSignal = this.getNeighborSignal(level, pos, direction); if (neighborSignal && !state.getValue(EXTENDED)) { diff --git a/net/minecraft/world/level/redstone/NeighborUpdater.java b/net/minecraft/world/level/redstone/NeighborUpdater.java -index 77ed7a6a4bea3dfc77d060c49f77f4e080da200b..be5d8ca78b4e293766add81ed6cacdae7cb02436 100644 +index b867a58eb2c954c49f80acfda7575114dfccecd4..41f3bdd134100814e4d3af42d74a8d9c361e0dff 100644 --- a/net/minecraft/world/level/redstone/NeighborUpdater.java +++ b/net/minecraft/world/level/redstone/NeighborUpdater.java @@ -34,6 +34,11 @@ public interface NeighborUpdater { static void executeShapeUpdate( - LevelAccessor level, Direction direction, BlockPos pos, BlockPos neighborPos, BlockState neighborState, int flags, int recursionLeft + LevelAccessor level, Direction direction, BlockPos pos, BlockPos neighborPos, BlockState neighborState, @Block.UpdateFlags int flags, int recursionLeft ) { + // Leaves start - no block update + if (org.leavesmc.leaves.command.leaves.subcommands.BlockUpdateCommand.isNoBlockUpdate()) { diff --git a/leaves-server/minecraft-patches/features/0056-Container-open-passthrough.patch b/leaves-server/minecraft-patches/features/0055-Container-open-passthrough.patch similarity index 95% rename from leaves-server/minecraft-patches/features/0056-Container-open-passthrough.patch rename to leaves-server/minecraft-patches/features/0055-Container-open-passthrough.patch index 6b420d3c2..b53b4f0dc 100644 --- a/leaves-server/minecraft-patches/features/0056-Container-open-passthrough.patch +++ b/leaves-server/minecraft-patches/features/0055-Container-open-passthrough.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Container open passthrough diff --git a/net/minecraft/world/entity/decoration/ItemFrame.java b/net/minecraft/world/entity/decoration/ItemFrame.java -index 1b50d5a1c61fe15d06b3c1880e046c4a674df04e..9ca6e464c6f82cc7cf8d7ca8740f081abf99ff09 100644 +index 462ad83bc08d6d6ae55ee852489439ff6e1dc845..b36ad5527c5b10f5903a9c6627b8877c015c9867 100644 --- a/net/minecraft/world/entity/decoration/ItemFrame.java +++ b/net/minecraft/world/entity/decoration/ItemFrame.java -@@ -400,6 +400,16 @@ public class ItemFrame extends HangingEntity { +@@ -398,6 +398,16 @@ public class ItemFrame extends HangingEntity { if (this.fixed) { return InteractionResult.PASS; } else if (!player.level().isClientSide()) { @@ -26,7 +26,7 @@ index 1b50d5a1c61fe15d06b3c1880e046c4a674df04e..9ca6e464c6f82cc7cf8d7ca8740f081a if (flag1 && !this.isRemoved()) { MapItemSavedData savedData = MapItem.getSavedData(itemInHand, this.level()); diff --git a/net/minecraft/world/level/block/SignBlock.java b/net/minecraft/world/level/block/SignBlock.java -index a2c6b0f85535b286c5649352f49e448ad587655c..89214a418a4e745121530e70179e9d744b389916 100644 +index b36b9b48da940ad7b4014c90c05eb90f5198a5fb..c2fb2a862fdaaa47bf848ed537827c315ed53503 100644 --- a/net/minecraft/world/level/block/SignBlock.java +++ b/net/minecraft/world/level/block/SignBlock.java @@ -108,6 +108,18 @@ public abstract class SignBlock extends BaseEntityBlock implements SimpleWaterlo diff --git a/leaves-server/minecraft-patches/features/0057-Dont-respond-ping-before-start-fully.patch b/leaves-server/minecraft-patches/features/0056-Dont-respond-ping-before-start-fully.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0057-Dont-respond-ping-before-start-fully.patch rename to leaves-server/minecraft-patches/features/0056-Dont-respond-ping-before-start-fully.patch diff --git a/leaves-server/minecraft-patches/features/0058-Faster-chunk-serialization.patch b/leaves-server/minecraft-patches/features/0057-Faster-chunk-serialization.patch similarity index 75% rename from leaves-server/minecraft-patches/features/0058-Faster-chunk-serialization.patch rename to leaves-server/minecraft-patches/features/0057-Faster-chunk-serialization.patch index 19ed0f4c2..49b3693d0 100644 --- a/leaves-server/minecraft-patches/features/0058-Faster-chunk-serialization.patch +++ b/leaves-server/minecraft-patches/features/0057-Faster-chunk-serialization.patch @@ -3,20 +3,17 @@ From: violetc <58360096+s-yh-china@users.noreply.github.com> Date: Tue, 18 Jul 2023 13:14:15 +0800 Subject: [PATCH] Faster chunk serialization -This patch is Powered by Gale(https://github.com/GaleMC/Gale) +This patch is Powered by Leaf(https://github.com/Winds-Studio/Leaf) License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) -This patch is based on the following mixins and classes: -* "net/caffeinemc/mods/lithium/common/world/chunk/CompactingPackedIntegerArray.java" -* "net/caffeinemc/mods/lithium/common/world/chunk/LithiumHashPalette.java" -* "net/caffeinemc/mods/lithium/mixin/chunk/serialization/SimpleBitStorageMixin.java" -* "net/caffeinemc/mods/lithium/mixin/chunk/serialization/PalettedContainerMixin.java" -By: Angeline -As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric) +This patch is based on the following mixins: +* "net/caffeinemc/mods/lithium/mixin/chunk/palette/StrategyMixin.java" +By: 2No2Name <2No2Name@web.de> +As part of: Lithium (https://github.com/CaffeineMC/lithium) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) diff --git a/net/minecraft/util/BitStorage.java b/net/minecraft/util/BitStorage.java -index 02502d50f0255f5bbcc0ecb965abb48cc1a112da..45f61e66b1c24af63e3840fc54c3564f6bc317af 100644 +index 02502d50f0255f5bbcc0ecb965abb48cc1a112da..0abb6a2886cd80889307d4bc596513837154810d 100644 --- a/net/minecraft/util/BitStorage.java +++ b/net/minecraft/util/BitStorage.java @@ -38,4 +38,6 @@ public interface BitStorage extends ca.spottedleaf.moonrise.patches.block_counti @@ -24,10 +21,10 @@ index 02502d50f0255f5bbcc0ecb965abb48cc1a112da..45f61e66b1c24af63e3840fc54c3564f } // Paper end - block counting + -+ void compact(net.minecraft.world.level.chunk.Palette srcPalette, net.minecraft.world.level.chunk.Palette dstPalette, short[] out, net.minecraft.world.level.chunk.PalettedContainer resizeHandler); // Leaves - Gale - Lithium - faster chunk serialization ++ void compact(net.minecraft.world.level.chunk.Palette srcPalette, net.minecraft.world.level.chunk.Palette dstPalette, short[] out, net.minecraft.world.level.chunk.PalettedContainer resizeHandler); // Leaves - Leaf - Lithium - faster chunk serialization } diff --git a/net/minecraft/util/SimpleBitStorage.java b/net/minecraft/util/SimpleBitStorage.java -index e6306a68c8652d4c5d22d5ecb1416f5f931f76ee..1c7986dbfd27c20e37824cab94ba61da3465ce9e 100644 +index 08af7687cdbf395116c2ae0c40befa518b796846..8b81dc0526f31cd23ef40fb047046738647ba35d 100644 --- a/net/minecraft/util/SimpleBitStorage.java +++ b/net/minecraft/util/SimpleBitStorage.java @@ -465,4 +465,45 @@ public class SimpleBitStorage implements BitStorage { @@ -35,7 +32,7 @@ index e6306a68c8652d4c5d22d5ecb1416f5f931f76ee..1c7986dbfd27c20e37824cab94ba61da } } + -+ // Leaves start - Gale - Lithium - faster chunk serialization ++ // Leaves start - Leaf - Lithium - faster chunk serialization + @Override + public void compact(net.minecraft.world.level.chunk.Palette srcPalette, net.minecraft.world.level.chunk.Palette dstPalette, short[] out, net.minecraft.world.level.chunk.PalettedContainer resizeHandler) { + if (this.size >= Short.MAX_VALUE) { @@ -73,11 +70,11 @@ index e6306a68c8652d4c5d22d5ecb1416f5f931f76ee..1c7986dbfd27c20e37824cab94ba61da + } + } + } -+ // Leaves end - Gale - Lithium - faster chunk serialization ++ // Leaves end - Leaf - Lithium - faster chunk serialization + } diff --git a/net/minecraft/util/ZeroBitStorage.java b/net/minecraft/util/ZeroBitStorage.java -index 09fd99c9cbd23b5f3c899bfb00c9b89651948ed8..bdbeff9c93b6775cf9d4a2db878dada767d172ee 100644 +index 09fd99c9cbd23b5f3c899bfb00c9b89651948ed8..8337ee207a01486516087fcfc99e985a3dcd7dc1 100644 --- a/net/minecraft/util/ZeroBitStorage.java +++ b/net/minecraft/util/ZeroBitStorage.java @@ -80,4 +80,6 @@ public class ZeroBitStorage implements BitStorage { @@ -85,18 +82,46 @@ index 09fd99c9cbd23b5f3c899bfb00c9b89651948ed8..bdbeff9c93b6775cf9d4a2db878dada7 } // Paper end - block counting + -+ @Override public void compact(net.minecraft.world.level.chunk.Palette srcPalette, net.minecraft.world.level.chunk.Palette dstPalette, short[] out, net.minecraft.world.level.chunk.PalettedContainer resizeHandler) {} // Leaves - Gale - Lithium - faster chunk serialization ++ @Override public void compact(net.minecraft.world.level.chunk.Palette srcPalette, net.minecraft.world.level.chunk.Palette dstPalette, short[] out, net.minecraft.world.level.chunk.PalettedContainer resizeHandler) {} // Leaves - Leaf - Lithium - faster chunk serialization } +diff --git a/net/minecraft/world/level/chunk/HashMapPalette.java b/net/minecraft/world/level/chunk/HashMapPalette.java +index 5b9346b25aa01db9f3c36e243f46846b87a6eb75..9f39eab314ca6a4c22b30d70df423eea4d35cc0f 100644 +--- a/net/minecraft/world/level/chunk/HashMapPalette.java ++++ b/net/minecraft/world/level/chunk/HashMapPalette.java +@@ -14,7 +14,7 @@ public class HashMapPalette implements Palette, ca.spottedleaf.moonrise.pa + + // Paper start - optimise palette reads + @Override +- public final T[] moonrise$getRawPalette(final ca.spottedleaf.moonrise.patches.fast_palette.FastPaletteData container) { ++ public T[] moonrise$getRawPalette(final ca.spottedleaf.moonrise.patches.fast_palette.FastPaletteData container) { // Leaves - Leaf - Lithium - faster hash palette - public final -> public + return ((ca.spottedleaf.moonrise.patches.fast_palette.FastPalette)this.values).moonrise$getRawPalette(container); + } + // Paper end - optimise palette reads +@@ -28,6 +28,14 @@ public class HashMapPalette implements Palette, ca.spottedleaf.moonrise.pa + this(bits, CrudeIncrementalIntIdentityHashBiMap.create((1 << bits) + 1)); // Paper - Perf: Avoid unnecessary resize operation in CrudeIncrementalIntIdentityHashBiMap + } + ++ // Leaves start - Leaf - Lithium - faster hash palette ++ protected HashMapPalette(int bits, boolean dummy) { ++ this.bits = bits; ++ //noinspection DataFlowIssue ++ this.values = dummy ? null : CrudeIncrementalIntIdentityHashBiMap.create((1 << bits) + 1); ++ } ++ // Leaves end - Leaf - Lithium - faster hash palette ++ + private HashMapPalette(int bits, CrudeIncrementalIntIdentityHashBiMap values) { + this.bits = bits; + this.values = values; diff --git a/net/minecraft/world/level/chunk/PalettedContainer.java b/net/minecraft/world/level/chunk/PalettedContainer.java -index 54d71bd666a946bdf6eece520e080c3f96003452..f16484ab8cd77d34b6e061282dd08b049ba915bc 100644 +index 7c8f8772a6fba04dbafdb5dbf8098b6ebce6d6f2..a74b249378e94721eb04579932625e61ecc71041 100644 --- a/net/minecraft/world/level/chunk/PalettedContainer.java +++ b/net/minecraft/world/level/chunk/PalettedContainer.java -@@ -23,6 +23,22 @@ import net.minecraft.util.ThreadingDetector; - import net.minecraft.util.ZeroBitStorage; +@@ -23,6 +23,22 @@ import net.minecraft.util.ZeroBitStorage; + import org.jspecify.annotations.Nullable; public class PalettedContainer implements PaletteResize, PalettedContainerRO { + -+ // Leaves start - Gale - Lithium - faster chunk serialization ++ // Leaves start - Leaf - Lithium - faster chunk serialization + private static final ThreadLocal CACHED_ARRAY_4096 = ThreadLocal.withInitial(() -> new short[4096]); + private static final ThreadLocal CACHED_ARRAY_64 = ThreadLocal.withInitial(() -> new short[64]); + private Optional asOptional(long[] data) { @@ -109,7 +134,7 @@ index 54d71bd666a946bdf6eece520e080c3f96003452..f16484ab8cd77d34b6e061282dd08b04 + default -> new short[size]; + }; + } -+ // Leaves end - Gale - Lithium - faster chunk serialization ++ // Leaves end - Leaf - Lithium - faster chunk serialization + private static final int MIN_PALETTE_BITS = 0; public volatile PalettedContainer.Data data; // Paper - optimise collisions - public @@ -118,7 +143,7 @@ index 54d71bd666a946bdf6eece520e080c3f96003452..f16484ab8cd77d34b6e061282dd08b04 public synchronized PalettedContainerRO.PackedData pack(Strategy strategy) { // Paper - synchronize this.acquire(); -+ // Leaves start - Gale - Lithium - faster chunk serialization ++ // Leaves start - Leaf - Lithium - faster chunk serialization + if (org.leavesmc.leaves.LeavesConfig.performance.fasterChunkSerialization) { + Optional data = Optional.empty(); + List elements = null; @@ -167,7 +192,7 @@ index 54d71bd666a946bdf6eece520e080c3f96003452..f16484ab8cd77d34b6e061282dd08b04 + + return new PalettedContainerRO.PackedData<>(elements, data); + } -+ // Leaves end - Gale - Lithium - faster chunk serialization ++ // Leaves end - Leaf - Lithium - faster chunk serialization PalettedContainerRO.PackedData var14; try { BitStorage bitStorage = this.data.storage; @@ -181,7 +206,7 @@ index 54d71bd666a946bdf6eece520e080c3f96003452..f16484ab8cd77d34b6e061282dd08b04 - Int2IntOpenHashMap map = new Int2IntOpenHashMap(); - this.data.storage.getAll(id -> map.addTo(id, 1)); - map.int2IntEntrySet().forEach(idEntry -> countConsumer.accept(this.data.palette.valueFor(idEntry.getIntKey()), idEntry.getIntValue())); -+ // Leaves start - Gale - Lithium - faster chunk serialization ++ // Leaves start - Leaf - Lithium - faster chunk serialization + if (!org.leavesmc.leaves.LeavesConfig.performance.fasterChunkSerialization) { + if (this.data.palette.getSize() == 1) { + countConsumer.accept(this.data.palette.valueFor(0), this.data.storage.getSize()); @@ -217,7 +242,7 @@ index 54d71bd666a946bdf6eece520e080c3f96003452..f16484ab8cd77d34b6e061282dd08b04 + countConsumer.accept(obj, counts[i]); + } } -+ // Leaves end - Gale - Lithium - faster chunk serialization ++ // Leaves end - Leaf - Lithium - faster chunk serialization } @FunctionalInterface diff --git a/leaves-server/minecraft-patches/features/0059-Skip-secondary-POI-sensor-if-absent.patch b/leaves-server/minecraft-patches/features/0058-Skip-secondary-POI-sensor-if-absent.patch similarity index 93% rename from leaves-server/minecraft-patches/features/0059-Skip-secondary-POI-sensor-if-absent.patch rename to leaves-server/minecraft-patches/features/0058-Skip-secondary-POI-sensor-if-absent.patch index 177927527..cad8c8cad 100644 --- a/leaves-server/minecraft-patches/features/0059-Skip-secondary-POI-sensor-if-absent.patch +++ b/leaves-server/minecraft-patches/features/0058-Skip-secondary-POI-sensor-if-absent.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Skip secondary POI sensor if absent This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java b/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java -index f0583076ef62189508a392a76c3fb6b741bbdde9..a11c2ef54b6b8193362c2a2d42cef49765adb5c5 100644 +index 39a9e9a6f6dfddbf47a7f96150ef832efe61f89e..fb5b90efabde9625ba404f754ffcc8c704641d32 100644 --- a/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java +++ b/net/minecraft/world/entity/ai/sensing/SecondaryPoiSensor.java @@ -22,6 +22,15 @@ public class SecondaryPoiSensor extends Sensor { diff --git a/leaves-server/minecraft-patches/features/0060-Store-mob-counts-in-an-array.patch b/leaves-server/minecraft-patches/features/0059-Store-mob-counts-in-an-array.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0060-Store-mob-counts-in-an-array.patch rename to leaves-server/minecraft-patches/features/0059-Store-mob-counts-in-an-array.patch diff --git a/leaves-server/minecraft-patches/features/0061-Optimize-noise-generation.patch b/leaves-server/minecraft-patches/features/0060-Optimize-noise-generation.patch similarity index 99% rename from leaves-server/minecraft-patches/features/0061-Optimize-noise-generation.patch rename to leaves-server/minecraft-patches/features/0060-Optimize-noise-generation.patch index 19a00b2e0..c873302f8 100644 --- a/leaves-server/minecraft-patches/features/0061-Optimize-noise-generation.patch +++ b/leaves-server/minecraft-patches/features/0060-Optimize-noise-generation.patch @@ -249,7 +249,7 @@ index fb11a2eea540d55e50eab59f9857ca5d99f556f8..a54ad0b2731b83ee2e3de09972c62992 private double sampleWithDerivative(int gridX, int gridY, int gridZ, double deltaX, double deltaY, double deltaZ, double[] noiseValues) { diff --git a/net/minecraft/world/level/levelgen/synth/PerlinNoise.java b/net/minecraft/world/level/levelgen/synth/PerlinNoise.java -index da3c26fbad32d75d71f7e59c8c3341316a754756..fde3efb7fa4fb9332ec0faafc6f9c4262a4f55c5 100644 +index 4c5268704af9b6a88c00878459254851c0592da1..3aff39b7bb9dca4fd357bd3ee69a4c4cb3e5f380 100644 --- a/net/minecraft/world/level/levelgen/synth/PerlinNoise.java +++ b/net/minecraft/world/level/levelgen/synth/PerlinNoise.java @@ -26,6 +26,10 @@ public class PerlinNoise { @@ -306,7 +306,7 @@ index da3c26fbad32d75d71f7e59c8c3341316a754756..fde3efb7fa4fb9332ec0faafc6f9c426 } @Deprecated -@@ -187,7 +218,13 @@ public class PerlinNoise { +@@ -186,7 +217,13 @@ public class PerlinNoise { } public static double wrap(double value) { diff --git a/leaves-server/minecraft-patches/features/0062-Optimize-sun-burn-tick.patch b/leaves-server/minecraft-patches/features/0061-Optimize-sun-burn-tick.patch similarity index 85% rename from leaves-server/minecraft-patches/features/0062-Optimize-sun-burn-tick.patch rename to leaves-server/minecraft-patches/features/0061-Optimize-sun-burn-tick.patch index f880a2ad3..ab7c84531 100644 --- a/leaves-server/minecraft-patches/features/0062-Optimize-sun-burn-tick.patch +++ b/leaves-server/minecraft-patches/features/0061-Optimize-sun-burn-tick.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Optimize sun burn tick This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 37f6e22d9f8f0fffede79b1d273d65a69f8d675c..39e31c547dcd60f48e607a9c98cfe03a38ae88b1 100644 +index 38bb637d2392268037be4facffc669546a1847b8..3fe3d5578fe6023ed75f66a64493db9a5ef1f9be 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -2174,9 +2174,20 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -2192,9 +2192,20 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name @Deprecated public float getLightLevelDependentMagicValue() { @@ -33,7 +33,7 @@ index 37f6e22d9f8f0fffede79b1d273d65a69f8d675c..39e31c547dcd60f48e607a9c98cfe03a } public void absSnapTo(double x, double y, double z, float yRot, float xRot) { -@@ -2191,6 +2202,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -2209,6 +2220,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name this.xRotO = this.getXRot(); this.setYHeadRot(yRot); // Paper - Update head rotation } @@ -42,20 +42,20 @@ index 37f6e22d9f8f0fffede79b1d273d65a69f8d675c..39e31c547dcd60f48e607a9c98cfe03a public void absSnapTo(double x, double y, double z) { double d = Mth.clamp(x, -3.0E7, 3.0E7); diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java -index 0659e1b95055e85e3eefd206ccb01ee4a4949a5b..1cefdab82744600c6e5886646450d4c3fab03181 100644 +index 0e58de4eef841606b5fb26ad8267c5736c2b807c..7d70731905440c6b01639c0b50e259c619bf0421 100644 --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -1565,17 +1565,39 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab - protected void playAttackSound() { +@@ -577,17 +577,39 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab + } } + // Leaves start - optimize sun burn tick -+ @Nullable private BlockPos cached_eye_blockpos; -+ @Nullable private net.minecraft.world.phys.Vec3 cached_position; ++ @org.jetbrains.annotations.Nullable private BlockPos cached_eye_blockpos; ++ @org.jetbrains.annotations.Nullable private net.minecraft.world.phys.Vec3 cached_position; + // Leaves end - optimize sun burn tick + public boolean isSunBurnTick() { - if (this.level().isBrightOutside() && !this.level().isClientSide()) { + if (!this.level().isClientSide() && this.level().environmentAttributes().getValue(EnvironmentAttributes.MONSTERS_BURN, this.position())) { - float lightLevelDependentMagicValue = this.getLightLevelDependentMagicValue(); - BlockPos blockPos = BlockPos.containing(this.getX(), this.getEyeY(), this.getZ()); - boolean flag = this.isInWaterOrRain() || this.isInPowderSnow || this.wasInPowderSnow; diff --git a/leaves-server/minecraft-patches/features/0063-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch b/leaves-server/minecraft-patches/features/0062-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0063-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch rename to leaves-server/minecraft-patches/features/0062-Reduce-lambda-and-Optional-allocation-in-EntityBased.patch diff --git a/leaves-server/minecraft-patches/features/0064-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch b/leaves-server/minecraft-patches/features/0063-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch similarity index 91% rename from leaves-server/minecraft-patches/features/0064-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch rename to leaves-server/minecraft-patches/features/0063-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch index d81c49121..800adcc02 100644 --- a/leaves-server/minecraft-patches/features/0064-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch +++ b/leaves-server/minecraft-patches/features/0063-Avoid-Class-isAssignableFrom-call-in-ClassInstanceMu.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Avoid Class#isAssignableFrom call in ClassInstanceMultiMap This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/net/minecraft/util/ClassInstanceMultiMap.java b/net/minecraft/util/ClassInstanceMultiMap.java -index 2a708ae0d5bb209650b525e3c56051f8b5655074..7f4b29fad0d70f0480b8b13d7a7d8d7a7f90b491 100644 +index 81b8bedff21dc77930e40457937b895b1c3d5401..912803b9f49975b2c601ee91ef2752699621a9d2 100644 --- a/net/minecraft/util/ClassInstanceMultiMap.java +++ b/net/minecraft/util/ClassInstanceMultiMap.java -@@ -56,13 +56,24 @@ public class ClassInstanceMultiMap extends AbstractCollection { +@@ -55,13 +55,24 @@ public class ClassInstanceMultiMap extends AbstractCollection { } public Collection find(Class type) { diff --git a/leaves-server/minecraft-patches/features/0065-Optimized-CubePointRange.patch b/leaves-server/minecraft-patches/features/0064-Optimized-CubePointRange.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0065-Optimized-CubePointRange.patch rename to leaves-server/minecraft-patches/features/0064-Optimized-CubePointRange.patch diff --git a/leaves-server/minecraft-patches/features/0066-Check-frozen-ticks-before-landing-block.patch b/leaves-server/minecraft-patches/features/0065-Check-frozen-ticks-before-landing-block.patch similarity index 93% rename from leaves-server/minecraft-patches/features/0066-Check-frozen-ticks-before-landing-block.patch rename to leaves-server/minecraft-patches/features/0065-Check-frozen-ticks-before-landing-block.patch index 2e5c87cda..fb662cc86 100644 --- a/leaves-server/minecraft-patches/features/0066-Check-frozen-ticks-before-landing-block.patch +++ b/leaves-server/minecraft-patches/features/0065-Check-frozen-ticks-before-landing-block.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Check frozen ticks before landing block This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 545e9c5f46dd4f8e016ed0a93f2049d1b687dd3c..1a7135f2fda41265c75448e8ca9fec1c64de8e97 100644 +index c2442d69ce547719467dd94fcf6fd209a3612ac2..411b5623511a2b3d0205a98f9ba6db43a630fed3 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -544,10 +544,10 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin diff --git a/leaves-server/minecraft-patches/features/0067-Skip-entity-move-if-movement-is-zero.patch b/leaves-server/minecraft-patches/features/0066-Skip-entity-move-if-movement-is-zero.patch similarity index 86% rename from leaves-server/minecraft-patches/features/0067-Skip-entity-move-if-movement-is-zero.patch rename to leaves-server/minecraft-patches/features/0066-Skip-entity-move-if-movement-is-zero.patch index 7573e177b..302db2bc3 100644 --- a/leaves-server/minecraft-patches/features/0067-Skip-entity-move-if-movement-is-zero.patch +++ b/leaves-server/minecraft-patches/features/0066-Skip-entity-move-if-movement-is-zero.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Skip entity move if movement is zero This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 39e31c547dcd60f48e607a9c98cfe03a38ae88b1..d2fafdbce9fe1db0451bb4ad819d8e075122530e 100644 +index 3fe3d5578fe6023ed75f66a64493db9a5ef1f9be..943dab97a4e22797664554b8cbcf1cb7603de12f 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -263,6 +263,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -265,6 +265,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name public float yRotO; public float xRotO; private AABB bb = INITIAL_AABB; @@ -17,7 +17,7 @@ index 39e31c547dcd60f48e607a9c98cfe03a38ae88b1..d2fafdbce9fe1db0451bb4ad819d8e07 public boolean onGround; public boolean horizontalCollision; public boolean verticalCollision; -@@ -1099,6 +1100,13 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -1114,6 +1115,13 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name // Paper end - detailed watchdog information public void move(MoverType type, Vec3 movement) { @@ -31,7 +31,7 @@ index 39e31c547dcd60f48e607a9c98cfe03a38ae88b1..d2fafdbce9fe1db0451bb4ad819d8e07 final Vec3 originalMovement = movement; // Paper - Expose pre-collision velocity // Paper start - detailed watchdog information ca.spottedleaf.moonrise.common.util.TickThread.ensureTickThread("Cannot move an entity off-main"); -@@ -4466,6 +4474,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4485,6 +4493,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } public final void setBoundingBox(AABB bb) { diff --git a/leaves-server/minecraft-patches/features/0068-Skip-cloning-advancement-criteria.patch b/leaves-server/minecraft-patches/features/0067-Skip-cloning-advancement-criteria.patch similarity index 92% rename from leaves-server/minecraft-patches/features/0068-Skip-cloning-advancement-criteria.patch rename to leaves-server/minecraft-patches/features/0067-Skip-cloning-advancement-criteria.patch index a4e8fe181..a738277f2 100644 --- a/leaves-server/minecraft-patches/features/0068-Skip-cloning-advancement-criteria.patch +++ b/leaves-server/minecraft-patches/features/0067-Skip-cloning-advancement-criteria.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Skip cloning advancement criteria This patch is Powered by Gale(https://github.com/GaleMC/Gale) diff --git a/net/minecraft/advancements/Advancement.java b/net/minecraft/advancements/Advancement.java -index ac6a85ddf6eb326b3fd53341a4a5db7bd00b7ce2..e677a81e7005b5c596a2cef3b14e2c738559e586 100644 +index 504052b70e5397b298ee99ac650b43af6103cc1a..95f31f4fde4d12d72173add5984d00697b709255 100644 --- a/net/minecraft/advancements/Advancement.java +++ b/net/minecraft/advancements/Advancement.java @@ -61,7 +61,7 @@ public record Advancement( diff --git a/leaves-server/minecraft-patches/features/0069-Avoid-anvil-too-expensive.patch b/leaves-server/minecraft-patches/features/0068-Avoid-anvil-too-expensive.patch similarity index 85% rename from leaves-server/minecraft-patches/features/0069-Avoid-anvil-too-expensive.patch rename to leaves-server/minecraft-patches/features/0068-Avoid-anvil-too-expensive.patch index 7f42294cd..40fa4eaad 100644 --- a/leaves-server/minecraft-patches/features/0069-Avoid-anvil-too-expensive.patch +++ b/leaves-server/minecraft-patches/features/0068-Avoid-anvil-too-expensive.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Avoid anvil too expensive diff --git a/net/minecraft/world/inventory/AnvilMenu.java b/net/minecraft/world/inventory/AnvilMenu.java -index 9a3887752aa4b39224c9bf6e6145e20fa6962439..a7f84100b350b097d33b571be65296fe76d13e82 100644 +index 7939f19b87364a32a40e58e001cea14e06348f86..0fd12fd175160dd73e0b129744d89855707a86d5 100644 --- a/net/minecraft/world/inventory/AnvilMenu.java +++ b/net/minecraft/world/inventory/AnvilMenu.java -@@ -268,7 +268,7 @@ public class AnvilMenu extends ItemCombinerMenu { +@@ -267,7 +267,7 @@ public class AnvilMenu extends ItemCombinerMenu { this.onlyRenaming = true; } diff --git a/leaves-server/minecraft-patches/features/0070-Bow-infinity-fix.patch b/leaves-server/minecraft-patches/features/0069-Bow-infinity-fix.patch similarity index 90% rename from leaves-server/minecraft-patches/features/0070-Bow-infinity-fix.patch rename to leaves-server/minecraft-patches/features/0069-Bow-infinity-fix.patch index 28cd12cdf..4bca89765 100644 --- a/leaves-server/minecraft-patches/features/0070-Bow-infinity-fix.patch +++ b/leaves-server/minecraft-patches/features/0069-Bow-infinity-fix.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Bow infinity fix diff --git a/net/minecraft/world/entity/player/Player.java b/net/minecraft/world/entity/player/Player.java -index 4e7e8b8f4004cab2cf5af0dafe81e72df78f7258..b692785e7f9f899fe8d06d75d8206df8cef4dd29 100644 +index 6bd3cd6b1a4807b0f2acee9087bcbbf9dd0bde05..7fe3de7baa38a5b769b1069f3ee7ae56dc76fd1b 100644 --- a/net/minecraft/world/entity/player/Player.java +++ b/net/minecraft/world/entity/player/Player.java -@@ -1968,8 +1968,10 @@ public abstract class Player extends Avatar implements ContainerUser { +@@ -2092,8 +2092,10 @@ public abstract class Player extends Avatar implements ContainerUser { } } diff --git a/leaves-server/minecraft-patches/features/0071-Zero-tick-plants.patch b/leaves-server/minecraft-patches/features/0070-Zero-tick-plants.patch similarity index 88% rename from leaves-server/minecraft-patches/features/0071-Zero-tick-plants.patch rename to leaves-server/minecraft-patches/features/0070-Zero-tick-plants.patch index bd20206a6..d4f1a51d4 100644 --- a/leaves-server/minecraft-patches/features/0071-Zero-tick-plants.patch +++ b/leaves-server/minecraft-patches/features/0070-Zero-tick-plants.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Zero tick plants diff --git a/net/minecraft/world/level/block/BambooStalkBlock.java b/net/minecraft/world/level/block/BambooStalkBlock.java -index a6249f5852c4ac2432bb60cb4f7a2e0a03abd7dd..29f9866e693dbbf9487cdc15ca8d2f5576cde00c 100644 +index 81e2a279d4c29f5fe52387875489239515a8c82b..66ef754fa72626886b14ea2941a851c847094efd 100644 --- a/net/minecraft/world/level/block/BambooStalkBlock.java +++ b/net/minecraft/world/level/block/BambooStalkBlock.java -@@ -109,6 +109,10 @@ public class BambooStalkBlock extends Block implements BonemealableBlock { +@@ -108,6 +108,10 @@ public class BambooStalkBlock extends Block implements BonemealableBlock { protected void tick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) { if (!state.canSurvive(level, pos)) { level.destroyBlock(pos, true); @@ -20,7 +20,7 @@ index a6249f5852c4ac2432bb60cb4f7a2e0a03abd7dd..29f9866e693dbbf9487cdc15ca8d2f55 } diff --git a/net/minecraft/world/level/block/CactusBlock.java b/net/minecraft/world/level/block/CactusBlock.java -index d4fbf130e23a959be8268085067b3bea1541be9a..a8cb3264ebc3b9728ce1a1af449f7ccb4d3c9973 100644 +index 9662828596de15e5b855f12d2a3b014763b3fc2e..67490a7db2db521863bcc4d923ed435de9d6e961 100644 --- a/net/minecraft/world/level/block/CactusBlock.java +++ b/net/minecraft/world/level/block/CactusBlock.java @@ -47,6 +47,10 @@ public class CactusBlock extends Block { @@ -35,7 +35,7 @@ index d4fbf130e23a959be8268085067b3bea1541be9a..a8cb3264ebc3b9728ce1a1af449f7ccb } diff --git a/net/minecraft/world/level/block/ChorusFlowerBlock.java b/net/minecraft/world/level/block/ChorusFlowerBlock.java -index 32ba79c568ef9e75639f03cd7cc34be569638742..46af89f48716a661c4ca31334299d874d29a0b36 100644 +index 184c971852a9eb387484e4ce89a26a69567cbeda..fe668a8c4c7449731901dc3bee8996b7baeaed5c 100644 --- a/net/minecraft/world/level/block/ChorusFlowerBlock.java +++ b/net/minecraft/world/level/block/ChorusFlowerBlock.java @@ -49,6 +49,9 @@ public class ChorusFlowerBlock extends Block { @@ -49,7 +49,7 @@ index 32ba79c568ef9e75639f03cd7cc34be569638742..46af89f48716a661c4ca31334299d874 } diff --git a/net/minecraft/world/level/block/GrowingPlantHeadBlock.java b/net/minecraft/world/level/block/GrowingPlantHeadBlock.java -index fe11f3ec82ebdbdf3d024d7273fb16b6823b1ece..577ba4b329e6d1e224d6ea57b224ad92e1993d65 100644 +index bac7f990282fd7c676c2f8c40d7fd87badb1e284..876f2e24c5e62eaf3b355ea313d7a9a1b473ffc8 100644 --- a/net/minecraft/world/level/block/GrowingPlantHeadBlock.java +++ b/net/minecraft/world/level/block/GrowingPlantHeadBlock.java @@ -155,4 +155,15 @@ public abstract class GrowingPlantHeadBlock extends GrowingPlantBlock implements @@ -69,7 +69,7 @@ index fe11f3ec82ebdbdf3d024d7273fb16b6823b1ece..577ba4b329e6d1e224d6ea57b224ad92 + // Leaves end - zero tick plants } diff --git a/net/minecraft/world/level/block/SugarCaneBlock.java b/net/minecraft/world/level/block/SugarCaneBlock.java -index a8de37e173e244d7a16c19ac8805e0e4327c837a..c6803d4869459b778d6a331950889ae1814422ce 100644 +index 4437fd5724e094e8d2edb97ca9bf494ef57f5b79..1060c57dde837481a898d9a5f45c7f1fd7174c4e 100644 --- a/net/minecraft/world/level/block/SugarCaneBlock.java +++ b/net/minecraft/world/level/block/SugarCaneBlock.java @@ -43,6 +43,10 @@ public class SugarCaneBlock extends Block { diff --git a/leaves-server/minecraft-patches/features/0072-Replay-Mod-API.patch b/leaves-server/minecraft-patches/features/0071-Replay-Mod-API.patch similarity index 92% rename from leaves-server/minecraft-patches/features/0072-Replay-Mod-API.patch rename to leaves-server/minecraft-patches/features/0071-Replay-Mod-API.patch index e5d5a84b2..cb586c5c0 100644 --- a/leaves-server/minecraft-patches/features/0072-Replay-Mod-API.patch +++ b/leaves-server/minecraft-patches/features/0071-Replay-Mod-API.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Replay Mod API 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 be42e2bd05a7468911698e53a33d87abf4a1080b..76350460f530d2edf3d58c30bff0291e7e498106 100644 +index 566304106fd4f1c677a56e7c66282d1570e7b974..539cc641d894cc74051e01da7acc5a62b84ffb7c 100644 --- a/net/minecraft/commands/CommandSourceStack.java +++ b/net/minecraft/commands/CommandSourceStack.java -@@ -580,7 +580,7 @@ public class CommandSourceStack implements ExecutionCommandSource getOnlinePlayerNames() { @@ -19,10 +19,10 @@ index be42e2bd05a7468911698e53a33d87abf4a1080b..76350460f530d2edf3d58c30bff0291e @Override diff --git a/net/minecraft/commands/arguments/selector/EntitySelector.java b/net/minecraft/commands/arguments/selector/EntitySelector.java -index d438e31a082b675d7eb0eead7067a0b92363a9f9..c08f34bc17bec9f73c377b45389a77558f53d2a2 100644 +index af71e0e1eb1c93745f3e4954ecc8fbd2ad4808a3..f3829564681faff3ae8971ed90b947b4a082a636 100644 --- a/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java -@@ -129,11 +129,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); @@ -36,7 +36,7 @@ index d438e31a082b675d7eb0eead7067a0b92363a9f9..c08f34bc17bec9f73c377b45389a7755 if (entity.getType().isEnabled(source.enabledFeatures())) { return List.of(entity); } -@@ -147,7 +148,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); @@ -45,7 +45,7 @@ index d438e31a082b675d7eb0eead7067a0b92363a9f9..c08f34bc17bec9f73c377b45389a7755 } else { Predicate predicate = this.getPredicate(vec3, absoluteAabb, source.enabledFeatures()); List list = new ObjectArrayList<>(); -@@ -158,6 +159,7 @@ public class EntitySelector { +@@ -155,6 +156,7 @@ public class EntitySelector { this.addEntities(list, serverLevel1, absoluteAabb, predicate); } } @@ -53,7 +53,7 @@ index d438e31a082b675d7eb0eead7067a0b92363a9f9..c08f34bc17bec9f73c377b45389a7755 return this.sortAndLimit(vec3, list); } -@@ -193,9 +195,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); @@ -65,7 +65,7 @@ index d438e31a082b675d7eb0eead7067a0b92363a9f9..c08f34bc17bec9f73c377b45389a7755 return playerByName == null ? List.of() : List.of(playerByName); } else { Vec3 vec3 = this.position.apply(source.getPosition()); -@@ -207,11 +211,11 @@ public class EntitySelector { +@@ -204,11 +208,11 @@ public class EntitySelector { int resultLimit = this.getResultLimit(); List players; if (this.isWorldLimited()) { @@ -80,10 +80,10 @@ index d438e31a082b675d7eb0eead7067a0b92363a9f9..c08f34bc17bec9f73c377b45389a7755 players.add(serverPlayer1); if (players.size() >= resultLimit) { diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index d9d661f72c90d04a3fca0d5698cc38a004717581..7daa09a9e088647c5147c7aa6376030834c46526 100644 +index 5a46df87c6af968c583bbfc2bdf365ad7779d90d..972dccc49fc6636168e82caa6a259a4b6d456d21 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1721,7 +1721,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> startTrackingPackets = this.getStartTrackingPackets(objective); @@ -154,7 +154,7 @@ index 07294b9cfa788313da7433946312939d93956021..292bd07552606fbc25af7fd590fcae40 if (serverPlayer.getBukkitEntity().getScoreboard().getHandle() != this) continue; // CraftBukkit - Only players on this board for (Packet packet : startTrackingPackets) { serverPlayer.connection.send(packet); -@@ -270,7 +270,7 @@ public class ServerScoreboard extends Scoreboard { +@@ -277,7 +277,7 @@ public class ServerScoreboard extends Scoreboard { public void stopTrackingObjective(Objective objective) { List> stopTrackingPackets = this.getStopTrackingPackets(objective); @@ -177,7 +177,7 @@ index e7c778a7f292fd0749cbd5e6586ad1b93ac7f29e..024b56405bb58801b17a6adad7fec7a4 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 065af7f615711d7830002cd8f3046fab706082c1..d78fbc78369aab0139b99a008300b799b1dc369f 100644 +index 590891d70a71ab30ceae3a3cf1923745e7c20b26..0ede1e5c73a0071e854de70f81ae1fc6a1d6dc59 100644 --- a/net/minecraft/server/commands/OpCommand.java +++ b/net/minecraft/server/commands/OpCommand.java @@ -25,7 +25,7 @@ public class OpCommand { @@ -190,7 +190,7 @@ index 065af7f615711d7830002cd8f3046fab706082c1..d78fbc78369aab0139b99a008300b799 .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 51f76f7a711257e5ee432ee0b2ebe7b2e129cda0..802322cccaff58e4fcd754a8f73ac2967fbab298 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 { @@ -252,7 +252,7 @@ index 0ae4d68dfe42004839a0c5ad457de592f6b4af8b..1d1e396e4b29f33669872fb39e3a7f1d .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 9f4715c1214d6848b67637622bd24fc8f6fa5f2a..d69333e308ea772515c440f89b0b39fbd458f85c 100644 +index 305273583b3d2ad233c6cd67883baad15fe572eb..ce2939eac9c66e0c6eaac1570c4da19d908662ad 100644 --- a/net/minecraft/server/commands/WhitelistCommand.java +++ b/net/minecraft/server/commands/WhitelistCommand.java @@ -44,7 +44,7 @@ public class WhitelistCommand { @@ -280,10 +280,10 @@ index 5a8cd3e6b448a4472092690cf589bca10b142126..8f22d5faf89006153b1fff4ff0b622f8 this.setListData(list); diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index b4edd659a77139c1771b0714eaa35b6810d96d78..ead3e1d538f138dc5370db49d8b4293aff376d46 100644 +index b06e7dd6f1ce735d4ea9b4c3f75c004adc296487..499714800b2160cf163fc7a37e287f655a9d80ee 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -2764,7 +2764,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2816,7 +2816,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.add(serverPlayer); // Leaves start - skip @@ -292,7 +292,7 @@ index b4edd659a77139c1771b0714eaa35b6810d96d78..ead3e1d538f138dc5370db49d8b4293a ServerLevel.this.realPlayers.add(serverPlayer); } // Leaves end - skip -@@ -2847,7 +2847,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2899,7 +2899,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.remove(serverPlayer); // Leaves start - skip @@ -302,10 +302,10 @@ index b4edd659a77139c1771b0714eaa35b6810d96d78..ead3e1d538f138dc5370db49d8b4293a } // Leaves end - skip diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index cf3c9f2a19377f2d446f6220180f63557ef8a901..b6e4a227d49ca97e8482c56ea0819a030b52097c 100644 +index fce0114134eb1ffee558f6ce072e793eafbd6779..dc27a7b11c72ff0d184580edf4ac1376fda86f7c 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -126,6 +126,7 @@ public abstract class PlayerList { +@@ -130,6 +130,7 @@ public abstract class PlayerList { private int simulationDistance; private boolean allowCommandsForAllPlayers; private int sendAllPlayerInfoIn; @@ -313,7 +313,7 @@ index cf3c9f2a19377f2d446f6220180f63557ef8a901..b6e4a227d49ca97e8482c56ea0819a03 // CraftBukkit start private org.bukkit.craftbukkit.CraftServer cserver; -@@ -149,6 +150,124 @@ public abstract class PlayerList { +@@ -153,6 +154,128 @@ public abstract class PlayerList { abstract public void loadAndSaveFiles(); // Paper - fix converting txt to json file; moved from DedicatedPlayerList constructor @@ -332,9 +332,9 @@ index cf3c9f2a19377f2d446f6220180f63557ef8a901..b6e4a227d49ca97e8482c56ea0819a03 + + 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 @@ -357,6 +357,10 @@ index cf3c9f2a19377f2d446f6220180f63557ef8a901..b6e4a227d49ca97e8482c56ea0819a03 + player.sendServerStatus(serverping); + } + ++ if (playersByName.containsKey(player.getScoreboardName()) || playersByUUID.containsKey(player.getUUID())) { ++ throw new IllegalStateException("There is a player with the same name as the photographer " + player.getScoreboardName() + " !"); ++ } ++ + this.players.add(player); + this.playersByName.put(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT), player); // Spigot + this.playersByUUID.put(player.getUUID(), player); @@ -438,7 +442,7 @@ index cf3c9f2a19377f2d446f6220180f63557ef8a901..b6e4a227d49ca97e8482c56ea0819a03 public void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie cookie) { player.isRealPlayer = true; // Paper player.loginTime = System.currentTimeMillis(); // Paper - Replace OfflinePlayer#getLastPlayed -@@ -216,6 +335,7 @@ public abstract class PlayerList { +@@ -221,6 +344,7 @@ public abstract class PlayerList { // player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players)); // CraftBukkit - replaced with loop below this.players.add(player); @@ -446,7 +450,7 @@ index cf3c9f2a19377f2d446f6220180f63557ef8a901..b6e4a227d49ca97e8482c56ea0819a03 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 -@@ -420,6 +540,7 @@ public abstract class PlayerList { +@@ -426,6 +550,7 @@ public abstract class PlayerList { } protected void save(ServerPlayer player) { @@ -454,7 +458,7 @@ index cf3c9f2a19377f2d446f6220180f63557ef8a901..b6e4a227d49ca97e8482c56ea0819a03 if (!player.getBukkitEntity().isPersistent()) return; // CraftBukkit player.lastSave = MinecraftServer.currentTick; // Paper - Incremental chunk and player saving this.playerIo.save(player); -@@ -434,6 +555,43 @@ public abstract class PlayerList { +@@ -440,6 +565,43 @@ public abstract class PlayerList { } } @@ -495,10 +499,10 @@ index cf3c9f2a19377f2d446f6220180f63557ef8a901..b6e4a227d49ca97e8482c56ea0819a03 + } + // 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()))); -@@ -507,6 +665,7 @@ public abstract class PlayerList { +@@ -513,6 +675,7 @@ public abstract class PlayerList { player.retireScheduler(); // Paper - Folia schedulers player.getAdvancements().stopListening(); this.players.remove(player); @@ -506,7 +510,7 @@ index cf3c9f2a19377f2d446f6220180f63557ef8a901..b6e4a227d49ca97e8482c56ea0819a03 this.playersByName.remove(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot this.server.getCustomBossEvents().onPlayerDisconnect(player); UUID uuid = player.getUUID(); -@@ -835,14 +994,14 @@ public abstract class PlayerList { +@@ -841,14 +1004,14 @@ public abstract class PlayerList { } public String[] getPlayerNamesArray() { @@ -526,7 +530,7 @@ index cf3c9f2a19377f2d446f6220180f63557ef8a901..b6e4a227d49ca97e8482c56ea0819a03 } // Leaves end - fakeplayer support -@@ -911,7 +1070,7 @@ public abstract class PlayerList { +@@ -915,7 +1078,7 @@ public abstract class PlayerList { // Paper start - whitelist verify event / login event public LoginResult canBypassFullServerLogin(final NameAndId nameAndId, final LoginResult currentResult) { diff --git a/leaves-server/minecraft-patches/features/0073-Leaves-I18n-support.patch b/leaves-server/minecraft-patches/features/0072-Leaves-I18n-support.patch similarity index 89% rename from leaves-server/minecraft-patches/features/0073-Leaves-I18n-support.patch rename to leaves-server/minecraft-patches/features/0072-Leaves-I18n-support.patch index ddee8d39c..699fbecc7 100644 --- a/leaves-server/minecraft-patches/features/0073-Leaves-I18n-support.patch +++ b/leaves-server/minecraft-patches/features/0072-Leaves-I18n-support.patch @@ -26,10 +26,10 @@ index 7b9e2a1a208b46a69c16e6afd8b502259893574f..8ef3627217a8c495e4e31b70e61ad1b7 loadFromJson(resourceAsStream, output); } catch (JsonParseException | IOException var7) { diff --git a/net/minecraft/server/Main.java b/net/minecraft/server/Main.java -index 30b681bc234eac8dc44ce3bf6e228171f5a71a7a..e7a4a977cd1dcdbdeb163016ff30346bc3289f99 100644 +index b946df218837f424c5f6fcdc43f6fa106aae4edf..ca434d97dbdf4a805f6fa566d18b7256b9a2673f 100644 --- a/net/minecraft/server/Main.java +++ b/net/minecraft/server/Main.java -@@ -152,6 +152,8 @@ public class Main { +@@ -150,6 +150,8 @@ public class Main { return; } @@ -39,10 +39,10 @@ index 30b681bc234eac8dc44ce3bf6e228171f5a71a7a..e7a4a977cd1dcdbdeb163016ff30346b 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 677ad1a39e76efc98fc3b953ad66b329184612e0..51400ef2db6e93bfa032108f72687cddfc60c88e 100644 +index 16ea8a00470943904ae167b7a670cd26c599f024..e6ad9b2a2478f768103b7829702cb25dda2cf63a 100644 --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -280,6 +280,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -277,6 +277,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface org.leavesmc.leaves.LeavesConfig.init((java.io.File) options.valueOf("leaves-settings")); // Leaves - Server Config this.getBotList().loadResumeBotInfo(); // Leaves - load resident bot info diff --git a/leaves-server/minecraft-patches/features/0074-Fix-minecraft-hopper-not-work-without-player.patch b/leaves-server/minecraft-patches/features/0073-Fix-minecraft-hopper-not-work-without-player.patch similarity index 56% rename from leaves-server/minecraft-patches/features/0074-Fix-minecraft-hopper-not-work-without-player.patch rename to leaves-server/minecraft-patches/features/0073-Fix-minecraft-hopper-not-work-without-player.patch index f3d662b7c..3c45a5df2 100644 --- a/leaves-server/minecraft-patches/features/0074-Fix-minecraft-hopper-not-work-without-player.patch +++ b/leaves-server/minecraft-patches/features/0073-Fix-minecraft-hopper-not-work-without-player.patch @@ -4,11 +4,11 @@ Date: Wed, 16 Aug 2023 13:10:58 +0800 Subject: [PATCH] Fix minecraft hopper not work without player -diff --git a/net/minecraft/world/entity/vehicle/MinecartHopper.java b/net/minecraft/world/entity/vehicle/MinecartHopper.java -index 41a6ec508a10a49a37539d2f10171d15c233b280..ae6246635b7961b91a217b7f4f9d9d0f41560207 100644 ---- a/net/minecraft/world/entity/vehicle/MinecartHopper.java -+++ b/net/minecraft/world/entity/vehicle/MinecartHopper.java -@@ -101,6 +101,13 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper +diff --git a/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java b/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java +index 3c961b76769f16160caedce8ec32bb2a2561163f..f2aae7add30a7652a98693efc0275fdafa274926 100644 +--- a/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java ++++ b/net/minecraft/world/entity/vehicle/minecart/MinecartHopper.java +@@ -102,6 +102,13 @@ public class MinecartHopper extends AbstractMinecartContainer implements Hopper } } diff --git a/leaves-server/minecraft-patches/features/0075-RNG-Fishing.patch b/leaves-server/minecraft-patches/features/0074-RNG-Fishing.patch similarity index 88% rename from leaves-server/minecraft-patches/features/0075-RNG-Fishing.patch rename to leaves-server/minecraft-patches/features/0074-RNG-Fishing.patch index 1b1b08d3a..a9142e4fa 100644 --- a/leaves-server/minecraft-patches/features/0075-RNG-Fishing.patch +++ b/leaves-server/minecraft-patches/features/0074-RNG-Fishing.patch @@ -5,10 +5,10 @@ Subject: [PATCH] RNG Fishing diff --git a/net/minecraft/world/entity/projectile/FishingHook.java b/net/minecraft/world/entity/projectile/FishingHook.java -index 2c79332e148375c2f277df94b16ce7dd2422c004..a22590c8c48049733d751306a2daa5686cbcf082 100644 +index 30e3c19adcdc55fa468257037ca49275c09de324..c6e87d453bfccbd7706ec45b105e469f8a27ba99 100644 --- a/net/minecraft/world/entity/projectile/FishingHook.java +++ b/net/minecraft/world/entity/projectile/FishingHook.java -@@ -534,7 +534,7 @@ public class FishingHook extends Projectile { +@@ -531,7 +531,7 @@ public class FishingHook extends Projectile { .withLuck(this.luck + playerOwner.getLuck()) .create(LootContextParamSets.FISHING); LootTable lootTable = this.level().getServer().reloadableRegistries().getLootTable(BuiltInLootTables.FISHING); diff --git a/leaves-server/minecraft-patches/features/0076-Wool-Hopper-Counter.patch b/leaves-server/minecraft-patches/features/0075-Wool-Hopper-Counter.patch similarity index 98% rename from leaves-server/minecraft-patches/features/0076-Wool-Hopper-Counter.patch rename to leaves-server/minecraft-patches/features/0075-Wool-Hopper-Counter.patch index d2ee7d903..b02897cb9 100644 --- a/leaves-server/minecraft-patches/features/0076-Wool-Hopper-Counter.patch +++ b/leaves-server/minecraft-patches/features/0075-Wool-Hopper-Counter.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Wool Hopper Counter 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 a1799e2646569bf9db4fcdd3a9758f486f96f56e..6781a1362f4318e37cb298c232bffde5d0fe7a67 100644 +index 9b0d26b7a8c0656848cfa659065abae6fc2fdab4..e3e7d8c9e704d49d78472ac7b9239f93031d2fd1 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -206,8 +206,30 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen diff --git a/leaves-server/minecraft-patches/features/0077-Spider-jockeys-drop-gapples.patch b/leaves-server/minecraft-patches/features/0076-Spider-jockeys-drop-gapples.patch similarity index 68% rename from leaves-server/minecraft-patches/features/0077-Spider-jockeys-drop-gapples.patch rename to leaves-server/minecraft-patches/features/0076-Spider-jockeys-drop-gapples.patch index 0db309094..eb8be47f0 100644 --- a/leaves-server/minecraft-patches/features/0077-Spider-jockeys-drop-gapples.patch +++ b/leaves-server/minecraft-patches/features/0076-Spider-jockeys-drop-gapples.patch @@ -4,10 +4,10 @@ Date: Tue, 5 Sep 2023 08:49:01 +0800 Subject: [PATCH] Spider jockeys drop gapples -diff --git a/net/minecraft/world/entity/monster/Skeleton.java b/net/minecraft/world/entity/monster/Skeleton.java -index 37a60cf7b00adaadbca129659b3aea3d8f10c4e2..f1dab982211cf9e1018f98d238cea04cfd82e31b 100644 ---- a/net/minecraft/world/entity/monster/Skeleton.java -+++ b/net/minecraft/world/entity/monster/Skeleton.java +diff --git a/net/minecraft/world/entity/monster/skeleton/Skeleton.java b/net/minecraft/world/entity/monster/skeleton/Skeleton.java +index 94a01d35457053bb4265acb5542ae2f83671d9bb..f1638ebacf61d4baffea7eff60605c56ca03bb2e 100644 +--- a/net/minecraft/world/entity/monster/skeleton/Skeleton.java ++++ b/net/minecraft/world/entity/monster/skeleton/Skeleton.java @@ -130,4 +130,25 @@ public class Skeleton extends AbstractSkeleton { SoundEvent getStepSound() { return SoundEvents.SKELETON_STEP; @@ -17,7 +17,7 @@ index 37a60cf7b00adaadbca129659b3aea3d8f10c4e2..f1dab982211cf9e1018f98d238cea04c + @Override + protected void dropCustomDeathLoot(net.minecraft.server.level.ServerLevel level, DamageSource damageSource, boolean recentlyHit) { + super.dropCustomDeathLoot(level, damageSource, recentlyHit); -+ if (damageSource.getEntity() instanceof Creeper creeper && creeper.isPowered() && !creeper.droppedSkulls) { ++ if (damageSource.getEntity() instanceof net.minecraft.world.entity.monster.Creeper creeper && creeper.isPowered() && !creeper.droppedSkulls) { + creeper.droppedSkulls = true; + this.spawnAtLocation(level, net.minecraft.world.item.Items.SKELETON_SKULL); + } @@ -34,11 +34,11 @@ index 37a60cf7b00adaadbca129659b3aea3d8f10c4e2..f1dab982211cf9e1018f98d238cea04c + } + // Leaves end - spider jockeys drop gapples } -diff --git a/net/minecraft/world/entity/monster/Spider.java b/net/minecraft/world/entity/monster/Spider.java -index a0008c2c5338d442040598ee79a667060a649695..3b578eb1a4bffb790b2baec7ba35d027158ea8d2 100644 ---- a/net/minecraft/world/entity/monster/Spider.java -+++ b/net/minecraft/world/entity/monster/Spider.java -@@ -139,6 +139,18 @@ public class Spider extends Monster { +diff --git a/net/minecraft/world/entity/monster/spider/Spider.java b/net/minecraft/world/entity/monster/spider/Spider.java +index 64a84f73d48deb254345a5c25f3fe650591e64a1..c4666ab51a1c308fbd632f8b598acb847f2b3ae9 100644 +--- a/net/minecraft/world/entity/monster/spider/Spider.java ++++ b/net/minecraft/world/entity/monster/spider/Spider.java +@@ -141,6 +141,18 @@ public class Spider extends Monster { this.entityData.set(DATA_FLAGS_ID, b); } @@ -54,6 +54,6 @@ index a0008c2c5338d442040598ee79a667060a649695..3b578eb1a4bffb790b2baec7ba35d027 + } + // Leaves end - spider jockeys drop gapples + - @Nullable @Override - public SpawnGroupData finalizeSpawn( + public @Nullable SpawnGroupData finalizeSpawn( + ServerLevelAccessor level, DifficultyInstance difficulty, EntitySpawnReason spawnReason, @Nullable SpawnGroupData spawnGroupData diff --git a/leaves-server/minecraft-patches/features/0078-Force-Void-Trade.patch b/leaves-server/minecraft-patches/features/0077-Force-Void-Trade.patch similarity index 80% rename from leaves-server/minecraft-patches/features/0078-Force-Void-Trade.patch rename to leaves-server/minecraft-patches/features/0077-Force-Void-Trade.patch index baf951d6a..99eff177d 100644 --- a/leaves-server/minecraft-patches/features/0078-Force-Void-Trade.patch +++ b/leaves-server/minecraft-patches/features/0077-Force-Void-Trade.patch @@ -4,13 +4,13 @@ Date: Thu, 14 Sep 2023 20:23:03 +0800 Subject: [PATCH] Force Void Trade -diff --git a/net/minecraft/world/entity/npc/AbstractVillager.java b/net/minecraft/world/entity/npc/AbstractVillager.java -index ea7364f3cc9f339578232ba1103008a9ed50234a..99ec0cac20dac363cd5a6b97bddf900266fc4498 100644 ---- a/net/minecraft/world/entity/npc/AbstractVillager.java -+++ b/net/minecraft/world/entity/npc/AbstractVillager.java -@@ -43,6 +43,7 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa - @Nullable - protected MerchantOffers offers; +diff --git a/net/minecraft/world/entity/npc/villager/AbstractVillager.java b/net/minecraft/world/entity/npc/villager/AbstractVillager.java +index e6b79e6877b31253c065864e38b1ed62be0b0efb..e1f1e6c9a1328e6910c7c3ca06e651dd93e43d3e 100644 +--- a/net/minecraft/world/entity/npc/villager/AbstractVillager.java ++++ b/net/minecraft/world/entity/npc/villager/AbstractVillager.java +@@ -44,6 +44,7 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa + private @Nullable Player tradingPlayer; + protected @Nullable MerchantOffers offers; private final SimpleContainer inventory = new SimpleContainer(8, (org.bukkit.craftbukkit.entity.CraftAbstractVillager) this.getBukkitEntity()); // CraftBukkit - add argument + protected boolean voidTrade = false; // Leaves - force void trade @@ -18,7 +18,7 @@ index ea7364f3cc9f339578232ba1103008a9ed50234a..99ec0cac20dac363cd5a6b97bddf9002 super(type, level); @@ -144,7 +145,13 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa @Override - public void processTrade(MerchantOffer offer, @Nullable io.papermc.paper.event.player.PlayerPurchaseEvent event) { // The MerchantRecipe passed in here is the one set by the PlayerPurchaseEvent + public void processTrade(MerchantOffer offer, io.papermc.paper.event.player.@Nullable PlayerPurchaseEvent event) { // The MerchantRecipe passed in here is the one set by the PlayerPurchaseEvent if (event == null || event.willIncreaseTradeUses()) { - offer.increaseUses(); + // Leaves start - force void trade @@ -49,7 +49,7 @@ index ea7364f3cc9f339578232ba1103008a9ed50234a..99ec0cac20dac363cd5a6b97bddf9002 this.makeSound(this.getTradeUpdatedSound(!stack.isEmpty())); } } -@@ -219,6 +226,12 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa +@@ -218,6 +225,12 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa } protected void stopTrading() { @@ -62,9 +62,9 @@ index ea7364f3cc9f339578232ba1103008a9ed50234a..99ec0cac20dac363cd5a6b97bddf9002 this.setTradingPlayer(null); } -@@ -297,4 +310,10 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa +@@ -296,4 +309,10 @@ public abstract class AbstractVillager extends AgeableMob implements InventoryCa public boolean stillValid(Player player) { - return this.getTradingPlayer() == player && this.isAlive() && player.canInteractWithEntity(this, 4.0); + return this.getTradingPlayer() == player && this.isAlive() && player.isWithinEntityInteractionRange(this, 4.0); } + + // Leaves start - force void trade @@ -73,10 +73,10 @@ index ea7364f3cc9f339578232ba1103008a9ed50234a..99ec0cac20dac363cd5a6b97bddf9002 + } + // Leaves end - force void trade } -diff --git a/net/minecraft/world/entity/npc/Villager.java b/net/minecraft/world/entity/npc/Villager.java -index d10a407bef7da29a24582e48d8ee599c981384c5..9fb83137caeee95d35bce9265e1f86cef1adac0e 100644 ---- a/net/minecraft/world/entity/npc/Villager.java -+++ b/net/minecraft/world/entity/npc/Villager.java +diff --git a/net/minecraft/world/entity/npc/villager/Villager.java b/net/minecraft/world/entity/npc/villager/Villager.java +index 89844d7e804cc8a2110b694e448bc5993991bea7..681960e4453cbbe60203948b4acdebf33af7a71d 100644 +--- a/net/minecraft/world/entity/npc/villager/Villager.java ++++ b/net/minecraft/world/entity/npc/villager/Villager.java @@ -384,6 +384,7 @@ public class Villager extends AbstractVillager implements ReputationEventHandler } @@ -85,7 +85,7 @@ index d10a407bef7da29a24582e48d8ee599c981384c5..9fb83137caeee95d35bce9265e1f86ce this.updateSpecialPrices(player); this.setTradingPlayer(player); this.openTradingScreen(player, this.getDisplayName(), this.getVillagerData().level()); -@@ -623,8 +624,12 @@ public class Villager extends AbstractVillager implements ReputationEventHandler +@@ -617,8 +618,12 @@ public class Villager extends AbstractVillager implements ReputationEventHandler @Override protected void rewardTradeXp(MerchantOffer offer) { int i = 3 + this.random.nextInt(4); @@ -100,10 +100,10 @@ index d10a407bef7da29a24582e48d8ee599c981384c5..9fb83137caeee95d35bce9265e1f86ce if (this.shouldIncreaseLevel()) { this.updateMerchantTimer = 40; this.increaseProfessionLevelOnUpdate = true; -diff --git a/net/minecraft/world/entity/npc/WanderingTrader.java b/net/minecraft/world/entity/npc/WanderingTrader.java -index 4c7287c4a081b4e1f0049c8c9bdf6a42b51e8274..c87bf6a5cfaaa1a68cba6b734e67db49709c6c5b 100644 ---- a/net/minecraft/world/entity/npc/WanderingTrader.java -+++ b/net/minecraft/world/entity/npc/WanderingTrader.java +diff --git a/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java b/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java +index 3eb6ee2ffecbdeb6057d81b7936b80e205db7cdc..8de44af1247797acdb9e9307ff094a72fb662e04 100644 +--- a/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java ++++ b/net/minecraft/world/entity/npc/wanderingtrader/WanderingTrader.java @@ -124,9 +124,10 @@ public class WanderingTrader extends AbstractVillager implements Consumable.Over return InteractionResult.CONSUME; } @@ -178,18 +178,18 @@ index 6afeb92c2e00ca5b945b7c7de9257bd741d53c3d..f5b82f56a59dd150938e35dde0333e7e public void setToOutOfStock() { diff --git a/net/minecraft/world/level/block/EndGatewayBlock.java b/net/minecraft/world/level/block/EndGatewayBlock.java -index 6161cd82dade8b4119ab0b8ba84451d592ce5858..cc90b8ebfe8c5d451710c202c5e87433e2a45c7b 100644 +index 4b959091412defb5ae6ffe387f98ed1cc9a29e5f..0d9b286bcc25ad5376a7a22ae4323bd553d4da3d 100644 --- a/net/minecraft/world/level/block/EndGatewayBlock.java +++ b/net/minecraft/world/level/block/EndGatewayBlock.java -@@ -109,6 +109,17 @@ public class EndGatewayBlock extends BaseEntityBlock implements Portal { - public TeleportTransition getPortalDestination(ServerLevel level, Entity entity, BlockPos pos) { +@@ -107,6 +107,17 @@ public class EndGatewayBlock extends BaseEntityBlock implements Portal { + public @Nullable TeleportTransition getPortalDestination(ServerLevel level, Entity entity, BlockPos pos) { if (level.getBlockEntity(pos) instanceof TheEndGatewayBlockEntity theEndGatewayBlockEntity) { Vec3 portalPosition = theEndGatewayBlockEntity.getPortalPosition(level, pos); + + // Leaves start - force void trade + if (org.leavesmc.leaves.LeavesConfig.modify.forceVoidTrade && portalPosition != null && entity instanceof net.minecraft.server.level.ServerPlayer player) { + if (player.containerMenu instanceof net.minecraft.world.inventory.MerchantMenu merchantMenu) { -+ if (merchantMenu.trader instanceof net.minecraft.world.entity.npc.AbstractVillager villager) { ++ if (merchantMenu.trader instanceof net.minecraft.world.entity.npc.villager.AbstractVillager villager) { + villager.setVoidTrade(); + } + } diff --git a/leaves-server/minecraft-patches/features/0079-Villager-infinite-discounts.patch b/leaves-server/minecraft-patches/features/0078-Villager-infinite-discounts.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0079-Villager-infinite-discounts.patch rename to leaves-server/minecraft-patches/features/0078-Villager-infinite-discounts.patch diff --git a/leaves-server/minecraft-patches/features/0080-CCE-update-suppression.patch b/leaves-server/minecraft-patches/features/0079-CCE-update-suppression.patch similarity index 89% rename from leaves-server/minecraft-patches/features/0080-CCE-update-suppression.patch rename to leaves-server/minecraft-patches/features/0079-CCE-update-suppression.patch index b5f7a3b61..52cdfadb5 100644 --- a/leaves-server/minecraft-patches/features/0080-CCE-update-suppression.patch +++ b/leaves-server/minecraft-patches/features/0079-CCE-update-suppression.patch @@ -5,10 +5,10 @@ Subject: [PATCH] CCE update suppression diff --git a/net/minecraft/world/level/block/ShulkerBoxBlock.java b/net/minecraft/world/level/block/ShulkerBoxBlock.java -index ffca65d881ee6f4bde8e579d012ee5c1a11a0c2d..efb25d556f2192b1ee499c28d14aa7d11bcabef8 100644 +index 02f3e470ed70de87deeb8180f50da11724bf5198..1b6bddc15f39c381050eb20c5ad43581d471d876 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 { +@@ -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 { diff --git a/leaves-server/minecraft-patches/features/0081-Disable-offline-warn-if-use-proxy.patch b/leaves-server/minecraft-patches/features/0080-Disable-offline-warn-if-use-proxy.patch similarity index 88% rename from leaves-server/minecraft-patches/features/0081-Disable-offline-warn-if-use-proxy.patch rename to leaves-server/minecraft-patches/features/0080-Disable-offline-warn-if-use-proxy.patch index 0fb17dee1..544d39dae 100644 --- a/leaves-server/minecraft-patches/features/0081-Disable-offline-warn-if-use-proxy.patch +++ b/leaves-server/minecraft-patches/features/0080-Disable-offline-warn-if-use-proxy.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Disable offline warn if use proxy diff --git a/net/minecraft/server/dedicated/DedicatedServer.java b/net/minecraft/server/dedicated/DedicatedServer.java -index 70f0adbd01aa6aabc7b8ecc9e02dd93e2f479a69..144d1ff610d2743e554e6a4940bcb184e09c1520 100644 +index e6ad9b2a2478f768103b7829702cb25dda2cf63a..fd53f41ded5f8904e1ac8d037250709ee8c43f23 100644 --- a/net/minecraft/server/dedicated/DedicatedServer.java +++ b/net/minecraft/server/dedicated/DedicatedServer.java -@@ -335,7 +335,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface +@@ -332,7 +332,7 @@ public class DedicatedServer extends MinecraftServer implements ServerInterface String proxyFlavor = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "Velocity" : "BungeeCord"; String proxyLink = (io.papermc.paper.configuration.GlobalConfiguration.get().proxies.velocity.enabled) ? "https://docs.papermc.io/velocity/security" : "http://www.spigotmc.org/wiki/firewall-guide/"; // Paper end - Add Velocity IP Forwarding Support diff --git a/leaves-server/minecraft-patches/features/0082-Make-Item-tick-vanilla.patch b/leaves-server/minecraft-patches/features/0081-Make-Item-tick-vanilla.patch similarity index 81% rename from leaves-server/minecraft-patches/features/0082-Make-Item-tick-vanilla.patch rename to leaves-server/minecraft-patches/features/0081-Make-Item-tick-vanilla.patch index 375fee9b6..ead4fc65e 100644 --- a/leaves-server/minecraft-patches/features/0082-Make-Item-tick-vanilla.patch +++ b/leaves-server/minecraft-patches/features/0081-Make-Item-tick-vanilla.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Make Item tick vanilla diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java -index 78edda120dd53be66f3e995dcf4e62799a837532..4bd9b16ad73114c457eb5987adeb18231ec6eea7 100644 +index 41050491bde33981448b3da0290f8edfaee82c30..80f9c003b125a3af29c1456b6f796a43954a9aad 100644 --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -129,6 +129,9 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -126,6 +126,9 @@ public class ItemEntity extends Entity implements TraceableEntity { // Paper start - EAR 2 @Override public void inactiveTick() { @@ -18,7 +18,7 @@ index 78edda120dd53be66f3e995dcf4e62799a837532..4bd9b16ad73114c457eb5987adeb1823 super.inactiveTick(); if (this.pickupDelay > 0 && this.pickupDelay != 32767) { this.pickupDelay--; -@@ -146,6 +149,8 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -143,6 +146,8 @@ public class ItemEntity extends Entity implements TraceableEntity { // CraftBukkit end this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause } diff --git a/leaves-server/minecraft-patches/features/0083-Copper-Bulb-1-gt-delay.patch b/leaves-server/minecraft-patches/features/0082-Copper-Bulb-1-gt-delay.patch similarity index 96% rename from leaves-server/minecraft-patches/features/0083-Copper-Bulb-1-gt-delay.patch rename to leaves-server/minecraft-patches/features/0082-Copper-Bulb-1-gt-delay.patch index c8395c0cd..d8b164a80 100644 --- a/leaves-server/minecraft-patches/features/0083-Copper-Bulb-1-gt-delay.patch +++ b/leaves-server/minecraft-patches/features/0082-Copper-Bulb-1-gt-delay.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Copper Bulb 1 gt delay diff --git a/net/minecraft/world/level/block/CopperBulbBlock.java b/net/minecraft/world/level/block/CopperBulbBlock.java -index 54511c27d8d85f1a9702d899f1f7c7dda201cdfa..1e8e7f7081b7f9d6a9d31e6cfd5900daf0a364db 100644 +index 79ce45289d9ab81fb2cd7fdf1b32042e84a01a50..32b774ddee171387d79f7da34520996622daefa5 100644 --- a/net/minecraft/world/level/block/CopperBulbBlock.java +++ b/net/minecraft/world/level/block/CopperBulbBlock.java @@ -33,14 +33,26 @@ public class CopperBulbBlock extends Block { diff --git a/leaves-server/minecraft-patches/features/0084-Crafter-1-gt-delay.patch b/leaves-server/minecraft-patches/features/0083-Crafter-1-gt-delay.patch similarity index 86% rename from leaves-server/minecraft-patches/features/0084-Crafter-1-gt-delay.patch rename to leaves-server/minecraft-patches/features/0083-Crafter-1-gt-delay.patch index 4c4115d88..daf4a0779 100644 --- a/leaves-server/minecraft-patches/features/0084-Crafter-1-gt-delay.patch +++ b/leaves-server/minecraft-patches/features/0083-Crafter-1-gt-delay.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Crafter 1 gt delay diff --git a/net/minecraft/world/level/block/CrafterBlock.java b/net/minecraft/world/level/block/CrafterBlock.java -index 59cea0d226829267e9a5dff9f81789673bd3f062..9ff207acba5584480481e0df63ad3ca9bced0354 100644 +index 3faa541c4a4623e915269d6241e1a3a3c6e374ff..468a39219d82a665b99ac1768435557d6f3326c9 100644 --- a/net/minecraft/world/level/block/CrafterBlock.java +++ b/net/minecraft/world/level/block/CrafterBlock.java @@ -75,7 +75,7 @@ public class CrafterBlock extends BaseEntityBlock { @@ -17,9 +17,9 @@ index 59cea0d226829267e9a5dff9f81789673bd3f062..9ff207acba5584480481e0df63ad3ca9 level.setBlock(pos, state.setValue(TRIGGERED, true), Block.UPDATE_CLIENTS); this.setBlockEntityTriggered(blockEntity, true); } else if (!hasNeighborSignal && triggeredValue) { -@@ -125,7 +125,7 @@ public class CrafterBlock extends BaseEntityBlock { +@@ -124,7 +124,7 @@ public class CrafterBlock extends BaseEntityBlock { @Override - public void setPlacedBy(Level level, BlockPos pos, BlockState state, LivingEntity placer, ItemStack stack) { + public void setPlacedBy(Level level, BlockPos pos, BlockState state, @Nullable LivingEntity placer, ItemStack stack) { if (state.getValue(TRIGGERED)) { - level.scheduleTick(pos, this, 4); + level.scheduleTick(pos, this, !org.leavesmc.leaves.LeavesConfig.modify.oldMC.crafter1gt ? 4 : 1); // Leaves - crafter 1 gt delay diff --git a/leaves-server/minecraft-patches/features/0085-More-Region-Format-Support.patch b/leaves-server/minecraft-patches/features/0084-More-Region-Format-Support.patch similarity index 92% rename from leaves-server/minecraft-patches/features/0085-More-Region-Format-Support.patch rename to leaves-server/minecraft-patches/features/0084-More-Region-Format-Support.patch index 4cf609b23..996f3414e 100644 --- a/leaves-server/minecraft-patches/features/0085-More-Region-Format-Support.patch +++ b/leaves-server/minecraft-patches/features/0084-More-Region-Format-Support.patch @@ -54,10 +54,10 @@ index 51c126735ace8fdde89ad97b5cab62f244212db0..a6573e327ace16b7ea320eb1440ffcbc + public void moonrise$write(final org.leavesmc.leaves.region.IRegionFile regionFile) throws IOException; // Leaves - more region format } diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 89067dceacb1f4fb6f7acacd4ec16874da049efe..d4409971d20e19266ff80b940b05edf07e8d52e3 100644 +index 6853577d7ae7e28cf68338b4939d7b01958563d1..499fa53ef47da7e46e6646d0c88a9c51c8fea7f1 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -960,10 +960,10 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop> progressMap = Reference2FloatMaps.synchronize(new Reference2FloatOpenHashMap<>()); volatile Component status = Component.translatable("optimizeWorld.stage.counting"); @@ -83,7 +83,7 @@ index a55ae044386baa52f2c4388b4ae2f58a58469099..61d986f8865ff2d169231c6f082ba6dd final DimensionDataStorage overworldDataStorage; public WorldUpgrader( -@@ -272,7 +272,7 @@ public class WorldUpgrader implements AutoCloseable { +@@ -270,7 +270,7 @@ public class WorldUpgrader implements AutoCloseable { } private static List getAllChunkPositions(RegionStorageInfo regionStorageInfo, Path path) { @@ -92,7 +92,7 @@ index a55ae044386baa52f2c4388b4ae2f58a58469099..61d986f8865ff2d169231c6f082ba6dd if (files == null) { return List.of(); } else { -@@ -285,7 +285,7 @@ public class WorldUpgrader implements AutoCloseable { +@@ -283,7 +283,7 @@ public class WorldUpgrader implements AutoCloseable { int i1 = Integer.parseInt(matcher.group(2)) << 5; List list1 = Lists.newArrayList(); @@ -101,16 +101,16 @@ index a55ae044386baa52f2c4388b4ae2f58a58469099..61d986f8865ff2d169231c6f082ba6dd for (int i2 = 0; i2 < 32; i2++) { for (int i3 = 0; i3 < 32; i3++) { ChunkPos chunkPos = new ChunkPos(i2 + i, i3 + i1); -@@ -333,7 +333,7 @@ public class WorldUpgrader implements AutoCloseable { +@@ -331,7 +331,7 @@ public class WorldUpgrader implements AutoCloseable { - protected abstract boolean tryProcessOnePosition(T chunkStorage, ChunkPos chunkPos, ResourceKey dimension); + protected abstract boolean tryProcessOnePosition(SimpleRegionStorage regionStorage, ChunkPos chunkPos, ResourceKey dimension); - private void onFileFinished(RegionFile regionFile) { + private void onFileFinished(org.leavesmc.leaves.region.IRegionFile regionFile) { // Leaves - more region format if (WorldUpgrader.this.recreateRegionFiles) { if (this.previousWriteFuture != null) { this.previousWriteFuture.join(); -@@ -438,7 +438,7 @@ public class WorldUpgrader implements AutoCloseable { +@@ -441,7 +441,7 @@ public class WorldUpgrader implements AutoCloseable { } } @@ -120,11 +120,11 @@ index a55ae044386baa52f2c4388b4ae2f58a58469099..61d986f8865ff2d169231c6f082ba6dd class PoiUpgrader extends WorldUpgrader.SimpleRegionStorageUpgrader { diff --git a/net/minecraft/world/level/chunk/storage/RegionFile.java b/net/minecraft/world/level/chunk/storage/RegionFile.java -index 22f3aa1674664906e8ec45372d758d79017e3987..1d9b2a315d3c18df3c0dfc0e8daac18c4d7462b7 100644 +index c6adcb44bc96eaeba74bfc228a6a61765b1628e7..69580a685bae83236f8047cf6afad05958ff072c 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFile.java +++ b/net/minecraft/world/level/chunk/storage/RegionFile.java -@@ -22,7 +22,7 @@ import net.minecraft.util.profiling.jfr.JvmProfiler; - import net.minecraft.world.level.ChunkPos; +@@ -22,7 +22,7 @@ import net.minecraft.world.level.ChunkPos; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patches.chunk_system.storage.ChunkSystemRegionFile { // Paper - rewrite chunk system @@ -141,7 +141,7 @@ index 22f3aa1674664906e8ec45372d758d79017e3987..1d9b2a315d3c18df3c0dfc0e8daac18c if (!this.canRecalcHeader) { return false; } -@@ -794,7 +794,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche +@@ -791,7 +791,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche } } @@ -150,7 +150,7 @@ index 22f3aa1674664906e8ec45372d758d79017e3987..1d9b2a315d3c18df3c0dfc0e8daac18c int offsetIndex = getOffsetIndex(chunkPos); int i = this.offsets.get(offsetIndex); int sectorNumber = getSectorNumber(i); -@@ -912,7 +912,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche +@@ -909,7 +909,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche } @Override @@ -159,7 +159,7 @@ index 22f3aa1674664906e8ec45372d758d79017e3987..1d9b2a315d3c18df3c0dfc0e8daac18c regionFile.write(this.pos, ByteBuffer.wrap(this.buf, 0, this.count)); } // Paper end - rewrite chunk system -@@ -978,11 +978,11 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche +@@ -975,11 +975,11 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche return (x & 31) + (z & 31) * 32; } @@ -173,7 +173,7 @@ index 22f3aa1674664906e8ec45372d758d79017e3987..1d9b2a315d3c18df3c0dfc0e8daac18c final int offset = getChunkIndex(x, z); boolean previous = this.oversized[offset] == 1; this.oversized[offset] = (byte) (oversized ? 1 : 0); -@@ -1021,7 +1021,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche +@@ -1018,7 +1018,7 @@ public class RegionFile implements AutoCloseable, ca.spottedleaf.moonrise.patche return this.path.getParent().resolve(this.path.getFileName().toString().replaceAll("\\.mca$", "") + "_oversized_" + x + "_" + z + ".nbt"); } @@ -183,7 +183,7 @@ index 22f3aa1674664906e8ec45372d758d79017e3987..1d9b2a315d3c18df3c0dfc0e8daac18c try (DataInputStream out = new DataInputStream(new java.io.BufferedInputStream(new java.util.zip.InflaterInputStream(Files.newInputStream(file))))) { return net.minecraft.nbt.NbtIo.read((java.io.DataInput) out); diff --git a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java -index 8ea830f561f5b7d6ff6ca3c38adc7fe8e54e4cc7..1e192147ea50c4167a7bb876e3643ed770989ef3 100644 +index 1e9e061ec694ad64fc2724b83a66dfec7e069a43..a242151f911d9b8f0ae0ebfea6440ca32a5d7b7f 100644 --- a/net/minecraft/world/level/chunk/storage/RegionFileStorage.java +++ b/net/minecraft/world/level/chunk/storage/RegionFileStorage.java @@ -19,7 +19,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise @@ -314,7 +314,7 @@ index 8ea830f561f5b7d6ff6ca3c38adc7fe8e54e4cc7..1e192147ea50c4167a7bb876e3643ed7 } - @org.jetbrains.annotations.Contract("_, false -> !null") @Nullable private RegionFile getRegionFile(ChunkPos chunkPos, boolean existingOnly) throws IOException { // CraftBukkit -+ @org.jetbrains.annotations.Contract("_, false -> !null") @Nullable private org.leavesmc.leaves.region.IRegionFile getRegionFile(ChunkPos chunkPos, boolean existingOnly) throws IOException { // CraftBukkit // Leaves - more region format ++ @org.jetbrains.annotations.Contract("_, false -> !null") private org.leavesmc.leaves.region.IRegionFile getRegionFile(ChunkPos chunkPos, boolean existingOnly) throws IOException { // CraftBukkit // Leaves - more region format // Paper start - rewrite chunk system if (existingOnly) { return this.moonrise$getRegionFileIfExists(chunkPos.x, chunkPos.z); @@ -361,16 +361,16 @@ index 8ea830f561f5b7d6ff6ca3c38adc7fe8e54e4cc7..1e192147ea50c4167a7bb876e3643ed7 synchronized (regionfile) { try (DataInputStream datainputstream = regionfile.getChunkDataInputStream(chunkCoordinate)) { CompoundTag oversizedData = regionfile.getOversizedData(chunkCoordinate.x, chunkCoordinate.z); -@@ -347,7 +366,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise - @Nullable - public CompoundTag read(ChunkPos chunkPos) throws IOException { +@@ -346,7 +365,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise + + public @Nullable CompoundTag read(ChunkPos chunkPos) throws IOException { // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing - RegionFile regionFile = this.getRegionFile(chunkPos, true); + org.leavesmc.leaves.region.IRegionFile regionFile = this.getRegionFile(chunkPos, true); // Leaves - more region format if (regionFile == null) { return null; } -@@ -386,7 +405,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -385,7 +404,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise public void scanChunk(ChunkPos chunkPos, StreamTagVisitor visitor) throws IOException { // CraftBukkit start - SPIGOT-5680: There's no good reason to preemptively create files on read, save that for writing @@ -379,7 +379,7 @@ index 8ea830f561f5b7d6ff6ca3c38adc7fe8e54e4cc7..1e192147ea50c4167a7bb876e3643ed7 if (regionFile == null) { return; } -@@ -401,7 +420,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -400,7 +419,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise public void write(ChunkPos chunkPos, @Nullable CompoundTag chunkData) throws IOException { // Paper - rewrite chunk system - public if (!SharedConstants.DEBUG_DONT_SAVE_WORLD) { @@ -388,7 +388,7 @@ index 8ea830f561f5b7d6ff6ca3c38adc7fe8e54e4cc7..1e192147ea50c4167a7bb876e3643ed7 // Paper start - rewrite chunk system if (regionFile == null) { // if the RegionFile doesn't exist, no point in deleting from it -@@ -432,7 +451,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -431,7 +450,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise // Paper start - rewrite chunk system synchronized (this) { final ExceptionCollector exceptionCollector = new ExceptionCollector<>(); @@ -397,7 +397,7 @@ index 8ea830f561f5b7d6ff6ca3c38adc7fe8e54e4cc7..1e192147ea50c4167a7bb876e3643ed7 try { regionFile.close(); } catch (final IOException ex) { -@@ -448,7 +467,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise +@@ -447,7 +466,7 @@ public class RegionFileStorage implements AutoCloseable, ca.spottedleaf.moonrise // Paper start - rewrite chunk system synchronized (this) { final ExceptionCollector exceptionCollector = new ExceptionCollector<>(); diff --git a/leaves-server/minecraft-patches/features/0086-No-TNT-place-update.patch b/leaves-server/minecraft-patches/features/0085-No-TNT-place-update.patch similarity index 93% rename from leaves-server/minecraft-patches/features/0086-No-TNT-place-update.patch rename to leaves-server/minecraft-patches/features/0085-No-TNT-place-update.patch index de7604d64..06cdec1b4 100644 --- a/leaves-server/minecraft-patches/features/0086-No-TNT-place-update.patch +++ b/leaves-server/minecraft-patches/features/0085-No-TNT-place-update.patch @@ -5,7 +5,7 @@ Subject: [PATCH] No TNT place update diff --git a/net/minecraft/world/level/block/TntBlock.java b/net/minecraft/world/level/block/TntBlock.java -index 938dbdbbaa90181865ad9f19446c99cf301ab653..0862ef425b518e8d322f9fa7d9a3aacdd03f8237 100644 +index 00da328f21e5ce5de6f968323b14a7832a6cbd62..03aaf2ced00873f74fa15cb72cd2cf88fa1a8651 100644 --- a/net/minecraft/world/level/block/TntBlock.java +++ b/net/minecraft/world/level/block/TntBlock.java @@ -47,7 +47,7 @@ public class TntBlock extends Block { diff --git a/leaves-server/minecraft-patches/features/0087-Servux-Protocol.patch b/leaves-server/minecraft-patches/features/0086-Servux-Protocol.patch similarity index 92% rename from leaves-server/minecraft-patches/features/0087-Servux-Protocol.patch rename to leaves-server/minecraft-patches/features/0086-Servux-Protocol.patch index c5cb3241c..a97e6cce4 100644 --- a/leaves-server/minecraft-patches/features/0087-Servux-Protocol.patch +++ b/leaves-server/minecraft-patches/features/0086-Servux-Protocol.patch @@ -20,10 +20,10 @@ index 4257c47d33e3773fac766817138cc21c55d9ab76..8638f3f7aa853802a60ddeb681d089e0 + // Leaves end - servux } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index ead3e1d538f138dc5370db49d8b4293aff376d46..dbebfec31e8bd9b9ea6bbf486875396fdcba93b6 100644 +index 499714800b2160cf163fc7a37e287f655a9d80ee..81094f0ab63dfb48f7ae9a529d407dec5e356626 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -2285,9 +2285,21 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2316,9 +2316,21 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper end } diff --git a/leaves-server/minecraft-patches/features/0088-Placing-locked-hopper-no-longer-send-NC-updates.patch b/leaves-server/minecraft-patches/features/0087-Placing-locked-hopper-no-longer-send-NC-updates.patch similarity index 83% rename from leaves-server/minecraft-patches/features/0088-Placing-locked-hopper-no-longer-send-NC-updates.patch rename to leaves-server/minecraft-patches/features/0087-Placing-locked-hopper-no-longer-send-NC-updates.patch index 87b7e1947..5bb9caba2 100644 --- a/leaves-server/minecraft-patches/features/0088-Placing-locked-hopper-no-longer-send-NC-updates.patch +++ b/leaves-server/minecraft-patches/features/0087-Placing-locked-hopper-no-longer-send-NC-updates.patch @@ -5,13 +5,13 @@ Subject: [PATCH] Placing locked hopper no longer send NC updates diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 48eca978dc58c3c2045c5746aac5d7f5b732ff89..07ab2907bb9e4de5810889bec6d2b08f9abfec0c 100644 +index 6c60317613df508b593cc1cfa4f62b0ca303ed93..6b9f1e5421a66c0a42f93c66a61c0fbecc913a16 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -1164,7 +1164,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1170,7 +1170,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl } - if ((flags & 1) != 0) { + if ((flags & Block.UPDATE_NEIGHBORS) != 0) { - this.updateNeighborsAt(pos, blockState.getBlock()); + // Leaves start - Placing locked hopper doesn't send NC updates. + if (!(blockState.getBlock() instanceof net.minecraft.world.level.block.HopperBlock) || blockState.getValue(net.minecraft.world.level.block.HopperBlock.ENABLED)) { diff --git a/leaves-server/minecraft-patches/features/0089-Renewable-deepslate.patch b/leaves-server/minecraft-patches/features/0088-Renewable-deepslate.patch similarity index 85% rename from leaves-server/minecraft-patches/features/0089-Renewable-deepslate.patch rename to leaves-server/minecraft-patches/features/0088-Renewable-deepslate.patch index 0435d6523..3edc5355a 100644 --- a/leaves-server/minecraft-patches/features/0089-Renewable-deepslate.patch +++ b/leaves-server/minecraft-patches/features/0088-Renewable-deepslate.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Renewable deepslate diff --git a/net/minecraft/world/level/block/LiquidBlock.java b/net/minecraft/world/level/block/LiquidBlock.java -index 70cb8b2cf79833d8b5f9cee6d9c5495e5b706078..24e0484f0570d071c9ccdc67250a2b5ecd112dfd 100644 +index 1f62dcf2709d430e996790750a691b12938eb09a..2d6f4579fa27b0f9117abf13671a47576fffb155 100644 --- a/net/minecraft/world/level/block/LiquidBlock.java +++ b/net/minecraft/world/level/block/LiquidBlock.java @@ -196,7 +196,7 @@ public class LiquidBlock extends Block implements BucketPickup { @@ -15,18 +15,18 @@ index 70cb8b2cf79833d8b5f9cee6d9c5495e5b706078..24e0484f0570d071c9ccdc67250a2b5e - Block block = level.getFluidState(pos).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE; + Block block = level.getFluidState(pos).isSource() ? Blocks.OBSIDIAN : (org.leavesmc.leaves.LeavesConfig.modify.renewableDeepslate && level.dimension() == Level.OVERWORLD && pos.getY() < 0 ? Blocks.COBBLED_DEEPSLATE : Blocks.COBBLESTONE); // Leaves - renewable deepslate // CraftBukkit start - if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, block.defaultBlockState(), 3)) { + if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level, pos, block.defaultBlockState(), Block.UPDATE_ALL)) { this.fizz(level, pos); diff --git a/net/minecraft/world/level/material/LavaFluid.java b/net/minecraft/world/level/material/LavaFluid.java -index 6f9e277f8ec94169e2ff8b70b63d5ef52729b069..371b864b85da51a0444cafc4b127ff8f036c7f1b 100644 +index a42878c191445ba4b0d50dd2b789a132d5cf6a3e..69ea51ee111b9595a234c9f8177f35147be35b94 100644 --- a/net/minecraft/world/level/material/LavaFluid.java +++ b/net/minecraft/world/level/material/LavaFluid.java -@@ -226,7 +226,7 @@ public abstract class LavaFluid extends FlowingFluid { +@@ -224,7 +224,7 @@ public abstract class LavaFluid extends FlowingFluid { if (this.is(FluidTags.LAVA) && fluidState1.is(FluidTags.WATER)) { if (state.getBlock() instanceof LiquidBlock) { // CraftBukkit start -- if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level.getMinecraftWorld(), pos, Blocks.STONE.defaultBlockState(), 3)) { -+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level.getMinecraftWorld(), pos, org.leavesmc.leaves.LeavesConfig.modify.renewableDeepslate && level.getMinecraftWorld().dimension() == Level.OVERWORLD && pos.getY() < 0 ? Blocks.DEEPSLATE.defaultBlockState() : Blocks.STONE.defaultBlockState(), 3)) { // Leaves - renewable deepslate +- if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level.getMinecraftWorld(), pos, Blocks.STONE.defaultBlockState(), Block.UPDATE_ALL)) { ++ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(level.getMinecraftWorld(), pos, org.leavesmc.leaves.LeavesConfig.modify.renewableDeepslate && level.getMinecraftWorld().dimension() == Level.OVERWORLD && pos.getY() < 0 ? Blocks.DEEPSLATE.defaultBlockState() : Blocks.STONE.defaultBlockState(), Block.UPDATE_ALL)) { // Leaves - renewable deepslate return; } // CraftBukkit end diff --git a/leaves-server/minecraft-patches/features/0090-Renewable-sponges.patch b/leaves-server/minecraft-patches/features/0089-Renewable-sponges.patch similarity index 85% rename from leaves-server/minecraft-patches/features/0090-Renewable-sponges.patch rename to leaves-server/minecraft-patches/features/0089-Renewable-sponges.patch index 460d44d0b..3cffd46f9 100644 --- a/leaves-server/minecraft-patches/features/0090-Renewable-sponges.patch +++ b/leaves-server/minecraft-patches/features/0089-Renewable-sponges.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Renewable sponges diff --git a/net/minecraft/world/entity/monster/Guardian.java b/net/minecraft/world/entity/monster/Guardian.java -index c907feb2ab6862d980f89f6341402131a8a966f2..daad38e533360501529f2f7a0bdfee213ac56ca6 100644 +index 8229de18fbac59493b377b12a281f3f4d74731d7..df574ab74cea4f2fbe83815983d65498a5fcba61 100644 --- a/net/minecraft/world/entity/monster/Guardian.java +++ b/net/minecraft/world/entity/monster/Guardian.java -@@ -453,6 +453,28 @@ public class Guardian extends Monster { +@@ -446,6 +446,28 @@ public class Guardian extends Monster { } } @@ -18,7 +18,7 @@ index c907feb2ab6862d980f89f6341402131a8a966f2..daad38e533360501529f2f7a0bdfee21 + if (org.leavesmc.leaves.LeavesConfig.modify.renewableSponges && !this.isRemoved() && !(this instanceof ElderGuardian)) { + ElderGuardian elderGuardian = new ElderGuardian(EntityType.ELDER_GUARDIAN ,this.level()); + elderGuardian.snapTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot()); -+ elderGuardian.finalizeSpawn(level ,this.level().getCurrentDifficultyAt(elderGuardian.blockPosition()), EntitySpawnReason.CONVERSION, null); ++ elderGuardian.finalizeSpawn(level ,this.level().getMinecraftWorld().getCurrentDifficultyAt(elderGuardian.blockPosition()), EntitySpawnReason.CONVERSION, null); + elderGuardian.setNoAi(this.isNoAi()); + + if (this.hasCustomName()) { diff --git a/leaves-server/minecraft-patches/features/0091-Renewable-coral.patch b/leaves-server/minecraft-patches/features/0090-Renewable-coral.patch similarity index 94% rename from leaves-server/minecraft-patches/features/0091-Renewable-coral.patch rename to leaves-server/minecraft-patches/features/0090-Renewable-coral.patch index 7ea5639c1..d618d0d66 100644 --- a/leaves-server/minecraft-patches/features/0091-Renewable-coral.patch +++ b/leaves-server/minecraft-patches/features/0090-Renewable-coral.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Renewable coral diff --git a/net/minecraft/world/level/block/CoralFanBlock.java b/net/minecraft/world/level/block/CoralFanBlock.java -index a10af527340d26b9cfd59f73a2518ce31ea5c464..5beaa24e96f3057cfd38df691306c78fcedf669c 100644 +index 2a48b215fde808fdc6b36a5d8fe88c7ae56c9567..4aa97ca825604478e2a86e655c6cf6cb4e0db336 100644 --- a/net/minecraft/world/level/block/CoralFanBlock.java +++ b/net/minecraft/world/level/block/CoralFanBlock.java @@ -13,7 +13,7 @@ import net.minecraft.world.level.block.state.BlockBehaviour; @@ -30,7 +30,7 @@ index a10af527340d26b9cfd59f73a2518ce31ea5c464..5beaa24e96f3057cfd38df691306c78f + // Leaves end - renewable coral } diff --git a/net/minecraft/world/level/block/CoralPlantBlock.java b/net/minecraft/world/level/block/CoralPlantBlock.java -index 20396db7afb93bc8ea5b7ae28a76ca82bd1a4535..9fc66adcb3ffdbfee5ad6b76a01e396634a6f4e5 100644 +index b66a3e6e109cab913ff2593accaea04110d66094..128f768ec5c194b697796ac7f2f8b55229f5a4be 100644 --- a/net/minecraft/world/level/block/CoralPlantBlock.java +++ b/net/minecraft/world/level/block/CoralPlantBlock.java @@ -16,7 +16,7 @@ import net.minecraft.world.level.material.Fluids; @@ -56,7 +56,7 @@ index 20396db7afb93bc8ea5b7ae28a76ca82bd1a4535..9fc66adcb3ffdbfee5ad6b76a01e3966 + // Leaves end - renewable coral } diff --git a/net/minecraft/world/level/block/CoralWallFanBlock.java b/net/minecraft/world/level/block/CoralWallFanBlock.java -index af0cc07404032032211ca4e377e8af681af2d7ab..7a0033ebce5f5058f331b32bb57e5f586a3d9d21 100644 +index 2d34d3e7a39a27b1756573d16ec0f8878ab8f620..b702c69f881a56a8d9cd48cf017ea8c0392720fd 100644 --- a/net/minecraft/world/level/block/CoralWallFanBlock.java +++ b/net/minecraft/world/level/block/CoralWallFanBlock.java @@ -13,7 +13,7 @@ import net.minecraft.world.level.block.state.BlockBehaviour; @@ -81,7 +81,7 @@ index af0cc07404032032211ca4e377e8af681af2d7ab..7a0033ebce5f5058f331b32bb57e5f58 + // Leaves end - renewable coral } diff --git a/net/minecraft/world/level/levelgen/feature/CoralClawFeature.java b/net/minecraft/world/level/levelgen/feature/CoralClawFeature.java -index abb8519ede1c2271c98497a8e3336f0ad89c340d..f5009d112b32ce91296ed84310bb9bf48bc0e408 100644 +index 19c810d820a559afdc8fac399e4021121063c2ff..d848f5e19347e69776b99d9feade002d66774513 100644 --- a/net/minecraft/world/level/levelgen/feature/CoralClawFeature.java +++ b/net/minecraft/world/level/levelgen/feature/CoralClawFeature.java @@ -17,7 +17,7 @@ public class CoralClawFeature extends CoralFeature { @@ -94,7 +94,7 @@ index abb8519ede1c2271c98497a8e3336f0ad89c340d..f5009d112b32ce91296ed84310bb9bf4 return false; } else { diff --git a/net/minecraft/world/level/levelgen/feature/CoralFeature.java b/net/minecraft/world/level/levelgen/feature/CoralFeature.java -index 2569754d96694edbc1fe64e6048d6ec26cbe243e..88d38433ffb78fbdd04d9adf53d584c492dc8ec7 100644 +index 53e2f2f05368949365b9690fc16bc21efabb50bb..b8475b55b3d7aa65125ecf9460a5c9c4e1261225 100644 --- a/net/minecraft/world/level/levelgen/feature/CoralFeature.java +++ b/net/minecraft/world/level/levelgen/feature/CoralFeature.java @@ -31,7 +31,7 @@ public abstract class CoralFeature extends Feature { diff --git a/leaves-server/minecraft-patches/features/0092-Vanilla-hopper.patch b/leaves-server/minecraft-patches/features/0091-Vanilla-hopper.patch similarity index 98% rename from leaves-server/minecraft-patches/features/0092-Vanilla-hopper.patch rename to leaves-server/minecraft-patches/features/0091-Vanilla-hopper.patch index 55c20449e..092459488 100644 --- a/leaves-server/minecraft-patches/features/0092-Vanilla-hopper.patch +++ b/leaves-server/minecraft-patches/features/0091-Vanilla-hopper.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Vanilla hopper This is a temporary solution designed to attempt to restore the vanilla behavior of the funnel while preserving optimizations as much as possible. It should ultimately be replaced by the optimization solution provided by lithium. diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index 6781a1362f4318e37cb298c232bffde5d0fe7a67..6b432c555d380098b07ba53039a9b148b2571de2 100644 +index e3e7d8c9e704d49d78472ac7b9239f93031d2fd1..47cff0e87dc9c6de280b1c59a7a2f83d5571a303 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -308,36 +308,58 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen diff --git a/leaves-server/minecraft-patches/features/0093-Old-hopper-suckin-behavior.patch b/leaves-server/minecraft-patches/features/0092-Old-hopper-suckin-behavior.patch similarity index 92% rename from leaves-server/minecraft-patches/features/0093-Old-hopper-suckin-behavior.patch rename to leaves-server/minecraft-patches/features/0092-Old-hopper-suckin-behavior.patch index 9e83af3c6..b9ca5cf68 100644 --- a/leaves-server/minecraft-patches/features/0093-Old-hopper-suckin-behavior.patch +++ b/leaves-server/minecraft-patches/features/0092-Old-hopper-suckin-behavior.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Old hopper suckin behavior diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index 6b432c555d380098b07ba53039a9b148b2571de2..a7ade5f683e43463f9ea42ad6843e9c80f2fa46c 100644 +index 47cff0e87dc9c6de280b1c59a7a2f83d5571a303..4876c725872674899252d3338868c696eaf31f45 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java @@ -630,7 +630,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen diff --git a/leaves-server/minecraft-patches/features/0094-Fix-falling-block-s-block-location.patch b/leaves-server/minecraft-patches/features/0093-Fix-falling-block-s-block-location.patch similarity index 87% rename from leaves-server/minecraft-patches/features/0094-Fix-falling-block-s-block-location.patch rename to leaves-server/minecraft-patches/features/0093-Fix-falling-block-s-block-location.patch index 9c63574f1..42f099b6c 100644 --- a/leaves-server/minecraft-patches/features/0094-Fix-falling-block-s-block-location.patch +++ b/leaves-server/minecraft-patches/features/0093-Fix-falling-block-s-block-location.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix falling block's block location diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index d2fafdbce9fe1db0451bb4ad819d8e075122530e..a18f2f0d1df0fecb6f8b22a252d7a6d715eb8439 100644 +index 943dab97a4e22797664554b8cbcf1cb7603de12f..0c38341119ba2cc1850ffd0726396f3e4ee0ec17 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -5052,6 +5052,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -5080,6 +5080,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name int floor = Mth.floor(x); int floor1 = Mth.floor(y); int floor2 = Mth.floor(z); diff --git a/leaves-server/minecraft-patches/features/0094-Bytebuf-API.patch b/leaves-server/minecraft-patches/features/0094-Bytebuf-API.patch new file mode 100644 index 000000000..b0039046e --- /dev/null +++ b/leaves-server/minecraft-patches/features/0094-Bytebuf-API.patch @@ -0,0 +1,24 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Lumine1909 <133463833+Lumine1909@users.noreply.github.com> +Date: Thu, 6 Feb 2025 00:14:22 +0800 +Subject: [PATCH] Bytebuf API + + +diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java +index dc27a7b11c72ff0d184580edf4ac1376fda86f7c..231387831280f24e9e50ee94aaacbd10d1532979 100644 +--- a/net/minecraft/server/players/PlayerList.java ++++ b/net/minecraft/server/players/PlayerList.java +@@ -294,6 +294,13 @@ public abstract class PlayerList { + serverGamePacketListenerImpl + ); + serverGamePacketListenerImpl.suspendFlushing(); ++ ++ // Leaves start - Bytebuf API ++ if (!(player instanceof org.leavesmc.leaves.bot.ServerBot) && !(player instanceof org.leavesmc.leaves.replay.ServerPhotographer)) { ++ org.leavesmc.leaves.bytebuf.internal.InternalBytebufHandler.updatePlayer(player); ++ } ++ // Leaves end - Bytebuf API ++ + GameRules gameRules = serverLevel.getGameRules(); + boolean flag = gameRules.get(GameRules.IMMEDIATE_RESPAWN); + boolean flag1 = gameRules.get(GameRules.REDUCED_DEBUG_INFO); diff --git a/leaves-server/minecraft-patches/features/0095-Bytebuf-API.patch b/leaves-server/minecraft-patches/features/0095-Bytebuf-API.patch deleted file mode 100644 index be982d40a..000000000 --- a/leaves-server/minecraft-patches/features/0095-Bytebuf-API.patch +++ /dev/null @@ -1,24 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Lumine1909 <133463833+Lumine1909@users.noreply.github.com> -Date: Thu, 6 Feb 2025 00:14:22 +0800 -Subject: [PATCH] Bytebuf API - - -diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index b6e4a227d49ca97e8482c56ea0819a030b52097c..7f21903070ab733249441e796a1faa5adf873ffb 100644 ---- a/net/minecraft/server/players/PlayerList.java -+++ b/net/minecraft/server/players/PlayerList.java -@@ -289,6 +289,13 @@ public abstract class PlayerList { - boolean _boolean = gameRules.getBoolean(GameRules.RULE_DO_IMMEDIATE_RESPAWN); - boolean _boolean1 = gameRules.getBoolean(GameRules.RULE_REDUCEDDEBUGINFO); - boolean _boolean2 = gameRules.getBoolean(GameRules.RULE_LIMITED_CRAFTING); -+ -+ // Leaves start - Bytebuf API -+ if (!(player instanceof org.leavesmc.leaves.bot.ServerBot) && !(player instanceof org.leavesmc.leaves.replay.ServerPhotographer)) { -+ this.cserver.getBytebufHandler().injectPlayer(player); -+ } -+ // Leaves end - Bytebuf API -+ - serverGamePacketListenerImpl.send( - new ClientboundLoginPacket( - player.getId(), diff --git a/leaves-server/minecraft-patches/features/0097-Configurable-MC-67.patch b/leaves-server/minecraft-patches/features/0095-Configurable-MC-67.patch similarity index 85% rename from leaves-server/minecraft-patches/features/0097-Configurable-MC-67.patch rename to leaves-server/minecraft-patches/features/0095-Configurable-MC-67.patch index 2add63ce2..8004cc11f 100644 --- a/leaves-server/minecraft-patches/features/0097-Configurable-MC-67.patch +++ b/leaves-server/minecraft-patches/features/0095-Configurable-MC-67.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Configurable MC-67 diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index a18f2f0d1df0fecb6f8b22a252d7a6d715eb8439..8bd5f957d61c429cf75e5a14296f735c33149e39 100644 +index 0c38341119ba2cc1850ffd0726396f3e4ee0ec17..64ab6dd069f423595a66769f255fba828ad20574 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -4245,6 +4245,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4265,6 +4265,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } public boolean canTeleport(Level fromLevel, Level toLevel) { diff --git a/leaves-server/minecraft-patches/features/0096-Allow-grindstone-overstacking.patch b/leaves-server/minecraft-patches/features/0096-Allow-grindstone-overstacking.patch deleted file mode 100644 index eccf9e8a8..000000000 --- a/leaves-server/minecraft-patches/features/0096-Allow-grindstone-overstacking.patch +++ /dev/null @@ -1,164 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Lumine1909 <133463833+lumine1909@users.noreply.github.com> -Date: Wed, 26 Jun 2024 17:59:56 +0800 -Subject: [PATCH] Allow grindstone overstacking - - -diff --git a/net/minecraft/world/SimpleContainer.java b/net/minecraft/world/SimpleContainer.java -index 75170c8d3be477a6ea2a1d62018a6ab630b0e54e..e5f348daf1ae9e604ae12928e5c8618c4803bd70 100644 ---- a/net/minecraft/world/SimpleContainer.java -+++ b/net/minecraft/world/SimpleContainer.java -@@ -211,6 +211,12 @@ public class SimpleContainer implements Container, StackedContentsCompatible { - @Override - public void setItem(int index, ItemStack stack) { - this.items.set(index, stack); -+ // Leaves end - grindstone overstacking -+ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && org.leavesmc.leaves.util.ItemOverstackUtils.CurseEnchantedBook.isCursedEnchantedBook(stack)) { -+ this.setChanged(); -+ return; -+ } -+ // Leaves end - grindstone overstacking - stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - item over-stack util - this.setChanged(); - } -diff --git a/net/minecraft/world/entity/vehicle/ContainerEntity.java b/net/minecraft/world/entity/vehicle/ContainerEntity.java -index 358de981544b220bde770410c24e5f6b10520d91..d079513d0fcafc1f9d0b6384602d0d3f4093b9db 100644 ---- a/net/minecraft/world/entity/vehicle/ContainerEntity.java -+++ b/net/minecraft/world/entity/vehicle/ContainerEntity.java -@@ -163,6 +163,11 @@ public interface ContainerEntity extends Container, MenuProvider { - default void setChestVehicleItem(int slot, ItemStack stack) { - this.unpackChestVehicleLootTable(null); - this.getItemStacks().set(slot, stack); -+ // Leaves end - grindstone overstacking -+ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && org.leavesmc.leaves.util.ItemOverstackUtils.CurseEnchantedBook.isCursedEnchantedBook(stack)) { -+ return; -+ } -+ // Leaves end - grindstone overstacking - stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - item over-stack util - } - -diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java -index e78baa9433b6f5cb32142fe583fe95831b173d5a..509d368f7fa9e6330da02615d7bf78debb932623 100644 ---- a/net/minecraft/world/inventory/AbstractContainerMenu.java -+++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -607,7 +607,7 @@ public abstract class AbstractContainerMenu { - } else if (carried.isEmpty()) { - if (slot.mayPlace(item)) { - int maxStackSize = slot.getMaxStackSize(item); -- if (item.getCount() > maxStackSize) { -+ if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && item.getCount() > maxStackSize) { // Leaves - grindstone overstacking - slot.setByPlayer(item.split(maxStackSize)); - } else { - inventory.setItem(button, ItemStack.EMPTY); -@@ -616,7 +616,7 @@ public abstract class AbstractContainerMenu { - } - } else if (slot.mayPickup(player) && slot.mayPlace(item)) { - int maxStackSize = slot.getMaxStackSize(item); -- if (item.getCount() > maxStackSize) { -+ if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && item.getCount() > maxStackSize) { // Leaves - grindstone overstacking - slot.setByPlayer(item.split(maxStackSize)); - slot.onTake(player, carried); - if (!inventory.add(carried)) { -@@ -776,10 +776,15 @@ public abstract class AbstractContainerMenu { - public abstract boolean stillValid(Player player); - - protected boolean moveItemStackTo(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection) { -+ // Leaves start - Add force move - // Paper start - Add PlayerTradeEvent and PlayerPurchaseEvent - return this.moveItemStackTo(stack, startIndex, endIndex, reverseDirection, false); - } - protected boolean moveItemStackTo(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection, boolean isCheck) { -+ return this.moveItemStackTo(stack, startIndex, endIndex, reverseDirection, isCheck, false); -+ } -+ protected boolean moveItemStackTo(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection, boolean isCheck, boolean forceMove) { -+ // Leaves end - Add force move - if (isCheck) { - stack = stack.copy(); - } -@@ -844,6 +849,14 @@ public abstract class AbstractContainerMenu { - // Paper end - Add PlayerTradeEvent and PlayerPurchaseEvent - if (itemx.isEmpty() && slotx.mayPlace(stack)) { - int i1 = slotx.getMaxStackSize(stack); -+ // Leaves start - Add force move -+ if (forceMove) { -+ slotx.setByPlayer(stack.split(stack.getCount())); -+ slotx.setChanged(); -+ flag = true; -+ break; -+ } -+ // Leaves end - Add force move - // Paper start - Add PlayerTradeEvent and PlayerPurchaseEvent - if (isCheck) { - stack.shrink(Math.min(stack.getCount(), i1)); -diff --git a/net/minecraft/world/inventory/GrindstoneMenu.java b/net/minecraft/world/inventory/GrindstoneMenu.java -index ad70a0f7debee27d9f3b2ff39cb0429b39485190..c8d3a8b9087460b20547dc49c1bf70bda87c218d 100644 ---- a/net/minecraft/world/inventory/GrindstoneMenu.java -+++ b/net/minecraft/world/inventory/GrindstoneMenu.java -@@ -179,7 +179,7 @@ public class GrindstoneMenu extends AbstractContainerMenu { - int i2 = i + i1 + max * 5 / 100; - int i3 = 1; - if (!inputItem.isDamageableItem()) { -- if (inputItem.getMaxStackSize() < 2 || !ItemStack.matches(inputItem, additionalItem)) { -+ if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && inputItem.getMaxStackSize() < 2 || !ItemStack.matches(inputItem, additionalItem)) { // Leaves - allowGrindstoneOverstaking - return ItemStack.EMPTY; - } - -@@ -248,7 +248,7 @@ public class GrindstoneMenu extends AbstractContainerMenu { - ItemStack item1 = this.repairSlots.getItem(0); - ItemStack item2 = this.repairSlots.getItem(1); - if (slotIndex == 2) { -- if (!this.moveItemStackTo(item, 3, 39, true)) { -+ if (!this.moveItemStackTo(item, 3, 39, true, false, org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking)) { // Leaves - allowGrindstoneOverstacking: Disable stack check - return ItemStack.EMPTY; - } - -diff --git a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -index 8a93c4b9571b3088dc92317544d209603880d3fa..005fd35dcae20d404922ef797cf22ef69ecd6c3a 100644 ---- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -+++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -@@ -410,7 +410,11 @@ 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); -- stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - item over-stack util -+ // Leaves end - grindstone overstacking -+ if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking || !org.leavesmc.leaves.util.ItemOverstackUtils.CurseEnchantedBook.isCursedEnchantedBook(itemStack)) { -+ stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - item over-stack util -+ } -+ // Leaves end - grindstone overstacking - if (index == 0 && !flag && this.level instanceof ServerLevel serverLevel) { - 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 701a12db0c342c9ff2c974e581b112182dec2ea6..1e6819928ffab524197003bd9469adb3976dce3a 100644 ---- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -+++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -@@ -149,6 +149,12 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co - @Override - public void setItem(int slot, ItemStack stack) { - this.getItems().set(slot, stack); -+ // Leaves end - grindstone overstacking -+ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && org.leavesmc.leaves.util.ItemOverstackUtils.CurseEnchantedBook.isCursedEnchantedBook(stack)) { -+ this.setChanged(); -+ return; -+ } -+ // Leaves end - grindstone overstacking - stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - item over-stack util - this.setChanged(); - } -diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index a7ade5f683e43463f9ea42ad6843e9c80f2fa46c..83a8dc51d0346fb5b28922e7b54d5ee58b315228 100644 ---- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java -+++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -@@ -114,6 +114,11 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen - public void setItem(int index, ItemStack stack) { - this.unpackLootTable(null); - this.getItems().set(index, stack); -+ // Leaves end - grindstone overstacking -+ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && org.leavesmc.leaves.util.ItemOverstackUtils.CurseEnchantedBook.isCursedEnchantedBook(stack)) { -+ return; -+ } -+ // Leaves end - grindstone overstacking - stack.limitSize(this.getMaxStackLeaves(stack)); // Leaves - item over-stack util - } - diff --git a/leaves-server/minecraft-patches/features/0098-Disable-end-gateway-portal-entity-ticking.patch b/leaves-server/minecraft-patches/features/0096-Disable-end-gateway-portal-entity-ticking.patch similarity index 92% rename from leaves-server/minecraft-patches/features/0098-Disable-end-gateway-portal-entity-ticking.patch rename to leaves-server/minecraft-patches/features/0096-Disable-end-gateway-portal-entity-ticking.patch index cf89683dc..4713ecb65 100644 --- a/leaves-server/minecraft-patches/features/0098-Disable-end-gateway-portal-entity-ticking.patch +++ b/leaves-server/minecraft-patches/features/0096-Disable-end-gateway-portal-entity-ticking.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Disable end gateway portal entity ticking diff --git a/net/minecraft/world/level/block/EndGatewayBlock.java b/net/minecraft/world/level/block/EndGatewayBlock.java -index f22d502df5f444703a248fff50c864d2924c4549..356f074106d416c7e5b2524490a51cc83931c114 100644 +index 0d9b286bcc25ad5376a7a22ae4323bd553d4da3d..e37f1e07656bdec2fe51223bda7cce1e13a616cd 100644 --- a/net/minecraft/world/level/block/EndGatewayBlock.java +++ b/net/minecraft/world/level/block/EndGatewayBlock.java -@@ -123,11 +123,14 @@ public class EndGatewayBlock extends BaseEntityBlock implements Portal { +@@ -121,11 +121,14 @@ public class EndGatewayBlock extends BaseEntityBlock implements Portal { if (portalPosition == null) { return null; } else { diff --git a/leaves-server/minecraft-patches/features/0099-Disable-crystal-portal-proximity-check.patch b/leaves-server/minecraft-patches/features/0097-Disable-crystal-portal-proximity-check.patch similarity index 92% rename from leaves-server/minecraft-patches/features/0099-Disable-crystal-portal-proximity-check.patch rename to leaves-server/minecraft-patches/features/0097-Disable-crystal-portal-proximity-check.patch index eb5ce0031..87e2ae546 100644 --- a/leaves-server/minecraft-patches/features/0099-Disable-crystal-portal-proximity-check.patch +++ b/leaves-server/minecraft-patches/features/0097-Disable-crystal-portal-proximity-check.patch @@ -27,10 +27,10 @@ index 05ec512839898f96d9769bb0d00f6ba11dda0c4b..27b225344c34e561d4913b3a6ca1c4a4 } diff --git a/net/minecraft/world/level/dimension/end/EndDragonFight.java b/net/minecraft/world/level/dimension/end/EndDragonFight.java -index d2e49f8490bff739a3726e73a303b2c24c47617f..5a616d89522aacd1230e356197dec49abcfef872 100644 +index 82d40effe5e8dafec60c25b97f45c1188d0e6d28..049cdeb156aedfa36a15d7ebb7a641909a05edef 100644 --- a/net/minecraft/world/level/dimension/end/EndDragonFight.java +++ b/net/minecraft/world/level/dimension/end/EndDragonFight.java -@@ -577,12 +577,14 @@ public class EndDragonFight { +@@ -571,12 +571,14 @@ public class EndDragonFight { } public boolean tryRespawn() { // CraftBukkit - return boolean @@ -45,7 +45,7 @@ index d2e49f8490bff739a3726e73a303b2c24c47617f..5a616d89522aacd1230e356197dec49a if (this.dragonKilled && this.respawnStage == null) { BlockPos blockPos = this.portalLocation; if (blockPos == null) { -@@ -597,6 +599,7 @@ public class EndDragonFight { +@@ -591,6 +593,7 @@ public class EndDragonFight { blockPos = this.portalLocation; } @@ -53,7 +53,7 @@ index d2e49f8490bff739a3726e73a303b2c24c47617f..5a616d89522aacd1230e356197dec49a // Paper start - Perf: Do crystal-portal proximity check before entity lookup if (placedEndCrystalPos != null && !level.paperConfig().misc.allowRemoteEnderDragonRespawning) { // The end crystal must be 0 or 1 higher than the portal origin -@@ -612,7 +615,7 @@ public class EndDragonFight { +@@ -606,7 +609,7 @@ public class EndDragonFight { } } // Paper end - Perf: Do crystal-portal proximity check before entity lookup diff --git a/leaves-server/minecraft-patches/features/0100-Can-disable-LivingEntity-aiStep-alive-check.patch b/leaves-server/minecraft-patches/features/0098-Can-disable-LivingEntity-aiStep-alive-check.patch similarity index 82% rename from leaves-server/minecraft-patches/features/0100-Can-disable-LivingEntity-aiStep-alive-check.patch rename to leaves-server/minecraft-patches/features/0098-Can-disable-LivingEntity-aiStep-alive-check.patch index ec69cbd8a..674cf6ada 100644 --- a/leaves-server/minecraft-patches/features/0100-Can-disable-LivingEntity-aiStep-alive-check.patch +++ b/leaves-server/minecraft-patches/features/0098-Can-disable-LivingEntity-aiStep-alive-check.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Can disable LivingEntity aiStep alive check diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 1a7135f2fda41265c75448e8ca9fec1c64de8e97..0f2a3002ec01451e92b3e4869373a910be6ccab2 100644 +index 411b5623511a2b3d0205a98f9ba6db43a630fed3..7703fb2264ddf66f36b114af63ab6e2f1f5e75fa 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -3325,7 +3325,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3400,7 +3400,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin } } diff --git a/leaves-server/minecraft-patches/features/0101-Fix-FallingBlockEntity-Duplicate.patch b/leaves-server/minecraft-patches/features/0099-Fix-FallingBlockEntity-Duplicate.patch similarity index 86% rename from leaves-server/minecraft-patches/features/0101-Fix-FallingBlockEntity-Duplicate.patch rename to leaves-server/minecraft-patches/features/0099-Fix-FallingBlockEntity-Duplicate.patch index d5d36ed61..7fb3aa90b 100644 --- a/leaves-server/minecraft-patches/features/0101-Fix-FallingBlockEntity-Duplicate.patch +++ b/leaves-server/minecraft-patches/features/0099-Fix-FallingBlockEntity-Duplicate.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix FallingBlockEntity Duplicate diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java -index 308af61031070d57556532645f73b41517d696e9..387f7a48499421858ea024bca01e372d3dbcdb57 100644 +index 51f1b141f5f2abd96d36d3ea1954f8dded936506..a5ce7877daa70cc5b3120d56fd50a57c5b7f2ea4 100644 --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -386,7 +386,7 @@ public class FallingBlockEntity extends Entity { +@@ -384,7 +384,7 @@ public class FallingBlockEntity extends Entity { ResourceKey resourceKey1 = this.level().dimension(); boolean flag = (resourceKey1 == Level.END || resourceKey == Level.END) && resourceKey1 != resourceKey; Entity entity = super.teleport(teleportTransition); diff --git a/leaves-server/minecraft-patches/features/0102-Old-Block-remove-behaviour.patch b/leaves-server/minecraft-patches/features/0100-Old-Block-remove-behaviour.patch similarity index 91% rename from leaves-server/minecraft-patches/features/0102-Old-Block-remove-behaviour.patch rename to leaves-server/minecraft-patches/features/0100-Old-Block-remove-behaviour.patch index b1f1fe543..c794adf45 100644 --- a/leaves-server/minecraft-patches/features/0102-Old-Block-remove-behaviour.patch +++ b/leaves-server/minecraft-patches/features/0100-Old-Block-remove-behaviour.patch @@ -25,7 +25,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 9cbc52312c065cc1e7a01368f3c3bd6f374f4e16..271a71aab53e206798c5e3a7be385da4e4f01e12 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 { @@ -56,7 +56,7 @@ index 9cbc52312c065cc1e7a01368f3c3bd6f374f4e16..271a71aab53e206798c5e3a7be385da4 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 95a1e4c332becb284af0e71c55f02e8e6338fdce..0597ec660c85c2ae5c50588016b2c15e951e2d56 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 { @@ -75,7 +75,7 @@ index 95a1e4c332becb284af0e71c55f02e8e6338fdce..0597ec660c85c2ae5c50588016b2c15e 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 a9c511e7debb8d47125d31291a0867791d9ab41b..aace49e366d2723c552d2efb082ab53b786fb5c5 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 { @@ -99,7 +99,7 @@ index a9c511e7debb8d47125d31291a0867791d9ab41b..aace49e366d2723c552d2efb082ab53b 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 37705ccc6b12113d22a1b7c2d8f8a05e4c812604..e6c732e29b0d3c7217e80e287483ce15fa29c043 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 @@ -127,10 +127,10 @@ index 37705ccc6b12113d22a1b7c2d8f8a05e4c812604..e6c732e29b0d3c7217e80e287483ce15 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 265736cb7b96dae60e9c6c7911d10f9a430a548c..687ea91d4e18adf97a5277340af976d07bb4d13a 100644 +index bd6dc109fd9c37666f23ccd17c0eab8aff95e777..e25103c62a41e3fb0a8f7e84496cacc73ed71a74 100644 --- a/net/minecraft/world/level/block/BrewingStandBlock.java +++ b/net/minecraft/world/level/block/BrewingStandBlock.java -@@ -79,6 +79,14 @@ public class BrewingStandBlock extends BaseEntityBlock { +@@ -78,6 +78,14 @@ public class BrewingStandBlock extends BaseEntityBlock { level.addParticle(ParticleTypes.SMOKE, d, d1, d2, 0.0, 0.0, 0.0); } @@ -146,7 +146,7 @@ index 265736cb7b96dae60e9c6c7911d10f9a430a548c..687ea91d4e18adf97a5277340af976d0 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 a0d4f27ec05a18fcd460a01507a004897abb1e4f..924b11ed548bd069c21c411f4ec1ec0d5ee573e5 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 { @@ -170,7 +170,7 @@ index a0d4f27ec05a18fcd460a01507a004897abb1e4f..924b11ed548bd069c21c411f4ec1ec0d 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 d6aaebacfb9b713dafb718d1e7ade8da8111ebb5..99fd2486c16c8d9d299862002cd82decc7442410 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,10 +195,10 @@ index d6aaebacfb9b713dafb718d1e7ade8da8111ebb5..99fd2486c16c8d9d299862002cd82dec 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 3cce87fd6e1d9d65d6b28bf44dd218541e815788..2b4260aef5bc56a9b2a5834f16c7d3ef2c8c2d2f 100644 +index fa2dce759419f62825000718361f47c6f208cdb2..64c0616c294bd7c7b62ae376d50369500b948390 100644 --- a/net/minecraft/world/level/block/ChestBlock.java +++ b/net/minecraft/world/level/block/ChestBlock.java -@@ -276,6 +276,14 @@ public class ChestBlock extends AbstractChestBlock implements +@@ -280,6 +280,14 @@ public class ChestBlock extends AbstractChestBlock implements return this.chestCanConnectTo(blockState) && blockState.getValue(TYPE) == ChestType.SINGLE ? blockState.getValue(FACING) : null; } @@ -214,10 +214,10 @@ index 3cce87fd6e1d9d65d6b28bf44dd218541e815788..2b4260aef5bc56a9b2a5834f16c7d3ef 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 77eee6728ecb0d5cb035a6a7969d5b3498a19b62..899508fbf9f59287d6ece9635e9cf071231d87b4 100644 +index cea0f015290137a5284f4a3021c954272b3db543..53d983505b4c92824083ecd123901874d04704c5 100644 --- a/net/minecraft/world/level/block/ChiseledBookShelfBlock.java +++ b/net/minecraft/world/level/block/ChiseledBookShelfBlock.java -@@ -150,6 +150,27 @@ public class ChiseledBookShelfBlock extends BaseEntityBlock implements Selectabl +@@ -149,6 +149,27 @@ public class ChiseledBookShelfBlock extends BaseEntityBlock implements Selectabl SLOT_OCCUPIED_PROPERTIES.forEach(property -> builder.add(property)); } @@ -246,10 +246,10 @@ index 77eee6728ecb0d5cb035a6a7969d5b3498a19b62..899508fbf9f59287d6ece9635e9cf071 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 9ff207acba5584480481e0df63ad3ca9bced0354..3e011483a74bd45269b5623e5f423495d0300120 100644 +index 468a39219d82a665b99ac1768435557d6f3326c9..43af4388f09a5be23906478b1ff1a74fdbc94023 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 { } } @@ -265,7 +265,7 @@ index 9ff207acba5584480481e0df63ad3ca9bced0354..3e011483a74bd45269b5623e5f423495 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 80fe93eedad9ff6cd5308c8039f988d2635cd574..6c1f1a00ad32bf579643b37b932f6aa3db50d77c 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 { @@ -286,10 +286,10 @@ index 80fe93eedad9ff6cd5308c8039f988d2635cd574..6c1f1a00ad32bf579643b37b932f6aa3 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 ba27d15c674582607f4be6a99541475f790aeb1a..b2a0d53f7480ec7e152d77b239345b21919678ed 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); } @@ -305,10 +305,10 @@ index ba27d15c674582607f4be6a99541475f790aeb1a..b2a0d53f7480ec7e152d77b239345b21 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 1158bdc1993a1c8f907070d6190c5a7d02d4bdb6..b975297c0475049935c38554a8c736abbf9882de 100644 +index a750e2d7f6c5ac7561c8b06870e022b07875c587..0ca50622be8dc300babc6b01b12eddae7fdd38bc 100644 --- a/net/minecraft/world/level/block/DiodeBlock.java +++ b/net/minecraft/world/level/block/DiodeBlock.java -@@ -175,6 +175,16 @@ public abstract class DiodeBlock extends HorizontalDirectionalBlock { +@@ -176,6 +176,16 @@ public abstract class DiodeBlock extends HorizontalDirectionalBlock { this.updateNeighborsInFront(level, pos, state); } @@ -326,7 +326,7 @@ index 1158bdc1993a1c8f907070d6190c5a7d02d4bdb6..b975297c0475049935c38554a8c736ab 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 78375f2ec7e62db803961f4b9feb3e467db20477..58e65813461b76baa6ec01a691549650e65468a2 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 { @@ -345,10 +345,10 @@ index 78375f2ec7e62db803961f4b9feb3e467db20477..58e65813461b76baa6ec01a691549650 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 3140269761935201882173e568004488147a4110..32b2f73d371b4dd53cdadfc94ff5e4d7bdaf7e37 100644 +index 6789dd6c6f9c1683bcf0abb20319ccd6775e613c..695520463adcc6000ef5a94c86466e93a59af118 100644 --- a/net/minecraft/world/level/block/HopperBlock.java +++ b/net/minecraft/world/level/block/HopperBlock.java -@@ -125,6 +125,14 @@ public class HopperBlock extends BaseEntityBlock { +@@ -121,6 +121,14 @@ public class HopperBlock extends BaseEntityBlock { } } @@ -364,7 +364,7 @@ index 3140269761935201882173e568004488147a4110..32b2f73d371b4dd53cdadfc94ff5e4d7 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 c48ffdca3adb53005af18a743fc368a0e9e78f0a..5a095afc88f31cab4be59f2bd5962b67d9236b27 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 { @@ -388,7 +388,7 @@ index c48ffdca3adb53005af18a743fc368a0e9e78f0a..5a095afc88f31cab4be59f2bd5962b67 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 8e18ff02e9773a76ec27e2f62b75a05ec0241dc0..c2615055354ef2539052096ef9ff042ac52460ba 100644 +index 52b9bd310c731c407fc4264559084debec81d3d9..0b991825d48ad64c1c68fd7c6bded7583572dded 100644 --- a/net/minecraft/world/level/block/LecternBlock.java +++ b/net/minecraft/world/level/block/LecternBlock.java @@ -198,6 +198,36 @@ public class LecternBlock extends BaseEntityBlock { @@ -429,10 +429,10 @@ index 8e18ff02e9773a76ec27e2f62b75a05ec0241dc0..c2615055354ef2539052096ef9ff042a 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 20207bcd2a9def5d94e994e2b7807d18df551015..358abfa6f4e4cfc648923caa4fa26e0fab9986bc 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 { } } @@ -498,10 +498,10 @@ index 3c12d8e23f20b666b0005e597ba2e803c02d5d78..17c371f4c24e8a81705bdd322b1de5de 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 6f9ab1b41222832c29949bca1bdfb717ceecf5fa..6e6d10b0a9c2cf4516d29fb747f7e6e7f6063666 100644 +index fe5a571e2ef6e505ba2ea8ccebd2f7b34395fd81..1c606cc15495a2f6f81bb22e3e0e0888c429a4ab 100644 --- a/net/minecraft/world/level/block/RedStoneWireBlock.java +++ b/net/minecraft/world/level/block/RedStoneWireBlock.java -@@ -363,6 +363,27 @@ public class RedStoneWireBlock extends Block { +@@ -362,6 +362,27 @@ public class RedStoneWireBlock extends Block { } } @@ -530,7 +530,7 @@ index 6f9ab1b41222832c29949bca1bdfb717ceecf5fa..6e6d10b0a9c2cf4516d29fb747f7e6e7 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 1ecf736ceeca45bb91dbe31a1dcb0262cbb9c1c7..52cc39babc8b884d01e6e50f04d113130b87eaa8 100644 +index 5365cc6c2ec7f86376bf27551493b6621d4c412e..b08f46411828b4cc05d7d836cd896063c6c9b6a9 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 { @@ -550,10 +550,10 @@ index 1ecf736ceeca45bb91dbe31a1dcb0262cbb9c1c7..52cc39babc8b884d01e6e50f04d11313 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 957f019773d5c042086c1f7c3887ac85b97960ed..de3d5e6eb82c13667f21a3af95b1d2dca02bea94 100644 +index 80e6ba8f026a6565696f18304507b2d0a347650c..593fab3d2a70bcd6832dd777afa4973f22abbaeb 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 } } @@ -573,7 +573,7 @@ index 957f019773d5c042086c1f7c3887ac85b97960ed..de3d5e6eb82c13667f21a3af95b1d2dc 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 465d13a748b5b6773bc0ee26ac3eda582c9f5bcd..484b97494ff45f9d1bc1ca80d01b74995dc220f9 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 @@ -594,10 +594,10 @@ index 465d13a748b5b6773bc0ee26ac3eda582c9f5bcd..484b97494ff45f9d1bc1ca80d01b7499 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 c64685c9aef0ec3c95dc27d631318d2293c1a361..f69f9fa1ec89baafeef9e6a0f01a108c2f443259 100644 +index 1b6bddc15f39c381050eb20c5ad43581d471d876..211fee7a51f73fb18d1b15bce34cf8b684f96a2d 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 } @@ -639,10 +639,10 @@ index 9d005c3db8f0c784cdd7217e7b110daa703a9cf3..190d7cd818f768bd44fc1b4e62af2c9b 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 219cbb38de6452fcc0a7b4db1cf648bbf2f1feac..dbefb8bbcc84ee910287d80ddc5d9abe46721f8f 100644 +index 599f62a108a943f4f4d566ebefa3647515f74c50..33557a0d921d0ff1ed3bba748c16db6ea0f517bd 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); } @@ -669,10 +669,10 @@ index 219cbb38de6452fcc0a7b4db1cf648bbf2f1feac..dbefb8bbcc84ee910287d80ddc5d9abe 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 33e8479f20d1a07c518ba736322517c422cd2763..caaf5a1324e1a3d8447145b8deb55e6c8cf8c56a 100644 +index 8b392c168d9cfefa972aa7f1e9b68711f9683024..adc9fee0c3d5204f7ae7003dc82085c661cdfd0c 100644 --- a/net/minecraft/world/level/block/entity/BlockEntityType.java +++ b/net/minecraft/world/level/block/entity/BlockEntityType.java -@@ -303,7 +303,7 @@ public class BlockEntityType { +@@ -302,7 +302,7 @@ public class BlockEntityType { } public boolean isValid(BlockState state) { @@ -682,10 +682,10 @@ index 33e8479f20d1a07c518ba736322517c422cd2763..caaf5a1324e1a3d8447145b8deb55e6c @Deprecated diff --git a/net/minecraft/world/level/block/piston/MovingPistonBlock.java b/net/minecraft/world/level/block/piston/MovingPistonBlock.java -index 9f013b6a87a18f83188d6efec9f84d8895876f24..3594d97bd7e233bd418e0763db75330a27759c7a 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); } @@ -705,7 +705,7 @@ index 9f013b6a87a18f83188d6efec9f84d8895876f24..3594d97bd7e233bd418e0763db75330a 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 8c35c7e54373f8be187a84bd4b4a9ce9d6341dff..894e0532cf4cdc0a92300b5ead2398da3a836d8e 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 { @@ -729,7 +729,7 @@ index 8c35c7e54373f8be187a84bd4b4a9ce9d6341dff..894e0532cf4cdc0a92300b5ead2398da 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 a38618c28819405f0fb35aa686d1f3f0e94e5da2..683a6a48593218b7504d6c99a0357278fb380665 100644 +index b1f1ea03072c63bc3032c9f023a8fb4ede34b34b..1d805ccd2bc9d74e8f15db37bcc8146b846e438e 100644 --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java @@ -170,6 +170,15 @@ public abstract class BlockBehaviour implements FeatureElement { @@ -748,7 +748,7 @@ index a38618c28819405f0fb35aa686d1f3f0e94e5da2..683a6a48593218b7504d6c99a0357278 protected void affectNeighborsAfterRemoval(BlockState state, ServerLevel level, BlockPos pos, boolean movedByPiston) { } -@@ -869,6 +878,12 @@ public abstract class BlockBehaviour implements FeatureElement { +@@ -865,6 +874,12 @@ public abstract class BlockBehaviour implements FeatureElement { // CraftBukkit end } @@ -762,10 +762,10 @@ index a38618c28819405f0fb35aa686d1f3f0e94e5da2..683a6a48593218b7504d6c99a0357278 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 7c5f827134e0fa81031660a78d4d404c21840cb6..479723aaee1cf9ea6be8606a63f721236b3e2424 100644 +index 670459abcc6f32bdc6d4742f6710585fda83ac83..3c5640ed649ba89066da70e64fe6291165948a5d 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -403,22 +403,28 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot +@@ -401,22 +401,28 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot boolean flag = !blockState.is(block); boolean flag1 = (flags & Block.UPDATE_MOVE_BY_PISTON) != 0; boolean flag2 = (flags & Block.UPDATE_SKIP_BLOCK_ENTITY_SIDEEFFECTS) == 0; diff --git a/leaves-server/minecraft-patches/features/0103-Old-raid-behavior.patch b/leaves-server/minecraft-patches/features/0101-Old-raid-behavior.patch similarity index 94% rename from leaves-server/minecraft-patches/features/0103-Old-raid-behavior.patch rename to leaves-server/minecraft-patches/features/0101-Old-raid-behavior.patch index e7873358f..31f279c4d 100644 --- a/leaves-server/minecraft-patches/features/0103-Old-raid-behavior.patch +++ b/leaves-server/minecraft-patches/features/0101-Old-raid-behavior.patch @@ -21,10 +21,10 @@ index 80f17f33f670018240c854df589cf90cdeab6e70..d7f443bcf91ac7817fe79881122960f4 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 5181a9334066a15e0d502d3522c23337e5eef2b5..36b4aeeb63319d28d637541c3b97a481a8673fd7 100644 +index 8c6b8439bbfb8d9763767fda7985f26f14c05f3f..bff6c27c9037eb88b5da696f6ec99866dced7b39 100644 --- a/net/minecraft/world/entity/raid/Raid.java +++ b/net/minecraft/world/entity/raid/Raid.java -@@ -258,7 +258,7 @@ public class Raid { +@@ -257,7 +257,7 @@ public class Raid { } public boolean absorbRaidOmen(ServerPlayer player) { @@ -33,7 +33,7 @@ index 5181a9334066a15e0d502d3522c23337e5eef2b5..36b4aeeb63319d28d637541c3b97a481 if (effect == null) { return false; } else { -@@ -335,7 +335,13 @@ public class Raid { +@@ -334,7 +334,13 @@ public class Raid { } if (flag1) { @@ -48,7 +48,7 @@ index 5181a9334066a15e0d502d3522c23337e5eef2b5..36b4aeeb63319d28d637541c3b97a481 } if (this.raidCooldownTicks == 300 || this.raidCooldownTicks % 20 == 0) { -@@ -390,7 +396,14 @@ public class Raid { +@@ -389,7 +395,14 @@ public class Raid { int i = 0; while (this.shouldSpawnGroup()) { @@ -64,7 +64,7 @@ index 5181a9334066a15e0d502d3522c23337e5eef2b5..36b4aeeb63319d28d637541c3b97a481 if (blockPos != null) { this.started = true; this.spawnGroup(level, blockPos); -@@ -402,7 +415,7 @@ public class Raid { +@@ -401,7 +414,7 @@ public class Raid { i++; } @@ -73,7 +73,7 @@ index 5181a9334066a15e0d502d3522c23337e5eef2b5..36b4aeeb63319d28d637541c3b97a481 org.bukkit.craftbukkit.event.CraftEventFactory.callRaidStopEvent(level, this, org.bukkit.event.raid.RaidStopEvent.Reason.UNSPAWNABLE); // CraftBukkit this.stop(); break; -@@ -689,7 +702,7 @@ public class Raid { +@@ -686,7 +699,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); @@ -82,7 +82,7 @@ index 5181a9334066a15e0d502d3522c23337e5eef2b5..36b4aeeb63319d28d637541c3b97a481 mutableBlockPos.set(i2, height, i3); if (!level.isVillage(mutableBlockPos) || i <= 7) { int i4 = 10; -@@ -708,6 +721,36 @@ public class Raid { +@@ -705,6 +718,36 @@ public class Raid { return null; } @@ -119,7 +119,7 @@ index 5181a9334066a15e0d502d3522c23337e5eef2b5..36b4aeeb63319d28d637541c3b97a481 private boolean addWaveMob(ServerLevel level, int wave, Raider raider) { return this.addWaveMob(level, wave, raider, true); } -@@ -865,4 +908,43 @@ public class Raid { +@@ -862,4 +905,43 @@ public class Raid { this.spawnsPerWaveBeforeBonus = spawnsPerWaveBeforeBonus; } } @@ -164,10 +164,10 @@ index 5181a9334066a15e0d502d3522c23337e5eef2b5..36b4aeeb63319d28d637541c3b97a481 + // Leaves end - old FindSpawnPosition } diff --git a/net/minecraft/world/entity/raid/Raider.java b/net/minecraft/world/entity/raid/Raider.java -index 8d8315edfb69b062ed5e3d957f4043ec411dd5d7..1c668b9dd246d29c37fc0de9d27e320d6b899a3f 100644 +index ab94809c5cedc8ea7db6db45394bc9c65516da63..e1b82527d7f3cf8b43482c0c8188ef06c6d6e5c4 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); } @@ -200,7 +200,7 @@ index 8d8315edfb69b062ed5e3d957f4043ec411dd5d7..1c668b9dd246d29c37fc0de9d27e320d + 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); diff --git a/leaves-server/minecraft-patches/features/0104-Allow-anvil-destroy-item-entities.patch b/leaves-server/minecraft-patches/features/0102-Allow-anvil-destroy-item-entities.patch similarity index 88% rename from leaves-server/minecraft-patches/features/0104-Allow-anvil-destroy-item-entities.patch rename to leaves-server/minecraft-patches/features/0102-Allow-anvil-destroy-item-entities.patch index 32c321f05..714f6c2b8 100644 --- a/leaves-server/minecraft-patches/features/0104-Allow-anvil-destroy-item-entities.patch +++ b/leaves-server/minecraft-patches/features/0102-Allow-anvil-destroy-item-entities.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Allow anvil destroy item entities diff --git a/net/minecraft/world/entity/item/FallingBlockEntity.java b/net/minecraft/world/entity/item/FallingBlockEntity.java -index 387f7a48499421858ea024bca01e372d3dbcdb57..9395301f25d2b525d1412b7b79b82fa06c2bebbb 100644 +index a5ce7877daa70cc5b3120d56fd50a57c5b7f2ea4..3faabf37f41688f51d17dc177e52078025879ca7 100644 --- a/net/minecraft/world/entity/item/FallingBlockEntity.java +++ b/net/minecraft/world/entity/item/FallingBlockEntity.java -@@ -281,7 +281,7 @@ public class FallingBlockEntity extends Entity { +@@ -280,7 +280,7 @@ public class FallingBlockEntity extends Entity { if (ceil < 0) { return false; } else { diff --git a/leaves-server/minecraft-patches/features/0105-Disable-vault-blacklist.patch b/leaves-server/minecraft-patches/features/0103-Disable-vault-blacklist.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0105-Disable-vault-blacklist.patch rename to leaves-server/minecraft-patches/features/0103-Disable-vault-blacklist.patch diff --git a/leaves-server/minecraft-patches/features/0106-Fix-EntityPortalExitEvent-logic.patch b/leaves-server/minecraft-patches/features/0104-Fix-EntityPortalExitEvent-logic.patch similarity index 93% rename from leaves-server/minecraft-patches/features/0106-Fix-EntityPortalExitEvent-logic.patch rename to leaves-server/minecraft-patches/features/0104-Fix-EntityPortalExitEvent-logic.patch index b1700fb84..334964aae 100644 --- a/leaves-server/minecraft-patches/features/0106-Fix-EntityPortalExitEvent-logic.patch +++ b/leaves-server/minecraft-patches/features/0104-Fix-EntityPortalExitEvent-logic.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix EntityPortalExitEvent logic diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 8bd5f957d61c429cf75e5a14296f735c33149e39..7376b7f56009865ba2db24b68f008b077bcf34d3 100644 +index 64ab6dd069f423595a66769f255fba828ad20574..4583083678004a9abe9fb5b6b1f4e7aa113e8d27 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -4052,19 +4052,21 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4073,19 +4073,21 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name ); event.callEvent(); diff --git a/leaves-server/minecraft-patches/features/0107-Fix-CraftPortalEvent-logic.patch b/leaves-server/minecraft-patches/features/0105-Fix-CraftPortalEvent-logic.patch similarity index 90% rename from leaves-server/minecraft-patches/features/0107-Fix-CraftPortalEvent-logic.patch rename to leaves-server/minecraft-patches/features/0105-Fix-CraftPortalEvent-logic.patch index e2397f16d..eeea83838 100644 --- a/leaves-server/minecraft-patches/features/0107-Fix-CraftPortalEvent-logic.patch +++ b/leaves-server/minecraft-patches/features/0105-Fix-CraftPortalEvent-logic.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix CraftPortalEvent logic diff --git a/net/minecraft/world/level/block/EndPortalBlock.java b/net/minecraft/world/level/block/EndPortalBlock.java -index fb51a78e16fd461d95f670eae43ef93c64b46843..dca30a02110181bf45306ca6b2f9508e20cd643f 100644 +index 19590aa5af0eaf0f9bf76dc189ed67e67c692c77..a2b0f63c20a08e15b36fbcffd264e7004f4480c5 100644 --- a/net/minecraft/world/level/block/EndPortalBlock.java +++ b/net/minecraft/world/level/block/EndPortalBlock.java -@@ -111,10 +111,10 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal { +@@ -110,10 +110,10 @@ public class EndPortalBlock extends BaseEntityBlock implements Portal { } // CraftBukkit start diff --git a/leaves-server/minecraft-patches/features/0108-Xaero-Map-Protocol.patch b/leaves-server/minecraft-patches/features/0106-Xaero-Map-Protocol.patch similarity index 58% rename from leaves-server/minecraft-patches/features/0108-Xaero-Map-Protocol.patch rename to leaves-server/minecraft-patches/features/0106-Xaero-Map-Protocol.patch index 44a1e1597..764fdf259 100644 --- a/leaves-server/minecraft-patches/features/0108-Xaero-Map-Protocol.patch +++ b/leaves-server/minecraft-patches/features/0106-Xaero-Map-Protocol.patch @@ -5,14 +5,16 @@ Subject: [PATCH] Xaero Map Protocol diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 7f21903070ab733249441e796a1faa5adf873ffb..e1ce47f1f507d7d1ec8606b02815b0d8fb970734 100644 +index 231387831280f24e9e50ee94aaacbd10d1532979..98a71ac21c8f658a751b8b1628aeaa540444c6da 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -1202,6 +1202,7 @@ public abstract class PlayerList { - player.connection.send(new ClientboundSetChunkCacheRadiusPacket(level.spigotConfig.viewDistance)); - player.connection.send(new ClientboundSetSimulationDistancePacket(level.spigotConfig.simulationDistance)); - // Paper end +@@ -1209,6 +1209,9 @@ public abstract class PlayerList { + //player.connection.send(new ClientboundSetChunkCacheRadiusPacket(io.papermc.paper.FeatureHooks.getViewDistance(level))); // Paper - rewrite chunk system + //player.connection.send(new ClientboundSetSimulationDistancePacket(io.papermc.paper.FeatureHooks.getSimulationDistance(level))); // Paper - rewrite chunk system + // Paper end - view distances ++ + org.leavesmc.leaves.protocol.XaeroMapProtocol.onSendWorldInfo(player); // Leaves - xaero map protocol ++ if (level.isRaining()) { // CraftBukkit start - handle player weather // player.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.START_RAINING, 0.0F)); diff --git a/leaves-server/minecraft-patches/features/0109-Skip-negligible-planar-movement-multiplication.patch b/leaves-server/minecraft-patches/features/0107-Skip-negligible-planar-movement-multiplication.patch similarity index 91% rename from leaves-server/minecraft-patches/features/0109-Skip-negligible-planar-movement-multiplication.patch rename to leaves-server/minecraft-patches/features/0107-Skip-negligible-planar-movement-multiplication.patch index c52b3a592..4030b5df3 100644 --- a/leaves-server/minecraft-patches/features/0109-Skip-negligible-planar-movement-multiplication.patch +++ b/leaves-server/minecraft-patches/features/0107-Skip-negligible-planar-movement-multiplication.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Skip negligible planar movement multiplication This patch is Powered by Gale(https://github.com/Dreeam-qwq/Gale) diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 7376b7f56009865ba2db24b68f008b077bcf34d3..0260ccee26a4dad7c7ea53504a45c645abe3c28f 100644 +index 4583083678004a9abe9fb5b6b1f4e7aa113e8d27..ff9e27a648e7fe8ff51fd1edc2e321b2213e4e6c 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -1246,8 +1246,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -1261,8 +1261,17 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } } diff --git a/leaves-server/minecraft-patches/features/0110-Support-REI-protocol.patch b/leaves-server/minecraft-patches/features/0108-Support-REI-protocol.patch similarity index 81% rename from leaves-server/minecraft-patches/features/0110-Support-REI-protocol.patch rename to leaves-server/minecraft-patches/features/0108-Support-REI-protocol.patch index 31eca2173..f00c95362 100644 --- a/leaves-server/minecraft-patches/features/0110-Support-REI-protocol.patch +++ b/leaves-server/minecraft-patches/features/0108-Support-REI-protocol.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Support REI protocol 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 { ); } @@ -22,10 +22,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/leaves-server/minecraft-patches/features/0111-Vanilla-player-display-name.patch b/leaves-server/minecraft-patches/features/0109-Vanilla-player-display-name.patch similarity index 88% rename from leaves-server/minecraft-patches/features/0111-Vanilla-player-display-name.patch rename to leaves-server/minecraft-patches/features/0109-Vanilla-player-display-name.patch index f46bae443..f8213bf80 100644 --- a/leaves-server/minecraft-patches/features/0111-Vanilla-player-display-name.patch +++ b/leaves-server/minecraft-patches/features/0109-Vanilla-player-display-name.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Vanilla player display name diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 44b1d56fb3ce3827290ef4cf987aa2386d07eb9c..77f82c8bf2ffbe642f1149aa4a5269818964296a 100644 +index 5b0b3735caa2ddbcb83d3adc29126205fa4bf131..49dbb6ca89c8a8b7f999ed98bda635d443cd8f85 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -491,7 +491,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -481,7 +481,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc this.object = null; // CraftBukkit start this.displayName = this.getScoreboardName(); @@ -18,10 +18,10 @@ index 44b1d56fb3ce3827290ef4cf987aa2386d07eb9c..77f82c8bf2ffbe642f1149aa4a526981 this.maxHealthCache = this.getMaxHealth(); // CraftBukkit end diff --git a/net/minecraft/world/scores/Scoreboard.java b/net/minecraft/world/scores/Scoreboard.java -index e25075f6436a8020bd1b0d9e53ed93d0eb914d6a..e20fe2d12b28e108763156781444a59a9dbdc25d 100644 +index 8ac6138dbf9299a0253599a57f85138fc7c80bd2..4b425d768b0d24a4ca95b901a9c706b507395bf7 100644 --- a/net/minecraft/world/scores/Scoreboard.java +++ b/net/minecraft/world/scores/Scoreboard.java -@@ -282,6 +282,16 @@ public class Scoreboard { +@@ -277,6 +277,16 @@ public class Scoreboard { } this.teamsByPlayer.put(playerName, team); @@ -38,7 +38,7 @@ index e25075f6436a8020bd1b0d9e53ed93d0eb914d6a..e20fe2d12b28e108763156781444a59a return team.getPlayers().add(playerName); } -@@ -301,6 +311,14 @@ public class Scoreboard { +@@ -296,6 +306,14 @@ public class Scoreboard { } else { this.teamsByPlayer.remove(playerName); team.getPlayers().remove(playerName); diff --git a/leaves-server/minecraft-patches/features/0112-Fix-SculkCatalyst-exp-skip.patch b/leaves-server/minecraft-patches/features/0110-Fix-SculkCatalyst-exp-skip.patch similarity index 88% rename from leaves-server/minecraft-patches/features/0112-Fix-SculkCatalyst-exp-skip.patch rename to leaves-server/minecraft-patches/features/0110-Fix-SculkCatalyst-exp-skip.patch index 9ce866ea2..df3fc964b 100644 --- a/leaves-server/minecraft-patches/features/0112-Fix-SculkCatalyst-exp-skip.patch +++ b/leaves-server/minecraft-patches/features/0110-Fix-SculkCatalyst-exp-skip.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix SculkCatalyst exp skip diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 77f82c8bf2ffbe642f1149aa4a5269818964296a..60a5bf1fa503dab25a7fef9d094fd6dc5a80fdca 100644 +index 49dbb6ca89c8a8b7f999ed98bda635d443cd8f85..270d567b2059466b6e54d63241d6d9f86f6da437 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -1214,7 +1214,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -1211,7 +1211,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc } // SPIGOT-5478 must be called manually now @@ -17,8 +17,8 @@ index 77f82c8bf2ffbe642f1149aa4a5269818964296a..60a5bf1fa503dab25a7fef9d094fd6dc // we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory. if (!event.getKeepInventory()) { // Paper start - PlayerDeathEvent#getItemsToKeep -@@ -1261,6 +1261,15 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc - this.setClientLoaded(false); +@@ -1258,6 +1258,15 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc + this.connection.markClientUnloadedAfterDeath(); } + // Leaves start - exp fix @@ -34,10 +34,10 @@ index 77f82c8bf2ffbe642f1149aa4a5269818964296a..60a5bf1fa503dab25a7fef9d094fd6dc 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 0f2a3002ec01451e92b3e4869373a910be6ccab2..0610df1c343f1c5cf724a79fbc68ed1372de5da5 100644 +index 7703fb2264ddf66f36b114af63ab6e2f1f5e75fa..493bbb6fb85d2b014a9f94a07409c7a73829d234 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -279,6 +279,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -281,6 +281,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin private Waypoint.Icon locatorBarIcon = new Waypoint.Icon(); // CraftBukkit start public int expToDrop; @@ -45,7 +45,7 @@ index 0f2a3002ec01451e92b3e4869373a910be6ccab2..0610df1c343f1c5cf724a79fbc68ed13 public List drops = new java.util.ArrayList<>(); // Paper - Restore vanilla drops behavior public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes; public boolean collides = true; -@@ -1872,6 +1873,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1883,6 +1884,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin entity.killedEntity((ServerLevel) this.level(), this, damageSource); } this.gameEvent(GameEvent.ENTITY_DIE); @@ -53,7 +53,7 @@ index 0f2a3002ec01451e92b3e4869373a910be6ccab2..0610df1c343f1c5cf724a79fbc68ed13 } else { this.dead = false; this.setHealth((float) deathEvent.getReviveHealth()); -@@ -1948,7 +1950,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1959,7 +1961,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin this.drops = new java.util.ArrayList<>(); // this.dropEquipment(level); // CraftBukkit - moved up // CraftBukkit end diff --git a/leaves-server/minecraft-patches/features/0113-Vanilla-creative-pickup-behavior.patch b/leaves-server/minecraft-patches/features/0111-Vanilla-creative-pickup-behavior.patch similarity index 100% rename from leaves-server/minecraft-patches/features/0113-Vanilla-creative-pickup-behavior.patch rename to leaves-server/minecraft-patches/features/0111-Vanilla-creative-pickup-behavior.patch diff --git a/leaves-server/minecraft-patches/features/0114-Vanilla-portal-handle.patch b/leaves-server/minecraft-patches/features/0112-Vanilla-portal-handle.patch similarity index 71% rename from leaves-server/minecraft-patches/features/0114-Vanilla-portal-handle.patch rename to leaves-server/minecraft-patches/features/0112-Vanilla-portal-handle.patch index e2ad09a28..0661288aa 100644 --- a/leaves-server/minecraft-patches/features/0114-Vanilla-portal-handle.patch +++ b/leaves-server/minecraft-patches/features/0112-Vanilla-portal-handle.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Vanilla portal handle diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 0260ccee26a4dad7c7ea53504a45c645abe3c28f..03972434172ff8615f0f5defa1076d348e0b6b19 100644 +index ff9e27a648e7fe8ff51fd1edc2e321b2213e4e6c..21c605ec1fc93366bc4c2d82d5ef9137a07b1d3b 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -841,6 +841,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -846,6 +846,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name // CraftBukkit start public void postTick() { @@ -16,7 +16,7 @@ index 0260ccee26a4dad7c7ea53504a45c645abe3c28f..03972434172ff8615f0f5defa1076d34 // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle if (!(this instanceof ServerPlayer) && this.isAlive()) { // Paper - don't attempt to teleport dead entities this.handlePortal(); -@@ -861,7 +862,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -867,7 +868,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name this.boardingCooldown--; } @@ -25,14 +25,14 @@ index 0260ccee26a4dad7c7ea53504a45c645abe3c28f..03972434172ff8615f0f5defa1076d34 if (this.canSpawnSprintParticle()) { this.spawnSprintParticle(); } -diff --git a/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/net/minecraft/world/entity/vehicle/AbstractMinecart.java -index 3454506b2d7ada401600e2adccd462a15bd86723..c8b053b01b06af6033b9a74452946333dbeb77fa 100644 ---- a/net/minecraft/world/entity/vehicle/AbstractMinecart.java -+++ b/net/minecraft/world/entity/vehicle/AbstractMinecart.java -@@ -293,7 +293,7 @@ public abstract class AbstractMinecart extends VehicleEntity { - } +diff --git a/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java b/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java +index 1123ec0038552e0b40774f4a433ff325695ea071..fdff726c89e25164437ec8ef370349df2e44c804 100644 +--- a/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java ++++ b/net/minecraft/world/entity/vehicle/minecart/AbstractMinecart.java +@@ -296,7 +296,7 @@ public abstract class AbstractMinecart extends VehicleEntity { this.checkBelowWorld(); + this.computeSpeed(); - // this.handlePortal(); // CraftBukkit - handled in postTick + if (org.leavesmc.leaves.LeavesConfig.fix.vanillaPortalHandle) this.handlePortal(); // CraftBukkit - handled in postTick // Leaves - vanilla this.behavior.tick(); diff --git a/leaves-server/minecraft-patches/features/0115-Fix-chunk-reload-detector.patch b/leaves-server/minecraft-patches/features/0113-Fix-chunk-reload-detector.patch similarity index 87% rename from leaves-server/minecraft-patches/features/0115-Fix-chunk-reload-detector.patch rename to leaves-server/minecraft-patches/features/0113-Fix-chunk-reload-detector.patch index 9ae19a7d5..9347902db 100644 --- a/leaves-server/minecraft-patches/features/0115-Fix-chunk-reload-detector.patch +++ b/leaves-server/minecraft-patches/features/0113-Fix-chunk-reload-detector.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix chunk reload detector diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index 1099280bd8e28c167702b74041928f260695ba7c..42c5e027ab04d03e761d956343bb41c3496da1ff 100644 +index 8f6b7ec2f2294ac5845b8f6fb94959e9a11d6329..451b9dcff9c37572df4e7c3aad1fd1afe314c932 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java -@@ -371,7 +371,7 @@ public class ServerEntity { +@@ -372,7 +372,7 @@ public class ServerEntity { if (!list.isEmpty()) { consumer.accept(new ClientboundSetEquipmentPacket(this.entity.getId(), list, true)); // Paper - data sanitization } diff --git a/leaves-server/minecraft-patches/features/0116-Do-not-reset-placed-block-on-exception.patch b/leaves-server/minecraft-patches/features/0114-Do-not-reset-placed-block-on-exception.patch similarity index 94% rename from leaves-server/minecraft-patches/features/0116-Do-not-reset-placed-block-on-exception.patch rename to leaves-server/minecraft-patches/features/0114-Do-not-reset-placed-block-on-exception.patch index 5115ecd75..198a0ff42 100644 --- a/leaves-server/minecraft-patches/features/0116-Do-not-reset-placed-block-on-exception.patch +++ b/leaves-server/minecraft-patches/features/0114-Do-not-reset-placed-block-on-exception.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Do not reset placed block on exception diff --git a/net/minecraft/world/item/BlockItem.java b/net/minecraft/world/item/BlockItem.java -index cf00493cbf131d0af2137a852c9ffba9dbeaddb3..13c357688f381e36ff4179a65a0654c73e1219b1 100644 +index 85416c58bd447a7129f2b021f93690e3fdda62c8..439e29d2b9399311d9b1ca3dc6153504bccb906b 100644 --- a/net/minecraft/world/item/BlockItem.java +++ b/net/minecraft/world/item/BlockItem.java -@@ -91,20 +91,22 @@ public class BlockItem extends Item { +@@ -92,20 +92,22 @@ public class BlockItem extends Item { BlockState blockState = level.getBlockState(clickedPos); if (blockState.is(placementState.getBlock())) { blockState = this.updateBlockStateFromTag(clickedPos, level, itemInHand, blockState); diff --git a/leaves-server/minecraft-patches/features/0117-Do-not-prevent-block-entity-and-entity-crash-at-Leve.patch b/leaves-server/minecraft-patches/features/0115-Do-not-prevent-block-entity-and-entity-crash-at-Leve.patch similarity index 93% rename from leaves-server/minecraft-patches/features/0117-Do-not-prevent-block-entity-and-entity-crash-at-Leve.patch rename to leaves-server/minecraft-patches/features/0115-Do-not-prevent-block-entity-and-entity-crash-at-Leve.patch index c1a85d9cb..92ef9e035 100644 --- a/leaves-server/minecraft-patches/features/0117-Do-not-prevent-block-entity-and-entity-crash-at-Leve.patch +++ b/leaves-server/minecraft-patches/features/0115-Do-not-prevent-block-entity-and-entity-crash-at-Leve.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Do not prevent block entity and entity crash at LevelChunk diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index 479723aaee1cf9ea6be8606a63f721236b3e2424..e6cc97e21e31faab0562e2a43766bd00f0451a19 100644 +index 3c5640ed649ba89066da70e64fe6291165948a5d..d5a0a2c0a5673088e4ad1e2e7f4fac8a65f68ceb 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -988,12 +988,14 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot +@@ -982,12 +982,14 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot profilerFiller.pop(); } catch (Throwable var5) { diff --git a/leaves-server/minecraft-patches/features/0118-Tripwire-behavior-modifier.patch b/leaves-server/minecraft-patches/features/0116-Tripwire-behavior-modifier.patch similarity index 97% rename from leaves-server/minecraft-patches/features/0118-Tripwire-behavior-modifier.patch rename to leaves-server/minecraft-patches/features/0116-Tripwire-behavior-modifier.patch index c5dfaba83..628a4e158 100644 --- a/leaves-server/minecraft-patches/features/0118-Tripwire-behavior-modifier.patch +++ b/leaves-server/minecraft-patches/features/0116-Tripwire-behavior-modifier.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Tripwire behavior modifier diff --git a/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java b/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java -index dfe8b815987a0ee385846616e4845428a81f2782..63bbee85d18537760c876cdab5bcac5798bf918b 100644 +index 20a7264c3f476f0100a7f3a78589f99b4ea59921..dbf34676e792c51e1147e952468030e92da7d5f9 100644 --- a/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java +++ b/net/minecraft/world/level/levelgen/feature/EndPlatformFeature.java @@ -28,14 +28,40 @@ public class EndPlatformFeature extends Feature { @@ -50,7 +50,7 @@ index dfe8b815987a0ee385846616e4845428a81f2782..63bbee85d18537760c876cdab5bcac57 + else blockList.destroyBlock(blockPos, true, null); } - blockList.setBlock(blockPos, block.defaultBlockState(), 3); // CraftBukkit + blockList.setBlock(blockPos, block.defaultBlockState(), Block.UPDATE_ALL); // CraftBukkit @@ -53,11 +79,29 @@ public class EndPlatformFeature extends Feature { if (portalEvent.isCancelled()) return; } diff --git a/leaves-server/minecraft-patches/features/0119-Spawn-invulnerable-time.patch b/leaves-server/minecraft-patches/features/0117-Spawn-invulnerable-time.patch similarity index 87% rename from leaves-server/minecraft-patches/features/0119-Spawn-invulnerable-time.patch rename to leaves-server/minecraft-patches/features/0117-Spawn-invulnerable-time.patch index 9a7f8f25d..67947585b 100644 --- a/leaves-server/minecraft-patches/features/0119-Spawn-invulnerable-time.patch +++ b/leaves-server/minecraft-patches/features/0117-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 60a5bf1fa503dab25a7fef9d094fd6dc5a80fdca..2d957b4bd98497100a9fc62fa4709b6898a6374f 100644 +index 270d567b2059466b6e54d63241d6d9f86f6da437..3623f1e71633f5823efec4f56285d1d7efe8087a 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -241,6 +241,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,7 +16,7 @@ index 60a5bf1fa503dab25a7fef9d094fd6dc5a80fdca..2d957b4bd98497100a9fc62fa4709b68 private ChatVisiblity chatVisibility = ChatVisiblity.FULL; public ParticleStatus particleStatus = ParticleStatus.ALL; private boolean canChatColor = true; -@@ -730,6 +731,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -727,6 +728,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc this.resetOperationCountPerTick(); // Leaves - player operation limiter this.gameMode.tick(); this.wardenSpawnTracker.tick(); @@ -24,7 +24,7 @@ index 60a5bf1fa503dab25a7fef9d094fd6dc5a80fdca..2d957b4bd98497100a9fc62fa4709b68 if (this.invulnerableTime > 0) { this.invulnerableTime--; } -@@ -1313,6 +1315,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -1310,6 +1312,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc if (this.isInvulnerableTo(level, damageSource)) { return false; } else { diff --git a/leaves-server/minecraft-patches/features/0120-Old-zombie-reinforcement.patch b/leaves-server/minecraft-patches/features/0118-Old-zombie-reinforcement.patch similarity index 66% rename from leaves-server/minecraft-patches/features/0120-Old-zombie-reinforcement.patch rename to leaves-server/minecraft-patches/features/0118-Old-zombie-reinforcement.patch index 532cfed45..e195b22d2 100644 --- a/leaves-server/minecraft-patches/features/0120-Old-zombie-reinforcement.patch +++ b/leaves-server/minecraft-patches/features/0118-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 afe4a2304268224f6b0a1cc40a41f7b67f9d3275..1a5f3bdfcd6811bd26f75f43e325cc0bd3bbc814 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 d9935d71393b28ee8052b1c05739bfd44d6afb47..19f892c01409af4d02a7771aca0ad098588ffd71 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/leaves-server/minecraft-patches/features/0121-Sound-update-suppression.patch b/leaves-server/minecraft-patches/features/0119-Sound-update-suppression.patch similarity index 90% rename from leaves-server/minecraft-patches/features/0121-Sound-update-suppression.patch rename to leaves-server/minecraft-patches/features/0119-Sound-update-suppression.patch index 901d816af..ebf250bbd 100644 --- a/leaves-server/minecraft-patches/features/0121-Sound-update-suppression.patch +++ b/leaves-server/minecraft-patches/features/0119-Sound-update-suppression.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Sound update suppression diff --git a/net/minecraft/world/level/block/SculkSensorBlock.java b/net/minecraft/world/level/block/SculkSensorBlock.java -index fa9cb4c40a41eea7fd63a4513d0b0f39067de9ba..a8375b6544a004c96e2b3c7c088831def855febe 100644 +index 593fab3d2a70bcd6832dd777afa4973f22abbaeb..0207f5d28d7a7673f82df5ce9e0e596c6756ecf6 100644 --- a/net/minecraft/world/level/block/SculkSensorBlock.java +++ b/net/minecraft/world/level/block/SculkSensorBlock.java -@@ -97,7 +97,7 @@ public class SculkSensorBlock extends BaseEntityBlock implements SimpleWaterlogg +@@ -96,7 +96,7 @@ public class SculkSensorBlock extends BaseEntityBlock implements SimpleWaterlogg @Override public void stepOn(Level level, BlockPos pos, BlockState state, Entity entity) { if (!level.isClientSide() @@ -17,7 +17,7 @@ index fa9cb4c40a41eea7fd63a4513d0b0f39067de9ba..a8375b6544a004c96e2b3c7c088831de && entity.getType() != EntityType.WARDEN && level.getBlockEntity(pos) instanceof SculkSensorBlockEntity sculkSensorBlockEntity && level instanceof ServerLevel serverLevel -@@ -214,6 +214,15 @@ public class SculkSensorBlock extends BaseEntityBlock implements SimpleWaterlogg +@@ -211,6 +211,15 @@ public class SculkSensorBlock extends BaseEntityBlock implements SimpleWaterlogg return state.getValue(PHASE); } @@ -34,11 +34,11 @@ index fa9cb4c40a41eea7fd63a4513d0b0f39067de9ba..a8375b6544a004c96e2b3c7c088831de return state.getBlock() instanceof SculkSensorBlock && getPhase(state) == SculkSensorPhase.INACTIVE; // Paper - Check for a valid type } diff --git a/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java b/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java -index 9a345fa3438b2d17a5de2fa0c0b0daef5a5183e1..f3f92666265e1b6dcb17124b5f52e84a6d62ccf2 100644 +index 39aa9e1703ade12899f26ffc8063895e52138adb..b6d0af221c083f29215d2c56f07b4b3954acc86b 100644 --- a/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java +++ b/net/minecraft/world/level/block/entity/SculkSensorBlockEntity.java @@ -113,7 +113,7 @@ public class SculkSensorBlockEntity extends BlockEntity implements GameEventList - public boolean canReceiveVibration(ServerLevel level, BlockPos pos, Holder gameEvent, @Nullable GameEvent.Context context) { + public boolean canReceiveVibration(ServerLevel level, BlockPos pos, Holder gameEvent, GameEvent.@Nullable Context context) { return (!pos.equals(this.blockPos) || !gameEvent.is(GameEvent.BLOCK_DESTROY) && !gameEvent.is(GameEvent.BLOCK_PLACE)) && VibrationSystem.getGameEventFrequency(gameEvent) != 0 - && SculkSensorBlock.canActivate(SculkSensorBlockEntity.this.getBlockState()); diff --git a/leaves-server/minecraft-patches/features/0122-Old-zombie-piglin-drop-behavior.patch b/leaves-server/minecraft-patches/features/0120-Old-zombie-piglin-drop-behavior.patch similarity index 55% rename from leaves-server/minecraft-patches/features/0122-Old-zombie-piglin-drop-behavior.patch rename to leaves-server/minecraft-patches/features/0120-Old-zombie-piglin-drop-behavior.patch index a6883d7e9..4c5f98c08 100644 --- a/leaves-server/minecraft-patches/features/0122-Old-zombie-piglin-drop-behavior.patch +++ b/leaves-server/minecraft-patches/features/0120-Old-zombie-piglin-drop-behavior.patch @@ -4,11 +4,11 @@ Date: Fri, 23 May 2025 08:05:45 +0800 Subject: [PATCH] Old zombie piglin drop behavior -diff --git a/net/minecraft/world/entity/monster/ZombifiedPiglin.java b/net/minecraft/world/entity/monster/ZombifiedPiglin.java -index 822712eaff2f6c579d982734ab14a00c02182770..abc18460374a246d0895dd56a3c3d8a6503ccde4 100644 ---- a/net/minecraft/world/entity/monster/ZombifiedPiglin.java -+++ b/net/minecraft/world/entity/monster/ZombifiedPiglin.java -@@ -113,6 +113,9 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob { +diff --git a/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java b/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java +index 8fcb6cd1cefa6c9e1809944b4720cfdc35325729..0c5da9aa8e682ee37b04a5fc18d696f25fbb0ba2 100644 +--- a/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java ++++ b/net/minecraft/world/entity/monster/zombie/ZombifiedPiglin.java +@@ -109,6 +109,9 @@ public class ZombifiedPiglin extends Zombie implements NeutralMob { this.maybeAlertOthers(); } diff --git a/leaves-server/minecraft-patches/features/0123-Fast-exp-orb-absorb.patch b/leaves-server/minecraft-patches/features/0121-Fast-exp-orb-absorb.patch similarity index 93% rename from leaves-server/minecraft-patches/features/0123-Fast-exp-orb-absorb.patch rename to leaves-server/minecraft-patches/features/0121-Fast-exp-orb-absorb.patch index 65a626611..28d1e69a6 100644 --- a/leaves-server/minecraft-patches/features/0123-Fast-exp-orb-absorb.patch +++ b/leaves-server/minecraft-patches/features/0121-Fast-exp-orb-absorb.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fast exp orb absorb diff --git a/net/minecraft/world/entity/ExperienceOrb.java b/net/minecraft/world/entity/ExperienceOrb.java -index 47bdbf9c73f19ff85ae93f3e31e45d35fe8c0a92..e3d5140ed9e7e9435213954ab603a9eb15c43a8d 100644 +index 29d904b02a2c7b3d25261ca26c7c0479b00999ef..ae716dffb9d282ee2c5df73dfb846ac20aea02e0 100644 --- a/net/minecraft/world/entity/ExperienceOrb.java +++ b/net/minecraft/world/entity/ExperienceOrb.java -@@ -358,6 +358,20 @@ public class ExperienceOrb extends Entity { +@@ -355,6 +355,20 @@ public class ExperienceOrb extends Entity { public void playerTouch(Player entity) { if (entity instanceof ServerPlayer serverPlayer) { if (entity.takeXpDelay == 0 && new com.destroystokyo.paper.event.player.PlayerPickupExperienceEvent(serverPlayer.getBukkitEntity(), (org.bukkit.entity.ExperienceOrb) this.getBukkitEntity()).callEvent()) { // Paper - PlayerPickupExperienceEvent diff --git a/leaves-server/minecraft-patches/features/0125-Configurable-item-damage-check.patch b/leaves-server/minecraft-patches/features/0122-Configurable-item-damage-check.patch similarity index 88% rename from leaves-server/minecraft-patches/features/0125-Configurable-item-damage-check.patch rename to leaves-server/minecraft-patches/features/0122-Configurable-item-damage-check.patch index 2293b261b..790a23ed5 100644 --- a/leaves-server/minecraft-patches/features/0125-Configurable-item-damage-check.patch +++ b/leaves-server/minecraft-patches/features/0122-Configurable-item-damage-check.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Configurable item damage check diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java -index 13d5cb566f31ce0657b93c24c8e20a5ce3559fa4..fba077a5b6b9256dd117ae72c6aa0c63452a3eaa 100644 +index c59dec418f94b468f0465d0375809031f10bac39..2d01258e377ad1d628b193d15d794a057c3d11b4 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -598,11 +598,11 @@ public final class ItemStack implements DataComponentHolder { +@@ -603,11 +603,11 @@ public final class ItemStack implements DataComponentHolder { } public int getDamageValue() { diff --git a/leaves-server/minecraft-patches/features/0126-Old-Throwable-Projectile-tick-order.patch b/leaves-server/minecraft-patches/features/0123-Old-Throwable-Projectile-tick-order.patch similarity index 97% rename from leaves-server/minecraft-patches/features/0126-Old-Throwable-Projectile-tick-order.patch rename to leaves-server/minecraft-patches/features/0123-Old-Throwable-Projectile-tick-order.patch index 0bdab2cde..d1e8a6c1c 100644 --- a/leaves-server/minecraft-patches/features/0126-Old-Throwable-Projectile-tick-order.patch +++ b/leaves-server/minecraft-patches/features/0123-Old-Throwable-Projectile-tick-order.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Old Throwable Projectile tick order diff --git a/net/minecraft/world/entity/projectile/ThrowableProjectile.java b/net/minecraft/world/entity/projectile/ThrowableProjectile.java -index 5104636be1de4bf1dc491673cad55854a106da53..5e45ce80ee2fcdba915e9be29fe2c6325dd338b3 100644 +index dfda0560e364aa7777bc1aa76febc55f1c2dd5a0..57ad4b5ef32e773d08bb1c0f496365ad154a01ce 100644 --- a/net/minecraft/world/entity/projectile/ThrowableProjectile.java +++ b/net/minecraft/world/entity/projectile/ThrowableProjectile.java @@ -45,23 +45,43 @@ public abstract class ThrowableProjectile extends Projectile { diff --git a/leaves-server/minecraft-patches/features/0127-Old-leash-behavior-when-use-firework.patch b/leaves-server/minecraft-patches/features/0124-Old-leash-behavior-when-use-firework.patch similarity index 90% rename from leaves-server/minecraft-patches/features/0127-Old-leash-behavior-when-use-firework.patch rename to leaves-server/minecraft-patches/features/0124-Old-leash-behavior-when-use-firework.patch index 0a45ffec6..b993a203f 100644 --- a/leaves-server/minecraft-patches/features/0127-Old-leash-behavior-when-use-firework.patch +++ b/leaves-server/minecraft-patches/features/0124-Old-leash-behavior-when-use-firework.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Old leash behavior when use firework diff --git a/net/minecraft/world/item/FireworkRocketItem.java b/net/minecraft/world/item/FireworkRocketItem.java -index 0e4335bb2469a4698b303b598ec773b5c7cc73ce..1a514f09873c9249a1d7ad77c8cd2d647d24772f 100644 +index 7ccf76e938280216def8df55fe397a433b521d29..05d10035da22f1a3450f680da3551ad05d2d89aa 100644 --- a/net/minecraft/world/item/FireworkRocketItem.java +++ b/net/minecraft/world/item/FireworkRocketItem.java -@@ -87,7 +87,7 @@ public class FireworkRocketItem extends Item implements ProjectileItem { +@@ -88,7 +88,7 @@ public class FireworkRocketItem extends Item implements ProjectileItem { com.destroystokyo.paper.event.player.PlayerElytraBoostEvent event = new com.destroystokyo.paper.event.player.PlayerElytraBoostEvent((org.bukkit.entity.Player) player.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemInHand), (org.bukkit.entity.Firework) delayed.projectile().getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand)); if (event.callEvent() && delayed.attemptSpawn()) { player.awardStat(Stats.ITEM_USED.get(this)); // Moved up from below diff --git a/leaves-server/minecraft-patches/features/0124-Vanilla-Fluid-Pushing.patch b/leaves-server/minecraft-patches/features/0124-Vanilla-Fluid-Pushing.patch deleted file mode 100644 index e2f45935e..000000000 --- a/leaves-server/minecraft-patches/features/0124-Vanilla-Fluid-Pushing.patch +++ /dev/null @@ -1,93 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Fortern -Date: Thu, 19 Jun 2025 00:49:24 +0800 -Subject: [PATCH] Vanilla Fluid Pushing - - -diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 03972434172ff8615f0f5defa1076d348e0b6b19..5c63b9603f7b6f6c4ceca0d836df4a4972568631 100644 ---- a/net/minecraft/world/entity/Entity.java -+++ b/net/minecraft/world/entity/Entity.java -@@ -4770,8 +4770,82 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name - return Mth.lerp(partialTick, this.yRotO, this.yRot); - } - -+ // Leaves start - vanilla fluid pushing -+ private boolean vanillaUpdateFluidHeightAndDoFluidPushing(final TagKey fluidTag, final double motionScale) { -+ if (this.touchingUnloadedChunk()) { -+ return false; -+ } else { -+ AABB aabb = this.getBoundingBox().deflate(0.001); -+ int floor = Mth.floor(aabb.minX); -+ int ceil = Mth.ceil(aabb.maxX); -+ int floor1 = Mth.floor(aabb.minY); -+ int ceil1 = Mth.ceil(aabb.maxY); -+ int floor2 = Mth.floor(aabb.minZ); -+ int ceil2 = Mth.ceil(aabb.maxZ); -+ double d = 0.0; -+ boolean isPushedByFluid = this.isPushedByFluid(); -+ boolean flag = false; -+ Vec3 vec3 = Vec3.ZERO; -+ int i = 0; -+ BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); -+ -+ for (int i1 = floor; i1 < ceil; i1++) { -+ for (int i2 = floor1; i2 < ceil1; i2++) { -+ for (int i3 = floor2; i3 < ceil2; i3++) { -+ mutableBlockPos.set(i1, i2, i3); -+ FluidState fluidState = this.level().getFluidState(mutableBlockPos); -+ if (fluidState.is(fluidTag)) { -+ double d1 = i2 + fluidState.getHeight(this.level(), mutableBlockPos); -+ if (d1 >= aabb.minY) { -+ flag = true; -+ d = Math.max(d1 - aabb.minY, d); -+ if (isPushedByFluid) { -+ Vec3 flow = fluidState.getFlow(this.level(), mutableBlockPos); -+ if (d < 0.4) { -+ flow = flow.scale(d); -+ } -+ -+ vec3 = vec3.add(flow); -+ i++; -+ } -+ } -+ } -+ } -+ } -+ } -+ -+ if (vec3.length() > 0.0) { -+ if (i > 0) { -+ vec3 = vec3.scale(1.0 / i); -+ } -+ -+ if (!(this instanceof Player)) { -+ vec3 = vec3.normalize(); -+ } -+ -+ Vec3 deltaMovement = this.getDeltaMovement(); -+ vec3 = vec3.scale(motionScale); -+ double d2 = 0.003; -+ if (Math.abs(deltaMovement.x) < 0.003 && Math.abs(deltaMovement.z) < 0.003 && vec3.length() < 0.0045000000000000005) { -+ vec3 = vec3.normalize().scale(0.0045000000000000005); -+ } -+ -+ this.setDeltaMovement(this.getDeltaMovement().add(vec3)); -+ } -+ -+ this.fluidHeight.put(fluidTag, d); -+ return flag; -+ } -+ } -+ // Leaves end - vanilla fluid pushing -+ - // Paper start - optimise collisions - public boolean updateFluidHeightAndDoFluidPushing(final TagKey fluid, final double flowScale) { -+ // Leaves start - vanilla fluid pushing -+ if (org.leavesmc.leaves.LeavesConfig.fix.vanillaFluidPushing) { -+ return vanillaUpdateFluidHeightAndDoFluidPushing(fluid, flowScale); -+ } -+ // Leaves end - vanilla fluid pushing - if (this.touchingUnloadedChunk()) { - return false; - } diff --git a/leaves-server/minecraft-patches/features/0125-Old-wet-tnt-explode-behavior.patch b/leaves-server/minecraft-patches/features/0125-Old-wet-tnt-explode-behavior.patch new file mode 100644 index 000000000..eb2588040 --- /dev/null +++ b/leaves-server/minecraft-patches/features/0125-Old-wet-tnt-explode-behavior.patch @@ -0,0 +1,18 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MC_XiaoHei +Date: Fri, 4 Jul 2025 08:55:31 +0800 +Subject: [PATCH] Old wet tnt explode behavior + + +diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java +index 1e94326047622d8975fd1cc5f44e75104fd56946..b6c289e9615753b2da66c995f2f950e874514ad9 100644 +--- a/net/minecraft/world/level/ServerExplosion.java ++++ b/net/minecraft/world/level/ServerExplosion.java +@@ -717,6 +717,7 @@ public class ServerExplosion implements Explosion { + public boolean shouldAffectBlocklikeEntities() { + 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 (org.leavesmc.leaves.LeavesConfig.modify.oldMC.tntWetExplosionNoItemDamage) 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/leaves-server/minecraft-patches/features/0126-Old-projectile-explosion-behavior.patch b/leaves-server/minecraft-patches/features/0126-Old-projectile-explosion-behavior.patch new file mode 100644 index 000000000..0b8ccf0ad --- /dev/null +++ b/leaves-server/minecraft-patches/features/0126-Old-projectile-explosion-behavior.patch @@ -0,0 +1,25 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: MC_XiaoHei +Date: Fri, 4 Jul 2025 09:11:46 +0800 +Subject: [PATCH] Old projectile explosion behavior + + +diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java +index b6c289e9615753b2da66c995f2f950e874514ad9..f43bb2d76ea8ad34065ad296609eecc4ef6edf34 100644 +--- a/net/minecraft/world/level/ServerExplosion.java ++++ b/net/minecraft/world/level/ServerExplosion.java +@@ -541,7 +541,13 @@ public class ServerExplosion implements Explosion { + // Paper end - knockback events + } + // CraftBukkit end +- entity.push(vec32); ++ // Leaves start - old projectile explosion behavior ++ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.oldProjectileExplosionBehavior) { ++ entity.setDeltaMovement(entity.getDeltaMovement().add(vec32)); ++ } else { ++ entity.push(vec32); ++ } ++ // Leaves end - old projectile explosion behavior + if (entity.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) && entity instanceof Projectile projectile) { + projectile.setOwner(this.damageSource.getEntity()); + } else if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback diff --git a/leaves-server/minecraft-patches/features/0130-Prevent-loss-of-item-drops-due-to-update-suppression.patch b/leaves-server/minecraft-patches/features/0127-Prevent-loss-of-item-drops-due-to-update-suppression.patch similarity index 91% rename from leaves-server/minecraft-patches/features/0130-Prevent-loss-of-item-drops-due-to-update-suppression.patch rename to leaves-server/minecraft-patches/features/0127-Prevent-loss-of-item-drops-due-to-update-suppression.patch index c31e811a9..77a45224d 100644 --- a/leaves-server/minecraft-patches/features/0130-Prevent-loss-of-item-drops-due-to-update-suppression.patch +++ b/leaves-server/minecraft-patches/features/0127-Prevent-loss-of-item-drops-due-to-update-suppression.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Prevent loss of item drops due to update suppression when diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java -index fc205e54941d40a5583129b0c6540950f97a6b49..2b69ff82977f3592fb99ef494d090d77be34c186 100644 +index 24632205303bbcb2240a851b9d8baf8bbdfe4622..caf753c700ae2542627ff60e420bc40ab04ae013 100644 --- a/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/net/minecraft/server/level/ServerPlayerGameMode.java -@@ -402,11 +402,21 @@ public class ServerPlayerGameMode { +@@ -399,11 +399,21 @@ public class ServerPlayerGameMode { this.level.captureDrops = new java.util.ArrayList<>(); // CraftBukkit end BlockState blockState1 = org.leavesmc.leaves.command.leaves.subcommands.BlockUpdateCommand.isNoBlockUpdate() ? blockState : block.playerWillDestroy(this.level, pos, blockState, this.player); // Leaves - no block update @@ -33,7 +33,7 @@ index fc205e54941d40a5583129b0c6540950f97a6b49..2b69ff82977f3592fb99ef494d090d77 if (flag) { block.destroy(this.level, pos, blockState1); } -@@ -434,6 +444,7 @@ public class ServerPlayerGameMode { +@@ -431,6 +441,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/leaves-server/minecraft-patches/features/0131-Fix-block-place-desync-due-to-update-suppression.patch b/leaves-server/minecraft-patches/features/0128-Fix-block-place-desync-due-to-update-suppression.patch similarity index 88% rename from leaves-server/minecraft-patches/features/0131-Fix-block-place-desync-due-to-update-suppression.patch rename to leaves-server/minecraft-patches/features/0128-Fix-block-place-desync-due-to-update-suppression.patch index 6f02159bb..06a3a2c87 100644 --- a/leaves-server/minecraft-patches/features/0131-Fix-block-place-desync-due-to-update-suppression.patch +++ b/leaves-server/minecraft-patches/features/0128-Fix-block-place-desync-due-to-update-suppression.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix block place desync due to update suppression diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java -index fba077a5b6b9256dd117ae72c6aa0c63452a3eaa..33df00727e42ee0728dfb6a8c0816395fab5d4a9 100644 +index 2d01258e377ad1d628b193d15d794a057c3d11b4..f0a27175e044f49f47ac012e0d81b61832ff5af5 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -390,8 +390,18 @@ public final class ItemStack implements DataComponentHolder { +@@ -395,8 +395,18 @@ public final class ItemStack implements DataComponentHolder { } } InteractionResult interactionResult; @@ -27,7 +27,7 @@ index fba077a5b6b9256dd117ae72c6aa0c63452a3eaa..33df00727e42ee0728dfb6a8c0816395 } finally { serverLevel.captureBlockStates = false; } -@@ -538,6 +548,7 @@ public final class ItemStack implements DataComponentHolder { +@@ -543,6 +553,7 @@ public final class ItemStack implements DataComponentHolder { serverLevel.capturedBlockStates.clear(); // CraftBukkit end diff --git a/leaves-server/minecraft-patches/features/0128-Old-wet-tnt-explode-behavior.patch b/leaves-server/minecraft-patches/features/0128-Old-wet-tnt-explode-behavior.patch deleted file mode 100644 index 199d90f3b..000000000 --- a/leaves-server/minecraft-patches/features/0128-Old-wet-tnt-explode-behavior.patch +++ /dev/null @@ -1,18 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MC_XiaoHei -Date: Fri, 4 Jul 2025 08:55:31 +0800 -Subject: [PATCH] Old wet tnt explode behavior - - -diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index 1c521f9f32340cf75310686c90777e521ac3ae5c..8b0341c060d9f61698f32dd05c360c303a443c9b 100644 ---- a/net/minecraft/world/level/ServerExplosion.java -+++ b/net/minecraft/world/level/ServerExplosion.java -@@ -719,6 +719,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 (org.leavesmc.leaves.LeavesConfig.modify.oldMC.tntWetExplosionNoItemDamage) flag = flag && (this.source == null || !this.source.isInWater()); // Leaves - Old MC TNT wet explosion no item damage - return _boolean ? flag : this.blockInteraction.shouldAffectBlocklikeEntities() && flag; - } - diff --git a/leaves-server/minecraft-patches/features/0133-Old-ender-dragon-part-can-use-end-portal.patch b/leaves-server/minecraft-patches/features/0129-Old-ender-dragon-part-can-use-end-portal.patch similarity index 73% rename from leaves-server/minecraft-patches/features/0133-Old-ender-dragon-part-can-use-end-portal.patch rename to leaves-server/minecraft-patches/features/0129-Old-ender-dragon-part-can-use-end-portal.patch index 4571ffebd..6bbda2d04 100644 --- a/leaves-server/minecraft-patches/features/0133-Old-ender-dragon-part-can-use-end-portal.patch +++ b/leaves-server/minecraft-patches/features/0129-Old-ender-dragon-part-can-use-end-portal.patch @@ -26,56 +26,56 @@ This patch is Powered by CrystalCarpetAddition(https://github.com/Crystal0404/Cr */ diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 01b4bcf6f975a9d7d083909f23c9bfb02fc074b2..6e763cec6201b641e5775c7d61bf3dc7e9b76c6b 100644 +index 21c605ec1fc93366bc4c2d82d5ef9137a07b1d3b..d3316e443b950e709d7e56266a777d0fc1205c87 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -186,7 +186,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -189,7 +189,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name // Paper end - Share random for entities to make them more random - public @Nullable org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason + public org.bukkit.event.entity.CreatureSpawnEvent.@Nullable SpawnReason spawnReason; // Paper - Entity#getEntitySpawnReason -- private volatile @Nullable org.bukkit.craftbukkit.entity.CraftEntity bukkitEntity; // Paper - Folia schedulers - volatile -+ public volatile @Nullable org.bukkit.craftbukkit.entity.CraftEntity bukkitEntity; // Paper - Folia schedulers - volatile // Leaves - private -> public +- private volatile org.bukkit.craftbukkit.entity.@Nullable CraftEntity bukkitEntity; // Paper - Folia schedulers - volatile ++ public volatile org.bukkit.craftbukkit.entity.@Nullable CraftEntity bukkitEntity; // Paper - Folia schedulers - volatile // Leaves - private -> public public org.bukkit.craftbukkit.entity.CraftEntity getBukkitEntity() { if (this.bukkitEntity == null) { -@@ -4020,7 +4020,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name - @Nullable - public Entity teleport(TeleportTransition teleportTransition) { +@@ -4044,7 +4044,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + + public @Nullable Entity teleport(TeleportTransition teleportTransition) { // Paper start - Fix item duplication and teleport issues - if ((!this.isAlive() || !this.valid) && (teleportTransition.newLevel() != this.level)) { -+ if (!(org.leavesmc.leaves.LeavesConfig.modify.oldMC.enderDragonPartCanUseEndPortal && this instanceof net.minecraft.world.entity.boss.EnderDragonPart)) if ((!this.isAlive() || !this.valid) && (teleportTransition.newLevel() != this.level)) { // Leaves - endDragonPartCanUseEndPortal ++ if (!(org.leavesmc.leaves.LeavesConfig.modify.oldMC.enderDragonPartCanUseEndPortal && this instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragonPart)) if ((!this.isAlive() || !this.valid) && (teleportTransition.newLevel() != this.level)) { // Leaves - endDragonPartCanUseEndPortal LOGGER.warn("Illegal Entity Teleport {} to {}:{}", this, teleportTransition.newLevel(), teleportTransition.position(), new Throwable()); return null; } -@@ -4137,7 +4137,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4160,7 +4160,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name entityx.restoreFrom(this); this.removeAfterChangingDimensions(); entityx.teleportSetPosition(PositionMoveRotation.of(this), PositionMoveRotation.of(teleportTransition), teleportTransition.relatives()); - if (this.inWorld) newLevel.addDuringTeleport(entityx); // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned -+ if (this.inWorld || (this instanceof net.minecraft.world.entity.boss.EnderDragonPart && org.leavesmc.leaves.LeavesConfig.modify.oldMC.enderDragonPartCanUseEndPortal)) newLevel.addDuringTeleport(entityx); // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned // Leaves - ender dragon part can use end portal ++ if (this.inWorld || (this instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragonPart && org.leavesmc.leaves.LeavesConfig.modify.oldMC.enderDragonPartCanUseEndPortal)) newLevel.addDuringTeleport(entityx); // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned // Leaves - ender dragon part can use end portal for (Entity entity2 : list) { entity2.startRiding(entityx, true, false); -@@ -4254,6 +4254,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -4277,6 +4277,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name } public boolean canTeleport(Level fromLevel, Level toLevel) { -+ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.enderDragonPartCanUseEndPortal && this instanceof net.minecraft.world.entity.boss.EnderDragonPart) return true; // Leaves - enderDragonPartCanUseEndPortal ++ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.enderDragonPartCanUseEndPortal && this instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragonPart) return true; // Leaves - enderDragonPartCanUseEndPortal if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowEntityPortalWithPassenger && (this.isPassenger() || this.isVehicle())) return false; // Leaves - allowEntityPortalWithPassenger if (!this.isAlive() || !this.valid) return false; // Paper - Fix item duplication and teleport issues if (fromLevel.dimension() == Level.END && toLevel.dimension() == Level.OVERWORLD) { diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java -index 1cefdab82744600c6e5886646450d4c3fab03181..e783710f312b8c7b97dfd227866b71cee45c4d21 100644 +index 7d70731905440c6b01639c0b50e259c619bf0421..4f417489f96217ef19e3ca624c5d791bf38a9237 100644 --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java -@@ -395,6 +395,16 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab +@@ -392,6 +392,16 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab if (!this.level().isClientSide() && this.tickCount % 5 == 0) { this.updateControlFlags(); } + // Leaves start - ender dragon part can use end portal + if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.enderDragonPartCanUseEndPortal) return; + if (!(this instanceof net.minecraft.world.entity.boss.enderdragon.EnderDragon dragon)) return; -+ for (net.minecraft.world.entity.boss.EnderDragonPart part : dragon.getSubEntities()) { ++ for (net.minecraft.world.entity.boss.enderdragon.EnderDragonPart part : dragon.getSubEntities()) { + PortalProcessor portalManager = part.portalProcess; + if (portalManager == null) continue; + if (!(portalManager.portal instanceof net.minecraft.world.level.block.EndPortalBlock)) continue; @@ -86,11 +86,11 @@ index 1cefdab82744600c6e5886646450d4c3fab03181..e783710f312b8c7b97dfd227866b71ce protected void updateControlFlags() { diff --git a/net/minecraft/world/entity/PortalProcessor.java b/net/minecraft/world/entity/PortalProcessor.java -index 88b07fbb96b20124777889830afa480673629d43..250c43fb38e2aabd0b58ef44c477f07eee48bce7 100644 +index 4e69e32ad000b8c02e44c3ffce24ff5e3c090a2f..2fdb9a7e0f81a988a17c63253b8574ddbab094d6 100644 --- a/net/minecraft/world/entity/PortalProcessor.java +++ b/net/minecraft/world/entity/PortalProcessor.java -@@ -7,7 +7,7 @@ import net.minecraft.world.level.block.Portal; - import net.minecraft.world.level.portal.TeleportTransition; +@@ -7,7 +7,7 @@ import net.minecraft.world.level.portal.TeleportTransition; + import org.jspecify.annotations.Nullable; public class PortalProcessor { - private final Portal portal; diff --git a/leaves-server/minecraft-patches/features/0129-Old-projectile-explosion-behavior.patch b/leaves-server/minecraft-patches/features/0129-Old-projectile-explosion-behavior.patch deleted file mode 100644 index 6df3e5c01..000000000 --- a/leaves-server/minecraft-patches/features/0129-Old-projectile-explosion-behavior.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MC_XiaoHei -Date: Fri, 4 Jul 2025 09:11:46 +0800 -Subject: [PATCH] Old projectile explosion behavior - - -diff --git a/net/minecraft/world/level/ServerExplosion.java b/net/minecraft/world/level/ServerExplosion.java -index 8b0341c060d9f61698f32dd05c360c303a443c9b..7a3f9305abc7f094611c6d7ca36ca664bd483a73 100644 ---- a/net/minecraft/world/level/ServerExplosion.java -+++ b/net/minecraft/world/level/ServerExplosion.java -@@ -538,7 +538,7 @@ public class ServerExplosion implements Explosion { - // Paper end - knockback events - } - // CraftBukkit end -- entity.push(vec32); -+ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.oldProjectileExplosionBehavior) entity.setDeltaMovement(entity.getDeltaMovement().add(vec32)); else entity.push(vec32); // Leaves - old projectile explosion behavior - if (entity.getType().is(EntityTypeTags.REDIRECTABLE_PROJECTILE) && entity instanceof Projectile projectile) { - projectile.setOwner(this.damageSource.getEntity()); - } else if (entity instanceof Player player && !player.isSpectator() && (!player.isCreative() || !player.getAbilities().flying) && !level.paperConfig().environment.disableExplosionKnockback) { // Paper - Option to disable explosion knockback diff --git a/leaves-server/minecraft-patches/features/0130-Configurable-collision-behavior.patch b/leaves-server/minecraft-patches/features/0130-Configurable-collision-behavior.patch new file mode 100644 index 000000000..2c034c9df --- /dev/null +++ b/leaves-server/minecraft-patches/features/0130-Configurable-collision-behavior.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Fortern +Date: Thu, 24 Oct 2024 23:10:34 +0800 +Subject: [PATCH] Configurable collision behavior + + +diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +index de764da80793d272ff597b4a0742ce785838799a..c818a3a64e5f7deadd4a1ca702dd396a7c3fedde 100644 +--- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java ++++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java +@@ -2022,7 +2022,7 @@ public final class CollisionUtil { + continue; + } + } else { +- if (!voxelShapeIntersect(aabb, singleAABB)) { ++ if (shouldSkip(aabb, singleAABB)) { // Leaves - Configurable collision behavior + continue; + } + } +@@ -2076,6 +2076,16 @@ public final class CollisionUtil { + return ret; + } + ++ // Leaves start - Configurable collision behavior ++ private static boolean shouldSkip(net.minecraft.world.phys.AABB aabb, net.minecraft.world.phys.AABB singleAABB) { ++ return switch (org.leavesmc.leaves.LeavesConfig.fix.collisionBehavior) { ++ // Paper has changed to block shape vanilla, so we only check fully vanilla here ++ case PAPER -> !voxelShapeIntersect(aabb, singleAABB); ++ case VANILLA -> !aabb.intersects(singleAABB); ++ }; ++ } ++ // Leaves end - Configurable collision behavior ++ + public static boolean getEntityHardCollisions(final Level world, final Entity entity, AABB aabb, + final List into, final int collisionFlags, final Predicate predicate) { + final boolean checkOnly = (collisionFlags & COLLISION_FLAG_CHECK_ONLY) != 0; diff --git a/leaves-server/minecraft-patches/features/0136-Lithium-Sleeping-Block-Entity.patch b/leaves-server/minecraft-patches/features/0131-Lithium-Sleeping-Block-Entity.patch similarity index 93% rename from leaves-server/minecraft-patches/features/0136-Lithium-Sleeping-Block-Entity.patch rename to leaves-server/minecraft-patches/features/0131-Lithium-Sleeping-Block-Entity.patch index c0a25fd00..62dcee1d8 100644 --- a/leaves-server/minecraft-patches/features/0136-Lithium-Sleeping-Block-Entity.patch +++ b/leaves-server/minecraft-patches/features/0131-Lithium-Sleeping-Block-Entity.patch @@ -17,32 +17,32 @@ As part of: Lithium (https://github.com/CaffeineMC/lithium) Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html) diff --git a/net/minecraft/core/NonNullList.java b/net/minecraft/core/NonNullList.java -index 40b4222ecc5a87e374e561513eb25cd1aa39e33d..e8b9542294f9b227c8817bddbb28a4d08d19e48c 100644 +index ede0a5403739a2cf8bf101d7b12748c8acce87f5..21e6190ae894a73cde27c6321c602acab2098cc0 100644 --- a/net/minecraft/core/NonNullList.java +++ b/net/minecraft/core/NonNullList.java -@@ -9,7 +9,7 @@ import javax.annotation.Nonnull; - import javax.annotation.Nullable; +@@ -8,7 +8,7 @@ import java.util.Objects; + import org.jspecify.annotations.Nullable; public class NonNullList extends AbstractList { - private final List list; + public final List list; // Leaves - private -> public - @Nullable - private final E defaultValue; + private final @Nullable E defaultValue; + public static NonNullList create() { diff --git a/net/minecraft/core/component/PatchedDataComponentMap.java b/net/minecraft/core/component/PatchedDataComponentMap.java -index 766b6080160d87742ef4d8caa73b3b8fa52d5589..10c811e960fe8e68908a7216c78ddd196a2c60e2 100644 +index 4276819c6143b41886e26d359a562beb3b277afc..56f0573bb74ea1e5f09851d421b83db23594441e 100644 --- a/net/minecraft/core/component/PatchedDataComponentMap.java +++ b/net/minecraft/core/component/PatchedDataComponentMap.java @@ -14,7 +14,7 @@ import java.util.Map.Entry; import java.util.stream.Collectors; - import javax.annotation.Nullable; + import org.jspecify.annotations.Nullable; -public final class PatchedDataComponentMap implements DataComponentMap { +public final class PatchedDataComponentMap implements DataComponentMap, org.leavesmc.leaves.lithium.common.util.change_tracking.ChangePublisher { // Leaves - Lithium Sleeping Block Entity private final DataComponentMap prototype; private Reference2ObjectMap, Optional> patch; private boolean copyOnWrite; -@@ -140,6 +140,7 @@ public final class PatchedDataComponentMap implements DataComponentMap { +@@ -136,6 +136,7 @@ public final class PatchedDataComponentMap implements DataComponentMap { } private void ensureMapOwnership() { @@ -50,7 +50,7 @@ index 766b6080160d87742ef4d8caa73b3b8fa52d5589..10c811e960fe8e68908a7216c78ddd19 if (this.copyOnWrite) { this.patch = new Reference2ObjectArrayMap<>(this.patch); this.copyOnWrite = false; -@@ -243,4 +244,22 @@ public final class PatchedDataComponentMap implements DataComponentMap { +@@ -239,4 +240,22 @@ public final class PatchedDataComponentMap implements DataComponentMap { public String toString() { return "{" + this.stream().map(TypedDataComponent::toString).collect(Collectors.joining(", ")) + "}"; } @@ -74,7 +74,7 @@ index 766b6080160d87742ef4d8caa73b3b8fa52d5589..10c811e960fe8e68908a7216c78ddd19 + // Leaves end - Lithium Sleeping Block Entity } diff --git a/net/minecraft/server/commands/data/EntityDataAccessor.java b/net/minecraft/server/commands/data/EntityDataAccessor.java -index 2b8d394dc30d459127289a1afeee0780003f4c79..6b7a9a05cebdf53ab7eb4d389c48090c6c2a2983 100644 +index 6f01763c178324dd1741b996cd21cb9c23795b71..a4f32e6333b3b7ac56ac010f842ce61c7c5c78fb 100644 --- a/net/minecraft/server/commands/data/EntityDataAccessor.java +++ b/net/minecraft/server/commands/data/EntityDataAccessor.java @@ -55,6 +55,7 @@ public class EntityDataAccessor implements DataAccessor { @@ -86,10 +86,10 @@ index 2b8d394dc30d459127289a1afeee0780003f4c79..6b7a9a05cebdf53ab7eb4d389c48090c } } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index dbebfec31e8bd9b9ea6bbf486875396fdcba93b6..fa5d582843387e3846b70c01ac85c71e9031f2f1 100644 +index 81094f0ab63dfb48f7ae9a529d407dec5e356626..fa45be0a6349cea76daf4f90528fb890cb2a90b9 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -2472,6 +2472,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2502,6 +2502,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe for (TickingBlockEntity tickingBlockEntity : this.blockEntityTickers) { BlockPos pos = tickingBlockEntity.getPos(); @@ -98,32 +98,32 @@ index dbebfec31e8bd9b9ea6bbf486875396fdcba93b6..fa5d582843387e3846b70c01ac85c71e } } diff --git a/net/minecraft/world/Container.java b/net/minecraft/world/Container.java -index 5493576c54e87823f68bbf8a18441b373aae0461..10d786ef9f29f1af1cb5088f5e054f19b97cdc13 100644 +index 61646fe4b3476017a175a5d30fde53f13538ad9e..392678778dc2a036c1e3db4b6bb2800e452d3cd0 100644 --- a/net/minecraft/world/Container.java +++ b/net/minecraft/world/Container.java -@@ -13,7 +13,7 @@ import net.minecraft.world.item.ItemStack; - import net.minecraft.world.level.Level; +@@ -16,7 +16,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; + import org.jspecify.annotations.Nullable; --public interface Container extends Clearable, Iterable { -+public interface Container extends Clearable, Iterable, org.leavesmc.leaves.lithium.api.inventory.LithiumCooldownReceivingInventory, org.leavesmc.leaves.lithium.api.inventory.LithiumTransferConditionInventory { // Leaves - Lithium Sleeping Block Entity +-public interface Container extends Clearable, SlotProvider, Iterable { ++public interface Container extends Clearable, SlotProvider, Iterable, org.leavesmc.leaves.lithium.api.inventory.LithiumCooldownReceivingInventory, org.leavesmc.leaves.lithium.api.inventory.LithiumTransferConditionInventory { // Leaves - Lithium Sleeping Block Entity float DEFAULT_DISTANCE_BUFFER = 4.0F; int getContainerSize(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 4e0f223aaa3d719e6216ee8ab8415e32490a0da7..d9fe2e6d424231c7acd15cd5bb6a05afa2e263c6 100644 +index d3316e443b950e709d7e56266a777d0fc1205c87..f150ccb26cb191f4db68f1f4596eacd62343d117 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java -@@ -310,7 +310,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name +@@ -311,7 +311,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name private static final EntityDataAccessor DATA_NO_GRAVITY = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.BOOLEAN); protected static final EntityDataAccessor DATA_POSE = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.POSE); public static final EntityDataAccessor DATA_TICKS_FROZEN = SynchedEntityData.defineId(Entity.class, EntityDataSerializers.INT); - private EntityInLevelCallback levelCallback = EntityInLevelCallback.NULL; + public EntityInLevelCallback levelCallback = EntityInLevelCallback.NULL; // Leaves - private -> public private final VecDeltaCodec packetPositionCodec = new VecDeltaCodec(); - public boolean hasImpulse; - @Nullable -@@ -5176,6 +5176,19 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + public boolean needsSync; + public @Nullable PortalProcessor portalProcess; +@@ -5133,6 +5133,19 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name this.setBoundingBox(this.makeBoundingBox()); } // Paper end - Block invalid positions and bounding box @@ -144,13 +144,13 @@ index 4e0f223aaa3d719e6216ee8ab8415e32490a0da7..d9fe2e6d424231c7acd15cd5bb6a05af public void checkDespawn() { diff --git a/net/minecraft/world/entity/item/ItemEntity.java b/net/minecraft/world/entity/item/ItemEntity.java -index ca0905258d6308a71a0cda552feef6ee6f082a4b..dadd06970b02a3cd220c6db2ccc2ffd066168530 100644 +index 80f9c003b125a3af29c1456b6f796a43954a9aad..eeb34a80c1bb491caa60526c1c09e5d91c3bf373 100644 --- a/net/minecraft/world/entity/item/ItemEntity.java +++ b/net/minecraft/world/entity/item/ItemEntity.java -@@ -34,8 +34,12 @@ import net.minecraft.world.level.portal.TeleportTransition; - import net.minecraft.world.level.storage.ValueInput; +@@ -34,8 +34,12 @@ import net.minecraft.world.level.storage.ValueInput; import net.minecraft.world.level.storage.ValueOutput; import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; +// Leaves start - Lithium Sleeping Block Entity +import org.leavesmc.leaves.lithium.common.util.change_tracking.ChangePublisher; +import org.leavesmc.leaves.lithium.common.util.change_tracking.ChangeSubscriber; @@ -161,7 +161,7 @@ index ca0905258d6308a71a0cda552feef6ee6f082a4b..dadd06970b02a3cd220c6db2ccc2ffd0 private static final EntityDataAccessor DATA_ITEM = SynchedEntityData.defineId(ItemEntity.class, EntityDataSerializers.ITEM_STACK); private static final float FLOAT_HEIGHT = 0.1F; public static final float EYE_HEIGHT = 0.2125F; -@@ -526,6 +530,25 @@ public class ItemEntity extends Entity implements TraceableEntity { +@@ -522,6 +526,25 @@ public class ItemEntity extends Entity implements TraceableEntity { } public void setItem(ItemStack stack) { @@ -187,8 +187,8 @@ index ca0905258d6308a71a0cda552feef6ee6f082a4b..dadd06970b02a3cd220c6db2ccc2ffd0 this.getEntityData().set(DATA_ITEM, stack); this.despawnRate = this.level().paperConfig().entities.spawning.altItemDespawnRate.enabled ? this.level().paperConfig().entities.spawning.altItemDespawnRate.items.getOrDefault(stack.getItem(), this.level().spigotConfig.itemDespawnRate) : this.level().spigotConfig.itemDespawnRate; // Paper - Alternative item-despawn-rate } -@@ -601,4 +624,76 @@ public class ItemEntity extends Entity implements TraceableEntity { - public SlotAccess getSlot(int slot) { +@@ -597,4 +620,76 @@ public class ItemEntity extends Entity implements TraceableEntity { + public @Nullable SlotAccess getSlot(int slot) { return slot == 0 ? SlotAccess.of(this::getItem, this::setItem) : super.getSlot(slot); } + @@ -264,20 +264,20 @@ index ca0905258d6308a71a0cda552feef6ee6f082a4b..dadd06970b02a3cd220c6db2ccc2ffd0 + } + // Leaves end - Lithium Sleeping Block Entity } -diff --git a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -index 8fdde0cc090c80b65b4c0d679bf4b412b6b761ee..92aa3950ec751378c5e2b17dc109bbf79df758b3 100644 ---- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -+++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java -@@ -21,7 +21,7 @@ import net.minecraft.world.level.storage.ValueOutput; - import net.minecraft.world.level.storage.loot.LootTable; +diff --git a/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java b/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java +index da1cfc043e261e7ed7bc85fa1e5e7ee2e2078630..22567f12fe9b3a3c7f8988bb196e78e804bcfd6f 100644 +--- a/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java ++++ b/net/minecraft/world/entity/vehicle/minecart/AbstractMinecartContainer.java +@@ -22,7 +22,7 @@ import net.minecraft.world.level.storage.loot.LootTable; import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; -public abstract class AbstractMinecartContainer extends AbstractMinecart implements ContainerEntity { +public abstract class AbstractMinecartContainer extends AbstractMinecart implements ContainerEntity, org.leavesmc.leaves.lithium.api.inventory.LithiumInventory { // Leaves - Lithium Sleeping Block Entity private NonNullList itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513 - @Nullable - public ResourceKey lootTable; -@@ -223,4 +223,15 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme + public @Nullable ResourceKey lootTable; + public long lootTableSeed; +@@ -221,4 +221,15 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme return this.getBukkitEntity().getLocation(); } // CraftBukkit end @@ -294,10 +294,10 @@ index 8fdde0cc090c80b65b4c0d679bf4b412b6b761ee..92aa3950ec751378c5e2b17dc109bbf7 + // Leaves end - Lithium Sleeping Block Entity } diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java -index 5ac49ee4743f7c4847e40dae6575f559df25abeb..80c3e83882fd43926b5d964a3b44320f19a910de 100644 +index 38af11add6b97a34c406e86278008c2652c241a1..792f37d1f4288be88d83eb25ccf5e3c5cb4eeb8c 100644 --- a/net/minecraft/world/inventory/AbstractContainerMenu.java +++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -935,6 +935,7 @@ public abstract class AbstractContainerMenu { +@@ -915,6 +915,7 @@ public abstract class AbstractContainerMenu { } else { float f = 0.0F; @@ -306,12 +306,12 @@ index 5ac49ee4743f7c4847e40dae6575f559df25abeb..80c3e83882fd43926b5d964a3b44320f ItemStack item = container.getItem(i); if (!item.isEmpty()) { diff --git a/net/minecraft/world/item/ItemStack.java b/net/minecraft/world/item/ItemStack.java -index b60e6e198e50e5d3794bb27a32023f9952121e86..024785b39c60776ce73e14bb9cd12cd4de013d27 100644 +index f0a27175e044f49f47ac012e0d81b61832ff5af5..16f219534e1118ff2d7ce6a447917d405eb19d5c 100644 --- a/net/minecraft/world/item/ItemStack.java +++ b/net/minecraft/world/item/ItemStack.java -@@ -95,8 +95,12 @@ import net.minecraft.world.level.block.state.pattern.BlockInWorld; - import org.apache.commons.lang3.function.TriConsumer; +@@ -101,8 +101,12 @@ import org.apache.commons.lang3.function.TriConsumer; import org.apache.commons.lang3.mutable.MutableBoolean; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; +// Leaves start - Lithium Sleeping Block Entity +import org.leavesmc.leaves.lithium.common.util.change_tracking.ChangePublisher; @@ -323,15 +323,15 @@ index b60e6e198e50e5d3794bb27a32023f9952121e86..024785b39c60776ce73e14bb9cd12cd4 private static final List OP_NBT_WARNING = List.of( Component.translatable("item.op_warning.line1").withStyle(ChatFormatting.RED, ChatFormatting.BOLD), Component.translatable("item.op_warning.line2").withStyle(ChatFormatting.RED), -@@ -979,6 +983,7 @@ public final class ItemStack implements DataComponentHolder { +@@ -1018,6 +1022,7 @@ public final class ItemStack implements DataComponentHolder { + // CraftBukkit end - @Nullable - public T set(DataComponentType component, @Nullable T value) { + public @Nullable T set(DataComponentType component, @Nullable T value) { + if (org.leavesmc.leaves.LeavesConfig.performance.sleepingBlockEntity && component == DataComponents.ENCHANTMENTS && this.subscriber instanceof ChangeSubscriber.EnchantmentSubscriber enchantmentSubscriber) enchantmentSubscriber.lithium$notifyAfterEnchantmentChange(this, this.subscriberData); // Leaves - Lithium Sleeping Block Entity return this.components.set(component, value); } -@@ -1326,6 +1331,23 @@ public final class ItemStack implements DataComponentHolder { +@@ -1366,6 +1371,23 @@ public final class ItemStack implements DataComponentHolder { } public void setCount(int count) { @@ -355,9 +355,9 @@ index b60e6e198e50e5d3794bb27a32023f9952121e86..024785b39c60776ce73e14bb9cd12cd4 this.count = count; } -@@ -1381,4 +1403,90 @@ public final class ItemStack implements DataComponentHolder { - public boolean canDestroyBlock(BlockState state, Level level, BlockPos pos, Player player) { - return this.getItem().canDestroyBlock(this, state, level, pos, player); +@@ -1434,4 +1456,90 @@ public final class ItemStack implements DataComponentHolder { + .or(() -> Optional.ofNullable(this.getItem().getItemDamageSource(attacker))) + .orElseGet(fallback); } + + // Leaves start - Lithium Sleeping Block Entity @@ -447,18 +447,18 @@ index b60e6e198e50e5d3794bb27a32023f9952121e86..024785b39c60776ce73e14bb9cd12cd4 + // Leaves end - Lithium Sleeping Block Entity } diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 07ab2907bb9e4de5810889bec6d2b08f9abfec0c..a8d8dce19cf780ecb8dd1025a36c642d50ee5f06 100644 +index 6b9f1e5421a66c0a42f93c66a61c0fbecc913a16..92747bbf355aa135a38df47cf7770bf74ab40dc9 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java -@@ -1178,6 +1178,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - int i = flags & -34; +@@ -1183,6 +1183,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + if ((flags & Block.UPDATE_KNOWN_SHAPE) == 0 && recursionLeft > 0) { // Leaves start - no block update if (org.leavesmc.leaves.command.leaves.subcommands.BlockUpdateCommand.isNoBlockUpdate()) { + if (org.leavesmc.leaves.LeavesConfig.performance.sleepingBlockEntity) org.leavesmc.leaves.lithium.common.hopper.HopperHelper.updateHopperOnUpdateSuppression(this, pos, flags, chunkAt, oldState != currentState); // Leaves - Lithium Sleeping Block Entity this.updatePOIOnBlockStateChange(pos, blockState, blockState1); return; } -@@ -1439,7 +1440,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl +@@ -1434,7 +1435,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl // Spigot end if (tickingBlockEntity.isRemoved()) { toRemove.add(tickingBlockEntity); // Paper - Fix MC-117075; use removeAll @@ -467,10 +467,10 @@ index 07ab2907bb9e4de5810889bec6d2b08f9abfec0c..a8d8dce19cf780ecb8dd1025a36c642d tickingBlockEntity.tick(); // Paper start - rewrite chunk system if ((++tickedEntities & 7) == 0) { -@@ -2138,4 +2139,25 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl - return this.id; - } +@@ -2116,4 +2117,25 @@ public abstract class Level implements LevelAccessor, AutoCloseable, ca.spottedl + return this.moonrise$getEntityLookup().getEntityCount(); // Paper - rewrite chunk system } + // Paper end - allow patching this logic + + // Leaves start - Lithium Sleeping Block Entity + public BlockEntity lithium$getLoadedExistingBlockEntity(BlockPos pos) { @@ -494,7 +494,7 @@ index 07ab2907bb9e4de5810889bec6d2b08f9abfec0c..a8d8dce19cf780ecb8dd1025a36c642d + // Leaves end - Lithium Sleeping Block Entity } diff --git a/net/minecraft/world/level/block/ComposterBlock.java b/net/minecraft/world/level/block/ComposterBlock.java -index 0707e08970a325f6a21f3fc2f48c0b7bfbcbcd45..e3d3875c9befe09587ce4318fbdf642bb3c8ae58 100644 +index 429e833ffe7c89d7b0ca7515dbd82ffc1ce8d60d..9fbd9b5d51685fac25fd05ef03276b4b5564c82f 100644 --- a/net/minecraft/world/level/block/ComposterBlock.java +++ b/net/minecraft/world/level/block/ComposterBlock.java @@ -411,7 +411,7 @@ public class ComposterBlock extends Block implements WorldlyContainerHolder { @@ -531,10 +531,10 @@ index 0707e08970a325f6a21f3fc2f48c0b7bfbcbcd45..e3d3875c9befe09587ce4318fbdf642b private final LevelAccessor level; private final BlockPos pos; diff --git a/net/minecraft/world/level/block/DiodeBlock.java b/net/minecraft/world/level/block/DiodeBlock.java -index b975297c0475049935c38554a8c736abbf9882de..0457761189ffd179c6cc1b7f9ffb4e67d9e5790a 100644 +index 0ca50622be8dc300babc6b01b12eddae7fdd38bc..0d45b5767045c719fec3f07c7e0e956c1901aeee 100644 --- a/net/minecraft/world/level/block/DiodeBlock.java +++ b/net/minecraft/world/level/block/DiodeBlock.java -@@ -173,6 +173,7 @@ public abstract class DiodeBlock extends HorizontalDirectionalBlock { +@@ -174,6 +174,7 @@ public abstract class DiodeBlock extends HorizontalDirectionalBlock { @Override protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) { this.updateNeighborsInFront(level, pos, state); @@ -543,19 +543,19 @@ index b975297c0475049935c38554a8c736abbf9882de..0457761189ffd179c6cc1b7f9ffb4e67 // Leaves start - behaviour 1.21.1- diff --git a/net/minecraft/world/level/block/HopperBlock.java b/net/minecraft/world/level/block/HopperBlock.java -index 32b2f73d371b4dd53cdadfc94ff5e4d7bdaf7e37..870df1a752e676fc8a6879250393c388496b1597 100644 +index 695520463adcc6000ef5a94c86466e93a59af118..cdbcf2edd2f95ee87239aaf7bad26189802115ad 100644 --- a/net/minecraft/world/level/block/HopperBlock.java +++ b/net/minecraft/world/level/block/HopperBlock.java -@@ -38,7 +38,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; - import net.minecraft.world.phys.shapes.Shapes; +@@ -37,7 +37,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; -public class HopperBlock extends BaseEntityBlock { +public class HopperBlock extends BaseEntityBlock implements org.leavesmc.leaves.lithium.common.block.entity.ShapeUpdateHandlingBlockBehaviour { // Leaves - Lithium Sleeping Block Entity public static final MapCodec CODEC = simpleCodec(HopperBlock::new); public static final EnumProperty FACING = BlockStateProperties.FACING_HOPPER; public static final BooleanProperty ENABLED = BlockStateProperties.ENABLED; -@@ -101,6 +101,17 @@ public class HopperBlock extends BaseEntityBlock { +@@ -97,6 +97,17 @@ public class HopperBlock extends BaseEntityBlock { protected void onPlace(BlockState state, Level level, BlockPos pos, BlockState oldState, boolean movedByPiston) { if (!oldState.is(state.getBlock())) { this.checkPoweredState(level, pos, state); @@ -573,7 +573,7 @@ index 32b2f73d371b4dd53cdadfc94ff5e4d7bdaf7e37..870df1a752e676fc8a6879250393c388 } } -@@ -115,6 +126,7 @@ public class HopperBlock extends BaseEntityBlock { +@@ -111,6 +122,7 @@ public class HopperBlock extends BaseEntityBlock { @Override protected void neighborChanged(BlockState state, Level level, BlockPos pos, Block neighborBlock, @Nullable Orientation orientation, boolean movedByPiston) { @@ -581,7 +581,7 @@ index 32b2f73d371b4dd53cdadfc94ff5e4d7bdaf7e37..870df1a752e676fc8a6879250393c388 this.checkPoweredState(level, pos, state); } -@@ -176,4 +188,25 @@ public class HopperBlock extends BaseEntityBlock { +@@ -172,4 +184,25 @@ public class HopperBlock extends BaseEntityBlock { protected boolean isPathfindable(BlockState state, PathComputationType pathComputationType) { return false; } @@ -608,12 +608,12 @@ index 32b2f73d371b4dd53cdadfc94ff5e4d7bdaf7e37..870df1a752e676fc8a6879250393c388 + // Leaves end - Lithium Sleeping Block Entity } diff --git a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -index 005fd35dcae20d404922ef797cf22ef69ecd6c3a..7f2b702ec1dfc900e87a8871944e7b7ad2896b5e 100644 +index 5b6baeabc4b09ca59a7a9965692d9307a4d3f397..398767a4e05847e5100e6656af4dfe921f2b1809 100644 --- a/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java +++ b/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java -@@ -40,7 +40,7 @@ import net.minecraft.world.level.storage.ValueInput; - import net.minecraft.world.level.storage.ValueOutput; +@@ -40,7 +40,7 @@ import net.minecraft.world.level.storage.ValueOutput; import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; -public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntity implements WorldlyContainer, RecipeCraftingHolder, StackedContentsCompatible { +public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntity implements WorldlyContainer, RecipeCraftingHolder, StackedContentsCompatible, org.leavesmc.leaves.lithium.common.block.entity.inventory_change_tracking.InventoryChangeTracker, org.leavesmc.leaves.lithium.common.block.entity.SleepingBlockEntity, org.leavesmc.leaves.lithium.common.block.entity.SetChangedHandlingBlockEntity, org.leavesmc.leaves.lithium.api.inventory.LithiumInventory { // Leaves - Lithium Sleeping Block Entity @@ -636,7 +636,7 @@ index 005fd35dcae20d404922ef797cf22ef69ecd6c3a..7f2b702ec1dfc900e87a8871944e7b7a } private static boolean canBurn( -@@ -542,4 +544,53 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit +@@ -535,4 +537,53 @@ public abstract class AbstractFurnaceBlockEntity extends BaseContainerBlockEntit this.getRecipesToAwardAndPopExperience(serverLevel, Vec3.atCenterOf(pos)); } } @@ -731,13 +731,13 @@ index 6741fe3abc4396236dc0ca31074e36d66e42c39a..780474a3f7b7128ca571356e26d0ae32 + // Leaves end - Lithium Sleeping Block Entity } diff --git a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -index 1e6819928ffab524197003bd9469adb3976dce3a..cb9b653af455847312e4298b1acd2c7952f9c407 100644 +index b1be97f37398240ce564aba6c700319243be215c..c49b08aec71c60a1e18476af41891e7af92aa63f 100644 --- a/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BaseContainerBlockEntity.java -@@ -23,8 +23,17 @@ import net.minecraft.world.item.component.ItemContainerContents; - import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.level.storage.ValueInput; +@@ -25,8 +25,17 @@ import net.minecraft.world.level.storage.ValueInput; import net.minecraft.world.level.storage.ValueOutput; + import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; +// Leaves start - Lithium Sleeping Block Entity +import it.unimi.dsi.fastutil.objects.ReferenceArraySet; +import org.leavesmc.leaves.lithium.api.inventory.LithiumInventory; @@ -751,9 +751,9 @@ index 1e6819928ffab524197003bd9469adb3976dce3a..cb9b653af455847312e4298b1acd2c79 -public abstract class BaseContainerBlockEntity extends BlockEntity implements Container, MenuProvider, Nameable { +public abstract class BaseContainerBlockEntity extends BlockEntity implements Container, MenuProvider, Nameable, InventoryChangeEmitter { public LockCode lockKey = LockCode.NO_LOCK; - @Nullable - public Component name; -@@ -38,6 +47,7 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co + public @Nullable Component name; + +@@ -39,6 +48,7 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co super.loadAdditional(input); this.lockKey = LockCode.fromTag(input); this.name = parseCustomNameSafe(input, "CustomName"); @@ -761,7 +761,7 @@ index 1e6819928ffab524197003bd9469adb3976dce3a..cb9b653af455847312e4298b1acd2c79 } @Override -@@ -210,4 +220,97 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co +@@ -183,4 +193,97 @@ public abstract class BaseContainerBlockEntity extends BlockEntity implements Co return org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.worldPosition, this.level); } // CraftBukkit end @@ -860,12 +860,12 @@ index 1e6819928ffab524197003bd9469adb3976dce3a..cb9b653af455847312e4298b1acd2c79 + } } diff --git a/net/minecraft/world/level/block/entity/BlockEntity.java b/net/minecraft/world/level/block/entity/BlockEntity.java -index bd038bdaa00fb1e09b098b4d2809d17e2382288b..fb53735c637bee86237d6a411d14569d48a0c915 100644 +index fb22ebe9758014ebf2aebcda21155f1c4c83fafe..9bae6fde43ecef2959137c3a791ec76158ac920c 100644 --- a/net/minecraft/world/level/block/entity/BlockEntity.java +++ b/net/minecraft/world/level/block/entity/BlockEntity.java -@@ -35,8 +35,16 @@ import net.minecraft.world.level.storage.TagValueOutput; - import net.minecraft.world.level.storage.ValueInput; +@@ -35,8 +35,16 @@ import net.minecraft.world.level.storage.ValueInput; import net.minecraft.world.level.storage.ValueOutput; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; - -public abstract class BlockEntity implements DebugValueSource { @@ -882,7 +882,7 @@ index bd038bdaa00fb1e09b098b4d2809d17e2382288b..fb53735c637bee86237d6a411d14569d static boolean ignoreBlockEntityUpdates; // Paper - Perf: Optimize Hoppers // CraftBukkit start - data containers private static final org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry(); -@@ -58,6 +66,7 @@ public abstract class BlockEntity implements DebugValueSource { +@@ -57,6 +65,7 @@ public abstract class BlockEntity implements DebugValueSource { this.validateBlockState(blockState); this.blockState = blockState; this.persistentDataContainer = new org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer(DATA_TYPE_REGISTRY); // Paper - always init @@ -890,7 +890,7 @@ index bd038bdaa00fb1e09b098b4d2809d17e2382288b..fb53735c637bee86237d6a411d14569d } private void validateBlockState(BlockState state) { -@@ -232,6 +241,7 @@ public abstract class BlockEntity implements DebugValueSource { +@@ -229,6 +238,7 @@ public abstract class BlockEntity implements DebugValueSource { if (this.level != null) { if (ignoreBlockEntityUpdates) return; // Paper - Perf: Optimize Hoppers setChanged(this.level, this.worldPosition, this.blockState); @@ -898,7 +898,7 @@ index bd038bdaa00fb1e09b098b4d2809d17e2382288b..fb53735c637bee86237d6a411d14569d } } -@@ -264,7 +274,9 @@ public abstract class BlockEntity implements DebugValueSource { +@@ -260,7 +270,9 @@ public abstract class BlockEntity implements DebugValueSource { } public void setRemoved() { @@ -908,7 +908,7 @@ index bd038bdaa00fb1e09b098b4d2809d17e2382288b..fb53735c637bee86237d6a411d14569d } public void clearRemoved() { -@@ -304,6 +316,7 @@ public abstract class BlockEntity implements DebugValueSource { +@@ -300,6 +312,7 @@ public abstract class BlockEntity implements DebugValueSource { public void setBlockState(BlockState blockState) { this.validateBlockState(blockState); this.blockState = blockState; @@ -916,7 +916,7 @@ index bd038bdaa00fb1e09b098b4d2809d17e2382288b..fb53735c637bee86237d6a411d14569d } protected void applyImplicitComponents(DataComponentGetter componentGetter) { -@@ -408,4 +421,32 @@ public abstract class BlockEntity implements DebugValueSource { +@@ -402,4 +415,32 @@ public abstract class BlockEntity implements DebugValueSource { return this.blockEntity.getNameForReporting() + "@" + this.blockEntity.getBlockPos(); } } @@ -950,12 +950,12 @@ index bd038bdaa00fb1e09b098b4d2809d17e2382288b..fb53735c637bee86237d6a411d14569d + // Leaves end - Lithium Sleeping Block Entity } diff --git a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -index a4d3d5b6830d156c76e381c5437867c0ed104016..db6a4c2ca481796cfde8e5e5a6e38217a37a027c 100644 +index 5c51ecca91cfbe86bf815f7c3a1d26a23381a7da..8022390f4a6be506d30531a50c53253be76c758b 100644 --- a/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java +++ b/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java -@@ -26,7 +26,7 @@ import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.level.storage.ValueInput; +@@ -26,7 +26,7 @@ import net.minecraft.world.level.storage.ValueInput; import net.minecraft.world.level.storage.ValueOutput; + import org.jspecify.annotations.Nullable; -public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements WorldlyContainer { +public class BrewingStandBlockEntity extends BaseContainerBlockEntity implements WorldlyContainer, org.leavesmc.leaves.lithium.common.block.entity.inventory_change_tracking.InventoryChangeTracker, org.leavesmc.leaves.lithium.common.block.entity.SleepingBlockEntity, org.leavesmc.leaves.lithium.common.block.entity.SetChangedHandlingBlockEntity, org.leavesmc.leaves.lithium.api.inventory.LithiumInventory { // Leaves - Lithium Sleeping Block Entity- @@ -1057,11 +1057,11 @@ index a4d3d5b6830d156c76e381c5437867c0ed104016..db6a4c2ca481796cfde8e5e5a6e38217 + // Leaves end - Lithium Sleeping Block Entity } diff --git a/net/minecraft/world/level/block/entity/CampfireBlockEntity.java b/net/minecraft/world/level/block/entity/CampfireBlockEntity.java -index 78c4d1fc052d72f8599c82291d2233ec2e552137..a961ec0cfa334d924cf6016e729256987309d64c 100644 +index a27f578eb4d2dbcdb5cd72cb0aa3ec98cdb543c2..5a3457e5a72b1666fccc955aa5522d803e6b6024 100644 --- a/net/minecraft/world/level/block/entity/CampfireBlockEntity.java +++ b/net/minecraft/world/level/block/entity/CampfireBlockEntity.java -@@ -39,7 +39,7 @@ import net.minecraft.world.level.storage.ValueInput; - import net.minecraft.world.level.storage.ValueOutput; +@@ -39,7 +39,7 @@ import net.minecraft.world.level.storage.ValueOutput; + import org.jspecify.annotations.Nullable; import org.slf4j.Logger; -public class CampfireBlockEntity extends BlockEntity implements Clearable { @@ -1424,13 +1424,13 @@ index 775928cfe700202a70b19589ca72afd9768b62f1..c87e57f4f0aa2ffcf5531a55d971c804 + // Leaves end - Lithium Sleeping Block Entity } diff --git a/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -index 83a8dc51d0346fb5b28922e7b54d5ee58b315228..b67a1cacad31a93276988560ef03879a43c15aff 100644 +index bf681157626ce35b5e91ca8d2de49913bbbe2dff..a0f379fbbc926c219f1274e963d65ea348dfdf26 100644 --- a/net/minecraft/world/level/block/entity/HopperBlockEntity.java +++ b/net/minecraft/world/level/block/entity/HopperBlockEntity.java -@@ -27,8 +27,29 @@ import net.minecraft.world.level.block.state.BlockState; - import net.minecraft.world.level.storage.ValueInput; +@@ -27,8 +27,29 @@ import net.minecraft.world.level.storage.ValueInput; import net.minecraft.world.level.storage.ValueOutput; import net.minecraft.world.phys.AABB; + import org.jspecify.annotations.Nullable; - -public class HopperBlockEntity extends RandomizableContainerBlockEntity implements Hopper { +// Leaves start - Lithium Sleeping Block Entity @@ -1459,7 +1459,7 @@ index 83a8dc51d0346fb5b28922e7b54d5ee58b315228..b67a1cacad31a93276988560ef03879a public static final int MOVE_ITEM_SPEED = 8; public static final int HOPPER_CONTAINER_SIZE = 5; private static final int[][] CACHED_SLOTS = new int[54][]; -@@ -124,6 +145,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -119,6 +140,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @Override public void setBlockState(BlockState blockState) { @@ -1467,7 +1467,7 @@ index 83a8dc51d0346fb5b28922e7b54d5ee58b315228..b67a1cacad31a93276988560ef03879a super.setBlockState(blockState); this.facing = blockState.getValue(HopperBlock.FACING); } -@@ -152,6 +174,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -147,6 +169,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen boolean result = tryMoveItems(level, pos, state, blockEntity, () -> { return suckInItems(level, blockEntity); }); @@ -1475,7 +1475,7 @@ index 83a8dc51d0346fb5b28922e7b54d5ee58b315228..b67a1cacad31a93276988560ef03879a if (!result && blockEntity.level.spigotConfig.hopperCheck > 1) { blockEntity.setCooldown(blockEntity.level.spigotConfig.hopperCheck); } -@@ -241,6 +264,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -236,6 +259,14 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen org.leavesmc.leaves.protocol.PcaSyncProtocol.syncBlockEntityToClient(blockEntity); } // Leaves end - pca @@ -1490,7 +1490,7 @@ index 83a8dc51d0346fb5b28922e7b54d5ee58b315228..b67a1cacad31a93276988560ef03879a return true; } } -@@ -439,6 +470,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -434,6 +465,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen private static void applyCooldown(final Hopper hopper) { if (hopper instanceof HopperBlockEntity blockEntity && blockEntity.getLevel() != null) { blockEntity.setCooldown(blockEntity.getLevel().spigotConfig.hopperTransfer); @@ -1498,7 +1498,7 @@ index 83a8dc51d0346fb5b28922e7b54d5ee58b315228..b67a1cacad31a93276988560ef03879a } } -@@ -489,11 +521,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -484,11 +516,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } } // Leaves end - hopper counter @@ -1519,7 +1519,7 @@ index 83a8dc51d0346fb5b28922e7b54d5ee58b315228..b67a1cacad31a93276988560ef03879a if (isFullContainer(attachedContainer, opposite)) { return false; } else { -@@ -622,10 +662,18 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -617,10 +657,18 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen public static boolean suckInItems(Level level, Hopper hopper) { BlockPos blockPos = BlockPos.containing(hopper.getLevelX(), hopper.getLevelY() + 1.0, hopper.getLevelZ()); BlockState blockState = level.getBlockState(blockPos); @@ -1539,7 +1539,7 @@ index 83a8dc51d0346fb5b28922e7b54d5ee58b315228..b67a1cacad31a93276988560ef03879a for (int i : getSlots(sourceContainer, direction)) { if (tryTakeInItemFromSlot(hopper, sourceContainer, i, direction, level)) { // Spigot -@@ -637,7 +685,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -632,7 +680,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } else { boolean flag = hopper.isGridAligned() && (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.oldHopperSuckInBehavior && blockState.isCollisionShapeFullBlock(level, blockPos)) && !blockState.is(BlockTags.DOES_NOT_BLOCK_HOPPERS); // Leaves - oldHopperSuckInBehavior if (!flag) { @@ -1548,16 +1548,16 @@ index 83a8dc51d0346fb5b28922e7b54d5ee58b315228..b67a1cacad31a93276988560ef03879a if (addItem(hopper, itemEntity)) { return true; } -@@ -808,7 +856,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -813,7 +861,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen + // CraftBukkit start - @Nullable - private static Container runHopperInventorySearchEvent( + private static @Nullable Container runHopperInventorySearchEvent( - Container container, + @Nullable Container container, org.bukkit.craftbukkit.block.CraftBlock hopper, org.bukkit.craftbukkit.block.CraftBlock searchLocation, org.bukkit.event.inventory.HopperInventorySearchEvent.ContainerType containerType -@@ -936,6 +984,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -934,6 +982,19 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen } public void setCooldown(int cooldownTime) { @@ -1577,7 +1577,7 @@ index 83a8dc51d0346fb5b28922e7b54d5ee58b315228..b67a1cacad31a93276988560ef03879a this.cooldownTime = cooldownTime; } -@@ -955,6 +1016,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -953,6 +1014,7 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen @Override protected void setItems(NonNullList items) { this.items = items; @@ -1585,14 +1585,14 @@ index 83a8dc51d0346fb5b28922e7b54d5ee58b315228..b67a1cacad31a93276988560ef03879a } public static void entityInside(Level level, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) { -@@ -969,4 +1031,757 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen +@@ -967,4 +1029,757 @@ public class HopperBlockEntity extends RandomizableContainerBlockEntity implemen protected AbstractContainerMenu createMenu(int id, Inventory player) { return new HopperMenu(id, player, this); } + + // Leaves start - Lithium Sleeping Block Entity -+ @Nullable private LevelChunk.RebindableTickingBlockEntityWrapper tickWrapper = null; -+ @Nullable private TickingBlockEntity sleepingTicker = null; ++ @org.jetbrains.annotations.Nullable private LevelChunk.RebindableTickingBlockEntityWrapper tickWrapper = null; ++ @org.jetbrains.annotations.Nullable private TickingBlockEntity sleepingTicker = null; + private long myModCountAtLastInsert, myModCountAtLastExtract, myModCountAtLastItemCollect; + private boolean skipNextSleepCheckAfterCooldown = false; + @@ -1739,7 +1739,7 @@ index 83a8dc51d0346fb5b28922e7b54d5ee58b315228..b67a1cacad31a93276988560ef03879a + } + + @Override -+ public @Nullable LevelChunk.RebindableTickingBlockEntityWrapper lithium$getTickWrapper() { ++ public @org.jetbrains.annotations.Nullable LevelChunk.RebindableTickingBlockEntityWrapper lithium$getTickWrapper() { + return tickWrapper; + } + @@ -2344,19 +2344,19 @@ index 83a8dc51d0346fb5b28922e7b54d5ee58b315228..b67a1cacad31a93276988560ef03879a + // Leaves end - Lithium Sleeping Block Entity } diff --git a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -index 7e8ca373a48f89d30d4efdfcfe2acdc903a1fed9..7ba5024c645fd0026c77ab0bef64dafddc88f33d 100644 +index feab1f0d6f89035f6fcc7a568bd287821eb70a5e..c96405d2c5cfa3120e26f5ee58c15e3fc2b208e3 100644 --- a/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +++ b/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -@@ -32,7 +32,7 @@ import net.minecraft.world.level.storage.ValueOutput; - import net.minecraft.world.phys.AABB; +@@ -32,7 +32,7 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; + import org.jspecify.annotations.Nullable; -public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity implements WorldlyContainer { +public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity implements WorldlyContainer, org.leavesmc.leaves.lithium.common.block.entity.inventory_change_tracking.InventoryChangeTracker, org.leavesmc.leaves.lithium.common.block.entity.SleepingBlockEntity, org.leavesmc.leaves.lithium.api.inventory.LithiumInventory { // Leaves - Lithium Sleeping Block Entity public static final int COLUMNS = 9; public static final int ROWS = 3; public static final int CONTAINER_SIZE = 27; -@@ -135,6 +135,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl +@@ -134,6 +134,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl doNeighborUpdates(level, pos, state); } } @@ -2364,7 +2364,7 @@ index 7e8ca373a48f89d30d4efdfcfe2acdc903a1fed9..7ba5024c645fd0026c77ab0bef64dafd } public ShulkerBoxBlockEntity.AnimationStatus getAnimationStatus() { -@@ -175,6 +176,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl +@@ -174,6 +175,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl @Override public boolean triggerEvent(int id, int type) { @@ -2372,7 +2372,7 @@ index 7e8ca373a48f89d30d4efdfcfe2acdc903a1fed9..7ba5024c645fd0026c77ab0bef64dafd if (id == 1) { this.openCount = type; if (type == 0) { -@@ -266,6 +268,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl +@@ -265,6 +267,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl @Override protected void setItems(NonNullList items) { this.itemStacks = items; @@ -2380,7 +2380,7 @@ index 7e8ca373a48f89d30d4efdfcfe2acdc903a1fed9..7ba5024c645fd0026c77ab0bef64dafd } // Leaves start - pca -@@ -317,4 +320,39 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl +@@ -315,4 +318,39 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl OPENED, CLOSING; } @@ -2421,12 +2421,12 @@ index 7e8ca373a48f89d30d4efdfcfe2acdc903a1fed9..7ba5024c645fd0026c77ab0bef64dafd + // Leaves end - Lithium Sleeping Block Entity } diff --git a/net/minecraft/world/level/block/state/BlockBehaviour.java b/net/minecraft/world/level/block/state/BlockBehaviour.java -index 683a6a48593218b7504d6c99a0357278fb380665..d9f20b103361a788955b11048dbd91e405cca733 100644 +index 1d805ccd2bc9d74e8f15db37bcc8146b846e438e..b6e232fa850d4b5aecc4fcf7a5efecee5caac849 100644 --- a/net/minecraft/world/level/block/state/BlockBehaviour.java +++ b/net/minecraft/world/level/block/state/BlockBehaviour.java -@@ -84,7 +84,7 @@ import net.minecraft.world.phys.shapes.CollisionContext; - import net.minecraft.world.phys.shapes.Shapes; +@@ -84,7 +84,7 @@ import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; + import org.jspecify.annotations.Nullable; -public abstract class BlockBehaviour implements FeatureElement { +public abstract class BlockBehaviour implements FeatureElement, org.leavesmc.leaves.lithium.common.block.entity.ShapeUpdateHandlingBlockBehaviour { // Leaves - Lithium Sleeping Block Entity @@ -2442,10 +2442,10 @@ index 683a6a48593218b7504d6c99a0357278fb380665..d9f20b103361a788955b11048dbd91e4 } diff --git a/net/minecraft/world/level/chunk/LevelChunk.java b/net/minecraft/world/level/chunk/LevelChunk.java -index e6cc97e21e31faab0562e2a43766bd00f0451a19..0ae3b15906b0bee7c55dce64a4fe46623ee2ebe2 100644 +index d5a0a2c0a5673088e4ad1e2e7f4fac8a65f68ceb..952311cc4d3dc9e1354bcbd08287005578b6352d 100644 --- a/net/minecraft/world/level/chunk/LevelChunk.java +++ b/net/minecraft/world/level/chunk/LevelChunk.java -@@ -934,12 +934,14 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot +@@ -928,12 +928,14 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot (pos, ticker1) -> { TickingBlockEntity tickingBlockEntity = this.createTicker(blockEntity, ticker); if (ticker1 != null) { @@ -2460,7 +2460,7 @@ index e6cc97e21e31faab0562e2a43766bd00f0451a19..0ae3b15906b0bee7c55dce64a4fe4662 this.level.addBlockEntityTicker(rebindableTickingBlockEntityWrapper); return rebindableTickingBlockEntityWrapper; } else { -@@ -1033,14 +1035,14 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot +@@ -1027,14 +1029,14 @@ public class LevelChunk extends ChunkAccess implements DebugValueSource, ca.spot void run(LevelChunk chunk); } diff --git a/leaves-server/minecraft-patches/features/0137-Bring-back-LivingEntity-effect-CME.patch b/leaves-server/minecraft-patches/features/0132-Bring-back-LivingEntity-effect-CME.patch similarity index 87% rename from leaves-server/minecraft-patches/features/0137-Bring-back-LivingEntity-effect-CME.patch rename to leaves-server/minecraft-patches/features/0132-Bring-back-LivingEntity-effect-CME.patch index 16ab7048f..dc7b93feb 100644 --- a/leaves-server/minecraft-patches/features/0137-Bring-back-LivingEntity-effect-CME.patch +++ b/leaves-server/minecraft-patches/features/0132-Bring-back-LivingEntity-effect-CME.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Bring back LivingEntity effect CME diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 7a849ba0e22574f00f3580a432e2fe8343c883c6..b0db5cec1293109b32fd6bb40b350d81ea0afc7a 100644 +index 493bbb6fb85d2b014a9f94a07409c7a73829d234..9c32e5d4d28e035abadf76512181c22e49e11401 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java -@@ -1158,7 +1158,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -1161,7 +1161,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin public boolean addEffect(MobEffectInstance effectInstance, @Nullable Entity entity, EntityPotionEffectEvent.Cause cause, boolean fireEvent) { // Paper end - Don't fire sync event during generation // org.spigotmc.AsyncCatcher.catchOp("effect add"); // Spigot // Paper - move to API diff --git a/leaves-server/minecraft-patches/features/0132-TEMP-Merge-Paper-11831.patch b/leaves-server/minecraft-patches/features/0132-TEMP-Merge-Paper-11831.patch deleted file mode 100644 index b4b9f239c..000000000 --- a/leaves-server/minecraft-patches/features/0132-TEMP-Merge-Paper-11831.patch +++ /dev/null @@ -1,82 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: MC_XiaoHei -Date: Sat, 5 Jul 2025 11:31:44 +0800 -Subject: [PATCH] TEMP Merge Paper#11831 - -Dec 27, 2024 ~ Today - -diff --git a/net/minecraft/server/commands/GiveCommand.java b/net/minecraft/server/commands/GiveCommand.java -index f6e18d62db18616a422ae74d6f329d1b3a96300b..eb34f3f9821f50f0a31fb22d9314c26b3e829d47 100644 ---- a/net/minecraft/server/commands/GiveCommand.java -+++ b/net/minecraft/server/commands/GiveCommand.java -@@ -54,7 +54,6 @@ 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 = org.leavesmc.leaves.util.ItemOverstackUtils.getItemStackMaxCount(itemStack); // Leaves - item over-stack util - int i = maxStackSize * 100; - if (count > i) { -@@ -99,11 +98,11 @@ public class GiveCommand { - - if (targets.size() == 1) { - source.sendSuccess( -- () -> Component.translatable("commands.give.success.single", count, displayName, targets.iterator().next().getDisplayName()), // Paper - use cached display name -+ () -> Component.translatable("commands.give.success.single", count, itemStack.getDisplayName(), targets.iterator().next().getDisplayName()), // Paper - use cached display name - true - ); - } else { -- source.sendSuccess(() -> Component.translatable("commands.give.success.single", count, displayName, targets.size()), true); // Paper - use cached display name -+ source.sendSuccess(() -> Component.translatable("commands.give.success.single", count, itemStack.getDisplayName(), targets.size()), true); // Paper - use cached display name - } - - return targets.size(); -diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 5c63b9603f7b6f6c4ceca0d836df4a4972568631..01b4bcf6f975a9d7d083909f23c9bfb02fc074b2 100644 ---- a/net/minecraft/world/entity/Entity.java -+++ b/net/minecraft/world/entity/Entity.java -@@ -2888,10 +2888,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name - return null; - } - // CraftBukkit end -- ItemEntity itemEntity = new ItemEntity(level, this.getX() + offset.x, this.getY() + offset.y, this.getZ() + offset.z, stack.copy()); // Paper - copy so we can destroy original -- stack.setCount(0); // Paper - destroy this item - if this ever leaks due to game bugs, ensure it doesn't dupe -- -- itemEntity.setDefaultPickUpDelay(); // Paper - diff on change (in dropConsumer) -+ ItemEntity itemEntity = new ItemEntity(level, this.getX() + offset.x, this.getY() + offset.y, this.getZ() + offset.z, stack.copy()); // Paper - copy - // Paper start - Call EntityDropItemEvent - return this.spawnAtLocation(level, itemEntity); - } -diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 0610df1c343f1c5cf724a79fbc68ed1372de5da5..7a849ba0e22574f00f3580a432e2fe8343c883c6 100644 ---- a/net/minecraft/world/entity/LivingEntity.java -+++ b/net/minecraft/world/entity/LivingEntity.java -@@ -3996,11 +3996,6 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin - return null; - } else { - double d = this.getEyeY() - 0.3F; -- // Paper start -- final ItemStack tmp = stack.copy(); -- stack.setCount(0); -- stack = tmp; -- // Paper end - ItemEntity itemEntity = new ItemEntity(this.level(), this.getX(), d, this.getZ(), stack); - itemEntity.setPickUpDelay(40); - if (includeThrower) { -diff --git a/net/minecraft/world/inventory/AbstractContainerMenu.java b/net/minecraft/world/inventory/AbstractContainerMenu.java -index 509d368f7fa9e6330da02615d7bf78debb932623..5ac49ee4743f7c4847e40dae6575f559df25abeb 100644 ---- a/net/minecraft/world/inventory/AbstractContainerMenu.java -+++ b/net/minecraft/world/inventory/AbstractContainerMenu.java -@@ -652,7 +652,11 @@ public abstract class AbstractContainerMenu { - } - - carried = slot2.safeTake(i1, Integer.MAX_VALUE, player); -- player.drop(carried, true); -+ // CraftBukkit start - SPIGOT-8010: break loop -+ if (player.drop(carried, true) == null) { -+ break; -+ } -+ // CraftBukkit end - SPIGOT-8010: break loop - player.handleCreativeModeItemDrop(carried); - } - } diff --git a/leaves-server/minecraft-patches/features/0140-Lithium-Equipment-Tracking.patch b/leaves-server/minecraft-patches/features/0133-Lithium-Equipment-Tracking.patch similarity index 96% rename from leaves-server/minecraft-patches/features/0140-Lithium-Equipment-Tracking.patch rename to leaves-server/minecraft-patches/features/0133-Lithium-Equipment-Tracking.patch index 3e433ddf7..9e93240d4 100644 --- a/leaves-server/minecraft-patches/features/0140-Lithium-Equipment-Tracking.patch +++ b/leaves-server/minecraft-patches/features/0133-Lithium-Equipment-Tracking.patch @@ -195,7 +195,7 @@ index 1e00a7bd89d885cabb4b9ca3c86fbd8cd93cebf5..08e3d257ffdc5dfa996b1e16e477b4e0 + // Leaves end - Lithium - equipment tracking } diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index b0db5cec1293109b32fd6bb40b350d81ea0afc7a..c275942cb57f2e5fe1e1cc8bee92abef4343297b 100644 +index 9c32e5d4d28e035abadf76512181c22e49e11401..dc5bf3422069c28e0690cf9f1523e3674ca3cd75 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -432,9 +432,17 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin @@ -218,7 +218,7 @@ index b0db5cec1293109b32fd6bb40b350d81ea0afc7a..c275942cb57f2e5fe1e1cc8bee92abef super.baseTick(); ProfilerFiller profilerFiller = Profiler.get(); -@@ -3388,6 +3396,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3519,6 +3527,7 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin public void detectEquipmentUpdates() { Map map = this.collectEquipmentChanges(); if (map != null) { @@ -226,10 +226,10 @@ index b0db5cec1293109b32fd6bb40b350d81ea0afc7a..c275942cb57f2e5fe1e1cc8bee92abef this.handleHandSwap(map); if (!map.isEmpty()) { this.handleEquipmentChanges(map); -@@ -3397,6 +3406,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin +@@ -3527,6 +3536,14 @@ public abstract class LivingEntity extends Entity implements Attackable, Waypoin + } - @Nullable - private Map collectEquipmentChanges() { + private @Nullable Map collectEquipmentChanges() { + // Leaves start - Lithium - equipment tracking + if (org.leavesmc.leaves.LeavesConfig.performance.equipmentTracking) { + final boolean isArmorStandUpdateNoTick = this instanceof net.minecraft.world.entity.decoration.ArmorStand stand && !stand.canTick && stand.noTickEquipmentDirty; @@ -242,7 +242,7 @@ index b0db5cec1293109b32fd6bb40b350d81ea0afc7a..c275942cb57f2e5fe1e1cc8bee92abef // Paper start - EntityEquipmentChangedEvent record EquipmentChangeImpl(org.bukkit.inventory.ItemStack oldItem, org.bukkit.inventory.ItemStack newItem) implements io.papermc.paper.event.entity.EntityEquipmentChangedEvent.EquipmentChange { diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java -index 9420ca7e32ae71ce9cecf8afd808ae6e9f8f4258..de89f78978ee5ae67049eb83fda3d56ef8371781 100644 +index a35415dced4c15ece829cea74010f42f0cb00441..4ae5877c4622c1e7979bab4fa6d87ee4f1feea2b 100644 --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java @@ -90,7 +90,7 @@ public class ArmorStand extends LivingEntity { diff --git a/leaves-server/minecraft-patches/features/0134-Allow-Inf-NaN-values-in-entity-motions.patch b/leaves-server/minecraft-patches/features/0134-Allow-Inf-NaN-values-in-entity-motions.patch new file mode 100644 index 000000000..cbbf14895 --- /dev/null +++ b/leaves-server/minecraft-patches/features/0134-Allow-Inf-NaN-values-in-entity-motions.patch @@ -0,0 +1,89 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Fortern +Date: Mon, 29 Sep 2025 10:24:45 +0800 +Subject: [PATCH] Allow Inf NaN values in entity motions + + +diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java +index f150ccb26cb191f4db68f1f4596eacd62343d117..c6d0043c99c24d4883f17815dc54b2b7d283c950 100644 +--- a/net/minecraft/world/entity/Entity.java ++++ b/net/minecraft/world/entity/Entity.java +@@ -2370,7 +2370,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + } + + public void push(Vec3 vector) { +- if (vector.isFinite()) { ++ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowInfNanMotionValues || vector.isFinite()) { // Leaves - allow Inf NaN motion values + this.push(vector.x, vector.y, vector.z); + } + } +@@ -2382,7 +2382,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + + public void push(double x, double y, double z, @Nullable Entity pushingEntity) { + // Paper end - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent +- if (Double.isFinite(x) && Double.isFinite(y) && Double.isFinite(z)) { ++ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowInfNanMotionValues || (Double.isFinite(x) && Double.isFinite(y) && Double.isFinite(z))) { // Leaves - allow Inf NaN motion values + // Paper start - Add EntityKnockbackByEntityEvent and EntityPushedByEntityAttackEvent + org.bukkit.util.Vector delta = new org.bukkit.util.Vector(x, y, z); + if (pushingEntity != null) { +@@ -2588,14 +2588,18 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + output.store("Motion", Vec3.CODEC, this.getDeltaMovement()); + // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero + // TODO: make sure this is the best way to address this. +- if (Float.isNaN(this.yRot)) { +- this.yRot = 0; +- } ++ // Leaves start - allow Inf NaN motion values ++ if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowInfNanMotionValues) { ++ if (Float.isNaN(this.yRot)) { ++ this.yRot = 0; ++ } + +- if (Float.isNaN(this.xRot)) { +- this.xRot = 0; ++ if (Float.isNaN(this.xRot)) { ++ this.xRot = 0; ++ } + } + // CraftBukkit end ++ // Leaves end - allow Inf NaN motion values + output.store("Rotation", Vec2.CODEC, new Vec2(this.getYRot(), this.getXRot())); + output.putDouble("fall_distance", this.fallDistance); + output.putShort("Fire", (short)this.remainingFireTicks); +@@ -4984,15 +4988,15 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + } + + public void setDeltaMovement(Vec3 deltaMovement) { +- if (deltaMovement.isFinite()) { ++ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowInfNanMotionValues || deltaMovement.isFinite()) { // Leaves - allow Inf NaN motion values + synchronized (this.posLock) { // Paper - detailed watchdog information +- this.deltaMovement = deltaMovement; ++ this.deltaMovement = deltaMovement; + } // Paper - detailed watchdog information + } + } + + public void addDeltaMovement(Vec3 addend) { +- if (addend.isFinite()) { ++ if (org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowInfNanMotionValues || addend.isFinite()) { // Leaves - allow Inf NaN motion values + this.setDeltaMovement(this.getDeltaMovement().add(addend)); + } + } +@@ -5213,7 +5217,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + } + + public void setYRot(float yRot) { +- if (!Float.isFinite(yRot)) { ++ if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowInfNanMotionValues && !Float.isFinite(yRot)) { // Leaves - allow Inf NaN motion values + Util.logAndPauseIfInIde("Invalid entity rotation: " + yRot + ", discarding."); + } else { + this.yRot = yRot; +@@ -5225,7 +5229,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name + } + + public void setXRot(float xRot) { +- if (!Float.isFinite(xRot)) { ++ if (!org.leavesmc.leaves.LeavesConfig.modify.oldMC.allowInfNanMotionValues && !Float.isFinite(xRot)) { // Leaves - allow Inf NaN motion values + Util.logAndPauseIfInIde("Invalid entity rotation: " + xRot + ", discarding."); + } else { + this.xRot = Math.clamp(xRot % 360.0F, -90.0F, 90.0F); diff --git a/leaves-server/minecraft-patches/features/0134-Configurable-collision-behavior.patch b/leaves-server/minecraft-patches/features/0134-Configurable-collision-behavior.patch deleted file mode 100644 index 4b4ed57b4..000000000 --- a/leaves-server/minecraft-patches/features/0134-Configurable-collision-behavior.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Fortern -Date: Thu, 24 Oct 2024 23:10:34 +0800 -Subject: [PATCH] Configurable collision behavior - - -diff --git a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java -index 01cd38bba2deb6cf65c82b4e4ec352a2998fd339..8eb8e1447043498c6a0db1b56e877a91cd5fc438 100644 ---- a/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java -+++ b/ca/spottedleaf/moonrise/patches/collisions/CollisionUtil.java -@@ -101,6 +101,14 @@ public final class CollisionUtil { - (box1.minZ - box2.maxZ) < -COLLISION_EPSILON && (box1.maxZ - box2.minZ) > COLLISION_EPSILON; - } - -+ // Leaves start - Configurable collision behavior -+ public static boolean voxelShapeIntersectVanilla(final AABB box1, final AABB box2) { -+ return box1.minX < box2.maxX && box1.maxX > box2.minX && -+ box1.minY < box2.maxY && box1.maxY > box2.minY && -+ box1.minZ < box2.maxZ && box1.maxZ > box2.minZ; -+ } -+ // Leaves end - Configurable collision behavior -+ - // assume !isEmpty(target) && abs(source_move) >= COLLISION_EPSILON - public static double collideX(final AABB target, final AABB source, final double source_move) { - if ((source.minY - target.maxY) < -COLLISION_EPSILON && (source.maxY - target.minY) > COLLISION_EPSILON && -@@ -2014,7 +2022,9 @@ public final class CollisionUtil { - AABB singleAABB = ((CollisionVoxelShape)blockCollision).moonrise$getSingleAABBRepresentation(); - if (singleAABB != null) { - singleAABB = singleAABB.move((double)blockX, (double)blockY, (double)blockZ); -- if (!voxelShapeIntersect(aabb, singleAABB)) { -+ // Leaves start - Configurable collision behavior -+ if (shouldSkip(aabb, blockCollision, singleAABB)) { -+ // Leaves end - Configurable collision behavior - continue; - } - -@@ -2067,6 +2077,17 @@ public final class CollisionUtil { - return ret; - } - -+ // Leaves start - Configurable collision behavior -+ private static boolean shouldSkip(net.minecraft.world.phys.AABB aabb, net.minecraft.world.phys.shapes.VoxelShape blockCollision, net.minecraft.world.phys.AABB singleAABB) { -+ boolean isBlockShape = blockCollision == net.minecraft.world.phys.shapes.Shapes.block(); -+ return switch (org.leavesmc.leaves.LeavesConfig.fix.collisionBehavior) { -+ case PAPER -> !voxelShapeIntersect(aabb, singleAABB); -+ case VANILLA -> !voxelShapeIntersectVanilla(aabb, singleAABB); -+ case BLOCK_SHAPE_VANILLA -> isBlockShape && !voxelShapeIntersectVanilla(aabb, singleAABB) || !isBlockShape && !voxelShapeIntersect(aabb, singleAABB); -+ }; -+ } -+ // Leaves end - Configurable collision behavior -+ - public static boolean getEntityHardCollisions(final Level world, final Entity entity, AABB aabb, - final List into, final int collisionFlags, final Predicate predicate) { - final boolean checkOnly = (collisionFlags & COLLISION_FLAG_CHECK_ONLY) != 0; diff --git a/leaves-server/minecraft-patches/features/0135-Chat-command-max-length.patch b/leaves-server/minecraft-patches/features/0135-Chat-command-max-length.patch deleted file mode 100644 index 6f0d31a4c..000000000 --- a/leaves-server/minecraft-patches/features/0135-Chat-command-max-length.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Wed, 30 Jul 2025 17:58:24 +0800 -Subject: [PATCH] Chat command max length - - -diff --git a/net/minecraft/network/protocol/game/ServerboundChatCommandPacket.java b/net/minecraft/network/protocol/game/ServerboundChatCommandPacket.java -index 3b0931d9bb5eef6f900c09a1fc342516e708af58..9bfe3bc0e9993280e5dac75e858f76d246b16c20 100644 ---- a/net/minecraft/network/protocol/game/ServerboundChatCommandPacket.java -+++ b/net/minecraft/network/protocol/game/ServerboundChatCommandPacket.java -@@ -11,11 +11,11 @@ public record ServerboundChatCommandPacket(String command) implements Packet -Date: Thu, 14 Aug 2025 15:47:58 +0800 -Subject: [PATCH] Do not tick Arrow life regardless - - -diff --git a/net/minecraft/world/entity/projectile/AbstractArrow.java b/net/minecraft/world/entity/projectile/AbstractArrow.java -index 1be2a7f45866bfe69b8f181fee98d1336b0cfba3..1a60d8f993d28a2cd2364acdf68b353220de49ab 100644 ---- a/net/minecraft/world/entity/projectile/AbstractArrow.java -+++ b/net/minecraft/world/entity/projectile/AbstractArrow.java -@@ -212,7 +212,7 @@ public abstract class AbstractArrow extends Projectile { - this.setSharedFlagOnFire(this.getRemainingFireTicks() > 0); - } - } else { -- if (this.tickCount > 200) this.tickDespawn(); // Paper - tick life regardless after 10 seconds -+ // if (this.tickCount > 200) this.tickDespawn(); // Paper - tick life regardless after 10 seconds // Leaves - do not tick arrow life regardless - this.inGroundTime = 0; - Vec3 vec31 = this.position(); - if (this.isInWater()) { diff --git a/leaves-server/minecraft-patches/features/0145-Force-minecraft-command.patch b/leaves-server/minecraft-patches/features/0138-Force-minecraft-command.patch similarity index 84% rename from leaves-server/minecraft-patches/features/0145-Force-minecraft-command.patch rename to leaves-server/minecraft-patches/features/0138-Force-minecraft-command.patch index 88e059ffb..0d7ec6f12 100644 --- a/leaves-server/minecraft-patches/features/0145-Force-minecraft-command.patch +++ b/leaves-server/minecraft-patches/features/0138-Force-minecraft-command.patch @@ -5,11 +5,11 @@ Subject: [PATCH] Force minecraft command diff --git a/net/minecraft/commands/Commands.java b/net/minecraft/commands/Commands.java -index 83f05b042630891d43cfb567e98666831df80f6e..f7990278fe2e112025fffe9bfa3649db7aa4150a 100644 +index 668eb52d71d77f75c24d4840be9a6c49d96dfc34..f4452de35a589612c11b413f6e09524b90d2d507 100644 --- a/net/minecraft/commands/Commands.java +++ b/net/minecraft/commands/Commands.java -@@ -176,7 +176,21 @@ public class Commands { - return node.getRequirement() instanceof PermissionCheck permissionCheck && permissionCheck.requiredLevel() > 0; +@@ -185,7 +185,21 @@ public class Commands { + return !requirement.test(this.noPermissionSource); } }; - private final CommandDispatcher dispatcher = new CommandDispatcher<>(); diff --git a/leaves-server/minecraft-patches/features/0146-Fix-Paper-config-preventMovingIntoUnloadedChunks.patch b/leaves-server/minecraft-patches/features/0139-Fix-Paper-config-preventMovingIntoUnloadedChunks.patch similarity index 91% rename from leaves-server/minecraft-patches/features/0146-Fix-Paper-config-preventMovingIntoUnloadedChunks.patch rename to leaves-server/minecraft-patches/features/0139-Fix-Paper-config-preventMovingIntoUnloadedChunks.patch index 8c2e45a45..09f63ddfd 100644 --- a/leaves-server/minecraft-patches/features/0146-Fix-Paper-config-preventMovingIntoUnloadedChunks.patch +++ b/leaves-server/minecraft-patches/features/0139-Fix-Paper-config-preventMovingIntoUnloadedChunks.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Fix Paper config preventMovingIntoUnloadedChunks Co-authored-by: Lumine1909 <133463833+Lumine1909@users.noreply.github.com> diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 8d3151a6cc4d3a53601d41abce9d61323ce86a8c..5cdab59a3cf2c412ad3cf064a52b06d32758c139 100644 +index 051e3bac4f406df379ec1fc335f351b1089bda8b..fd17ac30f22490820200f13e432aec42d47eb3c4 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1763,11 +1763,15 @@ public class ServerGamePacketListenerImpl +@@ -1781,11 +1781,15 @@ public class ServerGamePacketListenerImpl private boolean hasNewCollision(final ServerLevel level, final Entity entity, final AABB oldBox, final AABB newBox) { final List collisionsBB = new java.util.ArrayList<>(); final List collisionsVoxel = new java.util.ArrayList<>(); diff --git a/leaves-server/minecraft-patches/features/0139-Modify-end-void-rings-generation.patch b/leaves-server/minecraft-patches/features/0139-Modify-end-void-rings-generation.patch deleted file mode 100644 index 65da11921..000000000 --- a/leaves-server/minecraft-patches/features/0139-Modify-end-void-rings-generation.patch +++ /dev/null @@ -1,19 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Helvetica Volubi -Date: Tue, 26 Aug 2025 03:14:04 +0800 -Subject: [PATCH] Modify end void rings generation - - -diff --git a/net/minecraft/world/level/levelgen/DensityFunctions.java b/net/minecraft/world/level/levelgen/DensityFunctions.java -index 2dede0dc630097c878f4afc10b10a304eb458a99..b16cb2063e7aa42d0b85b518eba590c0cf3c5b8e 100644 ---- a/net/minecraft/world/level/levelgen/DensityFunctions.java -+++ b/net/minecraft/world/level/levelgen/DensityFunctions.java -@@ -534,7 +534,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 = org.leavesmc.leaves.LeavesConfig.fix.vanillaEndVoidRings ? 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 // Leaves - 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/leaves-server/minecraft-patches/features/0147-Async-keepalive.patch b/leaves-server/minecraft-patches/features/0140-Async-keepalive.patch similarity index 98% rename from leaves-server/minecraft-patches/features/0147-Async-keepalive.patch rename to leaves-server/minecraft-patches/features/0140-Async-keepalive.patch index 05bdad03d..ae45725b2 100644 --- a/leaves-server/minecraft-patches/features/0147-Async-keepalive.patch +++ b/leaves-server/minecraft-patches/features/0140-Async-keepalive.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Async keepalive diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index 20b9dfe68dfbcd5bb999ee4ec0500bdf6bc7fdd5..3e8b7a6ecc79eac256e1a377e46827764a38b14a 100644 +index cb9a4f669ae2ff772206bffde9255d239f47e1ea..8a2a9abf61cf6ae6ea8ecbbc6d9c2155f98b4a5b 100644 --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java @@ -46,6 +46,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack diff --git a/leaves-server/minecraft-patches/features/0141-Do-not-check-NaN-values-in-entities.patch b/leaves-server/minecraft-patches/features/0141-Do-not-check-NaN-values-in-entities.patch deleted file mode 100644 index b1f8c13e2..000000000 --- a/leaves-server/minecraft-patches/features/0141-Do-not-check-NaN-values-in-entities.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Fortern -Date: Mon, 29 Sep 2025 10:24:45 +0800 -Subject: [PATCH] Do not check NaN values in entities - - -diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index d9fe2e6d424231c7acd15cd5bb6a05afa2e263c6..50c143bb15108f02918fbacdff1eebfc14ee8aa6 100644 ---- a/net/minecraft/world/entity/Entity.java -+++ b/net/minecraft/world/entity/Entity.java -@@ -2561,10 +2561,12 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name - } - } // CraftBukkit - -- this.setDeltaMovement(io.papermc.paper.util.MCUtil.sanitizeNanInf(this.deltaMovement, 0D)); // Paper - remove NaN values before usage in saving -+ // Leaves start - Do not check NaN values -+ // this.setDeltaMovement(io.papermc.paper.util.MCUtil.sanitizeNanInf(this.deltaMovement, 0D)); // Paper - remove NaN values before usage in saving // Leaves - Do not check NaN values - output.store("Motion", Vec3.CODEC, this.getDeltaMovement()); - // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero - // TODO: make sure this is the best way to address this. -+ /* - if (Float.isNaN(this.yRot)) { - this.yRot = 0; - } -@@ -2572,7 +2574,9 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name - if (Float.isNaN(this.xRot)) { - this.xRot = 0; - } -+ */ - // CraftBukkit end -+ // Leaves end - Do not check NaN values - output.store("Rotation", Vec2.CODEC, new Vec2(this.getYRot(), this.getXRot())); - output.putDouble("fall_distance", this.fallDistance); - output.putShort("Fire", (short)this.remainingFireTicks); -@@ -2695,7 +2699,7 @@ public abstract class Entity implements SyncedDataHolder, DebugValueSource, Name - public void load(ValueInput input) { - try { - Vec3 vec3 = input.read("Pos", Vec3.CODEC).orElse(Vec3.ZERO); -- Vec3 vec31 = input.read("Motion", Vec3.CODEC).orElse(Vec3.ZERO); vec31 = io.papermc.paper.util.MCUtil.sanitizeNanInf(vec31, 0D); // Paper - avoid setting NaN values -+ Vec3 vec31 = input.read("Motion", Vec3.CODEC).orElse(Vec3.ZERO); // vec31 = io.papermc.paper.util.MCUtil.sanitizeNanInf(vec31, 0D); // Paper - avoid setting NaN values // Leaves - Do not check NaN values - Vec2 vec2 = input.read("Rotation", Vec2.CODEC).orElse(Vec2.ZERO); - this.setDeltaMovement(Math.abs(vec31.x) > 10.0 ? 0.0 : vec31.x, Math.abs(vec31.y) > 10.0 ? 0.0 : vec31.y, Math.abs(vec31.z) > 10.0 ? 0.0 : vec31.z); - this.hasImpulse = true; diff --git a/leaves-server/paper-patches/features/0001-Build-changes.patch b/leaves-server/paper-patches/features/0001-Build-changes.patch index 693904757..de7eff999 100644 --- a/leaves-server/paper-patches/features/0001-Build-changes.patch +++ b/leaves-server/paper-patches/features/0001-Build-changes.patch @@ -126,24 +126,11 @@ index bfacb856623b5cb6af4f1b65ee89200cdfb1ef13..a427a962ea90b089bef1a8177b187f4b private CompletableFuture computedVersion = CompletableFuture.completedFuture(new ComputedVersion(Component.empty(), -1)); // Precompute-- someday move that stuff out of bukkit public static LiteralCommandNode create() { -diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index 5bd6da467a1f536eb56c93ea00f98050cfaa36d0..26b30fac9a12c88b3e8ed114a9225f57603b937e 100644 ---- a/src/main/java/org/bukkit/craftbukkit/Main.java -+++ b/src/main/java/org/bukkit/craftbukkit/Main.java -@@ -231,7 +231,7 @@ public class Main { - if (buildDate.before(deadline.getTime())) { - // Paper start - This is some stupid bullshit - System.err.println("*** Warning, you've not updated in a while! ***"); -- System.err.println("*** Please download a new build from https://papermc.io/downloads/paper ***"); -+ System.err.println("*** Please download a new build from https://leavesmc.org/downloads/leaves ***"); // Leaves - // Paper end - } - } diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -index f83067eaa4eedc8108460c254782ba45a2933372..98baec88662eb1519468eb0095b0a23ae7dfe876 100644 +index 9323383f7d1226d887fc9219354ac9613204cbc2..148e863b513ebfbbcd25b48ce6f3675c383cc367 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java -@@ -481,7 +481,7 @@ public final class CraftMagicNumbers implements UnsafeValues { +@@ -485,7 +485,7 @@ public final class CraftMagicNumbers implements UnsafeValues { @Override public com.destroystokyo.paper.util.VersionFetcher getVersionFetcher() { @@ -152,21 +139,8 @@ index f83067eaa4eedc8108460c254782ba45a2933372..98baec88662eb1519468eb0095b0a23a } @Override -diff --git a/src/main/java/org/bukkit/craftbukkit/util/Versioning.java b/src/main/java/org/bukkit/craftbukkit/util/Versioning.java -index 774556a62eb240da42e84db4502e2ed43495be17..fdef98a7796d84c7b0ee61241859e10cc514534c 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/io.papermc.paper/paper-api/pom.properties"); -+ InputStream stream = Bukkit.class.getClassLoader().getResourceAsStream("META-INF/maven/org.leavesmc.leaves/leaves-api/pom.properties"); // Leaves - Properties properties = new Properties(); - - if (stream != null) { diff --git a/src/main/java/org/spigotmc/WatchdogThread.java b/src/main/java/org/spigotmc/WatchdogThread.java -index e2dc6644ae44ce02821100275ede4b0712cf260d..c7a7870199065aa853b4848f9aea75cc952eb6e6 100644 +index 5c1306ac6eb620a38ed5ef3632b611214e1d5dcd..a69f70c2fae62848db8bed92ede994b8385696fa 100644 --- a/src/main/java/org/spigotmc/WatchdogThread.java +++ b/src/main/java/org/spigotmc/WatchdogThread.java @@ -75,14 +75,14 @@ public class WatchdogThread extends ca.spottedleaf.moonrise.common.util.TickThre diff --git a/leaves-server/paper-patches/features/0003-Leaves-Server-Config.patch b/leaves-server/paper-patches/features/0003-Leaves-Server-Config.patch index 62fe9d520..08249193d 100644 --- a/leaves-server/paper-patches/features/0003-Leaves-Server-Config.patch +++ b/leaves-server/paper-patches/features/0003-Leaves-Server-Config.patch @@ -18,7 +18,7 @@ index 62e2d5704c348955bc8284dc2d54c933b7bcdd06..7ef20f0138fad39a1d23edd7b26ddc88 public void executeAsync(final Runnable runnable) { MCUtil.scheduleAsyncTask(this.catching(runnable, "asynchronous")); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 34d74014fd042f6eeafafadb6237a838b1ddd47c..01672aff7c4028da9714448bb3386b7d8369db59 100644 +index da49c8005592a154946750591ce082796f24dd3b..1562a3d0b97a5ca2680ebc30bf8c71de443cad1c 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -1020,6 +1020,7 @@ public final class CraftServer implements Server { @@ -30,10 +30,10 @@ index 34d74014fd042f6eeafafadb6237a838b1ddd47c..01672aff7c4028da9714448bb3386b7d org.spigotmc.SpigotConfig.registerCommands(); // Spigot io.papermc.paper.command.PaperCommands.registerCommands(this.console); // Paper diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java -index 26b30fac9a12c88b3e8ed114a9225f57603b937e..0aa959d64b34446d29961684eb050db336c79dfe 100644 +index 8ce8de8eedfe8557848b0508857744a5b9641239..ec8b215ce307725e465d5f5d75eeeca33090b16c 100644 --- a/src/main/java/org/bukkit/craftbukkit/Main.java +++ b/src/main/java/org/bukkit/craftbukkit/Main.java -@@ -169,6 +169,14 @@ public class Main { +@@ -144,6 +144,14 @@ public class Main { .ofType(String.class) .defaultsTo("Unknown Server") .describedAs("Name"); diff --git a/leaves-server/paper-patches/features/0004-Leaves-Protocol-Core.patch b/leaves-server/paper-patches/features/0004-Leaves-Protocol-Core.patch index b5201933d..ee4d3208b 100644 --- a/leaves-server/paper-patches/features/0004-Leaves-Protocol-Core.patch +++ b/leaves-server/paper-patches/features/0004-Leaves-Protocol-Core.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Leaves Protocol Core diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 01672aff7c4028da9714448bb3386b7d8369db59..3a81b4c659d35fd273542a8bb343c256c29dfccc 100644 +index a04458eb300e003fe3f37398077371b1a75d4a89..7aa66d5285b5b793c66c88df376f7668aab55f47 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -485,6 +485,7 @@ public final class CraftServer implements Server { diff --git a/leaves-server/paper-patches/features/0005-Leaves-Fakeplayer.patch b/leaves-server/paper-patches/features/0005-Leaves-Fakeplayer.patch index 305e9b1b4..9c99d9d75 100644 --- a/leaves-server/paper-patches/features/0005-Leaves-Fakeplayer.patch +++ b/leaves-server/paper-patches/features/0005-Leaves-Fakeplayer.patch @@ -32,10 +32,10 @@ index a589689e3a9de1fffef62e0e3dcd79bb2e848c5b..c0910f908ffad3bb94563836c032bb1d RegisteredListener[] listeners = handlers.getRegisteredListeners(); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java -index 119f4c23e351eab0a503f78b48136dc6ae55bf60..7d99e7f29156723a3f20f1daba21aed2bc6649c6 100644 +index 21d594a39d09b2d17f05c40ce5323d57949d0b0b..46859fc70795097366f02dba48fdaab8b9c85013 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftRegionAccessor.java -@@ -373,6 +373,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"); @@ -44,7 +44,7 @@ index 119f4c23e351eab0a503f78b48136dc6ae55bf60..7d99e7f29156723a3f20f1daba21aed2 if (nmsEntity.level() != this.getHandle().getLevel()) { 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 3a81b4c659d35fd273542a8bb343c256c29dfccc..dd132b146a694ac60348b0a3173d12fdd064f29e 100644 +index 7aa66d5285b5b793c66c88df376f7668aab55f47..99d2dee2fabda85df357de7efe18f8bdfde394fe 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -305,6 +305,7 @@ public final class CraftServer implements Server { @@ -72,7 +72,7 @@ index 3a81b4c659d35fd273542a8bb343c256c29dfccc..dd132b146a694ac60348b0a3173d12fd return false; } -@@ -2965,4 +2967,11 @@ public final class CraftServer implements Server { +@@ -2967,4 +2969,11 @@ public final class CraftServer implements Server { public void allowPausing(final Plugin plugin, final boolean value) { this.console.addPluginAllowingSleep(plugin.getName(), value); } @@ -85,10 +85,10 @@ index 3a81b4c659d35fd273542a8bb343c256c29dfccc..dd132b146a694ac60348b0a3173d12fd + // Leaves end - Bot API } diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index e92827b83d2cd7f18ed214ce389ac423b6d2d922..7fca335bb7db5b85ee5fc155cc4341b808db9a07 100644 +index ebc65e3338c646815416a47bf9af96fe45978caf..815825d8dfb2e4f0bbe59a815bc7045d4b508f21 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -@@ -251,7 +251,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -247,7 +247,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public int getPlayerCount() { @@ -97,7 +97,7 @@ index e92827b83d2cd7f18ed214ce389ac423b6d2d922..7fca335bb7db5b85ee5fc155cc4341b8 } @Override -@@ -1111,9 +1111,9 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1108,9 +1108,9 @@ public class CraftWorld extends CraftRegionAccessor implements World { @Override public List getPlayers() { @@ -109,7 +109,7 @@ index e92827b83d2cd7f18ed214ce389ac423b6d2d922..7fca335bb7db5b85ee5fc155cc4341b8 HumanEntity bukkitEntity = human.getBukkitEntity(); if ((bukkitEntity != null) && (bukkitEntity instanceof Player)) { -@@ -1600,7 +1600,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1597,7 +1597,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); @@ -118,7 +118,7 @@ index e92827b83d2cd7f18ed214ce389ac423b6d2d922..7fca335bb7db5b85ee5fc155cc4341b8 player.connection.send(io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, player.getX(), player.getY(), player.getZ(), seed, null)); } } -@@ -1628,7 +1628,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1625,7 +1625,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()) { @@ -127,7 +127,7 @@ index e92827b83d2cd7f18ed214ce389ac423b6d2d922..7fca335bb7db5b85ee5fc155cc4341b8 player.connection.send(io.papermc.paper.adventure.PaperAdventure.asSoundPacket(sound, player, seed, null)); } } else if (emitter instanceof CraftEntity craftEntity) { -@@ -1792,7 +1792,7 @@ public class CraftWorld extends CraftRegionAccessor implements World { +@@ -1764,7 +1764,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( @@ -137,10 +137,10 @@ index e92827b83d2cd7f18ed214ce389ac423b6d2d922..7fca335bb7db5b85ee5fc155cc4341b8 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 b177e23db960323b901909a3f845a9ae0426d0df..b28129242d13afc72ea863aaf405063c38663e0e 100644 +index 2a572ef0ba7405ecafaf6def2a2134bd71b60453..a509ced2a78fe67b57ddd37ec0521d6c74a1eb41 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java -@@ -121,6 +121,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { +@@ -122,6 +122,8 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return new CraftHumanEntity(server, (net.minecraft.world.entity.player.Player) entity); } @@ -150,10 +150,10 @@ index b177e23db960323b901909a3f845a9ae0426d0df..b28129242d13afc72ea863aaf405063c 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 d5496e5fbb5fcd65df2933ebc7cb39df7d832923..250a7d5427fc59478d8a540cfb2319939a489e65 100644 +index cd83ca2ace1dab6c1f10e2306a0ca0bb8ae083cc..d8a8679a6e768f8a02aa58695beb0ed1c792bda7 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -882,7 +882,11 @@ public class CraftEventFactory { +@@ -1013,7 +1013,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/leaves-server/paper-patches/features/0006-No-chat-sign.patch b/leaves-server/paper-patches/features/0006-No-chat-sign.patch index 7efef224c..b766a5d79 100644 --- a/leaves-server/paper-patches/features/0006-No-chat-sign.patch +++ b/leaves-server/paper-patches/features/0006-No-chat-sign.patch @@ -5,7 +5,7 @@ Subject: [PATCH] No chat sign diff --git a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java -index f6266b3ca9c031ef9e96df23e0413c7db5211bd8..7516581e3ce033d676330390a37e0f9c08409a82 100644 +index 965ddeb8f57565d68415fb6f549e6d00feed3c33..84ae6df6932d50a41147da2570cce3bef90d10a4 100644 --- a/src/main/java/io/papermc/paper/adventure/ChatProcessor.java +++ b/src/main/java/io/papermc/paper/adventure/ChatProcessor.java @@ -317,7 +317,7 @@ public final class ChatProcessor { diff --git a/leaves-server/paper-patches/features/0007-MC-Technical-Survival-Mode.patch b/leaves-server/paper-patches/features/0007-MC-Technical-Survival-Mode.patch index aef60ca3e..524b18057 100644 --- a/leaves-server/paper-patches/features/0007-MC-Technical-Survival-Mode.patch +++ b/leaves-server/paper-patches/features/0007-MC-Technical-Survival-Mode.patch @@ -6,10 +6,23 @@ Subject: [PATCH] MC Technical Survival Mode Will automatically overwrite some configuration after startup diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -index 940f60cd846107a82c1c523d73f9028b50a929d9..19a82b1e3b30b0e0877c726c166d8ab5b0c27c45 100644 +index e0491ef5cfc06b5c23d448b8c9679a17e58bca26..004997d8dd40f45112a563edfe166cba3a49e2ee 100644 --- a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java +++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java -@@ -335,6 +335,7 @@ public class PaperConfigurations extends Configurations files = ((java.util.List) optionSet.valuesOf("add-plugin")).stream().map(File::toPath).toList(); - io.papermc.paper.plugin.util.EntrypointUtil.registerProvidersFromSource(io.papermc.paper.plugin.provider.source.PluginFlagProviderSource.INSTANCE, files); +@@ -121,19 +121,30 @@ public class PluginInitializerManager { + java.util.List dirs = ((java.util.List) optionSet.valuesOf("add-plugin-dir")).stream().map(File::toPath).toList(); + dirs.forEach(pluginDir -> io.papermc.paper.plugin.util.EntrypointUtil.registerProvidersFromSource(io.papermc.paper.plugin.provider.source.DirectoryProviderSource.INSTANCE_NO_CREATE, pluginDir)); + // Leaves start - leaves plugin + final Set leavesPluginNames = new TreeSet<>(); @@ -261,10 +261,10 @@ index fbad4a2242aa1ab910b2e2ae4cce973ff63fda84..89d4fa952d072dd6e071dc9eef51f405 } catch (final IOException ex) { return CompletableFuture.failedFuture(new RuntimeException("Failed to open plugin jar " + inputFile, ex)); diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 6167dfe78793bd23748fcbd86a37618b8a4f76ea..8481618e09ed02afa04393a36c384237d0cca59d 100644 +index 7d74bedf91d6448dc2bf2920a84d8e93edf2a279..b22f9cf5da95435527aaae99e23f6f834727072f 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -2970,6 +2970,13 @@ public final class CraftServer implements Server { +@@ -2973,6 +2973,13 @@ public final class CraftServer implements Server { this.console.addPluginAllowingSleep(plugin.getName(), value); } diff --git a/leaves-server/paper-patches/features/0014-Fix-SculkCatalyst-exp-skip.patch b/leaves-server/paper-patches/features/0014-Fix-SculkCatalyst-exp-skip.patch index 5fecf9d98..769f0cbcb 100644 --- a/leaves-server/paper-patches/features/0014-Fix-SculkCatalyst-exp-skip.patch +++ b/leaves-server/paper-patches/features/0014-Fix-SculkCatalyst-exp-skip.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Fix SculkCatalyst exp skip diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -index 250a7d5427fc59478d8a540cfb2319939a489e65..3697a98306601030a0c717fb46823aa976d411c0 100644 +index d8a8679a6e768f8a02aa58695beb0ed1c792bda7..4c5443f3669c09e291721be910aab0e7eaa222fd 100644 --- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java +++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java -@@ -848,7 +848,7 @@ public class CraftEventFactory { +@@ -980,7 +980,7 @@ public class CraftEventFactory { CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity(); CraftDamageSource bukkitDamageSource = new CraftDamageSource(damageSource); CraftWorld world = (CraftWorld) entity.getWorld(); @@ -17,7 +17,7 @@ index 250a7d5427fc59478d8a540cfb2319939a489e65..3697a98306601030a0c717fb46823aa9 populateFields(victim, event); // Paper - make cancellable Bukkit.getServer().getPluginManager().callEvent(event); -@@ -859,6 +859,7 @@ public class CraftEventFactory { +@@ -991,6 +991,7 @@ public class CraftEventFactory { playDeathSound(victim, event, damageSource); // Paper end victim.expToDrop = event.getDroppedExp(); @@ -25,7 +25,7 @@ index 250a7d5427fc59478d8a540cfb2319939a489e65..3697a98306601030a0c717fb46823aa9 lootCheck.run(); // Paper - advancement triggers before destroying items // Paper start - Restore vanilla drops behavior -@@ -898,6 +899,7 @@ public class CraftEventFactory { +@@ -1029,6 +1030,7 @@ public class CraftEventFactory { victim.newLevel = event.getNewLevel(); victim.newTotalExp = event.getNewTotalExp(); victim.expToDrop = event.getDroppedExp(); diff --git a/leaves-server/paper-patches/features/0015-Leaves-Config-API.patch b/leaves-server/paper-patches/features/0015-Leaves-Config-API.patch index e6c2af562..ca0e213f3 100644 --- a/leaves-server/paper-patches/features/0015-Leaves-Config-API.patch +++ b/leaves-server/paper-patches/features/0015-Leaves-Config-API.patch @@ -5,11 +5,11 @@ Subject: [PATCH] Leaves Config API diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 8481618e09ed02afa04393a36c384237d0cca59d..9504f84d4a75419bc5551534ce7914f9a33c09f9 100644 +index b22f9cf5da95435527aaae99e23f6f834727072f..f53005ca607d004d8d043a8dc9143ab5f6e6b221 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -3001,4 +3001,11 @@ public final class CraftServer implements Server { - return internalBytebufHandler; +@@ -3000,4 +3000,11 @@ public final class CraftServer implements Server { + return org.leavesmc.leaves.bytebuf.internal.InternalBytebufHandler.allocator(); } // Leaves end - Bytebuf API + diff --git a/leaves-server/paper-patches/features/0016-Old-ender-dragon-part-can-use-end-portal.patch b/leaves-server/paper-patches/features/0016-Old-ender-dragon-part-can-use-end-portal.patch index 73c57d935..1df2250cc 100644 --- a/leaves-server/paper-patches/features/0016-Old-ender-dragon-part-can-use-end-portal.patch +++ b/leaves-server/paper-patches/features/0016-Old-ender-dragon-part-can-use-end-portal.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Old ender dragon part can use end portal diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java -index 178cadf023bf516b93625c124fbf1a06b0131c58..8151542d59ceb5e135571928d2e203170f3a9ea6 100644 +index e6d884596d20f3e970cc6f089f178e642773290d..efd18ffd9014692b3d481a12c4062d04e004a609 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftComplexPart.java @@ -12,14 +12,19 @@ public class CraftComplexPart extends CraftEntity implements ComplexEntityPart { diff --git a/leaves-server/paper-patches/files/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java.patch b/leaves-server/paper-patches/files/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java.patch index 0fe034119..d8978a635 100644 --- a/leaves-server/paper-patches/files/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java.patch +++ b/leaves-server/paper-patches/files/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java.patch @@ -1,15 +1,25 @@ --- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java +++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java -@@ -107,7 +_,7 @@ +@@ -217,10 +_,16 @@ + } } - // Contributed by Techcable in GH-65 -- private static int fetchDistanceFromGitHub(final String repo, final String branch, final String hash) { -+ protected static int fetchDistanceFromGitHub(final String repo, final String branch, final String hash) { // Leaves - private -> protected +- // Contributed by Techcable in GH-65 + private static int fetchDistanceFromGitHub(final String branch, final String hash) { ++ // Leaves start - build changes ++ return fetchDistanceFromGitHub(PaperVersionFetcher.REPOSITORY, branch, hash); ++ } ++ ++ // Contributed by Techcable in GH-65 ++ protected static int fetchDistanceFromGitHub(final String repo, final String branch, final String hash) { try { - final HttpURLConnection connection = (HttpURLConnection) URI.create("https://api.github.com/repos/%s/compare/%s...%s".formatted(repo, branch, hash)).toURL().openConnection(); - connection.connect(); -@@ -130,7 +_,7 @@ +- final HttpURLConnection connection = (HttpURLConnection) URI.create("https://api.github.com/repos/%s/compare/%s...%s".formatted(PaperVersionFetcher.REPOSITORY, branch, hash)).toURL().openConnection(); ++ final HttpURLConnection connection = (HttpURLConnection) URI.create("https://api.github.com/repos/%s/compare/%s...%s".formatted(repo, branch, hash)).toURL().openConnection(); ++ // Leaves end - build changes + connection.setConnectTimeout(5000); + connection.setReadTimeout(5000); + connection.setRequestProperty("User-Agent", PaperVersionFetcher.USER_AGENT); +@@ -244,7 +_,7 @@ } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java b/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java index 350ed88c8..f8cdb7c09 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/LeavesConfig.java @@ -337,9 +337,6 @@ public void verify(Boolean old, Boolean value) throws IllegalArgumentException { } } - @GlobalConfig("allow-grindstone-overstacking") - public boolean allowGrindstoneOverstacking = false; - @GlobalConfig("allow-entity-portal-with-passenger") public boolean allowEntityPortalWithPassenger = true; @@ -426,6 +423,9 @@ public void verify(Boolean old, Boolean value) throws IllegalArgumentException { @GlobalConfig("old-minecart-motion-behavior") public boolean oldMinecartMotionBehavior = false; + + @GlobalConfig("allow-inf-nan-motion-values") + public boolean allowInfNanMotionValues = true; } public ElytraAeronauticsConfig elytraAeronautics = new ElytraAeronauticsConfig(); @@ -510,35 +510,21 @@ private static class StackableShulkerValidator implements ConfigValidator { - if (stringValue.equals("true")) { - return 2; - } else if (!MathUtils.isNumeric(stringValue)) { - return 1; - } else { - return Integer.parseInt(stringValue); - } - } - case Integer integerValue -> { - return integerValue; - } - case Boolean boolValue -> { - return boolValue ? 2 : 1; - } + return switch (value) { + case String stringValue -> stringValue.equals("true") ? 2 + : !MathUtils.isNumeric(stringValue) ? 1 + : Integer.parseInt(stringValue); + case Integer integerValue -> integerValue; + case Boolean boolValue -> boolValue ? 2 : 1; case null, default -> throw new IllegalArgumentException("stackable-shulker-boxes need string or integer or boolean"); - } + }; } @Override public Object saveConvert(Integer value) { - if (value == 1) { - return false; - } else if (value == 2) { - return true; - } else { - return value; - } + return value == 1 ? false + : value == 2 ? true + : value; } @Override @@ -548,8 +534,8 @@ public Integer stringConvert(String value) throws IllegalArgumentException { @Override public void verify(Integer old, Integer value) throws IllegalArgumentException { - if (value < 1 || value > 64) { - throw new IllegalArgumentException("stackable-shulker-boxes need >= 1 and <= 64"); + if (value < 1 || value > 99) { + throw new IllegalArgumentException("stackable-shulker-boxes need >= 1 and <= 99"); } } @@ -817,9 +803,6 @@ public static class PerformanceRemoveConfig { @GlobalConfig("enable-suffocation-optimization") public boolean enableSuffocationOptimization = true; - @GlobalConfig("check-spooky-season-once-an-hour") - public boolean checkSpookySeasonOnceAnHour = true; - @GlobalConfig("inactive-goal-selector-disable") public boolean throttleInactiveGoalSelectorTick = false; @@ -1228,9 +1211,6 @@ public List valueSuggest() { @GlobalConfig("leaves-packet-event") public boolean leavesPacketEvent = false; - - @GlobalConfig("chat-command-max-length") - public int chatCommandMaxLength = 32767; } public static RegionConfig region = new RegionConfig(); @@ -1321,18 +1301,23 @@ public void verify(Boolean old, Boolean value) throws IllegalArgumentException { @GlobalConfig("vanilla-portal-handle") public boolean vanillaPortalHandle = true; - @GlobalConfig("vanilla-fluid-pushing") - public boolean vanillaFluidPushing = true; - - @GlobalConfig(value = "collision-behavior") - public CollisionBehavior collisionBehavior = CollisionBehavior.BLOCK_SHAPE_VANILLA; + @GlobalConfig(value = "collision-behavior", validator = CollisionBehaviorValidator.class) + public CollisionBehavior collisionBehavior = CollisionBehavior.PAPER; public enum CollisionBehavior { - VANILLA, BLOCK_SHAPE_VANILLA, PAPER + VANILLA, PAPER } - @GlobalConfig("vanilla-end-void-rings") - public boolean vanillaEndVoidRings = false; + private static class CollisionBehaviorValidator extends EnumConfigValidator { + @Override + public CollisionBehavior stringConvert(@NotNull String value) throws IllegalArgumentException { + if (value.equalsIgnoreCase("BLOCK_SHAPE_VANILLA")) { + LeavesLogger.LOGGER.warning("Paper has updated the collision behavior to BLOCK_SHAPE_VANILLA mode, converting this to PAPER..."); + value = "PAPER"; + } + return super.stringConvert(value); + } + } @GlobalConfig("stacked-container-destroyed-drop") public boolean stackedContainerDestroyedDrop = true; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotDataStorage.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotDataStorage.java index 7cde71391..221bab1e9 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotDataStorage.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotDataStorage.java @@ -5,6 +5,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtAccounter; import net.minecraft.nbt.NbtIo; +import net.minecraft.nbt.Tag; import net.minecraft.util.ProblemReporter; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.storage.LevelResource; @@ -17,7 +18,10 @@ import java.io.File; import java.io.IOException; +import java.util.Locale; +import java.util.Map; import java.util.Optional; +import java.util.UUID; public class BotDataStorage { @@ -35,7 +39,11 @@ public BotDataStorage(LevelStorageSource.@NotNull LevelStorageAccess session, St this.savedBotList = new CompoundTag(); if (this.botListFile.exists() && this.botListFile.isFile()) { try { - Optional.of(NbtIo.readCompressed(this.botListFile.toPath(), NbtAccounter.unlimitedHeap())).ifPresent(tag -> this.savedBotList = tag); + Optional.of(NbtIo.readCompressed(this.botListFile.toPath(), NbtAccounter.unlimitedHeap())).ifPresent(tag -> { + for (Map.Entry entry : tag.entrySet()) { + savedBotList.put(entry.getKey().toLowerCase(Locale.ROOT), entry.getValue()); + } + }); } catch (Exception exception) { BotDataStorage.LOGGER.warn("Failed to load player data list"); } @@ -43,7 +51,6 @@ public BotDataStorage(LevelStorageSource.@NotNull LevelStorageAccess session, St } public void save(Player player) { - boolean flag = true; try { CompoundTag nbt = TagUtil.saveEntityWithoutId(player); File file = new File(this.botDir, player.getStringUUID() + ".dat"); @@ -59,20 +66,19 @@ public void save(Player player) { NbtIo.writeCompressed(nbt, file.toPath()); } catch (Exception exception) { BotDataStorage.LOGGER.warn("Failed to save fakeplayer data for {}", player.getScoreboardName(), exception); - flag = false; + return; } - if (flag && player instanceof ServerBot bot) { + if (player instanceof ServerBot bot) { CompoundTag nbt = new CompoundTag(); nbt.putString("name", bot.createState.fullName()); nbt.store("uuid", UUIDUtil.CODEC, bot.getUUID()); nbt.putBoolean("resume", bot.resume); - this.savedBotList.put(bot.createState.fullName(), nbt); + this.savedBotList.put(bot.createState.fullName().toLowerCase(Locale.ROOT), nbt); this.saveBotList(); } } - public Optional load(@NotNull ServerBot bot, ProblemReporter reporter) { return this.load(bot.nameAndId().name(), bot.nameAndId().id().toString()).map(nbt -> { ValueInput valueInput = TagValueInput.create(reporter, bot.registryAccess(), nbt); @@ -81,27 +87,27 @@ public Optional load(@NotNull ServerBot bot, ProblemReporter reporte }); } - public void removeSavedData(@NotNull ServerBot bot) { - this.load(bot.nameAndId().name(), bot.nameAndId().id().toString()); + public void removeSavedData(String name) { + this.savedBotList.remove(name.toLowerCase(Locale.ROOT)); + this.saveBotList(); } private Optional load(String name, String uuid) { File file = new File(this.botDir, uuid + ".dat"); - - if (file.exists() && file.isFile()) { - try { - Optional optional = Optional.of(NbtIo.readCompressed(file.toPath(), NbtAccounter.unlimitedHeap())); - if (!file.delete()) { - throw new IOException("Failed to delete fakeplayer data"); - } - this.savedBotList.remove(name); - this.saveBotList(); - return optional; - } catch (Exception exception) { - BotDataStorage.LOGGER.warn("Failed to load fakeplayer data for {}", name); + if (!file.exists() || !file.isFile()) { + LOGGER.warn("Failed to load bot {}, the file {} DOES NOT EXIST!", name, file); + return Optional.empty(); + } + try { + Optional optional = Optional.of(NbtIo.readCompressed(file.toPath(), NbtAccounter.unlimitedHeap())); + if (!file.delete()) { + throw new IOException("Failed to delete fakeplayer data"); } + this.removeSavedData(name); + return optional; + } catch (Exception exception) { + BotDataStorage.LOGGER.warn("Failed to load fakeplayer data for {}", name); } - return Optional.empty(); } @@ -136,4 +142,12 @@ private void saveBotList() { public CompoundTag getSavedBotList() { return savedBotList; } + + public UUID getUUIDFromLower(String lowerName) { + return savedBotList.getCompoundOrEmpty(lowerName).read("uuid", UUIDUtil.CODEC).orElseThrow(); + } + + public String getNameFromLower(String lowerName) { + return savedBotList.getCompoundOrEmpty(lowerName).getString("name").orElseThrow(); + } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotList.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotList.java index ac6660316..e341f54ba 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotList.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotList.java @@ -10,6 +10,7 @@ import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.Style; import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundRemoveEntitiesPacket; import net.minecraft.resources.ResourceKey; @@ -18,9 +19,9 @@ 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; @@ -61,7 +62,7 @@ public class BotList { private final BotDataStorage resumeDataStorage; private final Map botsByUUID = Maps.newHashMap(); - private final Map botsByName = Maps.newHashMap(); + private final Map botsByLowerName = Maps.newHashMap(); private final Map> botsNameByWorldUuid = Maps.newHashMap(); private final Map> legacyBotsNameByWorldUuid = Maps.newHashMap(); @@ -124,20 +125,24 @@ public ServerBot loadNewResumeBot(String fullName) { return this.loadNewBot(fullName, this.resumeDataStorage); } - public ServerBot loadNewBot(String fullName, BotDataStorage storage) { - if (botsByName.containsKey(fullName)) { + public ServerBot loadNewBot(String inputName, BotDataStorage storage) { + String lowerName = inputName.toLowerCase(Locale.ROOT); + if (botsByLowerName.containsKey(lowerName)) { return null; } try { - UUID uuid = BotUtil.getBotUUID(fullName); - - BotLoadEvent event = new BotLoadEvent(fullName, uuid); + if (!storage.getSavedBotList().contains(lowerName)) { + return null; + } + String name = storage.getNameFromLower(lowerName); + UUID uuid = storage.getUUIDFromLower(lowerName); + BotLoadEvent event = new BotLoadEvent(name, uuid); this.server.server.getPluginManager().callEvent(event); if (event.isCancelled()) { return null; } - ServerBot bot = new ServerBot(this.server, this.server.getLevel(Level.OVERWORLD), new GameProfile(uuid, fullName)); + ServerBot bot = new ServerBot(this.server, this.server.getLevel(Level.OVERWORLD), new GameProfile(uuid, name)); bot.connection = new ServerBotPacketListenerImpl(this.server, bot); Optional optional; try (ProblemReporter.ScopedCollector scopedCollector = new ProblemReporter.ScopedCollector(bot.problemPath(), LOGGER)) { @@ -165,7 +170,7 @@ public ServerBot loadNewBot(String fullName, BotDataStorage storage) { ServerLevel world = this.server.getLevel(resourcekey); return this.placeNewBot(bot, world, bot.getLocation(), nbt); } catch (Exception e) { - LOGGER.error("Failed to load bot {}", fullName, e); + LOGGER.error("Failed to load bot {}", inputName, e); return null; } } @@ -191,7 +196,7 @@ public ServerBot placeNewBot(@NotNull ServerBot bot, ServerLevel world, Location bot.connection.teleport(bot.getX(), bot.getY(), bot.getZ(), bot.getYRot(), bot.getXRot()); this.bots.add(bot); - this.botsByName.put(bot.getScoreboardName().toLowerCase(Locale.ROOT), bot); + this.botsByLowerName.put(bot.getScoreboardName().toLowerCase(Locale.ROOT), bot); this.botsByUUID.put(bot.getUUID(), bot); bot.suppressTrackerForLogin = true; @@ -237,7 +242,7 @@ public boolean removeBot(@NotNull ServerBot bot, @NotNull BotRemoveEvent.RemoveR bot.disconnect(); - this.resumeDataStorage.removeSavedData(bot); + this.resumeDataStorage.removeSavedData(bot.nameAndId().name()); if (event.shouldSave()) { if (resume) { this.resumeDataStorage.save(bot); @@ -277,7 +282,7 @@ public boolean removeBot(@NotNull ServerBot bot, @NotNull BotRemoveEvent.RemoveR bot.level().removePlayerImmediately(bot, Entity.RemovalReason.UNLOADED_WITH_PLAYER); this.bots.remove(bot); - this.botsByName.remove(bot.getScoreboardName().toLowerCase(Locale.ROOT)); + this.botsByLowerName.remove(bot.getScoreboardName().toLowerCase(Locale.ROOT)); UUID uuid = bot.getUUID(); ServerBot bot1 = this.botsByUUID.get(uuid); @@ -321,7 +326,9 @@ public void loadResumeBotInfo() { return; } CompoundTag savedBotList = this.getResumeBotList().copy(); - for (String fullName : savedBotList.keySet()) { + for (Map.Entry entry : savedBotList.entrySet()) { + String lowerName = entry.getKey(); + String fullName = ((CompoundTag) entry.getValue()).getStringOr("name", lowerName); UUID levelUuid = BotUtil.getBotLevel(fullName, this.resumeDataStorage); if (levelUuid == null) { LOGGER.warn("Bot {} has no world UUID, skipping loading.", fullName); @@ -337,6 +344,7 @@ public void loadResumeBotInfo() { private void loadLegacyResumeBotInfo() { CompoundTag savedBotList = this.getManualSavedBotList().copy(); for (String fullName : savedBotList.keySet()) { + // Legacy format saved fullName as the key CompoundTag nbt = savedBotList.getCompound(fullName).orElseThrow(); if (!nbt.getBoolean("resume").orElse(false)) { continue; @@ -382,7 +390,7 @@ public ServerBot getBot(@NotNull UUID uuid) { @Nullable public ServerBot getBotByName(@NotNull String name) { - return this.botsByName.get(name.toLowerCase(Locale.ROOT)); + return this.botsByLowerName.get(name.toLowerCase(Locale.ROOT)); } public CompoundTag getManualSavedBotList() { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java index 10494446f..411d3a7aa 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java @@ -1,5 +1,6 @@ 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; @@ -14,7 +15,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 @@ -26,7 +27,7 @@ public void setValue(@NotNull Player player, @NotNull Stat stat, int value) { } @Override - public void parseLocal(@NotNull DataFixer dataFixer, @NotNull String json) { + public void parse(DataFixer fixerUpper, JsonElement json) { } @Override diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java index d3faccf5d..777f57f17 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java @@ -36,13 +36,13 @@ 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.Level; 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; @@ -75,6 +75,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.EnumSet; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Objects; @@ -86,7 +87,7 @@ public class ServerBot extends ServerPlayer { private final List> actions; - private final Map> configs; + private final Map> configs; public boolean resume = false; public BotCreateState createState; @@ -108,9 +109,10 @@ public ServerBot(MinecraftServer server, ServerLevel world, GameProfile profile) this.gameMode = new ServerBotGameMode(this); this.actions = new ArrayList<>(); - ImmutableMap.Builder> configBuilder = ImmutableMap.builder(); - for (AbstractBotConfig config : Configs.getConfigs()) { - configBuilder.put(config.getName(), config.create().setBot(this)); + + ImmutableMap.Builder> configBuilder = ImmutableMap.builder(); + for (Configs config : Configs.getConfigs()) { + configBuilder.put(config.getName(), config.create(this)); } this.configs = configBuilder.build(); @@ -122,7 +124,6 @@ public ServerBot(MinecraftServer server, ServerLevel world, GameProfile profile) this.notSleepTicks = 0; this.fauxSleeping = LeavesConfig.modify.fakeplayer.inGame.canSkipSleep; this.getBukkitEntity().setSimulationDistance(LeavesConfig.modify.fakeplayer.inGame.getSimulationDistance(this)); - this.setClientLoaded(true); } @Override @@ -397,7 +398,7 @@ public void addAdditionalSaveData(@NotNull ValueOutput nbt) { if (!this.configs.isEmpty()) { ValueOutput.TypedOutputList configNbt = nbt.list("configs", CompoundTag.CODEC); - for (AbstractBotConfig config : this.configs.values()) { + for (AbstractBotConfig config : this.configs.values()) { configNbt.add(config.save(new CompoundTag())); } } @@ -434,11 +435,11 @@ public void readAdditionalSaveData(@NotNull ValueInput nbt) { if (nbt.list("actions", CompoundTag.CODEC).isPresent()) { ValueInput.TypedInputList actionNbt = nbt.list("actions", CompoundTag.CODEC).orElseThrow(); actionNbt.forEach(actionTag -> { - AbstractBotAction type = Actions.getForName(actionTag.getString("actionName").orElseThrow()); - if (type != null) { - AbstractBotAction action = type.create(); - action.load(actionTag); - this.actions.add(action); + Actions holder = Actions.getByName(actionTag.getString("actionName").orElseThrow()); + if (holder != null) { + AbstractBotAction newAction = holder.create(); + newAction.load(actionTag); + this.actions.add(newAction); } }); } @@ -446,10 +447,12 @@ public void readAdditionalSaveData(@NotNull ValueInput nbt) { if (nbt.list("configs", CompoundTag.CODEC).isPresent()) { ValueInput.TypedInputList configNbt = nbt.list("configs", CompoundTag.CODEC).orElseThrow(); for (CompoundTag configTag : configNbt) { - AbstractBotConfig config = Configs.getConfig(configTag.getString("configName").orElseThrow()); - if (config != null) { - this.configs.get(config.getName()).load(configTag); + String key = configTag.getString("configName").orElseThrow(); + if (!this.configs.containsKey(key)) { + LeavesLogger.LOGGER.warning("Trying to load a unknown config \"" + key + "\", discard."); + continue; } + this.configs.get(key).load(configTag); } } } @@ -500,7 +503,7 @@ private void sendPacket(Packet 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); @@ -522,7 +525,7 @@ public void die(@NotNull DamageSource damageSource) { // TODO: separate die and remove logic, call super.die here this.removeEntitiesOnShoulder(); - if (this.level().getGameRules().getBoolean(GameRules.RULE_FORGIVE_DEAD_PLAYERS)) { + if (this.level().getGameRules().get(GameRules.FORGIVE_DEAD_PLAYERS)) { this.tellNeutralMobsThatIDied(); } getServer().getBotList().removeBot(this, BotRemoveEvent.RemoveReason.DEATH, null, false, false); @@ -699,15 +702,15 @@ public ServerStatsCounter getStats() { } @SuppressWarnings("unchecked") - public > AbstractBotConfig getConfig(@NotNull AbstractBotConfig config) { - return (AbstractBotConfig) Objects.requireNonNull(this.configs.get(config.getName())); + public AbstractBotConfig getConfig(@NotNull Configs> config) { + return (AbstractBotConfig) Objects.requireNonNull(this.configs.get(config.getName())); } - public Collection> getAllConfigs() { + public Collection> getAllConfigs() { return configs.values(); } - public > T getConfigValue(@NotNull AbstractBotConfig config) { + public T getConfigValue(@NotNull Configs> config) { return this.getConfig(config).getValue(); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBotPacketListenerImpl.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBotPacketListenerImpl.java index 35fb17fff..8929c33f6 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBotPacketListenerImpl.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBotPacketListenerImpl.java @@ -34,6 +34,11 @@ public boolean isAcceptingMessages() { public void tick() { } + @Override + public boolean hasClientLoaded() { + return true; // Don't kick me out! + } + public static class BotConnection extends Connection { private static final BotConnection INSTANCE = new BotConnection(); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/Actions.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/Actions.java index 214165eb4..73ce576f2 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/Actions.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/Actions.java @@ -1,58 +1,87 @@ package org.leavesmc.leaves.bot.agent; +import com.mojang.brigadier.exceptions.CommandSyntaxException; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.bot.agent.actions.*; +import org.leavesmc.leaves.command.CommandContext; import org.leavesmc.leaves.entity.bot.action.*; import java.util.Collection; import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.function.Supplier; -public class Actions { +public class Actions> { - private static final Map> actionsByName = new HashMap<>(); - private static final Map, AbstractBotAction> actionsByClass = new HashMap<>(); + private static final Map>> actionsByName = new HashMap<>(); + private static final Map>, Actions>> actionsByClass = new HashMap<>(); static { - register(new ServerAttackAction(), AttackAction.class); - register(new ServerBreakBlockAction(), BreakBlockAction.class); - register(new ServerDropAction(), DropAction.class); - register(new ServerJumpAction(), JumpAction.class); - register(new ServerSneakAction(), SneakAction.class); - register(new ServerUseItemAutoAction(), UseItemAutoAction.class); - register(new ServerUseItemAction(), UseItemAction.class); - register(new ServerUseItemOnAction(), UseItemOnAction.class); - register(new ServerUseItemToAction(), UseItemToAction.class); - register(new ServerUseItemOffhandAction(), UseItemOffhandAction.class); - register(new ServerUseItemOnOffhandAction(), UseItemOnOffhandAction.class); - register(new ServerUseItemToOffhandAction(), UseItemToOffhandAction.class); - register(new ServerLookAction(), LookAction.class); - register(new ServerFishAction(), FishAction.class); - register(new ServerSwimAction(), SwimAction.class); - register(new ServerRotationAction(), RotationAction.class); - register(new ServerMoveAction(), MoveAction.class); - register(new ServerMountAction(), MountAction.class); - register(new ServerSwapAction(), SwapAction.class); + register(AttackAction.class, ServerAttackAction::new); + register(BreakBlockAction.class, ServerBreakBlockAction::new); + register(DropAction.class, ServerDropAction::new); + register(JumpAction.class, ServerJumpAction::new); + register(SneakAction.class, ServerSneakAction::new); + register(UseItemAutoAction.class, ServerUseItemAutoAction::new); + register(UseItemAction.class, ServerUseItemAction::new); + register(UseItemOnAction.class, ServerUseItemOnAction::new); + register(UseItemToAction.class, ServerUseItemToAction::new); + register(UseItemOffhandAction.class, ServerUseItemOffhandAction::new); + register(UseItemOnOffhandAction.class, ServerUseItemOnOffhandAction::new); + register(UseItemToOffhandAction.class, ServerUseItemToOffhandAction::new); + register(LookAction.class, ServerLookAction::new); + register(FishAction.class, ServerFishAction::new); + register(SwimAction.class, ServerSwimAction::new); + register(RotationAction.class, ServerRotationAction::new); + register(MoveAction.class, ServerMoveAction::new); + register(MountAction.class, ServerMountAction::new); + register(SwapAction.class, ServerSwapAction::new); } - public static boolean register(@NotNull AbstractBotAction action, Class type) { + public static > boolean register(Class> apiType, @NotNull Supplier creator) { + AbstractBotAction action = creator.get(); if (!actionsByName.containsKey(action.getName())) { - actionsByName.put(action.getName(), action); - actionsByClass.put(type, action); + Actions actions = new Actions<>(creator.get().getName(), apiType, creator); + actionsByName.put(action.getName(), actions); + actionsByClass.put(apiType, actions); return true; } return false; } - public static boolean register(@NotNull AbstractBotAction action) { - return register(action, action.getClass()); + private final String name; + private final Class apiType; + private final Supplier creator; + + private Actions(String name, Class> apiType, Supplier creator) { + this.name = name; + this.apiType = apiType; + this.creator = creator; + } + + public String getName() { + return name; + } + + public Class getType() { + return apiType; + } + + public T create() { + return creator.get(); + } + + public T createByCommand(CommandContext context) throws CommandSyntaxException { + T action = create(); + action.loadCommand(context); + return action; } public static boolean unregister(@NotNull String name) { - AbstractBotAction action = actionsByName.remove(name); + Actions action = actionsByName.remove(name); if (action != null) { actionsByClass.remove(action.getClass()); return true; @@ -62,7 +91,7 @@ public static boolean unregister(@NotNull String name) { @NotNull @Contract(pure = true) - public static Collection> getAll() { + public static Collection>> getAll() { return actionsByName.values(); } @@ -72,12 +101,12 @@ public static Set getNames() { } @Nullable - public static AbstractBotAction getForName(String name) { + public static Actions getByName(String name) { return actionsByName.get(name); } @Nullable - public static AbstractBotAction getForClass(@NotNull Class type) { + public static Actions getByClass(@NotNull Class type) { return actionsByClass.get(type); } -} +} \ No newline at end of file diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/Configs.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/Configs.java index 602aff022..91f2418ca 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/Configs.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/Configs.java @@ -2,7 +2,7 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import org.leavesmc.leaves.bot.ServerBot; import org.leavesmc.leaves.bot.agent.configs.AbstractBotConfig; import org.leavesmc.leaves.bot.agent.configs.AlwaysSendDataConfig; import org.leavesmc.leaves.bot.agent.configs.LocatorBarConfig; @@ -14,35 +14,70 @@ import java.util.Collection; import java.util.HashMap; import java.util.Map; +import java.util.Optional; +import java.util.function.Supplier; -@SuppressWarnings({"unused"}) -public class Configs { - private static final Map, AbstractBotConfig> configs = new HashMap<>(); +public class Configs> { - public static final SkipSleepConfig SKIP_SLEEP = register(new SkipSleepConfig()); - public static final AlwaysSendDataConfig ALWAYS_SEND_DATA = register(new AlwaysSendDataConfig()); - public static final SpawnPhantomConfig SPAWN_PHANTOM = register(new SpawnPhantomConfig()); - public static final SimulationDistanceConfig SIMULATION_DISTANCE = register(new SimulationDistanceConfig()); - public static final TickTypeConfig TICK_TYPE = register(new TickTypeConfig()); - public static final LocatorBarConfig ENABLE_LOCATOR_BAR = register(new LocatorBarConfig()); + private static final Map>> configs = new HashMap<>(); - @Nullable - public static AbstractBotConfig getConfig(String name) { + public static final Configs SKIP_SLEEP = register(SkipSleepConfig.class, SkipSleepConfig::new); + public static final Configs ALWAYS_SEND_DATA = register(AlwaysSendDataConfig.class, AlwaysSendDataConfig::new); + public static final Configs SPAWN_PHANTOM = register(SpawnPhantomConfig.class, SpawnPhantomConfig::new); + public static final Configs SIMULATION_DISTANCE = register(SimulationDistanceConfig.class, SimulationDistanceConfig::new); + public static final Configs TICK_TYPE = register(TickTypeConfig.class, TickTypeConfig::new); + public static final Configs ENABLE_LOCATOR_BAR = register(LocatorBarConfig.class, LocatorBarConfig::new); + + private final Class> configClass; + private final Supplier> configCreator; + private final String name; + + private Configs(Class> configClass, Supplier> configCreator, String name) { + this.configClass = configClass; + this.configCreator = configCreator; + this.name = name; + } + + public String getName() { + return name; + } + + @SuppressWarnings("unchecked") + public E create() { + return (E) configCreator.get(); + } + + @SuppressWarnings("unchecked") + public E create(ServerBot bot) { + E config = (E) configCreator.get(); + config.setBot(bot); + return config; + } + + @NotNull + public static Optional> getConfig(String name) { return configs.values().stream() - .filter(config -> config.getName().equals(name)) - .findFirst() - .orElse(null); + .filter(config -> config.name.equals(name)) + .findFirst(); + } + + @NotNull + public static Optional> getConfig(Class> configClass) { + return configs.values().stream() + .filter(config -> config.configClass.equals(configClass)) + .findFirst(); } @NotNull @Contract(pure = true) - public static Collection> getConfigs() { + public static Collection>> getConfigs() { return configs.values(); } - @SuppressWarnings("unchecked") - private static > @NotNull E register(AbstractBotConfig instance) { - configs.put(instance.getClass(), instance); - return (E) instance; + private static > @NotNull Configs register(Class> configClass, Supplier> configCreator) { + String name = configCreator.get().getName(); + Configs config = new Configs<>(configClass, configCreator, name); + configs.put(name, config); + return config; } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractBotAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractBotAction.java index 8a67165c5..5a7395805 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractBotAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractBotAction.java @@ -11,6 +11,7 @@ import org.leavesmc.leaves.bot.agent.ExtraData; import org.leavesmc.leaves.command.CommandContext; import org.leavesmc.leaves.command.WrappedArgument; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.event.bot.BotActionExecuteEvent; import org.leavesmc.leaves.event.bot.BotActionStopEvent; import org.leavesmc.leaves.util.UpdateSuppressionException; @@ -21,14 +22,12 @@ import java.util.Map; import java.util.UUID; import java.util.function.Consumer; -import java.util.function.Supplier; @SuppressWarnings("unchecked") public abstract class AbstractBotAction> { private final String name; private final Map>>> arguments; - private final Supplier creator; private UUID uuid; private int currentFork = 0; @@ -44,10 +43,9 @@ public abstract class AbstractBotAction> { private Consumer onSuccess; private Consumer onStop; - public AbstractBotAction(String name, Supplier creator) { + public AbstractBotAction(String name) { this.name = name; this.uuid = UUID.randomUUID(); - this.creator = creator; this.arguments = new HashMap<>(); this.cancel = false; @@ -58,7 +56,7 @@ public AbstractBotAction(String name, Supplier creator) { public abstract boolean doTick(@NotNull ServerBot bot); - public abstract Object asCraft(); + public abstract CraftBotAction asCraft(); public String getActionDataString() { return getActionDataString(new ExtraData(new ArrayList<>())); @@ -184,11 +182,6 @@ public void stop(@NotNull ServerBot bot, BotActionStopEvent.Reason reason) { public void loadCommand(@NotNull CommandContext context) throws CommandSyntaxException { } - @NotNull - public E create() { - return this.creator.get(); - } - public String getName() { return this.name; } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractStateBotAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractStateBotAction.java index 75876ab83..9b6b991c3 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractStateBotAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractStateBotAction.java @@ -1,10 +1,8 @@ package org.leavesmc.leaves.bot.agent.actions; -import java.util.function.Supplier; - public abstract class AbstractStateBotAction> extends AbstractBotAction { - public AbstractStateBotAction(String name, Supplier creator) { - super(name, creator); + public AbstractStateBotAction(String name) { + super(name); this.setDoNumber(-1); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractTimerBotAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractTimerBotAction.java index 817b5ec03..401540edb 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractTimerBotAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractTimerBotAction.java @@ -5,15 +5,13 @@ import org.leavesmc.leaves.bot.agent.ExtraData; import org.leavesmc.leaves.command.CommandContext; -import java.util.function.Supplier; - import static com.mojang.brigadier.arguments.IntegerArgumentType.integer; import static org.leavesmc.leaves.command.ArgumentNode.ArgumentSuggestions.strings; public abstract class AbstractTimerBotAction> extends AbstractBotAction { - public AbstractTimerBotAction(String name, Supplier creator) { - super(name, creator); + public AbstractTimerBotAction(String name) { + super(name); this.addArgument("delay", integer(0)).suggests(strings("0", "5", "10", "20")).setOptional(true); this.addArgument("interval", integer(0)).suggests(strings("20", "0", "5", "10")).setOptional(true); this.addArgument("do_number", integer(-1)) diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractUseBotAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractUseBotAction.java index ddaeec331..ca7d53374 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractUseBotAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/AbstractUseBotAction.java @@ -9,8 +9,6 @@ import org.leavesmc.leaves.command.CommandContext; import org.leavesmc.leaves.event.bot.BotActionStopEvent; -import java.util.function.Supplier; - import static com.mojang.brigadier.arguments.IntegerArgumentType.integer; public abstract class AbstractUseBotAction> extends AbstractTimerBotAction { @@ -18,8 +16,8 @@ public abstract class AbstractUseBotAction> ex private int alreadyUsedTick = 0; private int useItemRemainingTicks = 0; - public AbstractUseBotAction(String name, Supplier supplier) { - super(name, supplier); + public AbstractUseBotAction(String name) { + super(name); this.addArgument("use_timeout", integer(-1)) .suggests((context, builder) -> { builder.suggest("-1", Component.literal("no use timeout")); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerAttackAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerAttackAction.java index 6a3add3b7..7b33db121 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerAttackAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerAttackAction.java @@ -4,11 +4,12 @@ import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; import org.leavesmc.leaves.entity.bot.actions.CraftAttackAction; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; public class ServerAttackAction extends AbstractTimerBotAction { public ServerAttackAction() { - super("attack", ServerAttackAction::new); + super("attack"); } @Override @@ -23,7 +24,7 @@ public boolean doTick(@NotNull ServerBot bot) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftAttackAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerBreakBlockAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerBreakBlockAction.java index 36a2e621c..ae85e2ee1 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerBreakBlockAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerBreakBlockAction.java @@ -11,12 +11,13 @@ import org.bukkit.craftbukkit.block.CraftBlock; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftBreakBlockAction; public class ServerBreakBlockAction extends AbstractTimerBotAction { public ServerBreakBlockAction() { - super("break", ServerBreakBlockAction::new); + super("break"); } private ItemStack lastItem = null; @@ -102,7 +103,7 @@ private float incrementDestroyProgress(ServerBot bot, @NotNull BlockState state, } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftBreakBlockAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerDropAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerDropAction.java index 68e7e8174..624e53ab7 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerDropAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerDropAction.java @@ -2,12 +2,13 @@ import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftDropAction; public class ServerDropAction extends AbstractTimerBotAction { public ServerDropAction() { - super("drop", ServerDropAction::new); + super("drop"); } @Override @@ -17,7 +18,7 @@ public boolean doTick(@NotNull ServerBot bot) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftDropAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerFishAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerFishAction.java index 3e895f1a9..5bed6238c 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerFishAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerFishAction.java @@ -7,12 +7,13 @@ import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftFishAction; public class ServerFishAction extends AbstractTimerBotAction { public ServerFishAction() { - super("fish", ServerFishAction::new); + super("fish"); } private static final int CATCH_ENTITY_DELAY = 20; @@ -74,7 +75,7 @@ public boolean doTick(@NotNull ServerBot bot) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftFishAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerJumpAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerJumpAction.java index f7571a79e..6a279b273 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerJumpAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerJumpAction.java @@ -2,12 +2,13 @@ import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftJumpAction; public class ServerJumpAction extends AbstractTimerBotAction { public ServerJumpAction() { - super("jump", ServerJumpAction::new); + super("jump"); } @Override @@ -21,7 +22,7 @@ public boolean doTick(@NotNull ServerBot bot) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftJumpAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerLookAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerLookAction.java index 8333826d2..9f1153b25 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerLookAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerLookAction.java @@ -14,6 +14,7 @@ import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; import org.leavesmc.leaves.command.CommandContext; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftLookAction; public class ServerLookAction extends AbstractBotAction { @@ -24,7 +25,7 @@ public class ServerLookAction extends AbstractBotAction { private ServerPlayer target = null; public ServerLookAction() { - super("look", ServerLookAction::new); + super("look"); this.addArgument("player", ArgumentTypes.player()).setOptional(true); this.fork(1); this.addArgument("location", ArgumentTypes.finePosition()); @@ -102,7 +103,7 @@ public boolean doTick(@NotNull ServerBot bot) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftLookAction(this); } } \ No newline at end of file diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerMountAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerMountAction.java index 05a8a697e..b26f2a17d 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerMountAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerMountAction.java @@ -5,6 +5,7 @@ import org.bukkit.entity.Vehicle; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftMountAction; import java.util.Comparator; @@ -13,7 +14,7 @@ public class ServerMountAction extends AbstractBotAction { public ServerMountAction() { - super("mount", ServerMountAction::new); + super("mount"); } @Override @@ -40,7 +41,7 @@ public boolean doTick(@NotNull ServerBot bot) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftMountAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerMoveAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerMoveAction.java index 4023b4696..f65e29acc 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerMoveAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerMoveAction.java @@ -6,6 +6,7 @@ import org.leavesmc.leaves.command.CommandContext; import org.leavesmc.leaves.command.arguments.EnumArgumentType; import org.leavesmc.leaves.entity.bot.action.MoveAction.MoveDirection; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftMoveAction; import org.leavesmc.leaves.event.bot.BotActionStopEvent; @@ -13,7 +14,7 @@ public class ServerMoveAction extends AbstractStateBotAction { private MoveDirection direction = MoveDirection.FORWARD; public ServerMoveAction() { - super("move", ServerMoveAction::new); + super("move"); this.addArgument("direction", EnumArgumentType.fromEnum(MoveDirection.class)); } @@ -59,7 +60,7 @@ public void setDirection(MoveDirection direction) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftMoveAction(this); } } \ No newline at end of file diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerRotationAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerRotationAction.java index 85f510640..ad7870991 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerRotationAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerRotationAction.java @@ -9,6 +9,7 @@ import org.leavesmc.leaves.bot.ServerBot; import org.leavesmc.leaves.bot.agent.ExtraData; import org.leavesmc.leaves.command.CommandContext; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftRotationAction; import java.text.DecimalFormat; @@ -18,7 +19,7 @@ public class ServerRotationAction extends AbstractBotAction { CommandSender sender = context.getSender(); @@ -103,7 +104,7 @@ public boolean doTick(@NotNull ServerBot bot) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftRotationAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSneakAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSneakAction.java index 7c6ac393f..a795b2e90 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSneakAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSneakAction.java @@ -2,13 +2,14 @@ import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftSneakAction; import org.leavesmc.leaves.event.bot.BotActionStopEvent; public class ServerSneakAction extends AbstractStateBotAction { public ServerSneakAction() { - super("sneak", ServerSneakAction::new); + super("sneak"); } @Override @@ -28,7 +29,7 @@ public void stop(@NotNull ServerBot bot, BotActionStopEvent.Reason reason) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftSneakAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSwapAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSwapAction.java index 12d737e30..f3aa11433 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSwapAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSwapAction.java @@ -4,12 +4,13 @@ import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftSwapAction; public class ServerSwapAction extends AbstractBotAction { public ServerSwapAction() { - super("swap", ServerSwapAction::new); + super("swap"); } @Override @@ -22,7 +23,7 @@ public boolean doTick(@NotNull ServerBot bot) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftSwapAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSwimAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSwimAction.java index df5b0bf5f..cab348e80 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSwimAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerSwimAction.java @@ -3,12 +3,13 @@ import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftSwimAction; public class ServerSwimAction extends AbstractStateBotAction { public ServerSwimAction() { - super("swim", ServerSwimAction::new); + super("swim"); } @Override @@ -20,7 +21,7 @@ public boolean doTick(@NotNull ServerBot bot) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftSwimAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAction.java index ce5884b87..4b7e0b635 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAction.java @@ -4,12 +4,13 @@ import net.minecraft.world.InteractionResult; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftUseItemAction; public class ServerUseItemAction extends AbstractUseBotAction { public ServerUseItemAction() { - super("use", ServerUseItemAction::new); + super("use"); } @Override @@ -27,7 +28,7 @@ protected boolean interact(@NotNull ServerBot bot) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftUseItemAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAutoAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAutoAction.java index bfb5f537e..6325e32be 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAutoAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemAutoAction.java @@ -11,6 +11,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.bot.ServerBot; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftUseItemAutoAction; import static org.leavesmc.leaves.bot.agent.actions.ServerUseItemAction.useItem; @@ -20,7 +21,7 @@ public class ServerUseItemAutoAction extends AbstractUseBotAction { public ServerUseItemAutoAction() { - super("use_auto", ServerUseItemAutoAction::new); + super("use_auto"); } @Override @@ -80,7 +81,7 @@ protected boolean interact(ServerBot bot) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftUseItemAutoAction(this); } } \ No newline at end of file diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOffhandAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOffhandAction.java index b05d8ab1b..c247f1b19 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOffhandAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOffhandAction.java @@ -3,6 +3,7 @@ import net.minecraft.world.InteractionHand; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftUseItemOffhandAction; import static org.leavesmc.leaves.bot.agent.actions.ServerUseItemAction.useItem; @@ -10,7 +11,7 @@ public class ServerUseItemOffhandAction extends AbstractUseBotAction { public ServerUseItemOffhandAction() { - super("use_offhand", ServerUseItemOffhandAction::new); + super("use_offhand"); } @Override @@ -19,7 +20,7 @@ protected boolean interact(@NotNull ServerBot bot) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftUseItemOffhandAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnAction.java index cdcb2b58f..17722da2c 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnAction.java @@ -7,12 +7,13 @@ import net.minecraft.world.phys.HitResult; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftUseItemOnAction; public class ServerUseItemOnAction extends AbstractUseBotAction { public ServerUseItemOnAction() { - super("use_on", ServerUseItemOnAction::new); + super("use_on"); } @Override @@ -41,7 +42,7 @@ public static InteractionResult useItemOn(ServerBot bot, BlockHitResult hitResul } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftUseItemOnAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnOffhandAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnOffhandAction.java index ac06e27cd..1022a406c 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnOffhandAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemOnOffhandAction.java @@ -4,6 +4,7 @@ import net.minecraft.world.phys.BlockHitResult; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftUseItemOnOffhandAction; import static org.leavesmc.leaves.bot.agent.actions.ServerUseItemOnAction.useItemOn; @@ -11,7 +12,7 @@ public class ServerUseItemOnOffhandAction extends AbstractUseBotAction { public ServerUseItemOnOffhandAction() { - super("use_on_offhand", ServerUseItemOnOffhandAction::new); + super("use_on_offhand"); } @Override @@ -21,7 +22,7 @@ protected boolean interact(@NotNull ServerBot bot) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftUseItemOnOffhandAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToAction.java index 9d985c0c4..0f1cf6e6b 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToAction.java @@ -7,12 +7,13 @@ import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftUseItemToAction; public class ServerUseItemToAction extends AbstractUseBotAction { public ServerUseItemToAction() { - super("use_to", ServerUseItemToAction::new); + super("use_to"); } @Override @@ -46,7 +47,7 @@ public static InteractionResult useItemTo(ServerBot bot, EntityHitResult hitResu } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftUseItemToAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToOffhandAction.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToOffhandAction.java index 6ce3aec69..b135463c5 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToOffhandAction.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/actions/ServerUseItemToOffhandAction.java @@ -4,6 +4,7 @@ import net.minecraft.world.phys.EntityHitResult; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.bot.ServerBot; +import org.leavesmc.leaves.entity.bot.actions.CraftBotAction; import org.leavesmc.leaves.entity.bot.actions.CraftUseItemToOffhandAction; import static org.leavesmc.leaves.bot.agent.actions.ServerUseItemToAction.useItemTo; @@ -11,7 +12,7 @@ public class ServerUseItemToOffhandAction extends AbstractUseBotAction { public ServerUseItemToOffhandAction() { - super("use_to_offhand", ServerUseItemToOffhandAction::new); + super("use_to_offhand"); } @Override @@ -21,7 +22,7 @@ protected boolean interact(@NotNull ServerBot bot) { } @Override - public Object asCraft() { + public CraftBotAction asCraft() { return new CraftUseItemToOffhandAction(this); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/AbstractBotConfig.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/AbstractBotConfig.java index 7b87332d3..d4ed8e172 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/AbstractBotConfig.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/AbstractBotConfig.java @@ -15,42 +15,36 @@ import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.function.Supplier; -public abstract class AbstractBotConfig> { +public abstract class AbstractBotConfig { + private final String name; private final WrappedArgument argument; - private final Supplier creator; protected ServerBot bot; - public AbstractBotConfig(String name, ArgumentType type, Supplier creator) { + public AbstractBotConfig(String name, ArgumentType type) { this.name = name; this.argument = new WrappedArgument<>(name, type); if (shouldApplySuggestions()) { this.argument.suggests(this::applySuggestions); } - this.creator = creator; } @SuppressWarnings("RedundantThrows") public void applySuggestions(final CommandContext context, final SuggestionsBuilder builder) throws CommandSyntaxException { } - public AbstractBotConfig setBot(ServerBot bot) { + public AbstractBotConfig setBot(ServerBot bot) { this.bot = bot; return this; } - public E create() { - return creator.get(); - } - public abstract T getValue(); public abstract void setValue(T value) throws CommandSyntaxException; - public abstract T loadFromCommand(@NotNull CommandContext context) throws CommandSyntaxException; + public abstract T parseFromCommand(@NotNull CommandContext context) throws CommandSyntaxException; public String getName() { return name; @@ -95,4 +89,4 @@ private boolean shouldApplySuggestions() { } return false; } -} +} \ No newline at end of file diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/AlwaysSendDataConfig.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/AlwaysSendDataConfig.java index 59ba35836..fea5cc082 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/AlwaysSendDataConfig.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/AlwaysSendDataConfig.java @@ -6,11 +6,11 @@ import org.leavesmc.leaves.LeavesConfig; import org.leavesmc.leaves.command.CommandContext; -public class AlwaysSendDataConfig extends AbstractBotConfig { +public class AlwaysSendDataConfig extends AbstractBotConfig { private boolean value; public AlwaysSendDataConfig() { - super("always_send_data", BoolArgumentType.bool(), AlwaysSendDataConfig::new); + super("always_send_data", BoolArgumentType.bool()); this.value = LeavesConfig.modify.fakeplayer.inGame.canSendDataAlways; } @@ -25,7 +25,7 @@ public void setValue(Boolean value) { } @Override - public Boolean loadFromCommand(@NotNull CommandContext context) { + public Boolean parseFromCommand(@NotNull CommandContext context) { return context.getBoolean(getName()); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/LocatorBarConfig.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/LocatorBarConfig.java index cfb94613e..58aab07d0 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/LocatorBarConfig.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/LocatorBarConfig.java @@ -7,11 +7,11 @@ import org.leavesmc.leaves.LeavesConfig; import org.leavesmc.leaves.command.CommandContext; -public class LocatorBarConfig extends AbstractBotConfig { +public class LocatorBarConfig extends AbstractBotConfig { private boolean value; public LocatorBarConfig() { - super("enable_locator_bar", BoolArgumentType.bool(), LocatorBarConfig::new); + super("enable_locator_bar", BoolArgumentType.bool()); this.value = LeavesConfig.modify.fakeplayer.inGame.enableLocatorBar; } @@ -32,7 +32,7 @@ public void setValue(@NotNull Boolean value) throws IllegalArgumentException { } @Override - public Boolean loadFromCommand(@NotNull CommandContext context) { + public Boolean parseFromCommand(@NotNull CommandContext context) { return context.getBoolean(getName()); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SimulationDistanceConfig.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SimulationDistanceConfig.java index 042064c74..8de547a34 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SimulationDistanceConfig.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SimulationDistanceConfig.java @@ -9,10 +9,10 @@ import static net.minecraft.network.chat.Component.literal; -public class SimulationDistanceConfig extends AbstractBotConfig { +public class SimulationDistanceConfig extends AbstractBotConfig { public SimulationDistanceConfig() { - super("simulation_distance", IntegerArgumentType.integer(2, 32), SimulationDistanceConfig::new); + super("simulation_distance", IntegerArgumentType.integer(2, 32)); } @Override @@ -35,7 +35,7 @@ public void setValue(Integer value) { } @Override - public Integer loadFromCommand(@NotNull CommandContext context) { + public Integer parseFromCommand(@NotNull CommandContext context) { return context.getInteger(getName()); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SkipSleepConfig.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SkipSleepConfig.java index 9580313a6..84be4a5af 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SkipSleepConfig.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SkipSleepConfig.java @@ -6,10 +6,10 @@ import org.leavesmc.leaves.LeavesConfig; import org.leavesmc.leaves.command.CommandContext; -public class SkipSleepConfig extends AbstractBotConfig { +public class SkipSleepConfig extends AbstractBotConfig { public SkipSleepConfig() { - super("skip_sleep", BoolArgumentType.bool(), SkipSleepConfig::new); + super("skip_sleep", BoolArgumentType.bool()); } @Override @@ -23,7 +23,7 @@ public void setValue(Boolean value) throws IllegalArgumentException { } @Override - public Boolean loadFromCommand(@NotNull CommandContext context) { + public Boolean parseFromCommand(@NotNull CommandContext context) { return context.getBoolean(getName()); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SpawnPhantomConfig.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SpawnPhantomConfig.java index f155beda4..bd28132bc 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SpawnPhantomConfig.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/SpawnPhantomConfig.java @@ -7,11 +7,11 @@ import org.leavesmc.leaves.bot.agent.ExtraData; import org.leavesmc.leaves.command.CommandContext; -public class SpawnPhantomConfig extends AbstractBotConfig { +public class SpawnPhantomConfig extends AbstractBotConfig { private boolean value; public SpawnPhantomConfig() { - super("spawn_phantom", BoolArgumentType.bool(), SpawnPhantomConfig::new); + super("spawn_phantom", BoolArgumentType.bool()); this.value = LeavesConfig.modify.fakeplayer.inGame.canSpawnPhantom; } @@ -32,7 +32,7 @@ public String getExtraDataString(@NotNull ExtraData data) { } @Override - public Boolean loadFromCommand(@NotNull CommandContext context) { + public Boolean parseFromCommand(@NotNull CommandContext context) { return context.getBoolean(getName()); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/TickTypeConfig.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/TickTypeConfig.java index 828bf9b5f..f221b5d9c 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/TickTypeConfig.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/agent/configs/TickTypeConfig.java @@ -9,16 +9,16 @@ import java.util.Locale; -public class TickTypeConfig extends AbstractBotConfig { +public class TickTypeConfig extends AbstractBotConfig { private ServerBot.TickType value; public TickTypeConfig() { - super("tick_type", EnumArgumentType.fromEnum(ServerBot.TickType.class), TickTypeConfig::new); + super("tick_type", EnumArgumentType.fromEnum(ServerBot.TickType.class)); this.value = LeavesConfig.modify.fakeplayer.inGame.tickType; } @Override - public ServerBot.TickType loadFromCommand(@NotNull CommandContext context) { + public ServerBot.TickType parseFromCommand(@NotNull CommandContext context) { return context.getArgument("tick_type", ServerBot.TickType.class); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/SimpleBytebufAllocator.java b/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/SimpleBytebufAllocator.java new file mode 100644 index 000000000..1f764723f --- /dev/null +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/SimpleBytebufAllocator.java @@ -0,0 +1,16 @@ +package org.leavesmc.leaves.bytebuf; + +import io.netty.buffer.Unpooled; + +public class SimpleBytebufAllocator implements BytebufAllocator { + + @Override + public Bytebuf newBytebuf(int size) { + return new WrappedBytebuf(Unpooled.buffer(size)); + } + + @Override + public Bytebuf toBytebuf(byte[] bytes) { + return new WrappedBytebuf(Unpooled.wrappedBuffer(bytes)); + } +} diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/SimpleBytebufManager.java b/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/SimpleBytebufManager.java deleted file mode 100644 index 87388491d..000000000 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/SimpleBytebufManager.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.leavesmc.leaves.bytebuf; - -import io.netty.buffer.Unpooled; -import org.bukkit.plugin.Plugin; -import org.leavesmc.leaves.bytebuf.internal.InternalBytebufHandler; -import org.leavesmc.leaves.bytebuf.packet.PacketListener; - -public class SimpleBytebufManager implements BytebufManager { - - private final InternalBytebufHandler internal; - - public SimpleBytebufManager(InternalBytebufHandler internal) { - this.internal = internal; - } - - @SuppressWarnings("deprecation") - @Override - public void registerListener(Plugin plugin, PacketListener listener) { - internal.listenerMap.put(listener, plugin); - } - - @SuppressWarnings("deprecation") - @Override - public void unregisterListener(Plugin plugin, PacketListener listener) { - internal.listenerMap.remove(listener); - } - - @Override - public Bytebuf newBytebuf(int size) { - return new WrappedBytebuf(Unpooled.buffer(size)); - } - - @Override - public Bytebuf toBytebuf(byte[] bytes) { - return new WrappedBytebuf(Unpooled.wrappedBuffer(bytes)); - } -} diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/WrappedBytebuf.java b/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/WrappedBytebuf.java index e549e6879..7986b0728 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/WrappedBytebuf.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/WrappedBytebuf.java @@ -5,7 +5,6 @@ import com.mojang.serialization.JsonOps; import io.netty.buffer.ByteBuf; import net.minecraft.core.RegistryAccess; -import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.ComponentSerialization; @@ -18,21 +17,28 @@ public class WrappedBytebuf implements Bytebuf { - private final FriendlyByteBuf buf; - private final RegistryFriendlyByteBuf registryBuf; + private final RegistryFriendlyByteBuf buf; + + private ByteBuf snapshot = null; public WrappedBytebuf(ByteBuf buf) { - if (buf instanceof RegistryFriendlyByteBuf) { - this.buf = (FriendlyByteBuf) buf; - this.registryBuf = (RegistryFriendlyByteBuf) buf; + if (buf instanceof RegistryFriendlyByteBuf registryBuf) { + this.buf = registryBuf; } else { - this.buf = new FriendlyByteBuf(buf); - this.registryBuf = new RegistryFriendlyByteBuf(this.buf, MinecraftServer.getServer().registryAccess()); + this.buf = new RegistryFriendlyByteBuf(buf, MinecraftServer.getServer().registryAccess()); } } public RegistryFriendlyByteBuf getRegistryBuf() { - return registryBuf; + return buf; + } + + public void takeSnapshot() { + snapshot = buf.copy(); + } + + public boolean isDirty() { + return !buf.equals(snapshot); } @Override @@ -43,6 +49,12 @@ public byte[] toArray() { return data; } + @Override + public Bytebuf clear() { + buf.clear(); + return this; + } + @Override public Bytebuf skipBytes(int i) { buf.skipBytes(i); @@ -140,7 +152,7 @@ public short readShort() { @Override public Bytebuf writeInt(int i) { - buf.writeShort(i); + buf.writeInt(i); return this; } @@ -244,26 +256,26 @@ public JsonElement readComponentJson() { @Override public Bytebuf writeItemStack(ItemStack itemStack) { net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.unwrap(itemStack); - net.minecraft.world.item.ItemStack.OPTIONAL_STREAM_CODEC.encode(this.registryBuf, nmsItem); + net.minecraft.world.item.ItemStack.OPTIONAL_STREAM_CODEC.encode(this.buf, nmsItem); return this; } @Override public ItemStack readItemStack() { - net.minecraft.world.item.ItemStack nmsItem = net.minecraft.world.item.ItemStack.OPTIONAL_STREAM_CODEC.decode(this.registryBuf); + net.minecraft.world.item.ItemStack nmsItem = net.minecraft.world.item.ItemStack.OPTIONAL_STREAM_CODEC.decode(this.buf); return nmsItem.asBukkitMirror(); } @Override public Bytebuf writeItemStackList(List itemStacks) { List nmsItemList = itemStacks.stream().map(CraftItemStack::unwrap).toList(); - net.minecraft.world.item.ItemStack.OPTIONAL_LIST_STREAM_CODEC.encode(this.registryBuf, nmsItemList); + net.minecraft.world.item.ItemStack.OPTIONAL_LIST_STREAM_CODEC.encode(this.buf, nmsItemList); return this; } @Override public List readItemStackList() { - List nmsItemList = net.minecraft.world.item.ItemStack.OPTIONAL_LIST_STREAM_CODEC.decode(this.registryBuf); + List nmsItemList = net.minecraft.world.item.ItemStack.OPTIONAL_LIST_STREAM_CODEC.decode(this.buf); return nmsItemList.stream().map(net.minecraft.world.item.ItemStack::asBukkitMirror).toList(); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/internal/AudienceHolder.java b/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/internal/AudienceHolder.java new file mode 100644 index 000000000..4182a8172 --- /dev/null +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/internal/AudienceHolder.java @@ -0,0 +1,59 @@ +package org.leavesmc.leaves.bytebuf.internal; + +import io.netty.channel.Channel; +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.leavesmc.leaves.bytebuf.Bytebuf; +import org.leavesmc.leaves.bytebuf.PacketAudience; +import org.leavesmc.leaves.bytebuf.PacketType; + +public class AudienceHolder { + + private volatile PacketAudience audience; + + private volatile String name; + + private volatile Player player; + + AudienceHolder(Channel initChannel) { + this.audience = new PacketAudience() { + @Override + public void send(PacketType packetType, Bytebuf bytebuf) { + InternalBytebufHandler.sendPacket(this, packetType, bytebuf); + } + + @Override + public @Nullable Player getPlayer() { + return player; + } + + @Override + public @Nullable String getName() { + return name; + } + + @Override + public @NotNull Object getChannel() { + return initChannel; + } + }; + } + + public void setPlayer(Player player) { + this.player = player; + this.audience = player; + } + + public PacketAudience get() { + return audience; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/internal/InternalBytebufHandler.java b/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/internal/InternalBytebufHandler.java index eba0cc486..8e058b32c 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/internal/InternalBytebufHandler.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/internal/InternalBytebufHandler.java @@ -1,65 +1,107 @@ package org.leavesmc.leaves.bytebuf.internal; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.collect.ImmutableMap; -import io.netty.buffer.Unpooled; +import io.netty.channel.Channel; import io.netty.channel.ChannelDuplexHandler; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPromise; +import io.papermc.paper.network.ChannelInitializeListenerHolder; +import net.kyori.adventure.key.Key; import net.minecraft.network.Connection; -import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; -import net.minecraft.network.codec.StreamCodec; import net.minecraft.network.protocol.BundleDelimiterPacket; import net.minecraft.network.protocol.BundlePacket; -import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; -import net.minecraft.network.protocol.game.ClientboundMoveEntityPacket; -import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket; +import net.minecraft.network.protocol.login.ServerboundHelloPacket; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; -import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; -import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.LeavesConfig; -import org.leavesmc.leaves.bytebuf.BytebufManager; -import org.leavesmc.leaves.bytebuf.SimpleBytebufManager; +import org.leavesmc.leaves.bytebuf.Bytebuf; +import org.leavesmc.leaves.bytebuf.PacketAudience; +import org.leavesmc.leaves.bytebuf.PacketFlow; +import org.leavesmc.leaves.bytebuf.PacketType; +import org.leavesmc.leaves.bytebuf.SimpleBytebufAllocator; import org.leavesmc.leaves.bytebuf.WrappedBytebuf; -import org.leavesmc.leaves.bytebuf.packet.Packet; -import org.leavesmc.leaves.bytebuf.packet.PacketListener; -import org.leavesmc.leaves.bytebuf.packet.PacketType; +import org.leavesmc.leaves.event.bytebuf.PacketEvent; +import org.leavesmc.leaves.event.bytebuf.PacketInEvent; +import org.leavesmc.leaves.event.bytebuf.PacketOutEvent; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.UUID; -import static org.leavesmc.leaves.bytebuf.packet.PacketType.*; +import static org.leavesmc.leaves.bytebuf.internal.UniversalCodec.TYPE_MAP; -@SuppressWarnings({"deprecation", "rawtypes", "unchecked"}) public class InternalBytebufHandler { - private class PacketHandler extends ChannelDuplexHandler { + private static final SimpleBytebufAllocator ALLOCATOR = new SimpleBytebufAllocator(); + private static final UniversalCodec CODEC = new UniversalCodec(); + + public static void init() { + ChannelInitializeListenerHolder.addListener(Key.key("leaves:bytebuf"), channel -> + channel.pipeline().addBefore("packet_handler", PacketHandler.handlerName, new PacketHandler(channel))); + } + + public static void updatePlayer(ServerPlayer player) { + PacketHandler handler = (PacketHandler) player.connection.connection.channel.pipeline().get(PacketHandler.handlerName); + handler.audienceHolder.setPlayer(player.getBukkitEntity()); + } + + public static SimpleBytebufAllocator allocator() { + return ALLOCATOR; + } + + public static net.minecraft.network.protocol.Packet callPacketEvent(PacketAudience audience, net.minecraft.network.protocol.Packet nmsPacket, PacketFlow bound) { + if ((bound == PacketFlow.CLIENTBOUND && PacketOutEvent.getHandlerList().getRegisteredListeners().length == 0) || + (bound == PacketFlow.SERVERBOUND && PacketInEvent.getHandlerList().getRegisteredListeners().length == 0)) { + return nmsPacket; + } + PacketType type = TYPE_MAP.get(nmsPacket.type()); + if (type == null) { + return nmsPacket; + } + boolean isConfigStage = audience.getPlayer() == null; + WrappedBytebuf bytebuf = new WrappedBytebuf(CODEC.encode(nmsPacket, isConfigStage)); + bytebuf.takeSnapshot(); + PacketEvent event = bound == PacketFlow.CLIENTBOUND ? new PacketOutEvent(audience, type, bytebuf) : new PacketInEvent(audience, type, bytebuf); + if (!event.callEvent()) { + return null; + } + WrappedBytebuf newBuf = (WrappedBytebuf) event.getBytebuf(); + RegistryFriendlyByteBuf registryBuf = newBuf.getRegistryBuf(); + // Maybe read in the listener? Reset reader index for decode. + if (newBuf == bytebuf) { + registryBuf.readerIndex(0); + } + return newBuf != bytebuf || bytebuf.isDirty() ? CODEC.decode(type, registryBuf, isConfigStage) : nmsPacket; + } + + public static void sendPacket(PacketAudience audience, PacketType type, Bytebuf bytebuf) { + Channel channel = (Channel) audience.getChannel(); + Connection connection = (Connection) channel.pipeline().get("packet_handler"); + connection.send(CODEC.decode(type, ((WrappedBytebuf) bytebuf).getRegistryBuf(), audience.getPlayer() == null)); + } + + private static class PacketHandler extends ChannelDuplexHandler { private final static String handlerName = "leaves-bytebuf-handler"; - private final Player player; - public PacketHandler(Player player) { - this.player = player; + private final AudienceHolder audienceHolder; + + public PacketHandler(Channel channel) { + this.audienceHolder = new AudienceHolder(channel); } @Override public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { - if (msg instanceof BundlePacket || msg instanceof BundleDelimiterPacket) { + if (!LeavesConfig.mics.leavesPacketEvent || msg instanceof BundlePacket || msg instanceof BundleDelimiterPacket) { super.channelRead(ctx, msg); return; } - + if (msg instanceof ServerboundHelloPacket(String name, UUID profileId)) { + audienceHolder.setName(name); + } if (msg instanceof net.minecraft.network.protocol.Packet nmsPacket) { try { - msg = callPacketInEvent(player, nmsPacket); - } catch (Exception e) { - MinecraftServer.LOGGER.error("Error on PacketInEvent.", e); + msg = callPacketEvent(audienceHolder.get(), nmsPacket, PacketFlow.SERVERBOUND); + } catch (Throwable t) { + MinecraftServer.LOGGER.error("Error on PacketInEvent.", t); } } @@ -70,16 +112,16 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception @Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { - if (msg instanceof BundlePacket || msg instanceof BundleDelimiterPacket) { + if (!LeavesConfig.mics.leavesPacketEvent || msg instanceof BundlePacket || msg instanceof BundleDelimiterPacket) { super.write(ctx, msg, promise); return; } if (msg instanceof net.minecraft.network.protocol.Packet nmsPacket) { try { - msg = callPacketOutEvent(player, nmsPacket); - } catch (Exception e) { - MinecraftServer.LOGGER.error("Error on PacketInEvent.", e); + msg = callPacketEvent(audienceHolder.get(), nmsPacket, PacketFlow.CLIENTBOUND); + } catch (Throwable t) { + MinecraftServer.LOGGER.error("Error on PacketInEvent.", t); } } @@ -88,153 +130,4 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) } } } - - private static final List PACKET_PACKAGES = List.of( - "net.minecraft.network.protocol.common", - "net.minecraft.network.protocol.configuration", - "net.minecraft.network.protocol.cookie", - "net.minecraft.network.protocol.game", - "net.minecraft.network.protocol.handshake", - "net.minecraft.network.protocol.login", - "net.minecraft.network.protocol.ping", - "net.minecraft.network.protocol.status" - ); - - public final Map listenerMap = new HashMap<>(); - private final BytebufManager manager = new SimpleBytebufManager(this); - private final ImmutableMap type2CodecMap; - private final Cache, PacketType> resultCache = CacheBuilder.newBuilder().build(); - - public InternalBytebufHandler() { - ImmutableMap.Builder builder = ImmutableMap.builder(); - - for (PacketType packet : PacketType.values()) { - String className = packet.name() + "Packet"; - for (String basePackage : PACKET_PACKAGES) { - try { - Class packetClass = Class.forName(basePackage + "." + className); - Field field = packetClass.getDeclaredField("STREAM_CODEC"); - field.setAccessible(true); - builder.put(packet, (StreamCodec) field.get(null)); - } catch (Exception ignored) { - } - } - } - - builder.put(ClientboundMoveEntityPos, ClientboundMoveEntityPacket.Pos.STREAM_CODEC); - builder.put(ClientboundMoveEntityPosRot, ClientboundMoveEntityPacket.PosRot.STREAM_CODEC); - builder.put(ClientboundMoveEntityRot, ClientboundMoveEntityPacket.Rot.STREAM_CODEC); - builder.put(ServerboundMovePlayerPos, ServerboundMovePlayerPacket.Pos.STREAM_CODEC); - builder.put(ServerboundMovePlayerPosRot, ServerboundMovePlayerPacket.PosRot.STREAM_CODEC); - builder.put(ServerboundMovePlayerRot, ServerboundMovePlayerPacket.Rot.STREAM_CODEC); - builder.put(ServerboundMovePlayerStatusOnly, ServerboundMovePlayerPacket.StatusOnly.STREAM_CODEC); - builder.put(ClientboundCustomPayload, ClientboundCustomPayloadPacket.GAMEPLAY_STREAM_CODEC); - - type2CodecMap = builder.build(); - } - - public void injectPlayer(ServerPlayer player) { - if (LeavesConfig.mics.leavesPacketEvent) { - player.connection.connection.channel.pipeline().addBefore("packet_handler", PacketHandler.handlerName, new PacketHandler(player.getBukkitEntity())); - } - } - - public BytebufManager getManager() { - return manager; - } - - public net.minecraft.network.protocol.Packet callPacketInEvent(Player player, net.minecraft.network.protocol.Packet nmsPacket) { - if (listenerMap.isEmpty()) { - return nmsPacket; - } - PacketType type = toEnumType(nmsPacket.type()); - if (type == null) { - return nmsPacket; - } - Packet packet = createBytebufPacket(type, nmsPacket); - for (PacketListener listener : listenerMap.keySet()) { - if (listenerMap.get(listener).isEnabled()) { - packet = listener.onPacketIn(player, packet); - packet.bytebuf().resetReaderIndex(); - } else { - listenerMap.remove(listener); - } - } - return createNMSPacket(packet); - } - - public net.minecraft.network.protocol.Packet callPacketOutEvent(Player player, net.minecraft.network.protocol.Packet nmsPacket) { - if (listenerMap.isEmpty()) { - return nmsPacket; - } - PacketType type = toEnumType(nmsPacket.type()); - if (type == null) { - return nmsPacket; - } - Packet packet = createBytebufPacket(type, nmsPacket); - for (PacketListener listener : listenerMap.keySet()) { - if (listenerMap.get(listener).isEnabled()) { - packet = listener.onPacketOut(player, packet); - packet.bytebuf().resetReaderIndex(); - } else { - listenerMap.remove(listener); - } - } - return createNMSPacket(packet); - } - - public void applyPacketToPlayer(ServerPlayer player, Packet packet) { - Connection sp = player.connection.connection; - sp.send(createNMSPacket(packet)); - } - - public net.minecraft.network.protocol.Packet createNMSPacket(Packet packet) { - StreamCodec> codec = type2CodecMap.get(packet.type()); - if (codec == null) { - throw new UnsupportedOperationException("This feature is not completely finished yet, packet type " + packet.type() + " is not supported temporary."); - } - return codec.decode(((WrappedBytebuf) packet.bytebuf()).getRegistryBuf()); - } - - @Nullable - private PacketType toEnumType(net.minecraft.network.protocol.PacketType type) { - try { - return this.resultCache.get(type, () -> { - StringBuilder builder = new StringBuilder(); - String bound = type.toString().split("/")[0]; - String name = type.toString().split(":")[1]; - builder.append(bound.substring(0, 1).toUpperCase()).append(bound.substring(1)); - boolean flag = true; - for (int i = 0; i < name.length(); i++) { - if (flag) { - builder.append(name.substring(i, i + 1).toUpperCase()); - flag = false; - continue; - } - if (name.charAt(i) == '_') { - flag = true; - } else { - builder.append(name.charAt(i)); - } - } - try { - return PacketType.valueOf(builder.toString()); - } catch (IllegalArgumentException e) { - throw new RuntimeException(e); - } - }); - } catch (Exception ignore) { - return null; - } - } - - public Packet createBytebufPacket(PacketType type, net.minecraft.network.protocol.Packet nmsPacket) { - RegistryFriendlyByteBuf buf = new RegistryFriendlyByteBuf(Unpooled.buffer(), MinecraftServer.getServer().registryAccess()); - StreamCodec> codec = type2CodecMap.get(type); - if (codec == null) { - throw new UnsupportedOperationException("This feature is not completely finished yet, packet type " + type + " is not supported temporary."); - } - codec.encode(buf, nmsPacket); - return new Packet(type, new WrappedBytebuf(buf)); - } } \ No newline at end of file diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/internal/UniversalCodec.java b/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/internal/UniversalCodec.java new file mode 100644 index 000000000..8bfa516ec --- /dev/null +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bytebuf/internal/UniversalCodec.java @@ -0,0 +1,97 @@ +package org.leavesmc.leaves.bytebuf.internal; + +import com.google.common.collect.ImmutableMap; +import io.netty.buffer.Unpooled; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.network.protocol.Packet; +import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; +import net.minecraft.network.protocol.common.CommonPacketTypes; +import net.minecraft.network.protocol.configuration.ConfigurationPacketTypes; +import net.minecraft.network.protocol.cookie.CookiePacketTypes; +import net.minecraft.network.protocol.game.GamePacketTypes; +import net.minecraft.network.protocol.handshake.HandshakePacketTypes; +import net.minecraft.network.protocol.login.LoginPacketTypes; +import net.minecraft.network.protocol.ping.PingPacketTypes; +import net.minecraft.network.protocol.status.StatusPacketTypes; +import net.minecraft.server.MinecraftServer; +import org.leavesmc.leaves.bytebuf.PacketType; + +import java.lang.reflect.Field; +import java.lang.reflect.ParameterizedType; +import java.util.Map; +import java.util.function.Supplier; + +@SuppressWarnings({"rawtypes", "unchecked"}) +public class UniversalCodec { + + static final Map, PacketType> TYPE_MAP; + static final Supplier BUF_FACTORY = () -> new RegistryFriendlyByteBuf(Unpooled.buffer(), MinecraftServer.getServer().registryAccess()); + private static final Map CODEC_MAP; + private static final Map ID_MAP; + + static { + ImmutableMap.Builder idBuilder = ImmutableMap.builder(); + ImmutableMap.Builder, PacketType> typeBuilder = ImmutableMap.builder(); + ImmutableMap.Builder codecBuilder = ImmutableMap.builder(); + Class[] classes = new Class[]{ + CommonPacketTypes.class, ConfigurationPacketTypes.class, + CookiePacketTypes.class, GamePacketTypes.class, HandshakePacketTypes.class, + LoginPacketTypes.class, PingPacketTypes.class, StatusPacketTypes.class + }; + for (PacketType clientbound : PacketType.Clientbound.values()) { + idBuilder.put(clientbound.id(), clientbound); + } + for (PacketType serverbound : PacketType.Serverbound.values()) { + idBuilder.put(serverbound.id(), serverbound); + } + ID_MAP = idBuilder.buildOrThrow(); + for (Class clazz : classes) { + for (java.lang.reflect.Field field : clazz.getDeclaredFields()) { + try { + field.setAccessible(true); + net.minecraft.network.protocol.PacketType packetType = (net.minecraft.network.protocol.PacketType) field.get(null); + if (!(field.getGenericType() instanceof ParameterizedType type)) { + continue; + } + Class> packetClass = (Class>) type.getActualTypeArguments()[0]; + Field codecField = packetClass.getDeclaredField("STREAM_CODEC"); + codecField.setAccessible(true); + StreamCodec codec = (StreamCodec) codecField.get(null); + String id = packetType.flow().id() + "/" + packetType.id().getPath(); + PacketType apiType = ID_MAP.get(id); + if (apiType == null) { + continue; + } + typeBuilder.put(packetType, apiType); + codecBuilder.put(apiType, codec); + } catch (Throwable ignored) { + } + } + } + // Special case, there is no STREAM_CODEC in ClientboundCustomPayloadPacket. + // CustomPayload's encode/decode should work with protocol stage context (Play/Config). + typeBuilder.put(CommonPacketTypes.CLIENTBOUND_CUSTOM_PAYLOAD, PacketType.Clientbound.CUSTOM_PAYLOAD); + TYPE_MAP = typeBuilder.build(); + CODEC_MAP = codecBuilder.build(); + } + + public RegistryFriendlyByteBuf encode(Packet packet, boolean isConfigStage) { + RegistryFriendlyByteBuf buf = BUF_FACTORY.get(); + if (packet instanceof ClientboundCustomPayloadPacket payloadPacket) { + StreamCodec codec = isConfigStage ? ClientboundCustomPayloadPacket.CONFIG_STREAM_CODEC : ClientboundCustomPayloadPacket.GAMEPLAY_STREAM_CODEC; + codec.encode(buf, payloadPacket); + return buf; + } + CODEC_MAP.get(TYPE_MAP.get(packet.type())).encode(buf, packet); + return buf; + } + + public Packet decode(PacketType type, RegistryFriendlyByteBuf buf, boolean isConfigStage) { + if (type == PacketType.Clientbound.CUSTOM_PAYLOAD) { + StreamCodec codec = isConfigStage ? ClientboundCustomPayloadPacket.CONFIG_STREAM_CODEC : ClientboundCustomPayloadPacket.GAMEPLAY_STREAM_CODEC; + return (Packet) codec.decode(buf); + } + return (Packet) CODEC_MAP.get(type).decode(buf); + } +} \ No newline at end of file diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/command/RootNode.java b/leaves-server/src/main/java/org/leavesmc/leaves/command/RootNode.java index b2805c6e6..d7eea2309 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/command/RootNode.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/command/RootNode.java @@ -8,9 +8,24 @@ import org.bukkit.command.CommandSender; import org.jetbrains.annotations.NotNull; +import java.util.HashMap; +import java.util.Map; + import static org.leavesmc.leaves.command.CommandUtils.registerPermissions; public abstract class RootNode extends LiteralNode { + + private static final Map> LEAVES_COMMANDS = new HashMap<>(); + + public static void reloadLeavesCommands() { + PaperCommands.INSTANCE.setValid(); + for (Map.Entry> entry : LEAVES_COMMANDS.entrySet()) { + PaperCommands.INSTANCE.getDispatcher().register(entry.getValue()); + } + PaperCommands.INSTANCE.invalidate(); + Bukkit.getOnlinePlayers().forEach(org.bukkit.entity.Player::updateCommands); + } + private final String permissionBase; public RootNode(String name, String permissionBase) { @@ -35,8 +50,10 @@ public boolean requires(@NotNull CommandSourceStack source) { @SuppressWarnings("unchecked") public void register() { + LiteralArgumentBuilder builder = (LiteralArgumentBuilder) compile(); + LEAVES_COMMANDS.put(name, builder); PaperCommands.INSTANCE.setValid(); - PaperCommands.INSTANCE.getDispatcher().register((LiteralArgumentBuilder) compile()); + PaperCommands.INSTANCE.getDispatcher().register(builder); PaperCommands.INSTANCE.invalidate(); Bukkit.getOnlinePlayers().forEach(org.bukkit.entity.Player::updateCommands); } @@ -45,6 +62,7 @@ public void unregister() { PaperCommands.INSTANCE.setValid(); PaperCommands.INSTANCE.getDispatcher().getRoot().removeCommand(name); PaperCommands.INSTANCE.invalidate(); + LEAVES_COMMANDS.remove(name); Bukkit.getOnlinePlayers().forEach(org.bukkit.entity.Player::updateCommands); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/ConfigCommand.java b/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/ConfigCommand.java index 98fb98c42..44024a957 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/ConfigCommand.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/ConfigCommand.java @@ -47,7 +47,7 @@ private BotArgument() { } @Contract(pure = true) - private @NotNull Supplier configNodeCreator(AbstractBotConfig config) { + private @NotNull Supplier configNodeCreator(Configs> config) { return () -> new ConfigNode<>(config); } @@ -59,13 +59,13 @@ private BotArgument() { protected boolean execute(CommandContext context) { ServerBot bot = BotArgument.getBot(context); CommandSender sender = context.getSender(); - Collection> botConfigs = bot.getAllConfigs(); + Collection> botConfigs = bot.getAllConfigs(); sender.sendMessage(join(spaces(), text("Bot", GRAY), asAdventure(bot.getDisplayName()).append(text("'s", GRAY)), text("configs:", GRAY) )); - for (AbstractBotConfig botConfig : botConfigs) { + for (AbstractBotConfig botConfig : botConfigs) { sender.sendMessage(join(spaces(), botConfig.getNameComponent(), text("=", GRAY), @@ -77,16 +77,17 @@ protected boolean execute(CommandContext context) { } private static class ConfigNode extends LiteralNode { - private final AbstractBotConfig config; + private final Configs> config; - private ConfigNode(@NotNull AbstractBotConfig config) { + @SuppressWarnings({"rawtypes", "unchecked"}) + private ConfigNode(@NotNull Configs config) { super(config.getName()); this.config = config; } @Override protected ArgumentBuilder compileBase() { - RequiredArgumentBuilder argument = config.getArgument() + RequiredArgumentBuilder argument = config.create().getArgument() .compile() .executes(mojangCtx -> { CommandContext ctx = new CommandContext(mojangCtx); @@ -98,7 +99,7 @@ private ConfigNode(@NotNull AbstractBotConfig config) { @Override protected boolean execute(@NotNull CommandContext context) { ServerBot bot = BotArgument.getBot(context); - AbstractBotConfig botConfig = bot.getConfig(config); + AbstractBotConfig botConfig = bot.getConfig(config); context.getSender().sendMessage(join(spaces(), text("Bot", GRAY), asAdventure(bot.getDisplayName()).append(text("'s", GRAY)), @@ -112,9 +113,9 @@ protected boolean execute(@NotNull CommandContext context) { private boolean executeSet(CommandContext context) throws CommandSyntaxException { ServerBot bot = BotArgument.getBot(context); - AbstractBotConfig botConfig = bot.getConfig(config); + AbstractBotConfig botConfig = bot.getConfig(config); try { - botConfig.setValue(botConfig.loadFromCommand(context)); + botConfig.setValue(botConfig.parseFromCommand(context)); } catch (ClassCastException e) { throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument().create(); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/ListCommand.java b/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/ListCommand.java index 3464717de..1aaaec688 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/ListCommand.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/ListCommand.java @@ -64,7 +64,7 @@ protected boolean execute(@NotNull CommandContext context) throws CommandSyntaxE .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), diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/LoadCommand.java b/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/LoadCommand.java index e1804ebf9..fa0f65fb2 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/LoadCommand.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/LoadCommand.java @@ -6,6 +6,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder; import io.papermc.paper.command.brigadier.CommandSourceStack; import net.kyori.adventure.text.format.NamedTextColor; +import net.minecraft.nbt.CompoundTag; import org.bukkit.command.CommandSender; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.LeavesConfig; @@ -15,6 +16,7 @@ import org.leavesmc.leaves.command.CommandContext; import org.leavesmc.leaves.command.bot.BotSubcommand; +import java.util.Locale; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -46,7 +48,7 @@ protected boolean execute(@NotNull CommandContext context) throws CommandSyntaxE String botName = context.getArgument(BotNameArgument.class); BotList botList = BotList.INSTANCE; CommandSender sender = context.getSender(); - if (!botList.getManualSavedBotList().contains(botName)) { + if (!botList.getManualSavedBotList().contains(botName.toLowerCase(Locale.ROOT))) { throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.dispatcherUnknownArgument().create(); } if (botList.getBotByName(botName) != null) { @@ -66,13 +68,14 @@ protected boolean execute(@NotNull CommandContext context) throws CommandSyntaxE @Override protected CompletableFuture getSuggestions(CommandContext context, @NotNull SuggestionsBuilder builder) { BotList botList = BotList.INSTANCE; - Set bots = botList.getManualSavedBotList().keySet(); + CompoundTag list = botList.getManualSavedBotList(); + Set bots = list.keySet(); if (bots.isEmpty()) { return builder .suggest("", net.minecraft.network.chat.Component.literal("There are no bots saved before, save one first.")) .buildFuture(); } - bots.forEach(builder::suggest); + bots.forEach(key -> builder.suggest(list.getCompoundOrEmpty(key).getString("name").orElseThrow())); return builder.buildFuture(); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StartCommand.java b/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StartCommand.java index 52c1045f8..1791e2d07 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StartCommand.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StartCommand.java @@ -35,15 +35,15 @@ public StartCommand() { Actions.getAll().stream().map(this::actionNodeCreator).forEach(this::children); } - private boolean handleStartCommand(CommandContext context, @NotNull AbstractBotAction type) throws CommandSyntaxException { + private boolean handleStartCommand(CommandContext context, @NotNull Actions holder) throws CommandSyntaxException { ServerBot bot = getBot(context); CommandSender sender = context.getSender(); - AbstractBotAction action = type.create(); - action.loadCommand(context); + + AbstractBotAction action = holder.createByCommand(context); if (bot.addBotAction(action, sender)) { sender.sendMessage(join(spaces(), text("Action", GRAY), - text(action.getName(), AQUA).hoverEvent(showText(text(action.getActionDataString()))), + text(holder.getName(), AQUA).hoverEvent(showText(text(action.getActionDataString()))), text("has been issued to", GRAY), asAdventure(bot.getDisplayName()) )); @@ -53,25 +53,25 @@ private boolean handleStartCommand(CommandContext context, @NotNull AbstractBotA } @Contract(pure = true) - private @NotNull Supplier actionNodeCreator(AbstractBotAction action) { + private @NotNull Supplier actionNodeCreator(Actions action) { return () -> new ActionLiteralNode(action); } private class ActionLiteralNode extends LiteralNode { - private final AbstractBotAction action; + private final Actions holder; - private ActionLiteralNode(@NotNull AbstractBotAction action) { - super(action.getName()); - this.action = action; + private ActionLiteralNode(@NotNull Actions holder) { + super(holder.getName()); + this.holder = holder; } @Override protected ArgumentBuilder compile() { ArgumentBuilder builder = super.compile(); - Map>>> arguments = action.getArguments(); + Map>>> arguments = holder.create().getArguments(); Command executor = context -> { - if (handleStartCommand(new CommandContext(context), action)) { + if (handleStartCommand(new CommandContext(context), holder)) { return Command.SINGLE_SUCCESS; } else { return 0; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StopCommand.java b/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StopCommand.java index 16d755830..f37e38d85 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StopCommand.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StopCommand.java @@ -124,13 +124,13 @@ protected boolean execute(@NotNull CommandContext context) throws CommandSyntaxE if (canceled.isEmpty()) { sender.sendMessage(join(spaces(), asAdventure(bot.getDisplayName()).append(text("'s", GRAY)), - text("'s action list cleared", GRAY) + text("action list cleared", GRAY) )); } else { sender.sendMessage(join(spaces(), text("Tried to clear", GRAY), asAdventure(bot.getDisplayName()).append(text("'s", GRAY)), - text("'s action list, but following actions' stop was canceled by plugin:", GRAY) + text("action list, but following actions' stop was canceled by plugin:", GRAY) )); for (AbstractBotAction action : canceled) { context.getSender().sendMessage( diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/command/leaves/subcommands/ReportCommand.java b/leaves-server/src/main/java/org/leavesmc/leaves/command/leaves/subcommands/ReportCommand.java index 99984ee26..c439eb67f 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/command/leaves/subcommands/ReportCommand.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/command/leaves/subcommands/ReportCommand.java @@ -98,7 +98,7 @@ protected boolean execute(CommandContext context) { for (final PluginProvider entry : leavesPlugins.values()) { pluginList.append(" ").append(entry.getMeta().getName()).append(","); } - pluginList.deleteCharAt(pluginList.length() - 1); + pluginList.deleteCharAt(pluginList.length() - 1).append("\n"); } if (!paperPlugins.isEmpty()) { @@ -106,7 +106,7 @@ protected boolean execute(CommandContext context) { for (final PluginProvider entry : paperPlugins.values()) { pluginList.append(" ").append(entry.getMeta().getName()).append(","); } - pluginList.deleteCharAt(pluginList.length() - 1); + pluginList.deleteCharAt(pluginList.length() - 1).append("\n"); } if (!spigotPlugins.isEmpty()) { @@ -114,7 +114,7 @@ protected boolean execute(CommandContext context) { for (final PluginProvider entry : spigotPlugins.values()) { pluginList.append(" ").append(entry.getMeta().getAPIVersion() == null ? "*" : "").append(entry.getMeta().getName()).append(","); } - pluginList.deleteCharAt(pluginList.length() - 1); + pluginList.deleteCharAt(pluginList.length() - 1).append("\n"); } return pluginList.toString(); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/entity/bot/CraftBot.java b/leaves-server/src/main/java/org/leavesmc/leaves/entity/bot/CraftBot.java index 97fa23e3f..0abe4a3f5 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/entity/bot/CraftBot.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/entity/bot/CraftBot.java @@ -53,7 +53,7 @@ public void addAction(@NotNull AbstractBotAction action) { @Override public BotAction getAction(int index) { - return (BotAction) this.getHandle().getBotActions().get(index).asCraft(); + return this.getHandle().getBotActions().get(index).asCraft(); } @Override diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/entity/bot/CraftBotManager.java b/leaves-server/src/main/java/org/leavesmc/leaves/entity/bot/CraftBotManager.java index 1fb5f33a5..425058c6c 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/entity/bot/CraftBotManager.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/entity/bot/CraftBotManager.java @@ -9,7 +9,6 @@ import org.leavesmc.leaves.bot.BotList; import org.leavesmc.leaves.bot.ServerBot; import org.leavesmc.leaves.bot.agent.Actions; -import org.leavesmc.leaves.bot.agent.actions.AbstractBotAction; import org.leavesmc.leaves.entity.bot.action.BotAction; import org.leavesmc.leaves.event.bot.BotCreateEvent; @@ -55,7 +54,7 @@ public Collection getBots() { @SuppressWarnings("unchecked") @Override public > T newAction(@NotNull Class type) { - AbstractBotAction action = Actions.getForClass(type); + Actions action = Actions.getByClass(type); if (action == null) { throw new IllegalArgumentException("No action registered for type: " + type.getName()); } else { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/lithium/common/world/chunk/LithiumHashPalette.java b/leaves-server/src/main/java/org/leavesmc/leaves/lithium/common/world/chunk/LithiumHashPalette.java index 105eac4f6..46248ade4 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/lithium/common/world/chunk/LithiumHashPalette.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/lithium/common/world/chunk/LithiumHashPalette.java @@ -1,7 +1,9 @@ -// Gale - Lithium - faster chunk serialization +// Leaves - Leaf - Lithium - faster hash palette package org.leavesmc.leaves.lithium.common.world.chunk; +import ca.spottedleaf.moonrise.patches.fast_palette.FastPalette; +import ca.spottedleaf.moonrise.patches.fast_palette.FastPaletteData; import it.unimi.dsi.fastutil.HashCommon; import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap; import net.minecraft.CrashReport; @@ -10,10 +12,11 @@ import net.minecraft.core.IdMap; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.VarInt; +import net.minecraft.world.level.chunk.HashMapPalette; import net.minecraft.world.level.chunk.MissingPaletteEntryException; import net.minecraft.world.level.chunk.Palette; import net.minecraft.world.level.chunk.PaletteResize; -import org.jetbrains.annotations.NotNull; +import org.jspecify.annotations.NullMarked; import java.util.Arrays; import java.util.List; @@ -25,14 +28,18 @@ * Generally provides better performance over the vanilla {@link net.minecraft.world.level.chunk.HashMapPalette} when calling * {@link LithiumHashPalette#idFor(Object, PaletteResize)} through using a faster backing map and reducing pointer chasing. */ -public class LithiumHashPalette implements Palette { +@NullMarked +public final class LithiumHashPalette extends HashMapPalette implements Palette, FastPalette { private static final int ABSENT_VALUE = -1; + private final int indexBits; + private final Reference2IntOpenHashMap table; private T[] entries; private int size = 0; private LithiumHashPalette(int indexBits, T[] entries, Reference2IntOpenHashMap table, int size) { + super(size, true); this.indexBits = indexBits; this.entries = entries; this.table = table; @@ -49,6 +56,7 @@ public LithiumHashPalette(int bits, List list) { @SuppressWarnings("unchecked") public LithiumHashPalette(int bits) { + super(bits, true); this.indexBits = bits; int capacity = 1 << bits; @@ -58,19 +66,26 @@ public LithiumHashPalette(int bits) { this.table.defaultReturnValue(ABSENT_VALUE); } + // Leaves start - Leaf - Sync moonrise changes + @Override + public T[] moonrise$getRawPalette(final FastPaletteData container) { + return this.entries; + } + // Leaves end - Leaf - Sync moonrise changes + @Override - public int idFor(@NotNull T obj, @NotNull PaletteResize resizeHandler) { + public int idFor(T obj, PaletteResize paletteResize) { int id = this.table.getInt(obj); if (id == ABSENT_VALUE) { - id = this.computeEntry(obj, resizeHandler); + id = this.computeEntry(obj, paletteResize); } return id; } @Override - public boolean maybeHas(@NotNull Predicate predicate) { + public boolean maybeHas(Predicate predicate) { for (int i = 0; i < this.size; ++i) { if (predicate.test(this.entries[i])) { return true; @@ -80,14 +95,14 @@ public boolean maybeHas(@NotNull Predicate predicate) { return false; } - private int computeEntry(T obj, PaletteResize resizeHandler) { + private int computeEntry(T obj, PaletteResize paletteResize) { int id = this.addEntry(obj); if (id >= 1 << this.indexBits) { - if (resizeHandler == null) { + if (paletteResize == null) { throw new IllegalStateException("Cannot grow"); } else { - id = resizeHandler.onResize(this.indexBits + 1, obj); + id = paletteResize.onResize(this.indexBits + 1, obj); } } @@ -114,7 +129,7 @@ private void resize(int neededCapacity) { } @Override - public @NotNull T valueFor(int id) { + public T valueFor(int id) { T[] entries = this.entries; T entry = null; @@ -143,7 +158,7 @@ private ReportedException missingPaletteEntryCrash(int id) { } @Override - public void read(FriendlyByteBuf buf, @NotNull IdMap idMap) { + public void read(FriendlyByteBuf buf, IdMap idMap) { this.clear(); int entryCount = buf.readVarInt(); @@ -154,7 +169,7 @@ public void read(FriendlyByteBuf buf, @NotNull IdMap idMap) { } @Override - public void write(FriendlyByteBuf buf, @NotNull IdMap idMap) { + public void write(FriendlyByteBuf buf, IdMap idMap) { int size = this.size; buf.writeVarInt(size); @@ -164,7 +179,7 @@ public void write(FriendlyByteBuf buf, @NotNull IdMap idMap) { } @Override - public int getSerializedSize(@NotNull IdMap idMap) { + public int getSerializedSize(IdMap idMap) { int size = VarInt.getByteSize(this.size); for (int i = 0; i < this.size; ++i) { @@ -180,7 +195,7 @@ public int getSize() { } @Override - public @NotNull Palette copy() { + public Palette copy() { return new LithiumHashPalette<>(this.indexBits, this.entries.clone(), this.table.clone(), this.size); } @@ -195,6 +210,14 @@ public List getElements() { return Arrays.asList(copy); } + // Leaves start - Leaf - override getEntries + @Override + public List getEntries() { + T[] copy = Arrays.copyOf(this.entries, this.size); + return Arrays.asList(copy); + } + // Leaves end - Leaf - override getEntries + public static Palette create(int bits, List list) { return new LithiumHashPalette<>(bits, list); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/network/AsyncKeepaliveManager.java b/leaves-server/src/main/java/org/leavesmc/leaves/network/AsyncKeepaliveManager.java index a0c26264d..c249daf44 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/network/AsyncKeepaliveManager.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/network/AsyncKeepaliveManager.java @@ -1,8 +1,8 @@ package org.leavesmc.leaves.network; -import net.minecraft.Util; import net.minecraft.network.Connection; import net.minecraft.server.network.ServerCommonPacketListenerImpl; +import net.minecraft.util.Util; import org.leavesmc.leaves.LeavesConfig; import org.leavesmc.leaves.LeavesLogger; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/plugin/MinecraftInternalPlugin.java b/leaves-server/src/main/java/org/leavesmc/leaves/plugin/MinecraftInternalPlugin.java index ab55857fd..8a9bb8bc6 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/plugin/MinecraftInternalPlugin.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/plugin/MinecraftInternalPlugin.java @@ -12,7 +12,6 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginBase; import org.bukkit.plugin.PluginDescriptionFile; -import org.bukkit.plugin.PluginLoader; import org.bukkit.plugin.PluginLogger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -65,8 +64,9 @@ public boolean isEnabled() { return enabled; } + @SuppressWarnings("removal") @Override - public @NotNull PluginLoader getPluginLoader() { + public @NotNull org.bukkit.plugin.PluginLoader getPluginLoader() { throw new UnsupportedOperationException("Not supported."); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java index 0879c96bd..cf7908f87 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java @@ -1,10 +1,10 @@ package org.leavesmc.leaves.protocol; -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.LeavesConfig; @@ -24,9 +24,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; @@ -37,8 +37,8 @@ public class AppleSkinProtocol implements LeavesProtocol { private static final Map> subscribedChannels = new HashMap<>(); @Contract("_ -> new") - public static ResourceLocation id(String path) { - return ResourceLocation.fromNamespaceAndPath(PROTOCOL_ID, path); + public static Identifier id(String path) { + return Identifier.fromNamespaceAndPath(PROTOCOL_ID, path); } @ProtocolHandler.PlayerJoin @@ -53,7 +53,7 @@ public static void onPlayerLoggedOut(@NotNull ServerPlayer player) { } @ProtocolHandler.MinecraftRegister(onlyNamespace = true) - public static void onPlayerSubscribed(@NotNull Context context, ResourceLocation id) { + public static void onPlayerSubscribed(@NotNull Context context, Identifier id) { subscribedChannels.computeIfAbsent(context.profile().id(), k -> new HashSet<>()).add(id.getPath()); } @@ -87,7 +87,7 @@ public static void tick() { } 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/BBORProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/BBORProtocol.java index ec416c19c..b38403d82 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/BBORProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/BBORProtocol.java @@ -4,7 +4,7 @@ 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; @@ -33,19 +33,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 HashMap<>(); - 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.fromNamespaceAndPath(PROTOCOL_ID, path); + public static Identifier id(String path) { + return Identifier.fromNamespaceAndPath(PROTOCOL_ID, path); } @ProtocolHandler.Ticker @@ -97,14 +97,14 @@ public static void onChunkLoaded(@NotNull LevelChunk chunk) { 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(); @@ -136,7 +136,7 @@ public static void onStructuresLoaded(@NotNull ResourceLocation dimensionID, @No 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); @@ -158,7 +158,7 @@ private static void sendBoundingToPlayer(int id, ServerPlayer player) { 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) { @@ -187,7 +187,7 @@ public static void loggedOutAllPlayer() { dimensionCache.clear(); } - private static Map> getOrCreateCache(ResourceLocation dimensionId) { + private static Map> getOrCreateCache(Identifier dimensionId) { return dimensionCache.computeIfAbsent(dimensionId, dt -> new ConcurrentHashMap<>()); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/CarpetServerProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/CarpetServerProtocol.java index 54e27d824..318666db5 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/CarpetServerProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/CarpetServerProtocol.java @@ -4,7 +4,7 @@ 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 net.minecraft.server.level.ServerPlayer; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -16,8 +16,10 @@ import org.leavesmc.leaves.protocol.core.ProtocolUtils; import java.util.HashMap; +import java.util.HashSet; import java.util.Locale; import java.util.Map; +import java.util.Set; @LeavesProtocol.Register(namespace = "carpet") public class CarpetServerProtocol implements LeavesProtocol { @@ -28,9 +30,11 @@ public class CarpetServerProtocol implements LeavesProtocol { private static final String HI = "69"; private static final String HELLO = "420"; + private static final Set activePlayers = new HashSet<>(); + @Contract("_ -> new") - public static ResourceLocation id(String path) { - return ResourceLocation.fromNamespaceAndPath(PROTOCOL_ID, path); + public static Identifier id(String path) { + return Identifier.fromNamespaceAndPath(PROTOCOL_ID, path); } @ProtocolHandler.PlayerJoin @@ -40,14 +44,25 @@ public static void onPlayerJoin(ServerPlayer player) { ProtocolUtils.sendPayloadPacket(player, new CarpetPayload(data)); } + @ProtocolHandler.PlayerLeave + public static void onPlayerLeave(ServerPlayer player) { + activePlayers.remove(player); + } + @ProtocolHandler.PayloadReceiver(payload = CarpetPayload.class) private static void handleHello(@NotNull ServerPlayer player, @NotNull CarpetServerProtocol.CarpetPayload payload) { - if (payload.nbt.contains(HELLO)) { - LeavesLogger.LOGGER.info("Player " + player.getScoreboardName() + " joined with carpet " + payload.nbt.getString(HELLO).orElse("Unknown")); - CompoundTag data = new CompoundTag(); - CarpetRules.write(data); - ProtocolUtils.sendPayloadPacket(player, new CarpetPayload(data)); + if (!payload.nbt.contains(HELLO)) { + return; } + LeavesLogger.LOGGER.info("Player " + player.getScoreboardName() + " joined with carpet " + payload.nbt.getString(HELLO).orElse("Unknown")); + sendServerData(player); + activePlayers.add(player); + } + + private static void sendServerData(ServerPlayer player) { + CompoundTag data = new CompoundTag(); + CarpetRules.write(data); + ProtocolUtils.sendPayloadPacket(player, new CarpetPayload(data)); } @Override @@ -67,7 +82,10 @@ public static void write(@NotNull CompoundTag tag) { } public static void register(CarpetRule rule) { - rules.put(rule.name, rule); + if (!rules.containsKey(rule.name) || !rules.get(rule.name).equals(rule)) { + rules.put(rule.name, rule); + activePlayers.forEach(CarpetServerProtocol::sendServerData); + } } } @@ -102,7 +120,7 @@ public void writeNBT(@NotNull CompoundTag rules) { public record CarpetPayload(CompoundTag nbt) implements LeavesCustomPayload { @ID - private static final ResourceLocation HELLO_ID = CarpetServerProtocol.id("hello"); + private static final Identifier HELLO_ID = CarpetServerProtocol.id("hello"); @Codec private static final StreamCodec CODEC = StreamCodec.composite( diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/PcaSyncProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/PcaSyncProtocol.java index b6b245a9e..7a4b66db3 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/PcaSyncProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/PcaSyncProtocol.java @@ -5,7 +5,7 @@ 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 net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -48,19 +48,19 @@ public class PcaSyncProtocol implements LeavesProtocol { public static final ReentrantLock pairLock = new ReentrantLock(true); // send - private static final ResourceLocation ENABLE_PCA_SYNC_PROTOCOL = id("enable_pca_sync_protocol"); - private static final ResourceLocation DISABLE_PCA_SYNC_PROTOCOL = id("disable_pca_sync_protocol"); + private static final Identifier ENABLE_PCA_SYNC_PROTOCOL = id("enable_pca_sync_protocol"); + private static final Identifier DISABLE_PCA_SYNC_PROTOCOL = id("disable_pca_sync_protocol"); - private static final Map> playerWatchBlockPos = new HashMap<>(); - private static final Map> playerWatchEntity = new HashMap<>(); - private static final Map, Set> blockPosWatchPlayerSet = new HashMap<>(); - private static final Map, Set> entityWatchPlayerSet = new HashMap<>(); - private static final MutablePair ResourceLocationEntityPair = new MutablePair<>(); - private static final MutablePair ResourceLocationBlockPosPair = new MutablePair<>(); + private static final Map> playerWatchBlockPos = new HashMap<>(); + private static final Map> playerWatchEntity = new HashMap<>(); + private static final Map, Set> blockPosWatchPlayerSet = new HashMap<>(); + private static final Map, Set> entityWatchPlayerSet = new HashMap<>(); + private static final MutablePair IdentifierEntityPair = new MutablePair<>(); + private static final MutablePair IdentifierBlockPosPair = new MutablePair<>(); @Contract("_ -> new") - public static ResourceLocation id(String path) { - return ResourceLocation.fromNamespaceAndPath(PROTOCOL_ID, path); + public static Identifier id(String path) { + return Identifier.fromNamespaceAndPath(PROTOCOL_ID, path); } @ProtocolHandler.PlayerJoin @@ -108,7 +108,7 @@ private static void syncBlockEntityHandler(ServerPlayer player, SyncBlockEntityP updateBlockEntity(player, blockEntity); } - Pair pair = new ImmutablePair<>(player.level().dimension().location(), pos); + Pair pair = new ImmutablePair<>(player.level().dimension().identifier(), pos); lock.lock(); playerWatchBlockPos.put(player, pair); if (!blockPosWatchPlayerSet.containsKey(pair)) { @@ -158,7 +158,7 @@ private static void syncEntityHandler(ServerPlayer player, SyncEntityPayload pay } updateEntity(player, entity); - Pair pair = new ImmutablePair<>(entity.level().dimension().location(), entity); + Pair pair = new ImmutablePair<>(entity.level().dimension().identifier(), entity); lock.lock(); playerWatchEntity.put(player, pair); if (!entityWatchPlayerSet.containsKey(pair)) { @@ -190,7 +190,7 @@ public static void disablePcaSyncProtocol(@NotNull ServerPlayer player) { public static void updateEntity(@NotNull ServerPlayer player, @NotNull Entity entity) { CompoundTag nbt = TagUtil.saveEntity(entity); - ProtocolUtils.sendPayloadPacket(player, new UpdateEntityPayload(entity.level().dimension().location(), entity.getId(), nbt)); + ProtocolUtils.sendPayloadPacket(player, new UpdateEntityPayload(entity.level().dimension().identifier(), entity.getId(), nbt)); } public static void updateBlockEntity(@NotNull ServerPlayer player, @NotNull BlockEntity blockEntity) { @@ -200,31 +200,31 @@ public static void updateBlockEntity(@NotNull ServerPlayer player, @NotNull Bloc return; } - ProtocolUtils.sendPayloadPacket(player, new UpdateBlockEntityPayload(world.dimension().location(), blockEntity.getBlockPos(), blockEntity.saveWithoutMetadata(world.registryAccess()))); + ProtocolUtils.sendPayloadPacket(player, new UpdateBlockEntityPayload(world.dimension().identifier(), blockEntity.getBlockPos(), blockEntity.saveWithoutMetadata(world.registryAccess()))); } - private static MutablePair getResourceLocationEntityPair(ResourceLocation ResourceLocation, Entity entity) { + private static MutablePair getIdentifierEntityPair(Identifier Identifier, Entity entity) { pairLock.lock(); - ResourceLocationEntityPair.setLeft(ResourceLocation); - ResourceLocationEntityPair.setRight(entity); + IdentifierEntityPair.setLeft(Identifier); + IdentifierEntityPair.setRight(entity); pairLock.unlock(); - return ResourceLocationEntityPair; + return IdentifierEntityPair; } - private static MutablePair getResourceLocationBlockPosPair(ResourceLocation ResourceLocation, BlockPos pos) { + private static MutablePair getIdentifierBlockPosPair(Identifier Identifier, BlockPos pos) { pairLock.lock(); - ResourceLocationBlockPosPair.setLeft(ResourceLocation); - ResourceLocationBlockPosPair.setRight(pos); + IdentifierBlockPosPair.setLeft(Identifier); + IdentifierBlockPosPair.setRight(pos); pairLock.unlock(); - return ResourceLocationBlockPosPair; + return IdentifierBlockPosPair; } private static @Nullable Set getWatchPlayerList(@NotNull Entity entity) { - return entityWatchPlayerSet.get(getResourceLocationEntityPair(entity.level().dimension().location(), entity)); + return entityWatchPlayerSet.get(getIdentifierEntityPair(entity.level().dimension().identifier(), entity)); } private static @Nullable Set getWatchPlayerList(@NotNull Level world, @NotNull BlockPos blockPos) { - return blockPosWatchPlayerSet.get(getResourceLocationBlockPosPair(world.dimension().location(), blockPos)); + return blockPosWatchPlayerSet.get(getIdentifierBlockPosPair(world.dimension().identifier(), blockPos)); } public static boolean syncEntityToClient(@NotNull Entity entity) { @@ -285,7 +285,7 @@ public static boolean syncBlockEntityToClient(@NotNull BlockEntity blockEntity) private static void clearPlayerWatchEntity(ServerPlayer player) { lock.lock(); - Pair pair = playerWatchEntity.get(player); + Pair pair = playerWatchEntity.get(player); if (pair != null) { Set playerSet = entityWatchPlayerSet.get(pair); playerSet.remove(player); @@ -299,7 +299,7 @@ private static void clearPlayerWatchEntity(ServerPlayer player) { private static void clearPlayerWatchBlock(ServerPlayer player) { lock.lock(); - Pair pair = playerWatchBlockPos.get(player); + Pair pair = playerWatchBlockPos.get(player); if (pair != null) { Set playerSet = blockPosWatchPlayerSet.get(pair); playerSet.remove(player); @@ -340,14 +340,14 @@ public boolean isActive() { return LeavesConfig.protocol.pca.enable; } - public record UpdateEntityPayload(ResourceLocation dimension, int entityId, CompoundTag tag) implements LeavesCustomPayload { + public record UpdateEntityPayload(Identifier dimension, int entityId, CompoundTag tag) implements LeavesCustomPayload { @ID - public static final ResourceLocation UPDATE_ENTITY = PcaSyncProtocol.id("update_entity"); + public static final Identifier UPDATE_ENTITY = PcaSyncProtocol.id("update_entity"); @Codec public static final StreamCodec CODEC = StreamCodec.composite( - ResourceLocation.STREAM_CODEC, + Identifier.STREAM_CODEC, UpdateEntityPayload::dimension, ByteBufCodecs.INT, UpdateEntityPayload::entityId, @@ -357,14 +357,14 @@ public record UpdateEntityPayload(ResourceLocation dimension, int entityId, Comp ); } - public record UpdateBlockEntityPayload(ResourceLocation dimension, BlockPos blockPos, CompoundTag tag) implements LeavesCustomPayload { + public record UpdateBlockEntityPayload(Identifier dimension, BlockPos blockPos, CompoundTag tag) implements LeavesCustomPayload { @ID - private static final ResourceLocation UPDATE_BLOCK_ENTITY = PcaSyncProtocol.id("update_block_entity"); + private static final Identifier UPDATE_BLOCK_ENTITY = PcaSyncProtocol.id("update_block_entity"); @Codec private static final StreamCodec CODEC = StreamCodec.composite( - ResourceLocation.STREAM_CODEC, + Identifier.STREAM_CODEC, UpdateBlockEntityPayload::dimension, BlockPos.STREAM_CODEC, UpdateBlockEntityPayload::blockPos, @@ -376,7 +376,7 @@ public record UpdateBlockEntityPayload(ResourceLocation dimension, BlockPos bloc public record SyncBlockEntityPayload(BlockPos pos) implements LeavesCustomPayload { @ID - public static final ResourceLocation SYNC_BLOCK_ENTITY = PcaSyncProtocol.id("sync_block_entity"); + public static final Identifier SYNC_BLOCK_ENTITY = PcaSyncProtocol.id("sync_block_entity"); @Codec private static final StreamCodec CODEC = StreamCodec.composite( @@ -386,7 +386,7 @@ public record SyncBlockEntityPayload(BlockPos pos) implements LeavesCustomPayloa public record SyncEntityPayload(int entityId) implements LeavesCustomPayload { @ID - public static final ResourceLocation SYNC_ENTITY = PcaSyncProtocol.id("sync_entity"); + public static final Identifier SYNC_ENTITY = PcaSyncProtocol.id("sync_entity"); @Codec private static final StreamCodec CODEC = StreamCodec.composite( diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java index 3c2e6137e..484cf46c9 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java @@ -1,6 +1,6 @@ package org.leavesmc.leaves.protocol; -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; @@ -14,17 +14,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.fromNamespaceAndPath(PROTOCOL_ID_MINI, path); + public static Identifier idMini(String path) { + return Identifier.fromNamespaceAndPath(PROTOCOL_ID_MINI, path); } @Contract("_ -> new") - public static ResourceLocation idWorld(String path) { - return ResourceLocation.fromNamespaceAndPath(PROTOCOL_ID_WORLD, path); + public static Identifier idWorld(String path) { + return Identifier.fromNamespaceAndPath(PROTOCOL_ID_WORLD, path); } public static void onSendWorldInfo(@NotNull ServerPlayer player) { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java index 2c773f2f6..e60bee575 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/bladeren/BladerenProtocol.java @@ -3,7 +3,7 @@ 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 org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; @@ -27,8 +27,8 @@ public class BladerenProtocol implements LeavesProtocol { private static final Map> registeredFeatures = new HashMap<>(); @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.PayloadReceiver(payload = BladerenHelloPayload.class) @@ -108,7 +108,7 @@ public void writeNBT(@NotNull CompoundTag rules) { public record BladerenFeatureModifyPayload(String name, CompoundTag nbt) implements LeavesCustomPayload { @ID - private static final ResourceLocation FEATURE_MODIFY_ID = id("feature_modify"); + private static final Identifier FEATURE_MODIFY_ID = id("feature_modify"); @Codec private static final StreamCodec CODEC = StreamCodec.of( @@ -123,7 +123,7 @@ public record BladerenFeatureModifyPayload(String name, CompoundTag nbt) impleme public record BladerenHelloPayload(String version, CompoundTag nbt) implements LeavesCustomPayload { @ID - private static final ResourceLocation HELLO_ID = id("hello"); + private static final Identifier HELLO_ID = id("hello"); @Codec private static final StreamCodec CODEC = StreamCodec.of( diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java index 9368d188e..dc2fdc0a7 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/bladeren/MsptSyncProtocol.java @@ -1,6 +1,6 @@ package org.leavesmc.leaves.protocol.bladeren; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import org.jetbrains.annotations.Contract; @@ -19,12 +19,12 @@ public class MsptSyncProtocol implements LeavesProtocol { public static final String PROTOCOL_ID = "bladeren"; - private static final ResourceLocation MSPT_SYNC = id("mspt_sync"); + private static final Identifier MSPT_SYNC = id("mspt_sync"); private static final List players = new ArrayList<>(); @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.Init diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/ChatImageProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/ChatImageProtocol.java index 5415b1da6..f7a8e7d59 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/ChatImageProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/ChatImageProtocol.java @@ -1,7 +1,7 @@ package org.leavesmc.leaves.protocol.chatimage; import com.google.gson.Gson; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import org.jetbrains.annotations.Contract; @@ -23,8 +23,8 @@ public class ChatImageProtocol implements LeavesProtocol { public static final Gson gson = new Gson(); @Contract("_ -> new") - public static ResourceLocation id(String path) { - return ResourceLocation.fromNamespaceAndPath(PROTOCOL_ID, path); + public static Identifier id(String path) { + return Identifier.fromNamespaceAndPath(PROTOCOL_ID, path); } @ProtocolHandler.PayloadReceiver(payload = FileChannelPayload.class) diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/DownloadFileChannelPayload.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/DownloadFileChannelPayload.java index fe40ca62e..53e054274 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/DownloadFileChannelPayload.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/DownloadFileChannelPayload.java @@ -3,13 +3,13 @@ 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; public record DownloadFileChannelPayload(String message) implements LeavesCustomPayload { @ID - private static final ResourceLocation ID = ChatImageProtocol.id("download_file_channel"); + private static final Identifier ID = ChatImageProtocol.id("download_file_channel"); @Codec private static final StreamCodec CODEC = StreamCodec.composite( diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/FileChannelPayload.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/FileChannelPayload.java index 8413f6b4c..65adb1f69 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/FileChannelPayload.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/FileChannelPayload.java @@ -3,13 +3,13 @@ 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; public record FileChannelPayload(String message) implements LeavesCustomPayload { @ID - private static final ResourceLocation ID = ChatImageProtocol.id("get_file_channel"); + private static final Identifier ID = ChatImageProtocol.id("get_file_channel"); @Codec private static final StreamCodec CODEC = StreamCodec.composite( diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/FileInfoChannelPayload.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/FileInfoChannelPayload.java index 6c54506f9..c4bc8f380 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/FileInfoChannelPayload.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/FileInfoChannelPayload.java @@ -3,13 +3,13 @@ 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; public record FileInfoChannelPayload(String message) implements LeavesCustomPayload { @ID - private static final ResourceLocation ID = ChatImageProtocol.id("file_info"); + private static final Identifier ID = ChatImageProtocol.id("file_info"); @Codec private static final StreamCodec CODEC = StreamCodec.composite( diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java index 59e4aff49..6b62b2e77 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java @@ -1,7 +1,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; @@ -11,7 +11,7 @@ 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java index 87eb1cf20..96f2824bf 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java @@ -4,7 +4,7 @@ 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.LeavesLogger; import org.leavesmc.leaves.protocol.core.invoker.BytebufReceiverInvokerHolder; @@ -40,9 +40,9 @@ public class LeavesProtocolManager { private static final LeavesLogger LOGGER = LeavesLogger.LOGGER; 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<>(); @@ -70,8 +70,8 @@ public static void init() { } 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)) { @@ -200,7 +200,7 @@ public static void init() { } } - 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; @@ -220,7 +220,7 @@ public static void encode(FriendlyByteBuf buf, LeavesCustomPayload payload) { throw new IllegalArgumentException("Payload " + payload.getClass() + " is not configured correctly " + location + " " + codec); } try { - buf.writeResourceLocation(location); + buf.writeIdentifier(location); codec.encode(ProtocolUtils.decorate(buf), payload); } catch (Exception e) { LOGGER.severe("Failed to encode payload " + location, e); @@ -235,7 +235,7 @@ public static void handlePayload(IdentifierSelector selector, LeavesCustomPayloa } } - 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) { @@ -289,7 +289,7 @@ public static void handleDataPackReload() { } public static void handleMinecraftRegister(String channelId, IdentifierSelector selector) { - ResourceLocation location = ResourceLocation.tryParse(channelId); + Identifier location = Identifier.tryParse(channelId); if (location == null) { return; } @@ -319,7 +319,7 @@ private static void sendKnownId(ServerPlayer player) { 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java index 93b61305c..fb1d55ffe 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java @@ -10,7 +10,7 @@ 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; @@ -32,11 +32,11 @@ public static String buildProtocolVersion(String protocol) { return protocol + "-leaves-" + 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)))); @@ -46,11 +46,11 @@ public static void sendPayloadPacket(ServerPlayer player, CustomPacketPayload pa 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/AbstractInvokerHolder.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/AbstractInvokerHolder.java index b34f54485..56c43207d 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/AbstractInvokerHolder.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/AbstractInvokerHolder.java @@ -60,7 +60,7 @@ protected Object invoke0(boolean force, Object... args) { try { return invoker.invoke(owner, args); } catch (InvocationTargetException e) { - throw new RuntimeException(e.getCause()); + throw new RuntimeException(e.getTargetException()); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/MinecraftRegisterInvokerHolder.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/MinecraftRegisterInvokerHolder.java index 5960042d0..13cb7b802 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/MinecraftRegisterInvokerHolder.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/MinecraftRegisterInvokerHolder.java @@ -1,6 +1,6 @@ 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; @@ -9,10 +9,10 @@ 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); } -} +} \ No newline at end of file diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java index 58f1af9b8..3e07913ff 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java @@ -5,7 +5,7 @@ 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.ServerPlayer; import net.minecraft.util.Mth; @@ -14,12 +14,12 @@ 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; @@ -76,17 +76,17 @@ public class JadeProtocol implements LeavesProtocol { 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.fromNamespaceAndPath(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 diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java index 1620d68f5..9f6e2d734 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java @@ -3,14 +3,14 @@ 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ReceiveDataPayload.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ReceiveDataPayload.java index b2630fca2..ba188aa2f 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ReceiveDataPayload.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ReceiveDataPayload.java @@ -4,14 +4,14 @@ 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java index 8a5be1843..beec5634b 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java @@ -4,7 +4,7 @@ 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; @@ -19,7 +19,7 @@ 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( diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java index 5b0e36602..29eca3326 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java @@ -4,7 +4,7 @@ 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; @@ -19,7 +19,7 @@ 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( diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java index 3a12a8cc7..749488de9 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java @@ -7,7 +7,7 @@ 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; @@ -18,24 +18,24 @@ 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java index b18132f8d..d04ec3fef 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java @@ -2,12 +2,12 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -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; @@ -35,7 +35,7 @@ public enum ItemStorageExtensionProvider implements ServerExtensionProvider> 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 Identifier UNIVERSAL_ITEM_STORAGE = JadeProtocol.mc_id("item_storage.default"); public static ItemCollector createItemCollector(Accessor request) { if (request.getTarget() instanceof AbstractHorse) { @@ -134,7 +134,7 @@ public List> getGroups(Accessor request) { } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return UNIVERSAL_ITEM_STORAGE; } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageProvider.java index 35f13c310..06ccc96b1 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageProvider.java @@ -3,7 +3,7 @@ import net.minecraft.nbt.CompoundTag; 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.LockCode; import net.minecraft.world.RandomizableContainer; import net.minecraft.world.entity.player.Player; @@ -24,9 +24,9 @@ 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; @@ -39,7 +39,7 @@ public static ForEntity getEntity() { 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) { @@ -60,7 +60,7 @@ public static void putData(CompoundTag tag, @NotNull Accessor accessor) { } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return UNIVERSAL_ITEM_STORAGE; } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/JadeProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/JadeProvider.java index b87da56fe..fb070b8be 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/JadeProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/JadeProvider.java @@ -1,10 +1,10 @@ package org.leavesmc.leaves.protocol.jade.provider; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; public interface JadeProvider { - ResourceLocation getUid(); + Identifier getUid(); default int getDefaultPriority() { return 0; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BeehiveProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BeehiveProvider.java index ee92d79bf..b85067ad9 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BeehiveProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BeehiveProvider.java @@ -3,7 +3,7 @@ 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; @@ -13,7 +13,7 @@ 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() { @@ -28,7 +28,7 @@ public Byte streamData(@NotNull BlockAccessor accessor) { } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_BEEHIVE; } } \ No newline at end of file diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BlockNameProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BlockNameProvider.java index 4904ef090..35375d46f 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BlockNameProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BlockNameProvider.java @@ -6,7 +6,7 @@ import net.minecraft.network.chat.ComponentSerialization; import net.minecraft.network.chat.contents.TranslatableContents; import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import net.minecraft.world.MenuProvider; import net.minecraft.world.Nameable; import net.minecraft.world.level.block.ChestBlock; @@ -21,7 +21,7 @@ public enum BlockNameProvider 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 @@ -49,7 +49,7 @@ public StreamCodec streamCodec() { } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return CORE_OBJECT_NAME; } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BrewingStandProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BrewingStandProvider.java index 4266550e0..4d6b9af77 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BrewingStandProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BrewingStandProvider.java @@ -4,7 +4,7 @@ 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.BrewingStandBlockEntity; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.jade.JadeProtocol; @@ -14,7 +14,7 @@ public enum BrewingStandProvider 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) { @@ -28,7 +28,7 @@ public enum BrewingStandProvider implements StreamServerDataProvider { INSTANCE; - 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) { @@ -44,7 +44,7 @@ public enum CampfireProvider implements ServerExtensionProvider { } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_CAMPFIRE; } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java index ad1bcc28c..7a90f4449 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java @@ -2,7 +2,7 @@ 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; @@ -18,7 +18,7 @@ public enum ChiseledBookshelfProvider implements StreamServerDataProvider { INSTANCE; - private static final ResourceLocation MC_CHISELED_BOOKSHELF = JadeProtocol.mc_id("shelf"); + private static final Identifier MC_CHISELED_BOOKSHELF = JadeProtocol.mc_id("shelf"); @Override public @Nullable ItemStack streamData(@NotNull BlockAccessor accessor) { @@ -35,7 +35,7 @@ public StreamCodec streamCodec() { } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_CHISELED_BOOKSHELF; } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/CommandBlockProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/CommandBlockProvider.java index 5f71fadae..b4df42307 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/CommandBlockProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/CommandBlockProvider.java @@ -3,7 +3,7 @@ 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.CommandBlockEntity; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -14,7 +14,7 @@ public enum CommandBlockProvider 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) { @@ -34,7 +34,7 @@ public String streamData(@NotNull BlockAccessor accessor) { } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_COMMAND_BLOCK; } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/FurnaceProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/FurnaceProvider.java index 5e5f2cce5..e3cbf334a 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/FurnaceProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/FurnaceProvider.java @@ -3,7 +3,7 @@ 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.level.block.entity.AbstractFurnaceBlockEntity; import org.jetbrains.annotations.NotNull; @@ -16,7 +16,7 @@ public enum FurnaceProvider 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) { @@ -34,7 +34,7 @@ public StreamCodec streamCodec() { } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_FURNACE; } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/HopperLockProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/HopperLockProvider.java index 2459acd48..1ea649179 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/HopperLockProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/HopperLockProvider.java @@ -3,7 +3,7 @@ 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.state.properties.BlockStateProperties; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.jade.JadeProtocol; @@ -13,7 +13,7 @@ public enum HopperLockProvider 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) { @@ -26,7 +26,7 @@ public Boolean streamData(@NotNull BlockAccessor accessor) { } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_HOPPER_LOCK; } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/JukeboxProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/JukeboxProvider.java index 0b6e224eb..5d60bea67 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/JukeboxProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/JukeboxProvider.java @@ -2,7 +2,7 @@ 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.entity.JukeboxBlockEntity; import org.jetbrains.annotations.NotNull; @@ -13,7 +13,7 @@ public enum JukeboxProvider 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) { @@ -26,7 +26,7 @@ public StreamCodec streamCodec() { } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_JUKEBOX; } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/LecternProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/LecternProvider.java index c363bd616..aa640cbdf 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/LecternProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/LecternProvider.java @@ -2,7 +2,7 @@ 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.entity.LecternBlockEntity; import org.jetbrains.annotations.NotNull; @@ -13,7 +13,7 @@ public enum LecternProvider 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) { @@ -27,7 +27,7 @@ public StreamCodec streamCodec() { @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_LECTERN; } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/MobSpawnerCooldownProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/MobSpawnerCooldownProvider.java index 428295922..b18ec991d 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/MobSpawnerCooldownProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/MobSpawnerCooldownProvider.java @@ -3,7 +3,7 @@ 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.server.level.ServerLevel; import net.minecraft.world.level.block.entity.TrialSpawnerBlockEntity; import net.minecraft.world.level.block.entity.trialspawner.TrialSpawnerStateData; @@ -16,7 +16,7 @@ public enum MobSpawnerCooldownProvider 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) { @@ -36,7 +36,7 @@ public enum MobSpawnerCooldownProvider implements StreamServerDataProvider { 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) { @@ -30,7 +30,7 @@ public void appendServerData(CompoundTag data, @NotNull BlockAccessor accessor) } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_REDSTONE; } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/AnimalOwnerProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/AnimalOwnerProvider.java index ab26adc04..d8b37d131 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/AnimalOwnerProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/AnimalOwnerProvider.java @@ -5,7 +5,7 @@ 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; @@ -24,7 +24,7 @@ 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) { @@ -67,7 +67,7 @@ public static String lookupPlayerName(@Nullable UUID uuid, Services services) { } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_ANIMAL_OWNER; } } \ No newline at end of file diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/MobBreedingProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/MobBreedingProvider.java index 0acba2f97..4502db38b 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/MobBreedingProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/MobBreedingProvider.java @@ -3,7 +3,7 @@ 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; @@ -16,7 +16,7 @@ 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) { @@ -38,7 +38,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) { @@ -37,7 +37,7 @@ public enum MobGrowthProvider implements StreamServerDataProvider { 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) { @@ -36,7 +36,7 @@ public void appendServerData(CompoundTag tag, @NotNull EntityAccessor accessor) } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_NEXT_ENTITY_DROP; } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/PetArmorProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/PetArmorProvider.java index cb8d17369..33fbb3480 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/PetArmorProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/PetArmorProvider.java @@ -2,7 +2,7 @@ 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.entity.Mob; import net.minecraft.world.item.ItemStack; import org.jetbrains.annotations.NotNull; @@ -14,7 +14,7 @@ public enum PetArmorProvider implements StreamServerDataProvider { 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 @@ -29,7 +29,7 @@ public StreamCodec streamCodec() { } @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_PET_ARMOR; } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/StatusEffectsProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/StatusEffectsProvider.java index 74706271c..1349c11a6 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/StatusEffectsProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/StatusEffectsProvider.java @@ -3,7 +3,7 @@ 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.effect.MobEffectInstance; import net.minecraft.world.entity.LivingEntity; import org.jetbrains.annotations.NotNull; @@ -20,7 +20,7 @@ public enum StatusEffectsProvider 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 @@ -39,7 +39,7 @@ public StreamCodec> streamCodec @Override - public ResourceLocation getUid() { + public Identifier getUid() { return MC_POTION_EFFECTS; } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/ZombieVillagerProvider.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/ZombieVillagerProvider.java index b7c9afd29..33858be52 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/ZombieVillagerProvider.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/ZombieVillagerProvider.java @@ -3,8 +3,8 @@ 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.world.entity.monster.ZombieVillager; +import net.minecraft.resources.Identifier; +import net.minecraft.world.entity.monster.zombie.ZombieVillager; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.protocol.jade.JadeProtocol; @@ -14,7 +14,7 @@ public enum ZombieVillagerProvider 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) { @@ -28,7 +28,7 @@ public enum ZombieVillagerProvider implements StreamServerDataProvider Map.Entry>> getServerExtensionData( + public static Map.Entry>> getServerExtensionData( Accessor accessor, WrappedHierarchyLookup> lookup) { for (var provider : lookup.wrappedGet(accessor)) { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java index 63e399a2b..940e33d35 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java @@ -10,7 +10,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Sets; import net.minecraft.core.IdMapper; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.LeavesLogger; import org.leavesmc.leaves.protocol.jade.JadeProtocol; @@ -108,12 +108,12 @@ public void invalidate() { } @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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java index 405afc407..a87956353 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java @@ -2,7 +2,7 @@ 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.JadeProvider; @@ -27,7 +27,7 @@ default IHierarchyLookup cast() { @Nullable IdMapper idMapper(); - default List mappedIds() { + default List mappedIds() { return Streams.stream(Objects.requireNonNull(idMapper())) .map(JadeProvider::getUid) .toList(); @@ -52,7 +52,7 @@ default List get(Object obj) { 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/LootTableMineableCollector.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/LootTableMineableCollector.java index 9c580ab39..9a93f0e18 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/LootTableMineableCollector.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/LootTableMineableCollector.java @@ -1,7 +1,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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java index e66600016..03ae640db 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java @@ -5,7 +5,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.Iterables; 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.LeavesLogger; @@ -105,7 +105,7 @@ public void invalidate() { } @Override - public void loadComplete(PriorityStore priorityStore) { + public void loadComplete(PriorityStore priorityStore) { first.loadComplete(priorityStore); second.loadComplete(priorityStore); if (idMapped) { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java index 56f3e4e29..9630d54c7 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java @@ -4,7 +4,7 @@ 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; @@ -40,9 +40,9 @@ public static StreamCodec> codec(StreamCo 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java index 5c249c682..18297cc77 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java @@ -3,7 +3,7 @@ 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; @@ -84,7 +84,7 @@ public void invalidate() { } @Override - public void loadComplete(PriorityStore priorityStore) { + public void loadComplete(PriorityStore priorityStore) { for (var override : overrides) { override.getLeft().loadComplete(priorityStore); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/PacketTransformer.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/PacketTransformer.java index 7060e23bb..ee825c09a 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/PacketTransformer.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/PacketTransformer.java @@ -6,7 +6,7 @@ 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.leavesmc.leaves.LeavesLogger; @@ -28,13 +28,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(); @@ -105,7 +105,7 @@ public void inbound(ResourceLocation id, RegistryFriendlyByteBuf buf, ServerPlay } } - 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); @@ -135,11 +135,11 @@ public void outbound(ResourceLocation id, RegistryFriendlyByteBuf buf, BiConsume } 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/REIServerProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/REIServerProtocol.java index 52b21c1c6..2d4fed33e 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/REIServerProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/REIServerProtocol.java @@ -4,7 +4,6 @@ import com.google.common.collect.ImmutableMap; 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; @@ -14,10 +13,12 @@ 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.server.permissions.PermissionLevel; 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.*; @@ -64,17 +65,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()); @@ -99,8 +100,8 @@ public static void onRecipeReload() { } @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) { @@ -184,7 +185,7 @@ private static void reloadRecipe(int reiRecipeVer) { } @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")) { @@ -193,7 +194,7 @@ public static void onPlayerSubscribed(@NotNull ServerPlayer player, ResourceLoca } } else if (channel.equals("ci_msg")) { // cheat rei-client into using "delete_item" packet - if (MinecraftServer.getServer().getProfilePermissions(player.nameAndId()) < 1) { + if (!MinecraftServer.getServer().getProfilePermissions(player.nameAndId()).level().isEqualOrHigherThan(PermissionLevel.MODERATORS)) { player.getBukkitEntity().sendOpLevel((byte) 1); } } @@ -219,7 +220,7 @@ public static void handleCreateItem(ServerPlayer player, RegistryFriendlyByteBuf 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())) { @@ -244,7 +245,7 @@ public static void handleCreateItemGrab(ServerPlayer player, RegistryFriendlyByt 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(); @@ -274,7 +275,7 @@ public static void handleCreateItemHotbar(ServerPlayer player, RegistryFriendlyB 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(); @@ -300,10 +301,10 @@ public static void handleCreateItemHotbar(ServerPlayer player, RegistryFriendlyB @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 { @@ -344,7 +345,7 @@ public static void handleMoveItem(ServerPlayer player, RegistryFriendlyByteBuf b 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); @@ -353,7 +354,7 @@ private static void inboundTransform(ServerPlayer player, ResourceLocation id, R } } - 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/BlastingDisplay.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/BlastingDisplay.java index 8a7d00af5..5d34c9e9a 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/BlastingDisplay.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/BlastingDisplay.java @@ -1,18 +1,18 @@ 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CampfireDisplay.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CampfireDisplay.java index a097770b5..1f7674d19 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CampfireDisplay.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CampfireDisplay.java @@ -1,18 +1,18 @@ 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CookingDisplay.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CookingDisplay.java index 0aba2c030..706e47a02 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CookingDisplay.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CookingDisplay.java @@ -3,7 +3,7 @@ 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; @@ -21,7 +21,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, @@ -32,7 +32,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; @@ -42,14 +42,14 @@ public CookingDisplay(RecipeHolder recipe) { 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CraftingDisplay.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CraftingDisplay.java index 069276fd5..443de652a 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CraftingDisplay.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CraftingDisplay.java @@ -1,6 +1,6 @@ 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; @@ -10,7 +10,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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CustomDisplay.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CustomDisplay.java index 7c24bb0ef..beea3c068 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CustomDisplay.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/CustomDisplay.java @@ -3,7 +3,7 @@ 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; @@ -17,18 +17,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); @@ -46,7 +46,7 @@ public CustomDisplay(@NotNull List inputs, @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(); } @@ -61,7 +61,7 @@ public int getHeight() { } @Override - public ResourceLocation getSerializerId() { + public Identifier getSerializerId() { return SERIALIZER_ID; } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/Display.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/Display.java index 10e31d3b5..5886eec41 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/Display.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/Display.java @@ -12,7 +12,7 @@ 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; @@ -56,7 +56,7 @@ */ public abstract class Display { - protected ResourceLocation id; + protected Identifier id; protected List inputs; @@ -64,7 +64,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; @@ -81,7 +81,7 @@ public Display decode(@NotNull RegistryFriendlyByteBuf buffer) { @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); } }; @@ -94,9 +94,9 @@ public static Collection ofTransmuteRecipe(@NotNull RecipeHolder ofTransmuteRecipe(@NotNull RecipeHolder 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) @@ -118,7 +118,7 @@ public static Collection ofTippedArrowRecipe(@NotNull RecipeHolder input = new ArrayList<>(); for (int i = 0; i < 4; i++) { input.add(arrowIngredient); @@ -129,7 +129,7 @@ public static Collection ofTippedArrowRecipe(@NotNull RecipeHolder ofFireworkRocketRecipe(@NotNull RecipeHolder ofMapCloningRecipe(@NotNull RecipeHolder ofSmithingTrimRecipe(@NotNull RecipeHolder getOutputEntries() { 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapedDisplay.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapedDisplay.java index 8f38955cb..abd7222a5 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapedDisplay.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapedDisplay.java @@ -3,7 +3,7 @@ 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; @@ -25,7 +25,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, @@ -33,7 +33,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; @@ -41,13 +41,13 @@ public ShapedDisplay(@NotNull RecipeHolder recipeHolder) { 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())), @@ -58,7 +58,7 @@ public ShapedDisplay(@NotNull ShapedCraftingRecipeDisplay recipeDisplay, Resourc } @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(); } @@ -85,7 +85,7 @@ public int getHeight() { } @Override - public ResourceLocation getSerializerId() { + public Identifier getSerializerId() { return SERIALIZER_ID; } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapelessDisplay.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapelessDisplay.java index f458901a2..fc69deb86 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapelessDisplay.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/ShapelessDisplay.java @@ -3,12 +3,12 @@ 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; import net.minecraft.world.item.crafting.display.ShapelessCraftingRecipeDisplay; -import org.apache.commons.lang.NotImplementedException; +import org.apache.commons.lang3.NotImplementedException; import org.bukkit.craftbukkit.CraftRegistry; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.rei.ingredient.EntryIngredient; @@ -22,16 +22,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); } @@ -39,11 +39,11 @@ public ShapelessDisplay(@NotNull RecipeHolder recipeHolder) { 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())), @@ -52,7 +52,7 @@ public ShapelessDisplay(@NotNull ShapelessCraftingRecipeDisplay recipeDisplay, R } @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(); } @@ -67,7 +67,7 @@ public int getHeight() { } @Override - public ResourceLocation getSerializerId() { + public Identifier getSerializerId() { return SERIALIZER_ID; } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmeltingDisplay.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmeltingDisplay.java index e22a93b06..fb7331091 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmeltingDisplay.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmeltingDisplay.java @@ -1,18 +1,18 @@ 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmithingDisplay.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmithingDisplay.java index 59f5ab5cb..ca44fd6d1 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmithingDisplay.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmithingDisplay.java @@ -6,7 +6,7 @@ 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; @@ -24,12 +24,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; @@ -37,14 +37,14 @@ public SmithingDisplay( @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(); } @@ -53,7 +53,7 @@ public Optional getOptionalType() { } @Override - public ResourceLocation getSerializerId() { + public Identifier getSerializerId() { return SERIALIZER_ID; } @@ -80,14 +80,14 @@ public static class Trimming extends SmithingDisplay { 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; @@ -95,7 +95,7 @@ public Trimming( @NotNull List inputs, @NotNull List outputs, @NotNull SmithingRecipeType type, - @NotNull ResourceLocation location, + @NotNull Identifier location, @NotNull Holder pattern ) { super(inputs, outputs, type, location); @@ -103,12 +103,12 @@ public Trimming( } @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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmokingDisplay.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmokingDisplay.java index b4504d395..b7082a03f 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmokingDisplay.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/SmokingDisplay.java @@ -1,18 +1,18 @@ 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/StoneCuttingDisplay.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/StoneCuttingDisplay.java index 83d34f14a..273de2533 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/StoneCuttingDisplay.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/display/StoneCuttingDisplay.java @@ -3,7 +3,7 @@ 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; @@ -24,14 +24,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); } @@ -39,17 +39,17 @@ public StoneCuttingDisplay(RecipeHolder recipeHolder) { 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/ingredient/EntryIngredient.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/ingredient/EntryIngredient.java index 80d3cdd1c..20e872506 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/ingredient/EntryIngredient.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/rei/ingredient/EntryIngredient.java @@ -6,7 +6,7 @@ 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; @@ -19,7 +19,7 @@ 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 @@ -31,7 +31,7 @@ public EntryIngredient decode(@NotNull RegistryFriendlyByteBuf buffer) { 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxEntityDataProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxEntityDataProtocol.java index 79f480019..1accca79b 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxEntityDataProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxEntityDataProtocol.java @@ -1,14 +1,14 @@ package org.leavesmc.leaves.protocol.servux; 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.level.block.entity.BlockEntity; import org.bukkit.Bukkit; @@ -162,7 +162,7 @@ private static final class Helper { 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxHudDataProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxHudDataProtocol.java index ea1ecaa9b..6196ac8e6 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxHudDataProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxHudDataProtocol.java @@ -11,13 +11,13 @@ 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.LeavesConfig; import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; @@ -122,7 +122,7 @@ public static void refreshRecipeManager(ServerPlayer player) { 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); } @@ -134,7 +134,7 @@ public static void refreshRecipeManager(ServerPlayer player) { 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; } @@ -304,7 +304,7 @@ private static final class Helper { public record HudDataPayload(HudDataPayloadType packetType, CompoundTag nbt, 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxProtocol.java index 3838b95ce..0b1e32354 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxProtocol.java @@ -1,6 +1,6 @@ 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; @@ -13,7 +13,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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxStructuresProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxStructuresProtocol.java index af57e6591..c495f9e92 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxStructuresProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxStructuresProtocol.java @@ -8,7 +8,7 @@ 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; @@ -354,7 +354,7 @@ private static final class Helper { public record StructuresPayload(StructuresPayloadType packetType, CompoundTag nbt, 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/LitematicaSchematic.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/LitematicaSchematic.java index 88b2aebe1..8ca999575 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/LitematicaSchematic.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/LitematicaSchematic.java @@ -10,7 +10,7 @@ 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; @@ -186,11 +186,11 @@ private static Map> readPendingTicksFromNBT(ListT continue; } T target; - ResourceLocation resourceLocation = ResourceLocation.tryParse(tag.getStringOr(tagName, "")); - if (resourceLocation == null) { + Identifier identifier = Identifier.tryParse(tag.getStringOr(tagName, "")); + if (identifier == null) { continue; } - Optional> tReference = registry.get(resourceLocation); + Optional> tReference = registry.get(identifier); if (tReference.isEmpty()) { continue; } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/ServuxLitematicsProtocol.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/ServuxLitematicsProtocol.java index 925a0e96c..42fc93765 100755 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/ServuxLitematicsProtocol.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/ServuxLitematicsProtocol.java @@ -10,7 +10,7 @@ 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; @@ -153,7 +153,7 @@ public static void onEntityRequest(ServerPlayer player, int entityId) { 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; @@ -296,7 +296,7 @@ private static final class Helper { 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/utils/SchematicPlacingUtils.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/utils/SchematicPlacingUtils.java index 1ecd8e590..090bfb13e 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/utils/SchematicPlacingUtils.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/litematics/utils/SchematicPlacingUtils.java @@ -11,7 +11,7 @@ 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/logger/DataLogger.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/logger/DataLogger.java index 29d03ab56..67afa75d0 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/logger/DataLogger.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/servux/logger/DataLogger.java @@ -143,7 +143,7 @@ public CompoundTag getResult(MinecraftServer server) { } try { - nbt.put(world.dimension().location().toString(), MobCapData.CODEC.encodeStart(world.registryAccess().createSerializationContext(NbtOps.INSTANCE), mobCapData).getPartialOrThrow()); + nbt.put(world.dimension().identifier().toString(), MobCapData.CODEC.encodeStart(world.registryAccess().createSerializationContext(NbtOps.INSTANCE), mobCapData).getPartialOrThrow()); } catch (Exception ignored) { } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java index 4e0093970..3c6c3ecf1 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java @@ -5,7 +5,7 @@ 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; @@ -78,7 +78,7 @@ public static void onPacketGet(ServerPlayer player, SyncmaticaPayload payload) { 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) { @@ -97,7 +97,7 @@ public static void onPacket(final @NotNull ExchangeTarget source, final Resource } } - 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); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PacketType.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PacketType.java index 002664304..7f4cef864 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PacketType.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PacketType.java @@ -1,6 +1,6 @@ package org.leavesmc.leaves.protocol.syncmatica; -import net.minecraft.resources.ResourceLocation; +import net.minecraft.resources.Identifier; public enum PacketType { REGISTER_METADATA("register_metadata"), @@ -22,9 +22,9 @@ public enum PacketType { MODIFY_FINISH("modify_finish"), MESSAGE("mesage"); - public final ResourceLocation identifier; + public final Identifier identifier; PacketType(final String id) { - identifier = ResourceLocation.fromNamespaceAndPath(SyncmaticaProtocol.PROTOCOL_ID, id); + identifier = Identifier.fromNamespaceAndPath(SyncmaticaProtocol.PROTOCOL_ID, id); } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java index d161e7365..1b8a09c54 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java @@ -2,17 +2,17 @@ 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java index 3bf1c2796..3a9237f9a 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java @@ -2,7 +2,7 @@ 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.CommunicationManager; import org.leavesmc.leaves.protocol.syncmatica.MessageType; @@ -37,7 +37,7 @@ public DownloadExchange(final ServerPlacement syncmatic, final File downloadFile } @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)) { @@ -47,7 +47,7 @@ public boolean checkPacket(final @NotNull ResourceLocation id, final FriendlyByt } @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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java index 0f45ef7f4..a2d6d26bd 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java @@ -1,14 +1,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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java index b0da7abf0..34217f809 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java @@ -1,7 +1,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; @@ -21,7 +21,7 @@ public ExchangeTarget(final ServerGamePacketListenerImpl client) { 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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java index 45fc01915..34593e273 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java @@ -2,7 +2,7 @@ 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; @@ -15,13 +15,13 @@ protected FeatureExchange(final ExchangeTarget partner) { } @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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java index f7f423c73..bb3a09699 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java @@ -2,7 +2,7 @@ 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.CommunicationManager; import org.leavesmc.leaves.protocol.syncmatica.PacketType; @@ -24,12 +24,12 @@ public ModifyExchangeServer(final UUID placeId, final ExchangeTarget partner) { } @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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java index 065a39942..7a460436b 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java @@ -2,7 +2,7 @@ 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; @@ -28,7 +28,7 @@ public UploadExchange(final ServerPlacement syncmatic, final File uploadFile, fi } @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()); @@ -37,7 +37,7 @@ public boolean checkPacket(final @NotNull ResourceLocation id, final FriendlyByt } @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/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java index cb7aed6c0..0c7221464 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java @@ -2,7 +2,7 @@ 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.CommunicationManager; import org.leavesmc.leaves.protocol.syncmatica.FeatureSet; @@ -19,13 +19,13 @@ public VersionHandshakeServer(final ExchangeTarget partner) { } @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/leaves-server/src/main/java/org/leavesmc/leaves/util/BreakBedrockList.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/BreakBedrockList.java index fb10e783e..34027221a 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/BreakBedrockList.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/BreakBedrockList.java @@ -57,7 +57,7 @@ public static void onPistonBreakBedrock(Level level, BlockPos bedrock) { } } else { if (!MBB.isEmpty()) { - ScoreHolder world = ScoreHolder.forNameOnly("$" + level.dimension().location()); + ScoreHolder world = ScoreHolder.forNameOnly("$" + level.dimension().identifier()); for (Objective objective : MBB) { level.getScoreboard().getOrCreatePlayerScore(world, objective).increment(); level.getScoreboard().getOrCreatePlayerScore(ScoreHolder.forNameOnly("$total"), objective).increment(); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java index 1c335026f..c06a37d4a 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/HopperCounter.java @@ -13,8 +13,8 @@ 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.BlockItem; @@ -244,7 +244,7 @@ public static TextColor guessColor(@NotNull MinecraftServer server, Item item) { return direct; } - ResourceLocation id = registryAccess.lookupOrThrow(Registries.ITEM).getKey(item); + Identifier id = registryAccess.lookupOrThrow(Registries.ITEM).getKey(item); if (id == null) { return null; } @@ -252,7 +252,7 @@ public static TextColor guessColor(@NotNull MinecraftServer server, Item item) { for (Recipe recipe : getRecipesForOutput(server.getRecipeManager(), id, server.overworld())) { for (Ingredient ingredient : recipe.placementInfo().ingredients()) { - Optional> match = ingredient.items().filter(stack -> fromItem(stack.value(), registryAccess) != null).findFirst(); + Optional> match = ingredient.items().filter(stack -> fromItem(stack.value(), registryAccess) != null).findFirst(); if (match.isPresent()) { return fromItem(match.get().value(), registryAccess); } @@ -262,13 +262,13 @@ public static TextColor guessColor(@NotNull MinecraftServer server, Item item) { } @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()); } }); @@ -287,9 +287,9 @@ public static TextColor fromItem(Item item, RegistryAccess registryAccess) { } Block block = null; - final Registry itemRegistry = registryAccess.lookupOrThrow(Registries.ITEM); - final Registry blockRegistry = registryAccess.lookupOrThrow(Registries.BLOCK); - ResourceLocation id = itemRegistry.getKey(item); + final Registry<@NotNull Item> itemRegistry = registryAccess.lookupOrThrow(Registries.ITEM); + final Registry<@NotNull Block> blockRegistry = registryAccess.lookupOrThrow(Registries.BLOCK); + Identifier id = itemRegistry.getKey(item); if (item instanceof BlockItem blockItem) { block = blockItem.getBlock(); } else if (blockRegistry.getOptional(id).isPresent()) { diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/ItemOverstackUtils.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/ItemOverstackUtils.java index 737be4d05..37cfc9366 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/ItemOverstackUtils.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/ItemOverstackUtils.java @@ -1,7 +1,6 @@ package org.leavesmc.leaves.util; -import io.papermc.paper.datacomponent.DataComponentTypes; -import io.papermc.paper.datacomponent.item.ItemEnchantments; +import com.google.common.collect.Iterables; import net.minecraft.core.component.DataComponents; import net.minecraft.nbt.CompoundTag; import net.minecraft.world.entity.item.ItemEntity; @@ -10,19 +9,16 @@ import net.minecraft.world.item.component.CustomData; import net.minecraft.world.item.component.ItemContainerContents; import net.minecraft.world.level.block.ShulkerBoxBlock; -import org.bukkit.enchantments.Enchantment; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.LeavesConfig; import java.util.List; import java.util.Objects; -import java.util.Optional; public class ItemOverstackUtils { private static final List overstackUtils = List.of( - new ShulkerBox(), - new CurseEnchantedBook() + new ShulkerBox() ); public static int getItemStackMaxCount(ItemStack stack) { @@ -63,13 +59,13 @@ public static boolean hasOverstackingItem() { return false; } - public static int getItemStackMaxCountReal(ItemStack stack) { - CompoundTag nbt = Optional.ofNullable(stack.get(DataComponents.CUSTOM_DATA)).orElse(CustomData.EMPTY).copyTag(); + public static int getRealItemStackMaxCount(ItemStack stack) { + CompoundTag nbt = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).copyTag(); return nbt.getInt("Leaves.RealStackSize").orElse(stack.getMaxStackSize()); } public static ItemStack encodeMaxStackSize(ItemStack itemStack) { - int realMaxStackSize = getItemStackMaxCountReal(itemStack); + int realMaxStackSize = getRealItemStackMaxCount(itemStack); int modifiedMaxStackSize = getNetworkMaxCount(itemStack); if (itemStack.getMaxStackSize() != modifiedMaxStackSize) { itemStack.set(DataComponents.MAX_STACK_SIZE, modifiedMaxStackSize); @@ -81,7 +77,7 @@ public static ItemStack encodeMaxStackSize(ItemStack itemStack) { } public static ItemStack decodeMaxStackSize(ItemStack itemStack) { - int realMaxStackSize = getItemStackMaxCountReal(itemStack); + int realMaxStackSize = getRealItemStackMaxCount(itemStack); if (itemStack.getMaxStackSize() != realMaxStackSize) { itemStack.set(DataComponents.MAX_STACK_SIZE, realMaxStackSize); CompoundTag nbt = itemStack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).copyTag(); @@ -97,9 +93,6 @@ public static ItemStack decodeMaxStackSize(ItemStack itemStack) { public static float getItemStackSignalStrength(int maxStackSize, ItemStack itemStack) { float result = (float) itemStack.getCount() / Math.min(maxStackSize, itemStack.getMaxStackSize()); - if (LeavesConfig.modify.oldMC.allowGrindstoneOverstacking && CurseEnchantedBook.isCursedEnchantedBook(itemStack)) { - return result; - } return Math.clamp(result, 0f, 1f); } @@ -122,15 +115,15 @@ default int getMaxClientStackCount(ItemStack stack) { } private static class ShulkerBox implements ItemUtil { - public static boolean shulkerBoxCheck(@NotNull ItemStack stack1, @NotNull ItemStack stack2) { + public static boolean checkItems(@NotNull ItemStack stack1, @NotNull ItemStack stack2) { if (LeavesConfig.modify.shulkerBox.sameNbtStackable) { return Objects.equals(stack1.getComponents(), stack2.getComponents()); } - return shulkerBoxNoItem(stack1) && shulkerBoxNoItem(stack2) && Objects.equals(stack1.getComponents(), stack2.getComponents()); + return isEmpty(stack1) && isEmpty(stack2) && Objects.equals(stack1.getComponents(), stack2.getComponents()); } - public static boolean shulkerBoxNoItem(@NotNull ItemStack stack) { - return stack.getComponents().getOrDefault(DataComponents.CONTAINER, ItemContainerContents.EMPTY).stream().findAny().isEmpty(); + public static boolean isEmpty(@NotNull ItemStack stack) { + return Iterables.isEmpty(stack.getComponents().getOrDefault(DataComponents.CONTAINER, ItemContainerContents.EMPTY).nonEmptyItems()); } @Override @@ -147,7 +140,7 @@ public boolean tryStackItems(ItemEntity self, ItemEntity other) { ItemStack otherStack = other.getItem(); if (selfStack.getItem() == otherStack.getItem() - && shulkerBoxCheck(selfStack, otherStack) + && checkItems(selfStack, otherStack) && selfStack.getCount() != org.leavesmc.leaves.LeavesConfig.modify.shulkerBox.stackableShulkerBoxes) { int amount = Math.min(otherStack.getCount(), org.leavesmc.leaves.LeavesConfig.modify.shulkerBox.stackableShulkerBoxes - selfStack.getCount()); @@ -171,41 +164,10 @@ && shulkerBoxCheck(selfStack, otherStack) @Override public int getMaxServerStackCount(ItemStack stack) { if (stack.getItem() instanceof BlockItem bi && - bi.getBlock() instanceof ShulkerBoxBlock && (LeavesConfig.modify.shulkerBox.sameNbtStackable || shulkerBoxNoItem(stack))) { + bi.getBlock() instanceof ShulkerBoxBlock && (LeavesConfig.modify.shulkerBox.sameNbtStackable || isEmpty(stack))) { return LeavesConfig.modify.shulkerBox.stackableShulkerBoxes; } return -1; } } - - public static class CurseEnchantedBook implements ItemUtil { - public static boolean isCursedEnchantedBook(ItemStack stack) { - ItemEnchantments enchantments = stack.getBukkitStack().getData(DataComponentTypes.STORED_ENCHANTMENTS); - if (enchantments == null || enchantments.enchantments().size() != 1) { - return false; - } - return enchantments.enchantments().containsKey(Enchantment.BINDING_CURSE) || - enchantments.enchantments().containsKey(Enchantment.VANISHING_CURSE); - } - - @Override - public boolean isEnabled() { - return LeavesConfig.modify.oldMC.allowGrindstoneOverstacking; - } - - @Override - public boolean tryStackItems(ItemEntity self, ItemEntity other) { - return false; - } - - @Override - public int getMaxServerStackCount(ItemStack stack) { - return -1; - } - - @Override - public int getMaxClientStackCount(ItemStack stack) { - return isCursedEnchantedBook(stack) ? 2 : -1; - } - } } \ No newline at end of file diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/LeavesUpdateHelper.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/LeavesUpdateHelper.java index e99c1d62f..a966bcbff 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/LeavesUpdateHelper.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/LeavesUpdateHelper.java @@ -7,7 +7,7 @@ import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; import io.papermc.paper.ServerBuildInfo; -import net.minecraft.Util; +import net.minecraft.util.Util; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.LeavesConfig; import org.leavesmc.leaves.LeavesLogger; diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/McTechnicalModeHelper.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/McTechnicalModeHelper.java index de20867bd..1514296e4 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/McTechnicalModeHelper.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/McTechnicalModeHelper.java @@ -1,12 +1,19 @@ package org.leavesmc.leaves.util; import io.papermc.paper.configuration.GlobalConfiguration; +import io.papermc.paper.configuration.WorldConfiguration; +import io.papermc.paper.configuration.type.number.IntOr; import org.leavesmc.leaves.LeavesConfig; +import java.util.ArrayList; +import java.util.List; import java.util.Map; +import java.util.function.Consumer; public class McTechnicalModeHelper { + private static final List> worldConfigModifiers = new ArrayList<>(); + public static void doMcTechnicalModeIf() { if (LeavesConfig.modify.mcTechnicalMode) { doMcTechnicalMode(); @@ -24,5 +31,12 @@ public static void doMcTechnicalMode() { GlobalConfiguration.get().packetLimiter.overrides = Map.of(); GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks = true; GlobalConfiguration.get().scoreboards.saveEmptyScoreboardTeams = true; + worldConfigModifiers.add(config -> config.entities.spawning.maxArrowDespawnInvulnerability = IntOr.Disabled.DISABLED); + } + + public static void onWorldConfigCreate(WorldConfiguration config) { + if (LeavesConfig.modify.mcTechnicalMode) { + worldConfigModifiers.forEach(it -> it.accept(config)); + } } } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/ReturnPortalManager.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/ReturnPortalManager.java index aebed438a..9c06e49ba 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/ReturnPortalManager.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/ReturnPortalManager.java @@ -6,8 +6,8 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; +import net.minecraft.resources.Identifier; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -54,7 +54,7 @@ public static ReturnPortal findReturnPortal(ServerPlayer player, ResourceKey entryFromDim = ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(portal.getString(FROM_DIM).orElseThrow())); + ResourceKey entryFromDim = ResourceKey.create(Registries.DIMENSION, Identifier.parse(portal.getString(FROM_DIM).orElseThrow())); if (entryFromDim == fromDim) { BlockPos portalTrigger = BlockPos.of(portal.getLong(FROM_POS).orElseThrow()); if (portalTrigger.distSqr(fromPos) <= MAX_PORTAL_DISTANCE_SQ) { @@ -77,7 +77,7 @@ public static void storeReturnPortal(ServerPlayer player, ResourceKey fro CompoundTag portalCompound = new CompoundTag(); portalCompound.store(RETURN_PORTAL_UID, UUIDUtil.CODEC, UUID.randomUUID()); - portalCompound.putString(FROM_DIM, String.valueOf(fromDim.location())); + portalCompound.putString(FROM_DIM, String.valueOf(fromDim.identifier())); portalCompound.putLong(FROM_POS, fromPos.asLong()); portalCompound.putLong(TO_POS, toPos.asLong()); portalList.add(portalCompound); diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/ShearsWrenchUtil.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/ShearsWrenchUtil.java index 217d6ceb6..93d2c5d48 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/ShearsWrenchUtil.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/ShearsWrenchUtil.java @@ -1,9 +1,9 @@ package org.leavesmc.leaves.util; -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; @@ -15,10 +15,13 @@ import net.minecraft.world.level.block.state.StateDefinition; import net.minecraft.world.level.block.state.properties.Property; import net.minecraft.world.level.block.state.properties.RailShape; +import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.LeavesConfig; import java.util.List; +import static net.minecraft.world.level.block.Block.UPDATE_KNOWN_SHAPE; + public class ShearsWrenchUtil { public static InteractionResult tryApplyRotate(UseOnContext context, BlockState blockState) { @@ -31,7 +34,7 @@ public static InteractionResult tryApplyRotate(UseOnContext context, BlockState if (context.getPlayer() == null || !context.getPlayer().getItemInHand(invert(context.getHand())).isEmpty()) { return null; } - StateDefinition blockstatelist = block.getStateDefinition(); + StateDefinition<@NotNull Block, @NotNull BlockState> blockstatelist = block.getStateDefinition(); Property iblockstate; if (block instanceof CrafterBlock) { iblockstate = blockstatelist.getProperty("orientation"); @@ -85,7 +88,7 @@ public static InteractionResult tryApplyRotate(UseOnContext context, BlockState } BlockState iblockdata1 = cycleState(blockState, iblockstate, player.isSecondaryUseActive()); - level.setBlock(clickedPos, iblockdata1, 18); + level.setBlock(clickedPos, iblockdata1, Block.UPDATE_CLIENTS | UPDATE_KNOWN_SHAPE); message(player, Component.translatable("item.minecraft.debug_stick.update", iblockstate.getName(), getNameHelper(iblockdata1, iblockstate))); return InteractionResult.CONSUME; } @@ -94,7 +97,7 @@ private static InteractionHand invert(InteractionHand original) { return original == InteractionHand.MAIN_HAND ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND; } - private static > BlockState cycleState(BlockState state, Property property, boolean inverse) { + private static > BlockState cycleState(BlockState state, Property<@NotNull T> property, boolean inverse) { List possibleValues = property.getPossibleValues(); if (possibleValues.getFirst() instanceof RailShape) { boolean isRailBlock = state.getBlock() instanceof RailBlock; @@ -117,7 +120,7 @@ private static void message(Player player, Component message) { ((ServerPlayer) player).sendSystemMessage(message, true); } - private static > String getNameHelper(BlockState state, Property property) { + private static > String getNameHelper(BlockState state, Property<@NotNull T> property) { return property.getName(state.getValue(property)); } } \ No newline at end of file diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/util/UpdateSuppressionException.java b/leaves-server/src/main/java/org/leavesmc/leaves/util/UpdateSuppressionException.java index 759c1efe7..09a1518d5 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/util/UpdateSuppressionException.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/util/UpdateSuppressionException.java @@ -98,7 +98,7 @@ public String getMessage() { 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())); } if (player != null) { if (player instanceof ServerBot) { diff --git a/scripts/ShiftPatches.sh b/scripts/ShiftPatches.sh new file mode 100644 index 000000000..b1bc2ecc2 --- /dev/null +++ b/scripts/ShiftPatches.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +if [ $# -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +shift_by="$1" + +for f in *.patch; do + [ -e "$f" ] || continue + + num=$(printf '%s\n' "$f" | sed -n 's/^\([0-9]\+\).*/\1/p') + [ -n "$num" ] || continue + + rest=${f#$num} + + new_num=$((10#$num + shift_by)) + + if [ "$new_num" -lt 0 ]; then + echo "Skipping $f (resulting number < 0)" + continue + fi + + width=${#num} + new_num_fmt=$(printf "%0*d" "$width" "$new_num") + + mv -- "$f" "$new_num_fmt$rest" +done