Skip to content

Commit

Permalink
fix(neo): Network refactor nightmare
Browse files Browse the repository at this point in the history
  • Loading branch information
null2264 committed Oct 30, 2024
1 parent be63a83 commit cf81618
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixed REI integration due to API breaking changes in MC 1.21.2 or newer
- Adjust JEI integration due to deprecations in JEI 19 or newer
- Fixed issues with sending packet on NeoForge caused by Network Refactor
16 changes: 14 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ val supportedVersionRange: List<String?> = mapOf(
11802 to listOf(null, "1.18.2"),
11902 to listOf("1.19-", "1.19.2"),
12001 to listOf("1.20-", "1.20.1"),
12002 to listOf("1.20.2-", "1.20.4"),
12002 to listOf("1.20.2-", if (!isNeo) "1.20.4" else "1.20.3"),
12004 to listOf(null, "1.20.4"), // for Neo
12006 to listOf("1.20.5-", "1.20.6"),
12101 to listOf("1.21-", "1.21.1"),
12103 to listOf("1.21.2-", null),
Expand Down Expand Up @@ -152,6 +153,7 @@ dependencies {
// "20.5.0-alpha.${mc[mcVersion]}.+"
"neoForge"("net.neoforged:neoforge:" + mapOf(
12002 to "20.2.86",
12004 to "20.4.237",
12006 to "20.6.121",
12101 to "21.1.72",
12103 to "21.3.1-beta",
Expand Down Expand Up @@ -191,6 +193,7 @@ dependencies {
11904 to "1.19.4",
12001 to "1.20.1",
12002 to "1.20.2",
12004 to "1.20.2", // For Neo, the same 1.20.2
12006 to "1.20.6",
12101 to "1.21.1",
12103 to "1.21.1", // FIXME: .
Expand All @@ -212,6 +215,7 @@ dependencies {
11904 to "11.0.621",
12001 to "12.0.625",
12002 to "13.0.685",
12004 to "13.0.685", // for Neo
12006 to "15.0.787",
12101 to "16.0.788",
12103 to "17.0.789",
Expand All @@ -238,6 +242,7 @@ dependencies {
11904 to "13.1.0.13",
12001 to "15.0.0.12",
12002 to "16.0.0.28",
12004 to "16.0.0.28", // for Neo
12006 to "18.0.0.62",
12101 to "19.21.0.246",
12103 to null,
Expand All @@ -248,6 +253,7 @@ dependencies {
val fallbackJeiMcVer = "1.21.1"
// fallback ->
val jeiMc = mapOf(
12004 to "1.20.2", // for Neo
12103 to fallbackJeiMcVer,
)
modCompileOnly("mezz.jei:jei-${jeiMc[mcVersion] ?: mcVersionStr}-common-api:${jeiVersion ?: fallbackJeiVer}")
Expand Down Expand Up @@ -381,7 +387,13 @@ val mcReleaseVersions = mapOf<Int, List<String>>(
11802 to listOf("1.18.2"),
11902 to listOf("1.19", "1.19.1", "1.19.2"),
12001 to listOf("1.20", "1.20.1"),
12002 to listOf("1.20.2", "1.20.3", "1.20.4"),
12002 to listOf("1.20.2", "1.20.3").let {
val rt = it.toMutableList()
if (!isNeo) rt.add("1.20.4")

rt
},
12004 to listOf("1.20.4"), // for Neo
12006 to listOf("1.20.5", "1.20.6"),
12101 to listOf("1.21", "1.21.1"),
12103 to listOf("1.21.2", "1.21.3")
Expand Down
2 changes: 2 additions & 0 deletions root.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ preprocess {
val fabric12101 = createNode("1.21.1-fabric", 12100, "mojang")
val neo12006 = createNode("1.20.6-neoforge", 12005, "mojang")
val fabric12006 = createNode("1.20.6-fabric", 12005, "mojang")
val neo12004 = createNode("1.20.4-neoforge", 12004, "mojang")
val neo12002 = createNode("1.20.2-neoforge", 12002, "mojang")
val fabric12002 = createNode("1.20.2-fabric", 12002, "mojang")
val forge12001 = createNode("1.20.1-forge", 12001, "mojang")
Expand All @@ -23,6 +24,7 @@ preprocess {
neo12103.link(fabric12103)
neo12101.link(fabric12101)
neo12006.link(fabric12006)
neo12004.link(neo12002)
neo12002.link(fabric12002)

forge12001.link(fabric12001)
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ listOf(
"1.20.1-forge",
"1.20.2-fabric",
"1.20.2-neoforge",
"1.20.4-neoforge",
"1.20.6-fabric",
"1.20.6-neoforge",
"1.21.1-fabric",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
//#if MC<1.20.2
import net.minecraft.network.protocol.game.ClientboundCustomPayloadPacket;
//#else
//$$ import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
//$$ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
//$$ import io.github.null2264.cobblegen.network.payload.CGPacketPayload;
//$$ import net.minecraft.network.protocol.Packet;
//$$ import net.minecraft.network.protocol.common.ClientCommonPacketListener;
//$$ import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
//$$ import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
//#endif
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand Down Expand Up @@ -56,4 +62,24 @@ private void handleDisconnect(Component reason, CallbackInfo ci) {
CGClientPlayNetworkHandler.onDisconnect();
}
//#endif
}

//#if MC>=1.20.4 && FORGE>=1
//$$ @WrapOperation(
//$$ method = "send",
//$$ at = @At(value = "INVOKE", target = "Lnet/neoforged/neoforge/network/registration/NetworkRegistry;checkPacket(Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/protocol/common/ClientCommonPacketListener;)V")
//$$ )
//$$ private void validateCobbleGen(Packet<?> packet, ClientCommonPacketListener listener, Operation<Void> original) {
//$$ try {
//$$ original.call(packet, listener);
//$$ } catch (UnsupportedOperationException e) {
//$$ if (!(packet instanceof ServerboundCustomPayloadPacket customPayloadPacket)) {
//$$ throw e;
//$$ }

//$$ if (!(customPayloadPacket.payload() instanceof CGPacketPayload)) {
//$$ throw e;
//$$ }
//$$ }
//$$ }
//#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
//#if MC<1.20.2
import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
//#else
//$$ import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
//$$ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
//$$ import io.github.null2264.cobblegen.network.payload.CGPacketPayload;
//$$ import net.minecraft.network.protocol.Packet;
//$$ import net.minecraft.network.protocol.common.ClientboundCustomPayloadPacket;
//$$ import net.minecraft.network.protocol.common.ServerCommonPacketListener;
//$$ import net.minecraft.network.protocol.common.ServerboundCustomPayloadPacket;
//#endif
import io.github.null2264.cobblegen.network.CGServerPlayNetworkHandler;
Expand Down Expand Up @@ -58,4 +64,24 @@ private void handleCustomPayload(ServerboundCustomPayloadPacket packet, Callback
ci.cancel();
}
}
}

//#if MC>=1.20.4 && FORGE>=1
//$$ @WrapOperation(
//$$ method = "send(Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/PacketSendListener;)V",
//$$ at = @At(value = "INVOKE", target = "Lnet/neoforged/neoforge/network/registration/NetworkRegistry;checkPacket(Lnet/minecraft/network/protocol/Packet;Lnet/minecraft/network/protocol/common/ServerCommonPacketListener;)V")
//$$ )
//$$ private void validateCobbleGen(Packet<?> packet, ServerCommonPacketListener listener, Operation<Void> original) {
//$$ try {
//$$ original.call(packet, listener);
//$$ } catch (UnsupportedOperationException e) {
//$$ if (!(packet instanceof ClientboundCustomPayloadPacket customPayloadPacket)) {
//$$ throw e;
//$$ }

//$$ if (!(customPayloadPacket.payload() instanceof CGPacketPayload)) {
//$$ throw e;
//$$ }
//$$ }
//$$ }
//#endif
}
1 change: 1 addition & 0 deletions versions/1.20.4-neoforge/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
loom.platform=neoforge

0 comments on commit cf81618

Please sign in to comment.