mirror of
https://github.com/LeavesMC/Leaves.git
synced 2026-01-04 15:41:31 +00:00
Leaves carpet support
This commit is contained in:
@@ -128,10 +128,10 @@ index a53514f2c510b29f596c361de7bc0b405c27e964..269c7ba0707db4fdc45a70000e0be892
|
||||
.withRequiredArg()
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3572c769f9b5bf66b99d1d6f85312396c27b0fba
|
||||
index 0000000000000000000000000000000000000000..0a7a28151137a34346c9c4aca1ba53f2b77ee55a
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
@@ -0,0 +1,738 @@
|
||||
@@ -0,0 +1,747 @@
|
||||
+package top.leavesmc.leaves;
|
||||
+
|
||||
+import com.destroystokyo.paper.util.SneakyThrow;
|
||||
@@ -198,6 +198,7 @@ index 0000000000000000000000000000000000000000..3572c769f9b5bf66b99d1d6f85312396
|
||||
+ updateConfigVersion(config);
|
||||
+
|
||||
+ LeavesConfig.load(config);
|
||||
+ registerCarpetRules();
|
||||
+
|
||||
+ commands = new HashMap<>();
|
||||
+ }
|
||||
@@ -695,6 +696,14 @@ index 0000000000000000000000000000000000000000..3572c769f9b5bf66b99d1d6f85312396
|
||||
+ despawnEndermanWithBlock = getBoolean("settings.modify.despawn-enderman-with-block", despawnEndermanWithBlock);
|
||||
+ }
|
||||
+
|
||||
+ public static boolean leavesCarpetSupport = false;
|
||||
+ private static void leavesCarpetSupport() {
|
||||
+ leavesCarpetSupport = getBoolean("settings.protocol.leaves-carpet-support", leavesCarpetSupport);
|
||||
+ }
|
||||
+
|
||||
+ public static void registerCarpetRules() {
|
||||
+ }
|
||||
+
|
||||
+ public static final class WorldConfig {
|
||||
+
|
||||
+ public final String worldName;
|
||||
|
||||
@@ -236,7 +236,7 @@ index fc0dc8e607cc24020106ea1af92b4421a5f9393d..81670f76c4d7ccec6f9e95465687c83b
|
||||
}
|
||||
// Water Animals
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
index 3572c769f9b5bf66b99d1d6f85312396c27b0fba..5332774b2e68144aeac0b4e31ceacffa3d5bbf80 100644
|
||||
index 0a7a28151137a34346c9c4aca1ba53f2b77ee55a..b097f72c1009d4c9618e1eece839f53d7429b528 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
@@ -7,6 +7,9 @@ import org.bukkit.Bukkit;
|
||||
@@ -249,8 +249,8 @@ index 3572c769f9b5bf66b99d1d6f85312396c27b0fba..5332774b2e68144aeac0b4e31ceacffa
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -66,6 +69,11 @@ public final class LeavesConfig {
|
||||
LeavesConfig.load(config);
|
||||
@@ -67,6 +70,11 @@ public final class LeavesConfig {
|
||||
registerCarpetRules();
|
||||
|
||||
commands = new HashMap<>();
|
||||
+
|
||||
|
||||
@@ -22,7 +22,7 @@ index 9522e646529f3d849471931b4b3c0d133e7fcfc5..e8e5be743f1303589ad0d3bcb14d6f37
|
||||
|
||||
private final BlockState first;
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
index 2c97c13f9d148b97a9492766aee976d035750ab6..adf3af6d8b07e3f274168885c6b522b2ff8cd976 100644
|
||||
index b097f72c1009d4c9618e1eece839f53d7429b528..38a547e221be452e5227a855e9a59abf7ab87dd4 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
@@ -3,6 +3,8 @@ package top.leavesmc.leaves;
|
||||
@@ -34,7 +34,7 @@ index 2c97c13f9d148b97a9492766aee976d035750ab6..adf3af6d8b07e3f274168885c6b522b2
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -212,6 +214,7 @@ public final class LeavesConfig {
|
||||
@@ -213,6 +215,7 @@ public final class LeavesConfig {
|
||||
public static boolean buddingAmethystCanPushByPiston = false;
|
||||
private static void buddingAmethystCanPushByPiston() {
|
||||
buddingAmethystCanPushByPiston = getBoolean("settings.modify.budding-amethyst-can-push-by-piston", buddingAmethystCanPushByPiston);
|
||||
|
||||
@@ -19,10 +19,10 @@ index 089dd93d4cd4c1f72e63c4944b3b82c1e2ba732d..73bf34c3ce7e55e9fd15a3af90bf107e
|
||||
// CraftBukkit end
|
||||
Objects.requireNonNull(info);
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
index adf3af6d8b07e3f274168885c6b522b2ff8cd976..6a1b9bb88acba3b529ff80d559d11b565456e9d3 100644
|
||||
index 38a547e221be452e5227a855e9a59abf7ab87dd4..a5091db99c663cb0dcbd35897f70d3f9a07fc4ba 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
@@ -236,7 +236,7 @@ public final class LeavesConfig {
|
||||
@@ -237,7 +237,7 @@ public final class LeavesConfig {
|
||||
noChatSign = getBoolean("settings.misc.no-chat-sign", noChatSign);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ Subject: [PATCH] Multithreaded Tracker
|
||||
This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)
|
||||
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
index 6a1b9bb88acba3b529ff80d559d11b565456e9d3..1e9ebd81594320a9e75740d410fecd5a66a51a31 100644
|
||||
index a5091db99c663cb0dcbd35897f70d3f9a07fc4ba..383f1eddb640c80de5bb737f90d947d546685039 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
@@ -255,7 +255,7 @@ public final class LeavesConfig {
|
||||
@@ -256,7 +256,7 @@ public final class LeavesConfig {
|
||||
dontSendUselessEntityPackets = getBoolean("settings.performance.dont-send-useless-entity-packets", dontSendUselessEntityPackets);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ This patch is Powered by Pufferfish(https://github.com/pufferfish-gg/Pufferfish)
|
||||
But Pufferfish patch was ported downstream from the Petal fork
|
||||
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
index 1e9ebd81594320a9e75740d410fecd5a66a51a31..77513f66b5d595a3ada956eaaa22fdbf9318f153 100644
|
||||
index 383f1eddb640c80de5bb737f90d947d546685039..2aa2f773de6a981c5f035ef2bfdc568b04ebf190 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
@@ -356,7 +356,7 @@ public final class LeavesConfig {
|
||||
@@ -357,7 +357,7 @@ public final class LeavesConfig {
|
||||
// only config now
|
||||
public static boolean asyncPathfinding = false;
|
||||
private static boolean asyncPathfindingLock = false;
|
||||
|
||||
@@ -70,7 +70,7 @@ index c767257b56acbe2cde391f405c010f5b2f62a17c..4327ec0948fb82939272f2dc1bbde8b1
|
||||
entity.spawnReason == org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.CHUNK_GEN)) {
|
||||
continue;
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
index d92c00454200684b3b27e74d2b53f4eb2e30851a..82277d55e8aa3fb71832192696f97c65341b2016 100644
|
||||
index 2aa2f773de6a981c5f035ef2bfdc568b04ebf190..8cc74b1eb94ca5e246a667aada013de3af3a4c45 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
@@ -2,6 +2,7 @@ package top.leavesmc.leaves;
|
||||
@@ -81,7 +81,7 @@ index d92c00454200684b3b27e74d2b53f4eb2e30851a..82277d55e8aa3fb71832192696f97c65
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
@@ -476,6 +477,13 @@ public final class LeavesConfig {
|
||||
@@ -477,6 +478,13 @@ public final class LeavesConfig {
|
||||
|
||||
public static void doMcTechnicalMode() {
|
||||
if (mcTechnicalMode) {
|
||||
|
||||
@@ -31,7 +31,7 @@ index dae36c6452ccd57a436dd918547b64d59957ab0a..973ecf723e4239307600b42f2d12c264
|
||||
String s = (String) Optional.ofNullable((String) optionset.valueOf("world")).orElse(dedicatedserversettings.getProperties().levelName);
|
||||
LevelStorageSource convertable = LevelStorageSource.createDefault(file.toPath());
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
index 2717bd11e449fbc38e886ff7f70b71e55d703e52..e520c2e95620db70f9b1881188cb05fcf7ca18e4 100644
|
||||
index 8cc74b1eb94ca5e246a667aada013de3af3a4c45..01cc4ae723d5681c17d6a65412987199029fe36b 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
@@ -12,6 +12,7 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
@@ -42,7 +42,7 @@ index 2717bd11e449fbc38e886ff7f70b71e55d703e52..e520c2e95620db70f9b1881188cb05fc
|
||||
import top.leavesmc.leaves.util.MathUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -510,6 +511,9 @@ public final class LeavesConfig {
|
||||
@@ -511,6 +512,9 @@ public final class LeavesConfig {
|
||||
extraYggdrasilService = getBoolean("settings.misc.extra-yggdrasil-service.enable", extraYggdrasilService);
|
||||
extraYggdrasilServiceList = getList("settings.misc.extra-yggdrasil-service.urls", extraYggdrasilServiceList);
|
||||
if (extraYggdrasilService) {
|
||||
|
||||
@@ -54,7 +54,7 @@ index 0acb073649a286f9756974e941aa5da7ed09ed0d..b616b819a1434fe76a6fa36e70cdc1c2
|
||||
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", ex);
|
||||
this.disconnect("Invalid custom payload!", org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PAYLOAD);
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/LeavesConfig.java b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
index 86ab00d8b17e6fb5c79b11a4d1b0abe5765e67fe..55d18ef11eacbb6ba0de9a6a6f8ca79a84bac8ce 100644
|
||||
index 01cc4ae723d5681c17d6a65412987199029fe36b..61597ff3c16fbfc6f4c5bcf8455b43724aaeb2d0 100644
|
||||
--- a/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
+++ b/src/main/java/top/leavesmc/leaves/LeavesConfig.java
|
||||
@@ -13,6 +13,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@@ -65,7 +65,7 @@ index 86ab00d8b17e6fb5c79b11a4d1b0abe5765e67fe..55d18ef11eacbb6ba0de9a6a6f8ca79a
|
||||
import top.leavesmc.leaves.util.MathUtils;
|
||||
|
||||
import java.io.File;
|
||||
@@ -548,6 +549,7 @@ public final class LeavesConfig {
|
||||
@@ -549,6 +550,7 @@ public final class LeavesConfig {
|
||||
syncmaticaQuota = getBoolean("settings.protocol.syncmatica.quota", syncmaticaQuota);
|
||||
syncmaticaQuotaLimit = getInt("settings.protocol.syncmatica.quota-limit", syncmaticaQuotaLimit);
|
||||
if (syncmaticaProtocol) {
|
||||
|
||||
123
patches/server/0070-Leaves-carpet-support.patch
Normal file
123
patches/server/0070-Leaves-carpet-support.patch
Normal file
@@ -0,0 +1,123 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
||||
Date: Tue, 27 Jun 2023 01:54:43 +0800
|
||||
Subject: [PATCH] Leaves carpet support
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
index 9ad3dbb4b376b04ddc9729bf46185d9aafa45891..6d40c0b3fbccaa86207603f38b073f36df3880e6 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
||||
@@ -3576,6 +3576,9 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
|
||||
if (top.leavesmc.leaves.LeavesConfig.syncmaticaProtocol && ProtocolUtils.isNamespacePacket(packet, top.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol.PROTOCOL_ID)) {
|
||||
top.leavesmc.leaves.protocol.syncmatica.SyncmaticaProtocol.getCommunicationManager().onPacketGet(packet, this);
|
||||
}
|
||||
+ if (top.leavesmc.leaves.LeavesConfig.leavesCarpetSupport && ProtocolUtils.isNamespacePacket(packet, top.leavesmc.leaves.protocol.CarpetServerProtocol.PROTOCOL_ID)) {
|
||||
+ top.leavesmc.leaves.protocol.CarpetServerProtocol.handlePacket(player, packet);
|
||||
+ }
|
||||
} catch (Exception ex) {
|
||||
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", ex);
|
||||
this.disconnect("Invalid custom payload!", org.bukkit.event.player.PlayerKickEvent.Cause.INVALID_PAYLOAD);
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 6c19d9b64830efe4b9d6f17d8ca92f88ad3475d5..fb6810289ac855e622d3970101f27b2133bd67d2 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -364,6 +364,7 @@ public abstract class PlayerList {
|
||||
top.leavesmc.leaves.protocol.BBORProtocol.onPlayerLoggedIn(player); // Leaves - bbor
|
||||
top.leavesmc.leaves.protocol.JadeProtocol.onPlayerJoin(player); // Leaves - Jade
|
||||
top.leavesmc.leaves.protocol.AppleSkinProtocol.onPlayerLoggedIn(player); // Leaves - appleskin
|
||||
+ top.leavesmc.leaves.protocol.CarpetServerProtocol.onPlayerJoin(player); // Leaves - carpet
|
||||
|
||||
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();
|
||||
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/protocol/CarpetServerProtocol.java b/src/main/java/top/leavesmc/leaves/protocol/CarpetServerProtocol.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..afcbb7b8c9a6e933665500b068fe7c9111658df7
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/protocol/CarpetServerProtocol.java
|
||||
@@ -0,0 +1,85 @@
|
||||
+package top.leavesmc.leaves.protocol;
|
||||
+
|
||||
+import io.netty.buffer.Unpooled;
|
||||
+import net.minecraft.nbt.CompoundTag;
|
||||
+import net.minecraft.network.FriendlyByteBuf;
|
||||
+import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
|
||||
+import net.minecraft.resources.ResourceLocation;
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
+import org.jetbrains.annotations.Contract;
|
||||
+import org.jetbrains.annotations.NotNull;
|
||||
+import top.leavesmc.leaves.LeavesConfig;
|
||||
+import top.leavesmc.leaves.LeavesLogger;
|
||||
+import top.leavesmc.leaves.util.ProtocolUtils;
|
||||
+
|
||||
+import java.util.HashMap;
|
||||
+import java.util.Map;
|
||||
+
|
||||
+public class CarpetServerProtocol {
|
||||
+
|
||||
+ public static final String PROTOCOL_ID = "carpet";
|
||||
+
|
||||
+ private static final ResourceLocation HELLO_ID = id("hello"); // why?????????????
|
||||
+
|
||||
+ private static final int HI = 69;
|
||||
+ private static final int HELLO = 420;
|
||||
+ private static final int DATA = 1;
|
||||
+
|
||||
+ @Contract("_ -> new")
|
||||
+ public static @NotNull ResourceLocation id(String path) {
|
||||
+ return new ResourceLocation(PROTOCOL_ID, path);
|
||||
+ }
|
||||
+
|
||||
+ public static void handlePacket(ServerPlayer player, @NotNull ServerboundCustomPayloadPacket packet) {
|
||||
+ if (packet.identifier.equals(HELLO_ID)) {
|
||||
+ FriendlyByteBuf data = packet.data;
|
||||
+ if (data.readVarInt() == HELLO) {
|
||||
+ handleHello(player, data);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private static void handleHello(@NotNull ServerPlayer player, @NotNull FriendlyByteBuf data) {
|
||||
+ LeavesLogger.LOGGER.info("Player " + player.getScoreboardName() + " joined with carpet " + data.readUtf(64));
|
||||
+ ProtocolUtils.sendPayloadPacket(player, HELLO_ID, CarpetRules.buildBuf());
|
||||
+ }
|
||||
+
|
||||
+ public static void onPlayerJoin(ServerPlayer player) {
|
||||
+ if (LeavesConfig.leavesCarpetSupport) {
|
||||
+ FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
|
||||
+ buf.writeVarInt(HI).writeUtf("leaves-carpet-1.0.0");
|
||||
+ ProtocolUtils.sendPayloadPacket(player, HELLO_ID, buf);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public static class CarpetRules {
|
||||
+
|
||||
+ public static Map<String, CarpetRule> rules = new HashMap<>();
|
||||
+
|
||||
+ @NotNull
|
||||
+ public static FriendlyByteBuf buildBuf() {
|
||||
+ FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer());
|
||||
+ buf.writeVarInt(1);
|
||||
+
|
||||
+ CompoundTag rulesNbt = new CompoundTag();
|
||||
+ rules.values().forEach(rule -> rule.writeNBT(rulesNbt));
|
||||
+
|
||||
+ CompoundTag tag = new CompoundTag();
|
||||
+ tag.put("Rules", rulesNbt);
|
||||
+ buf.writeNbt(tag);
|
||||
+
|
||||
+ return buf;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public record CarpetRule(String identifier, String name, String value) {
|
||||
+ public void writeNBT(@NotNull CompoundTag rules) {
|
||||
+ CompoundTag rule = new CompoundTag();
|
||||
+ rule.putString("Value", value);
|
||||
+ rule.putString("Manager", identifier);
|
||||
+ rule.putString("Rule", name);
|
||||
+ rules.put(name, rule);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
Reference in New Issue
Block a user