Start Hello process when player joins (not on enter)

This commit is contained in:
Frank Bauer 2021-08-08 17:24:29 +02:00
parent 990b024fdb
commit 819514a699
3 changed files with 19 additions and 10 deletions

View file

@ -19,6 +19,19 @@ import org.jetbrains.annotations.NotNull;
import java.nio.charset.StandardCharsets;
public abstract class DataHandler {
public abstract static class WithoutPayload extends DataHandler{
protected WithoutPayload(ResourceLocation identifier, boolean originatesOnServer) {
super(identifier, originatesOnServer);
}
protected void serializeData(FriendlyByteBuf buf) {
}
protected void deserializeFromIncomingData(FriendlyByteBuf buf, PacketSender responseSender, boolean isClient){
}
}
private final boolean originatesOnServer;
@NotNull
private final ResourceLocation identifier;
@ -49,14 +62,9 @@ public abstract class DataHandler {
server.execute(() -> runOnGameThread(null, server, false));
}
protected void serializeData(FriendlyByteBuf buf) {
}
protected void deserializeFromIncomingData(FriendlyByteBuf buf, PacketSender responseSender, boolean isClient){
}
protected void runOnGameThread(Minecraft client, MinecraftServer server, boolean isClient){
}
abstract protected void serializeData(FriendlyByteBuf buf) ;
abstract protected void deserializeFromIncomingData(FriendlyByteBuf buf, PacketSender responseSender, boolean isClient);
abstract protected void runOnGameThread(Minecraft client, MinecraftServer server, boolean isClient);
final protected boolean reply(DataHandler message, MinecraftServer server){
if (lastMessageSender==null) return false;

View file

@ -55,7 +55,7 @@ import java.io.File;
* </table>
*/
public class HelloServer extends DataHandler {
public static DataHandlerDescriptor DESCRIPTOR = new DataHandlerDescriptor(new ResourceLocation(BCLib.MOD_ID, "hello_server"), HelloServer::new, false, true);
public static DataHandlerDescriptor DESCRIPTOR = new DataHandlerDescriptor(new ResourceLocation(BCLib.MOD_ID, "hello_server"), HelloServer::new, true, false);
protected String bclibVersion ="0.0.0";
public HelloServer() {