Class StorageInstance<D extends IStorageData,S extends IServerStorage<D>>

java.lang.Object
net.nullved.pmweatherapi.storage.StorageInstance<D,S>
Type Parameters:
D - The IStorageData of the IServerStorage
S - The IServerStorage

public class StorageInstance<D extends IStorageData,S extends IServerStorage<D>> extends Object
A Storage Instance for a given IServerStorage type.

A Storage Instance holds all of the IServerStorage instances for each dimension.

To get the IServerStorage for a specific dimension, use get(ResourceKey). If you are unsure the IServerStorage exists and have a ServerLevel, use getOrCreate(ServerLevel).

To load a new dimension, pass the ServerLevel into load(ServerLevel). To remove a dimension, call remove(ResourceKey)

You should not create StorageInstances yourself. Instead, get them from PMWStorages.get(net.minecraft.resources.ResourceLocation)
Since:
0.15.3.3
  • Constructor Details

    • StorageInstance

      public StorageInstance(net.minecraft.resources.ResourceLocation id, Class<S> clazz, Function<net.minecraft.server.level.ServerLevel,S> creator)
  • Method Details

    • id

      public net.minecraft.resources.ResourceLocation id()
    • getBackingMap

      public HashMap<net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>,S> getBackingMap()
    • clear

      public void clear()
    • keySet

      public Set<net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>> keySet()
    • values

      public Collection<S> values()
    • entrySet

      public Set<Map.Entry<net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level>,S>> entrySet()
    • get

      public S get(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension)
    • getOrCreate

      public S getOrCreate(net.minecraft.server.level.ServerLevel level)
    • cast

      public <F extends IStorageData, O extends IServerStorage<F>> Optional<StorageInstance<F,O>> cast(Class<O> oclazz)
    • load

      public void load(net.minecraft.server.level.ServerLevel level)
    • remove

      public void remove(net.minecraft.resources.ResourceKey<net.minecraft.world.level.Level> dimension)