From 006f93dc5f7ca54e4a3f1272157c5541f5df75df Mon Sep 17 00:00:00 2001 From: acrylic-style Date: Tue, 30 Jul 2024 13:29:28 +0900 Subject: [PATCH] fix custom payload & mixins --- .../network/BlueberryNetworkManager.java | 2 +- MagmaCube-Patches/0005-Mods-support.patch | 15 +++++++++++++-- scripts/files/version.json | 11 +++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/Blueberry-API/src/main/java/net/blueberrymc/network/BlueberryNetworkManager.java b/Blueberry-API/src/main/java/net/blueberrymc/network/BlueberryNetworkManager.java index 33830b3..1a8a5db 100644 --- a/Blueberry-API/src/main/java/net/blueberrymc/network/BlueberryNetworkManager.java +++ b/Blueberry-API/src/main/java/net/blueberrymc/network/BlueberryNetworkManager.java @@ -138,7 +138,7 @@ public static void sendToClient(@NotNull ServerGamePacketListenerImpl connection connection.send(customPayloadPacket); } - @SuppressWarnings("JavaReflectionMemberAccess") + @SuppressWarnings("JavaReflectionMemberAccess") // constructor is defined in Blueberry-Client private static @NotNull DiscardedPayload createCustomPayload(ResourceLocation id, ByteBuf buf) { byte[] bytes = new byte[buf.readableBytes()]; buf.readBytes(bytes); diff --git a/MagmaCube-Patches/0005-Mods-support.patch b/MagmaCube-Patches/0005-Mods-support.patch index 970ea5f..ad3b529 100644 --- a/MagmaCube-Patches/0005-Mods-support.patch +++ b/MagmaCube-Patches/0005-Mods-support.patch @@ -687,10 +687,10 @@ index 33827434b04f08893431f622c5aeed89b6471c74..d45f7e26f20272b0bfc02f0ca821ed3a iterable.forEach(blockState -> this.modelGroups.put(blockState, i)); } diff --git a/src/main/java/net/minecraft/network/protocol/common/custom/DiscardedPayload.java b/src/main/java/net/minecraft/network/protocol/common/custom/DiscardedPayload.java -index 5fda67ba06ee75fe0c62a00e0b9ca2a82827e97c..ee8e117c6d2e11f55d86a3c4817bd665cb214551 100644 +index 5fda67ba06ee75fe0c62a00e0b9ca2a82827e97c..4b179c0be98e26007704253052e4310a750b2ca0 100644 --- a/src/main/java/net/minecraft/network/protocol/common/custom/DiscardedPayload.java +++ b/src/main/java/net/minecraft/network/protocol/common/custom/DiscardedPayload.java -@@ -4,7 +4,24 @@ import net.minecraft.network.FriendlyByteBuf; +@@ -4,14 +4,33 @@ import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.codec.StreamCodec; import net.minecraft.resources.ResourceLocation; @@ -715,7 +715,18 @@ index 5fda67ba06ee75fe0c62a00e0b9ca2a82827e97c..ee8e117c6d2e11f55d86a3c4817bd665 + public static StreamCodec codec(ResourceLocation resourceLocation, int i) { return CustomPacketPayload.codec((discardedPayload, friendlyByteBuf) -> { ++ friendlyByteBuf.writeBytes(discardedPayload.payload()); }, friendlyByteBuf -> { + int j = friendlyByteBuf.readableBytes(); + if (j >= 0 && j <= i) { +- friendlyByteBuf.skipBytes(j); +- return new DiscardedPayload(resourceLocation); ++ byte[] bytes = new byte[j]; ++ friendlyByteBuf.readBytes(bytes); ++ return new DiscardedPayload(resourceLocation, bytes); + } else { + throw new IllegalArgumentException("Payload may not be larger than " + i + " bytes"); + } diff --git a/src/main/java/net/minecraft/network/protocol/status/ClientStatusPacketListener.java b/src/main/java/net/minecraft/network/protocol/status/ClientStatusPacketListener.java index 8a52addea7666e52c7e396cde2d69b69d5da11c4..445b9aa0e77bfee21057cfd1c43a2a23aac67f4e 100644 --- a/src/main/java/net/minecraft/network/protocol/status/ClientStatusPacketListener.java diff --git a/scripts/files/version.json b/scripts/files/version.json index efbc92d..dded95e 100644 --- a/scripts/files/version.json +++ b/scripts/files/version.json @@ -1686,6 +1686,17 @@ }, "name": "org.ow2.asm:asm-util:9.7" }, + { + "downloads": { + "artifact": { + "path": "org/ow2/asm/asm-analysis/9.7/asm-analysis-9.7.jar", + "sha1": "e4a258b7eb96107106c0599f0061cfc1832fe07a", + "size": 34776, + "url": "https://repository.ow2.org/nexus/content/repositories/releases/org/ow2/asm/asm-analysis/9.7/asm-analysis-9.7.jar" + } + }, + "name": "org.ow2.asm:asm-analysis:9.7" + }, { "downloads": { "artifact": {