tutorial:persistent_states
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
tutorial:persistent_states [2023/09/28 05:52] – Dropped un-needed DataFixType parameter and made type singleton jmanc3 | tutorial:persistent_states [2024/04/25 14:06] (current) – mayaqq | ||
---|---|---|---|
Line 128: | Line 128: | ||
// ... (Previously written code) | // ... (Previously written code) | ||
- | public static StateSaverAndLoader createFromNbt(NbtCompound tag) { | + | public static StateSaverAndLoader createFromNbt(NbtCompound tag, RegistryWrapper.WrapperLookup registryLookup) { |
StateSaverAndLoader state = new StateSaverAndLoader(); | StateSaverAndLoader state = new StateSaverAndLoader(); | ||
state.totalDirtBlocksBroken = tag.getInt(" | state.totalDirtBlocksBroken = tag.getInt(" | ||
Line 136: | Line 136: | ||
</ | </ | ||
- | This function does the opposite of '' | + | This function does the opposite of '' |
* Note: how we pull out the int we stored earlier with '' | * Note: how we pull out the int we stored earlier with '' | ||
- | Now we just need to add one more utility function which hooks everything up together. This function will take a '' | + | Now we just need to add one more utility function which hooks everything up together. This function will take a '' |
<code java> | <code java> | ||
Line 193: | Line 193: | ||
} | } | ||
- | public static StateSaverAndLoader createFromNbt(NbtCompound tag) { | + | public static StateSaverAndLoader createFromNbt(NbtCompound tag, RegistryWrapper.WrapperLookup registryLookup) { |
StateSaverAndLoader state = new StateSaverAndLoader(); | StateSaverAndLoader state = new StateSaverAndLoader(); | ||
state.totalDirtBlocksBroken = tag.getInt(" | state.totalDirtBlocksBroken = tag.getInt(" | ||
Line 428: | Line 428: | ||
} | } | ||
- | public static StateSaverAndLoader createFromNbt(NbtCompound tag) { | + | public static StateSaverAndLoader createFromNbt(NbtCompound tag, RegistryWrapper.WrapperLookup registryLookup) { |
StateSaverAndLoader state = new StateSaverAndLoader(); | StateSaverAndLoader state = new StateSaverAndLoader(); | ||
state.totalDirtBlocksBroken = tag.getInt(" | state.totalDirtBlocksBroken = tag.getInt(" | ||
Line 486: | Line 486: | ||
} | } | ||
- | public static StateSaverAndLoader createFromNbt(NbtCompound tag) { | + | public static StateSaverAndLoader createFromNbt(NbtCompound tag, RegistryWrapper.WrapperLookup registryLookup) { |
StateSaverAndLoader state = new StateSaverAndLoader(); | StateSaverAndLoader state = new StateSaverAndLoader(); | ||
state.totalDirtBlocksBroken = tag.getInt(" | state.totalDirtBlocksBroken = tag.getInt(" | ||
Line 541: | Line 541: | ||
Running the client now, all our player-specific data is correctly saved. | Running the client now, all our player-specific data is correctly saved. | ||
- | | + | ==== Important Caveat ==== |
+ | |||
+ | | ||
Just remember if you add new fields to '' | Just remember if you add new fields to '' | ||
Line 646: | Line 648: | ||
* Note: The '' | * Note: The '' | ||
- | | + | ==== Important Caveat ==== |
+ | |||
+ | | ||
====== More Involved Player Data ====== | ====== More Involved Player Data ====== | ||
Line 710: | Line 714: | ||
} | } | ||
- | public static StateSaverAndLoader createFromNbt(NbtCompound tag) { | + | public static StateSaverAndLoader createFromNbt(NbtCompound tag, RegistryWrapper.WrapperLookup registryLookup) { |
StateSaverAndLoader state = new StateSaverAndLoader(); | StateSaverAndLoader state = new StateSaverAndLoader(); | ||
state.totalDirtBlocksBroken = tag.getInt(" | state.totalDirtBlocksBroken = tag.getInt(" |
tutorial/persistent_states.1695880372.txt.gz · Last modified: 2023/09/28 05:52 by jmanc3