Skip to content

Commit

Permalink
Some server patches work
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq committed Jun 21, 2024
1 parent 8826f78 commit 36bb626
Show file tree
Hide file tree
Showing 32 changed files with 209 additions and 205 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,26 @@ Original project: https://github.com/LeavesMC/Leaves
Commit: e234432bd99e1c4b07c24d1dd247977226a7516a

diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 0fafe65e9f0ee85469d80a1033078b20a7abbfcf..fd937544baae6835e1826a686676dcbfa58aca33 100644
index 43b13836406ac6a7f26317f029225e6b2c9f2ea8..a8c7a433043ae670a34764ab3947b11b2fbf1671 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -430,6 +430,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -434,6 +434,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
public boolean activatedPriorityReset = false; // Pufferfish - DAB
public int activatedPriority = org.dreeam.leaf.config.modules.opt.DynamicActivationofBrain.maximumActivationPrio; // Pufferfish - DAB (golf score)
public @Nullable Boolean immuneToFire = null; // Purpur - Fire immune API
+ private CompoundTag leavesData = new CompoundTag(); // Leaves - Leaves ex data

public void setOrigin(@javax.annotation.Nonnull Location location) {
this.origin = location.toVector();
@@ -2626,6 +2627,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -2528,6 +2529,7 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
nbttagcompound.putBoolean("Purpur.FireImmune", immuneToFire);
}
// Purpur end
+ nbttagcompound.put("Leaves.Data", leavesData); // Leaves - leaves ex data
return nbttagcompound;
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -2778,6 +2780,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -2680,6 +2682,11 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
immuneToFire = nbt.getBoolean("Purpur.FireImmune");
}
// Purpur end
Expand All @@ -40,7 +40,7 @@ index 0fafe65e9f0ee85469d80a1033078b20a7abbfcf..fd937544baae6835e1826a686676dcbf

} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
@@ -5222,4 +5229,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
@@ -5050,4 +5057,10 @@ public abstract class Entity implements SyncedDataHolder, Nameable, EntityAccess
return false;
}
// Purpur end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Original project: https://github.com/LeavesMC/Leaves
Commit: e234432bd99e1c4b07c24d1dd247977226a7516a

diff --git a/src/main/java/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java b/src/main/java/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
index 663b3b12d9a7cdc04b7f86ccfe6bc6fcfd5028bc..a58ad6f41fc0eacf020e9ab6c8e5f7dfc4977f8d 100644
index a4f9de18d40d5d85a809af3777b00eb75b1af027..b2048639f652cb16358901052af0c6c68ebf7716 100644
--- a/src/main/java/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
+++ b/src/main/java/net/minecraft/network/protocol/common/custom/CustomPacketPayload.java
@@ -40,13 +40,23 @@ public interface CustomPacketPayload {
Expand Down Expand Up @@ -40,10 +40,10 @@ index 663b3b12d9a7cdc04b7f86ccfe6bc6fcfd5028bc..a58ad6f41fc0eacf020e9ab6c8e5f7df
};
}
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 03a787c9bafee3a6b300703cf05a6a65bd4e9c03..3e150865ba40413a9caf5e92cd6c4d60debb59da 100644
index 0eac388d53d65d6dbd6900040be4d661cc799765..3d6be33c3310da2bfacba887e8ba12840d2f811c 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1785,6 +1785,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@@ -1739,6 +1739,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
GameTestTicker.SINGLETON.tick();
}

Expand All @@ -53,10 +53,10 @@ index 03a787c9bafee3a6b300703cf05a6a65bd4e9c03..3e150865ba40413a9caf5e92cd6c4d60
((Runnable) this.tickables.get(i)).run();
}
diff --git a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
index 0805eae5d770a5cc9c0b96ec11de6d9c9faf2d1d..392a8ce9c36c5d464df3a7d6a75737e19c22bdbb 100644
index b66fdb789fcb460d63fd81540112d655c9a0c3f2..ae0d0310d50f1ada082e045a58a24a43f8079da8 100644
--- a/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerCommonPacketListenerImpl.java
@@ -168,6 +168,11 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
@@ -169,6 +169,11 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack

