Skip to content
/ init Public

Called on the initial #load after server process startup

License

Notifications You must be signed in to change notification settings

intsuc/init

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

init

This data pack provides #minecraft:init function tag, called on the initial #minecraft:load after server process startup.

Caution

This data pack strongly depends on the internal implementation details of Minecraft and may not work in future versions!

Warning

An error message about UTFDataFormatException is printed every time a world is saved. You can safely ignore this message.

How it works

A string tag larger than 65535 bytes can exist in memory with no problem. However, when it is tried to be saved to a command storage file, a UTFDataFormatException occurs and an empty string is saved instead by StringFallbackDataOutput. Once this happens, the string tag becomes out of sync between in-memory (too long) and on-file (empty). Since the same command storage file is never loaded more than once during the lifetime of the server process, this out of sync will continue until the server is stopped. When the server process is started again, an empty string tag is loaded from the command storage file.

In light of the above, #minecraft:init can be implemented as follows:

---
title: The lifecycle of a server process
---
flowchart TD
  Start --> Load
  Load --> C1{{Does the string tag exist?}}
  C1 -- Yes --> C2{{Is the string tag empty?}}
  C1 -- No --> C3
  C2 -- Yes --> C3
  C3[Create a too long string tag] --> Init
  Init --> Tick
  C2 -- No --> Tick
  Tick --> Tick
  Tick -- Reload --> Load
  Tick --> Stop
  Stop -- Restart --> Start
Loading

About

Called on the initial #load after server process startup

Topics

Resources

License

Stars

Watchers

Forks