Skip to content

Commit 3e7ff36

Browse files
committed
fix: avoid using ClientPlayNetworking.PlayChannelHandler in packet initialization
Closes #17
1 parent a5e7a45 commit 3e7ff36

9 files changed

Lines changed: 77 additions & 14 deletions

File tree

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ org.gradle.jvmargs=-Xmx3G
33
org.gradle.warning.mode=all
44
# Check these on https://fabricmc.net/develop/
55
minecraftVersion=1.18.2
6-
yarnMappings=1.18.2+build.1
6+
yarnMappings=1.18.2+build.2
77
loaderVersion=0.13.3
88
# Fabric API
9-
fabricVersion=0.47.10+1.18.2
9+
fabricVersion=0.48.0+1.18.2
1010
loomVersion=0.11-SNAPSHOT
1111
# Mod Properties
12-
modVersion=1.18.2-1.4.0
12+
modVersion=1.18.2-1.4.1
1313
mavenGroup=io.github.samarium150
1414
archivesBaseName=structures_compass-fabric
1515
# Kotlin

src/main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/client/StructuresCompassClient.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* You should have received a copy of the GNU General Public License
1515
* along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
1616
*/
17-
1817
package io.github.samarium150.minecraft.mod.structures_compass.client
1918

2019
import io.github.samarium150.minecraft.mod.structures_compass.client.init.HudRegistry

src/main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/init/CommandRegistry.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* You should have received a copy of the GNU General Public License
1515
* along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
1616
*/
17-
1817
package io.github.samarium150.minecraft.mod.structures_compass.init
1918

2019
import io.github.samarium150.minecraft.mod.structures_compass.server.command.GetCompass
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2022 Samarium
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
16+
*/
17+
package io.github.samarium150.minecraft.mod.structures_compass.network.packet.c2s
18+
19+
import net.fabricmc.fabric.api.networking.v1.PacketSender
20+
import net.minecraft.network.PacketByteBuf
21+
import net.minecraft.server.MinecraftServer
22+
import net.minecraft.server.network.ServerPlayNetworkHandler
23+
import net.minecraft.server.network.ServerPlayerEntity
24+
25+
/**
26+
* @see net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking.PlayChannelHandler
27+
*/
28+
fun interface PacketHandler {
29+
fun receive(
30+
server: MinecraftServer,
31+
player: ServerPlayerEntity,
32+
handler: ServerPlayNetworkHandler,
33+
buf: PacketByteBuf,
34+
responseSender: PacketSender
35+
)
36+
}

src/main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/network/packet/c2s/RequestSyncPacket.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* You should have received a copy of the GNU General Public License
1515
* along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
1616
*/
17-
1817
package io.github.samarium150.minecraft.mod.structures_compass.network.packet.c2s
1918

2019
import io.github.samarium150.minecraft.mod.structures_compass.data.StructuresCompassData
@@ -32,7 +31,7 @@ import net.minecraft.util.Identifier
3231

3332
class RequestSyncPacket : PacketByteBuf(Unpooled.buffer()) {
3433

35-
companion object : ServerPlayNetworking.PlayChannelHandler {
34+
companion object : PacketHandler {
3635

3736
val ID = Identifier(MOD_ID, "request_sync_packet")
3837

src/main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/network/packet/c2s/SearchPacket.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,12 @@
1414
* You should have received a copy of the GNU General Public License
1515
* along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
1616
*/
17-
1817
package io.github.samarium150.minecraft.mod.structures_compass.network.packet.c2s
1918

2019
import io.github.samarium150.minecraft.mod.structures_compass.util.MOD_ID
2120
import io.github.samarium150.minecraft.mod.structures_compass.util.search
2221
import io.netty.buffer.Unpooled
2322
import net.fabricmc.fabric.api.networking.v1.PacketSender
24-
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking
2523
import net.minecraft.network.PacketByteBuf
2624
import net.minecraft.server.MinecraftServer
2725
import net.minecraft.server.network.ServerPlayNetworkHandler
@@ -30,7 +28,7 @@ import net.minecraft.util.Identifier
3028

3129
class SearchPacket(structureId: Identifier) : PacketByteBuf(Unpooled.buffer()) {
3230

33-
companion object : ServerPlayNetworking.PlayChannelHandler {
31+
companion object : PacketHandler {
3432

3533
val ID = Identifier(MOD_ID, "search_packet")
3634

src/main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/network/packet/c2s/SetSkipPacket.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import io.github.samarium150.minecraft.mod.structures_compass.util.MOD_ID
2121
import io.github.samarium150.minecraft.mod.structures_compass.util.setSkip
2222
import io.netty.buffer.Unpooled
2323
import net.fabricmc.fabric.api.networking.v1.PacketSender
24-
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking
2524
import net.minecraft.network.PacketByteBuf
2625
import net.minecraft.server.MinecraftServer
2726
import net.minecraft.server.network.ServerPlayNetworkHandler
@@ -30,7 +29,7 @@ import net.minecraft.util.Identifier
3029

3130
class SetSkipPacket(skip: Boolean) : PacketByteBuf(Unpooled.buffer()) {
3231

33-
companion object : ServerPlayNetworking.PlayChannelHandler {
32+
companion object : PacketHandler {
3433

3534
val ID = Identifier(MOD_ID, "set_skip")
3635

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2022 Samarium
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/gpl-3.0.html>.
16+
*/
17+
package io.github.samarium150.minecraft.mod.structures_compass.network.packet.s2c
18+
19+
import net.fabricmc.fabric.api.networking.v1.PacketSender
20+
import net.minecraft.client.MinecraftClient
21+
import net.minecraft.client.network.ClientPlayNetworkHandler
22+
import net.minecraft.network.PacketByteBuf
23+
24+
/**
25+
* @see net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking.PlayChannelHandler
26+
*/
27+
fun interface PacketHandler {
28+
fun receive(
29+
client: MinecraftClient,
30+
handler: ClientPlayNetworkHandler,
31+
buf: PacketByteBuf,
32+
responseSender: PacketSender
33+
)
34+
}

src/main/kotlin/io/github/samarium150/minecraft/mod/structures_compass/network/packet/s2c/SyncPacket.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import io.github.samarium150.minecraft.mod.structures_compass.util.MOD_ID
2222
import io.github.samarium150.minecraft.mod.structures_compass.util.getIdentifier
2323
import io.github.samarium150.minecraft.mod.structures_compass.util.getStructureFeature
2424
import io.netty.buffer.Unpooled
25-
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking
2625
import net.fabricmc.fabric.api.networking.v1.PacketSender
2726
import net.minecraft.client.MinecraftClient
2827
import net.minecraft.client.network.ClientPlayNetworkHandler
@@ -37,7 +36,7 @@ class SyncPacket(
3736
structuresDimensionsMap: Map<StructureFeature<*>, List<Identifier>>
3837
) : PacketByteBuf(Unpooled.buffer()) {
3938

40-
companion object : ClientPlayNetworking.PlayChannelHandler {
39+
companion object : PacketHandler {
4140

4241
val ID = Identifier(MOD_ID, "sync_packet")
4342

0 commit comments

Comments
 (0)