@Override
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {
Expand All @@ -68,7 +68,7 @@ index 0805eae5d770a5cc9c0b96ec11de6d9c9faf2d1d..392a8ce9c36c5d464df3a7d6a75737e1
// Paper start - Brand support
if (packet.payload() instanceof net.minecraft.network.protocol.common.custom.BrandPayload brandPayload) {
this.player.clientBrandName = brandPayload.brand();
@@ -185,6 +190,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
@@ -186,6 +191,7 @@ public abstract class ServerCommonPacketListenerImpl implements ServerCommonPack
String channels = payload.toString(com.google.common.base.Charsets.UTF_8);
for (String channel : channels.split("\0")) {
this.getCraftPlayer().addChannel(channel);
Expand All @@ -77,10 +77,10 @@ index 0805eae5d770a5cc9c0b96ec11de6d9c9faf2d1d..392a8ce9c36c5d464df3a7d6a75737e1
} catch (Exception ex) {
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t register custom payload", ex);
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 2e98c6598e589b498991c745058db3c0efb9cbf6..0d65a53b23c82cbc4539afd28c52b5fd2d2ff5b4 100644
index 360b52002fe8bc9dd27a4fe3831ed6f5dfe8d6c6..44abb103462dc5a2718b3112e94342c39dead554 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -365,6 +365,8 @@ public abstract class PlayerList {
@@ -363,6 +363,8 @@ public abstract class PlayerList {

player.didPlayerJoinEvent = true; // Gale - EMC - do not process chat/commands before player has joined

Expand All @@ -89,7 +89,7 @@ index 2e98c6598e589b498991c745058db3c0efb9cbf6..0d65a53b23c82cbc4539afd28c52b5fd
final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();

if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure
@@ -618,6 +620,7 @@ public abstract class PlayerList {
@@ -609,6 +611,7 @@ public abstract class PlayerList {
return this.remove(entityplayer, net.kyori.adventure.text.Component.translatable("multiplayer.player.left", net.kyori.adventure.text.format.NamedTextColor.YELLOW, io.papermc.paper.configuration.GlobalConfiguration.get().messages.useDisplayNameInQuitMessage ? entityplayer.getBukkitEntity().displayName() : io.papermc.paper.adventure.PaperAdventure.asAdventure(entityplayer.getDisplayName())));
}
public net.kyori.adventure.text.Component remove(ServerPlayer entityplayer, net.kyori.adventure.text.Component leaveMessage) {
Expand All @@ -98,18 +98,18 @@ index 2e98c6598e589b498991c745058db3c0efb9cbf6..0d65a53b23c82cbc4539afd28c52b5fd
org.purpurmc.purpur.task.BossBarTask.removeFromAll(entityplayer.getBukkitEntity()); // Purpur
ServerLevel worldserver = entityplayer.serverLevel();
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index c8e424d6646f782c8fbd97c1e699115304983533..31b5beb4c3a3712d4f38a4ffef09675050f2eb04 100644
index ec341e053e8eb539d4401161245039c90609138c..8e1bc7b117ac0766e3eb0f38cb33b71d6a972fb8 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -488,6 +488,7 @@ public final class CraftServer implements Server {
@@ -491,6 +491,7 @@ public final class CraftServer implements Server {
}
this.potionBrewer = new io.papermc.paper.potion.PaperPotionBrewer(console); // Paper - custom potion mixes
datapackManager = new io.papermc.paper.datapack.PaperDatapackManager(console.getPackRepository()); // Paper
+ org.leavesmc.leaves.protocol.core.LeavesProtocolManager.init(); // Leaves - protocol
}

public boolean getCommandBlockOverride(String command) {
@@ -1110,6 +1111,7 @@ public final class CraftServer implements Server {
@@ -1113,6 +1114,7 @@ public final class CraftServer implements Server {
org.purpurmc.purpur.PurpurConfig.registerCommands(); // Purpur
this.overrideAllCommandBlockCommands = this.commandsConfiguration.getStringList("command-block-overrides").contains("*");
this.ignoreVanillaPermissions = this.commandsConfiguration.getBoolean("ignore-vanilla-permissions");
Expand Down Expand Up @@ -193,12 +193,13 @@ index 0000000000000000000000000000000000000000..986d2a6641ff8017dddf3e5f2655adfc
+}
diff --git a/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..2356bb3bc68d2a33329b7c4a41b48f1a52576ccb
index 0000000000000000000000000000000000000000..09b27b164e0ffb37ae75f94c9d5dd5ff2a83e372
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
@@ -0,0 +1,368 @@
@@ -0,0 +1,369 @@
+package org.leavesmc.leaves.protocol.core;
+
+import net.kyori.adventure.text.Component;
+import net.minecraft.network.FriendlyByteBuf;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.level.ServerPlayer;
Expand Down Expand Up @@ -364,7 +365,7 @@ index 0000000000000000000000000000000000000000..2356bb3bc68d2a33329b7c4a41b48f1a
+
+ public static void handlePayload(ServerPlayer player, LeavesCustomPayload<?> payload) {
+ if (payload instanceof ErrorPayload errorPayload) {
+ player.connection.disconnect("Payload " + Arrays.toString(errorPayload.packetID) + " from " + Arrays.toString(errorPayload.protocolID) + " error", PlayerKickEvent.Cause.INVALID_PAYLOAD);
+ player.connection.disconnect(Component.text("Payload " + Arrays.toString(errorPayload.packetID) + " from " + Arrays.toString(errorPayload.protocolID) + " error"), PlayerKickEvent.Cause.INVALID_PAYLOAD);
+ return;
+ }
+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Commit: e234432bd99e1c4b07c24d1dd247977226a7516a
This patch is Powered by Jade (https://github.com/Snownee/Jade)

diff --git a/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java b/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java
index 063dde771ade593a29481f14b8f44a0f72f15953..877fe6312051f2669360b85c0caded7b47f04866 100644
index 7c7b063b0b563716757294792653a705fe7436f9..0d85300632c6476152e6c1072f84cb75d38dea77 100644
--- a/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java
+++ b/src/main/java/net/minecraft/world/entity/animal/armadillo/Armadillo.java
@@ -58,7 +58,7 @@ public class Armadillo extends Animal {
@@ -59,7 +59,7 @@ public class Armadillo extends Animal {
public final AnimationState rollOutAnimationState = new AnimationState();
public final AnimationState rollUpAnimationState = new AnimationState();
public final AnimationState peekAnimationState = new AnimationState();
Expand All @@ -24,10 +24,10 @@ index 063dde771ade593a29481f14b8f44a0f72f15953..877fe6312051f2669360b85c0caded7b

public Armadillo(EntityType<? extends Animal> type, Level world) {
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
index e6861fd5f9817ec54294976f0e93952baa387773..45f92d8fd06027f1487e24987c3fb9a389f619a9 100644
index c51637514bf671c08dbe4e5ac55566b92b5876f9..5addd3243dd63041442f2a6bcf92a2128e4242c1 100644
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
@@ -290,7 +290,7 @@ public class Tadpole extends AbstractFish {
@@ -291,7 +291,7 @@ public class Tadpole extends AbstractFish {

}

Expand All @@ -37,10 +37,10 @@ index e6861fd5f9817ec54294976f0e93952baa387773..45f92d8fd06027f1487e24987c3fb9a3
}

diff --git a/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java b/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java
index fca0131b9a90ac026a24cf579b17928c19173f3f..f8d0a8ea39cd90a9b45ff97e32e0e7224ddd8808 100644
index 055f4b87c01ee7ecf7d2a111b72cc5aa85d9fbe8..5d9030f4787a43c56ae9455180badd5658dea35b 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/trialspawner/TrialSpawnerData.java
@@ -68,7 +68,7 @@ public class TrialSpawnerData {
@@ -72,7 +72,7 @@ public class TrialSpawnerData {
});
public final Set<UUID> detectedPlayers;
public final Set<UUID> currentMobs;
Expand All @@ -62,10 +62,10 @@ index c852b3a8d31bc73d32aef215e4d3a82aa1fd8f19..b63d87d0593d116b0c5ee835dc4372f1
+ public static boolean jadeProtocol = false;
}
diff --git a/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
index 2356bb3bc68d2a33329b7c4a41b48f1a52576ccb..25dc0a249d47d20d52fa279cb03acfa0181885e2 100644
index 09b27b164e0ffb37ae75f94c9d5dd5ff2a83e372..12345854c2cc338909cc52f28c18c2c926f318d4 100644
--- a/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
+++ b/src/main/java/org/leavesmc/leaves/protocol/core/LeavesProtocolManager.java
@@ -34,7 +34,7 @@ import java.util.jar.JarFile;
@@ -35,7 +35,7 @@ import java.util.jar.JarFile;

public class LeavesProtocolManager {

Expand All @@ -76,7 +76,7 @@ index 2356bb3bc68d2a33329b7c4a41b48f1a52576ccb..25dc0a249d47d20d52fa279cb03acfa0
private static final Map<LeavesProtocol, Map<ProtocolHandler.PayloadReceiver, Method>> KNOW_RECEIVERS = new HashMap<>();
diff --git a/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java
new file mode 100644
index 0000000000000000000000000000000000000000..f3347bea49b80621b6f69b0e0aac63cf55db6b3e
index 0000000000000000000000000000000000000000..ff9dbddfab5f2879bfeba2b425ee6b831a720461
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/protocol/jade/JadeProtocol.java
@@ -0,0 +1,343 @@
Expand Down Expand Up @@ -185,20 +185,20 @@ index 0000000000000000000000000000000000000000..f3347bea49b80621b6f69b0e0aac63cf
+
+ @Contract("_ -> new")
+ public static @NotNull ResourceLocation id(String path) {
+ return new ResourceLocation(PROTOCOL_ID, path);
+ return ResourceLocation.fromNamespaceAndPath(PROTOCOL_ID, path);
+ }
+
+ @Contract("_ -> new")
+ public static @NotNull ResourceLocation mc_id(String path) {
+ return new ResourceLocation(path);
+ return ResourceLocation.withDefaultNamespace(path);
+ }
+
+ private static boolean isPrimaryKey(ResourceLocation key) {
+ return !key.getPath().contains(".");
+ }
+
+ private static ResourceLocation getPrimaryKey(ResourceLocation key) {
+ return new ResourceLocation(key.getNamespace(), key.getPath().substring(0, key.getPath().indexOf('.')));
+ return ResourceLocation.fromNamespaceAndPath(key.getNamespace(), key.getPath().substring(0, key.getPath().indexOf('.')));
+ }
+
+ @ProtocolHandler.Init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ index b63d87d0593d116b0c5ee835dc4372f1b5542453..ef23577faaf7948d7a9b1def4d56506e
}
diff --git a/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java
new file mode 100644
index 0000000000000000000000000000000000000000..c496c97c99cd352c2566731d3017cf1b14ee74ec
index 0000000000000000000000000000000000000000..2580d188b6b5213bb906b487052b9e5fd8153696
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/protocol/AppleSkinProtocol.java
@@ -0,0 +1,105 @@
Expand Down Expand Up @@ -63,7 +63,7 @@ index 0000000000000000000000000000000000000000..c496c97c99cd352c2566731d3017cf1b
+
+ @Contract("_ -> new")
+ public static @NotNull ResourceLocation id(String path) {
+ return new ResourceLocation(PROTOCOL_ID, path);
+ return ResourceLocation.fromNamespaceAndPath(PROTOCOL_ID, path);
+ }
+
+ @ProtocolHandler.PlayerJoin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Commit: e234432bd99e1c4b07c24d1dd247977226a7516a
This patch is Powered by Xaero Map

diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 0d65a53b23c82cbc4539afd28c52b5fd2d2ff5b4..c410f781371a87ecc2849144c747a6ac3182a65a 100644
index 44abb103462dc5a2718b3112e94342c39dead554..5075e22ae84191b3d94ce7a8bcbf0ef7735e7f28 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -1376,6 +1376,7 @@ public abstract class PlayerList {
@@ -1314,6 +1314,7 @@ public abstract class PlayerList {
player.connection.send(new ClientboundInitializeBorderPacket(worldborder));
player.connection.send(new ClientboundSetTimePacket(world.getGameTime(), world.getDayTime(), world.getGameRules().getBoolean(GameRules.RULE_DAYLIGHT)));
player.connection.send(new ClientboundSetDefaultSpawnPositionPacket(world.getSharedSpawnPos(), world.getSharedSpawnAngle()));
Expand Down Expand Up @@ -47,7 +47,7 @@ index ef23577faaf7948d7a9b1def4d56506eab19cc80..c9736e79387d785a67d6ebe71df6553e
}
diff --git a/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java b/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java
new file mode 100644
index 0000000000000000000000000000000000000000..9e35dfaf8bb5511b4cd0a71175d7ecb6d835042f
index 0000000000000000000000000000000000000000..22f6e492232d31bbe861d5747af8aa5bdbb96112
--- /dev/null
+++ b/src/main/java/org/leavesmc/leaves/protocol/XaeroMapProtocol.java
@@ -0,0 +1,41 @@
Expand All @@ -71,12 +71,12 @@ index 0000000000000000000000000000000000000000..9e35dfaf8bb5511b4cd0a71175d7ecb6
+
+ @Contract("_ -> new")
+ public static @NotNull ResourceLocation idMini(String path) {
+ return new ResourceLocation(PROTOCOL_ID_MINI, path);
+ return ResourceLocation.fromNamespaceAndPath(PROTOCOL_ID_MINI, path);
+ }
+
+ @Contract("_ -> new")
+ public static @NotNull ResourceLocation idWorld(String path) {
+ return new ResourceLocation(PROTOCOL_ID_WORLD, path);
+ return ResourceLocation.fromNamespaceAndPath(PROTOCOL_ID_WORLD, path);
+ }
+
+ public static void onSendWorldInfo(@NotNull ServerPlayer player) {
Expand Down
Loading

0 comments on commit 36bb626

Please sign in to comment.