Package de.z0rdak.yawp.data.region
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
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddDimKeyOnDimensionChange(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 voidaddDimKeyOnPlayerLogin(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 voidaddFlags(Set<String> flags, IProtectedRegion region) cacheFor(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) booleancontainsCacheFor(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) static RegionDataManagerget()getCache(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) intstatic List<DimensionRegionCache>Returns the name of all dimension tracked by the region data manager.Set<net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>>getFlagsIdsForDim(DimensionRegionCache dimCache) intgetRegionAmount(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) @Nullable Optional<IMarkableRegion>getRegionIn(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim, String regionName) getRegionsFor(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) intstatic voidinitServerInstance(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.booleanisAvailableForLocal(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.intisValidRegionName(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.static RegionDataManagerload(net.minecraft.nbt.CompoundTag nbt) Method which gets called when a new RegionDataManager instance is created by loadRegionData.static voidloadRegionDataForWorld(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) voidresetDimensionCache(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim) voidstatic voidsave()net.minecraft.nbt.CompoundTagsave(@NotNull net.minecraft.nbt.CompoundTag compound) 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
-
Field Details
-
serverInstance
public static net.minecraft.server.MinecraftServer serverInstance
-
-
Method Details
-
save
public static void save() -
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
-
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
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
-
save
public net.minecraft.nbt.CompoundTag save(@NotNull @NotNull net.minecraft.nbt.CompoundTag compound) Method which gets called the region data is marked as dirty via the save/markDirty method.- Specified by:
savein classnet.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
-
getDimKeys
-
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
-
newCacheFor
public DimensionRegionCache newCacheFor(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dim)
-