List all mod versions from server and client
This commit is contained in:
parent
032b4187bd
commit
a53c503c4e
4 changed files with 81 additions and 6 deletions
|
@ -1,5 +1,7 @@
|
|||
package ru.bclib.api.dataexchange;
|
||||
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.util.CharsetUtil;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
|
@ -16,6 +18,8 @@ import net.minecraft.server.level.ServerPlayer;
|
|||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public abstract class DataHandler {
|
||||
private final boolean originatesOnServer;
|
||||
@NotNull
|
||||
|
@ -104,4 +108,23 @@ public abstract class DataHandler {
|
|||
public String toString() {
|
||||
return "DataHandler{" + "originatesOnServer=" + originatesOnServer + ", identifier=" + identifier + '}';
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a String to a buffer (Convenience Method)
|
||||
* @param buf The buffer to write to
|
||||
* @param s The String you want to write
|
||||
*/
|
||||
public static void writeString(FriendlyByteBuf buf, String s){
|
||||
buf.writeByteArray(s.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a string from a buffer (Convenience Method)
|
||||
* @param buf Thea buffer to read from
|
||||
* @return The received String
|
||||
*/
|
||||
public static String readString(FriendlyByteBuf buf){
|
||||
byte[] data = buf.readByteArray();
|
||||
return new String(data, StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue