generated from FabricMC/fabric-example-mod
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix packet types not being registered
- Loading branch information
Showing
2 changed files
with
13 additions
and
0 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
src/main/java/cf/witcheskitchen/api/event/network/C2SPacketRegistryListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
package cf.witcheskitchen.api.event.network; | ||
|
||
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry; | ||
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking; | ||
import net.minecraft.network.packet.CustomPayload; | ||
|
||
public interface C2SPacketRegistryListener<T extends CustomPayload> extends PacketRegistryListener<T> { | ||
void handle(T payload, ServerPlayNetworking.Context context); | ||
|
||
default void register() { | ||
PayloadTypeRegistry.playC2S().register(this.type().id(), this.type().codec()); | ||
ServerPlayNetworking.registerGlobalReceiver(this.type().id(), this::handle); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters