Klasse GameData
java.lang.Object
de.luckymcdev.foundryengine.common.game.GameData
Persistable data container identified by an Identifier, backed by NBT compounds.
-
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifikator und TypMethodeBeschreibungnet.minecraft.nbt.CompoundTagdata()Returns the underlying NBT compound data.booleangetBoolean(String key) Gets a boolean value from the data.doubleGets a double value from the data.intGets an integer value from the data.@Nullable StringGets a string value from the data, or null if absent.net.minecraft.resources.IdentifierReturns the identifier for this game data.booleanReturns true if this data has been initialized at least once.final voidLoads the game data from a compressed NBT file in the given directory.Registers a callback that fires once when the data is first loaded from disk.protected voidonLoad(net.minecraft.nbt.CompoundTag tag) protected voidonSave(net.minecraft.nbt.CompoundTag tag) voidputBoolean(String key, boolean value) Puts a boolean value into the data.voidPuts a double value into the data.voidPuts an integer value into the data.voidPuts a string value into the data.final voidSaves the game data to a compressed NBT file in the given directory.voidsetInitialized(boolean initialized) Sets the initialization flag for this data.
-
Konstruktordetails
-
GameData
public GameData(net.minecraft.resources.Identifier identifier)
-
-
Methodendetails
-
identifier
public net.minecraft.resources.Identifier identifier()Returns the identifier for this game data. -
data
public net.minecraft.nbt.CompoundTag data()Returns the underlying NBT compound data. The returned tag is shared via GameManager's persistent store and survives bundle reloads — modifications are visible to all sessions with the same ID.Threading contract: a session can be ticked from both the client and the server thread in the same process (integrated server), so the shared tag may be accessed concurrently. Every read/write that goes through the accessors is guarded by synchronizing on the tag itself. If the returned tag is mutated directly, the caller must synchronize on that tag object as well to avoid races.
-
isInitialized
public boolean isInitialized()Returns true if this data has been initialized at least once. -
setInitialized
public void setInitialized(boolean initialized) Sets the initialization flag for this data. -
onInit
-
getBoolean
Gets a boolean value from the data. -
putBoolean
Puts a boolean value into the data. -
getDouble
Gets a double value from the data. -
putDouble
Puts a double value into the data. -
getInt
Gets an integer value from the data. -
putInt
Puts an integer value into the data. -
getString
-
putString
-
onSave
protected void onSave(net.minecraft.nbt.CompoundTag tag) -
onLoad
protected void onLoad(net.minecraft.nbt.CompoundTag tag) -
saveTo
Saves the game data to a compressed NBT file in the given directory. -
loadFrom
Loads the game data from a compressed NBT file in the given directory.
-