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 [2024/01/11 06:36] – Short AuthMe explanation 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 543: | Line 543: | ||
==== Important Caveat ==== | ==== Important Caveat ==== | ||
- | * Each time you restart the minecraft client with fabric, you're assigned a new random UUID each launch, so it may seem like our code is not working because it's pulling data for a new UUID never before seen. If you want to verify everything is working correctly, download [[https:// | + | * Each time you restart the minecraft client with fabric, you're assigned a new random UUID each launch, so it may seem like our code is not working because it's pulling data for a new UUID never before seen. If you want to verify everything is working correctly, download [[https:// |
Just remember if you add new fields to '' | Just remember if you add new fields to '' | ||
Line 650: | Line 650: | ||
==== Important Caveat ==== | ==== Important Caveat ==== | ||
- | * Each time you restart the minecraft client with fabric, you're assigned a new random UUID each launch, so it may seem like our code is not working because it's pulling data for a new UUID never before seen. If you want to verify everything is working correctly, download [[https:// | + | * Each time you restart the minecraft client with fabric, you're assigned a new random UUID each launch, so it may seem like our code is not working because it's pulling data for a new UUID never before seen. If you want to verify everything is working correctly, download [[https:// |
====== More Involved Player Data ====== | ====== More Involved Player Data ====== | ||
Line 714: | 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.1704954984.txt.gz · Last modified: 2024/01/11 06:36 by jmanc3