Class SharedNetworkStoragesImpl
java.lang.Object
com.hammy275.immersivemc.server.api_impl.SharedNetworkStoragesImpl
- All Implemented Interfaces:
SharedNetworkStorages
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all storages.<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.<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.
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
SharedNetworkStoragesImpl
public SharedNetworkStoragesImpl()
-
-
Method Details
-
getOrCreate
public <S extends NetworkStorage> S getOrCreate(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, ImmersiveHandler<S> handler) Description copied from interface:SharedNetworkStoragesGets the NetworkStorage saved at the specified position, or creates a new one if one isn't already there.- Specified by:
getOrCreatein interfaceSharedNetworkStorages- 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- TheImmersiveHandlerfor 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 public <S extends NetworkStorage> S get(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, ImmersiveHandler<S> handler) Description copied from interface:SharedNetworkStoragesGets the NetworkStorage saved at the specified position, or returns null if one isn't already there.- Specified by:
getin interfaceSharedNetworkStorages- 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- TheImmersiveHandlerfor 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
public <S extends NetworkStorage> void remove(net.minecraft.world.level.Level level, net.minecraft.core.BlockPos pos, ImmersiveHandler<S> handler) Description copied from interface:SharedNetworkStoragesRemoves 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.- Specified by:
removein interfaceSharedNetworkStorages- 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- TheImmersiveHandlerfor the Immersive.
-
getAll
Description copied from interface:SharedNetworkStoragesGet 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.- Specified by:
getAllin interfaceSharedNetworkStorages- 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.
-
clear
public void clear()Clears all storages. Used by clients disconnecting to clear storages for singleplayer worlds.
-