Package net.minestom.server.instance
Class SharedInstance
java.lang.Object
net.minestom.server.instance.Instance
net.minestom.server.instance.SharedInstance
- All Implemented Interfaces:
Audience,ForwardingAudience,Pointered,PacketGroupingAudience,EventHandler<InstanceEvent>,Block.Getter,Block.Setter,Snapshotable,Taggable,TagReadable,TagWritable,Tickable,Schedulable
The
SharedInstance is an instance that shares the same chunks as its linked InstanceContainer,
entities are separated.-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minestom.server.instance.block.Block.Getter
Block.Getter.ConditionNested classes/interfaces inherited from interface net.kyori.adventure.audience.ForwardingAudience
ForwardingAudience.Single -
Field Summary
Fields inherited from class net.minestom.server.instance.Instance
tagHandler, uniqueId -
Constructor Summary
ConstructorsConstructorDescriptionSharedInstance(@NotNull UUID uniqueId, @NotNull InstanceContainer instanceContainer) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbreakBlock(@NotNull Player player, @NotNull Point blockPosition, @NotNull BlockFace blockFace, boolean doBlockUpdates) Does callPlayerBlockBreakEventand send particle packetsvoidenableAutoChunkLoad(boolean enable) When set to true, chunks will load automatically when requested.@Nullable GeneratorGets the generator associated with the instancegetChunk(int chunkX, int chunkZ) Gets the loadedChunkat a position.@NotNull Collection<Chunk> Gets all the instance's loaded chunks.Gets the chunk supplier of the instance.@NotNull InstanceContainerGets theInstanceContainerfrom where this instance takes its chunks from.booleanGets if the instance should auto load chunks.booleanDetermines whether a position in the void.@NotNull CompletableFuture<Chunk> loadChunk(int chunkX, int chunkZ) Forces the generation of aChunk, even if no file andChunkGeneratorare defined.@NotNull CompletableFuture<Chunk> loadOptionalChunk(int chunkX, int chunkZ) Loads the chunk if the chunk is already loaded or ifInstance.hasEnabledAutoChunkLoad()returns true.booleanplaceBlock(BlockHandler.Placement placement, boolean doBlockUpdates) @NotNull CompletableFuture<Void> Saves multiple chunks to permanent storage.@NotNull CompletableFuture<Void> saveChunkToStorage(@NotNull Chunk chunk) Saves aChunkto permanent storage.@NotNull CompletableFuture<Void> Saves the current instance tags.voidvoidsetChunkSupplier(@NotNull ChunkSupplier chunkSupplier) voidsetGenerator(@Nullable Generator generator) Changes the generator of the instancevoidunloadChunk(@NotNull Chunk chunk) Schedules the removal of aChunk, this method does not promise when it will be done.Methods inherited from class net.minestom.server.instance.Instance
breakBlock, createTimePacket, eventNode, explode, explode, getBlock, getBlockLight, getChunkAt, getChunkAt, getChunkEntities, getCreatures, getDimensionName, getDimensionType, getEntities, getEntityTracker, getExperienceOrbs, getExplosionSupplier, getInstanceSpace, getNearbyEntities, getPlayers, getSkyLight, getTime, getTimeRate, getTimeUpdate, getUniqueId, getWeather, getWorldAge, getWorldBorder, getWorldSpawnPosition, isChunkLoaded, isChunkLoaded, isRegistered, loadChunk, loadOptionalChunk, placeBlock, pointers, scheduleNextTick, scheduler, sendBlockAction, setBlock, setBlock, setChunkGenerator, setExplosionSupplier, setRegistered, setTime, setTimeRate, setTimeUpdate, setWeather, setWeather, setWorldSpawnPosition, setWorldSpawnPosition, tagHandler, tick, unloadChunk, updateSnapshotMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.kyori.adventure.audience.Audience
deleteMessage, openBook, removeResourcePacks, removeResourcePacks, removeResourcePacks, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendResourcePacks, sendResourcePacks, showTitle, stopSoundMethods inherited from interface net.minestom.server.instance.block.Block.Getter
getBlock, getBlock, getBlockMethods inherited from interface net.minestom.server.instance.block.Block.Setter
setBlockMethods inherited from interface net.kyori.adventure.audience.ForwardingAudience
clearResourcePacks, deleteMessage, filterAudience, forEachAudience, openBook, playSound, removeResourcePacks, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendResourcePacksMethods inherited from interface net.minestom.server.adventure.audience.PacketGroupingAudience
audiences, clearTitle, hideBossBar, playSound, playSound, playSound, resetTitle, sendActionBar, sendGroupedPacket, sendMessage, sendPlayerListHeaderAndFooter, sendTitlePart, showBossBar, stopSoundMethods inherited from interface net.kyori.adventure.pointer.Pointered
get, getOrDefault, getOrDefaultFrom
-
Constructor Details
-
SharedInstance
public SharedInstance(@NotNull @NotNull UUID uniqueId, @NotNull @NotNull InstanceContainer instanceContainer)
-
-
Method Details
-
setBlock
-
placeBlock
- Specified by:
placeBlockin classInstance
-
breakBlock
public boolean breakBlock(@NotNull @NotNull Player player, @NotNull @NotNull Point blockPosition, @NotNull @NotNull BlockFace blockFace, boolean doBlockUpdates) Description copied from class:InstanceDoes callPlayerBlockBreakEventand send particle packets- Specified by:
breakBlockin classInstance- Parameters:
player- thePlayerwho break the blockblockPosition- the position of the broken blockdoBlockUpdates- true to do block updates, false otherwise- Returns:
- true if the block has been broken, false if it has been cancelled
-
loadChunk
Description copied from class:InstanceForces the generation of aChunk, even if no file andChunkGeneratorare defined.- Specified by:
loadChunkin classInstance- Parameters:
chunkX- the chunk XchunkZ- the chunk Z- Returns:
- a
CompletableFuturecompleted once the chunk has been loaded
-
loadOptionalChunk
Description copied from class:InstanceLoads the chunk if the chunk is already loaded or ifInstance.hasEnabledAutoChunkLoad()returns true.- Specified by:
loadOptionalChunkin classInstance- Parameters:
chunkX- the chunk XchunkZ- the chunk Z- Returns:
- a
CompletableFuturecompleted once the chunk has been processed, can be null if not loaded
-
unloadChunk
Description copied from class:InstanceSchedules the removal of aChunk, this method does not promise when it will be done.WARNING: during unloading, all entities other than
Playerwill be removed.- Specified by:
unloadChunkin classInstance- Parameters:
chunk- the chunk to unload
-
getChunk
Description copied from class:InstanceGets the loadedChunkat a position.WARNING: this should only return already-loaded chunk, use
Instance.loadChunk(int, int)or similar to load one instead. -
saveInstance
Description copied from class:InstanceSaves the current instance tags.Warning: only the global instance data will be saved, not chunks. You would need to call
Instance.saveChunksToStorage()too.- Specified by:
saveInstancein classInstance- Returns:
- the future called once the instance data has been saved
-
saveChunkToStorage
Description copied from class:InstanceSaves aChunkto permanent storage.- Specified by:
saveChunkToStoragein classInstance- Parameters:
chunk- theChunkto save- Returns:
- future called when the chunk is done saving
-
saveChunksToStorage
Description copied from class:InstanceSaves multiple chunks to permanent storage.- Specified by:
saveChunksToStoragein classInstance- Returns:
- future called when the chunks are done saving
-
setChunkSupplier
- Specified by:
setChunkSupplierin classInstance
-
getChunkSupplier
Description copied from class:InstanceGets the chunk supplier of the instance.- Specified by:
getChunkSupplierin classInstance- Returns:
- the chunk supplier of the instance
-
generator
Description copied from class:InstanceGets the generator associated with the instance -
setGenerator
Description copied from class:InstanceChanges the generator of the instance- Specified by:
setGeneratorin classInstance- Parameters:
generator- the new generator, or null to disable generation
-
getChunks
Description copied from class:InstanceGets all the instance's loaded chunks. -
enableAutoChunkLoad
public void enableAutoChunkLoad(boolean enable) Description copied from class:InstanceWhen set to true, chunks will load automatically when requested. Otherwise usingInstance.loadChunk(int, int)will be required to even spawn a player- Specified by:
enableAutoChunkLoadin classInstance- Parameters:
enable- enable the auto chunk load
-
hasEnabledAutoChunkLoad
public boolean hasEnabledAutoChunkLoad()Description copied from class:InstanceGets if the instance should auto load chunks.- Specified by:
hasEnabledAutoChunkLoadin classInstance- Returns:
- true if auto chunk load is enabled, false otherwise
-
isInVoid
Description copied from class:InstanceDetermines whether a position in the void. -
getInstanceContainer
Gets theInstanceContainerfrom where this instance takes its chunks from.- Returns:
- the associated
InstanceContainer
-