Merge pull request #28 from quiqueck/main

Start Hello process when player joins (not on enter)
This commit is contained in:
paulevsGitch 2021-08-09 02:32:20 +03:00 committed by GitHub
commit c48c06d2f8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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() {

View file

@ -26,7 +26,8 @@ public abstract class GridScreen extends Screen {
protected abstract void initLayout();
public void render(PoseStack poseStack, int i, int j, float f) {
this.renderBackground(poseStack);
//this.renderBackground(poseStack);
this.renderDirtBackground(i);
drawCenteredString(poseStack, this.font, this.title, grid.width / 2, grid.getTopStart(), 16777215);
if (grid!=null) grid.render(poseStack);
super.render(poseStack, i, j, f);