diff --git a/build-data/leaf.at b/build-data/leaf.at index ff42ee40..34938c58 100644 --- a/build-data/leaf.at +++ b/build-data/leaf.at @@ -28,5 +28,6 @@ public net.minecraft.world.level.chunk.storage.RegionFile write(Lnet/minecraft/w public net.minecraft.world.level.levelgen.structure.PoolElementStructurePiece LOGGER public net.minecraft.world.level.material.FlowingFluid canHoldAnyFluid(Lnet/minecraft/world/level/block/state/BlockState;)Z public net.minecraft.world.level.pathfinder.SwimNodeEvaluator allowBreaching +public-f net.minecraft.server.level.ServerPlayer gameMode public-f net.minecraft.world.entity.EntityType dimensions public-f net.minecraft.world.level.block.state.BlockBehaviour explosionResistance diff --git a/leaf-api/paper-patches/features/0018-Leaves-Replay-Mod-API.patch b/leaf-api/paper-patches/features/0018-Leaves-Replay-Mod-API.patch new file mode 100644 index 00000000..ae56bc5a --- /dev/null +++ b/leaf-api/paper-patches/features/0018-Leaves-Replay-Mod-API.patch @@ -0,0 +1,40 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Thu, 3 Aug 2023 20:36:38 +0800 +Subject: [PATCH] Leaves: Replay Mod API + +Co-authored-by: alazeprt + +Original license: GPLv3 +Original project: https://github.com/LeavesMC/Leaves + +This patch is Powered by ReplayMod(https://github.com/ReplayMod) + +diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java +index 98cfd68226494dbb1a2eaa6680e23a76c2129a62..0f8a1b82dc9d3f4911a0aaa092ef06388ace5108 100644 +--- a/src/main/java/org/bukkit/Bukkit.java ++++ b/src/main/java/org/bukkit/Bukkit.java +@@ -3202,4 +3202,10 @@ public final class Bukkit { + server.clearBlockHighlights(); + } + // Purpur end - Debug Marker API ++ ++ // Leaves start - Photographer API ++ public static @NotNull org.leavesmc.leaves.entity.PhotographerManager getPhotographerManager() { ++ return server.getPhotographerManager(); ++ } ++ // Leaves end - Photographer API + } +diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java +index 002c998368dea33872d65beb79eb4931ce1158d2..b11bd139e2ca7015207145c022b5822e184d8fd0 100644 +--- a/src/main/java/org/bukkit/Server.java ++++ b/src/main/java/org/bukkit/Server.java +@@ -2930,4 +2930,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi + */ + void clearBlockHighlights(); + // Purpur end - Debug Marker API ++ ++ // Leaves start - Photographer API ++ @NotNull org.leavesmc.leaves.entity.PhotographerManager getPhotographerManager(); ++ // Leaves end - Photographer API + } diff --git a/leaf-api/paper-patches/features/0018-Async-structure-locate-api.patch b/leaf-api/paper-patches/features/0019-Async-structure-locate-api.patch similarity index 100% rename from leaf-api/paper-patches/features/0018-Async-structure-locate-api.patch rename to leaf-api/paper-patches/features/0019-Async-structure-locate-api.patch diff --git a/leaf-api/paper-patches/features/0019-PlayerInventoryOverflowEvent.patch b/leaf-api/paper-patches/features/0020-PlayerInventoryOverflowEvent.patch similarity index 100% rename from leaf-api/paper-patches/features/0019-PlayerInventoryOverflowEvent.patch rename to leaf-api/paper-patches/features/0020-PlayerInventoryOverflowEvent.patch diff --git a/leaf-api/paper-patches/features/0020-Raytrace-AntiXray-SDK-integration.patch b/leaf-api/paper-patches/features/0021-Raytrace-AntiXray-SDK-integration.patch similarity index 100% rename from leaf-api/paper-patches/features/0020-Raytrace-AntiXray-SDK-integration.patch rename to leaf-api/paper-patches/features/0021-Raytrace-AntiXray-SDK-integration.patch diff --git a/leaf-api/src/main/java/org/leavesmc/leaves/entity/Photographer.java b/leaf-api/src/main/java/org/leavesmc/leaves/entity/Photographer.java new file mode 100644 index 00000000..6cc611c7 --- /dev/null +++ b/leaf-api/src/main/java/org/leavesmc/leaves/entity/Photographer.java @@ -0,0 +1,26 @@ +package org.leavesmc.leaves.entity; + +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.io.File; + +public interface Photographer extends Player { + + @NotNull String getId(); + + void setRecordFile(@NotNull File file); + + void stopRecording(); + + void stopRecording(boolean async); + + void stopRecording(boolean async, boolean save); + + void pauseRecording(); + + void resumeRecording(); + + void setFollowPlayer(@Nullable Player player); +} diff --git a/leaf-api/src/main/java/org/leavesmc/leaves/entity/PhotographerManager.java b/leaf-api/src/main/java/org/leavesmc/leaves/entity/PhotographerManager.java new file mode 100644 index 00000000..4a2b67f1 --- /dev/null +++ b/leaf-api/src/main/java/org/leavesmc/leaves/entity/PhotographerManager.java @@ -0,0 +1,27 @@ +package org.leavesmc.leaves.entity; + +import org.bukkit.Location; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.leavesmc.leaves.replay.BukkitRecorderOption; + +import java.util.Collection; +import java.util.UUID; + +public interface PhotographerManager { + @Nullable Photographer getPhotographer(@NotNull UUID uuid); + + @Nullable Photographer getPhotographer(@NotNull String id); + + @Nullable Photographer createPhotographer(@NotNull String id, @NotNull Location location); + + @Nullable Photographer createPhotographer(@NotNull String id, @NotNull Location location, @NotNull BukkitRecorderOption recorderOption); + + void removePhotographer(@NotNull String id); + + void removePhotographer(@NotNull UUID uuid); + + void removeAllPhotographers(); + + Collection getPhotographers(); +} diff --git a/leaf-api/src/main/java/org/leavesmc/leaves/replay/BukkitRecorderOption.java b/leaf-api/src/main/java/org/leavesmc/leaves/replay/BukkitRecorderOption.java new file mode 100644 index 00000000..5ea6cb1d --- /dev/null +++ b/leaf-api/src/main/java/org/leavesmc/leaves/replay/BukkitRecorderOption.java @@ -0,0 +1,18 @@ +package org.leavesmc.leaves.replay; + +public class BukkitRecorderOption { + + // public int recordDistance = -1; + public String serverName = "Leaf"; + public BukkitRecordWeather forceWeather = BukkitRecordWeather.NULL; + public int forceDayTime = -1; + public boolean ignoreChat = false; + // public boolean ignoreItem = false; + + public enum BukkitRecordWeather { + CLEAR, + RAIN, + THUNDER, + NULL + } +} diff --git a/leaf-archived-patches/unapplied/api/paper-patches/features/0009-Leaves-Replay-Mod-API.patch b/leaf-archived-patches/unapplied/api/paper-patches/features/0009-Leaves-Replay-Mod-API.patch deleted file mode 100644 index 0b9eac30..00000000 --- a/leaf-archived-patches/unapplied/api/paper-patches/features/0009-Leaves-Replay-Mod-API.patch +++ /dev/null @@ -1,138 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Thu, 3 Aug 2023 20:36:38 +0800 -Subject: [PATCH] Leaves: Replay Mod API - -Co-authored-by: alazeprt - -Original license: GPLv3 -Original project: https://github.com/LeavesMC/Leaves - -This patch is Powered by ReplayMod(https://github.com/ReplayMod) - -diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java -index f4e1c330b6e23ac9edde5c5644a0a41bdfde81f9..917b7cbd7647fccd9bdd70544bb0e5b6532045a7 100644 ---- a/src/main/java/org/bukkit/Bukkit.java -+++ b/src/main/java/org/bukkit/Bukkit.java -@@ -3191,4 +3191,10 @@ public final class Bukkit { - server.clearBlockHighlights(); - } - // Purpur end - Debug Marker API -+ -+ // Leaves start - Photographer API -+ public static @NotNull org.leavesmc.leaves.entity.PhotographerManager getPhotographerManager() { -+ return server.getPhotographerManager(); -+ } -+ // Leaves end - Photographer API - } -diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java -index 50984d397d9ff98e82d02efc166aba61f645e491..a1b76899a416b997c6844bcaf837219ce0726496 100644 ---- a/src/main/java/org/bukkit/Server.java -+++ b/src/main/java/org/bukkit/Server.java -@@ -2902,4 +2902,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi - */ - void clearBlockHighlights(); - // Purpur end - Debug Marker API -+ -+ // Leaves start - Photographer API -+ @NotNull org.leavesmc.leaves.entity.PhotographerManager getPhotographerManager(); -+ // Leaves end - Photographer API - } -diff --git a/src/main/java/org/leavesmc/leaves/entity/Photographer.java b/src/main/java/org/leavesmc/leaves/entity/Photographer.java -new file mode 100644 -index 0000000000000000000000000000000000000000..5b564dfd8aa882d0dc8b1833a4b46e1bba699876 ---- /dev/null -+++ b/src/main/java/org/leavesmc/leaves/entity/Photographer.java -@@ -0,0 +1,27 @@ -+package org.leavesmc.leaves.entity; -+ -+import org.bukkit.entity.Player; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+ -+import java.io.File; -+ -+public interface Photographer extends Player { -+ -+ @NotNull -+ public String getId(); -+ -+ public void setRecordFile(@NotNull File file); -+ -+ public void stopRecording(); -+ -+ public void stopRecording(boolean async); -+ -+ public void stopRecording(boolean async, boolean save); -+ -+ public void pauseRecording(); -+ -+ public void resumeRecording(); -+ -+ public void setFollowPlayer(@Nullable Player player); -+} -\ No newline at end of file -diff --git a/src/main/java/org/leavesmc/leaves/entity/PhotographerManager.java b/src/main/java/org/leavesmc/leaves/entity/PhotographerManager.java -new file mode 100644 -index 0000000000000000000000000000000000000000..ccb19e75748803eb9ad356ffcd0ccfd5145ed776 ---- /dev/null -+++ b/src/main/java/org/leavesmc/leaves/entity/PhotographerManager.java -@@ -0,0 +1,32 @@ -+package org.leavesmc.leaves.entity; -+ -+import org.bukkit.Location; -+import org.bukkit.util.Consumer; -+import org.jetbrains.annotations.NotNull; -+import org.jetbrains.annotations.Nullable; -+import org.leavesmc.leaves.replay.BukkitRecorderOption; -+ -+import java.util.Collection; -+import java.util.UUID; -+ -+public interface PhotographerManager { -+ @Nullable -+ public Photographer getPhotographer(@NotNull UUID uuid); -+ -+ @Nullable -+ public Photographer getPhotographer(@NotNull String id); -+ -+ @Nullable -+ public Photographer createPhotographer(@NotNull String id, @NotNull Location location); -+ -+ @Nullable -+ public Photographer createPhotographer(@NotNull String id, @NotNull Location location, @NotNull BukkitRecorderOption recorderOption); -+ -+ public void removePhotographer(@NotNull String id); -+ -+ public void removePhotographer(@NotNull UUID uuid); -+ -+ public void removeAllPhotographers(); -+ -+ public Collection getPhotographers(); -+} -\ No newline at end of file -diff --git a/src/main/java/org/leavesmc/leaves/replay/BukkitRecorderOption.java b/src/main/java/org/leavesmc/leaves/replay/BukkitRecorderOption.java -new file mode 100644 -index 0000000000000000000000000000000000000000..c985721bdf6be0b8a154e7abfd50e0168965a8d1 ---- /dev/null -+++ b/src/main/java/org/leavesmc/leaves/replay/BukkitRecorderOption.java -@@ -0,0 +1,18 @@ -+package org.leavesmc.leaves.replay; -+ -+public class BukkitRecorderOption { -+ -+ // public int recordDistance = -1; -+ public String serverName = "Leaf"; -+ public BukkitRecordWeather forceWeather = BukkitRecordWeather.NULL; -+ public int forceDayTime = -1; -+ public boolean ignoreChat = false; -+ // public boolean ignoreItem = false; -+ -+ public enum BukkitRecordWeather { -+ CLEAR, -+ RAIN, -+ THUNDER, -+ NULL -+ } -+} -\ No newline at end of file diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0021-Leaves-Protocol-Core.patch b/leaf-archived-patches/unapplied/server/minecraft-patches/features/0021-Leaves-Protocol-Core.patch deleted file mode 100644 index 8dfbf88a..00000000 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0021-Leaves-Protocol-Core.patch +++ /dev/null @@ -1,100 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: violetc <58360096+s-yh-china@users.noreply.github.com> -Date: Tue, 26 Sep 2023 19:00:41 +0800 -Subject: [PATCH] Leaves: Protocol Core - -TODO: Check whether Leaves's Return-nether-portal-fix.patch improves performance -and change store way to sql maybe? - -Original license: GPLv3 -Original project: https://github.com/LeavesMC/Leaves - -Commit: 99b3aafce1f162c68a771fe56d77f33648636b7d - -diff --git a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java -index fb263fa1f30a7dfcb7ec2656abfb38e5fe88eac9..7e19dfe90a63ff26f03b95891dacb7360bba5a3c 100644 ---- a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java -+++ b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java -@@ -40,13 +40,23 @@ public interface CustomPacketPayload { - - @Override - public void encode(B buffer, CustomPacketPayload value) { -+ // Leaves start - protocol core -+ if (value instanceof org.leavesmc.leaves.protocol.core.LeavesCustomPayload payload) { -+ buffer.writeResourceLocation(payload.id()); -+ payload.write(buffer); -+ return; -+ } -+ // Leaves end - protocol core - this.writeCap(buffer, value.type(), value); - } - - @Override - public CustomPacketPayload decode(B buffer) { - ResourceLocation resourceLocation = buffer.readResourceLocation(); -- return (CustomPacketPayload)this.findCodec(resourceLocation).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)); -+ // Leaves end - protocol core - } - }; - } -diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 047a09cf4a2c32e714aacedeccb0928ef2c7dfa9..dddbb18992348fb7e8a6552423d134809cd7fdbc 100644 ---- a/net/minecraft/server/MinecraftServer.java -+++ b/net/minecraft/server/MinecraftServer.java -@@ -1747,6 +1747,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop leavesPayload) { -+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePayload(player, leavesPayload); -+ } -+ // Leaves end - protocol - // Paper start - if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.BrandPayload(String brand)) { - this.player.clientBrandName = brand; -@@ -210,6 +215,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack - final String channel = new String(data, from, length, java.nio.charset.StandardCharsets.US_ASCII); - if (register) { - this.getCraftPlayer().addChannel(channel); -+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handleMinecraftRegister(channel, player); // Leaves - protocol - } else { - this.getCraftPlayer().removeChannel(channel); - } -diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 9a2f2dc1eb471776de6049590cb16e8a061aa24e..e0dbafdbf36ab8597827ac7a828981013ec16bde 100644 ---- a/net/minecraft/server/players/PlayerList.java -+++ b/net/minecraft/server/players/PlayerList.java -@@ -341,6 +341,8 @@ public abstract class PlayerList { - - player.didPlayerJoinEvent = true; // Gale - EMC - do not process chat/commands before player has joined - -+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerJoin(player); // Leaves - protocol -+ - final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); - - if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure -@@ -518,6 +520,7 @@ public abstract class PlayerList { - return this.remove(player, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? player.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName()))); - } - public net.kyori.adventure.text.Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) { -+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerLeave(player); // Leaves - protocol - // Paper end - Fix kick event leave message not being sent - org.purpurmc.purpur.task.BossBarTask.removeFromAll(player.getBukkitEntity()); // Purpur - Implement TPSBar - ServerLevel serverLevel = player.serverLevel(); diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java b/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java deleted file mode 100644 index b09a7bfe..00000000 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.leavesmc.leaves.protocol.core; - -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.protocol.common.custom.CustomPacketPayload; -import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.NotNull; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -public interface LeavesCustomPayload> extends CustomPacketPayload { - - @Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) - @Retention(RetentionPolicy.RUNTIME) - @interface New { - } - - void write(FriendlyByteBuf buf); - - ResourceLocation id(); - - @Override - @NotNull - default Type type() { - return new CustomPacketPayload.Type<>(id()); - } -} diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocol.java b/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocol.java deleted file mode 100644 index 986d2a66..00000000 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocol.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.leavesmc.leaves.protocol.core; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface LeavesProtocol { - String[] namespace(); -} diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java deleted file mode 100644 index c3c86b0b..00000000 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java +++ /dev/null @@ -1,379 +0,0 @@ -package org.leavesmc.leaves.protocol.core; - -import com.google.common.collect.ImmutableSet; -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.server.level.ServerPlayer; -import org.apache.commons.lang.ArrayUtils; -import org.bukkit.event.player.PlayerKickEvent; -import org.jetbrains.annotations.NotNull; -import org.leavesmc.leaves.LeavesLogger; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Executable; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -public class LeavesProtocolManager { - - private static final Class[] PAYLOAD_PARAMETER_TYPES = {ResourceLocation.class, FriendlyByteBuf.class}; - - private static final LeavesLogger LOGGER = LeavesLogger.LOGGER; - - private static final Map> KNOWN_TYPES = new HashMap<>(); - private static final Map> KNOW_RECEIVERS = new HashMap<>(); - private static Set ALL_KNOWN_ID = new HashSet<>(); - - private static final List TICKERS = new ArrayList<>(); - private static final List PLAYER_JOIN = new ArrayList<>(); - private static final List PLAYER_LEAVE = new ArrayList<>(); - private static final List RELOAD_SERVER = new ArrayList<>(); - private static final Map> MINECRAFT_REGISTER = new HashMap<>(); - - public static void reload() { - handleServerReload(); - cleanProtocols(); // Do cleanup - init(); - } - - public static void init() { - boolean shouldEnable; - - for (Class clazz : org.dreeam.leaf.config.LeafConfig.getClasses("org.leavesmc.leaves.protocol")) { - final LeavesProtocol protocol = clazz.getAnnotation(LeavesProtocol.class); - if (protocol != null) { - Set methods; - try { - Method[] publicMethods = clazz.getMethods(); - Method[] privateMethods = clazz.getDeclaredMethods(); - methods = new HashSet<>(publicMethods.length + privateMethods.length, 1.0f); - Collections.addAll(methods, publicMethods); - Collections.addAll(methods, privateMethods); - - Object instance = clazz.getConstructor().newInstance(); - Method method = clazz.getMethod("shouldEnable"); - shouldEnable = (boolean) method.invoke(instance); - } catch (NoClassDefFoundError | InvocationTargetException | InstantiationException | - IllegalAccessException | NoSuchMethodException error) { - LOGGER.severe("Failed to load class " + clazz.getName() + " due to missing dependencies, " + error.getCause() + ": " + error.getMessage()); - return; - } - - Map map = KNOWN_TYPES.getOrDefault(protocol, new HashMap<>()); - for (final Method method : methods) { - if (method.isBridge() || method.isSynthetic() || !Modifier.isStatic(method.getModifiers())) { - continue; - } - - method.setAccessible(true); - - final ProtocolHandler.ReloadServer reloadServer = method.getAnnotation(ProtocolHandler.ReloadServer.class); - if (reloadServer != null) { - RELOAD_SERVER.add(method); - continue; - } - - if (!shouldEnable) { - continue; - } - - final ProtocolHandler.Init init = method.getAnnotation(ProtocolHandler.Init.class); - if (init != null) { - try { - method.invoke(null); - } catch (InvocationTargetException | IllegalAccessException exception) { - LOGGER.severe("Failed to invoke init method " + method.getName() + " in " + clazz.getName() + ", " + exception.getCause() + ": " + exception.getMessage()); - } - continue; - } - - final ProtocolHandler.PayloadReceiver receiver = method.getAnnotation(ProtocolHandler.PayloadReceiver.class); - if (receiver != null) { - try { - boolean found = false; - for (Method payloadMethod : receiver.payload().getDeclaredMethods()) { - if (payloadMethod.isAnnotationPresent(LeavesCustomPayload.New.class)) { - if (Arrays.equals(payloadMethod.getParameterTypes(), PAYLOAD_PARAMETER_TYPES) && payloadMethod.getReturnType() == receiver.payload() && Modifier.isStatic(payloadMethod.getModifiers())) { - payloadMethod.setAccessible(true); - map.put(receiver, payloadMethod); - found = true; - break; - } - } - } - - if (!found) { - Constructor> constructor = receiver.payload().getConstructor(PAYLOAD_PARAMETER_TYPES); - if (constructor.isAnnotationPresent(LeavesCustomPayload.New.class)) { - constructor.setAccessible(true); - map.put(receiver, constructor); - } else { - throw new NoSuchMethodException(); - } - } - } catch (NoSuchMethodException exception) { - LOGGER.severe("Failed to find constructor for " + receiver.payload().getName() + ", " + exception.getCause() + ": " + exception.getMessage()); - continue; - } - - if (!KNOW_RECEIVERS.containsKey(protocol)) { - KNOW_RECEIVERS.put(protocol, new HashMap<>()); - } - - KNOW_RECEIVERS.get(protocol).put(receiver, method); - continue; - } - - final ProtocolHandler.Ticker ticker = method.getAnnotation(ProtocolHandler.Ticker.class); - if (ticker != null) { - TICKERS.add(method); - continue; - } - - final ProtocolHandler.PlayerJoin playerJoin = method.getAnnotation(ProtocolHandler.PlayerJoin.class); - if (playerJoin != null) { - PLAYER_JOIN.add(method); - continue; - } - - final ProtocolHandler.PlayerLeave playerLeave = method.getAnnotation(ProtocolHandler.PlayerLeave.class); - if (playerLeave != null) { - PLAYER_LEAVE.add(method); - continue; - } - - final ProtocolHandler.MinecraftRegister minecraftRegister = method.getAnnotation(ProtocolHandler.MinecraftRegister.class); - if (minecraftRegister != null) { - if (!MINECRAFT_REGISTER.containsKey(protocol)) { - MINECRAFT_REGISTER.put(protocol, new HashMap<>()); - } - - MINECRAFT_REGISTER.get(protocol).put(minecraftRegister, method); - } - } - KNOWN_TYPES.put(protocol, map); - } - } - - for (LeavesProtocol protocol : KNOWN_TYPES.keySet()) { - Map map = KNOWN_TYPES.get(protocol); - for (ProtocolHandler.PayloadReceiver receiver : map.keySet()) { - if (receiver.sendFabricRegister() && !receiver.ignoreId()) { - for (String payloadId : receiver.payloadId()) { - for (String namespace : protocol.namespace()) { - ALL_KNOWN_ID.add(ResourceLocation.tryBuild(namespace, payloadId)); - } - } - } - } - } - ALL_KNOWN_ID = ImmutableSet.copyOf(ALL_KNOWN_ID); - } - - private static void cleanProtocols() { - KNOWN_TYPES.clear(); - KNOW_RECEIVERS.clear(); - //ALL_KNOWN_ID.clear(); // No need - TICKERS.clear(); - PLAYER_JOIN.clear(); - PLAYER_LEAVE.clear(); - //RELOAD_SERVER.clear(); // No need - MINECRAFT_REGISTER.clear(); - } - - public static LeavesCustomPayload decode(ResourceLocation id, FriendlyByteBuf buf) { - for (LeavesProtocol protocol : KNOWN_TYPES.keySet()) { - if (!ArrayUtils.contains(protocol.namespace(), id.getNamespace())) { - continue; - } - - Map map = KNOWN_TYPES.get(protocol); - for (ProtocolHandler.PayloadReceiver receiver : map.keySet()) { - if (receiver.ignoreId() || ArrayUtils.contains(receiver.payloadId(), id.getPath())) { - try { - if (map.get(receiver) instanceof Constructor constructor) { - return (LeavesCustomPayload) constructor.newInstance(id, buf); - } else if (map.get(receiver) instanceof Method method) { - return (LeavesCustomPayload) method.invoke(null, id, buf); - } - } catch (InvocationTargetException | InstantiationException | IllegalAccessException exception) { - LOGGER.warning("Failed to create payload for " + id + " in " + ArrayUtils.toString(protocol.namespace()) + ", " + exception.getCause() + ": " + exception.getMessage()); - buf.readBytes(buf.readableBytes()); - return new ErrorPayload(id, protocol.namespace(), receiver.payloadId()); - } - } - } - } - return null; - } - - public static void handlePayload(ServerPlayer player, LeavesCustomPayload payload) { - if (payload instanceof ErrorPayload errorPayload) { - player.connection.disconnect(Component.literal("Payload " + Arrays.toString(errorPayload.packetID) + " from " + Arrays.toString(errorPayload.protocolID) + " error"), PlayerKickEvent.Cause.INVALID_PAYLOAD); - return; - } - - for (LeavesProtocol protocol : KNOW_RECEIVERS.keySet()) { - if (!ArrayUtils.contains(protocol.namespace(), payload.type().id().getNamespace())) { - continue; - } - - Map map = KNOW_RECEIVERS.get(protocol); - for (ProtocolHandler.PayloadReceiver receiver : map.keySet()) { - if (payload.getClass() == receiver.payload()) { - if (receiver.ignoreId() || ArrayUtils.contains(receiver.payloadId(), payload.type().id().getPath())) { - try { - map.get(receiver).invoke(null, player, payload); - } catch (InvocationTargetException | IllegalAccessException exception) { - LOGGER.warning("Failed to handle payload " + payload.type().id() + " in " + ArrayUtils.toString(protocol.namespace()) + ", " + exception.getCause() + ": " + exception.getMessage()); - } - } - } - } - } - } - - public static void handleTick() { - if (!TICKERS.isEmpty()) { - try { - for (Method method : TICKERS) { - method.invoke(null); - } - } catch (InvocationTargetException | IllegalAccessException exception) { - LOGGER.warning("Failed to tick, " + exception.getCause() + ": " + exception.getMessage()); - } - } - } - - public static void handlePlayerJoin(ServerPlayer player) { - if (!PLAYER_JOIN.isEmpty()) { - try { - for (Method method : PLAYER_JOIN) { - method.invoke(null, player); - } - } catch (InvocationTargetException | IllegalAccessException exception) { - LOGGER.warning("Failed to handle player join, " + exception.getCause() + ": " + exception.getMessage()); - } - } - - ProtocolUtils.sendPayloadPacket(player, new FabricRegisterPayload(ALL_KNOWN_ID)); - } - - public static void handlePlayerLeave(ServerPlayer player) { - if (!PLAYER_LEAVE.isEmpty()) { - try { - for (Method method : PLAYER_LEAVE) { - method.invoke(null, player); - } - } catch (InvocationTargetException | IllegalAccessException exception) { - LOGGER.warning("Failed to handle player leave, " + exception.getCause() + ": " + exception.getMessage()); - } - } - } - - public static void handleServerReload() { - if (!RELOAD_SERVER.isEmpty()) { - try { - for (Method method : RELOAD_SERVER) { - method.invoke(null); - } - } catch (InvocationTargetException | IllegalAccessException exception) { - LOGGER.warning("Failed to handle server reload, " + exception.getCause() + ": " + exception.getMessage()); - } - } - } - - public static void handleMinecraftRegister(String channelId, ServerPlayer player) { - for (LeavesProtocol protocol : MINECRAFT_REGISTER.keySet()) { - String[] channel = channelId.split(":"); - if (!ArrayUtils.contains(protocol.namespace(), channel[0])) { - continue; - } - - Map map = MINECRAFT_REGISTER.get(protocol); - for (ProtocolHandler.MinecraftRegister register : map.keySet()) { - if (register.ignoreId() || ArrayUtils.contains(register.channelId(), channel[1])) { - try { - map.get(register).invoke(null, player, channel[1]); - } catch (InvocationTargetException | IllegalAccessException exception) { - LOGGER.warning("Failed to handle minecraft register, " + exception.getCause() + ": " + exception.getMessage()); - } - } - } - } - } - - public record ErrorPayload(ResourceLocation id, String[] protocolID, - String[] packetID) implements LeavesCustomPayload { - @Override - public void write(@NotNull FriendlyByteBuf buf) { - } - } - - public record EmptyPayload(ResourceLocation id) implements LeavesCustomPayload { - @New - public EmptyPayload(ResourceLocation location, FriendlyByteBuf buf) { - this(location); - } - - @Override - public void write(@NotNull FriendlyByteBuf buf) { - } - } - - public record LeavesPayload(FriendlyByteBuf data, - ResourceLocation id) implements LeavesCustomPayload { - @New - public LeavesPayload(ResourceLocation location, FriendlyByteBuf buf) { - this(new FriendlyByteBuf(buf.readBytes(buf.readableBytes())), location); - } - - @Override - public void write(FriendlyByteBuf buf) { - buf.writeBytes(data); - } - } - - public record FabricRegisterPayload( - Set channels) implements LeavesCustomPayload { - - public static final ResourceLocation CHANNEL = ResourceLocation.withDefaultNamespace("register"); - - @New - public FabricRegisterPayload(ResourceLocation location, FriendlyByteBuf buf) { - this(buf.readCollection(HashSet::new, FriendlyByteBuf::readResourceLocation)); - } - - @Override - public void write(FriendlyByteBuf buf) { - boolean first = true; - - ResourceLocation channel; - for (Iterator var3 = this.channels.iterator(); var3.hasNext(); buf.writeBytes(channel.toString().getBytes(StandardCharsets.US_ASCII))) { - channel = var3.next(); - if (first) { - first = false; - } else { - buf.writeByte(0); - } - } - } - - @Override - public ResourceLocation id() { - return CHANNEL; - } - } -} diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java b/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java deleted file mode 100644 index 3d40670d..00000000 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java +++ /dev/null @@ -1,35 +0,0 @@ -package org.leavesmc.leaves.protocol.jade.payload; - -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.network.RegistryFriendlyByteBuf; -import net.minecraft.network.codec.ByteBufCodecs; -import net.minecraft.network.codec.StreamCodec; -import net.minecraft.resources.ResourceLocation; -import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; -import org.leavesmc.leaves.protocol.core.ProtocolUtils; -import org.leavesmc.leaves.protocol.jade.JadeProtocol; - -public record ClientHandshakePayload(String protocolVersion) implements LeavesCustomPayload { - - private static final ResourceLocation PACKET_CLIENT_HANDSHAKE = JadeProtocol.id("client_handshake"); - - private static final StreamCodec CODEC = StreamCodec.composite( - ByteBufCodecs.STRING_UTF8, - ClientHandshakePayload::protocolVersion, - ClientHandshakePayload::new); - - @Override - public void write(FriendlyByteBuf buf) { - CODEC.encode(ProtocolUtils.decorate(buf), this); - } - - @Override - public ResourceLocation id() { - return PACKET_CLIENT_HANDSHAKE; - } - - @New - public static ClientHandshakePayload create(ResourceLocation location, FriendlyByteBuf buf) { - return CODEC.decode(ProtocolUtils.decorate(buf)); - } -} diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ObjectNameProvider.java b/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ObjectNameProvider.java deleted file mode 100644 index 0abd42a7..00000000 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ObjectNameProvider.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.leavesmc.leaves.protocol.jade.provider.block; - -import net.minecraft.core.component.DataComponents; -import net.minecraft.network.RegistryFriendlyByteBuf; -import net.minecraft.network.chat.Component; -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.world.MenuProvider; -import net.minecraft.world.Nameable; -import net.minecraft.world.level.block.ChestBlock; -import net.minecraft.world.level.block.entity.ChestBlockEntity; -import net.minecraft.world.level.block.state.properties.ChestType; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import org.leavesmc.leaves.protocol.jade.JadeProtocol; -import org.leavesmc.leaves.protocol.jade.accessor.BlockAccessor; -import org.leavesmc.leaves.protocol.jade.provider.StreamServerDataProvider; - -public abstract class ObjectNameProvider implements StreamServerDataProvider { - - private static final ResourceLocation CORE_OBJECT_NAME = JadeProtocol.id("object_name"); - - public static class ForBlock extends ObjectNameProvider implements StreamServerDataProvider { - public static final ForBlock INSTANCE = new ForBlock(); - - @Override - @Nullable - public Component streamData(@NotNull BlockAccessor accessor) { - if (!(accessor.getBlockEntity() instanceof Nameable nameable)) { - return null; - } - if (nameable instanceof ChestBlockEntity && accessor.getBlock() instanceof ChestBlock && accessor.getBlockState().getValue(ChestBlock.TYPE) != ChestType.SINGLE) { - MenuProvider menuProvider = accessor.getBlockState().getMenuProvider(accessor.getLevel(), accessor.getPosition()); - if (menuProvider != null) { - Component name = menuProvider.getDisplayName(); - if (!(name.getContents() instanceof TranslatableContents contents) || !"container.chestDouble".equals(contents.getKey())) { - return name; - } - } - } else if (nameable.hasCustomName()) { - return nameable.getDisplayName(); - } - return accessor.getBlockEntity().components().get(DataComponents.ITEM_NAME); - } - - @Override - public StreamCodec streamCodec() { - return ComponentSerialization.STREAM_CODEC; - } - } - - @Override - public ResourceLocation getUid() { - return CORE_OBJECT_NAME; - } - - @Override - public int getDefaultPriority() { - return -10100; - } -} diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/tool/ShearsToolHandler.java b/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/tool/ShearsToolHandler.java deleted file mode 100644 index 6a9cd9f0..00000000 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/tool/ShearsToolHandler.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.leavesmc.leaves.protocol.jade.tool; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.Items; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Blocks; -import net.minecraft.world.level.block.state.BlockState; -import org.leavesmc.leaves.protocol.jade.JadeProtocol; - -import java.util.List; - -public class ShearsToolHandler extends SimpleToolHandler { - - private static final ShearsToolHandler INSTANCE = new ShearsToolHandler(); - - public static ShearsToolHandler getInstance() { - return INSTANCE; - } - - public ShearsToolHandler() { - super(JadeProtocol.id("shears"), List.of(Items.SHEARS.getDefaultInstance()), true); - } - - @Override - public ItemStack test(BlockState state, Level world, BlockPos pos) { - if (state.is(Blocks.TRIPWIRE)) { - return tools.getFirst(); - } - return super.test(state, world, pos); - } -} diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/tool/SimpleToolHandler.java b/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/tool/SimpleToolHandler.java deleted file mode 100644 index d45ecdb1..00000000 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/tool/SimpleToolHandler.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.leavesmc.leaves.protocol.jade.tool; - -import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; -import net.minecraft.core.BlockPos; -import net.minecraft.core.component.DataComponents; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.component.Tool; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.BlockState; -import org.jetbrains.annotations.Contract; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -public class SimpleToolHandler implements ToolHandler { - - protected final List tools = Lists.newArrayList(); - private final ResourceLocation uid; - private final boolean skipInstaBreakingBlock; - - protected SimpleToolHandler(ResourceLocation uid, @NotNull List tools, boolean skipInstaBreakingBlock) { - this.uid = uid; - Preconditions.checkArgument(!tools.isEmpty(), "tools cannot be empty"); - this.tools.addAll(tools); - this.skipInstaBreakingBlock = skipInstaBreakingBlock; - } - - @Contract("_, _ -> new") - public static @NotNull SimpleToolHandler create(ResourceLocation uid, List tools) { - return create(uid, tools, true); - } - - @Contract("_, _, _ -> new") - public static @NotNull SimpleToolHandler create(ResourceLocation uid, List tools, boolean skipInstaBreakingBlock) { - return new SimpleToolHandler(uid, Lists.transform(tools, Item::getDefaultInstance), skipInstaBreakingBlock); - } - - @Override - public ItemStack test(BlockState state, Level world, BlockPos pos) { - if (skipInstaBreakingBlock && !state.requiresCorrectToolForDrops() && state.getDestroySpeed(world, pos) == 0) { - return ItemStack.EMPTY; - } - return test(state); - } - - public ItemStack test(BlockState state) { - for (ItemStack toolItem : tools) { - if (toolItem.isCorrectToolForDrops(state)) { - return toolItem; - } - Tool tool = toolItem.get(DataComponents.TOOL); - if (tool != null && tool.getMiningSpeed(state) > tool.defaultMiningSpeed()) { - return toolItem; - } - } - return ItemStack.EMPTY; - } - - @Override - public List getTools() { - return tools; - } - - @Override - public ResourceLocation getUid() { - return uid; - } -} diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/tool/ToolHandler.java b/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/tool/ToolHandler.java deleted file mode 100644 index ba7a3925..00000000 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/tool/ToolHandler.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.leavesmc.leaves.protocol.jade.tool; - -import net.minecraft.core.BlockPos; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.BlockState; -import org.leavesmc.leaves.protocol.jade.provider.IJadeProvider; - -import java.util.List; - -public interface ToolHandler extends IJadeProvider { - - ItemStack test(BlockState state, Level world, BlockPos pos); - - List getTools(); - -} diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java b/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java deleted file mode 100644 index 8c6dd05c..00000000 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.leavesmc.leaves.protocol.syncmatica; - -import net.minecraft.network.FriendlyByteBuf; -import net.minecraft.resources.ResourceLocation; -import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; - -public record SyncmaticaPayload(ResourceLocation packetType, - FriendlyByteBuf data) implements LeavesCustomPayload { - - private static final ResourceLocation NETWORK_ID = ResourceLocation.tryBuild(SyncmaticaProtocol.PROTOCOL_ID, "main"); - - @New - public static SyncmaticaPayload decode(ResourceLocation location, FriendlyByteBuf buf) { - return new SyncmaticaPayload(buf.readResourceLocation(), new FriendlyByteBuf(buf.readBytes(buf.readableBytes()))); - } - - @Override - public void write(FriendlyByteBuf buf) { - buf.writeResourceLocation(this.packetType); - buf.writeBytes(this.data.readBytes(this.data.readableBytes())); - } - - @Override - public ResourceLocation id() { - return NETWORK_ID; - } -} diff --git a/leaf-server/minecraft-patches/features/0113-Leaves-Protocol-Core.patch b/leaf-server/minecraft-patches/features/0113-Leaves-Protocol-Core.patch new file mode 100644 index 00000000..562fe677 --- /dev/null +++ b/leaf-server/minecraft-patches/features/0113-Leaves-Protocol-Core.patch @@ -0,0 +1,154 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: violetc <58360096+s-yh-china@users.noreply.github.com> +Date: Tue, 26 Sep 2023 19:00:41 +0800 +Subject: [PATCH] Leaves: Protocol Core + +TODO: Check whether Leaves's Return-nether-portal-fix.patch improves performance +and change store way to sql maybe? + +Original license: GPLv3 +Original project: https://github.com/LeavesMC/Leaves + +Commit: 358d3d232c88d0d089e2bcd2de9f814384572b8b + +diff --git a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java +index fb263fa1f30a7dfcb7ec2656abfb38e5fe88eac9..56fd1ed7ccaf96e7eedea60fbdbf7f934939d563 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 { + + @Override + public void encode(B buffer, CustomPacketPayload value) { ++ // Leaves start - protocol core ++ if (value instanceof org.leavesmc.leaves.protocol.core.LeavesCustomPayload payload) { ++ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.encode(buffer, payload); ++ return; ++ } ++ // Leaves end - protocol core + this.writeCap(buffer, value.type(), value); + } + + @Override + public CustomPacketPayload decode(B buffer) { + ResourceLocation resourceLocation = buffer.readResourceLocation(); +- return (CustomPacketPayload)this.findCodec(resourceLocation).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)); ++ // Leaves end - protocol core + } + }; + } +diff --git a/net/minecraft/network/protocol/common/custom/DiscardedPayload.java b/net/minecraft/network/protocol/common/custom/DiscardedPayload.java +index 62b9d9486c15a1ec6527f786df4e9fc483390bcb..5384bbc6bb3dbe5481f9d8cb10282551a0f78ec1 100644 +--- a/net/minecraft/network/protocol/common/custom/DiscardedPayload.java ++++ b/net/minecraft/network/protocol/common/custom/DiscardedPayload.java +@@ -4,12 +4,12 @@ import net.minecraft.network.FriendlyByteBuf; + import net.minecraft.network.codec.StreamCodec; + import net.minecraft.resources.ResourceLocation; + +-public record DiscardedPayload(ResourceLocation id, byte[] data) implements CustomPacketPayload { // Paper - store data ++public record DiscardedPayload(ResourceLocation id, byte @org.jetbrains.annotations.Nullable [] data) implements CustomPacketPayload { // Paper - store data // Leaves - nullable + public static StreamCodec codec(ResourceLocation id, int maxSize) { + return CustomPacketPayload.codec((value, output) -> { + // Paper start + // Always write data +- output.writeBytes(value.data); ++ if (value.data != null) output.writeBytes(value.data); // Leaves - nullable + }, buffer -> { + int i = buffer.readableBytes(); + if (i >= 0 && i <= maxSize) { +diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java +index 3190ed2171b0de32aeb8761aa3e510c968c45448..58c52eabba725be9fa5fde06be5cf69d0281ce5b 100644 +--- a/net/minecraft/server/MinecraftServer.java ++++ b/net/minecraft/server/MinecraftServer.java +@@ -1735,6 +1735,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop entityType, Level level) { diff --git a/net/minecraft/world/entity/animal/frog/Tadpole.java b/net/minecraft/world/entity/animal/frog/Tadpole.java -index ec9db1c12426db80dbf02d704e6c7ec867d59f6f..0fdda6b24aee95170e54079e53125b4aed19ac0b 100644 +index 7a3bfa91ffc5c7c6b04eef7b1b1d3c04c5a6d856..07fd03f1a8e72a5b39e5f9fd13f401dbfdb45280 100644 --- a/net/minecraft/world/entity/animal/frog/Tadpole.java +++ b/net/minecraft/world/entity/animal/frog/Tadpole.java -@@ -285,7 +285,7 @@ public class Tadpole extends AbstractFish { +@@ -284,7 +284,7 @@ public class Tadpole extends AbstractFish { } } @@ -48,11 +48,11 @@ index 29ad43245a310756c4227acd7532e905f7f8b8ee..ad422817593449b8e914628b51d760e7 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 dd646b11ef0a40e7f782742e62ccccfa9bcfd235..c9820777342124524c046d910085b1bf89c12488 100644 +index 7a8eb1e8b07647e1124594f78652d34731e4fda6..6cfe7ef8c81f506bce9c971b597cc4e902bcabbe 100644 --- a/net/minecraft/world/level/storage/loot/LootTable.java +++ b/net/minecraft/world/level/storage/loot/LootTable.java -@@ -45,7 +45,7 @@ public class LootTable { - public static final Codec> CODEC = RegistryFileCodec.create(Registries.LOOT_TABLE, DIRECT_CODEC); +@@ -49,7 +49,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 List pools; @@ -87,10 +87,10 @@ index e0e933245e038b7229eeddbda272b081161ab603..c5e3834fa970ac909cefea4342037839 protected LootPoolEntryContainer(List conditions) { diff --git a/net/minecraft/world/level/storage/loot/entries/NestedLootTable.java b/net/minecraft/world/level/storage/loot/entries/NestedLootTable.java -index d5e697a0cf6091a7f37c68e3c2a52851535735b1..a8a5a872a8647896e80f91cb5a89adead4005cf7 100644 +index f7b647e81ca99040bae8161a2bc0dcacf5bd537f..069df530b1db72bd4a2b1b80b2570dca545dfd20 100644 --- a/net/minecraft/world/level/storage/loot/entries/NestedLootTable.java +++ b/net/minecraft/world/level/storage/loot/entries/NestedLootTable.java -@@ -25,7 +25,7 @@ public class NestedLootTable extends LootPoolSingletonContainer { +@@ -22,7 +22,7 @@ public class NestedLootTable extends LootPoolSingletonContainer { .and(singletonFields(instance)) .apply(instance, NestedLootTable::new) ); diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0023-Leaves-Xaero-Map-Protocol.patch b/leaf-server/minecraft-patches/features/0115-Leaves-Xaero-Map-Protocol.patch similarity index 89% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0023-Leaves-Xaero-Map-Protocol.patch rename to leaf-server/minecraft-patches/features/0115-Leaves-Xaero-Map-Protocol.patch index 3ec4ef54..4642d04c 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0023-Leaves-Xaero-Map-Protocol.patch +++ b/leaf-server/minecraft-patches/features/0115-Leaves-Xaero-Map-Protocol.patch @@ -9,10 +9,10 @@ Original project: https://github.com/LeavesMC/Leaves This patch is Powered by Xaero Map diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 924faf76763588fb41b8aee53236ccb05b1239b1..e3d09d5f4efb32bb276e001e5ee747a775b502ee 100644 +index 5cdfd7b0170ad1dff67802cd7b4d59753b7067b8..b7c1d4c66d3ea23288e9e6ba9cb20122730f8869 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -1222,6 +1222,7 @@ public abstract class PlayerList { +@@ -1238,6 +1238,7 @@ public abstract class PlayerList { player.connection.send(new ClientboundInitializeBorderPacket(worldBorder)); player.connection.send(new ClientboundSetTimePacket(level.getGameTime(), level.getDayTime(), level.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT))); player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(level.getSharedSpawnPos(), level.getSharedSpawnAngle())); diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0024-Leaves-Syncmatica-Protocol.patch b/leaf-server/minecraft-patches/features/0116-Leaves-Syncmatica-Protocol.patch similarity index 78% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0024-Leaves-Syncmatica-Protocol.patch rename to leaf-server/minecraft-patches/features/0116-Leaves-Syncmatica-Protocol.patch index a6831570..168bfebb 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0024-Leaves-Syncmatica-Protocol.patch +++ b/leaf-server/minecraft-patches/features/0116-Leaves-Syncmatica-Protocol.patch @@ -9,23 +9,18 @@ Original project: https://github.com/LeavesMC/Leaves 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 61bf3bfb41392d38c7e796f56cc0cce870e12631..543e7e278bb94c0bc996c377f8778df8a0b0440b 100644 +index 44e96e867d8a4403a7c88f772d2aa60cbe9f516b..0bf9ead58e256dccd3c1e89bd08ebae9d630b49e 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -326,6 +326,7 @@ public class ServerGamePacketListenerImpl +@@ -319,8 +319,11 @@ 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 + this.exchangeTarget = new org.leavesmc.leaves.protocol.syncmatica.exchange.ExchangeTarget(this); // Leaves - Syncmatica Protocol } - // Purpur start - AFK API -@@ -342,6 +343,8 @@ public class ServerGamePacketListenerImpl - ); - // Purpur end - AFK API - + public final org.leavesmc.leaves.protocol.syncmatica.exchange.ExchangeTarget exchangeTarget; // Leaves - Syncmatica Protocol + - @Override - public void tick() { - if (this.ackBlockChangesUpTo > -1) { + // Purpur start - AFK API + private final com.google.common.cache.LoadingCache kickPermissionCache = com.google.common.cache.CacheBuilder.newBuilder() + .maximumSize(1000) diff --git a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0025-Leaves-Replay-Mod-API.patch b/leaf-server/minecraft-patches/features/0117-Leaves-Replay-Mod-API.patch similarity index 83% rename from leaf-archived-patches/unapplied/server/minecraft-patches/features/0025-Leaves-Replay-Mod-API.patch rename to leaf-server/minecraft-patches/features/0117-Leaves-Replay-Mod-API.patch index e1f45d70..b7a9bba1 100644 --- a/leaf-archived-patches/unapplied/server/minecraft-patches/features/0025-Leaves-Replay-Mod-API.patch +++ b/leaf-server/minecraft-patches/features/0117-Leaves-Replay-Mod-API.patch @@ -11,10 +11,10 @@ Original project: https://github.com/LeavesMC/Leaves 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 59c70c567051bc7dba0d308387352d1b15f3c842..e654387167cf3e9a88f0e62be940fe398387cffa 100644 +index 4d06587cd55af988eecdda5186577ab72ca3d533..6d1096d6cdf0ae23ab4cacabe4dbe531fea455a7 100644 --- a/net/minecraft/commands/CommandSourceStack.java +++ b/net/minecraft/commands/CommandSourceStack.java -@@ -626,7 +626,7 @@ public class CommandSourceStack implements ExecutionCommandSource getOnlinePlayerNames() { @@ -24,7 +24,7 @@ index 59c70c567051bc7dba0d308387352d1b15f3c842..e654387167cf3e9a88f0e62be940fe39 @Override diff --git a/net/minecraft/commands/arguments/selector/EntitySelector.java b/net/minecraft/commands/arguments/selector/EntitySelector.java -index b305ba9bab617bf4e52d0e6ddf160bacc5751a94..c9b4f00d5ccde83898ecf69efdbfee7a3f91b96d 100644 +index b305ba9bab617bf4e52d0e6ddf160bacc5751a94..853933618e67d7597c23b3099ea7a7a105c0483e 100644 --- a/net/minecraft/commands/arguments/selector/EntitySelector.java +++ b/net/minecraft/commands/arguments/selector/EntitySelector.java @@ -128,11 +128,12 @@ public class EntitySelector { @@ -37,7 +37,7 @@ index b305ba9bab617bf4e52d0e6ddf160bacc5751a94..c9b4f00d5ccde83898ecf69efdbfee7a for (ServerLevel serverLevel : source.getServer().getAllLevels()) { Entity entity = serverLevel.getEntity(this.entityUUID); - if (entity != null) { -+ if (entity != null && !(entity instanceof org.leavesmc.leaves.replay.ServerPhotographer)) { // Leaves - skip photographer ++ if (entity != null && !(entity instanceof org.leavesmc.leaves.replay.ServerPhotographer)) { if (entity.getType().isEnabled(source.enabledFeatures())) { return List.of(entity); } @@ -58,7 +58,7 @@ index b305ba9bab617bf4e52d0e6ddf160bacc5751a94..c9b4f00d5ccde83898ecf69efdbfee7a return this.sortAndLimit(vec3, list); } -@@ -192,27 +194,30 @@ public class EntitySelector { +@@ -192,9 +194,11 @@ public class EntitySelector { this.checkPermissions(source); if (this.playerName != null) { ServerPlayer playerByName = source.getServer().getPlayerList().getPlayerByName(this.playerName); @@ -70,32 +70,27 @@ index b305ba9bab617bf4e52d0e6ddf160bacc5751a94..c9b4f00d5ccde83898ecf69efdbfee7a return playerByName == null || !canSee(source, playerByName) ? List.of() : List.of(playerByName); // Purpur - Hide hidden players from entity selector } else { Vec3 vec3 = this.position.apply(source.getPosition()); - AABB absoluteAabb = this.getAbsoluteAabb(vec3); - Predicate predicate = this.getPredicate(vec3, absoluteAabb, null); - if (this.currentEntity) { -+ //return source.getEntity() instanceof ServerPlayer serverPlayer && predicate.test(serverPlayer) && !(serverPlayer instanceof org.leavesmc.leaves.replay.ServerPhotographer) && canSee(source, serverPlayer) ? List.of(serverPlayer) : List.of(); // Purpur - Hide hidden players from entity selector // Leaves - skip photographer - return source.getEntity() instanceof ServerPlayer serverPlayer && predicate.test(serverPlayer) && canSee(source, serverPlayer) ? List.of(serverPlayer) : List.of(); // Purpur - Hide hidden players from entity selector - } else { +@@ -206,13 +210,13 @@ public class EntitySelector { int resultLimit = this.getResultLimit(); List players; if (this.isWorldLimited()) { - players = source.getLevel().getPlayers(predicate, resultLimit); -- players.removeIf(entityplayer3 -> !canSee(source, entityplayer3)); // Purpur - Hide hidden players from entity selector -+ players.removeIf(entityplayer3 -> entityplayer3 instanceof org.leavesmc.leaves.replay.ServerPhotographer || !canSee(source, entityplayer3)); // Purpur - Hide hidden players from entity selector // Leaves - skip photographer +- players = source.getLevel().getPlayers(predicate, resultLimit); ++ players = source.getLevel().getPlayers((player -> !(player instanceof org.leavesmc.leaves.replay.ServerPhotographer) && predicate.test(player)), resultLimit); // Leaves - skip photographer + players.removeIf(entityplayer3 -> !canSee(source, entityplayer3)); // Purpur - Hide hidden players from entity selector } else { players = new ObjectArrayList<>(); for (ServerPlayer serverPlayer1 : source.getServer().getPlayerList().getPlayers()) { - if (predicate.test(serverPlayer1) && canSee(source, serverPlayer1)) { // Purpur - Hide hidden players from entity selector -+ if (!(serverPlayer1 instanceof org.leavesmc.leaves.replay.ServerPhotographer) && predicate.test(serverPlayer1) && canSee(source, serverPlayer1)) { // Purpur - Hide hidden players from entity selector // Leaves - skip photographer ++ if (predicate.test(serverPlayer1) && canSee(source, serverPlayer1) && !(serverPlayer1 instanceof org.leavesmc.leaves.replay.ServerPhotographer)) { // Purpur - Hide hidden players from entity selector // Leaves - skip photographer players.add(serverPlayer1); if (players.size() >= resultLimit) { return players; diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index dddbb18992348fb7e8a6552423d134809cd7fdbc..0e6e71030e3fd1335fff796b861524a48cb0a507 100644 +index 58c52eabba725be9fa5fde06be5cf69d0281ce5b..83cbf865d83edcb4caea59a1a2b4932a915414be 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1650,7 +1650,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop !playerList.isOp(player.getGameProfile())) .map(player -> player.getGameProfile().getName()), diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index b49dd636e730f0c5b609df68ee51bcd12efc1eaa..5e971bca365c692d4ce0c58693592002ce01471c 100644 +index e6730996dfd4c2422b6c13f10309fc58af4ac595..9b193bf81cf7f9f45dfa207a826043e083c2f8ba 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -216,6 +216,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -212,6 +212,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe public boolean hasEntityMoveEvent; // Paper - Add EntityMoveEvent private final alternate.current.wire.WireHandler wireHandler = new alternate.current.wire.WireHandler(this); // Paper - optimize redstone (Alternate Current) public boolean hasRidableMoveEvent = false; // Purpur - Ridables + final List realPlayers; // Leaves - skip - public LevelChunk getChunkIfLoaded(int x, int z) { - return this.chunkSource.getChunkAtIfLoadedImmediately(x, z); // Paper - Use getChunkIfLoadedImmediately -@@ -700,6 +701,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe + @Override + public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { +@@ -690,6 +691,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper end - rewrite chunk system this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit this.preciseTime = this.serverLevelData.getDayTime(); // Purpur - Configurable daylight cycle @@ -153,7 +148,7 @@ index b49dd636e730f0c5b609df68ee51bcd12efc1eaa..5e971bca365c692d4ce0c58693592002 } // Paper start -@@ -2698,6 +2700,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2690,6 +2692,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); @@ -165,7 +160,7 @@ index b49dd636e730f0c5b609df68ee51bcd12efc1eaa..5e971bca365c692d4ce0c58693592002 ServerLevel.this.updateSleepingPlayerList(); } -@@ -2768,6 +2775,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2760,6 +2767,11 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe ServerLevel.this.getChunkSource().removeEntity(entity); if (entity instanceof ServerPlayer serverPlayer) { ServerLevel.this.players.remove(serverPlayer); @@ -177,21 +172,8 @@ index b49dd636e730f0c5b609df68ee51bcd12efc1eaa..5e971bca365c692d4ce0c58693592002 ServerLevel.this.updateSleepingPlayerList(); } -diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index d44c3baa2ef30d5cd4c46e491ff9198fa558513c..f89d28595fa9ca12e414f7b3cc86085ff0769e72 100644 ---- a/net/minecraft/server/level/ServerPlayer.java -+++ b/net/minecraft/server/level/ServerPlayer.java -@@ -195,7 +195,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc - ); - public ServerGamePacketListenerImpl connection; - public final MinecraftServer server; -- public final ServerPlayerGameMode gameMode; -+ public ServerPlayerGameMode gameMode; // Leaves - final -> null - private final PlayerAdvancements advancements; - private final ServerStatsCounter stats; - private float lastRecordedHealthAndAbsorption = Float.MIN_VALUE; diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index c26bf04abe86b566e7f5cd29191a0a853f9808f8..4c172e2aee3e48d42009cd39b28f694aa71e20e3 100644 +index b7c1d4c66d3ea23288e9e6ba9cb20122730f8869..f6bfd246571f9f7b25e4bdff66253a99a2e5a77f 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java @@ -132,6 +132,7 @@ public abstract class PlayerList { @@ -230,7 +212,7 @@ index c26bf04abe86b566e7f5cd29191a0a853f9808f8..4c172e2aee3e48d42009cd39b28f694a + player.getBukkitEntity().sendSupportedChannels(); // CraftBukkit + playerconnection.send(new ClientboundChangeDifficultyPacket(worlddata.getDifficulty(), worlddata.isDifficultyLocked())); + playerconnection.send(new ClientboundPlayerAbilitiesPacket(player.getAbilities())); -+ playerconnection.send(new ClientboundSetHeldSlotPacket(player.getInventory().selected)); ++ playerconnection.send(new ClientboundSetHeldSlotPacket(player.getInventory().getSelectedSlot())); + RecipeManager craftingmanager = this.server.getRecipeManager(); + playerconnection.send(new ClientboundUpdateRecipesPacket(craftingmanager.getSynchronizedItemProperties(), craftingmanager.getSynchronizedStonecutterRecipes())); + @@ -279,7 +261,7 @@ index c26bf04abe86b566e7f5cd29191a0a853f9808f8..4c172e2aee3e48d42009cd39b28f694a + + player.sentListPacket = true; + player.supressTrackerForLogin = false; -+ ((ServerLevel) player.level()).getChunkSource().chunkMap.addEntity(player); ++ ((ServerLevel)player.level()).getChunkSource().chunkMap.addEntity(player); + + this.sendLevelInfo(player, worldserver1); + @@ -289,7 +271,7 @@ index c26bf04abe86b566e7f5cd29191a0a853f9808f8..4c172e2aee3e48d42009cd39b28f694a + } + + worldserver1 = player.serverLevel(); -+ java.util.Iterator iterator = player.getActiveEffects().iterator(); ++ java.util.Iterator iterator = player.getActiveEffects().iterator(); + while (iterator.hasNext()) { + MobEffectInstance mobeffect = iterator.next(); + playerconnection.send(new ClientboundUpdateMobEffectPacket(player.getId(), mobeffect, false)); @@ -297,10 +279,10 @@ index c26bf04abe86b566e7f5cd29191a0a853f9808f8..4c172e2aee3e48d42009cd39b28f694a + + if (player.isDeadOrDying()) { + net.minecraft.core.Holder plains = worldserver1.registryAccess().lookupOrThrow(net.minecraft.core.registries.Registries.BIOME) -+ .getOrThrow(net.minecraft.world.level.biome.Biomes.PLAINS); ++ .getOrThrow(net.minecraft.world.level.biome.Biomes.PLAINS); + player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket( -+ new net.minecraft.world.level.chunk.EmptyLevelChunk(worldserver1, player.chunkPosition(), plains), -+ worldserver1.getLightEngine(), null, null, false) ++ new net.minecraft.world.level.chunk.EmptyLevelChunk(worldserver1, player.chunkPosition(), plains), ++ worldserver1.getLightEngine(), null, null, false) + ); + } + } @@ -309,7 +291,7 @@ index c26bf04abe86b566e7f5cd29191a0a853f9808f8..4c172e2aee3e48d42009cd39b28f694a public void placeNewPlayer(Connection connection, ServerPlayer player, CommonListenerCookie cookie) { player.isRealPlayer = true; // Paper player.loginTime = System.currentTimeMillis(); // Paper - Replace OfflinePlayer#getLastPlayed -@@ -315,6 +416,7 @@ public abstract class PlayerList { +@@ -317,6 +418,7 @@ public abstract class PlayerList { // player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players)); // CraftBukkit - replaced with loop below this.players.add(player); @@ -317,7 +299,7 @@ index c26bf04abe86b566e7f5cd29191a0a853f9808f8..4c172e2aee3e48d42009cd39b28f694a this.playersByName.put(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT), player); // Spigot this.playersByUUID.put(player.getUUID(), player); this.addToSendAllPlayerInfoBuckets(player); // Gale - Purpur - spread out sending all player info -@@ -374,6 +476,12 @@ public abstract class PlayerList { +@@ -378,6 +480,12 @@ public abstract class PlayerList { continue; } @@ -330,7 +312,7 @@ index c26bf04abe86b566e7f5cd29191a0a853f9808f8..4c172e2aee3e48d42009cd39b28f694a onlinePlayers.add(entityplayer1); // Paper - Use single player info update packet on join } // Paper start - Use single player info update packet on join -@@ -515,6 +623,43 @@ public abstract class PlayerList { +@@ -519,6 +627,43 @@ public abstract class PlayerList { } } @@ -371,10 +353,10 @@ index c26bf04abe86b566e7f5cd29191a0a853f9808f8..4c172e2aee3e48d42009cd39b28f694a + } + // Leaves stop - replay mod api + - public net.kyori.adventure.text.Component remove(ServerPlayer player) { // CraftBukkit - return string // Paper - return Component + public @Nullable net.kyori.adventure.text.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()))); -@@ -591,6 +736,7 @@ public abstract class PlayerList { +@@ -595,6 +740,7 @@ public abstract class PlayerList { player.retireScheduler(); // Paper - Folia schedulers player.getAdvancements().stopListening(); this.players.remove(player); @@ -382,7 +364,7 @@ index c26bf04abe86b566e7f5cd29191a0a853f9808f8..4c172e2aee3e48d42009cd39b28f694a this.playersByName.remove(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT)); // Spigot this.removeFromSendAllPlayerInfoBuckets(player); // Gale - Purpur - spread out sending all player info this.server.getCustomBossEvents().onPlayerDisconnect(player); -@@ -688,7 +834,7 @@ public abstract class PlayerList { +@@ -687,7 +833,7 @@ public abstract class PlayerList { // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameProfile) // ? Component.translatable("multiplayer.disconnect.server_full") // : null; diff --git a/leaf-server/minecraft-patches/features/0113-Petal-Async-Pathfinding.patch b/leaf-server/minecraft-patches/features/0118-Petal-Async-Pathfinding.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0113-Petal-Async-Pathfinding.patch rename to leaf-server/minecraft-patches/features/0118-Petal-Async-Pathfinding.patch diff --git a/leaf-server/minecraft-patches/features/0114-Petal-reduce-work-done-by-game-event-system.patch b/leaf-server/minecraft-patches/features/0119-Petal-reduce-work-done-by-game-event-system.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0114-Petal-reduce-work-done-by-game-event-system.patch rename to leaf-server/minecraft-patches/features/0119-Petal-reduce-work-done-by-game-event-system.patch diff --git a/leaf-server/minecraft-patches/features/0115-Reduce-canSee-work.patch b/leaf-server/minecraft-patches/features/0120-Reduce-canSee-work.patch similarity index 95% rename from leaf-server/minecraft-patches/features/0115-Reduce-canSee-work.patch rename to leaf-server/minecraft-patches/features/0120-Reduce-canSee-work.patch index bbd9e85d..14e93be2 100644 --- a/leaf-server/minecraft-patches/features/0115-Reduce-canSee-work.patch +++ b/leaf-server/minecraft-patches/features/0120-Reduce-canSee-work.patch @@ -7,7 +7,7 @@ Co-authored by: Martijn Muijsers Co-authored by: MachineBreaker diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 3b814983b91165ecee1a15d24cc0352247316a9f..453d4babc78f5676cb9534a5d80967a6f8c5a263 100644 +index a94f6eb93a4271d8b50cbb55dce04affd1ac4a13..9ac2ecb78f6214616376b0e3badef21dc3f72114 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -987,17 +987,19 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl diff --git a/leaf-server/minecraft-patches/features/0116-Fix-sprint-glitch.patch b/leaf-server/minecraft-patches/features/0121-Fix-sprint-glitch.patch similarity index 90% rename from leaf-server/minecraft-patches/features/0116-Fix-sprint-glitch.patch rename to leaf-server/minecraft-patches/features/0121-Fix-sprint-glitch.patch index 3f40b4ff..aa11a26c 100644 --- a/leaf-server/minecraft-patches/features/0116-Fix-sprint-glitch.patch +++ b/leaf-server/minecraft-patches/features/0121-Fix-sprint-glitch.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Fix sprint glitch diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 40ab67a6930242553ed7acc9d6cc474a36e23888..ab7bdbce80046df43e4889c20c4d3d9fb1d2e2c4 100644 +index ed15b5f29658d799a36dcbd196a8fcb107be4bda..09aa0b344aff0c48eec9a296d47c0704bd0fdc5c 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -1387,7 +1387,8 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/leaf-server/minecraft-patches/features/0117-Configurable-movement-speed-of-more-entities.patch b/leaf-server/minecraft-patches/features/0122-Configurable-movement-speed-of-more-entities.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0117-Configurable-movement-speed-of-more-entities.patch rename to leaf-server/minecraft-patches/features/0122-Configurable-movement-speed-of-more-entities.patch diff --git a/leaf-server/minecraft-patches/features/0118-Faster-sequencing-of-futures-for-chunk-structure-gen.patch b/leaf-server/minecraft-patches/features/0123-Faster-sequencing-of-futures-for-chunk-structure-gen.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0118-Faster-sequencing-of-futures-for-chunk-structure-gen.patch rename to leaf-server/minecraft-patches/features/0123-Faster-sequencing-of-futures-for-chunk-structure-gen.patch diff --git a/leaf-server/minecraft-patches/features/0119-Reduce-active-items-finding-hopper-nearby-check.patch b/leaf-server/minecraft-patches/features/0124-Reduce-active-items-finding-hopper-nearby-check.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0119-Reduce-active-items-finding-hopper-nearby-check.patch rename to leaf-server/minecraft-patches/features/0124-Reduce-active-items-finding-hopper-nearby-check.patch diff --git a/leaf-server/minecraft-patches/features/0120-Plazma-Add-some-missing-Pufferfish-configurations.patch b/leaf-server/minecraft-patches/features/0125-Plazma-Add-some-missing-Pufferfish-configurations.patch similarity index 98% rename from leaf-server/minecraft-patches/features/0120-Plazma-Add-some-missing-Pufferfish-configurations.patch rename to leaf-server/minecraft-patches/features/0125-Plazma-Add-some-missing-Pufferfish-configurations.patch index 79430e61..6b9c1f90 100644 --- a/leaf-server/minecraft-patches/features/0120-Plazma-Add-some-missing-Pufferfish-configurations.patch +++ b/leaf-server/minecraft-patches/features/0125-Plazma-Add-some-missing-Pufferfish-configurations.patch @@ -10,7 +10,7 @@ Add Pufferfish DAB support for Camel, Sniffer https://github.com/pufferfish-gg/Pufferfish/issues/83 diff --git a/net/minecraft/world/entity/animal/armadillo/Armadillo.java b/net/minecraft/world/entity/animal/armadillo/Armadillo.java -index aea96e036846c66d411fdea55fbbf0efb60d467d..3b1a40226e903119503108ea72bd0880c164e0e0 100644 +index fb8a56d0ee80b0d397f2acd3af1f52fc26676b62..5d93eb5e56e45d485c0718db9e3d8754e97b691c 100644 --- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java +++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java @@ -162,8 +162,10 @@ public class Armadillo extends Animal { diff --git a/leaf-server/minecraft-patches/features/0121-Plazma-Add-missing-purpur-configuration-options.patch b/leaf-server/minecraft-patches/features/0126-Plazma-Add-missing-purpur-configuration-options.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0121-Plazma-Add-missing-purpur-configuration-options.patch rename to leaf-server/minecraft-patches/features/0126-Plazma-Add-missing-purpur-configuration-options.patch index 8674d65d..f52a2a4c 100644 --- a/leaf-server/minecraft-patches/features/0121-Plazma-Add-missing-purpur-configuration-options.patch +++ b/leaf-server/minecraft-patches/features/0126-Plazma-Add-missing-purpur-configuration-options.patch @@ -92,7 +92,7 @@ index 50f9a11f8cb53fd1fa34017598ff3fe828b3ca25..9f9abbd3272cba17f79dc4da6cf2cd4d protected Brain.Provider brainProvider() { return Brain.provider(MEMORY_TYPES, SENSOR_TYPES); diff --git a/net/minecraft/world/entity/animal/frog/Tadpole.java b/net/minecraft/world/entity/animal/frog/Tadpole.java -index 7a3bfa91ffc5c7c6b04eef7b1b1d3c04c5a6d856..649d0fd34fc807ee0c87577490c77b71d5d76ecf 100644 +index 07fd03f1a8e72a5b39e5f9fd13f401dbfdb45280..daa315bfbedb0ec21a684d9141fb41ad40ce45b1 100644 --- a/net/minecraft/world/entity/animal/frog/Tadpole.java +++ b/net/minecraft/world/entity/animal/frog/Tadpole.java @@ -106,6 +106,23 @@ public class Tadpole extends AbstractFish { diff --git a/leaf-server/minecraft-patches/features/0122-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch b/leaf-server/minecraft-patches/features/0127-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0122-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch rename to leaf-server/minecraft-patches/features/0127-SparklyPaper-Skip-distanceToSqr-call-in-ServerEntity.patch diff --git a/leaf-server/minecraft-patches/features/0123-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch b/leaf-server/minecraft-patches/features/0128-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0123-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch rename to leaf-server/minecraft-patches/features/0128-SparklyPaper-Skip-MapItem-update-if-the-map-does-not.patch diff --git a/leaf-server/minecraft-patches/features/0124-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch b/leaf-server/minecraft-patches/features/0129-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch similarity index 97% rename from leaf-server/minecraft-patches/features/0124-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch rename to leaf-server/minecraft-patches/features/0129-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch index e6756e94..99c0c0c3 100644 --- a/leaf-server/minecraft-patches/features/0124-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch +++ b/leaf-server/minecraft-patches/features/0129-SparklyPaper-Skip-EntityScheduler-s-executeTick-chec.patch @@ -13,7 +13,7 @@ To avoid the hefty ArrayDeque's size() call, we check if we *really* need to exe Most entities won't have any scheduled tasks, so this is a nice performance bonus. These optimizations, however, wouldn't work in a Folia environment, but because in SparklyPaper executeTick is always executed on the main thread, it ain't an issue for us (yay). diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 3190ed2171b0de32aeb8761aa3e510c968c45448..b8b1bcac05917fa985210bcd5c6e226ed188b0ff 100644 +index 83cbf865d83edcb4caea59a1a2b4932a915414be..3a86960729e23c7a5028dd64538d08428afd2b01 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -289,6 +289,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop 0 ? split[0] : "").replace(org.purpurmc.purpur.PurpurConfig.afkTabListPrefix, ""); String suffix = (split.length > 1 ? split[1] : "").replace(org.purpurmc.purpur.PurpurConfig.afkTabListSuffix, ""); if (afk) { @@ -53,10 +53,10 @@ index a05cd22bfe3a2c25a5e37c973766a162ce8e7244..602a087122a6baa3cb33e1bf5e6c4d98 } else { getBukkitEntity().setPlayerListName(prefix + scoreboardName + suffix, true); diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 470660998d3df511f00936bcaa210142ab8ba7b2..220dd097aa1d912feb6699dccd1b68523c14cdf6 100644 +index 0bf9ead58e256dccd3c1e89bd08ebae9d630b49e..3c14d32ec9caf3dba9d99afe86a3ca053de70958 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -2324,6 +2324,7 @@ public class ServerGamePacketListenerImpl +@@ -2327,6 +2327,7 @@ public class ServerGamePacketListenerImpl @Override public void handleChatCommand(ServerboundChatCommandPacket packet) { @@ -64,7 +64,7 @@ index 470660998d3df511f00936bcaa210142ab8ba7b2..220dd097aa1d912feb6699dccd1b6852 this.tryHandleChat(packet.command(), () -> { // CraftBukkit start - SPIGOT-7346: Prevent disconnected players from executing commands if (this.player.hasDisconnected()) { -@@ -2332,7 +2333,7 @@ public class ServerGamePacketListenerImpl +@@ -2335,7 +2336,7 @@ public class ServerGamePacketListenerImpl // CraftBukkit end this.performUnsignedChatCommand(packet.command()); this.detectRateSpam("/" + packet.command()); // Spigot @@ -73,7 +73,7 @@ index 470660998d3df511f00936bcaa210142ab8ba7b2..220dd097aa1d912feb6699dccd1b6852 } private void performUnsignedChatCommand(String command) { -@@ -2365,6 +2366,7 @@ public class ServerGamePacketListenerImpl +@@ -2368,6 +2369,7 @@ public class ServerGamePacketListenerImpl public void handleSignedChatCommand(ServerboundChatCommandSignedPacket packet) { Optional optional = this.unpackAndApplyLastSeen(packet.lastSeenMessages()); if (!optional.isEmpty()) { @@ -81,7 +81,7 @@ index 470660998d3df511f00936bcaa210142ab8ba7b2..220dd097aa1d912feb6699dccd1b6852 this.tryHandleChat(packet.command(), () -> { // CraftBukkit start - SPIGOT-7346: Prevent disconnected players from executing commands if (this.player.hasDisconnected()) { -@@ -2373,7 +2375,7 @@ public class ServerGamePacketListenerImpl +@@ -2376,7 +2378,7 @@ public class ServerGamePacketListenerImpl // CraftBukkit end this.performSignedChatCommand(packet, optional.get()); this.detectRateSpam("/" + packet.command()); // Spigot @@ -90,7 +90,7 @@ index 470660998d3df511f00936bcaa210142ab8ba7b2..220dd097aa1d912feb6699dccd1b6852 } } -@@ -2480,12 +2482,17 @@ public class ServerGamePacketListenerImpl +@@ -2483,12 +2485,17 @@ public class ServerGamePacketListenerImpl return dispatcher.parse(command, this.player.createCommandSourceStack()); } @@ -110,7 +110,7 @@ index 470660998d3df511f00936bcaa210142ab8ba7b2..220dd097aa1d912feb6699dccd1b6852 this.player.resetLastActionTime(); // CraftBukkit start if (sync) { -@@ -2497,6 +2504,40 @@ public class ServerGamePacketListenerImpl +@@ -2500,6 +2507,40 @@ public class ServerGamePacketListenerImpl } } @@ -152,11 +152,11 @@ index 470660998d3df511f00936bcaa210142ab8ba7b2..220dd097aa1d912feb6699dccd1b6852 synchronized (this.lastSeenMessages) { Optional var10000; diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 536fea9622cdec212aa61adbb627704c59a8999f..37ba75bd50f785da11a0127fb40d86ee8b988c17 100644 +index 5966b45ec8c385539535139885e5ff522c998141..e9529dfb98bf025fbdd59bbd2c61ea8169907fb6 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -524,6 +524,7 @@ public abstract class PlayerList { - public @Nullable net.kyori.adventure.text.Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) { +@@ -672,6 +672,7 @@ public abstract class PlayerList { + org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerLeave(player); // Leaves - protocol // Paper end - Fix kick event leave message not being sent org.purpurmc.purpur.task.BossBarTask.removeFromAll(player.getBukkitEntity()); // Purpur - Implement TPSBar + net.minecraft.server.network.ServerGamePacketListenerImpl.afkCooldown.remove(player.getBukkitEntity().getUniqueId()); // Leaf - Improve Purpur AFK system diff --git a/leaf-server/minecraft-patches/features/0131-Virtual-thread-for-chat-executor.patch b/leaf-server/minecraft-patches/features/0136-Virtual-thread-for-chat-executor.patch similarity index 90% rename from leaf-server/minecraft-patches/features/0131-Virtual-thread-for-chat-executor.patch rename to leaf-server/minecraft-patches/features/0136-Virtual-thread-for-chat-executor.patch index 3bfc5802..da189fb4 100644 --- a/leaf-server/minecraft-patches/features/0131-Virtual-thread-for-chat-executor.patch +++ b/leaf-server/minecraft-patches/features/0136-Virtual-thread-for-chat-executor.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Virtual thread for chat executor diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index b8b1bcac05917fa985210bcd5c6e226ed188b0ff..49cd06c0b71c6aa643b692c21ecbc01266291770 100644 +index 3a86960729e23c7a5028dd64538d08428afd2b01..3ca7405318a4076000250203be4b91dbde95191b 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -2660,7 +2660,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop packet) { @@ -138,10 +138,10 @@ index d2e8adccf33c6b842fac615006b782b09cfa7a1a..434be9d08d8e816e2dea1e9d23fa26d2 if (packet == null || this.processedDisconnect) { // Spigot return; diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 37ba75bd50f785da11a0127fb40d86ee8b988c17..a3fdc328399c5d4806c6f361ba83515cf2094336 100644 +index e9529dfb98bf025fbdd59bbd2c61ea8169907fb6..3bc0469173330b50b488fb8eaf5f0c1b98e33fc4 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -1386,7 +1386,7 @@ public abstract class PlayerList { +@@ -1537,7 +1537,7 @@ public abstract class PlayerList { public void broadcastChatMessage(PlayerChatMessage message, Predicate shouldFilterMessageTo, @Nullable ServerPlayer sender, ChatType.Bound boundChatType, @Nullable Function unsignedFunction) { // Paper end boolean flag = this.verifyChatTrusted(message); @@ -150,7 +150,7 @@ index 37ba75bd50f785da11a0127fb40d86ee8b988c17..a3fdc328399c5d4806c6f361ba83515c OutgoingChatMessage outgoingChatMessage = OutgoingChatMessage.create(message); boolean flag1 = false; -@@ -1411,6 +1411,7 @@ public abstract class PlayerList { +@@ -1562,6 +1562,7 @@ public abstract class PlayerList { } public boolean verifyChatTrusted(PlayerChatMessage message) { diff --git a/leaf-server/minecraft-patches/features/0134-Cache-player-profileResult.patch b/leaf-server/minecraft-patches/features/0139-Cache-player-profileResult.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0134-Cache-player-profileResult.patch rename to leaf-server/minecraft-patches/features/0139-Cache-player-profileResult.patch diff --git a/leaf-server/minecraft-patches/features/0135-Matter-Secure-Seed.patch b/leaf-server/minecraft-patches/features/0140-Matter-Secure-Seed.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0135-Matter-Secure-Seed.patch rename to leaf-server/minecraft-patches/features/0140-Matter-Secure-Seed.patch index 503af0fc..c03a05e6 100644 --- a/leaf-server/minecraft-patches/features/0135-Matter-Secure-Seed.patch +++ b/leaf-server/minecraft-patches/features/0140-Matter-Secure-Seed.patch @@ -48,10 +48,10 @@ index 229e115447b06db3e3b440ee8ea0505979656846..a9acfc3ba6c3447b4632d32fe24e9a09 } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 0f09a2b0cbc17f1d64638f677f2518617f906576..7d8efad091cbf9f1177e7c0751c8e534bd665e0a 100644 +index 9b193bf81cf7f9f45dfa207a826043e083c2f8ba..11e8738b7cf388e0742bfe5e6136365f6ac066f9 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -624,6 +624,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -625,6 +625,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe chunkGenerator = new org.bukkit.craftbukkit.generator.CustomChunkGenerator(this, chunkGenerator, gen); } // CraftBukkit end @@ -60,7 +60,7 @@ index 0f09a2b0cbc17f1d64638f677f2518617f906576..7d8efad091cbf9f1177e7c0751c8e534 DataFixer fixerUpper = server.getFixerUpper(); // Paper - rewrite chunk system diff --git a/net/minecraft/world/entity/monster/Slime.java b/net/minecraft/world/entity/monster/Slime.java -index 7b6db084a483b4a9c2f292c5ed6e4c7550344c50..471d61cfd26ab1724432afc99dfe335a09a5ba48 100644 +index 9a157a2bdbbeab89dbfcd23be8bdc62c8de4548c..c257a19ff6b15ee6a83e9c946e2b20309ada9b51 100644 --- a/net/minecraft/world/entity/monster/Slime.java +++ b/net/minecraft/world/entity/monster/Slime.java @@ -412,7 +412,11 @@ public class Slime extends Mob implements Enemy { diff --git a/leaf-server/minecraft-patches/features/0136-Matter-Secure-Seed-command.patch b/leaf-server/minecraft-patches/features/0141-Matter-Secure-Seed-command.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0136-Matter-Secure-Seed-command.patch rename to leaf-server/minecraft-patches/features/0141-Matter-Secure-Seed-command.patch diff --git a/leaf-server/minecraft-patches/features/0137-Faster-random-generator.patch b/leaf-server/minecraft-patches/features/0142-Faster-random-generator.patch similarity index 98% rename from leaf-server/minecraft-patches/features/0137-Faster-random-generator.patch rename to leaf-server/minecraft-patches/features/0142-Faster-random-generator.patch index 916c744a..d5c5efac 100644 --- a/leaf-server/minecraft-patches/features/0137-Faster-random-generator.patch +++ b/leaf-server/minecraft-patches/features/0142-Faster-random-generator.patch @@ -27,10 +27,10 @@ index a9acfc3ba6c3447b4632d32fe24e9a09d55ba1e2..0f9d18dd29e210ad656da211a3cb1cb2 final ServerLevel world = this.level; final int randomTickSpeed = world.getGameRules().getInt(GameRules.RULE_RANDOMTICKING); diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 7d8efad091cbf9f1177e7c0751c8e534bd665e0a..d23ed8dbda5132337c8c96c67cf924e438ea9f4b 100644 +index 11e8738b7cf388e0742bfe5e6136365f6ac066f9..16cafa0acb7b2972ce08ab56921e73eb44eff6fa 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -889,7 +889,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -891,7 +891,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe private void optimiseRandomTick(final LevelChunk chunk, final int tickSpeed) { final LevelChunkSection[] sections = chunk.getSections(); final int minSection = ca.spottedleaf.moonrise.common.util.WorldUtil.getMinSection((ServerLevel)(Object)this); @@ -39,7 +39,7 @@ index 7d8efad091cbf9f1177e7c0751c8e534bd665e0a..d23ed8dbda5132337c8c96c67cf924e4 final boolean doubleTickFluids = !ca.spottedleaf.moonrise.common.PlatformHooks.get().configFixMC224294(); final ChunkPos cpos = chunk.getPos(); -@@ -938,7 +938,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -940,7 +940,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe private int currentIceAndSnowTick = 0; protected void resetIceAndSnowTick() { this.currentIceAndSnowTick = this.simpleRandom.nextInt(16); } // Gale - Airplane - optimize random calls in chunk ticking public void tickChunk(LevelChunk chunk, int randomTickSpeed) { @@ -97,7 +97,7 @@ index 8516d47b0ba79d91638837199e7ae0fb6cb44a79..4f4b55dd099dd2c2fea118b18b535881 RandomSource fork(); diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 109ec179bd7e960cb09a98e1ec6179a60b2cba57..1f439c158f58fac08d17a262c01a1202ff3eb8e0 100644 +index 4e3b73bee5dae2b5921db86cc53b4cd9ebbd06f8..fa44ddaeac193a686211a9ede5993674626b8e25 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -149,7 +149,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess @@ -110,7 +110,7 @@ index 109ec179bd7e960cb09a98e1ec6179a60b2cba57..1f439c158f58fac08d17a262c01a1202 private static final class RandomRandomSource extends ca.spottedleaf.moonrise.common.util.ThreadUnsafeRandom { public RandomRandomSource() { diff --git a/net/minecraft/world/level/Level.java b/net/minecraft/world/level/Level.java -index 453d4babc78f5676cb9534a5d80967a6f8c5a263..5fe79a471b5a5f1474a1fcb305b323d2e3a0de87 100644 +index 9ac2ecb78f6214616376b0e3badef21dc3f72114..f145453f70a219c1be33b241309ae2ab22a8004b 100644 --- a/net/minecraft/world/level/Level.java +++ b/net/minecraft/world/level/Level.java @@ -117,7 +117,7 @@ public abstract class Level implements LevelAccessor, UUIDLookup, AutoCl @@ -189,7 +189,7 @@ index 426692d9627f46d708f551bd22ce3c52b2a23b37..8a19fd2b816b07a7374cb9dc96896a12 if (!org.dreeam.leaf.config.modules.misc.SecureSeed.enabled) { // Paper start - Add missing structure set seed configs diff --git a/net/minecraft/world/level/levelgen/DensityFunctions.java b/net/minecraft/world/level/levelgen/DensityFunctions.java -index 04527a5c65ad630f794fed9071d485aedd02257a..15fc39f9c77fdd03a0ca4a39d173c851b9454f08 100644 +index 77731406cb3dc417aa2fe1cb4352f3d2d7d498aa..1420dac658c4b27d25882a6d7dd3efb2c5b7e720 100644 --- a/net/minecraft/world/level/levelgen/DensityFunctions.java +++ b/net/minecraft/world/level/levelgen/DensityFunctions.java @@ -518,7 +518,7 @@ public final class DensityFunctions { diff --git a/leaf-server/minecraft-patches/features/0138-Don-t-save-primed-tnt-entity.patch b/leaf-server/minecraft-patches/features/0143-Don-t-save-primed-tnt-entity.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0138-Don-t-save-primed-tnt-entity.patch rename to leaf-server/minecraft-patches/features/0143-Don-t-save-primed-tnt-entity.patch diff --git a/leaf-server/minecraft-patches/features/0139-Don-t-save-falling-block-entity.patch b/leaf-server/minecraft-patches/features/0144-Don-t-save-falling-block-entity.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0139-Don-t-save-falling-block-entity.patch rename to leaf-server/minecraft-patches/features/0144-Don-t-save-falling-block-entity.patch diff --git a/leaf-server/minecraft-patches/features/0140-Configurable-connection-message.patch b/leaf-server/minecraft-patches/features/0145-Configurable-connection-message.patch similarity index 94% rename from leaf-server/minecraft-patches/features/0140-Configurable-connection-message.patch rename to leaf-server/minecraft-patches/features/0145-Configurable-connection-message.patch index f857d5b6..8763273e 100644 --- a/leaf-server/minecraft-patches/features/0140-Configurable-connection-message.patch +++ b/leaf-server/minecraft-patches/features/0145-Configurable-connection-message.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Configurable connection message diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index a3fdc328399c5d4806c6f361ba83515cf2094336..9f2dcbbd82c5f077f058b64a61cc31d76b34b471 100644 +index 3bc0469173330b50b488fb8eaf5f0c1b98e33fc4..fae3c65d7411cd2c279dde27f8b8eafd45b657cf 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -336,7 +336,7 @@ public abstract class PlayerList { +@@ -438,7 +438,7 @@ public abstract class PlayerList { // Ensure that player inventory is populated with its viewer player.containerMenu.transferTo(player.containerMenu, bukkitPlayer); @@ -17,7 +17,7 @@ index a3fdc328399c5d4806c6f361ba83515cf2094336..9f2dcbbd82c5f077f058b64a61cc31d7 this.cserver.getPluginManager().callEvent(playerJoinEvent); if (!player.connection.isAcceptingMessages()) { -@@ -347,7 +347,7 @@ public abstract class PlayerList { +@@ -451,7 +451,7 @@ public abstract class PlayerList { final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage(); @@ -26,7 +26,7 @@ index a3fdc328399c5d4806c6f361ba83515cf2094336..9f2dcbbd82c5f077f058b64a61cc31d7 joinMessage = io.papermc.paper.adventure.PaperAdventure.asVanilla(jm); // Paper - Adventure this.server.getPlayerList().broadcastSystemMessage(joinMessage, false); // Paper - Adventure } -@@ -533,7 +533,7 @@ public abstract class PlayerList { +@@ -681,7 +681,7 @@ public abstract class PlayerList { player.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.DISCONNECT); // Paper - Inventory close reason } @@ -35,7 +35,7 @@ index a3fdc328399c5d4806c6f361ba83515cf2094336..9f2dcbbd82c5f077f058b64a61cc31d7 this.cserver.getPluginManager().callEvent(playerQuitEvent); player.getBukkitEntity().disconnect(playerQuitEvent.getQuitMessage()); -@@ -1538,4 +1538,40 @@ public abstract class PlayerList { +@@ -1690,4 +1690,40 @@ public abstract class PlayerList { public boolean isAllowCommandsForAllPlayers() { return this.allowCommandsForAllPlayers; } diff --git a/leaf-server/minecraft-patches/features/0141-Configurable-unknown-command-message.patch b/leaf-server/minecraft-patches/features/0146-Configurable-unknown-command-message.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0141-Configurable-unknown-command-message.patch rename to leaf-server/minecraft-patches/features/0146-Configurable-unknown-command-message.patch diff --git a/leaf-server/minecraft-patches/features/0142-Remove-stream-in-BlockBehaviour-cache-blockstate.patch b/leaf-server/minecraft-patches/features/0147-Remove-stream-in-BlockBehaviour-cache-blockstate.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0142-Remove-stream-in-BlockBehaviour-cache-blockstate.patch rename to leaf-server/minecraft-patches/features/0147-Remove-stream-in-BlockBehaviour-cache-blockstate.patch diff --git a/leaf-server/minecraft-patches/features/0143-Remove-stream-in-entity-visible-effects-filter.patch b/leaf-server/minecraft-patches/features/0148-Remove-stream-in-entity-visible-effects-filter.patch similarity index 93% rename from leaf-server/minecraft-patches/features/0143-Remove-stream-in-entity-visible-effects-filter.patch rename to leaf-server/minecraft-patches/features/0148-Remove-stream-in-entity-visible-effects-filter.patch index a69787be..eb2dd953 100644 --- a/leaf-server/minecraft-patches/features/0143-Remove-stream-in-entity-visible-effects-filter.patch +++ b/leaf-server/minecraft-patches/features/0148-Remove-stream-in-entity-visible-effects-filter.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Remove stream in entity visible effects filter diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index ab7bdbce80046df43e4889c20c4d3d9fb1d2e2c4..916a964263a9b71d20007c29302341dd50c94b85 100644 +index 09aa0b344aff0c48eec9a296d47c0704bd0fdc5c..fdbe3d4d71ba30c8330760555e97ff436643a7a9 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -988,12 +988,15 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/leaf-server/minecraft-patches/features/0144-Remove-stream-and-double-iteration-in-enough-deep-sl.patch b/leaf-server/minecraft-patches/features/0149-Remove-stream-and-double-iteration-in-enough-deep-sl.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0144-Remove-stream-and-double-iteration-in-enough-deep-sl.patch rename to leaf-server/minecraft-patches/features/0149-Remove-stream-and-double-iteration-in-enough-deep-sl.patch diff --git a/leaf-server/minecraft-patches/features/0145-Remove-stream-in-trial-spawner-ticking.patch b/leaf-server/minecraft-patches/features/0150-Remove-stream-in-trial-spawner-ticking.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0145-Remove-stream-in-trial-spawner-ticking.patch rename to leaf-server/minecraft-patches/features/0150-Remove-stream-in-trial-spawner-ticking.patch diff --git a/leaf-server/minecraft-patches/features/0146-Remove-stream-in-Brain.patch b/leaf-server/minecraft-patches/features/0151-Remove-stream-in-Brain.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0146-Remove-stream-in-Brain.patch rename to leaf-server/minecraft-patches/features/0151-Remove-stream-in-Brain.patch diff --git a/leaf-server/minecraft-patches/features/0147-Remove-stream-in-BehaviorUtils.patch b/leaf-server/minecraft-patches/features/0152-Remove-stream-in-BehaviorUtils.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0147-Remove-stream-in-BehaviorUtils.patch rename to leaf-server/minecraft-patches/features/0152-Remove-stream-in-BehaviorUtils.patch diff --git a/leaf-server/minecraft-patches/features/0148-Remove-stream-in-YieldJobSite.patch b/leaf-server/minecraft-patches/features/0153-Remove-stream-in-YieldJobSite.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0148-Remove-stream-in-YieldJobSite.patch rename to leaf-server/minecraft-patches/features/0153-Remove-stream-in-YieldJobSite.patch diff --git a/leaf-server/minecraft-patches/features/0149-Remove-stream-in-PlayerSensor.patch b/leaf-server/minecraft-patches/features/0154-Remove-stream-in-PlayerSensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0149-Remove-stream-in-PlayerSensor.patch rename to leaf-server/minecraft-patches/features/0154-Remove-stream-in-PlayerSensor.patch diff --git a/leaf-server/minecraft-patches/features/0150-Remove-stream-in-GolemSensor.patch b/leaf-server/minecraft-patches/features/0155-Remove-stream-in-GolemSensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0150-Remove-stream-in-GolemSensor.patch rename to leaf-server/minecraft-patches/features/0155-Remove-stream-in-GolemSensor.patch diff --git a/leaf-server/minecraft-patches/features/0151-Remove-stream-in-GateBehavior.patch b/leaf-server/minecraft-patches/features/0156-Remove-stream-in-GateBehavior.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0151-Remove-stream-in-GateBehavior.patch rename to leaf-server/minecraft-patches/features/0156-Remove-stream-in-GateBehavior.patch diff --git a/leaf-server/minecraft-patches/features/0152-Remove-stream-in-updateFluidOnEyes.patch b/leaf-server/minecraft-patches/features/0157-Remove-stream-in-updateFluidOnEyes.patch similarity index 97% rename from leaf-server/minecraft-patches/features/0152-Remove-stream-in-updateFluidOnEyes.patch rename to leaf-server/minecraft-patches/features/0157-Remove-stream-in-updateFluidOnEyes.patch index a4c65058..f97b29a5 100644 --- a/leaf-server/minecraft-patches/features/0152-Remove-stream-in-updateFluidOnEyes.patch +++ b/leaf-server/minecraft-patches/features/0157-Remove-stream-in-updateFluidOnEyes.patch @@ -46,7 +46,7 @@ index 6c7edbbf3935c40ccb78bee680ea75431718b9bd..a1b4dc70d555cce5e06c0298736d8b89 public String toString() { return "Reference{" + this.key + "=" + this.value + "}"; diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index 1f439c158f58fac08d17a262c01a1202ff3eb8e0..753515c65a2b49db15ef6616cc7caf276fdbbeb1 100644 +index fa44ddaeac193a686211a9ede5993674626b8e25..c3d4cdfece32a05acd03b892cd5b343f0d230e64 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -1976,7 +1976,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess diff --git a/leaf-server/minecraft-patches/features/0153-Remove-stream-in-matchingSlot.patch b/leaf-server/minecraft-patches/features/0158-Remove-stream-in-matchingSlot.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0153-Remove-stream-in-matchingSlot.patch rename to leaf-server/minecraft-patches/features/0158-Remove-stream-in-matchingSlot.patch diff --git a/leaf-server/minecraft-patches/features/0154-Remove-stream-in-entity-mountedOrDismounted-changes-.patch b/leaf-server/minecraft-patches/features/0159-Remove-stream-in-entity-mountedOrDismounted-changes-.patch similarity index 94% rename from leaf-server/minecraft-patches/features/0154-Remove-stream-in-entity-mountedOrDismounted-changes-.patch rename to leaf-server/minecraft-patches/features/0159-Remove-stream-in-entity-mountedOrDismounted-changes-.patch index 719ca42e..4a7ad3f7 100644 --- a/leaf-server/minecraft-patches/features/0154-Remove-stream-in-entity-mountedOrDismounted-changes-.patch +++ b/leaf-server/minecraft-patches/features/0159-Remove-stream-in-entity-mountedOrDismounted-changes-.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Remove stream in entity mountedOrDismounted changes update diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index 27e8c6a61cfa30b4e5bcc8ac30b0023940d9f310..dca939778d637ee293dc14f55edde7b1a97a2617 100644 +index b3fe9ea70148cdbefbdb617abaf81fe48ee26685..d6b261f8d3fbeee771208528b3e0bd5fcd94878b 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java @@ -118,7 +118,19 @@ public class ServerEntity { diff --git a/leaf-server/minecraft-patches/features/0155-Replace-Entity-active-effects-map-with-optimized-col.patch b/leaf-server/minecraft-patches/features/0160-Replace-Entity-active-effects-map-with-optimized-col.patch similarity index 96% rename from leaf-server/minecraft-patches/features/0155-Replace-Entity-active-effects-map-with-optimized-col.patch rename to leaf-server/minecraft-patches/features/0160-Replace-Entity-active-effects-map-with-optimized-col.patch index 74e17cac..76b8291e 100644 --- a/leaf-server/minecraft-patches/features/0155-Replace-Entity-active-effects-map-with-optimized-col.patch +++ b/leaf-server/minecraft-patches/features/0160-Replace-Entity-active-effects-map-with-optimized-col.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Replace Entity active effects map with optimized collection Dreeam TODO: check this diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index 916a964263a9b71d20007c29302341dd50c94b85..fe201ffb28df1171bc22f7ed40cd729b9f3f1017 100644 +index fdbe3d4d71ba30c8330760555e97ff436643a7a9..ba6d9a5df71e9aae9defedf5bbe12f49599123cb 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -196,6 +196,10 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/leaf-server/minecraft-patches/features/0156-Replace-criterion-map-with-optimized-collection.patch b/leaf-server/minecraft-patches/features/0161-Replace-criterion-map-with-optimized-collection.patch similarity index 93% rename from leaf-server/minecraft-patches/features/0156-Replace-criterion-map-with-optimized-collection.patch rename to leaf-server/minecraft-patches/features/0161-Replace-criterion-map-with-optimized-collection.patch index 6be18088..d04c8e32 100644 --- a/leaf-server/minecraft-patches/features/0156-Replace-criterion-map-with-optimized-collection.patch +++ b/leaf-server/minecraft-patches/features/0161-Replace-criterion-map-with-optimized-collection.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Replace criterion map with optimized collection diff --git a/net/minecraft/server/PlayerAdvancements.java b/net/minecraft/server/PlayerAdvancements.java -index edf115439c630a4471460db02109bbce7868de81..6dc728625de0f323322c34104e1c55b17aa0b712 100644 +index c7e92f0122823d9e1aa471c5c0e995d1e1d90184..10ac7393d20a0857be2bfdd856dda448699b3eff 100644 --- a/net/minecraft/server/PlayerAdvancements.java +++ b/net/minecraft/server/PlayerAdvancements.java @@ -60,7 +60,7 @@ public class PlayerAdvancements { diff --git a/leaf-server/minecraft-patches/features/0157-Replace-brain-maps-with-optimized-collection.patch b/leaf-server/minecraft-patches/features/0162-Replace-brain-maps-with-optimized-collection.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0157-Replace-brain-maps-with-optimized-collection.patch rename to leaf-server/minecraft-patches/features/0162-Replace-brain-maps-with-optimized-collection.patch diff --git a/leaf-server/minecraft-patches/features/0158-Reduce-worldgen-allocations.patch b/leaf-server/minecraft-patches/features/0163-Reduce-worldgen-allocations.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0158-Reduce-worldgen-allocations.patch rename to leaf-server/minecraft-patches/features/0163-Reduce-worldgen-allocations.patch diff --git a/leaf-server/minecraft-patches/features/0159-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch b/leaf-server/minecraft-patches/features/0164-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch similarity index 87% rename from leaf-server/minecraft-patches/features/0159-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch rename to leaf-server/minecraft-patches/features/0164-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch index ed251a39..3b1a91d0 100644 --- a/leaf-server/minecraft-patches/features/0159-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch +++ b/leaf-server/minecraft-patches/features/0164-Use-caffeine-cache-for-kickPermission-instead-of-usi.patch @@ -6,11 +6,11 @@ Subject: [PATCH] Use caffeine cache for kickPermission instead of using diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 4287bb927a25206016298be2cc659d5920b3c414..5e693808b54efd77a40ccf0bafdf5a2aa7245da3 100644 +index 3c14d32ec9caf3dba9d99afe86a3ca053de70958..155e2047659111f68e27d3517e5178afa233dfe4 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -322,17 +322,12 @@ public class ServerGamePacketListenerImpl - } +@@ -325,17 +325,12 @@ public class ServerGamePacketListenerImpl + public final org.leavesmc.leaves.protocol.syncmatica.exchange.ExchangeTarget exchangeTarget; // Leaves - Syncmatica Protocol // Purpur start - AFK API - private final com.google.common.cache.LoadingCache kickPermissionCache = com.google.common.cache.CacheBuilder.newBuilder() @@ -31,7 +31,7 @@ index 4287bb927a25206016298be2cc659d5920b3c414..5e693808b54efd77a40ccf0bafdf5a2a // Purpur end - AFK API @Override -@@ -395,7 +390,7 @@ public class ServerGamePacketListenerImpl +@@ -398,7 +393,7 @@ public class ServerGamePacketListenerImpl && Util.getMillis() - this.player.getLastActionTime() > this.server.getPlayerIdleTimeout() * 1000L * 60L && !this.player.wonGame) { // Paper - Prevent AFK kick while watching end credits // Purpur start - AFK API this.player.setAfk(true); diff --git a/leaf-server/minecraft-patches/features/0160-Do-not-place-player-if-the-server-is-full.patch b/leaf-server/minecraft-patches/features/0165-Do-not-place-player-if-the-server-is-full.patch similarity index 67% rename from leaf-server/minecraft-patches/features/0160-Do-not-place-player-if-the-server-is-full.patch rename to leaf-server/minecraft-patches/features/0165-Do-not-place-player-if-the-server-is-full.patch index 37c6e67e..80d40261 100644 --- a/leaf-server/minecraft-patches/features/0160-Do-not-place-player-if-the-server-is-full.patch +++ b/leaf-server/minecraft-patches/features/0165-Do-not-place-player-if-the-server-is-full.patch @@ -6,15 +6,15 @@ Subject: [PATCH] Do not place player if the server is full Fix https://github.com/PaperMC/Paper/issues/10668 diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index a289c3247ef6e1b7ae76fdc86c286e7b426731b4..7f12288fc361f780171026beb52c07b20ae17324 100644 +index fae3c65d7411cd2c279dde27f8b8eafd45b657cf..34c5c2e3d6b0706cb91ec0171969cf81e94741a4 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -241,6 +241,13 @@ public abstract class PlayerList { +@@ -342,6 +342,13 @@ public abstract class PlayerList { return; } // Gale end - MultiPaper - do not place player in world if kicked before being spawned in + // Leaf start - Do not place player if the server is full - copied from canPlayerLogin -+ if (org.dreeam.leaf.config.modules.fixes.DontPlacePlayerIfFull.enabled && this.players.size() >= this.maxPlayers && !(player.getBukkitEntity().hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameProfile))) { // Purpur - Allow player join full server by permission ++ if (org.dreeam.leaf.config.modules.fixes.DontPlacePlayerIfFull.enabled && this.realPlayers.size() >= this.maxPlayers && !(player.getBukkitEntity().hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameProfile))) { // Purpur - Allow player join full server by permission + connection.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage))); + //playerconnection.disconnect(io.papermc.paper.adventure.PaperAdventure.asVanilla(net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); + return; @@ -23,12 +23,12 @@ index a289c3247ef6e1b7ae76fdc86c286e7b426731b4..7f12288fc361f780171026beb52c07b2 org.bukkit.Location loc = ev.getSpawnLocation(); serverLevel = ((org.bukkit.craftbukkit.CraftWorld) loc.getWorld()).getHandle(); -@@ -684,7 +691,7 @@ public abstract class PlayerList { +@@ -834,7 +841,7 @@ public abstract class PlayerList { // return this.players.size() >= this.maxPlayers && !this.canBypassPlayerLimit(gameProfile) // ? Component.translatable("multiplayer.disconnect.server_full") // : null; -- if (this.players.size() >= this.maxPlayers && !(player.hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameProfile))) { // Purpur - Allow player join full server by permission -+ if (this.players.size() >= this.maxPlayers && !(player.hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameProfile))) { // Purpur - Allow player join full server by permission // Leaf - Do not place player if the server is full - diff on change +- if (this.realPlayers.size() >= this.maxPlayers && !(player.hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameProfile))) { // Purpur - Allow player join full server by permission // Leaves - only real player ++ if (this.realPlayers.size() >= this.maxPlayers && !(player.hasPermission("purpur.joinfullserver") || this.canBypassPlayerLimit(gameProfile))) { // Purpur - Allow player join full server by permission // Leaves - only real player // Leaf - Do not place player if the server is full - diff on change event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_FULL, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(org.spigotmc.SpigotConfig.serverFullMessage)); // Spigot // Paper - Adventure } } diff --git a/leaf-server/minecraft-patches/features/0161-Fix-MC-65198.patch b/leaf-server/minecraft-patches/features/0166-Fix-MC-65198.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0161-Fix-MC-65198.patch rename to leaf-server/minecraft-patches/features/0166-Fix-MC-65198.patch diff --git a/leaf-server/minecraft-patches/features/0162-Fix-MC-200418.patch b/leaf-server/minecraft-patches/features/0167-Fix-MC-200418.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0162-Fix-MC-200418.patch rename to leaf-server/minecraft-patches/features/0167-Fix-MC-200418.patch diff --git a/leaf-server/minecraft-patches/features/0163-Fix-MC-119417.patch b/leaf-server/minecraft-patches/features/0168-Fix-MC-119417.patch similarity index 85% rename from leaf-server/minecraft-patches/features/0163-Fix-MC-119417.patch rename to leaf-server/minecraft-patches/features/0168-Fix-MC-119417.patch index ac41d99e..70853fdc 100644 --- a/leaf-server/minecraft-patches/features/0163-Fix-MC-119417.patch +++ b/leaf-server/minecraft-patches/features/0168-Fix-MC-119417.patch @@ -6,10 +6,10 @@ Subject: [PATCH] Fix MC-119417 Related MC issue: https://bugs.mojang.com/browse/MC/issues/MC-119417 diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 602a087122a6baa3cb33e1bf5e6c4d98e500fa05..f898961de04ad0b224d0405e2cd43d61665cc1b1 100644 +index 034a946cd545d775188a4375a87c90d253ebdb08..18125ed336c3425f123232b405a8af9ee3a2ba7d 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -2189,6 +2189,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -2191,6 +2191,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc this.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.CHANGE_GAME_MODE, gameMode.getId())); if (gameMode == GameType.SPECTATOR) { this.removeEntitiesOnShoulder(); diff --git a/leaf-server/minecraft-patches/features/0164-Fix-MC-223153.patch b/leaf-server/minecraft-patches/features/0169-Fix-MC-223153.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0164-Fix-MC-223153.patch rename to leaf-server/minecraft-patches/features/0169-Fix-MC-223153.patch diff --git a/leaf-server/minecraft-patches/features/0165-Configurable-player-knockback-zombie.patch b/leaf-server/minecraft-patches/features/0170-Configurable-player-knockback-zombie.patch similarity index 95% rename from leaf-server/minecraft-patches/features/0165-Configurable-player-knockback-zombie.patch rename to leaf-server/minecraft-patches/features/0170-Configurable-player-knockback-zombie.patch index 93679332..5cb47f7f 100644 --- a/leaf-server/minecraft-patches/features/0165-Configurable-player-knockback-zombie.patch +++ b/leaf-server/minecraft-patches/features/0170-Configurable-player-knockback-zombie.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Configurable player knockback zombie diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index fe201ffb28df1171bc22f7ed40cd729b9f3f1017..f36af61d7620f57f396d879d669161b8b1a30875 100644 +index ba6d9a5df71e9aae9defedf5bbe12f49599123cb..4c3eadc2d8480b2a2c2c08e58620544d403d3adc 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -2079,6 +2079,8 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/leaf-server/minecraft-patches/features/0166-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch b/leaf-server/minecraft-patches/features/0171-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch similarity index 96% rename from leaf-server/minecraft-patches/features/0166-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch rename to leaf-server/minecraft-patches/features/0171-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch index 75c1fab1..c74dc1b3 100644 --- a/leaf-server/minecraft-patches/features/0166-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch +++ b/leaf-server/minecraft-patches/features/0171-Paper-PR-Skip-AI-during-inactive-ticks-for-non-aware.patch @@ -8,7 +8,7 @@ Original project: https://github.com/PaperMC/Paper Paper pull request: https://github.com/PaperMC/Paper/pull/10990 diff --git a/net/minecraft/world/entity/Mob.java b/net/minecraft/world/entity/Mob.java -index e9ebf23b0b1af85e3738a70acc0eaa3e8980261f..d473c09e98eb5d3ef7b3e096197c7bf9a6219c56 100644 +index cf136bc3d0d285ebde23c6e31c002933564fdcb2..c15b6e32bd00650366dc4ecba2abeb6bfb98d638 100644 --- a/net/minecraft/world/entity/Mob.java +++ b/net/minecraft/world/entity/Mob.java @@ -207,6 +207,11 @@ public abstract class Mob extends LivingEntity implements EquipmentUser, Leashab diff --git a/leaf-server/minecraft-patches/features/0167-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch b/leaf-server/minecraft-patches/features/0172-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0167-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch rename to leaf-server/minecraft-patches/features/0172-Paper-PR-Prevent-zombie-reinforcements-loading-chunk.patch diff --git a/leaf-server/minecraft-patches/features/0168-PaperPR-Fix-some-beacon-event-issues.patch b/leaf-server/minecraft-patches/features/0173-PaperPR-Fix-some-beacon-event-issues.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0168-PaperPR-Fix-some-beacon-event-issues.patch rename to leaf-server/minecraft-patches/features/0173-PaperPR-Fix-some-beacon-event-issues.patch diff --git a/leaf-server/minecraft-patches/features/0169-Dont-send-useless-entity-packets.patch b/leaf-server/minecraft-patches/features/0174-Dont-send-useless-entity-packets.patch similarity index 96% rename from leaf-server/minecraft-patches/features/0169-Dont-send-useless-entity-packets.patch rename to leaf-server/minecraft-patches/features/0174-Dont-send-useless-entity-packets.patch index c27a69f8..12564389 100644 --- a/leaf-server/minecraft-patches/features/0169-Dont-send-useless-entity-packets.patch +++ b/leaf-server/minecraft-patches/features/0174-Dont-send-useless-entity-packets.patch @@ -9,7 +9,7 @@ Original license: MIT Original project: https://github.com/PurpurMC/Purpur diff --git a/net/minecraft/server/level/ServerEntity.java b/net/minecraft/server/level/ServerEntity.java -index dca939778d637ee293dc14f55edde7b1a97a2617..44d87997e1ce9b846ebed541634a4478334c920c 100644 +index d6b261f8d3fbeee771208528b3e0bd5fcd94878b..1a9601aee097b6c10cf2ae1c52fddf45da85f60f 100644 --- a/net/minecraft/server/level/ServerEntity.java +++ b/net/minecraft/server/level/ServerEntity.java @@ -221,6 +221,8 @@ public class ServerEntity { diff --git a/leaf-server/minecraft-patches/features/0170-Multithreaded-Tracker.patch b/leaf-server/minecraft-patches/features/0175-Multithreaded-Tracker.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0170-Multithreaded-Tracker.patch rename to leaf-server/minecraft-patches/features/0175-Multithreaded-Tracker.patch index b6e9fb9c..c4cc557e 100644 --- a/leaf-server/minecraft-patches/features/0170-Multithreaded-Tracker.patch +++ b/leaf-server/minecraft-patches/features/0175-Multithreaded-Tracker.patch @@ -353,10 +353,10 @@ index 1a9601aee097b6c10cf2ae1c52fddf45da85f60f..16b2ca8c96e9561aa57e0903d1e98e64 } diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 42f56bd6a9f449df23f7e7f00b3efa114a003449..0471b04833fbca5dfc0cc6575692cdefb83edbed 100644 +index 16cafa0acb7b2972ce08ab56921e73eb44eff6fa..bbccf0c8aef3792bb7b7cb0070e48bca4c274a2c 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -2503,7 +2503,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2505,7 +2505,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe @Override public LevelEntityGetter getEntities() { @@ -365,7 +365,7 @@ index 42f56bd6a9f449df23f7e7f00b3efa114a003449..0471b04833fbca5dfc0cc6575692cdef return this.moonrise$getEntityLookup(); // Paper - rewrite chunk system } -@@ -2739,7 +2739,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -2746,7 +2746,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } map.carriedByPlayers.remove(player); @@ -375,10 +375,10 @@ index 42f56bd6a9f449df23f7e7f00b3efa114a003449..0471b04833fbca5dfc0cc6575692cdef } } diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index be803fd0a79850254bd4a7f64534142cd5b4ec98..6992a53abdcff6299bedf33ba0b1bc6386a1ea74 100644 +index 155e2047659111f68e27d3517e5178afa233dfe4..c91348eea1350728d8f6de7b8c3613cb44b5cdec 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1878,7 +1878,7 @@ public class ServerGamePacketListenerImpl +@@ -1881,7 +1881,7 @@ public class ServerGamePacketListenerImpl } public void internalTeleport(PositionMoveRotation posMoveRotation, Set relatives) { diff --git a/leaf-server/minecraft-patches/features/0171-Nitori-Async-playerdata-saving.patch b/leaf-server/minecraft-patches/features/0176-Nitori-Async-playerdata-saving.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0171-Nitori-Async-playerdata-saving.patch rename to leaf-server/minecraft-patches/features/0176-Nitori-Async-playerdata-saving.patch index 27f993f0..4a47a035 100644 --- a/leaf-server/minecraft-patches/features/0171-Nitori-Async-playerdata-saving.patch +++ b/leaf-server/minecraft-patches/features/0176-Nitori-Async-playerdata-saving.patch @@ -7,7 +7,7 @@ Original license: GPL v3 Original project: https://github.com/Gensokyo-Reimagined/Nitori diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 17d3a8a2cc3c86ed6aae9c20ed9f281dc9715cf5..354823def23167feb1e7b35cd9db5ef1584e7e8c 100644 +index 3ca7405318a4076000250203be4b91dbde95191b..2aed6f594c73bea5e8919e65cf04bc7eb6775c3e 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -1067,6 +1067,12 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop, AutoCl diff --git a/leaf-server/minecraft-patches/features/0195-Sepals-Rearrange-the-attackable-conditions.patch b/leaf-server/minecraft-patches/features/0200-Sepals-Rearrange-the-attackable-conditions.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0195-Sepals-Rearrange-the-attackable-conditions.patch rename to leaf-server/minecraft-patches/features/0200-Sepals-Rearrange-the-attackable-conditions.patch diff --git a/leaf-server/minecraft-patches/features/0196-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch b/leaf-server/minecraft-patches/features/0201-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0196-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch rename to leaf-server/minecraft-patches/features/0201-SparklyPaper-Skip-dirty-stats-copy-when-requesting-p.patch diff --git a/leaf-server/minecraft-patches/features/0197-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch b/leaf-server/minecraft-patches/features/0202-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch similarity index 92% rename from leaf-server/minecraft-patches/features/0197-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch rename to leaf-server/minecraft-patches/features/0202-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch index 21674588..d546f3a3 100644 --- a/leaf-server/minecraft-patches/features/0197-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch +++ b/leaf-server/minecraft-patches/features/0202-SparklyPaper-Reset-dirty-flag-when-loading-maps-from.patch @@ -9,7 +9,7 @@ By default, the server will start rewriting all map datas to the disk after load This also slows down world saving a lot if you have a lot of maps diff --git a/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java -index df471cd42f4084facb895b229c261b685054c3ae..3e84cb0fe6efa95ccede9ead29cafbf1afb717d9 100644 +index d62ff9ebd4b55e1a9a0b51e84be868d844e5a954..8abf2160ae5df851e218f78ce1bfb8350df2bc28 100644 --- a/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java +++ b/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java @@ -160,6 +160,7 @@ public class MapItemSavedData extends SavedData { diff --git a/leaf-server/minecraft-patches/features/0198-Optimize-checking-nearby-players-for-spawning.patch b/leaf-server/minecraft-patches/features/0203-Optimize-checking-nearby-players-for-spawning.patch similarity index 97% rename from leaf-server/minecraft-patches/features/0198-Optimize-checking-nearby-players-for-spawning.patch rename to leaf-server/minecraft-patches/features/0203-Optimize-checking-nearby-players-for-spawning.patch index d7c1f9d3..8e1b2837 100644 --- a/leaf-server/minecraft-patches/features/0198-Optimize-checking-nearby-players-for-spawning.patch +++ b/leaf-server/minecraft-patches/features/0203-Optimize-checking-nearby-players-for-spawning.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Optimize checking nearby players for spawning diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 560a857f3b61679bbf2ee93ac6da393052a1f320..a50fb16dc2e6230d346eea8ee76820ec56906446 100644 +index ae0a7c9b95f4f2561769e0d661fadbe29a2d6f8b..14b2abc51fa5d2caa56adfaf50784296c5668ae6 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java @@ -773,7 +773,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider diff --git a/leaf-server/minecraft-patches/features/0199-Cache-supporting-block-check.patch b/leaf-server/minecraft-patches/features/0204-Cache-supporting-block-check.patch similarity index 96% rename from leaf-server/minecraft-patches/features/0199-Cache-supporting-block-check.patch rename to leaf-server/minecraft-patches/features/0204-Cache-supporting-block-check.patch index 009ee89b..f83fbc6f 100644 --- a/leaf-server/minecraft-patches/features/0199-Cache-supporting-block-check.patch +++ b/leaf-server/minecraft-patches/features/0204-Cache-supporting-block-check.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Cache supporting block check diff --git a/net/minecraft/world/entity/Entity.java b/net/minecraft/world/entity/Entity.java -index a2e9306d9a5eef738f8225e98fb1cc1f4bbca504..cb17aaad72940ac94317a50cbe85b22c00e02a10 100644 +index 1cbc319a9b5ce3b15f79fcfec8cf9c46d0d3d1d0..309a31215cb63452215fd880590cffd569aee208 100644 --- a/net/minecraft/world/entity/Entity.java +++ b/net/minecraft/world/entity/Entity.java @@ -1078,12 +1078,36 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess diff --git a/leaf-server/minecraft-patches/features/0200-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch b/leaf-server/minecraft-patches/features/0205-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0200-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch rename to leaf-server/minecraft-patches/features/0205-Avoid-useless-deque-clear-on-LevelTicks-cleanupAfter.patch diff --git a/leaf-server/minecraft-patches/features/0201-Replace-brain-activity-maps-with-optimized-collectio.patch b/leaf-server/minecraft-patches/features/0206-Replace-brain-activity-maps-with-optimized-collectio.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0201-Replace-brain-activity-maps-with-optimized-collectio.patch rename to leaf-server/minecraft-patches/features/0206-Replace-brain-activity-maps-with-optimized-collectio.patch diff --git a/leaf-server/minecraft-patches/features/0202-Remove-stream-in-villagers.patch b/leaf-server/minecraft-patches/features/0207-Remove-stream-in-villagers.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0202-Remove-stream-in-villagers.patch rename to leaf-server/minecraft-patches/features/0207-Remove-stream-in-villagers.patch diff --git a/leaf-server/minecraft-patches/features/0203-Optimize-baby-villager-sensor.patch b/leaf-server/minecraft-patches/features/0208-Optimize-baby-villager-sensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0203-Optimize-baby-villager-sensor.patch rename to leaf-server/minecraft-patches/features/0208-Optimize-baby-villager-sensor.patch diff --git a/leaf-server/minecraft-patches/features/0204-Only-player-pushable.patch b/leaf-server/minecraft-patches/features/0209-Only-player-pushable.patch similarity index 96% rename from leaf-server/minecraft-patches/features/0204-Only-player-pushable.patch rename to leaf-server/minecraft-patches/features/0209-Only-player-pushable.patch index bf6543f9..4f83389d 100644 --- a/leaf-server/minecraft-patches/features/0204-Only-player-pushable.patch +++ b/leaf-server/minecraft-patches/features/0209-Only-player-pushable.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Only player pushable Useful for extreme cases like massive entities collide together in a small area diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index dabd49c7b9e689be4b476c16b28cbb8edcd3306b..8461be7c6723925d26f7f162564a18f4aa162089 100644 +index a927e8a7d9149f5b7abaae50ba8d4fdc6ec87b55..0f717ee9e977ece4f30e66d9d1caf6bb7beecda7 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -3635,7 +3635,7 @@ public abstract class LivingEntity extends Entity implements Attackable { @@ -78,7 +78,7 @@ index dabd49c7b9e689be4b476c16b28cbb8edcd3306b..8461be7c6723925d26f7f162564a18f4 AABB aabb = boundingBoxBeforeSpin.minmax(boundingBoxAfterSpin); List entities = this.level().getEntities(this, aabb); diff --git a/net/minecraft/world/entity/decoration/ArmorStand.java b/net/minecraft/world/entity/decoration/ArmorStand.java -index a5a6e4cd74a5444ce06828404036de1728a1a5ce..f6b1c17dbd9999a4d774cf3943c967db46c46f53 100644 +index cb2a8f9cff99a7a906bc7be09d301728742bc11e..f3ef1c11f1f5fe02c0b38f327b527221a5a45b0f 100644 --- a/net/minecraft/world/entity/decoration/ArmorStand.java +++ b/net/minecraft/world/entity/decoration/ArmorStand.java @@ -247,7 +247,7 @@ public class ArmorStand extends LivingEntity { diff --git a/leaf-server/minecraft-patches/features/0205-Remove-iterators-from-Inventory.patch b/leaf-server/minecraft-patches/features/0210-Remove-iterators-from-Inventory.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0205-Remove-iterators-from-Inventory.patch rename to leaf-server/minecraft-patches/features/0210-Remove-iterators-from-Inventory.patch diff --git a/leaf-server/minecraft-patches/features/0206-Alternative-Brain-Behaviour.patch b/leaf-server/minecraft-patches/features/0211-Alternative-Brain-Behaviour.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0206-Alternative-Brain-Behaviour.patch rename to leaf-server/minecraft-patches/features/0211-Alternative-Brain-Behaviour.patch diff --git a/leaf-server/minecraft-patches/features/0207-Cache-eligible-players-for-despawn-checks.patch b/leaf-server/minecraft-patches/features/0212-Cache-eligible-players-for-despawn-checks.patch similarity index 92% rename from leaf-server/minecraft-patches/features/0207-Cache-eligible-players-for-despawn-checks.patch rename to leaf-server/minecraft-patches/features/0212-Cache-eligible-players-for-despawn-checks.patch index 60a0703f..d58b850b 100644 --- a/leaf-server/minecraft-patches/features/0207-Cache-eligible-players-for-despawn-checks.patch +++ b/leaf-server/minecraft-patches/features/0212-Cache-eligible-players-for-despawn-checks.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Cache eligible players for despawn checks diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index 1f3020f5a051d5f4e5c8fa088f844962c3105573..c6eb136e8db0aa232681ac9bd28c4b70fbbacb40 100644 +index ccd6f16e244745ee0702504dbea710485037a3e3..2ecb73fc7b6754ade93bf16b48c623e6b3a955a9 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -723,6 +723,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -725,6 +725,8 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe return this.structureManager; } @@ -17,7 +17,7 @@ index 1f3020f5a051d5f4e5c8fa088f844962c3105573..c6eb136e8db0aa232681ac9bd28c4b70 public void tick(BooleanSupplier hasTimeLeft) { this.handlingTick = true; TickRateManager tickRateManager = this.tickRateManager(); -@@ -790,6 +792,19 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -792,6 +794,19 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } io.papermc.paper.entity.activation.ActivationRange.activateEntities(this); // Paper - EAR @@ -38,10 +38,10 @@ index 1f3020f5a051d5f4e5c8fa088f844962c3105573..c6eb136e8db0aa232681ac9bd28c4b70 .forEach( entity -> { diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index afbac4f2da3aa58da82b9a06d656851f12756f32..f765cc0044282ad592a146773ab93f82fefcebc4 100644 +index e97a93c97e1822f969dce2d30dd915db5d3d14cf..ccd442b24693bc9269cc8ab3e44887d0ad3eadbd 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -1517,6 +1517,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -1519,6 +1519,13 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc this.containerMenu.broadcastChanges(); } diff --git a/leaf-server/minecraft-patches/features/0208-Slightly-optimise-getNearestPlayer.patch b/leaf-server/minecraft-patches/features/0213-Slightly-optimise-getNearestPlayer.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0208-Slightly-optimise-getNearestPlayer.patch rename to leaf-server/minecraft-patches/features/0213-Slightly-optimise-getNearestPlayer.patch diff --git a/leaf-server/minecraft-patches/features/0209-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch b/leaf-server/minecraft-patches/features/0214-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch similarity index 91% rename from leaf-server/minecraft-patches/features/0209-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch rename to leaf-server/minecraft-patches/features/0214-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch index 2a68bfcb..33c1c7e3 100644 --- a/leaf-server/minecraft-patches/features/0209-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch +++ b/leaf-server/minecraft-patches/features/0214-Use-ensureCapacity-to-pre-populate-the-size-of-ticki.patch @@ -6,7 +6,7 @@ Subject: [PATCH] Use ensureCapacity to pre-populate the size of ticking chunks diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index a50fb16dc2e6230d346eea8ee76820ec56906446..4a2ef88cb75f4a10565ed819570b2885942b525c 100644 +index 14b2abc51fa5d2caa56adfaf50784296c5668ae6..0813505f96a1a6bb2cbfb05a97c90241f0c5b1c8 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java @@ -733,6 +733,11 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider diff --git a/leaf-server/minecraft-patches/features/0210-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch b/leaf-server/minecraft-patches/features/0215-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch similarity index 92% rename from leaf-server/minecraft-patches/features/0210-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch rename to leaf-server/minecraft-patches/features/0215-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch index 0527173e..75019207 100644 --- a/leaf-server/minecraft-patches/features/0210-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch +++ b/leaf-server/minecraft-patches/features/0215-Directly-use-the-pre-filtered-ticking-chunks-list-as.patch @@ -7,7 +7,7 @@ Subject: [PATCH] Directly use the pre-filtered ticking chunks list as the This patch uses already pre filtered chunks, which completely skips the isChunkNearPlayer check diff --git a/net/minecraft/server/level/ChunkMap.java b/net/minecraft/server/level/ChunkMap.java -index 4a2ef88cb75f4a10565ed819570b2885942b525c..b94375fb83fab6434060c2f7288dc7a366ed1391 100644 +index 0813505f96a1a6bb2cbfb05a97c90241f0c5b1c8..051d839fece06cac8ad79d8d936237a66cd01ae4 100644 --- a/net/minecraft/server/level/ChunkMap.java +++ b/net/minecraft/server/level/ChunkMap.java @@ -739,13 +739,7 @@ public class ChunkMap extends ChunkStorage implements ChunkHolder.PlayerProvider diff --git a/leaf-server/minecraft-patches/features/0211-Bulk-writes-to-writeLongArray-during-chunk-loading.patch b/leaf-server/minecraft-patches/features/0216-Bulk-writes-to-writeLongArray-during-chunk-loading.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0211-Bulk-writes-to-writeLongArray-during-chunk-loading.patch rename to leaf-server/minecraft-patches/features/0216-Bulk-writes-to-writeLongArray-during-chunk-loading.patch diff --git a/leaf-server/minecraft-patches/features/0212-Improve-sorting-in-SortedArraySet.patch b/leaf-server/minecraft-patches/features/0217-Improve-sorting-in-SortedArraySet.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0212-Improve-sorting-in-SortedArraySet.patch rename to leaf-server/minecraft-patches/features/0217-Improve-sorting-in-SortedArraySet.patch diff --git a/leaf-server/minecraft-patches/features/0213-Make-removeIf-slightly-faster.patch b/leaf-server/minecraft-patches/features/0218-Make-removeIf-slightly-faster.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0213-Make-removeIf-slightly-faster.patch rename to leaf-server/minecraft-patches/features/0218-Make-removeIf-slightly-faster.patch diff --git a/leaf-server/minecraft-patches/features/0214-Optimize-LinearPalette.patch b/leaf-server/minecraft-patches/features/0219-Optimize-LinearPalette.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0214-Optimize-LinearPalette.patch rename to leaf-server/minecraft-patches/features/0219-Optimize-LinearPalette.patch diff --git a/leaf-server/minecraft-patches/features/0215-Slightly-optimized-VarInt-write.patch b/leaf-server/minecraft-patches/features/0220-Slightly-optimized-VarInt-write.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0215-Slightly-optimized-VarInt-write.patch rename to leaf-server/minecraft-patches/features/0220-Slightly-optimized-VarInt-write.patch diff --git a/leaf-server/minecraft-patches/features/0216-Rewrite-ClientboundLightUpdatePacketData.patch b/leaf-server/minecraft-patches/features/0221-Rewrite-ClientboundLightUpdatePacketData.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0216-Rewrite-ClientboundLightUpdatePacketData.patch rename to leaf-server/minecraft-patches/features/0221-Rewrite-ClientboundLightUpdatePacketData.patch diff --git a/leaf-server/minecraft-patches/features/0217-Async-chunk-send.patch b/leaf-server/minecraft-patches/features/0222-Async-chunk-send.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0217-Async-chunk-send.patch rename to leaf-server/minecraft-patches/features/0222-Async-chunk-send.patch diff --git a/leaf-server/minecraft-patches/features/0218-Spawner-Configurations.patch b/leaf-server/minecraft-patches/features/0223-Spawner-Configurations.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0218-Spawner-Configurations.patch rename to leaf-server/minecraft-patches/features/0223-Spawner-Configurations.patch diff --git a/leaf-server/minecraft-patches/features/0219-PaperPR-Fix-cancelled-Projectile-Events-still-consum.patch b/leaf-server/minecraft-patches/features/0224-PaperPR-Fix-cancelled-Projectile-Events-still-consum.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0219-PaperPR-Fix-cancelled-Projectile-Events-still-consum.patch rename to leaf-server/minecraft-patches/features/0224-PaperPR-Fix-cancelled-Projectile-Events-still-consum.patch diff --git a/leaf-server/minecraft-patches/features/0220-Optimize-SetLookAndInteract-and-NearestVisibleLiving.patch b/leaf-server/minecraft-patches/features/0225-Optimize-SetLookAndInteract-and-NearestVisibleLiving.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0220-Optimize-SetLookAndInteract-and-NearestVisibleLiving.patch rename to leaf-server/minecraft-patches/features/0225-Optimize-SetLookAndInteract-and-NearestVisibleLiving.patch diff --git a/leaf-server/minecraft-patches/features/0221-Remove-streams-on-InsideBrownianWalk.patch b/leaf-server/minecraft-patches/features/0226-Remove-streams-on-InsideBrownianWalk.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0221-Remove-streams-on-InsideBrownianWalk.patch rename to leaf-server/minecraft-patches/features/0226-Remove-streams-on-InsideBrownianWalk.patch diff --git a/leaf-server/minecraft-patches/features/0222-Use-BFS-on-getSlopeDistance.patch b/leaf-server/minecraft-patches/features/0227-Use-BFS-on-getSlopeDistance.patch similarity index 98% rename from leaf-server/minecraft-patches/features/0222-Use-BFS-on-getSlopeDistance.patch rename to leaf-server/minecraft-patches/features/0227-Use-BFS-on-getSlopeDistance.patch index 46ad5a98..ddde4245 100644 --- a/leaf-server/minecraft-patches/features/0222-Use-BFS-on-getSlopeDistance.patch +++ b/leaf-server/minecraft-patches/features/0227-Use-BFS-on-getSlopeDistance.patch @@ -9,10 +9,10 @@ Leaf: ~48ms (-36%) This should help drastically on the farms that use actively changing fluids. diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index c6eb136e8db0aa232681ac9bd28c4b70fbbacb40..706e198631e4a3b0a5d2fc3f58060e4a15701ecd 100644 +index 2ecb73fc7b6754ade93bf16b48c623e6b3a955a9..4ecca1bf5ece7788f3de41d5ec58565b8a768251 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -1300,6 +1300,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1302,6 +1302,10 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.emptyTime = 0; } diff --git a/leaf-server/minecraft-patches/features/0223-Paper-PR-Throttle-failed-spawn-attempts.patch b/leaf-server/minecraft-patches/features/0228-Paper-PR-Throttle-failed-spawn-attempts.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0223-Paper-PR-Throttle-failed-spawn-attempts.patch rename to leaf-server/minecraft-patches/features/0228-Paper-PR-Throttle-failed-spawn-attempts.patch diff --git a/leaf-server/minecraft-patches/features/0224-Improve-BlockEntity-ticking-isRemoved-check.patch b/leaf-server/minecraft-patches/features/0229-Improve-BlockEntity-ticking-isRemoved-check.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0224-Improve-BlockEntity-ticking-isRemoved-check.patch rename to leaf-server/minecraft-patches/features/0229-Improve-BlockEntity-ticking-isRemoved-check.patch diff --git a/leaf-server/minecraft-patches/features/0225-Raytrace-AntiXray-SDK-integration.patch b/leaf-server/minecraft-patches/features/0230-Raytrace-AntiXray-SDK-integration.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0225-Raytrace-AntiXray-SDK-integration.patch rename to leaf-server/minecraft-patches/features/0230-Raytrace-AntiXray-SDK-integration.patch diff --git a/leaf-server/minecraft-patches/features/0226-Optimize-addOrUpdateTransientModifier.patch b/leaf-server/minecraft-patches/features/0231-Optimize-addOrUpdateTransientModifier.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0226-Optimize-addOrUpdateTransientModifier.patch rename to leaf-server/minecraft-patches/features/0231-Optimize-addOrUpdateTransientModifier.patch diff --git a/leaf-server/minecraft-patches/features/0227-Optimize-ContextMap.create.patch b/leaf-server/minecraft-patches/features/0232-Optimize-ContextMap.create.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0227-Optimize-ContextMap.create.patch rename to leaf-server/minecraft-patches/features/0232-Optimize-ContextMap.create.patch diff --git a/leaf-server/minecraft-patches/features/0228-Micro-optimizations-for-random-tick.patch b/leaf-server/minecraft-patches/features/0233-Micro-optimizations-for-random-tick.patch similarity index 95% rename from leaf-server/minecraft-patches/features/0228-Micro-optimizations-for-random-tick.patch rename to leaf-server/minecraft-patches/features/0233-Micro-optimizations-for-random-tick.patch index ed3e00ad..c067bfc4 100644 --- a/leaf-server/minecraft-patches/features/0228-Micro-optimizations-for-random-tick.patch +++ b/leaf-server/minecraft-patches/features/0233-Micro-optimizations-for-random-tick.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Micro optimizations for random tick diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index c6eb136e8db0aa232681ac9bd28c4b70fbbacb40..1346cff0018e6d17cb892892c3aeebfb86453b60 100644 +index 4ecca1bf5ece7788f3de41d5ec58565b8a768251..05173104db4c04823658930aa92645f6c2400109 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -903,7 +903,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -905,7 +905,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper start - optimise random ticking private void optimiseRandomTick(final LevelChunk chunk, final int tickSpeed) { final LevelChunkSection[] sections = chunk.getSections(); @@ -17,7 +17,7 @@ index c6eb136e8db0aa232681ac9bd28c4b70fbbacb40..1346cff0018e6d17cb892892c3aeebfb final net.minecraft.world.level.levelgen.BitRandomSource simpleRandom = this.simpleRandom; // Leaf - Faster random generator - upcasting final boolean doubleTickFluids = !ca.spottedleaf.moonrise.common.PlatformHooks.get().configFixMC224294(); -@@ -912,41 +912,41 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -914,41 +914,41 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe final int offsetZ = cpos.z << 4; for (int sectionIndex = 0, sectionsLen = sections.length; sectionIndex < sectionsLen; sectionIndex++) { diff --git a/leaf-server/minecraft-patches/features/0229-Remove-streams-on-updateConnectedPlayersWithinRange.patch b/leaf-server/minecraft-patches/features/0234-Remove-streams-on-updateConnectedPlayersWithinRange.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0229-Remove-streams-on-updateConnectedPlayersWithinRange.patch rename to leaf-server/minecraft-patches/features/0234-Remove-streams-on-updateConnectedPlayersWithinRange.patch diff --git a/leaf-server/minecraft-patches/features/0230-Remove-streams-on-PlayerDetector.patch b/leaf-server/minecraft-patches/features/0235-Remove-streams-on-PlayerDetector.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0230-Remove-streams-on-PlayerDetector.patch rename to leaf-server/minecraft-patches/features/0235-Remove-streams-on-PlayerDetector.patch diff --git a/leaf-server/minecraft-patches/features/0231-Use-direct-iteration-on-Sensing.tick.patch b/leaf-server/minecraft-patches/features/0236-Use-direct-iteration-on-Sensing.tick.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0231-Use-direct-iteration-on-Sensing.tick.patch rename to leaf-server/minecraft-patches/features/0236-Use-direct-iteration-on-Sensing.tick.patch diff --git a/leaf-server/minecraft-patches/features/0232-Optimise-non-flush-packet-sending.patch b/leaf-server/minecraft-patches/features/0237-Optimise-non-flush-packet-sending.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0232-Optimise-non-flush-packet-sending.patch rename to leaf-server/minecraft-patches/features/0237-Optimise-non-flush-packet-sending.patch diff --git a/leaf-server/minecraft-patches/features/0233-Prevent-double-chunk-retrieving-in-entity-fluid-push.patch b/leaf-server/minecraft-patches/features/0238-Prevent-double-chunk-retrieving-in-entity-fluid-push.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0233-Prevent-double-chunk-retrieving-in-entity-fluid-push.patch rename to leaf-server/minecraft-patches/features/0238-Prevent-double-chunk-retrieving-in-entity-fluid-push.patch diff --git a/leaf-server/minecraft-patches/features/0234-Null-handling-on-MultifaceSpreader.patch b/leaf-server/minecraft-patches/features/0239-Null-handling-on-MultifaceSpreader.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0234-Null-handling-on-MultifaceSpreader.patch rename to leaf-server/minecraft-patches/features/0239-Null-handling-on-MultifaceSpreader.patch diff --git a/leaf-server/minecraft-patches/features/0235-More-virtual-threads.patch b/leaf-server/minecraft-patches/features/0240-More-virtual-threads.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0235-More-virtual-threads.patch rename to leaf-server/minecraft-patches/features/0240-More-virtual-threads.patch diff --git a/leaf-server/minecraft-patches/features/0236-Async-target-finding.patch b/leaf-server/minecraft-patches/features/0241-Async-target-finding.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0236-Async-target-finding.patch rename to leaf-server/minecraft-patches/features/0241-Async-target-finding.patch index 2a4f2c28..a560d8ec 100644 --- a/leaf-server/minecraft-patches/features/0236-Async-target-finding.patch +++ b/leaf-server/minecraft-patches/features/0241-Async-target-finding.patch @@ -106,7 +106,7 @@ index 7b686d834e4eb36be5758b0e0a846a70d1e2294b..956d48fb7146b9eb2a5b5b4e23a83f60 final EntityCollectionBySection byType = this.entitiesByType.get(entity.getType()); byType.removeEntity(entity, sectionIndex); diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 508f3c7c1e806576f1faea7975ac9bbe73b1024b..78aee57ad8224b0728411c699d2e3844847c9c79 100644 +index bbd2b327c658b56a1fcf30c8b77cab987d688fcc..f8dba8be5774035744233c251c61abf572dd7d49 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -290,6 +290,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop realPlayers; // Leaves - skip + public final @Nullable org.dreeam.leaf.async.ai.AsyncGoalExecutor asyncGoalExecutor; // Leaf - Async target finding @Override public @Nullable LevelChunk getChunkIfLoaded(int x, int z) { -@@ -330,6 +340,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -331,6 +341,12 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe ((ca.spottedleaf.moonrise.patches.chunk_system.server.ChunkSystemMinecraftServer)this.server).moonrise$executeMidTickTasks(); } @@ -191,10 +191,10 @@ index 1d2c27a7595701895aa3c96339814fd1454a50dd..db3bff36c812a00fc35ebcc6ac6d11ce @Override public final ChunkAccess moonrise$syncLoadNonFull(final int chunkX, final int chunkZ, final net.minecraft.world.level.chunk.status.ChunkStatus status) { return this.moonrise$getChunkTaskScheduler().syncLoadNonFull(chunkX, chunkZ, status); -@@ -691,6 +707,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe - // Paper end - rewrite chunk system +@@ -693,6 +709,13 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe this.getCraftServer().addWorld(this.getWorld()); // CraftBukkit this.preciseTime = this.serverLevelData.getDayTime(); // Purpur - Configurable daylight cycle + this.realPlayers = Lists.newArrayList(); // Leaves - skip + // Leaf start - Async target finding + if (org.dreeam.leaf.config.modules.async.AsyncTargetFinding.enabled) { + this.asyncGoalExecutor = new org.dreeam.leaf.async.ai.AsyncGoalExecutor(server.asyncGoalThread, this); @@ -205,7 +205,7 @@ index 1d2c27a7595701895aa3c96339814fd1454a50dd..db3bff36c812a00fc35ebcc6ac6d11ce } // Paper start -@@ -835,12 +858,14 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -837,12 +860,14 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } this.moonrise$midTickTasks(); // Paper - rewrite chunk system // Gale end - Airplane - remove lambda from ticking guard - copied from guardEntityTick @@ -220,7 +220,7 @@ index 1d2c27a7595701895aa3c96339814fd1454a50dd..db3bff36c812a00fc35ebcc6ac6d11ce } // Paper - rewrite chunk system } -@@ -1316,6 +1341,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1318,6 +1343,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } // Paper end - rewrite chunk system @@ -228,7 +228,7 @@ index 1d2c27a7595701895aa3c96339814fd1454a50dd..db3bff36c812a00fc35ebcc6ac6d11ce } private void tickBlock(BlockPos pos, Block block) { -@@ -1329,6 +1355,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1331,6 +1357,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe } // Paper end - rewrite chunk system diff --git a/leaf-server/minecraft-patches/features/0237-Optimize-ThreadedTicketLevelPropagator.patch b/leaf-server/minecraft-patches/features/0242-Optimize-ThreadedTicketLevelPropagator.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0237-Optimize-ThreadedTicketLevelPropagator.patch rename to leaf-server/minecraft-patches/features/0242-Optimize-ThreadedTicketLevelPropagator.patch diff --git a/leaf-server/minecraft-patches/features/0238-Optimise-MobEffectUtil-getDigSpeedAmplification.patch b/leaf-server/minecraft-patches/features/0243-Optimise-MobEffectUtil-getDigSpeedAmplification.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0238-Optimise-MobEffectUtil-getDigSpeedAmplification.patch rename to leaf-server/minecraft-patches/features/0243-Optimise-MobEffectUtil-getDigSpeedAmplification.patch diff --git a/leaf-server/minecraft-patches/features/0239-Optimise-chunkUnloads.patch b/leaf-server/minecraft-patches/features/0244-Optimise-chunkUnloads.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0239-Optimise-chunkUnloads.patch rename to leaf-server/minecraft-patches/features/0244-Optimise-chunkUnloads.patch diff --git a/leaf-server/minecraft-patches/features/0240-Optimize-BlockEntityType-isValid.patch b/leaf-server/minecraft-patches/features/0245-Optimize-BlockEntityType-isValid.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0240-Optimize-BlockEntityType-isValid.patch rename to leaf-server/minecraft-patches/features/0245-Optimize-BlockEntityType-isValid.patch diff --git a/leaf-server/minecraft-patches/features/0241-PaperPR-Add-ticket-on-player-join-to-avoid-chunk-loa.patch b/leaf-server/minecraft-patches/features/0246-PaperPR-Add-ticket-on-player-join-to-avoid-chunk-loa.patch similarity index 96% rename from leaf-server/minecraft-patches/features/0241-PaperPR-Add-ticket-on-player-join-to-avoid-chunk-loa.patch rename to leaf-server/minecraft-patches/features/0246-PaperPR-Add-ticket-on-player-join-to-avoid-chunk-loa.patch index c68a860e..65d56ee1 100644 --- a/leaf-server/minecraft-patches/features/0241-PaperPR-Add-ticket-on-player-join-to-avoid-chunk-loa.patch +++ b/leaf-server/minecraft-patches/features/0246-PaperPR-Add-ticket-on-player-join-to-avoid-chunk-loa.patch @@ -27,10 +27,10 @@ index 3a78e7512772fd3f7cf8f221e3a72474def14bea..ba52af914e9e231caa0ac50562e9a692 public static final int GENERATED_TICKET_LEVEL = ChunkHolderManager.FULL_LOADED_TICKET_LEVEL; public static final int LOADED_TICKET_LEVEL = ChunkTaskScheduler.getTicketLevel(ChunkStatus.EMPTY); diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 07dafa0e12fd51e4b9e968e22b20f000d04f6dbc..8173242d149709f092e6d609f6e1d831eca0a884 100644 +index 8b1652805a2ac9ebae9c99dd77e81c7a484a7abb..608d4612ed15ec04492b0137ec61e157161d792f 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -330,6 +330,13 @@ public abstract class PlayerList { +@@ -432,6 +432,13 @@ public abstract class PlayerList { // this.broadcastAll(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(player))); // CraftBukkit - replaced with loop below // Paper start - Fire PlayerJoinEvent when Player is actually ready; correctly register player BEFORE PlayerJoinEvent, so the entity is valid and doesn't require tick delay hacks player.supressTrackerForLogin = true; diff --git a/leaf-server/minecraft-patches/features/0242-Sakura-Optimise-check-inside-blocks-and-traverse-blo.patch b/leaf-server/minecraft-patches/features/0247-Sakura-Optimise-check-inside-blocks-and-traverse-blo.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0242-Sakura-Optimise-check-inside-blocks-and-traverse-blo.patch rename to leaf-server/minecraft-patches/features/0247-Sakura-Optimise-check-inside-blocks-and-traverse-blo.patch diff --git a/leaf-server/minecraft-patches/features/0243-Sakura-copy-EntityList-implementation-to-BasicEntity.patch b/leaf-server/minecraft-patches/features/0248-Sakura-copy-EntityList-implementation-to-BasicEntity.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0243-Sakura-copy-EntityList-implementation-to-BasicEntity.patch rename to leaf-server/minecraft-patches/features/0248-Sakura-copy-EntityList-implementation-to-BasicEntity.patch diff --git a/leaf-server/minecraft-patches/features/0244-Protocol-Core.patch b/leaf-server/minecraft-patches/features/0249-Protocol-Core.patch similarity index 74% rename from leaf-server/minecraft-patches/features/0244-Protocol-Core.patch rename to leaf-server/minecraft-patches/features/0249-Protocol-Core.patch index df23ab64..ae2a02fb 100644 --- a/leaf-server/minecraft-patches/features/0244-Protocol-Core.patch +++ b/leaf-server/minecraft-patches/features/0249-Protocol-Core.patch @@ -5,13 +5,13 @@ Subject: [PATCH] Protocol Core diff --git a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java -index fb263fa1f30a7dfcb7ec2656abfb38e5fe88eac9..a5f4deff8ecde365b7fbec92760b1a7cc5b8c58e 100644 +index 56fd1ed7ccaf96e7eedea60fbdbf7f934939d563..d2f522ea6d0a209496848af073c9af1c45d6b6ce 100644 --- a/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java +++ b/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java -@@ -40,6 +40,12 @@ public interface CustomPacketPayload { - - @Override - public void encode(B buffer, CustomPacketPayload value) { +@@ -46,6 +46,12 @@ public interface CustomPacketPayload { + return; + } + // Leaves end - protocol core + // Leaf start - Protocol core + if (value instanceof org.dreeam.leaf.protocol.LeafCustomPayload payload) { + org.dreeam.leaf.protocol.Protocols.write(buffer, payload); @@ -22,18 +22,17 @@ index fb263fa1f30a7dfcb7ec2656abfb38e5fe88eac9..a5f4deff8ecde365b7fbec92760b1a7c } diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 78aee57ad8224b0728411c699d2e3844847c9c79..8f5b400bdf5c1c194f75ee98e2f1e984e6137a50 100644 +index f8dba8be5774035744233c251c61abf572dd7d49..2ca484a6c3e75fd392ca953737bb548ab10f2121 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java -@@ -1770,6 +1770,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop mountedOrDismounted(List entities) { diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index f765cc0044282ad592a146773ab93f82fefcebc4..4a611930d8b153f60611275b2b5acacf26add509 100644 +index ccd442b24693bc9269cc8ab3e44887d0ad3eadbd..aee177756afebd3f39917ae8a08bbbd0e2efe4df 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -801,6 +801,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -803,6 +803,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc } } // Purpur end - Ridables @@ -59,10 +58,10 @@ index f765cc0044282ad592a146773ab93f82fefcebc4..4a611930d8b153f60611275b2b5acacf private void updatePlayerAttributes() { diff --git a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -index 434be9d08d8e816e2dea1e9d23fa26d21b9f35f6..98f169c64b31ff523fe8b2d435f796a5156203a9 100644 +index 18f0d486c478087f404d8bb6cd840079e2c8d239..1a6f1c5f4cf13ee50bc8445845cbb973c3f4a07d 100644 --- a/net/minecraft/server/network/ServerCommonPacketListenerImpl.java +++ b/net/minecraft/server/network/ServerCommonPacketListenerImpl.java -@@ -162,6 +162,8 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack +@@ -174,6 +174,8 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack PacketUtils.ensureRunningOnSameThread(packet, this, this.player.serverLevel()); @@ -72,13 +71,13 @@ index 434be9d08d8e816e2dea1e9d23fa26d21b9f35f6..98f169c64b31ff523fe8b2d435f796a5 final byte[] data = discardedPayload.data(); try { diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java -index 8173242d149709f092e6d609f6e1d831eca0a884..05bc165ecae4151355dd9329673f10cff6253ca4 100644 +index 608d4612ed15ec04492b0137ec61e157161d792f..7802f33f4259e9df0b2e682dd2e6bb8f6f74f25b 100644 --- a/net/minecraft/server/players/PlayerList.java +++ b/net/minecraft/server/players/PlayerList.java -@@ -536,6 +536,7 @@ public abstract class PlayerList { - return this.remove(player, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? player.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(player.getDisplayName()))); +@@ -684,6 +684,7 @@ public abstract class PlayerList { } public @Nullable net.kyori.adventure.text.Component remove(ServerPlayer player, net.kyori.adventure.text.Component leaveMessage) { + org.leavesmc.leaves.protocol.core.LeavesProtocolManager.handlePlayerLeave(player); // Leaves - protocol + org.dreeam.leaf.protocol.Protocols.disconnected(player); // Leaf - Protocol core // Paper end - Fix kick event leave message not being sent org.purpurmc.purpur.task.BossBarTask.removeFromAll(player.getBukkitEntity()); // Purpur - Implement TPSBar diff --git a/leaf-server/minecraft-patches/features/0245-Reduce-PlayerChunk-Updates.patch b/leaf-server/minecraft-patches/features/0250-Reduce-PlayerChunk-Updates.patch similarity index 89% rename from leaf-server/minecraft-patches/features/0245-Reduce-PlayerChunk-Updates.patch rename to leaf-server/minecraft-patches/features/0250-Reduce-PlayerChunk-Updates.patch index 5d4b6b9e..f91f9bee 100644 --- a/leaf-server/minecraft-patches/features/0245-Reduce-PlayerChunk-Updates.patch +++ b/leaf-server/minecraft-patches/features/0250-Reduce-PlayerChunk-Updates.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Reduce PlayerChunk Updates diff --git a/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -index 6992a53abdcff6299bedf33ba0b1bc6386a1ea74..b89b6c5affd0a84f56756d9c5e92fe176c41061b 100644 +index c91348eea1350728d8f6de7b8c3613cb44b5cdec..b260211fcf0dbe0d300a7c9769e6cd327e4555ab 100644 --- a/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/net/minecraft/server/network/ServerGamePacketListenerImpl.java -@@ -1418,6 +1418,8 @@ public class ServerGamePacketListenerImpl +@@ -1421,6 +1421,8 @@ public class ServerGamePacketListenerImpl this.resetPosition(); } @@ -17,7 +17,7 @@ index 6992a53abdcff6299bedf33ba0b1bc6386a1ea74..b89b6c5affd0a84f56756d9c5e92fe17 if (this.player.hasClientLoaded()) { float f = Mth.wrapDegrees(packet.getYRot(this.player.getYRot())); final float toYaw = f; // Paper - OBFHELPER float f1 = Mth.wrapDegrees(packet.getXRot(this.player.getXRot())); final float toPitch = f1; // Paper - OBFHELPER -@@ -1696,7 +1698,7 @@ public class ServerGamePacketListenerImpl +@@ -1699,7 +1701,7 @@ public class ServerGamePacketListenerImpl && !isFallFlying && !isAutoSpinAttack && this.noBlocksAround(this.player); diff --git a/leaf-server/minecraft-patches/features/0246-Async-switch-connection-state.patch b/leaf-server/minecraft-patches/features/0251-Async-switch-connection-state.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0246-Async-switch-connection-state.patch rename to leaf-server/minecraft-patches/features/0251-Async-switch-connection-state.patch diff --git a/leaf-server/minecraft-patches/features/0247-Optimise-BlockEntities-tickersInLevel.patch b/leaf-server/minecraft-patches/features/0252-Optimise-BlockEntities-tickersInLevel.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0247-Optimise-BlockEntities-tickersInLevel.patch rename to leaf-server/minecraft-patches/features/0252-Optimise-BlockEntities-tickersInLevel.patch diff --git a/leaf-server/minecraft-patches/features/0248-Pluto-Check-if-the-cactus-can-even-survive-being-pla.patch b/leaf-server/minecraft-patches/features/0253-Pluto-Check-if-the-cactus-can-even-survive-being-pla.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0248-Pluto-Check-if-the-cactus-can-even-survive-being-pla.patch rename to leaf-server/minecraft-patches/features/0253-Pluto-Check-if-the-cactus-can-even-survive-being-pla.patch diff --git a/leaf-server/minecraft-patches/features/0249-Flush-location-while-knockback.patch b/leaf-server/minecraft-patches/features/0254-Flush-location-while-knockback.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0249-Flush-location-while-knockback.patch rename to leaf-server/minecraft-patches/features/0254-Flush-location-while-knockback.patch diff --git a/leaf-server/minecraft-patches/features/0250-Only-tick-items-at-hand.patch b/leaf-server/minecraft-patches/features/0255-Only-tick-items-at-hand.patch similarity index 93% rename from leaf-server/minecraft-patches/features/0250-Only-tick-items-at-hand.patch rename to leaf-server/minecraft-patches/features/0255-Only-tick-items-at-hand.patch index 78b23092..ac15f030 100644 --- a/leaf-server/minecraft-patches/features/0250-Only-tick-items-at-hand.patch +++ b/leaf-server/minecraft-patches/features/0255-Only-tick-items-at-hand.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Only tick items at hand diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 4a611930d8b153f60611275b2b5acacf26add509..487d3f1856ac9a0977bbc3a2c54cd1e85328ad73 100644 +index aee177756afebd3f39917ae8a08bbbd0e2efe4df..b4e5405a3b48cc18d2dac264c5bb7ff666ad2e22 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -830,12 +830,19 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -832,12 +832,19 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc super.tick(); } diff --git a/leaf-server/minecraft-patches/features/0251-Smart-sort-items-in-NearestItemSensor.patch b/leaf-server/minecraft-patches/features/0256-Smart-sort-items-in-NearestItemSensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0251-Smart-sort-items-in-NearestItemSensor.patch rename to leaf-server/minecraft-patches/features/0256-Smart-sort-items-in-NearestItemSensor.patch diff --git a/leaf-server/minecraft-patches/features/0252-Optimise-player-movement-checks.patch b/leaf-server/minecraft-patches/features/0257-Optimise-player-movement-checks.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0252-Optimise-player-movement-checks.patch rename to leaf-server/minecraft-patches/features/0257-Optimise-player-movement-checks.patch diff --git a/leaf-server/minecraft-patches/features/0253-Remove-streams-in-MobSensor.patch b/leaf-server/minecraft-patches/features/0258-Remove-streams-in-MobSensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0253-Remove-streams-in-MobSensor.patch rename to leaf-server/minecraft-patches/features/0258-Remove-streams-in-MobSensor.patch diff --git a/leaf-server/minecraft-patches/features/0254-Remove-streams-in-TemptingSensor.patch b/leaf-server/minecraft-patches/features/0259-Remove-streams-in-TemptingSensor.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0254-Remove-streams-in-TemptingSensor.patch rename to leaf-server/minecraft-patches/features/0259-Remove-streams-in-TemptingSensor.patch diff --git a/leaf-server/minecraft-patches/features/0255-Use-HashedList-on-WeightedList.patch b/leaf-server/minecraft-patches/features/0260-Use-HashedList-on-WeightedList.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0255-Use-HashedList-on-WeightedList.patch rename to leaf-server/minecraft-patches/features/0260-Use-HashedList-on-WeightedList.patch diff --git a/leaf-server/minecraft-patches/features/0256-Add-configurable-death-item-drop-knockback-settings.patch b/leaf-server/minecraft-patches/features/0261-Add-configurable-death-item-drop-knockback-settings.patch similarity index 90% rename from leaf-server/minecraft-patches/features/0256-Add-configurable-death-item-drop-knockback-settings.patch rename to leaf-server/minecraft-patches/features/0261-Add-configurable-death-item-drop-knockback-settings.patch index 99a8a11e..d98419dd 100644 --- a/leaf-server/minecraft-patches/features/0256-Add-configurable-death-item-drop-knockback-settings.patch +++ b/leaf-server/minecraft-patches/features/0261-Add-configurable-death-item-drop-knockback-settings.patch @@ -5,10 +5,10 @@ Subject: [PATCH] Add configurable death item drop knockback settings diff --git a/net/minecraft/server/level/ServerPlayer.java b/net/minecraft/server/level/ServerPlayer.java -index 487d3f1856ac9a0977bbc3a2c54cd1e85328ad73..432362df2401ec5d05f80fea7756befd7f30e6d4 100644 +index b4e5405a3b48cc18d2dac264c5bb7ff666ad2e22..2a4fb4de12409166e9463eacafb13e37760a3a1b 100644 --- a/net/minecraft/server/level/ServerPlayer.java +++ b/net/minecraft/server/level/ServerPlayer.java -@@ -1049,7 +1049,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc +@@ -1051,7 +1051,7 @@ public class ServerPlayer extends Player implements ca.spottedleaf.moonrise.patc if (!keepInventory) { for (ItemStack item : this.getInventory().getContents()) { if (!item.isEmpty() && !EnchantmentHelper.has(item, net.minecraft.world.item.enchantment.EnchantmentEffectComponents.PREVENT_EQUIPMENT_DROP)) { @@ -18,7 +18,7 @@ index 487d3f1856ac9a0977bbc3a2c54cd1e85328ad73..432362df2401ec5d05f80fea7756befd } } diff --git a/net/minecraft/world/entity/LivingEntity.java b/net/minecraft/world/entity/LivingEntity.java -index c46bc07e6bd8f121bb6df922408a931ab01ce2ca..ebe8b4c51152e691322571750949e13a986ea7a5 100644 +index 0f717ee9e977ece4f30e66d9d1caf6bb7beecda7..620ddc31b4ff91713aaa6f4c54998ea66670951d 100644 --- a/net/minecraft/world/entity/LivingEntity.java +++ b/net/minecraft/world/entity/LivingEntity.java @@ -4088,9 +4088,9 @@ public abstract class LivingEntity extends Entity implements Attackable { diff --git a/leaf-server/minecraft-patches/features/0257-Optimize-getScaledTrackingDistance.patch b/leaf-server/minecraft-patches/features/0262-Optimize-getScaledTrackingDistance.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0257-Optimize-getScaledTrackingDistance.patch rename to leaf-server/minecraft-patches/features/0262-Optimize-getScaledTrackingDistance.patch diff --git a/leaf-server/minecraft-patches/features/0258-Optimize-SynchedEntityData-packDirty.patch b/leaf-server/minecraft-patches/features/0263-Optimize-SynchedEntityData-packDirty.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0258-Optimize-SynchedEntityData-packDirty.patch rename to leaf-server/minecraft-patches/features/0263-Optimize-SynchedEntityData-packDirty.patch diff --git a/leaf-server/minecraft-patches/features/0259-Optimize-isEyeInFluid.patch b/leaf-server/minecraft-patches/features/0264-Optimize-isEyeInFluid.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0259-Optimize-isEyeInFluid.patch rename to leaf-server/minecraft-patches/features/0264-Optimize-isEyeInFluid.patch diff --git a/leaf-server/minecraft-patches/features/0260-Paw-optimization.patch b/leaf-server/minecraft-patches/features/0265-Paw-optimization.patch similarity index 98% rename from leaf-server/minecraft-patches/features/0260-Paw-optimization.patch rename to leaf-server/minecraft-patches/features/0265-Paw-optimization.patch index d8448158..8ae61256 100644 --- a/leaf-server/minecraft-patches/features/0260-Paw-optimization.patch +++ b/leaf-server/minecraft-patches/features/0265-Paw-optimization.patch @@ -94,10 +94,10 @@ index 0f9d18dd29e210ad656da211a3cb1cb25cd4efb1..d1c36cd17c83e7e0167046093c4a2b84 for (LevelChunk levelChunk : list) { diff --git a/net/minecraft/server/level/ServerLevel.java b/net/minecraft/server/level/ServerLevel.java -index db3bff36c812a00fc35ebcc6ac6d11ce24040003..e8706189de80a2f0e60882fff0fe891165050f38 100644 +index e0fdf7205ff1dfab2c5cccd3d18c2b22deda686a..9df599e94e17da12a880df2f40a2117c5ec2a569 100644 --- a/net/minecraft/server/level/ServerLevel.java +++ b/net/minecraft/server/level/ServerLevel.java -@@ -1371,13 +1371,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1373,13 +1373,7 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe // Paper end - log detailed entity tick information public void tickNonPassenger(Entity entity) { @@ -111,7 +111,7 @@ index db3bff36c812a00fc35ebcc6ac6d11ce24040003..e8706189de80a2f0e60882fff0fe8911 entity.setOldPosAndRot(); entity.tickCount++; entity.totalEntityAge++; // Paper - age-like counter for all entities -@@ -1390,13 +1384,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe +@@ -1392,13 +1386,6 @@ public class ServerLevel extends Level implements ServerEntityGetter, WorldGenLe for (Entity entity1 : entity.getPassengers()) { this.tickPassenger(entity, entity1, isActive); // Paper - EAR 2 } diff --git a/leaf-server/minecraft-patches/features/0261-Cache-block-path-type.patch b/leaf-server/minecraft-patches/features/0266-Cache-block-path-type.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0261-Cache-block-path-type.patch rename to leaf-server/minecraft-patches/features/0266-Cache-block-path-type.patch diff --git a/leaf-server/minecraft-patches/features/0262-optimize-getEntityStatus.patch b/leaf-server/minecraft-patches/features/0267-optimize-getEntityStatus.patch similarity index 100% rename from leaf-server/minecraft-patches/features/0262-optimize-getEntityStatus.patch rename to leaf-server/minecraft-patches/features/0267-optimize-getEntityStatus.patch diff --git a/leaf-server/minecraft-patches/features/0263-Paper-Rewrite-dataconverter-system.patch b/leaf-server/minecraft-patches/features/0268-Paper-Rewrite-dataconverter-system.patch similarity index 99% rename from leaf-server/minecraft-patches/features/0263-Paper-Rewrite-dataconverter-system.patch rename to leaf-server/minecraft-patches/features/0268-Paper-Rewrite-dataconverter-system.patch index 81ccebe7..2db0fc97 100644 --- a/leaf-server/minecraft-patches/features/0263-Paper-Rewrite-dataconverter-system.patch +++ b/leaf-server/minecraft-patches/features/0268-Paper-Rewrite-dataconverter-system.patch @@ -33075,7 +33075,7 @@ index 175647d57e59e838ea7b4680fbf22c161100c513..a7b772cfc89161414469cd7da374d6c7 return structureTemplate.save(new CompoundTag()); } diff --git a/net/minecraft/server/MinecraftServer.java b/net/minecraft/server/MinecraftServer.java -index 8f5b400bdf5c1c194f75ee98e2f1e984e6137a50..40f82c3772af7f42970a473a08316410fcd3023c 100644 +index 2ca484a6c3e75fd392ca953737bb548ab10f2121..1540b1a571c8f44c4163f4720a9279f87a8032c9 100644 --- a/net/minecraft/server/MinecraftServer.java +++ b/net/minecraft/server/MinecraftServer.java @@ -293,6 +293,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop set = new java.util.HashSet<>(tracker.seenBy.size()); @@ -72,7 +72,7 @@ index 2a63e8e725fa97da5d4b9fba6bfe19377c7cfbe1..0c286eabd8e4d5e599d93a151874af6b } return set; diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java -index cab15624afaeaca5d69206a0b7fff5da54e5ef29..4533fbbbc35ed92177f7704f243a1614a1773ca1 100644 +index 16d836614cea2599a6252bcec8301bd76582328e..ee113efb74d24a0c70c0e189694b1d5d3bd2aaa9 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -2892,7 +2892,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { diff --git a/leaf-server/paper-patches/features/0043-Asynchronous-locator.patch b/leaf-server/paper-patches/features/0045-Asynchronous-locator.patch similarity index 93% rename from leaf-server/paper-patches/features/0043-Asynchronous-locator.patch rename to leaf-server/paper-patches/features/0045-Asynchronous-locator.patch index 4418c7a9..cd3b7ec8 100644 --- a/leaf-server/paper-patches/features/0043-Asynchronous-locator.patch +++ b/leaf-server/paper-patches/features/0045-Asynchronous-locator.patch @@ -24,7 +24,7 @@ index 69cdd304d255d52c9b7dc9b6a33ffdb630b79abe..a4aa2615823d77920ff55b8aa0bcc27a this(group, run, name, ID_GENERATOR.incrementAndGet()); } diff --git a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java -index 84905d7802f8a5c3f68e15f1b17ef08216ad1f4e..196fddeab452e7bc89ef6758635e1d07074e7416 100644 +index 361f4de9cdf0f7505628a2fed2a3f5366031e04b..548fcd9646dee0c40b6ba9b3dafb9ca157dfe324 100644 --- a/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java +++ b/src/main/java/io/papermc/paper/plugin/manager/PaperEventManager.java @@ -48,6 +48,12 @@ class PaperEventManager { @@ -39,4 +39,4 @@ index 84905d7802f8a5c3f68e15f1b17ef08216ad1f4e..196fddeab452e7bc89ef6758635e1d07 + // Leaf end - Asynchronous locator throw new IllegalStateException(event.getEventName() + " may only be triggered synchronously."); } - + // Leaves start - skip photographer diff --git a/leaf-server/paper-patches/features/0044-EMC-Don-t-use-snapshots-for-acquiring-blockstate.patch b/leaf-server/paper-patches/features/0046-EMC-Don-t-use-snapshots-for-acquiring-blockstate.patch similarity index 94% rename from leaf-server/paper-patches/features/0044-EMC-Don-t-use-snapshots-for-acquiring-blockstate.patch rename to leaf-server/paper-patches/features/0046-EMC-Don-t-use-snapshots-for-acquiring-blockstate.patch index 6114b45d..2289148c 100644 --- a/leaf-server/paper-patches/features/0044-EMC-Don-t-use-snapshots-for-acquiring-blockstate.patch +++ b/leaf-server/paper-patches/features/0046-EMC-Don-t-use-snapshots-for-acquiring-blockstate.patch @@ -7,7 +7,7 @@ Original license: MIT Original project: https://github.com/starlis/empirecraft diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java -index bbaaea8e03e3eb80c53161968ff75efd39b57ba5..5f04b2dcff7c0e967647bde9dfa0f35f59e8524c 100644 +index a4d5c65edc1db59f3486ce5d3757cc306211a54b..b00a82816784ea2f6422ca98c1f11597105cc177 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftBlock.java @@ -332,7 +332,7 @@ public class CraftBlock implements Block { diff --git a/leaf-server/paper-patches/features/0045-Faster-CraftServer-getworlds-list-creation.patch b/leaf-server/paper-patches/features/0047-Faster-CraftServer-getworlds-list-creation.patch similarity index 85% rename from leaf-server/paper-patches/features/0045-Faster-CraftServer-getworlds-list-creation.patch rename to leaf-server/paper-patches/features/0047-Faster-CraftServer-getworlds-list-creation.patch index 8828e5da..2c1d0203 100644 --- a/leaf-server/paper-patches/features/0045-Faster-CraftServer-getworlds-list-creation.patch +++ b/leaf-server/paper-patches/features/0047-Faster-CraftServer-getworlds-list-creation.patch @@ -8,10 +8,10 @@ replacing ArrayList with Fastutil ObjectArrayList brings about 40% performance improvement in benchmark. diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -index 828f454c73f042610940cbe62cc7ed1ae8294e9b..80ea506bacb206dabb6d12aeea1cc2000f8ea4b7 100644 +index b71edea2c1126bc558f2a803cdf4dd46677a16fc..20542041202bf7589f0246ae172c6801b335b75c 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java -@@ -977,7 +977,7 @@ public final class CraftServer implements Server { +@@ -979,7 +979,7 @@ public final class CraftServer implements Server { @Override public List getWorlds() { diff --git a/leaf-server/paper-patches/features/0046-Cache-chunk-key.patch b/leaf-server/paper-patches/features/0048-Cache-chunk-key.patch similarity index 100% rename from leaf-server/paper-patches/features/0046-Cache-chunk-key.patch rename to leaf-server/paper-patches/features/0048-Cache-chunk-key.patch diff --git a/leaf-server/paper-patches/features/0047-Async-structure-locate-api.patch b/leaf-server/paper-patches/features/0049-Async-structure-locate-api.patch similarity index 97% rename from leaf-server/paper-patches/features/0047-Async-structure-locate-api.patch rename to leaf-server/paper-patches/features/0049-Async-structure-locate-api.patch index def10a86..1306b955 100644 --- a/leaf-server/paper-patches/features/0047-Async-structure-locate-api.patch +++ b/leaf-server/paper-patches/features/0049-Async-structure-locate-api.patch @@ -9,7 +9,7 @@ Added some asynchronous structure locate methods in World, requires async-locator to be enabled in Leaf config, or else it will fall back to sync methods. diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java -index 28ece1167907558c21d292cb36960a026d0c0897..7d0874e3a4da1bfce80a83635c904c7d257c276b 100644 +index 0ea7df63498492e320f98ddec5bdf33b203cc770..0d2cfaef1413a343bc03829730453b03f903d5ce 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -2277,6 +2277,45 @@ public class CraftWorld extends CraftRegionAccessor implements World { diff --git a/leaf-server/paper-patches/features/0048-PlayerInventoryOverflowEvent.patch b/leaf-server/paper-patches/features/0050-PlayerInventoryOverflowEvent.patch similarity index 100% rename from leaf-server/paper-patches/features/0048-PlayerInventoryOverflowEvent.patch rename to leaf-server/paper-patches/features/0050-PlayerInventoryOverflowEvent.patch diff --git a/leaf-server/paper-patches/features/0049-Paper-PR-Throttle-failed-spawn-attempts.patch b/leaf-server/paper-patches/features/0051-Paper-PR-Throttle-failed-spawn-attempts.patch similarity index 96% rename from leaf-server/paper-patches/features/0049-Paper-PR-Throttle-failed-spawn-attempts.patch rename to leaf-server/paper-patches/features/0051-Paper-PR-Throttle-failed-spawn-attempts.patch index b454b21b..45286aed 100644 --- a/leaf-server/paper-patches/features/0049-Paper-PR-Throttle-failed-spawn-attempts.patch +++ b/leaf-server/paper-patches/features/0051-Paper-PR-Throttle-failed-spawn-attempts.patch @@ -31,7 +31,7 @@ vain. Throttling spawn attempts in suspected spawnproof chunks improves performance without noticeably advantaging or disadvantaging the mob farm. diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java -index 65f6839fe75340a4b58894ad50c6eda7b59128c0..f7610c709bd6f9e30ec7b1295d58dfbe98fc8661 100644 +index 9511f978f6c7da506f67928f5a5a92ecf28e5930..6c298304f842612d0e063b578f274eed04b32960 100644 --- a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java +++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java @@ -182,6 +182,17 @@ public class WorldConfiguration extends ConfigurationPart { diff --git a/leaf-server/paper-patches/features/0050-Async-playerdata-saving.patch b/leaf-server/paper-patches/features/0052-Async-playerdata-saving.patch similarity index 100% rename from leaf-server/paper-patches/features/0050-Async-playerdata-saving.patch rename to leaf-server/paper-patches/features/0052-Async-playerdata-saving.patch diff --git a/leaf-server/paper-patches/features/0051-Async-chunk-send.patch b/leaf-server/paper-patches/features/0053-Async-chunk-send.patch similarity index 100% rename from leaf-server/paper-patches/features/0051-Async-chunk-send.patch rename to leaf-server/paper-patches/features/0053-Async-chunk-send.patch diff --git a/leaf-server/paper-patches/features/0052-Optimise-player-movement-checks.patch b/leaf-server/paper-patches/features/0054-Optimise-player-movement-checks.patch similarity index 100% rename from leaf-server/paper-patches/features/0052-Optimise-player-movement-checks.patch rename to leaf-server/paper-patches/features/0054-Optimise-player-movement-checks.patch diff --git a/leaf-server/paper-patches/features/0053-Paw-optimization.patch b/leaf-server/paper-patches/features/0055-Paw-optimization.patch similarity index 100% rename from leaf-server/paper-patches/features/0053-Paw-optimization.patch rename to leaf-server/paper-patches/features/0055-Paw-optimization.patch diff --git a/leaf-server/paper-patches/features/0054-optimise-ReferenceList.patch b/leaf-server/paper-patches/features/0056-optimise-ReferenceList.patch similarity index 100% rename from leaf-server/paper-patches/features/0054-optimise-ReferenceList.patch rename to leaf-server/paper-patches/features/0056-optimise-ReferenceList.patch diff --git a/leaf-archived-patches/unapplied/src/main/java/org/dreeam/leaf/config/modules/network/ProtocolSupport.java b/leaf-server/src/main/java/org/dreeam/leaf/config/modules/network/ProtocolSupport.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/dreeam/leaf/config/modules/network/ProtocolSupport.java rename to leaf-server/src/main/java/org/dreeam/leaf/config/modules/network/ProtocolSupport.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/LeavesLogger.java b/leaf-server/src/main/java/org/leavesmc/leaves/LeavesLogger.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/LeavesLogger.java rename to leaf-server/src/main/java/org/leavesmc/leaves/LeavesLogger.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java b/leaf-server/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java rename to leaf-server/src/main/java/org/leavesmc/leaves/bot/BotStatsCounter.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/entity/CraftPhotographer.java b/leaf-server/src/main/java/org/leavesmc/leaves/entity/CraftPhotographer.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/entity/CraftPhotographer.java rename to leaf-server/src/main/java/org/leavesmc/leaves/entity/CraftPhotographer.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/entity/CraftPhotographerManager.java b/leaf-server/src/main/java/org/leavesmc/leaves/entity/CraftPhotographerManager.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/entity/CraftPhotographerManager.java rename to leaf-server/src/main/java/org/leavesmc/leaves/entity/CraftPhotographerManager.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java similarity index 81% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java index d9ae61b8..939b4f19 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java @@ -5,6 +5,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.food.FoodData; import net.minecraft.world.level.GameRules; +import org.dreeam.leaf.config.modules.network.ProtocolSupport; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.core.LeavesProtocol; @@ -16,8 +17,8 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; -@LeavesProtocol(namespace = "appleskin") -public class AppleSkinProtocol { +@LeavesProtocol.Register(namespace = "appleskin") +public class AppleSkinProtocol implements LeavesProtocol { public static final String PROTOCOL_ID = "appleskin"; @@ -33,10 +34,6 @@ public class AppleSkinProtocol { private static final Map> subscribedChannels = new HashMap<>(); - public static boolean shouldEnable() { - return org.dreeam.leaf.config.modules.network.ProtocolSupport.appleskinProtocol; - } - @Contract("_ -> new") public static ResourceLocation id(String path) { return ResourceLocation.tryBuild(PROTOCOL_ID, path); @@ -53,19 +50,13 @@ public class AppleSkinProtocol { resetPlayerData(player); } - @ProtocolHandler.MinecraftRegister(ignoreId = true) - public static void onPlayerSubscribed(@NotNull ServerPlayer player, String channel) { - if (org.dreeam.leaf.config.modules.network.ProtocolSupport.appleskinProtocol) { - subscribedChannels.computeIfAbsent(player, k -> new HashSet<>()).add(channel); - } + @ProtocolHandler.MinecraftRegister(onlyNamespace = true) + public static void onPlayerSubscribed(@NotNull ServerPlayer player, ResourceLocation id) { + subscribedChannels.computeIfAbsent(player, k -> new HashSet<>()).add(id.getPath()); } @ProtocolHandler.Ticker public static void tick() { - if (MinecraftServer.getServer().getTickCount() % org.dreeam.leaf.config.modules.network.ProtocolSupport.appleskinSyncTickInterval != 0) { - return; - } - for (Map.Entry> entry : subscribedChannels.entrySet()) { ServerPlayer player = entry.getKey(); FoodData data = player.getFoodData(); @@ -76,7 +67,7 @@ public class AppleSkinProtocol { float saturation = data.getSaturationLevel(); Float previousSaturation = previousSaturationLevels.get(player); if (previousSaturation == null || saturation != previousSaturation) { - ProtocolUtils.sendPayloadPacket(player, SATURATION_KEY, buf -> buf.writeFloat(saturation)); + ProtocolUtils.sendBytebufPacket(player, SATURATION_KEY, buf -> buf.writeFloat(saturation)); previousSaturationLevels.put(player, saturation); } } @@ -85,7 +76,7 @@ public class AppleSkinProtocol { float exhaustion = data.exhaustionLevel; Float previousExhaustion = previousExhaustionLevels.get(player); if (previousExhaustion == null || Math.abs(exhaustion - previousExhaustion) >= MINIMUM_EXHAUSTION_CHANGE_THRESHOLD) { - ProtocolUtils.sendPayloadPacket(player, EXHAUSTION_KEY, buf -> buf.writeFloat(exhaustion)); + ProtocolUtils.sendBytebufPacket(player, EXHAUSTION_KEY, buf -> buf.writeFloat(exhaustion)); previousExhaustionLevels.put(player, exhaustion); } } @@ -94,7 +85,7 @@ public class AppleSkinProtocol { boolean regeneration = player.serverLevel().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION); Boolean previousRegeneration = previousNaturalRegeneration.get(player); if (previousRegeneration == null || regeneration != previousRegeneration) { - ProtocolUtils.sendPayloadPacket(player, NATURAL_REGENERATION_KEY, buf -> buf.writeBoolean(regeneration)); + ProtocolUtils.sendBytebufPacket(player, NATURAL_REGENERATION_KEY, buf -> buf.writeBoolean(regeneration)); previousNaturalRegeneration.put(player, regeneration); } } @@ -105,9 +96,7 @@ public class AppleSkinProtocol { @ProtocolHandler.ReloadServer public static void onServerReload() { - if (!org.dreeam.leaf.config.modules.network.ProtocolSupport.appleskinProtocol) { - disableAllPlayer(); - } + disableAllPlayer(); } public static void disableAllPlayer() { @@ -121,4 +110,14 @@ public class AppleSkinProtocol { previousSaturationLevels.remove(player); previousNaturalRegeneration.remove(player); } + + @Override + public int tickerInterval(String tickerID) { + return ProtocolSupport.appleskinSyncTickInterval; + } + + @Override + public boolean isActive() { + return ProtocolSupport.appleskinProtocol; + } } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/AsteorBarProtocol.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/AsteorBarProtocol.java similarity index 87% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/AsteorBarProtocol.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/AsteorBarProtocol.java index f7f43eac..3be7a325 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/AsteorBarProtocol.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/AsteorBarProtocol.java @@ -4,6 +4,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.food.FoodData; +import org.dreeam.leaf.config.modules.network.ProtocolSupport; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.core.LeavesProtocol; @@ -16,8 +17,8 @@ import java.util.Map; import java.util.Set; import java.util.UUID; -@LeavesProtocol(namespace = "asteorbar") -public class AsteorBarProtocol { +@LeavesProtocol.Register(namespace = "asteorbar") +public class AsteorBarProtocol implements LeavesProtocol { public static final String PROTOCOL_ID = "asteorbar"; @@ -30,10 +31,6 @@ public class AsteorBarProtocol { private static final Set players = new HashSet<>(); - public static boolean shouldEnable() { - return org.dreeam.leaf.config.modules.network.ProtocolSupport.asteorBarProtocol; - } - @Contract("_ -> new") public static @NotNull ResourceLocation id(String path) { return ResourceLocation.fromNamespaceAndPath(PROTOCOL_ID, path); @@ -50,7 +47,7 @@ public class AsteorBarProtocol { resetPlayerData(player); } - @ProtocolHandler.MinecraftRegister(ignoreId = true) + @ProtocolHandler.MinecraftRegister(onlyNamespace = true) public static void onPlayerSubscribed(@NotNull ServerPlayer player) { players.add(player); } @@ -63,7 +60,7 @@ public class AsteorBarProtocol { float saturation = data.getSaturationLevel(); Float previousSaturation = previousSaturationLevels.get(player.getUUID()); if (previousSaturation == null || saturation != previousSaturation) { - ProtocolUtils.sendPayloadPacket(player, NETWORK_KEY, buf -> { + ProtocolUtils.sendBytebufPacket(player, NETWORK_KEY, buf -> { buf.writeByte(1); buf.writeFloat(saturation); }); @@ -73,7 +70,7 @@ public class AsteorBarProtocol { float exhaustion = data.exhaustionLevel; Float previousExhaustion = previousExhaustionLevels.get(player.getUUID()); if (previousExhaustion == null || Math.abs(exhaustion - previousExhaustion) >= THRESHOLD) { - ProtocolUtils.sendPayloadPacket(player, NETWORK_KEY, buf -> { + ProtocolUtils.sendBytebufPacket(player, NETWORK_KEY, buf -> { buf.writeByte(0); buf.writeFloat(exhaustion); }); @@ -99,4 +96,9 @@ public class AsteorBarProtocol { previousExhaustionLevels.remove(player.getUUID()); previousSaturationLevels.remove(player.getUUID()); } + + @Override + public boolean isActive() { + return ProtocolSupport.asteorBarProtocol; + } } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java similarity index 65% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java index 0aef5633..24bebec4 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java @@ -2,13 +2,14 @@ package org.leavesmc.leaves.protocol; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; +import org.dreeam.leaf.config.modules.network.ProtocolSupport; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.core.LeavesProtocol; import org.leavesmc.leaves.protocol.core.ProtocolUtils; -@LeavesProtocol(namespace = {"xaerominimap", "xaeroworldmap"}) -public class XaeroMapProtocol { +@LeavesProtocol.Register(namespace = "xaerominimap_or_xaeroworldmap_i_dont_care") +public class XaeroMapProtocol implements LeavesProtocol { public static final String PROTOCOL_ID_MINI = "xaerominimap"; public static final String PROTOCOL_ID_WORLD = "xaeroworldmap"; @@ -16,10 +17,6 @@ public class XaeroMapProtocol { private static final ResourceLocation MINIMAP_KEY = idMini("main"); private static final ResourceLocation WORLDMAP_KEY = idWorld("main"); - public static boolean shouldEnable() { - return org.dreeam.leaf.config.modules.network.ProtocolSupport.xaeroMapProtocol; - } - @Contract("_ -> new") public static ResourceLocation idMini(String path) { return ResourceLocation.tryBuild(PROTOCOL_ID_MINI, path); @@ -31,15 +28,20 @@ public class XaeroMapProtocol { } public static void onSendWorldInfo(@NotNull ServerPlayer player) { - if (shouldEnable()) { - ProtocolUtils.sendPayloadPacket(player, MINIMAP_KEY, buf -> { + if (ProtocolSupport.xaeroMapProtocol) { + ProtocolUtils.sendBytebufPacket(player, MINIMAP_KEY, buf -> { buf.writeByte(0); - buf.writeInt(org.dreeam.leaf.config.modules.network.ProtocolSupport.xaeroMapServerID); + buf.writeInt(ProtocolSupport.xaeroMapServerID); }); - ProtocolUtils.sendPayloadPacket(player, WORLDMAP_KEY, buf -> { + ProtocolUtils.sendBytebufPacket(player, WORLDMAP_KEY, buf -> { buf.writeByte(0); - buf.writeInt(org.dreeam.leaf.config.modules.network.ProtocolSupport.xaeroMapServerID); + buf.writeInt(ProtocolSupport.xaeroMapServerID); }); } } + + @Override + public boolean isActive() { + return ProtocolSupport.xaeroMapProtocol; + } } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/chatimage/ChatImageIndex.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/ChatImageIndex.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/chatimage/ChatImageIndex.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/chatimage/ChatImageIndex.java diff --git a/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java new file mode 100644 index 00000000..59e4aff4 --- /dev/null +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesCustomPayload.java @@ -0,0 +1,30 @@ +package org.leavesmc.leaves.protocol.core; + +import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.NotNull; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +public interface LeavesCustomPayload extends CustomPacketPayload { + + Type LEAVES_TYPE = new Type<>(ResourceLocation.fromNamespaceAndPath("leaves", "custom_payload")); + + @Override + default @NotNull Type type() { + return LEAVES_TYPE; + } + + @Target(ElementType.FIELD) + @Retention(RetentionPolicy.RUNTIME) + @interface ID { + } + + @Target(ElementType.FIELD) + @Retention(RetentionPolicy.RUNTIME) + @interface Codec { + } +} diff --git a/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocol.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocol.java new file mode 100644 index 00000000..8479a3fa --- /dev/null +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocol.java @@ -0,0 +1,21 @@ +package org.leavesmc.leaves.protocol.core; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +public interface LeavesProtocol { + + boolean isActive(); + + default int tickerInterval(String tickerID) { + return 1; + } + + @Target(ElementType.TYPE) + @Retention(RetentionPolicy.RUNTIME) + @interface Register { + String namespace(); + } +} \ No newline at end of file diff --git a/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java new file mode 100644 index 00000000..2787f546 --- /dev/null +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java @@ -0,0 +1,397 @@ +package org.leavesmc.leaves.protocol.core; + +import io.netty.buffer.ByteBuf; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import org.leavesmc.leaves.LeavesLogger; +import org.leavesmc.leaves.protocol.core.invoker.BytebufReceiverInvokerHolder; +import org.leavesmc.leaves.protocol.core.invoker.EmptyInvokerHolder; +import org.leavesmc.leaves.protocol.core.invoker.InitInvokerHolder; +import org.leavesmc.leaves.protocol.core.invoker.MinecraftRegisterInvokerHolder; +import org.leavesmc.leaves.protocol.core.invoker.PayloadReceiverInvokerHolder; +import org.leavesmc.leaves.protocol.core.invoker.PlayerInvokerHolder; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.net.JarURLConnection; +import java.net.URL; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +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, StreamCodec> CODECS = 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<>(); + private static final List GENERIC_BYTEBUF_RECEIVERS = new ArrayList<>(); + + private static final Map STRICT_MINECRAFT_REGISTER = new HashMap<>(); + private static final Map NAMESPACED_MINECRAFT_REGISTER = new HashMap<>(); + private static final List WILD_MINECRAFT_REGISTER = new ArrayList<>(); + + private static final List> TICKERS = new ArrayList<>(); + + private static final List> PLAYER_JOIN = new ArrayList<>(); + private static final List> PLAYER_LEAVE = new ArrayList<>(); + private static final List> RELOAD_SERVER = new ArrayList<>(); + private static final List> RELOAD_DATAPACK = new ArrayList<>(); + + @SuppressWarnings("unchecked") + public static void init() { + for (Class clazz : getClasses("org.leavesmc.leaves.protocol")) { + if (LeavesCustomPayload.class.isAssignableFrom(clazz) && !clazz.equals(LeavesCustomPayload.class)) { + for (Field field : clazz.getDeclaredFields()) { + field.setAccessible(true); + if (!Modifier.isStatic(field.getModifiers())) { + continue; + } + 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)); + } + final LeavesCustomPayload.Codec codec = field.getAnnotation(LeavesCustomPayload.Codec.class); + if (codec != null && field.getType().equals(StreamCodec.class)) { + CODECS.put((Class) clazz, (StreamCodec) field.get(null)); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } + continue; + } + + final LeavesProtocol.Register register = clazz.getAnnotation(LeavesProtocol.Register.class); + if (register == null) { + continue; + } + LeavesProtocol protocol; + try { + Constructor constructor = clazz.getDeclaredConstructor(); + constructor.setAccessible(true); + protocol = (LeavesProtocol) constructor.newInstance(); + } catch (Throwable throwable) { + LOGGER.severe("Failed to load class " + clazz.getName() + ". " + throwable); + return; + } + + for (final Method method : clazz.getDeclaredMethods()) { + if (method.isBridge() || method.isSynthetic()) { + continue; + } + method.setAccessible(true); + + final ProtocolHandler.Init init = method.getAnnotation(ProtocolHandler.Init.class); + if (init != null) { + InitInvokerHolder holder = new InitInvokerHolder(protocol, method, init); + try { + holder.invoke(); + } catch (RuntimeException exception) { + LOGGER.severe("Failed to invoke init method " + method.getName() + " in " + clazz.getName() + ", " + exception.getCause() + ": " + exception.getMessage()); + } + continue; + } + + final ProtocolHandler.PayloadReceiver payloadReceiver = method.getAnnotation(ProtocolHandler.PayloadReceiver.class); + if (payloadReceiver != null) { + PAYLOAD_RECEIVERS.put(payloadReceiver.payload(), new PayloadReceiverInvokerHolder(protocol, method, payloadReceiver)); + continue; + } + + final ProtocolHandler.BytebufReceiver bytebufReceiver = method.getAnnotation(ProtocolHandler.BytebufReceiver.class); + if (bytebufReceiver != null) { + String key = bytebufReceiver.key(); + BytebufReceiverInvokerHolder holder = new BytebufReceiverInvokerHolder(protocol, method, bytebufReceiver); + if (bytebufReceiver.onlyNamespace()) { + NAMESPACED_BYTEBUF_RECEIVERS.put(key.isEmpty() ? register.namespace() : key, holder); + } else { + if (key.isEmpty()) { + GENERIC_BYTEBUF_RECEIVERS.add(holder); + } else { + if (key.contains(":")) { + STRICT_BYTEBUF_RECEIVERS.put(key, holder); + } else { + STRICT_BYTEBUF_RECEIVERS.put(register.namespace() + ":" + key, holder); + } + } + } + continue; + } + + final ProtocolHandler.Ticker ticker = method.getAnnotation(ProtocolHandler.Ticker.class); + if (ticker != null) { + TICKERS.add(new EmptyInvokerHolder<>(protocol, method, ticker)); + continue; + } + + final ProtocolHandler.PlayerJoin playerJoin = method.getAnnotation(ProtocolHandler.PlayerJoin.class); + if (playerJoin != null) { + PLAYER_JOIN.add(new PlayerInvokerHolder<>(protocol, method, playerJoin)); + continue; + } + + final ProtocolHandler.PlayerLeave playerLeave = method.getAnnotation(ProtocolHandler.PlayerLeave.class); + if (playerLeave != null) { + PLAYER_LEAVE.add(new PlayerInvokerHolder<>(protocol, method, playerLeave)); + continue; + } + + final ProtocolHandler.ReloadServer reloadServer = method.getAnnotation(ProtocolHandler.ReloadServer.class); + if (reloadServer != null) { + RELOAD_SERVER.add(new EmptyInvokerHolder<>(protocol, method, reloadServer)); + continue; + } + + final ProtocolHandler.ReloadDataPack reloadDataPack = method.getAnnotation(ProtocolHandler.ReloadDataPack.class); + if (reloadDataPack != null) { + RELOAD_DATAPACK.add(new EmptyInvokerHolder<>(protocol, method, reloadDataPack)); + continue; + } + + final ProtocolHandler.MinecraftRegister minecraftRegister = method.getAnnotation(ProtocolHandler.MinecraftRegister.class); + if (minecraftRegister != null) { + String key = minecraftRegister.key(); + MinecraftRegisterInvokerHolder holder = new MinecraftRegisterInvokerHolder(protocol, method, minecraftRegister); + if (minecraftRegister.onlyNamespace()) { + NAMESPACED_MINECRAFT_REGISTER.put(key.isEmpty() ? register.namespace() : key, holder); + } else { + if (key.isEmpty()) { + WILD_MINECRAFT_REGISTER.add(holder); + } else { + if (key.contains(":")) { + STRICT_MINECRAFT_REGISTER.put(key, holder); + } else { + STRICT_MINECRAFT_REGISTER.put(register.namespace() + ":" + key, holder); + } + } + } + } + } + } + for (var idInfo : IDS.entrySet()) { + var codec = CODECS.get(idInfo.getKey()); + if (codec == null) { + throw new IllegalArgumentException("Payload " + idInfo.getKey() + " is not configured correctly"); + } + ID2CODEC.put(idInfo.getValue(), codec); + } + } + + public static LeavesCustomPayload decode(ResourceLocation location, FriendlyByteBuf buf) { + var codec = ID2CODEC.get(location); + if (codec == null) { + return null; + } + return codec.decode(ProtocolUtils.decorate(buf)); + } + + public static void encode(FriendlyByteBuf buf, LeavesCustomPayload payload) { + var location = IDS.get(payload.getClass()); + var codec = CODECS.get(payload.getClass()); + if (location == null || codec == null) { + throw new IllegalArgumentException("Payload " + payload.getClass() + " is not configured correctly " + location + " " + codec); + } + buf.writeResourceLocation(location); + codec.encode(ProtocolUtils.decorate(buf), payload); + } + + public static void handlePayload(ServerPlayer player, LeavesCustomPayload payload) { + PayloadReceiverInvokerHolder holder; + if ((holder = PAYLOAD_RECEIVERS.get(payload.getClass())) != null) { + holder.invoke(player, payload); + } + } + + public static boolean handleBytebuf(ServerPlayer player, ResourceLocation location, ByteBuf buf) { + RegistryFriendlyByteBuf buf1 = ProtocolUtils.decorate(buf); + BytebufReceiverInvokerHolder holder; + if ((holder = STRICT_BYTEBUF_RECEIVERS.get(location.toString())) != null) { + holder.invoke(player, buf1); + return true; + } + if ((holder = NAMESPACED_BYTEBUF_RECEIVERS.get(location.getNamespace())) != null) { + if (holder.invoke(player, buf1)) { + return true; + } + } + for (var holder1 : GENERIC_BYTEBUF_RECEIVERS) { + if (holder1.invoke(player, buf1)) { + return true; + } + } + return false; + } + + public static void handleTick(long tickCount) { + for (var tickerInfo : TICKERS) { + if (tickCount % tickerInfo.owner().tickerInterval(tickerInfo.handler().tickerId()) == 0) { + tickerInfo.invoke(); + } + } + } + + public static void handlePlayerJoin(ServerPlayer player) { + sendKnownId(player); + for (var join : PLAYER_JOIN) { + join.invoke(player); + } + } + + public static void handlePlayerLeave(ServerPlayer player) { + for (var leave : PLAYER_LEAVE) { + leave.invoke(player); + } + } + + public static void handleServerReload() { + for (var reload : RELOAD_SERVER) { + reload.invoke(); + } + } + + public static void handleDataPackReload() { + for (var reload : RELOAD_DATAPACK) { + reload.invoke(); + } + } + + public static void handleMinecraftRegister(String channelId, ServerPlayer player) { + ResourceLocation location = ResourceLocation.tryParse(channelId); + if (location == null) { + return; + } + + for (var wildHolder : WILD_MINECRAFT_REGISTER) { + wildHolder.invoke(player, location); + } + + MinecraftRegisterInvokerHolder holder; + if ((holder = STRICT_MINECRAFT_REGISTER.get(location.toString())) != null) { + holder.invoke(player, location); + } + if ((holder = NAMESPACED_MINECRAFT_REGISTER.get(location.getNamespace())) != null) { + holder.invoke(player, location); + } + } + + private static void sendKnownId(ServerPlayer player) { + Set set = new HashSet<>(); + PAYLOAD_RECEIVERS.forEach((clazz, holder) -> { + if (holder.owner().isActive()) { + set.add(IDS.get(clazz).toString()); + } + }); + STRICT_BYTEBUF_RECEIVERS.forEach((key, holder) -> { + if (holder.owner().isActive()) { + set.add(key); + } + }); + ProtocolUtils.sendBytebufPacket(player, ResourceLocation.fromNamespaceAndPath("minecraft", "register"), buf -> { + ResourceLocation channel; + for (Iterator var3 = set.iterator(); var3.hasNext(); buf.writeBytes(channel.toString().getBytes(StandardCharsets.US_ASCII))) { + channel = ResourceLocation.parse(var3.next()); + buf.writeByte(0); + } + buf.writerIndex(Math.max(buf.writerIndex() - 1, 0)); + }); + } + + public static Set> getClasses(String pack) { + Set> classes = new LinkedHashSet<>(); + String packageDirName = pack.replace('.', '/'); + Enumeration dirs; + try { + dirs = Thread.currentThread().getContextClassLoader().getResources(packageDirName); + while (dirs.hasMoreElements()) { + URL url = dirs.nextElement(); + String protocol = url.getProtocol(); + if ("file".equals(protocol)) { + String filePath = URLDecoder.decode(url.getFile(), StandardCharsets.UTF_8); + findClassesInPackageByFile(pack, filePath, classes); + } else if ("jar".equals(protocol)) { + JarFile jar; + try { + jar = ((JarURLConnection) url.openConnection()).getJarFile(); + Enumeration entries = jar.entries(); + findClassesInPackageByJar(pack, entries, packageDirName, classes); + } catch (IOException exception) { + LOGGER.warning("Failed to load jar file, " + exception.getCause() + ": " + exception.getMessage()); + } + } + } + } catch (IOException exception) { + LOGGER.warning("Failed to load classes, " + exception.getCause() + ": " + exception.getMessage()); + } + return classes; + } + + private static void findClassesInPackageByFile(String packageName, String packagePath, Set> classes) { + File dir = new File(packagePath); + if (!dir.exists() || !dir.isDirectory()) { + return; + } + File[] dirfiles = dir.listFiles((file) -> file.isDirectory() || file.getName().endsWith(".class")); + if (dirfiles != null) { + for (File file : dirfiles) { + if (file.isDirectory()) { + findClassesInPackageByFile(packageName + "." + file.getName(), file.getAbsolutePath(), classes); + } else { + String className = file.getName().substring(0, file.getName().length() - 6); + try { + classes.add(Class.forName(packageName + '.' + className)); + } catch (ClassNotFoundException exception) { + LOGGER.warning("Failed to load class " + className + ", " + exception.getCause() + ": " + exception.getMessage()); + } + } + } + } + } + + private static void findClassesInPackageByJar(String packageName, Enumeration entries, String packageDirName, Set> classes) { + while (entries.hasMoreElements()) { + JarEntry entry = entries.nextElement(); + String name = entry.getName(); + if (name.charAt(0) == '/') { + name = name.substring(1); + } + if (name.startsWith(packageDirName)) { + int idx = name.lastIndexOf('/'); + if (idx != -1) { + packageName = name.substring(0, idx).replace('/', '.'); + } + if (name.endsWith(".class") && !entry.isDirectory()) { + String className = name.substring(packageName.length() + 1, name.length() - 6); + try { + classes.add(Class.forName(packageName + '.' + className)); + } catch (ClassNotFoundException exception) { + LOGGER.warning("Failed to load class " + className + ", " + exception.getCause() + ": " + exception.getMessage()); + } + } + } + } + } +} \ No newline at end of file diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java similarity index 68% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java index 22f47824..0a36db38 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolHandler.java @@ -15,19 +15,21 @@ public class ProtocolHandler { @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface PayloadReceiver { - Class> payload(); + Class payload(); + } - String[] payloadId() default ""; + @Target(ElementType.METHOD) + @Retention(RetentionPolicy.RUNTIME) + public @interface BytebufReceiver { + String key() default ""; - boolean ignoreId() default false; - - boolean sendFabricRegister() default true; + boolean onlyNamespace() default false; } @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface Ticker { - int delay() default 0; + String tickerId() default ""; } @Target(ElementType.METHOD) @@ -48,9 +50,13 @@ public class ProtocolHandler { @Target(ElementType.METHOD) @Retention(RetentionPolicy.RUNTIME) public @interface MinecraftRegister { + String key() default ""; - String[] channelId() default ""; - - boolean ignoreId() default false; + boolean onlyNamespace() default false; } -} + + @Target(ElementType.METHOD) + @Retention(RetentionPolicy.RUNTIME) + public @interface ReloadDataPack { + } +} \ No newline at end of file diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java similarity index 53% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java index 72fb1e65..361660c6 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/ProtocolUtils.java @@ -1,11 +1,13 @@ package org.leavesmc.leaves.protocol.core; import io.netty.buffer.ByteBuf; +import io.netty.buffer.ByteBufUtil; +import io.netty.buffer.Unpooled; import io.papermc.paper.ServerBuildInfo; -import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket; import net.minecraft.network.protocol.common.custom.CustomPacketPayload; +import net.minecraft.network.protocol.common.custom.DiscardedPayload; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; @@ -16,34 +18,24 @@ import java.util.function.Function; public class ProtocolUtils { - private static final Function bufDecorator = RegistryFriendlyByteBuf.decorator(MinecraftServer.getServer().registryAccess()); + private static final Function bufDecorator = buf -> buf instanceof RegistryFriendlyByteBuf registry ? registry : new RegistryFriendlyByteBuf(buf, MinecraftServer.getServer().registryAccess()); public static String buildProtocolVersion(String protocol) { return protocol + "-leaves-" + ServerBuildInfo.buildInfo().asString(ServerBuildInfo.StringRepresentation.VERSION_SIMPLE); } - public static void sendEmptyPayloadPacket(ServerPlayer player, ResourceLocation id) { - player.connection.send(new ClientboundCustomPayloadPacket(new LeavesProtocolManager.EmptyPayload(id))); + public static void sendEmptyPacket(ServerPlayer player, ResourceLocation id) { + player.internalConnection.send(new ClientboundCustomPayloadPacket(new DiscardedPayload(id, null))); } - @SuppressWarnings("all") - public static void sendPayloadPacket(@NotNull ServerPlayer player, ResourceLocation id, Consumer consumer) { - player.connection.send(new ClientboundCustomPayloadPacket(new LeavesCustomPayload() { - @Override - public void write(@NotNull FriendlyByteBuf buf) { - consumer.accept(buf); - } - - @Override - @NotNull - public ResourceLocation id() { - return id; - } - })); + public static void sendBytebufPacket(@NotNull ServerPlayer player, ResourceLocation id, Consumer consumer) { + RegistryFriendlyByteBuf buf = decorate(Unpooled.buffer()); + consumer.accept(buf); + player.internalConnection.send(new ClientboundCustomPayloadPacket(new DiscardedPayload(id, ByteBufUtil.getBytes(buf)))); } public static void sendPayloadPacket(ServerPlayer player, CustomPacketPayload payload) { - player.connection.send(new ClientboundCustomPayloadPacket(payload)); + player.internalConnection.send(new ClientboundCustomPayloadPacket(payload)); } public static RegistryFriendlyByteBuf decorate(ByteBuf buf) { diff --git a/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/AbstractInvokerHolder.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/AbstractInvokerHolder.java new file mode 100644 index 00000000..1cac9120 --- /dev/null +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/AbstractInvokerHolder.java @@ -0,0 +1,70 @@ +package org.leavesmc.leaves.protocol.core.invoker; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.leavesmc.leaves.protocol.core.LeavesProtocol; + +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; + +public abstract class AbstractInvokerHolder { + + protected final LeavesProtocol owner; + protected final Method invoker; + protected final T handler; + protected final Class returnType; + protected final Class[] parameterTypes; + + protected AbstractInvokerHolder(LeavesProtocol owner, Method invoker, T handler, @Nullable Class returnType, @NotNull Class... parameterTypes) { + this.owner = owner; + this.invoker = invoker; + this.handler = handler; + this.returnType = returnType; + this.parameterTypes = parameterTypes; + + validateMethodSignature(); + } + + protected void validateMethodSignature() { + if (returnType != null && !returnType.isAssignableFrom(invoker.getReturnType())) { + throw new IllegalArgumentException("Return type mismatch in " + owner.getClass().getName() + "#" + invoker.getName() + + ": expected " + returnType.getName() + " but found " + invoker.getReturnType().getName()); + } + + Class[] methodParamTypes = invoker.getParameterTypes(); + if (methodParamTypes.length != parameterTypes.length) { + throw new IllegalArgumentException("Parameter count mismatch in " + owner.getClass().getName() + "#" + invoker.getName() + + ": expected " + parameterTypes.length + " but found " + methodParamTypes.length); + } + + for (int i = 0; i < parameterTypes.length; i++) { + if (!parameterTypes[i].isAssignableFrom(methodParamTypes[i])) { + throw new IllegalArgumentException("Parameter type mismatch in " + owner.getClass().getName() + "#" + invoker.getName() + + " at index " + i + ": expected " + parameterTypes[i].getName() + " but found " + methodParamTypes[i].getName()); + } + } + } + + public LeavesProtocol owner() { + return owner; + } + + public T handler() { + return handler; + } + + protected Object invoke0(boolean force, Object... args) { + if (!force && !owner.isActive()) { + return null; + } + try { + if (Modifier.isStatic(invoker.getModifiers())) { + return invoker.invoke(null, args); + } else { + return invoker.invoke(owner, args); + } + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff --git a/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/BytebufReceiverInvokerHolder.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/BytebufReceiverInvokerHolder.java new file mode 100644 index 00000000..e2c01b8e --- /dev/null +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/BytebufReceiverInvokerHolder.java @@ -0,0 +1,18 @@ +package org.leavesmc.leaves.protocol.core.invoker; + +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.server.level.ServerPlayer; +import org.leavesmc.leaves.protocol.core.LeavesProtocol; +import org.leavesmc.leaves.protocol.core.ProtocolHandler; + +import java.lang.reflect.Method; + +public class BytebufReceiverInvokerHolder extends AbstractInvokerHolder { + public BytebufReceiverInvokerHolder(LeavesProtocol owner, Method invoker, ProtocolHandler.BytebufReceiver handler) { + super(owner, invoker, handler, null, ServerPlayer.class, FriendlyByteBuf.class); + } + + public boolean invoke(ServerPlayer player, FriendlyByteBuf buf) { + return invoke0(false, player, buf) instanceof Boolean b && b; + } +} diff --git a/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/EmptyInvokerHolder.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/EmptyInvokerHolder.java new file mode 100644 index 00000000..d6e18d3e --- /dev/null +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/EmptyInvokerHolder.java @@ -0,0 +1,15 @@ +package org.leavesmc.leaves.protocol.core.invoker; + +import org.leavesmc.leaves.protocol.core.LeavesProtocol; + +import java.lang.reflect.Method; + +public class EmptyInvokerHolder extends AbstractInvokerHolder { + public EmptyInvokerHolder(LeavesProtocol owner, Method invoker, T handler) { + super(owner, invoker, handler, null); + } + + public void invoke() { + invoke0(false); + } +} diff --git a/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/InitInvokerHolder.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/InitInvokerHolder.java new file mode 100644 index 00000000..128aaf8e --- /dev/null +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/InitInvokerHolder.java @@ -0,0 +1,16 @@ +package org.leavesmc.leaves.protocol.core.invoker; + +import org.leavesmc.leaves.protocol.core.LeavesProtocol; +import org.leavesmc.leaves.protocol.core.ProtocolHandler; + +import java.lang.reflect.Method; + +public class InitInvokerHolder extends AbstractInvokerHolder { + public InitInvokerHolder(LeavesProtocol owner, Method invoker, ProtocolHandler.Init handler) { + super(owner, invoker, handler, null); + } + + public void invoke() { + invoke0(true); + } +} diff --git a/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/MinecraftRegisterInvokerHolder.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/MinecraftRegisterInvokerHolder.java new file mode 100644 index 00000000..c6766bc7 --- /dev/null +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/MinecraftRegisterInvokerHolder.java @@ -0,0 +1,18 @@ +package org.leavesmc.leaves.protocol.core.invoker; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerPlayer; +import org.leavesmc.leaves.protocol.core.LeavesProtocol; +import org.leavesmc.leaves.protocol.core.ProtocolHandler; + +import java.lang.reflect.Method; + +public class MinecraftRegisterInvokerHolder extends AbstractInvokerHolder { + public MinecraftRegisterInvokerHolder(LeavesProtocol owner, Method invoker, ProtocolHandler.MinecraftRegister handler) { + super(owner, invoker, handler, null, ServerPlayer.class, ResourceLocation.class); + } + + public void invoke(ServerPlayer player, ResourceLocation id) { + invoke0(false, player, id); + } +} diff --git a/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/PayloadReceiverInvokerHolder.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/PayloadReceiverInvokerHolder.java new file mode 100644 index 00000000..bed868b5 --- /dev/null +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/PayloadReceiverInvokerHolder.java @@ -0,0 +1,18 @@ +package org.leavesmc.leaves.protocol.core.invoker; + +import net.minecraft.server.level.ServerPlayer; +import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; +import org.leavesmc.leaves.protocol.core.LeavesProtocol; +import org.leavesmc.leaves.protocol.core.ProtocolHandler; + +import java.lang.reflect.Method; + +public class PayloadReceiverInvokerHolder extends AbstractInvokerHolder { + public PayloadReceiverInvokerHolder(LeavesProtocol owner, Method invoker, ProtocolHandler.PayloadReceiver handler) { + super(owner, invoker, handler, null, ServerPlayer.class, handler.payload()); + } + + public void invoke(ServerPlayer player, LeavesCustomPayload payload) { + invoke0(false, player, payload); + } +} diff --git a/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/PlayerInvokerHolder.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/PlayerInvokerHolder.java new file mode 100644 index 00000000..5ed2c2da --- /dev/null +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/core/invoker/PlayerInvokerHolder.java @@ -0,0 +1,16 @@ +package org.leavesmc.leaves.protocol.core.invoker; + +import net.minecraft.server.level.ServerPlayer; +import org.leavesmc.leaves.protocol.core.LeavesProtocol; + +import java.lang.reflect.Method; + +public class PlayerInvokerHolder extends AbstractInvokerHolder { + public PlayerInvokerHolder(LeavesProtocol owner, Method invoker, T handler) { + super(owner, invoker, handler, null, ServerPlayer.class); + } + + public void invoke(ServerPlayer player) { + invoke0(false, player); + } +} diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java similarity index 93% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java index 4a52e20d..77474e44 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java @@ -18,6 +18,7 @@ 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.frog.Tadpole; +import net.minecraft.world.entity.animal.sniffer.Sniffer; import net.minecraft.world.entity.monster.ZombieVillager; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; @@ -35,6 +36,7 @@ import net.minecraft.world.level.block.entity.HopperBlockEntity; import net.minecraft.world.level.block.entity.JukeboxBlockEntity; import net.minecraft.world.level.block.entity.LecternBlockEntity; import net.minecraft.world.level.block.entity.TrialSpawnerBlockEntity; +import org.dreeam.leaf.config.modules.network.ProtocolSupport; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.LeavesLogger; @@ -52,18 +54,18 @@ import org.leavesmc.leaves.protocol.jade.provider.IJadeProvider; import org.leavesmc.leaves.protocol.jade.provider.IServerDataProvider; import org.leavesmc.leaves.protocol.jade.provider.IServerExtensionProvider; import org.leavesmc.leaves.protocol.jade.provider.ItemStorageExtensionProvider; +import org.leavesmc.leaves.protocol.jade.provider.ItemStorageProvider; import org.leavesmc.leaves.protocol.jade.provider.block.BeehiveProvider; +import org.leavesmc.leaves.protocol.jade.provider.block.BlockNameProvider; import org.leavesmc.leaves.protocol.jade.provider.block.BrewingStandProvider; import org.leavesmc.leaves.protocol.jade.provider.block.CampfireProvider; import org.leavesmc.leaves.protocol.jade.provider.block.ChiseledBookshelfProvider; import org.leavesmc.leaves.protocol.jade.provider.block.CommandBlockProvider; import org.leavesmc.leaves.protocol.jade.provider.block.FurnaceProvider; import org.leavesmc.leaves.protocol.jade.provider.block.HopperLockProvider; -import org.leavesmc.leaves.protocol.jade.provider.ItemStorageProvider; import org.leavesmc.leaves.protocol.jade.provider.block.JukeboxProvider; import org.leavesmc.leaves.protocol.jade.provider.block.LecternProvider; import org.leavesmc.leaves.protocol.jade.provider.block.MobSpawnerCooldownProvider; -import org.leavesmc.leaves.protocol.jade.provider.block.ObjectNameProvider; import org.leavesmc.leaves.protocol.jade.provider.block.RedstoneProvider; import org.leavesmc.leaves.protocol.jade.provider.entity.AnimalOwnerProvider; import org.leavesmc.leaves.protocol.jade.provider.entity.MobBreedingProvider; @@ -77,29 +79,25 @@ import org.leavesmc.leaves.protocol.jade.util.LootTableMineableCollector; import org.leavesmc.leaves.protocol.jade.util.PairHierarchyLookup; import org.leavesmc.leaves.protocol.jade.util.PriorityStore; import org.leavesmc.leaves.protocol.jade.util.WrappedHierarchyLookup; +import org.leavesmc.leaves.util.NbtUtils; import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; -@LeavesProtocol(namespace = "jade") -public class JadeProtocol { - - public static PriorityStore priorities; - private static List shearableBlocks = null; +@LeavesProtocol.Register(namespace = "jade") +public class JadeProtocol implements LeavesProtocol { public static final String PROTOCOL_ID = "jade"; public static final String PROTOCOL_VERSION = "7"; - public static final HierarchyLookup> entityDataProviders = new HierarchyLookup<>(Entity.class); public static final PairHierarchyLookup> blockDataProviders = new PairHierarchyLookup<>(new HierarchyLookup<>(Block.class), new HierarchyLookup<>(BlockEntity.class)); public static final WrappedHierarchyLookup> itemStorageProviders = WrappedHierarchyLookup.forAccessor(); private static final Set enabledPlayers = new HashSet<>(); - public static boolean shouldEnable() { - return org.dreeam.leaf.config.modules.network.ProtocolSupport.jadeProtocol; - } + public static PriorityStore priorities; + private static List shearableBlocks = null; @Contract("_ -> new") public static ResourceLocation id(String path) { @@ -116,7 +114,7 @@ public class JadeProtocol { priorities = new PriorityStore<>(IJadeProvider::getDefaultPriority, IJadeProvider::getUid); // core plugin - blockDataProviders.register(BlockEntity.class, ObjectNameProvider.ForBlock.INSTANCE); + blockDataProviders.register(BlockEntity.class, BlockNameProvider.INSTANCE); // universal plugin entityDataProviders.register(Entity.class, ItemStorageProvider.getEntity()); @@ -136,6 +134,7 @@ public class JadeProtocol { entityDataProviders.register(Chicken.class, NextEntityDropProvider.INSTANCE); entityDataProviders.register(Armadillo.class, NextEntityDropProvider.INSTANCE); + entityDataProviders.register(Sniffer.class, NextEntityDropProvider.INSTANCE); entityDataProviders.register(ZombieVillager.class, ZombieVillagerProvider.INSTANCE); @@ -153,9 +152,10 @@ public class JadeProtocol { blockDataProviders.register(ChiseledBookShelfBlockEntity.class, ChiseledBookshelfProvider.INSTANCE); blockDataProviders.register(TrialSpawnerBlockEntity.class, MobSpawnerCooldownProvider.INSTANCE); + itemStorageProviders.register(CampfireBlock.class, CampfireProvider.INSTANCE); + blockDataProviders.idMapped(); entityDataProviders.idMapped(); - itemStorageProviders.register(CampfireBlock.class, CampfireProvider.INSTANCE); blockDataProviders.loadComplete(priorities); entityDataProviders.loadComplete(priorities); @@ -164,7 +164,7 @@ public class JadeProtocol { rebuildShearableBlocks(); } - @ProtocolHandler.PayloadReceiver(payload = ClientHandshakePayload.class, payloadId = "client_handshake") + @ProtocolHandler.PayloadReceiver(payload = ClientHandshakePayload.class) public static void clientHandshake(ServerPlayer player, ClientHandshakePayload payload) { if (!payload.protocolVersion().equals(PROTOCOL_VERSION)) { player.sendSystemMessage(Component.literal("You are using a different version of Jade than the server. Please update Jade or report to the server operator").withColor(0xff0000)); @@ -179,7 +179,7 @@ public class JadeProtocol { enabledPlayers.remove(player); } - @ProtocolHandler.PayloadReceiver(payload = RequestEntityPayload.class, payloadId = "request_entity") + @ProtocolHandler.PayloadReceiver(payload = RequestEntityPayload.class) public static void requestEntityData(ServerPlayer player, RequestEntityPayload payload) { MinecraftServer.getServer().execute(() -> { EntityAccessor accessor = payload.data().unpack(player); @@ -215,7 +215,7 @@ public class JadeProtocol { }); } - @ProtocolHandler.PayloadReceiver(payload = RequestBlockPayload.class, payloadId = "request_block") + @ProtocolHandler.PayloadReceiver(payload = RequestBlockPayload.class) public static void requestBlockData(ServerPlayer player, RequestBlockPayload payload) { MinecraftServer server = MinecraftServer.getServer(); server.execute(() -> { @@ -254,9 +254,7 @@ public class JadeProtocol { LeavesLogger.LOGGER.warning("Error while saving data for block " + accessor.getBlockState()); } } - tag.putInt("x", pos.getX()); - tag.putInt("y", pos.getY()); - tag.putInt("z", pos.getZ()); + NbtUtils.writeBlockPosToTag(pos, tag); tag.putString("BlockId", BuiltInRegistries.BLOCK.getKey(block).toString()); ProtocolUtils.sendPayloadPacket(player, new ReceiveDataPayload(tag)); @@ -265,11 +263,9 @@ public class JadeProtocol { @ProtocolHandler.ReloadServer public static void onServerReload() { - if (org.dreeam.leaf.config.modules.network.ProtocolSupport.jadeProtocol) { - rebuildShearableBlocks(); - for (ServerPlayer player : enabledPlayers) { - ProtocolUtils.sendPayloadPacket(player, new ServerHandshakePayload(Collections.emptyMap(), shearableBlocks, blockDataProviders.mappedIds(), entityDataProviders.mappedIds())); - } + rebuildShearableBlocks(); + for (ServerPlayer player : enabledPlayers) { + ProtocolUtils.sendPayloadPacket(player, new ServerHandshakePayload(Collections.emptyMap(), shearableBlocks, blockDataProviders.mappedIds(), entityDataProviders.mappedIds())); } } @@ -284,4 +280,9 @@ public class JadeProtocol { LeavesLogger.LOGGER.severe("Failed to collect shearable blocks"); } } + + @Override + public boolean isActive() { + return ProtocolSupport.jadeProtocol; + } } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/Accessor.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/Accessor.java similarity index 77% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/Accessor.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/Accessor.java index 1a637045..6bc22532 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/Accessor.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/Accessor.java @@ -9,7 +9,6 @@ import net.minecraft.world.phys.HitResult; import org.jetbrains.annotations.Nullable; public interface Accessor { - Level getLevel(); Player getPlayer(); @@ -18,15 +17,6 @@ public interface Accessor { T getHitResult(); - /** - * @return {@code true} if the dedicated server has Jade installed. - */ - boolean isServerConnected(); - - boolean showDetails(); - @Nullable Object getTarget(); - - float tickRate(); } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/AccessorImpl.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/AccessorImpl.java similarity index 74% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/AccessorImpl.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/AccessorImpl.java index 7e57bd40..a6d91d97 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/AccessorImpl.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/AccessorImpl.java @@ -17,17 +17,13 @@ public abstract class AccessorImpl implements Accessor { private final Level level; private final Player player; private final Supplier hit; - private final boolean serverConnected; - private final boolean showDetails; protected boolean verify; private RegistryFriendlyByteBuf buffer; - public AccessorImpl(Level level, Player player, Supplier hit, boolean serverConnected, boolean showDetails) { + public AccessorImpl(Level level, Player player, Supplier hit) { this.level = level; this.player = player; this.hit = hit; - this.serverConnected = serverConnected; - this.showDetails = showDetails; } @Override @@ -61,22 +57,4 @@ public abstract class AccessorImpl implements Accessor { public T getHitResult() { return hit.get(); } - - /** - * Returns true if dedicated server has Jade installed. - */ - @Override - public boolean isServerConnected() { - return serverConnected; - } - - @Override - public boolean showDetails() { - return showDetails; - } - - @Override - public float tickRate() { - return getLevel().tickRateManager().tickrate(); - } } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessor.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessor.java similarity index 90% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessor.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessor.java index 90724515..133415a3 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessor.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessor.java @@ -1,7 +1,6 @@ package org.leavesmc.leaves.protocol.jade.accessor; import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; @@ -22,16 +21,12 @@ public interface BlockAccessor extends Accessor { BlockPos getPosition(); - Direction getSide(); - @ApiStatus.NonExtendable interface Builder { Builder level(Level level); Builder player(Player player); - Builder showDetails(boolean showDetails); - Builder hit(BlockHitResult hit); Builder blockState(BlockState state); diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessorImpl.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessorImpl.java similarity index 88% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessorImpl.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessorImpl.java index 126b86db..a94bb9eb 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessorImpl.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/BlockAccessorImpl.java @@ -1,13 +1,7 @@ package org.leavesmc.leaves.protocol.jade.accessor; -import java.util.function.Supplier; - -import org.jetbrains.annotations.Nullable; - import com.google.common.base.Suppliers; - import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; @@ -21,6 +15,9 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.BlockHitResult; +import org.jetbrains.annotations.Nullable; + +import java.util.function.Supplier; /** * Class to get information of block target and context. @@ -32,7 +29,7 @@ public class BlockAccessorImpl extends AccessorImpl implements B private final Supplier blockEntity; private BlockAccessorImpl(Builder builder) { - super(builder.level, builder.player, Suppliers.ofInstance(builder.hit), builder.connected, builder.showDetails); + super(builder.level, builder.player, Suppliers.ofInstance(builder.hit)); blockState = builder.blockState; blockEntity = builder.blockEntity; } @@ -57,11 +54,6 @@ public class BlockAccessorImpl extends AccessorImpl implements B return getHitResult().getBlockPos(); } - @Override - public Direction getSide() { - return getHitResult().getDirection(); - } - @Nullable @Override public Object getTarget() { @@ -69,11 +61,8 @@ public class BlockAccessorImpl extends AccessorImpl implements B } public static class Builder implements BlockAccessor.Builder { - private Level level; private Player player; - private boolean connected; - private boolean showDetails; private BlockHitResult hit; private BlockState blockState = Blocks.AIR.defaultBlockState(); private Supplier blockEntity; @@ -90,12 +79,6 @@ public class BlockAccessorImpl extends AccessorImpl implements B return this; } - @Override - public Builder showDetails(boolean showDetails) { - this.showDetails = showDetails; - return this; - } - @Override public Builder hit(BlockHitResult hit) { this.hit = hit; @@ -118,8 +101,6 @@ public class BlockAccessorImpl extends AccessorImpl implements B public Builder from(BlockAccessor accessor) { level = accessor.getLevel(); player = accessor.getPlayer(); - connected = accessor.isServerConnected(); - showDetails = accessor.showDetails(); hit = accessor.getHitResult(); blockEntity = accessor::getBlockEntity; blockState = accessor.getBlockState(); @@ -153,7 +134,6 @@ public class BlockAccessorImpl extends AccessorImpl implements B return new Builder() .level(player.level()) .player(player) - .showDetails(showDetails) .hit(hit) .blockState(blockState) .blockEntity(blockEntity) diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessor.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessor.java similarity index 95% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessor.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessor.java index 02b453ea..00fd87b7 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessor.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessor.java @@ -23,8 +23,6 @@ public interface EntityAccessor extends Accessor { Builder player(Player player); - Builder showDetails(boolean showDetails); - default Builder hit(EntityHitResult hit) { return hit(() -> hit); } @@ -41,4 +39,4 @@ public interface EntityAccessor extends Accessor { EntityAccessor build(); } -} +} \ No newline at end of file diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessorImpl.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessorImpl.java similarity index 87% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessorImpl.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessorImpl.java index 3d42bce0..56166c62 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessorImpl.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/accessor/EntityAccessorImpl.java @@ -20,7 +20,7 @@ public class EntityAccessorImpl extends AccessorImpl implements private final Supplier entity; public EntityAccessorImpl(Builder builder) { - super(builder.level, builder.player, builder.hit, builder.connected, builder.showDetails); + super(builder.level, builder.player, builder.hit); entity = builder.entity; } @@ -41,11 +41,8 @@ public class EntityAccessorImpl extends AccessorImpl implements } public static class Builder implements EntityAccessor.Builder { - - public boolean showDetails; private Level level; private Player player; - private boolean connected; private Supplier hit; private Supplier entity; @@ -61,11 +58,6 @@ public class EntityAccessorImpl extends AccessorImpl implements return this; } - @Override - public Builder showDetails(boolean showDetails) { - this.showDetails = showDetails; - return this; - } @Override public Builder hit(Supplier hit) { @@ -83,8 +75,6 @@ public class EntityAccessorImpl extends AccessorImpl implements public Builder from(EntityAccessor accessor) { level = accessor.getLevel(); player = accessor.getPlayer(); - connected = accessor.isServerConnected(); - showDetails = accessor.showDetails(); hit = accessor::getHitResult; entity = accessor::getEntity; return this; @@ -114,10 +104,9 @@ public class EntityAccessorImpl extends AccessorImpl implements return new EntityAccessorImpl.Builder() .level(player.level()) .player(player) - .showDetails(showDetails) .entity(entity) .hit(Suppliers.memoize(() -> new EntityHitResult(entity.get(), hitVec))) .build(); } } -} +} \ No newline at end of file diff --git a/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java new file mode 100644 index 00000000..1620d68f --- /dev/null +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ClientHandshakePayload.java @@ -0,0 +1,19 @@ +package org.leavesmc.leaves.protocol.jade.payload; + +import net.minecraft.network.RegistryFriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.resources.ResourceLocation; +import 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"); + + @Codec + private static final StreamCodec CODEC = StreamCodec.composite( + ByteBufCodecs.STRING_UTF8, ClientHandshakePayload::protocolVersion, ClientHandshakePayload::new + ); +} \ No newline at end of file diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ReceiveDataPayload.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ReceiveDataPayload.java similarity index 54% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ReceiveDataPayload.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ReceiveDataPayload.java index 1b474ea8..b2630fca 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ReceiveDataPayload.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ReceiveDataPayload.java @@ -2,27 +2,19 @@ package org.leavesmc.leaves.protocol.jade.payload; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.codec.ByteBufCodecs; +import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; import org.leavesmc.leaves.protocol.jade.JadeProtocol; -public record ReceiveDataPayload(CompoundTag tag) implements LeavesCustomPayload { +public record ReceiveDataPayload(CompoundTag tag) implements LeavesCustomPayload { + @ID private static final ResourceLocation PACKET_RECEIVE_DATA = JadeProtocol.id("receive_data"); - @New - public ReceiveDataPayload(ResourceLocation id, FriendlyByteBuf buf) { - this(buf.readNbt()); - } - - @Override - public void write(@NotNull FriendlyByteBuf buf) { - buf.writeNbt(tag); - } - - @Override - public ResourceLocation id() { - return PACKET_RECEIVE_DATA; - } + @Codec + private static final StreamCodec CODEC = StreamCodec.composite( + ByteBufCodecs.COMPOUND_TAG, ReceiveDataPayload::tag, ReceiveDataPayload::new + ); } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java similarity index 50% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java index 6c333a0a..9d32bf29 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestBlockPayload.java @@ -1,15 +1,12 @@ package org.leavesmc.leaves.protocol.jade.payload; import io.netty.buffer.ByteBuf; -import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; -import org.leavesmc.leaves.protocol.core.ProtocolUtils; import org.leavesmc.leaves.protocol.jade.JadeProtocol; import org.leavesmc.leaves.protocol.jade.accessor.BlockAccessor; import org.leavesmc.leaves.protocol.jade.accessor.BlockAccessorImpl; @@ -20,32 +17,19 @@ import java.util.Objects; import static org.leavesmc.leaves.protocol.jade.JadeProtocol.blockDataProviders; -public record RequestBlockPayload(BlockAccessorImpl.SyncData data, List<@Nullable IServerDataProvider> dataProviders) implements LeavesCustomPayload { +public record RequestBlockPayload(BlockAccessorImpl.SyncData data, List<@Nullable IServerDataProvider> dataProviders) implements LeavesCustomPayload { + @ID private static final ResourceLocation PACKET_REQUEST_BLOCK = JadeProtocol.id("request_block"); + + @Codec private static final StreamCodec CODEC = StreamCodec.composite( - BlockAccessorImpl.SyncData.STREAM_CODEC, - RequestBlockPayload::data, - ByteBufCodecs.>list() - .apply(ByteBufCodecs.idMapper( - $ -> Objects.requireNonNull(blockDataProviders.idMapper()).byId($), - $ -> Objects.requireNonNull(blockDataProviders.idMapper()).getIdOrThrow($))), - RequestBlockPayload::dataProviders, - RequestBlockPayload::new); - - @Override - public void write(FriendlyByteBuf buf) { - CODEC.encode(ProtocolUtils.decorate(buf), this); - } - - @Override - @NotNull - public ResourceLocation id() { - return PACKET_REQUEST_BLOCK; - } - - @New - public static RequestBlockPayload create(ResourceLocation location, FriendlyByteBuf buf) { - return CODEC.decode(ProtocolUtils.decorate(buf)); - } -} + BlockAccessorImpl.SyncData.STREAM_CODEC, + RequestBlockPayload::data, + ByteBufCodecs.>list() + .apply(ByteBufCodecs.idMapper( + $ -> Objects.requireNonNull(blockDataProviders.idMapper()).byId($), + $ -> Objects.requireNonNull(blockDataProviders.idMapper()).getIdOrThrow($))), + RequestBlockPayload::dataProviders, + RequestBlockPayload::new); +} \ No newline at end of file diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java similarity index 68% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java index 41fb2dba..70dd289a 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/RequestEntityPayload.java @@ -1,15 +1,12 @@ package org.leavesmc.leaves.protocol.jade.payload; import io.netty.buffer.ByteBuf; -import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceLocation; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; -import org.leavesmc.leaves.protocol.core.ProtocolUtils; import org.leavesmc.leaves.protocol.jade.JadeProtocol; import org.leavesmc.leaves.protocol.jade.accessor.EntityAccessor; import org.leavesmc.leaves.protocol.jade.accessor.EntityAccessorImpl; @@ -20,10 +17,12 @@ import java.util.Objects; import static org.leavesmc.leaves.protocol.jade.JadeProtocol.entityDataProviders; -public record RequestEntityPayload(EntityAccessorImpl.SyncData data, - List<@Nullable IServerDataProvider> dataProviders) implements LeavesCustomPayload { +public record RequestEntityPayload(EntityAccessorImpl.SyncData data, List<@Nullable IServerDataProvider> dataProviders) implements LeavesCustomPayload { + @ID private static final ResourceLocation PACKET_REQUEST_ENTITY = JadeProtocol.id("request_entity"); + + @Codec private static final StreamCodec CODEC = StreamCodec.composite( EntityAccessorImpl.SyncData.STREAM_CODEC, RequestEntityPayload::data, @@ -34,22 +33,4 @@ public record RequestEntityPayload(EntityAccessorImpl.SyncData data, )), RequestEntityPayload::dataProviders, RequestEntityPayload::new); - - - @Override - public void write(FriendlyByteBuf buf) { - CODEC.encode(ProtocolUtils.decorate(buf), this); - } - - - @Override - @NotNull - public ResourceLocation id() { - return PACKET_REQUEST_ENTITY; - } - - @New - public static RequestEntityPayload create(ResourceLocation location, FriendlyByteBuf buf) { - return CODEC.decode(ProtocolUtils.decorate(buf)); - } -} +} \ No newline at end of file diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java similarity index 66% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java index 21848bc8..4955e0e1 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/payload/ServerHandshakePayload.java @@ -1,16 +1,15 @@ package org.leavesmc.leaves.protocol.jade.payload; + import com.google.common.collect.Maps; import io.netty.buffer.ByteBuf; import net.minecraft.core.registries.Registries; -import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.ByteBufCodecs; import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; -import org.leavesmc.leaves.protocol.core.ProtocolUtils; import org.leavesmc.leaves.protocol.jade.JadeProtocol; import java.util.List; @@ -18,11 +17,12 @@ import java.util.Map; import static org.leavesmc.leaves.protocol.jade.util.JadeCodec.PRIMITIVE_STREAM_CODEC; -public record ServerHandshakePayload(Map serverConfig, List shearableBlocks, - List blockProviderIds, - List entityProviderIds) implements LeavesCustomPayload { +public record ServerHandshakePayload(Map serverConfig, List shearableBlocks, List blockProviderIds, List entityProviderIds) implements LeavesCustomPayload { + @ID private static final ResourceLocation 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), ServerHandshakePayload::serverConfig, @@ -32,20 +32,6 @@ public record ServerHandshakePayload(Map serverConfig, ServerHandshakePayload::blockProviderIds, ByteBufCodecs.list().apply(ResourceLocation.STREAM_CODEC), ServerHandshakePayload::entityProviderIds, - ServerHandshakePayload::new); - - @Override - public void write(FriendlyByteBuf buf) { - CODEC.encode(ProtocolUtils.decorate(buf), this); - } - - @Override - public ResourceLocation id() { - return PACKET_SERVER_HANDSHAKE; - } - - @New - public static ServerHandshakePayload create(ResourceLocation location, FriendlyByteBuf buf) { - return CODEC.decode(ProtocolUtils.decorate(buf)); - } -} + ServerHandshakePayload::new + ); +} \ No newline at end of file diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IJadeProvider.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IJadeProvider.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IJadeProvider.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IJadeProvider.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IServerDataProvider.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IServerDataProvider.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IServerDataProvider.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IServerDataProvider.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IServerExtensionProvider.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IServerExtensionProvider.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IServerExtensionProvider.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/IServerExtensionProvider.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java similarity index 98% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java index c9e00e50..a0916567 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageExtensionProvider.java @@ -37,52 +37,6 @@ public enum ItemStorageExtensionProvider implements IServerExtensionProvider> getGroups(Accessor request) { - Object target = request.getTarget(); - - switch (target) { - case null -> { - return createItemCollector(request).update(request); - } - case RandomizableContainer te when te.getLootTable() != null -> { - return List.of(); - } - case ContainerEntity containerEntity when containerEntity.getContainerLootTable() != null -> { - return List.of(); - } - default -> { - } - } - - Player player = request.getPlayer(); - if (!player.isCreative() && !player.isSpectator() && target instanceof BaseContainerBlockEntity te) { - if (te.lockKey != LockCode.NO_LOCK) { - return List.of(); - } - } - - if (target instanceof EnderChestBlockEntity) { - PlayerEnderChestContainer inventory = player.getEnderChestInventory(); - return new ItemCollector<>(new ItemIterator.ContainerItemIterator(x -> inventory, 0)).update(request); - } - - ItemCollector itemCollector; - try { - itemCollector = targetCache.get(target, () -> createItemCollector(request)); - } catch (ExecutionException e) { - LeavesLogger.LOGGER.severe("Failed to get item collector for " + target); - return null; - } - - return itemCollector.update(request); - } - - @Override - public ResourceLocation getUid() { - return UNIVERSAL_ITEM_STORAGE; - } - public static ItemCollector createItemCollector(Accessor request) { if (request.getTarget() instanceof AbstractHorse) { return new ItemCollector<>(new ItemIterator.ContainerItemIterator(o -> { @@ -131,8 +85,54 @@ public enum ItemStorageExtensionProvider implements IServerExtensionProvider> getGroups(Accessor request) { + Object target = request.getTarget(); + + switch (target) { + case null -> { + return createItemCollector(request).update(request); + } + case RandomizableContainer te when te.getLootTable() != null -> { + return List.of(); + } + case ContainerEntity containerEntity when containerEntity.getContainerLootTable() != null -> { + return List.of(); + } + default -> { + } + } + + Player player = request.getPlayer(); + if (!player.isCreative() && !player.isSpectator() && target instanceof BaseContainerBlockEntity te) { + if (te.lockKey != LockCode.NO_LOCK) { + return List.of(); + } + } + + if (target instanceof EnderChestBlockEntity) { + PlayerEnderChestContainer inventory = player.getEnderChestInventory(); + return new ItemCollector<>(new ItemIterator.ContainerItemIterator(x -> inventory, 0)).update(request); + } + + ItemCollector itemCollector; + try { + itemCollector = targetCache.get(target, () -> createItemCollector(request)); + } catch (ExecutionException e) { + LeavesLogger.LOGGER.severe("Failed to get item collector for " + target); + return null; + } + + return itemCollector.update(request); + } + + @Override + public ResourceLocation getUid() { + return UNIVERSAL_ITEM_STORAGE; + } + @Override public int getDefaultPriority() { - return IServerExtensionProvider.super.getDefaultPriority() + 1000; + return 9999; } } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageProvider.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageProvider.java similarity index 97% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageProvider.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageProvider.java index 6657c493..7d6cd6dd 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageProvider.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/ItemStorageProvider.java @@ -24,8 +24,7 @@ import java.util.Map; public abstract class ItemStorageProvider> implements IServerDataProvider { - 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"); @@ -37,14 +36,6 @@ public abstract class ItemStorageProvider> implements ISer return ForEntity.INSTANCE; } - public static class ForBlock extends ItemStorageProvider { - private static final ForBlock INSTANCE = new ForBlock(); - } - - public static class ForEntity extends ItemStorageProvider { - private static final ForEntity INSTANCE = new ForEntity(); - } - public static void putData(CompoundTag tag, @NotNull Accessor accessor) { Object target = accessor.getTarget(); Player player = accessor.getPlayer(); @@ -83,6 +74,14 @@ public abstract class ItemStorageProvider> implements ISer @Override public int getDefaultPriority() { - return 9999; + return 1000; } -} + + public static class ForBlock extends ItemStorageProvider { + private static final ForBlock INSTANCE = new ForBlock(); + } + + public static class ForEntity extends ItemStorageProvider { + private static final ForEntity INSTANCE = new ForEntity(); + } +} \ No newline at end of file diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/StreamServerDataProvider.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/StreamServerDataProvider.java similarity index 92% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/StreamServerDataProvider.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/StreamServerDataProvider.java index 52887edb..fde7c8e6 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/StreamServerDataProvider.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/StreamServerDataProvider.java @@ -1,14 +1,11 @@ package org.leavesmc.leaves.protocol.jade.provider; import net.minecraft.nbt.CompoundTag; -import net.minecraft.nbt.Tag; import net.minecraft.network.RegistryFriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.protocol.jade.accessor.Accessor; -import java.util.Optional; - public interface StreamServerDataProvider, D> extends IServerDataProvider { @Override diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BeehiveProvider.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BeehiveProvider.java similarity index 99% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BeehiveProvider.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BeehiveProvider.java index 708fc5fc..ee92d79b 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BeehiveProvider.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BeehiveProvider.java @@ -31,4 +31,4 @@ public enum BeehiveProvider implements StreamServerDataProvider { + INSTANCE; + + private static final ResourceLocation CORE_OBJECT_NAME = JadeProtocol.id("object_name"); + + @Override + @Nullable + public Component streamData(@NotNull BlockAccessor accessor) { + if (!(accessor.getBlockEntity() instanceof Nameable nameable)) { + return null; + } + if (nameable instanceof ChestBlockEntity && accessor.getBlock() instanceof ChestBlock && accessor.getBlockState().getValue(ChestBlock.TYPE) != ChestType.SINGLE) { + MenuProvider menuProvider = accessor.getBlockState().getMenuProvider(accessor.getLevel(), accessor.getPosition()); + if (menuProvider != null) { + Component name = menuProvider.getDisplayName(); + if (!(name.getContents() instanceof TranslatableContents contents) || !"container.chestDouble".equals(contents.getKey())) { + return name; + } + } + } else if (nameable.hasCustomName()) { + return nameable.getDisplayName(); + } + return accessor.getBlockEntity().components().get(DataComponents.ITEM_NAME); + } + + @Override + public StreamCodec streamCodec() { + return ComponentSerialization.STREAM_CODEC; + } + + @Override + public ResourceLocation getUid() { + return CORE_OBJECT_NAME; + } + + @Override + public int getDefaultPriority() { + return -10100; + } +} \ No newline at end of file diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BrewingStandProvider.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BrewingStandProvider.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BrewingStandProvider.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/BrewingStandProvider.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/CampfireProvider.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/CampfireProvider.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/CampfireProvider.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/CampfireProvider.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java similarity index 88% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java index bde872cc..12fdbc3c 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/block/ChiseledBookshelfProvider.java @@ -10,6 +10,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.protocol.jade.JadeProtocol; import org.leavesmc.leaves.protocol.jade.accessor.BlockAccessor; +import org.leavesmc.leaves.protocol.jade.provider.ItemStorageProvider; import org.leavesmc.leaves.protocol.jade.provider.StreamServerDataProvider; public enum ChiseledBookshelfProvider implements StreamServerDataProvider { @@ -31,9 +32,13 @@ public enum ChiseledBookshelfProvider implements StreamServerDataProvider reference = ownableEntity.getOwnerReference(); + if (reference != null) { + return reference.getUUID(); + } + } + return null; + } + @Override public String streamData(@NotNull EntityAccessor accessor) { return CommonUtil.getLastKnownUsername(getOwnerUUID(accessor.getEntity())); @@ -29,13 +41,6 @@ public enum AnimalOwnerProvider implements StreamServerDataProvider 0 && time < max) { + tag.putInt("NextSniffIn", (int) time); + } } } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/PetArmorProvider.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/PetArmorProvider.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/PetArmorProvider.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/PetArmorProvider.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/StatusEffectsProvider.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/StatusEffectsProvider.java similarity index 99% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/StatusEffectsProvider.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/StatusEffectsProvider.java index b709d046..74706271 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/StatusEffectsProvider.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/StatusEffectsProvider.java @@ -17,6 +17,7 @@ import java.util.List; public enum StatusEffectsProvider implements StreamServerDataProvider> { INSTANCE; + private static final StreamCodec> STREAM_CODEC = ByteBufCodecs.list() .apply(MobEffectInstance.STREAM_CODEC); private static final ResourceLocation MC_POTION_EFFECTS = JadeProtocol.mc_id("potion_effects"); diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/ZombieVillagerProvider.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/ZombieVillagerProvider.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/ZombieVillagerProvider.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/provider/entity/ZombieVillagerProvider.java diff --git a/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/tool/ShearsToolHandler.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/tool/ShearsToolHandler.java new file mode 100644 index 00000000..9bbe5168 --- /dev/null +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/tool/ShearsToolHandler.java @@ -0,0 +1,37 @@ +package org.leavesmc.leaves.protocol.jade.tool; + +import net.minecraft.core.component.DataComponents; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.component.Tool; +import net.minecraft.world.level.block.state.BlockState; + +import java.util.List; + +public class ShearsToolHandler { + + private static final ShearsToolHandler INSTANCE = new ShearsToolHandler(); + + private final List tools; + + public ShearsToolHandler() { + this.tools = List.of(Items.SHEARS.getDefaultInstance()); + } + + public static ShearsToolHandler getInstance() { + return INSTANCE; + } + + public ItemStack test(BlockState state) { + for (ItemStack toolItem : tools) { + if (toolItem.isCorrectToolForDrops(state)) { + return toolItem; + } + Tool tool = toolItem.get(DataComponents.TOOL); + if (tool != null && tool.getMiningSpeed(state) > tool.defaultMiningSpeed()) { + return toolItem; + } + } + return ItemStack.EMPTY; + } +} diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/CommonUtil.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/CommonUtil.java similarity index 89% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/CommonUtil.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/CommonUtil.java index 47701b17..4e48a268 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/CommonUtil.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/CommonUtil.java @@ -1,14 +1,11 @@ package org.leavesmc.leaves.protocol.jade.util; import com.mojang.authlib.GameProfile; -import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.boss.EnderDragonPart; import net.minecraft.world.entity.boss.enderdragon.EnderDragon; -import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.SkullBlockEntity; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.LeavesLogger; import org.leavesmc.leaves.protocol.jade.accessor.Accessor; @@ -21,10 +18,6 @@ import java.util.UUID; public class CommonUtil { - public static @NotNull ResourceLocation getId(Block block) { - return BuiltInRegistries.BLOCK.getKey(block); - } - public static Entity wrapPartEntityParent(Entity target) { if (target instanceof EnderDragonPart part) { return part.parentMob; diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java similarity index 97% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java index 153d944d..b2736d7d 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/HierarchyLookup.java @@ -26,7 +26,6 @@ import java.util.concurrent.ExecutionException; import java.util.stream.Stream; public class HierarchyLookup implements IHierarchyLookup { - private final Class baseClass; private final Cache, List> resultCache = CacheBuilder.newBuilder().build(); private final boolean singleton; @@ -74,7 +73,7 @@ public class HierarchyLookup implements IHierarchyLooku return resultCache.get(clazz, () -> { List list = Lists.newArrayList(); getInternal(clazz, list); - list = ImmutableList.sortedCopyOf(Comparator.comparingInt(JadeProtocol.priorities::byValue), list); + list = ImmutableList.sortedCopyOf(COMPARATOR, list); if (singleton && !list.isEmpty()) { return ImmutableList.of(list.getFirst()); } @@ -136,5 +135,4 @@ public class HierarchyLookup implements IHierarchyLooku idMapper = createIdMapper(); } } - -} +} \ No newline at end of file diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java similarity index 89% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java index 25824249..c160eaa7 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/IHierarchyLookup.java @@ -4,9 +4,11 @@ import com.google.common.collect.Streams; import net.minecraft.core.IdMapper; import net.minecraft.resources.ResourceLocation; import org.jetbrains.annotations.Nullable; +import org.leavesmc.leaves.protocol.jade.JadeProtocol; import org.leavesmc.leaves.protocol.jade.provider.IJadeProvider; import java.util.Collection; +import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Objects; @@ -14,6 +16,8 @@ import java.util.stream.Stream; public interface IHierarchyLookup { + Comparator COMPARATOR = Comparator.comparingInt(provider -> JadeProtocol.priorities.byValue(provider)); + default IHierarchyLookup cast() { return this; } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemCollector.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemCollector.java similarity index 87% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemCollector.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemCollector.java index e8467927..c23cb197 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemCollector.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemCollector.java @@ -7,6 +7,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.component.CustomData; +import net.minecraft.world.item.component.TooltipDisplay; import org.leavesmc.leaves.protocol.jade.accessor.Accessor; import java.util.List; @@ -15,18 +16,19 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Predicate; public class ItemCollector { - public static final int MAX_SIZE = 54; public static final ItemCollector EMPTY = new ItemCollector<>(null); - private static final Predicate NON_EMPTY = stack -> { + private static final Predicate SHOWN = stack -> { if (stack.isEmpty()) { return false; } - CustomData customData = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY); - if (customData.contains("CustomModelData")) { - CompoundTag tag = customData.copyTag(); - for (String key : tag.getAllKeys()) { - if (key.toLowerCase(Locale.ENGLISH).endsWith("clear") && tag.getBoolean(key)) { + if (stack.getOrDefault(DataComponents.TOOLTIP_DISPLAY, TooltipDisplay.DEFAULT).hideTooltip()) { + return false; + } + if (stack.hasNonDefault(DataComponents.CUSTOM_MODEL_DATA) || stack.hasNonDefault(DataComponents.ITEM_MODEL)) { + CompoundTag tag = stack.getOrDefault(DataComponents.CUSTOM_DATA, CustomData.EMPTY).copyTag(); + for (String key : tag.keySet()) { + if (key.toLowerCase(Locale.ENGLISH).endsWith("clear") && tag.getBooleanOr(key, true)) { return false; } } @@ -66,7 +68,7 @@ public class ItemCollector { AtomicInteger count = new AtomicInteger(); iterator.populate(container).forEach(stack -> { count.incrementAndGet(); - if (NON_EMPTY.test(stack)) { + if (SHOWN.test(stack)) { ItemDefinition def = new ItemDefinition(stack); items.addTo(def, stack.getCount()); } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemIterator.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemIterator.java similarity index 99% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemIterator.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemIterator.java index 9ea5cdb4..4d65e9a8 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemIterator.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ItemIterator.java @@ -10,7 +10,6 @@ import java.util.stream.IntStream; import java.util.stream.Stream; public abstract class ItemIterator { - public static final AtomicLong version = new AtomicLong(); protected final Function containerFinder; protected final int fromIndex; diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/JadeCodec.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/JadeCodec.java similarity index 93% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/JadeCodec.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/JadeCodec.java index 895af9b2..a046ae4e 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/JadeCodec.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/JadeCodec.java @@ -6,7 +6,6 @@ import net.minecraft.network.codec.StreamCodec; import org.jetbrains.annotations.NotNull; public class JadeCodec { - public static final StreamCodec PRIMITIVE_STREAM_CODEC = new StreamCodec<>() { @Override public @NotNull Object decode(@NotNull ByteBuf buf) { @@ -53,8 +52,7 @@ public class JadeCodec { ByteBufCodecs.STRING_UTF8.encode(buf, anEnum.name()); } case null -> throw new NullPointerException(); - default -> - throw new IllegalArgumentException("Unknown primitive type: %s (%s)".formatted(o, o.getClass())); + default -> throw new IllegalArgumentException("Unknown primitive type: %s (%s)".formatted(o, o.getClass())); } } }; diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/LootTableMineableCollector.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/LootTableMineableCollector.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/LootTableMineableCollector.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/LootTableMineableCollector.java index 81575cfa..9c580ab3 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/LootTableMineableCollector.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/LootTableMineableCollector.java @@ -50,6 +50,25 @@ public class LootTableMineableCollector { return list; } + public static boolean isCorrectConditions(@NotNull List conditions, ItemStack toolItem) { + if (conditions.size() != 1) { + return false; + } + + LootItemCondition condition = conditions.getFirst(); + if (condition instanceof MatchTool(Optional predicate)) { + ItemPredicate itemPredicate = predicate.orElse(null); + return itemPredicate != null && itemPredicate.test(toolItem); + } else if (condition instanceof AnyOfCondition anyOfCondition) { + for (LootItemCondition child : anyOfCondition.terms) { + if (isCorrectConditions(List.of(child), toolItem)) { + return true; + } + } + } + return false; + } + private boolean doLootTable(LootTable lootTable) { if (lootTable == null || lootTable == LootTable.EMPTY) { return false; @@ -87,23 +106,4 @@ public class LootTableMineableCollector { } return false; } - - public static boolean isCorrectConditions(@NotNull List conditions, ItemStack toolItem) { - if (conditions.size() != 1) { - return false; - } - - LootItemCondition condition = conditions.getFirst(); - if (condition instanceof MatchTool(Optional predicate)) { - ItemPredicate itemPredicate = predicate.orElse(null); - return itemPredicate != null && itemPredicate.test(toolItem); - } else if (condition instanceof AnyOfCondition anyOfCondition) { - for (LootItemCondition child : anyOfCondition.terms) { - if (isCorrectConditions(List.of(child), toolItem)) { - return true; - } - } - } - return false; - } } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java similarity index 92% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java index da1a60ff..9e0dd9cc 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PairHierarchyLookup.java @@ -9,11 +9,9 @@ import net.minecraft.resources.ResourceLocation; import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.Nullable; import org.leavesmc.leaves.LeavesLogger; -import org.leavesmc.leaves.protocol.jade.JadeProtocol; import org.leavesmc.leaves.protocol.jade.provider.IJadeProvider; import java.util.Collection; -import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Objects; @@ -21,7 +19,6 @@ import java.util.concurrent.ExecutionException; import java.util.stream.Stream; public class PairHierarchyLookup implements IHierarchyLookup { - public final IHierarchyLookup first; public final IHierarchyLookup second; private final Cache, Class>, List> mergedCache = CacheBuilder.newBuilder().build(); @@ -47,10 +44,7 @@ public class PairHierarchyLookup implements IHierarchyL } else if (secondList.isEmpty()) { return firstList; } - return ImmutableList.sortedCopyOf( - Comparator.comparingInt(JadeProtocol.priorities::byValue), - Iterables.concat(firstList, secondList) - ); + return ImmutableList.sortedCopyOf(COMPARATOR, Iterables.concat(firstList, secondList)); }); } catch (ExecutionException e) { LeavesLogger.LOGGER.severe(e.toString()); @@ -118,4 +112,4 @@ public class PairHierarchyLookup implements IHierarchyL idMapper = createIdMapper(); } } -} +} \ No newline at end of file diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/PriorityStore.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PriorityStore.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/PriorityStore.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/PriorityStore.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java similarity index 94% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java index 92e1f0df..56f3e4e2 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/ViewGroup.java @@ -12,6 +12,22 @@ import java.util.Map; import java.util.Optional; public class ViewGroup { + public List views; + @Nullable + public String id; + @Nullable + protected CompoundTag extraData; + + public ViewGroup(List views) { + this(views, Optional.empty(), Optional.empty()); + } + + @SuppressWarnings("OptionalUsedAsFieldOrParameterType") + public ViewGroup(List views, Optional id, Optional extraData) { + this.views = views; + this.id = id.orElse(null); + this.extraData = extraData.orElse(null); + } public static StreamCodec> codec(StreamCodec viewCodec) { return StreamCodec.composite( @@ -33,31 +49,10 @@ public class ViewGroup { Map::entry); } - public List views; - @Nullable - public String id; - @Nullable - protected CompoundTag extraData; - - public ViewGroup(List views) { - this(views, Optional.empty(), Optional.empty()); - } - - @SuppressWarnings("OptionalUsedAsFieldOrParameterType") - public ViewGroup(List views, Optional id, Optional extraData) { - this.views = views; - this.id = id.orElse(null); - this.extraData = extraData.orElse(null); - } - public CompoundTag getExtraData() { if (extraData == null) { extraData = new CompoundTag(); } return extraData; } - - public void setProgress(float progress) { - getExtraData().putFloat("Progress", progress); - } } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java similarity index 90% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java index e8d29645..be8abe21 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/jade/util/WrappedHierarchyLookup.java @@ -1,6 +1,8 @@ package org.leavesmc.leaves.protocol.jade.util; +import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; import org.apache.commons.lang3.tuple.Pair; @@ -13,11 +15,11 @@ import org.leavesmc.leaves.protocol.jade.provider.IJadeProvider; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.function.Function; import java.util.stream.Stream; public class WrappedHierarchyLookup extends HierarchyLookup { - public final List, Function, @Nullable Object>>> overrides = Lists.newArrayList(); private boolean empty = true; @@ -39,15 +41,15 @@ public class WrappedHierarchyLookup extends HierarchyLo } public List wrappedGet(Accessor accessor) { - List list = Lists.newArrayList(); + Set set = Sets.newLinkedHashSet(); for (var override : overrides) { Object o = override.getRight().apply(accessor); if (o != null) { - list.addAll(override.getLeft().get(o)); + set.addAll(override.getLeft().get(o)); } } - list.addAll(get(accessor.getTarget())); - return list; + set.addAll(get(accessor.getTarget())); + return ImmutableList.sortedCopyOf(COMPARATOR, set); } @Override diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java similarity index 98% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java index 4853c2d9..114da047 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/CommunicationManager.java @@ -9,6 +9,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.block.Mirror; import net.minecraft.world.level.block.Rotation; +import org.dreeam.leaf.config.modules.network.ProtocolSupport; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.protocol.core.LeavesProtocol; import org.leavesmc.leaves.protocol.core.ProtocolHandler; @@ -30,43 +31,24 @@ import java.util.List; import java.util.Map; import java.util.UUID; -@LeavesProtocol(namespace = "syncmatica") -public class CommunicationManager { - - private static final Map> downloadingFile = new HashMap<>(); - private static final Map playerMap = new HashMap<>(); +@LeavesProtocol.Register(namespace = "syncmatica") +public class CommunicationManager implements LeavesProtocol { protected static final Collection broadcastTargets = new ArrayList<>(); - protected static final Map downloadState = new HashMap<>(); protected static final Map modifyState = new HashMap<>(); - protected static final Rotation[] rotOrdinals = Rotation.values(); protected static final Mirror[] mirOrdinals = Mirror.values(); + private static final Map> downloadingFile = new HashMap<>(); + private static final Map playerMap = new HashMap<>(); public CommunicationManager() { } - public static boolean shouldEnable() { - return org.dreeam.leaf.config.modules.network.ProtocolSupport.syncmaticaProtocol; - } - public static GameProfile getGameProfile(final ExchangeTarget exchangeTarget) { return playerMap.get(exchangeTarget).getGameProfile(); } - public void sendMessage(final @NotNull ExchangeTarget client, final MessageType type, final String identifier) { - if (client.getFeatureSet().hasFeature(Feature.MESSAGE)) { - final FriendlyByteBuf newPacketBuf = new FriendlyByteBuf(Unpooled.buffer()); - newPacketBuf.writeUtf(type.toString()); - newPacketBuf.writeUtf(identifier); - client.sendPacket(PacketType.MESSAGE.identifier, newPacketBuf); - } else if (playerMap.containsKey(client)) { - final ServerPlayer player = playerMap.get(client); - player.sendSystemMessage(Component.literal("Syncmatica " + type.toString() + " " + identifier)); - } - } - @ProtocolHandler.PlayerJoin public static void onPlayerJoin(ServerPlayer player) { final ExchangeTarget newPlayer = player.connection.exchangeTarget; @@ -91,7 +73,7 @@ public class CommunicationManager { playerMap.remove(oldPlayer); } - @ProtocolHandler.PayloadReceiver(payload = SyncmaticaPayload.class, payloadId = "main") + @ProtocolHandler.PayloadReceiver(payload = SyncmaticaPayload.class) public static void onPacketGet(ServerPlayer player, SyncmaticaPayload payload) { onPacket(player.connection.exchangeTarget, payload.packetType(), payload.data()); } @@ -387,4 +369,21 @@ public class CommunicationManager { e.getPartner().getExchanges().remove(e); handleExchange(e); } + + public void sendMessage(final @NotNull ExchangeTarget client, final MessageType type, final String identifier) { + if (client.getFeatureSet().hasFeature(Feature.MESSAGE)) { + final FriendlyByteBuf newPacketBuf = new FriendlyByteBuf(Unpooled.buffer()); + newPacketBuf.writeUtf(type.toString()); + newPacketBuf.writeUtf(identifier); + client.sendPacket(PacketType.MESSAGE.identifier, newPacketBuf); + } else if (playerMap.containsKey(client)) { + final ServerPlayer player = playerMap.get(client); + player.sendSystemMessage(Component.literal("Syncmatica " + type.toString() + " " + identifier)); + } + } + + @Override + public boolean isActive() { + return ProtocolSupport.syncmaticaProtocol; + } } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/Feature.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/Feature.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/Feature.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/Feature.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FeatureSet.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FeatureSet.java similarity index 99% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FeatureSet.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FeatureSet.java index ddd0f498..fdd2e32b 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FeatureSet.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FeatureSet.java @@ -12,8 +12,18 @@ import java.util.Map; public class FeatureSet { private static final Map versionFeatures; + + static { + versionFeatures = new HashMap<>(); + versionFeatures.put("0.1", new FeatureSet(Collections.singletonList(Feature.CORE))); + } + private final Collection features; + public FeatureSet(final Collection features) { + this.features = features; + } + @Nullable public static FeatureSet fromVersionString(@NotNull String version) { if (version.matches("^\\d+(\\.\\d+){2,4}$")) { @@ -52,16 +62,7 @@ public class FeatureSet { return output.toString(); } - public FeatureSet(final Collection features) { - this.features = features; - } - public boolean hasFeature(final Feature f) { return features.contains(f); } - - static { - versionFeatures = new HashMap<>(); - versionFeatures.put("0.1", new FeatureSet(Collections.singletonList(Feature.CORE))); - } } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FileStorage.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FileStorage.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FileStorage.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/FileStorage.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/LocalLitematicState.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/LocalLitematicState.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/LocalLitematicState.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/LocalLitematicState.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/MessageType.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/MessageType.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/MessageType.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/MessageType.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PacketType.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PacketType.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PacketType.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PacketType.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifier.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifier.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifier.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifier.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/PlayerIdentifierProvider.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java index 70759c9d..2c7ca6c1 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPlacement.java @@ -34,6 +34,49 @@ public class ServerPlacement { lastModifiedBy = owner; } + @Nullable + public static ServerPlacement fromJson(final @NotNull JsonObject obj) { + if (obj.has("id") + && obj.has("file_name") + && obj.has("hash") + && obj.has("origin") + && obj.has("rotation") + && obj.has("mirror")) { + final UUID id = UUID.fromString(obj.get("id").getAsString()); + final String name = obj.get("file_name").getAsString(); + final UUID hashValue = UUID.fromString(obj.get("hash").getAsString()); + + PlayerIdentifier owner = PlayerIdentifier.MISSING_PLAYER; + if (obj.has("owner")) { + owner = SyncmaticaProtocol.getPlayerIdentifierProvider().fromJson(obj.get("owner").getAsJsonObject()); + } + + final ServerPlacement newPlacement = new ServerPlacement(id, name, hashValue, owner); + final ServerPosition pos = ServerPosition.fromJson(obj.get("origin").getAsJsonObject()); + if (pos == null) { + return null; + } + newPlacement.origin = pos; + newPlacement.rotation = Rotation.valueOf(obj.get("rotation").getAsString()); + newPlacement.mirror = Mirror.valueOf(obj.get("mirror").getAsString()); + + if (obj.has("lastModifiedBy")) { + newPlacement.lastModifiedBy = SyncmaticaProtocol.getPlayerIdentifierProvider() + .fromJson(obj.get("lastModifiedBy").getAsJsonObject()); + } else { + newPlacement.lastModifiedBy = owner; + } + + if (obj.has("subregionData")) { + newPlacement.subRegionData = SubRegionData.fromJson(obj.get("subregionData")); + } + + return newPlacement; + } + + return null; + } + public UUID getId() { return id; } @@ -120,47 +163,4 @@ public class ServerPlacement { return obj; } - - @Nullable - public static ServerPlacement fromJson(final @NotNull JsonObject obj) { - if (obj.has("id") - && obj.has("file_name") - && obj.has("hash") - && obj.has("origin") - && obj.has("rotation") - && obj.has("mirror")) { - final UUID id = UUID.fromString(obj.get("id").getAsString()); - final String name = obj.get("file_name").getAsString(); - final UUID hashValue = UUID.fromString(obj.get("hash").getAsString()); - - PlayerIdentifier owner = PlayerIdentifier.MISSING_PLAYER; - if (obj.has("owner")) { - owner = SyncmaticaProtocol.getPlayerIdentifierProvider().fromJson(obj.get("owner").getAsJsonObject()); - } - - final ServerPlacement newPlacement = new ServerPlacement(id, name, hashValue, owner); - final ServerPosition pos = ServerPosition.fromJson(obj.get("origin").getAsJsonObject()); - if (pos == null) { - return null; - } - newPlacement.origin = pos; - newPlacement.rotation = Rotation.valueOf(obj.get("rotation").getAsString()); - newPlacement.mirror = Mirror.valueOf(obj.get("mirror").getAsString()); - - if (obj.has("lastModifiedBy")) { - newPlacement.lastModifiedBy = SyncmaticaProtocol.getPlayerIdentifierProvider() - .fromJson(obj.get("lastModifiedBy").getAsJsonObject()); - } else { - newPlacement.lastModifiedBy = owner; - } - - if (obj.has("subregionData")) { - newPlacement.subRegionData = SubRegionData.fromJson(obj.get("subregionData")); - } - - return newPlacement; - } - - return null; - } } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPosition.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPosition.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPosition.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPosition.java index 9775c6c4..63573bce 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPosition.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/ServerPosition.java @@ -15,6 +15,21 @@ public class ServerPosition { dimensionId = dim; } + public static ServerPosition fromJson(final JsonObject obj) { + if (obj.has("position") && obj.has("dimension")) { + final int x; + final int y; + final int z; + final JsonArray arr = obj.get("position").getAsJsonArray(); + x = arr.get(0).getAsInt(); + y = arr.get(1).getAsInt(); + z = arr.get(2).getAsInt(); + final BlockPos pos = new BlockPos(x, y, z); + return new ServerPosition(pos, obj.get("dimension").getAsString()); + } + return null; + } + public BlockPos getBlockPosition() { return position; } @@ -33,19 +48,4 @@ public class ServerPosition { obj.add("dimension", new JsonPrimitive(dimensionId)); return obj; } - - public static ServerPosition fromJson(final JsonObject obj) { - if (obj.has("position") && obj.has("dimension")) { - final int x; - final int y; - final int z; - final JsonArray arr = obj.get("position").getAsJsonArray(); - x = arr.get(0).getAsInt(); - y = arr.get(1).getAsInt(); - z = arr.get(2).getAsInt(); - final BlockPos pos = new BlockPos(x, y, z); - return new ServerPosition(pos, obj.get("dimension").getAsString()); - } - return null; - } } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionData.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionData.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionData.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionData.java index 22fdf92d..09bf7958 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionData.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionData.java @@ -24,6 +24,19 @@ public class SubRegionData { this.modificationData = modificationData; } + @NotNull + public static SubRegionData fromJson(final @NotNull JsonElement obj) { + final SubRegionData newSubRegionData = new SubRegionData(); + + newSubRegionData.isModified = true; + + for (final JsonElement modification : obj.getAsJsonArray()) { + newSubRegionData.modify(SubRegionPlacementModification.fromJson(modification.getAsJsonObject())); + } + + return newSubRegionData; + } + public void reset() { isModified = false; modificationData = null; @@ -67,19 +80,6 @@ public class SubRegionData { return arr; } - @NotNull - public static SubRegionData fromJson(final @NotNull JsonElement obj) { - final SubRegionData newSubRegionData = new SubRegionData(); - - newSubRegionData.isModified = true; - - for (final JsonElement modification : obj.getAsJsonArray()) { - newSubRegionData.modify(SubRegionPlacementModification.fromJson(modification.getAsJsonObject())); - } - - return newSubRegionData; - } - @Override public String toString() { if (!isModified) { diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionPlacementModification.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionPlacementModification.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionPlacementModification.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionPlacementModification.java index a52e299b..24100754 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionPlacementModification.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SubRegionPlacementModification.java @@ -23,22 +23,6 @@ public class SubRegionPlacementModification { this.mirror = mirror; } - public JsonObject toJson() { - final JsonObject obj = new JsonObject(); - - final JsonArray arr = new JsonArray(); - arr.add(position.getX()); - arr.add(position.getY()); - arr.add(position.getZ()); - obj.add("position", arr); - - obj.add("name", new JsonPrimitive(name)); - obj.add("rotation", new JsonPrimitive(rotation.name())); - obj.add("mirror", new JsonPrimitive(mirror.name())); - - return obj; - } - @Nullable public static SubRegionPlacementModification fromJson(final @NotNull JsonObject obj) { if (!obj.has("name") || !obj.has("position") || !obj.has("rotation") || !obj.has("mirror")) { @@ -58,6 +42,22 @@ public class SubRegionPlacementModification { return new SubRegionPlacementModification(name, position, rotation, mirror); } + public JsonObject toJson() { + final JsonObject obj = new JsonObject(); + + final JsonArray arr = new JsonArray(); + arr.add(position.getX()); + arr.add(position.getY()); + arr.add(position.getZ()); + obj.add("position", arr); + + obj.add("name", new JsonPrimitive(name)); + obj.add("rotation", new JsonPrimitive(rotation.name())); + obj.add("mirror", new JsonPrimitive(mirror.name())); + + return obj; + } + @Override public String toString() { return String.format("[name=%s, position=%s, rotation=%s, mirror=%s]", name, position, rotation, mirror); diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticManager.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticManager.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticManager.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticManager.java diff --git a/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java new file mode 100644 index 00000000..d161e736 --- /dev/null +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaPayload.java @@ -0,0 +1,18 @@ +package org.leavesmc.leaves.protocol.syncmatica; + +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.codec.StreamCodec; +import net.minecraft.resources.ResourceLocation; +import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; + +public record SyncmaticaPayload(ResourceLocation packetType, FriendlyByteBuf data) implements LeavesCustomPayload { + + @ID + private static final ResourceLocation NETWORK_ID = ResourceLocation.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()))) + ); +} diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java similarity index 96% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java index 4ee092ce..71a96b1b 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/SyncmaticaProtocol.java @@ -1,5 +1,6 @@ package org.leavesmc.leaves.protocol.syncmatica; +import org.dreeam.leaf.config.modules.network.ProtocolSupport; import org.jetbrains.annotations.NotNull; import java.io.File; @@ -16,14 +17,15 @@ public class SyncmaticaProtocol { public static final String PROTOCOL_ID = "syncmatica"; public static final String PROTOCOL_VERSION = "leaves-syncmatica-1.1.0"; - - private static boolean loaded = false; private static final File litematicFolder = new File("." + File.separator + "syncmatics"); private static final PlayerIdentifierProvider playerIdentifierProvider = new PlayerIdentifierProvider(); private static final CommunicationManager communicationManager = new CommunicationManager(); private static final FeatureSet featureSet = new FeatureSet(Arrays.asList(Feature.values())); private static final SyncmaticManager syncmaticManager = new SyncmaticManager(); private static final FileStorage fileStorage = new FileStorage(); + private static final int[] ILLEGAL_CHARS = {34, 60, 62, 124, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 42, 63, 92, 47}; + private static final String ILLEGAL_PATTERNS = "(^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\\..*)?$)|(^\\.\\.*$)"; + private static boolean loaded = false; public static File getLitematicFolder() { return litematicFolder; @@ -74,9 +76,6 @@ public class SyncmaticaProtocol { return UUID.nameUUIDFromBytes(messageDigest.digest()); } - private static final int[] ILLEGAL_CHARS = {34, 60, 62, 124, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 58, 42, 63, 92, 47}; - private static final String ILLEGAL_PATTERNS = "(^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\\..*)?$)|(^\\.\\.*$)"; - @NotNull public static String sanitizeFileName(final @NotNull String badFileName) { final StringBuilder sanitized = new StringBuilder(); @@ -96,7 +95,7 @@ public class SyncmaticaProtocol { } public static boolean isOverQuota(int sent) { - return org.dreeam.leaf.config.modules.network.ProtocolSupport.syncmaticaQuota && sent > org.dreeam.leaf.config.modules.network.ProtocolSupport.syncmaticaQuotaLimit; + return ProtocolSupport.syncmaticaQuota && sent > ProtocolSupport.syncmaticaQuotaLimit; } public static void backupAndReplace(final Path backup, final Path current, final Path incoming) { diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/AbstractExchange.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/AbstractExchange.java similarity index 84% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/AbstractExchange.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/AbstractExchange.java index da152f02..aa40f0a1 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/AbstractExchange.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/AbstractExchange.java @@ -1,19 +1,28 @@ package org.leavesmc.leaves.protocol.syncmatica.exchange; import net.minecraft.network.FriendlyByteBuf; +import org.leavesmc.leaves.protocol.syncmatica.CommunicationManager; +import org.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol; import java.util.UUID; public abstract class AbstractExchange implements Exchange { + private final ExchangeTarget partner; private boolean success = false; private boolean finished = false; - private final ExchangeTarget partner; protected AbstractExchange(final ExchangeTarget partner) { this.partner = partner; } + protected static boolean checkUUID(final FriendlyByteBuf sourceBuf, final UUID targetId) { + final int r = sourceBuf.readerIndex(); + final UUID sourceId = sourceBuf.readUUID(); + sourceBuf.readerIndex(r); + return sourceId.equals(targetId); + } + @Override public ExchangeTarget getPartner() { return partner; @@ -39,6 +48,10 @@ public abstract class AbstractExchange implements Exchange { } } + public CommunicationManager getManager() { + return SyncmaticaProtocol.getCommunicationManager(); + } + protected void sendCancelPacket() { } @@ -50,11 +63,4 @@ public abstract class AbstractExchange implements Exchange { success = true; onClose(); } - - protected static boolean checkUUID(final FriendlyByteBuf sourceBuf, final UUID targetId) { - final int r = sourceBuf.readerIndex(); - final UUID sourceId = sourceBuf.readUUID(); - sourceBuf.readerIndex(r); - return sourceId.equals(targetId); - } } diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java similarity index 99% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java index 08ab1fe6..5880678b 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/DownloadExchange.java @@ -102,6 +102,7 @@ public class DownloadExchange extends AbstractExchange { @Override protected void onClose() { + getManager(); CommunicationManager.setDownloadState(toDownload, false); try { outputStream.close(); diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java similarity index 99% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java index 856daf28..0f45ef7f 100644 --- a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java +++ b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/Exchange.java @@ -4,7 +4,6 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.resources.ResourceLocation; public interface Exchange { - ExchangeTarget getPartner(); boolean checkPacket(ResourceLocation id, FriendlyByteBuf packetBuf); diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ExchangeTarget.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/FeatureExchange.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/ModifyExchangeServer.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/UploadExchange.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java b/leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java rename to leaf-server/src/main/java/org/leavesmc/leaves/protocol/syncmatica/exchange/VersionHandshakeServer.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/DigestOutputStream.java b/leaf-server/src/main/java/org/leavesmc/leaves/replay/DigestOutputStream.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/DigestOutputStream.java rename to leaf-server/src/main/java/org/leavesmc/leaves/replay/DigestOutputStream.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/RecordMetaData.java b/leaf-server/src/main/java/org/leavesmc/leaves/replay/RecordMetaData.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/RecordMetaData.java rename to leaf-server/src/main/java/org/leavesmc/leaves/replay/RecordMetaData.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/Recorder.java b/leaf-server/src/main/java/org/leavesmc/leaves/replay/Recorder.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/Recorder.java rename to leaf-server/src/main/java/org/leavesmc/leaves/replay/Recorder.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/RecorderOption.java b/leaf-server/src/main/java/org/leavesmc/leaves/replay/RecorderOption.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/RecorderOption.java rename to leaf-server/src/main/java/org/leavesmc/leaves/replay/RecorderOption.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/ReplayFile.java b/leaf-server/src/main/java/org/leavesmc/leaves/replay/ReplayFile.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/ReplayFile.java rename to leaf-server/src/main/java/org/leavesmc/leaves/replay/ReplayFile.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/ReplayMarker.java b/leaf-server/src/main/java/org/leavesmc/leaves/replay/ReplayMarker.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/ReplayMarker.java rename to leaf-server/src/main/java/org/leavesmc/leaves/replay/ReplayMarker.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/ServerPhotographer.java b/leaf-server/src/main/java/org/leavesmc/leaves/replay/ServerPhotographer.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/ServerPhotographer.java rename to leaf-server/src/main/java/org/leavesmc/leaves/replay/ServerPhotographer.java diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/ServerPhotographerGameMode.java b/leaf-server/src/main/java/org/leavesmc/leaves/replay/ServerPhotographerGameMode.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/replay/ServerPhotographerGameMode.java rename to leaf-server/src/main/java/org/leavesmc/leaves/replay/ServerPhotographerGameMode.java diff --git a/leaf-server/src/main/java/org/leavesmc/leaves/util/NbtUtils.java b/leaf-server/src/main/java/org/leavesmc/leaves/util/NbtUtils.java new file mode 100644 index 00000000..3c75d501 --- /dev/null +++ b/leaf-server/src/main/java/org/leavesmc/leaves/util/NbtUtils.java @@ -0,0 +1,75 @@ +package org.leavesmc.leaves.util; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Vec3i; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.DoubleTag; +import net.minecraft.nbt.ListTag; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class NbtUtils { + + public static void writeBlockPosToTag(Vec3i pos, CompoundTag tag) { + tag.putInt("x", pos.getX()); + tag.putInt("y", pos.getY()); + tag.putInt("z", pos.getZ()); + } + + @Nullable + public static BlockPos readBlockPos(@Nullable CompoundTag tag) { + if (tag != null && tag.contains("x") && tag.contains("y") && tag.contains("z")) { + return new BlockPos(tag.getIntOr("x", 0), tag.getIntOr("y", 0), tag.getIntOr("z", 0)); + } + + return null; + } + + public static void writeEntityPositionToTag(Vec3 pos, CompoundTag tag) { + ListTag posList = new ListTag(); + + posList.add(DoubleTag.valueOf(pos.x)); + posList.add(DoubleTag.valueOf(pos.y)); + posList.add(DoubleTag.valueOf(pos.z)); + tag.put("Pos", posList); + } + + @Nullable + public static Vec3 readVec3(@Nullable CompoundTag tag) { + if (tag != null && tag.contains("dx") && tag.contains("dy") && tag.contains("dz")) { + return new Vec3(tag.getDoubleOr("dx", 0.0), tag.getDoubleOr("dy", 0.0), tag.getDoubleOr("dz", 0.0)); + } + return null; + } + + @Nullable + public static Vec3 readEntityPositionFromTag(@Nullable CompoundTag tag) { + if (tag == null || !tag.contains("Pos")) { + return null; + } + ListTag tagList = tag.getListOrEmpty("Pos"); + if (tagList.size() != 3) { + return null; + } + return new Vec3(tagList.getDoubleOr(0, 0.0), tagList.getDoubleOr(1, 0.0), tagList.getDoubleOr(2, 0.0)); + } + + @Nullable + public static Vec3i readVec3iFromTag(@Nullable CompoundTag tag) { + if (tag != null && tag.contains("x") && tag.contains("y") && tag.contains("z")) { + return new Vec3i(tag.getIntOr("x", 0), tag.getIntOr("y", 0), tag.getIntOr("z", 0)); + } + return null; + } + + public static BlockPos readBlockPosFromArrayTag(@NotNull CompoundTag tag, String tagName) { + if (tag.contains(tagName)) { + int[] pos = tag.getIntArray(tagName).orElse(new int[0]); + if (pos.length == 3) { + return new BlockPos(pos[0], pos[1], pos[2]); + } + } + return null; + } +} diff --git a/leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/util/UUIDSerializer.java b/leaf-server/src/main/java/org/leavesmc/leaves/util/UUIDSerializer.java similarity index 100% rename from leaf-archived-patches/unapplied/src/main/java/org/leavesmc/leaves/util/UUIDSerializer.java rename to leaf-server/src/main/java/org/leavesmc/leaves/util/UUIDSerializer.java