From 1666c164aabbcc0108c7c21e4de02a67977310f1 Mon Sep 17 00:00:00 2001 From: deirn Date: Sun, 14 Jan 2024 21:10:29 +0700 Subject: [PATCH 1/5] fix workflows (cherry picked from commit 724a3ab8b768521b3e8d562c13df5b75ae436475) --- .github/workflows/build_head.yml | 8 ++------ .github/workflows/build_release.yml | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build_head.yml b/.github/workflows/build_head.yml index 4dd2149..803761e 100644 --- a/.github/workflows/build_head.yml +++ b/.github/workflows/build_head.yml @@ -32,9 +32,5 @@ jobs: GIT_HASH: ${{ steps.vars.outputs.git_hash }} - uses: actions/upload-artifact@v3 with: - name: wthit-fabric-${{ steps.vars.outputs.git_hash }} - path: "./platform/fabric/build/libs/**.jar" - - uses: actions/upload-artifact@v3 - with: - name: wthit-forge-${{ steps.vars.outputs.git_hash }} - path: "./platform/forge/build/libs/**.jar" + name: wthit-${{ steps.vars.outputs.git_hash }} + path: "./platform/*/build/libs/**.jar" diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 9b9819c..6e229fa 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -30,12 +30,8 @@ jobs: b2 clear-account - uses: actions/upload-artifact@v3 with: - name: wthit-fabric-${{ steps.vars.outputs.version }} - path: "./platform/fabric/build/libs/**.jar" - - uses: actions/upload-artifact@v3 - with: - name: wthit-forge-${{ steps.vars.outputs.version }} - path: "./platform/forge/build/libs/**.jar" + name: wthit-${{ steps.vars.outputs.git_hash }} + path: "./platform/*/build/libs/**.jar" - uses: alexellis/upload-assets@259de5111cb56966d046ced998941e93f91d2c93 env: GITHUB_TOKEN: ${{ github.token }} From 9fd18d4de9085e84e975f070ddeafb784758316f Mon Sep 17 00:00:00 2001 From: deirn Date: Sun, 14 Jan 2024 21:22:59 +0700 Subject: [PATCH 2/5] a (cherry picked from commit bea002f67684cc6bebe99ecb7bb208444c49dd93) --- .github/workflows/build_head.yml | 2 +- .github/workflows/build_release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_head.yml b/.github/workflows/build_head.yml index 803761e..e946f00 100644 --- a/.github/workflows/build_head.yml +++ b/.github/workflows/build_head.yml @@ -32,5 +32,5 @@ jobs: GIT_HASH: ${{ steps.vars.outputs.git_hash }} - uses: actions/upload-artifact@v3 with: - name: wthit-${{ steps.vars.outputs.git_hash }} + name: badpackets-${{ steps.vars.outputs.git_hash }} path: "./platform/*/build/libs/**.jar" diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 6e229fa..baa5ff0 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -30,7 +30,7 @@ jobs: b2 clear-account - uses: actions/upload-artifact@v3 with: - name: wthit-${{ steps.vars.outputs.git_hash }} + name: badpackets-${{ steps.vars.outputs.git_hash }} path: "./platform/*/build/libs/**.jar" - uses: alexellis/upload-assets@259de5111cb56966d046ced998941e93f91d2c93 env: From a3e92defac02202919943553346e32aacb605f1f Mon Sep 17 00:00:00 2001 From: deirn Date: Mon, 15 Jan 2024 20:51:49 +0700 Subject: [PATCH 3/5] add modmenu library badge closes #12 (cherry picked from commit 105cb69064af75e7028db48970f7df06e186fd61) --- platform/fabric/src/main/resources/fabric.mod.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/platform/fabric/src/main/resources/fabric.mod.json b/platform/fabric/src/main/resources/fabric.mod.json index 3080665..de7b763 100644 --- a/platform/fabric/src/main/resources/fabric.mod.json +++ b/platform/fabric/src/main/resources/fabric.mod.json @@ -12,5 +12,10 @@ "depends" : { "minecraft" : ">=1.20.2-", "fabricloader": ">=0.14.22" + }, + "custom" : { + "modmenu": { + "badges": ["library"] + } } } From 48f28485149096a4885ee1e9230482e4c1f79fc0 Mon Sep 17 00:00:00 2001 From: deirn Date: Mon, 15 Jan 2024 21:05:11 +0700 Subject: [PATCH 4/5] copy untyped payload buffer on read/write closes #13 (cherry picked from commit 3e1f7e3ed244cb4a42100523b13ba60c48704e3e) --- .../lol/bai/badpackets/impl/payload/UntypedPayload.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/lol/bai/badpackets/impl/payload/UntypedPayload.java b/src/main/java/lol/bai/badpackets/impl/payload/UntypedPayload.java index 46b0e01..02a27a9 100644 --- a/src/main/java/lol/bai/badpackets/impl/payload/UntypedPayload.java +++ b/src/main/java/lol/bai/badpackets/impl/payload/UntypedPayload.java @@ -21,7 +21,7 @@ public static FriendlyByteBuf.Reader reader(ResourceLocation cha @Override public void write(@NotNull FriendlyByteBuf buf) { - buf.writeBytes(buffer); + buf.writeBytes(buffer.copy()); } @Override @@ -29,4 +29,9 @@ public void write(@NotNull FriendlyByteBuf buf) { return channelId; } + @Override + public FriendlyByteBuf buffer() { + return new FriendlyByteBuf(buffer.copy()); + } + } From 459c9cc18d66bbd5b54b7346b908806e2c28d9a1 Mon Sep 17 00:00:00 2001 From: deirn Date: Wed, 14 Feb 2024 00:07:50 +0700 Subject: [PATCH 5/5] don't sent `minecraft:register` on quilt --- .../java/lol/bai/badpackets/impl/fabric/FabricProxy.java | 6 ++++++ .../bai/badpackets/impl/handler/AbstractPacketHandler.java | 3 ++- .../lol/bai/badpackets/impl/platform/PlatformProxy.java | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/platform/fabric/src/main/java/lol/bai/badpackets/impl/fabric/FabricProxy.java b/platform/fabric/src/main/java/lol/bai/badpackets/impl/fabric/FabricProxy.java index 5d017d7..7462d52 100644 --- a/platform/fabric/src/main/java/lol/bai/badpackets/impl/fabric/FabricProxy.java +++ b/platform/fabric/src/main/java/lol/bai/badpackets/impl/fabric/FabricProxy.java @@ -13,6 +13,12 @@ public class FabricProxy extends PlatformProxy { private static final boolean HAS_FABRIC_API = FabricLoader.getInstance().isModLoaded("fabric-networking-api-v1"); + private static final boolean HAS_QUILT_STD = FabricLoader.getInstance().isModLoaded("quilt_networking"); + + @Override + public boolean canSendVanillaRegisterPackets() { + return !HAS_QUILT_STD; + } @Override public Packet createVanillaRegisterConfigS2CPacket(FriendlyByteBuf buf) { diff --git a/src/main/java/lol/bai/badpackets/impl/handler/AbstractPacketHandler.java b/src/main/java/lol/bai/badpackets/impl/handler/AbstractPacketHandler.java index 7dadc9c..ee442aa 100644 --- a/src/main/java/lol/bai/badpackets/impl/handler/AbstractPacketHandler.java +++ b/src/main/java/lol/bai/badpackets/impl/handler/AbstractPacketHandler.java @@ -13,6 +13,7 @@ import lol.bai.badpackets.api.PacketSender; import lol.bai.badpackets.impl.Constants; import lol.bai.badpackets.impl.payload.UntypedPayload; +import lol.bai.badpackets.impl.platform.PlatformProxy; import lol.bai.badpackets.impl.registry.ChannelRegistry; import net.minecraft.network.Connection; import net.minecraft.network.FriendlyByteBuf; @@ -143,7 +144,7 @@ public void remove() { } private void sendVanillaChannelRegisterPacket(Set channels) { - if (!channels.isEmpty()) { + if (PlatformProxy.INSTANCE.canSendVanillaRegisterPackets() && !channels.isEmpty()) { FriendlyByteBuf buf = new FriendlyByteBuf(Unpooled.buffer()); boolean first = true; for (ResourceLocation channel : channels) { diff --git a/src/main/java/lol/bai/badpackets/impl/platform/PlatformProxy.java b/src/main/java/lol/bai/badpackets/impl/platform/PlatformProxy.java index 34304c4..f84fb01 100644 --- a/src/main/java/lol/bai/badpackets/impl/platform/PlatformProxy.java +++ b/src/main/java/lol/bai/badpackets/impl/platform/PlatformProxy.java @@ -13,6 +13,10 @@ public class PlatformProxy { public static final PlatformProxy INSTANCE = ServiceLoader.load(PlatformProxy.class).findFirst().orElseGet(PlatformProxy::new); + public boolean canSendVanillaRegisterPackets() { + return true; + } + public Packet createVanillaRegisterConfigC2SPacket(FriendlyByteBuf buf) { return new ServerboundCustomPayloadPacket(new UntypedPayload(Constants.MC_REGISTER_CHANNEL, buf)); }