Start Hello process when player joins (not on enter)
This commit is contained in:
parent
990b024fdb
commit
819514a699
3 changed files with 19 additions and 10 deletions
|
@ -19,6 +19,19 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
public abstract class DataHandler {
|
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;
|
private final boolean originatesOnServer;
|
||||||
@NotNull
|
@NotNull
|
||||||
private final ResourceLocation identifier;
|
private final ResourceLocation identifier;
|
||||||
|
@ -49,14 +62,9 @@ public abstract class DataHandler {
|
||||||
server.execute(() -> runOnGameThread(null, server, false));
|
server.execute(() -> runOnGameThread(null, server, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void serializeData(FriendlyByteBuf buf) {
|
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);
|
||||||
protected void deserializeFromIncomingData(FriendlyByteBuf buf, PacketSender responseSender, boolean isClient){
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void runOnGameThread(Minecraft client, MinecraftServer server, boolean isClient){
|
|
||||||
}
|
|
||||||
|
|
||||||
final protected boolean reply(DataHandler message, MinecraftServer server){
|
final protected boolean reply(DataHandler message, MinecraftServer server){
|
||||||
if (lastMessageSender==null) return false;
|
if (lastMessageSender==null) return false;
|
||||||
|
|
|
@ -55,7 +55,7 @@ import java.io.File;
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
public class HelloServer extends DataHandler {
|
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";
|
protected String bclibVersion ="0.0.0";
|
||||||
public HelloServer() {
|
public HelloServer() {
|
||||||
|
|
|
@ -26,7 +26,8 @@ public abstract class GridScreen extends Screen {
|
||||||
protected abstract void initLayout();
|
protected abstract void initLayout();
|
||||||
|
|
||||||
public void render(PoseStack poseStack, int i, int j, float f) {
|
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);
|
drawCenteredString(poseStack, this.font, this.title, grid.width / 2, grid.getTopStart(), 16777215);
|
||||||
if (grid!=null) grid.render(poseStack);
|
if (grid!=null) grid.render(poseStack);
|
||||||
super.render(poseStack, i, j, f);
|
super.render(poseStack, i, j, f);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue