Class RegionDataManager

java.lang.Object
net.minecraft.world.level.saveddata.SavedData
de.z0rdak.yawp.data.region.RegionDataManager

public class RegionDataManager extends net.minecraft.world.level.saveddata.SavedData
  • Nested Class Summary

    Nested classes/interfaces inherited from class net.minecraft.world.level.saveddata.SavedData

    net.minecraft.world.level.saveddata.SavedData.Factory<T extends net.minecraft.world.level.saveddata.SavedData>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static net.minecraft.server.MinecraftServer
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    addDimKeyOnDimensionChange(net.minecraft.world.entity.player.Player Player, net.minecraft.world.level.Level origin, net.minecraft.world.level.Level destination)
    An event which is called after a player has been moved to a different world.
    static void
    addDimKeyOnPlayerLogin(net.minecraft.world.entity.Entity entity, net.minecraft.world.level.Level serverWorld)
    Event handler which is used to initialize the dimension cache with first dimension entry when a player logs in.
    static void
     
    cacheFor(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
     
    boolean
    containsCacheFor(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
     
    get()
     
    getCache(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
     
    int
     
     
    static Set<String>
    Returns the name of all dimension tracked by the region data manager.
     
    Set<net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>>
     
     
     
    int
    getRegionAmount(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
     
    getRegionIn(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim, String regionName)
     
    getRegionsFor(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
     
    int
     
    static void
    initServerInstance(net.minecraft.server.MinecraftServer server)
    Server startup hook for loading the region data from the yawp-dimension.dat file by creating an instance of RegionDataManager.
    boolean
    isAvailableForLocal(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim, String regionName)
    Method to check if a region name is valid for a given dimension.
    int
    isValidRegionName(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim, String regionName)
    Method to check if a region name is valid for a given dimension.
    load(net.minecraft.nbt.CompoundTag nbt, net.minecraft.core.HolderLookup.Provider registries)
    Method which gets called when a new RegionDataManager instance is created by loadRegionData.
    static void
    loadRegionDataForWorld(net.minecraft.server.MinecraftServer minecraftServer, net.minecraft.server.level.ServerLevel serverWorld)
    Server startup hook for loading the region data from the yawp-dimension.dat file by creating an instance of RegionDataManager.
    newCacheFor(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
     
    void
    resetDimensionCache(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
     
    void
     
    static void
     
    net.minecraft.nbt.CompoundTag
    save(net.minecraft.nbt.CompoundTag compound, net.minecraft.core.HolderLookup.Provider var2)
    Method which gets called the region data is marked as dirty via the save/markDirty method.

    Methods inherited from class net.minecraft.world.level.saveddata.SavedData

    isDirty, save, setDirty, setDirty

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • serverInstance

      public static net.minecraft.server.MinecraftServer serverInstance
  • Method Details

    • save

      public static void save()
    • getDimensionDataNames

      public static Set<String> getDimensionDataNames()
      Returns the name of all dimension tracked by the region data manager.
      Returns:
      the set of dimension names which are tracked by the region data manager.
    • getDimensionCaches

      public static List<DimensionRegionCache> getDimensionCaches()
    • get

      public static RegionDataManager get()
    • initServerInstance

      public static void initServerInstance(net.minecraft.server.MinecraftServer server)
      Server startup hook for loading the region data from the yawp-dimension.dat file by creating an instance of RegionDataManager.
      Parameters:
      server - which is fired upon server start and acts as trigger to load region data from disk.
    • loadRegionDataForWorld

      public static void loadRegionDataForWorld(net.minecraft.server.MinecraftServer minecraftServer, net.minecraft.server.level.ServerLevel serverWorld)
      Server startup hook for loading the region data from the yawp-dimension.dat file by creating an instance of RegionDataManager.
      Parameters:
      minecraftServer -
      serverWorld -
    • load

      public static RegionDataManager load(net.minecraft.nbt.CompoundTag nbt, net.minecraft.core.HolderLookup.Provider registries)
      Method which gets called when a new RegionDataManager instance is created by loadRegionData.
      Parameters:
      nbt - compound region data read from disk to be deserialized for the region cache.
    • addDimKeyOnDimensionChange

      public static void addDimKeyOnDimensionChange(net.minecraft.world.entity.player.Player Player, net.minecraft.world.level.Level origin, net.minecraft.world.level.Level destination)
      An event which is called after a player has been moved to a different world. Event handler which creates a new DimensionRegionCache when a dimension is created the first time, by a player loading the dimension.
    • addDimKeyOnPlayerLogin

      public static void addDimKeyOnPlayerLogin(net.minecraft.world.entity.Entity entity, net.minecraft.world.level.Level serverWorld)
      Event handler which is used to initialize the dimension cache with first dimension entry when a player logs in.
    • addFlags

      public static void addFlags(Set<String> flags, IProtectedRegion region)
    • save

      public net.minecraft.nbt.CompoundTag save(net.minecraft.nbt.CompoundTag compound, net.minecraft.core.HolderLookup.Provider var2)
      Method which gets called the region data is marked as dirty via the save/markDirty method.
      Specified by:
      save in class net.minecraft.world.level.saveddata.SavedData
      Parameters:
      compound - nbt data to be filled with the region information.
      Returns:
      the compound region nbt data to be saved to disk.
    • getTotalRegionAmount

      public int getTotalRegionAmount()
    • getRegionAmount

      public int getRegionAmount(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    • getDimensionList

      public Set<String> getDimensionList()
    • getDimKeys

      public Set<net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>> getDimKeys()
    • getGlobalRegion

      public GlobalRegion getGlobalRegion()
    • resetDimensionCache

      public void resetDimensionCache(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    • resetGlobalRegion

      public void resetGlobalRegion()
    • getDimensionAmount

      public int getDimensionAmount()
    • getRegionIn

      @Nullable public @Nullable Optional<IMarkableRegion> getRegionIn(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim, String regionName)
    • getRegionsFor

      public Collection<IMarkableRegion> getRegionsFor(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    • cacheFor

      public DimensionRegionCache cacheFor(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    • getCache

      public Optional<DimensionRegionCache> getCache(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    • isValidRegionName

      public int isValidRegionName(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim, String regionName)
      Method to check if a region name is valid for a given dimension.
      A region name is valid if it matches the pattern and is not already used in the dimension.
      Parameters:
      dim - the dimension to be checked.
      regionName - the name of the region to be checked.
      Returns:
      -1 if the region name is invalid, 0 if the region name is valid, 1 if the region name is already used in the dimension.
    • isAvailableForLocal

      public boolean isAvailableForLocal(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim, String regionName)
      Method to check if a region name is valid for a given dimension.
      A region name is valid if it matches the pattern and is not already used in the dimension.
      Parameters:
      dim - the dimension to be checked.
      regionName - the name of the region to be checked.
      Returns:
      -1 if the region name is invalid, 0 if the region name is valid, 1 if the region name is already used in the dimension.
    • containsCacheFor

      public boolean containsCacheFor(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    • getFlagsIdsForDim

      public List<String> getFlagsIdsForDim(DimensionRegionCache dimCache)
    • newCacheFor

      public DimensionRegionCache newCacheFor(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)