Interface SharedNetworkStorages
- All Known Implementing Classes:
SharedNetworkStoragesImpl
@Beta
public interface SharedNetworkStorages
A place to keep
Note: This API is currently untested. Beyond just the @Beta annotation, this API may contain more bugs than other parts of the ImmersiveMC API.
NetworkStorage
instances. These are not saved to disk, but are kept as long as the
immersive block exists and is tracked by at least one player. Useful for keeping shared state that can
be synced to players if they start tracking an Immersive.
Note: This API is currently untested. Beyond just the @Beta annotation, this API may contain more bugs than other parts of the ImmersiveMC API.
-
Method Summary
Modifier and TypeMethodDescription<S extends NetworkStorage>
Sget
(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, ImmersiveHandler<S> handler) Gets the NetworkStorage saved at the specified position, or returns null if one isn't already there.<S extends NetworkStorage>
List<S>Get all storages stored that match some class; useful for marking storages as no longer dirty for client syncing.<S extends NetworkStorage>
SgetOrCreate
(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, ImmersiveHandler<S> handler) Gets the NetworkStorage saved at the specified position, or creates a new one if one isn't already there.static SharedNetworkStorages
instance()
<S extends NetworkStorage>
voidremove
(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, ImmersiveHandler<S> handler) Removes the NetworkStorage saved at the specified position, or does nothing if one isn't there or doesn't match the storage type of the handler provided.
-
Method Details
-
instance
- Returns:
- A SharedNetworkStorages instance to access API functions. All details of this object not mentioned in this file are assumed to be an implementation detail, and may change at any time.
-
getOrCreate
<S extends NetworkStorage> S getOrCreate(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, ImmersiveHandler<S> handler) Gets the NetworkStorage saved at the specified position, or creates a new one if one isn't already there.- Type Parameters:
S
- The type of storage used by the ImmersiveHandler.- Parameters:
level
- The level to get the storage from. This should be the level the Immersive is in.pos
- The position to get the storage from. This should be the block position the Immersive is at.handler
- TheImmersiveHandler
for the Immersive.- Returns:
- An instance of S, which is the NetworkStorage at that position. It may have been freshly created via
ImmersiveHandler.getEmptyNetworkStorage()
, so it may need initializing.
-
get
@Nullable <S extends NetworkStorage> S get(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, ImmersiveHandler<S> handler) Gets the NetworkStorage saved at the specified position, or returns null if one isn't already there.- Type Parameters:
S
- The type of storage used by the ImmersiveHandler.- Parameters:
level
- The level to get the storage from. This should be the level the Immersive is in.pos
- The position to get the storage from. This should be the block position the Immersive is at.handler
- TheImmersiveHandler
for the Immersive.- Returns:
- An instance of S, which is the NetworkStorage at that position, or null if a NetworkStorage either wasn't there, or did not match the type of your handler.
-
remove
<S extends NetworkStorage> void remove(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, ImmersiveHandler<S> handler) Removes the NetworkStorage saved at the specified position, or does nothing if one isn't there or doesn't match the storage type of the handler provided.- Type Parameters:
S
- The type of storage used by the ImmersiveHandler.- Parameters:
level
- The level to remove the storage from. This should be the level the Immersive is in.pos
- The position to remove the storage from. This should be the block position the Immersive is at.handler
- TheImmersiveHandler
for the Immersive.
-
getAll
Get all storages stored that match some class; useful for marking storages as no longer dirty for client syncing. Note that the returned list is not guaranteed to be mutable.- Type Parameters:
S
- The type of storage to get a list of.- Parameters:
storageClass
- The class of storages to get.- Returns:
- A list of all storages matching the provided class. The list is not guaranteed to be mutable.
-