Class RegionManager

java.lang.Object
de.z0rdak.yawp.api.core.RegionManager
All Implemented Interfaces:
IRegionManager

public final class RegionManager extends Object implements IRegionManager
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    createDimRegion(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    Creates a new DimensionalRegionCache (and DimensionalRegion) for the specified dimension.
    get()
     
    net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>
    Create the corresponding ResourceKey for the provided resource key string (e.g.
    getDimensionalRegion(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    You can safely cast the returned instance of to DimensionalRegion, but it doesn't provide any benefit.
    getDimensionCache(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    Gets the DimensionRegionCache for the specified dimension.
    Set<net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>>
    Returns a set of resource keys for all created Dimensional Regions
    getDimRegionApi(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    Gets the DimensionalRegion API for the specified dimension key.
    Gets the DimensionalRegion API for the specified dimension key (E.g.
     
    boolean
    hasRegionFor(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    Check whether a DimensionalRegion for the specified dimension already exists.
    void
    resetDimension(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
    Resets the DimensionalRegion as well as all LocalRegions of the corresponding level.
    void
    This only resets the Global Region, not its child regions.
    void
    Flag the scheduler to save the region data.

    Methods inherited from class java.lang.Object

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

    • get

      public static RegionManager get()
    • getGlobalRegion

      public GlobalRegion getGlobalRegion()
      Specified by:
      getGlobalRegion in interface IRegionManager
    • resetGlobal

      public void resetGlobal()
      Description copied from interface: IRegionManager
      This only resets the Global Region, not its child regions.
      Specified by:
      resetGlobal in interface IRegionManager
    • getDimensionalRegion

      public Optional<IProtectedRegion> getDimensionalRegion(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Description copied from interface: IRegionManager
      You can safely cast the returned instance of to DimensionalRegion, but it doesn't provide any benefit.
      Specified by:
      getDimensionalRegion in interface IRegionManager
      Parameters:
      dim - the resource key of the dimension/level * @return the DimensionRegionCache corresponding to dim
    • getDimensionCache

      public Optional<DimensionRegionCache> getDimensionCache(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Description copied from interface: IRegionManager
      Gets the DimensionRegionCache for the specified dimension. A DimensionRegionCache manages the DimensionalRegion and all Local Regions of the corresponding dimensions.
      Specified by:
      getDimensionCache in interface IRegionManager
      Parameters:
      dim - the resource key of the dimension/level
      Returns:
      the DimensionRegionCache corresponding to dim
    • save

      public void save()
      Description copied from interface: IRegionManager
      Flag the scheduler to save the region data. This usually happens either - cyclic (when enabled) - when leaving the world (in single player) - shutting down the server gracefully - or executing the '/save-all' command.
      Specified by:
      save in interface IRegionManager
    • getDimRegionApi

      public Optional<IDimensionRegionApi> getDimRegionApi(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Gets the DimensionalRegion API for the specified dimension key.
      Specified by:
      getDimRegionApi in interface IRegionManager
      Parameters:
      dim - the dimension key to get the API for
      Returns:
      the DimensionalRegionApi for the specified dimension key if it exists, otherwise Optional.Empty
    • getDimRegionApiByKey

      public Optional<IDimensionRegionApi> getDimRegionApiByKey(String dimKey)
      Gets the DimensionalRegion API for the specified dimension key (E.g. "minecraft:overworld").
      Specified by:
      getDimRegionApiByKey in interface IRegionManager
      Parameters:
      dimKey - the dimension key to get the API for
      Returns:
      the DimensionalRegionApi for the specified dimension key if it exists, otherwise Optional.Empty
    • getDimApiKey

      public net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> getDimApiKey(String dimKey)
      Description copied from interface: IRegionManager
      Create the corresponding ResourceKey for the provided resource key string (e.g. 'minecraft:overworld') Basically a wrapper around `ResourceKey.create(Registries.DIMENSION, ResourceLocation.parse(dimKey));`
      Specified by:
      getDimApiKey in interface IRegionManager
      Parameters:
      dimKey - resource key of the level/dimension
      Returns:
      the corresponding ResourceKey for the level/dimension
    • hasRegionFor

      public boolean hasRegionFor(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Description copied from interface: IRegionManager
      Check whether a DimensionalRegion for the specified dimension already exists.
      Specified by:
      hasRegionFor in interface IRegionManager
      Parameters:
      dim - the dimension key to check for
      Returns:
      true if a DimensionalRegion exists, false otherwise
    • createDimRegion

      public boolean createDimRegion(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Description copied from interface: IRegionManager
      Creates a new DimensionalRegionCache (and DimensionalRegion) for the specified dimension.
      Specified by:
      createDimRegion in interface IRegionManager
      Parameters:
      dim - the dimension identifier of the dimension
      Returns:
      true if a new DimensionalRegionCache was created, false if it already existed
    • getDimensions

      public Set<net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>> getDimensions()
      Description copied from interface: IRegionManager
      Returns a set of resource keys for all created Dimensional Regions
      Specified by:
      getDimensions in interface IRegionManager
      Returns:
      a set of resource keys corresponding to registered DimensionalRegions
    • resetDimension

      public void resetDimension(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
      Description copied from interface: IRegionManager
      Resets the DimensionalRegion as well as all LocalRegions of the corresponding level.
      Specified by:
      resetDimension in interface IRegionManager
      Parameters:
      dim - the resource key of the level/dimension you want to reset its corresponding data for.