-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cdf34b5
commit d525446
Showing
33 changed files
with
403 additions
and
839 deletions.
There are no files selected for viewing
79 changes: 0 additions & 79 deletions
79
library/core/networking/src/main/java/org/quiltmc/qsl/networking/api/CustomPayloads.java
This file was deleted.
Oops, something went wrong.
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
73 changes: 73 additions & 0 deletions
73
...ary/core/networking/src/main/java/org/quiltmc/qsl/networking/api/PayloadTypeRegistry.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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC | ||
* Copyright 2023 The Quilt Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.quiltmc.qsl.networking.api; | ||
|
||
import net.minecraft.network.PacketByteBuf; | ||
import net.minecraft.network.RegistryByteBuf; | ||
import net.minecraft.network.codec.PacketCodec; | ||
import net.minecraft.network.packet.payload.CustomPayload; | ||
|
||
import org.jetbrains.annotations.ApiStatus; | ||
import org.quiltmc.qsl.networking.impl.PayloadTypeRegistryImpl; | ||
|
||
/** | ||
* A registry for payload types. | ||
*/ | ||
@ApiStatus.NonExtendable | ||
public interface PayloadTypeRegistry<B extends PacketByteBuf> { | ||
/** | ||
* Registers a custom payload type. | ||
* | ||
* <p>This must be done on both the sending and receiving side, usually during mod initialization | ||
* and <strong>before registering a packet handler</strong>. | ||
* | ||
* @param id the id of the payload type | ||
* @param codec the codec for the payload type | ||
* @param <T> the payload type | ||
* @return the registered payload type | ||
*/ | ||
<T extends CustomPayload> CustomPayload.Type<? super B, T> register(CustomPayload.Id<T> id, PacketCodec<? super B, T> codec); | ||
|
||
/** | ||
* @return the {@link PayloadTypeRegistry} instance for the client to server configuration channel. | ||
*/ | ||
static PayloadTypeRegistry<PacketByteBuf> configurationC2S() { | ||
return PayloadTypeRegistryImpl.CONFIGURATION_C2S; | ||
} | ||
|
||
/** | ||
* @return the {@link PayloadTypeRegistry} instance for the server to client configuration channel. | ||
*/ | ||
static PayloadTypeRegistry<PacketByteBuf> configurationS2C() { | ||
return PayloadTypeRegistryImpl.CONFIGURATION_S2C; | ||
} | ||
|
||
/** | ||
* @return the {@link PayloadTypeRegistry} instance for the client to server play channel. | ||
*/ | ||
static PayloadTypeRegistry<RegistryByteBuf> playC2S() { | ||
return PayloadTypeRegistryImpl.PLAY_C2S; | ||
} | ||
|
||
/** | ||
* @return the {@link PayloadTypeRegistry} instance for the server to client play channel. | ||
*/ | ||
static PayloadTypeRegistry<RegistryByteBuf> playS2C() { | ||
return PayloadTypeRegistryImpl.PLAY_S2C; | ||
} | ||
} |
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
Oops, something went wrong.