Class SharedInstance
java.lang.Object
net.minestom.server.instance.Instance
net.minestom.server.instance.SharedInstance
- All Implemented Interfaces:
Audience, ForwardingAudience, Identified, 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 Block.Getter
Block.Getter.ConditionNested classes/interfaces inherited from interface ForwardingAudience
ForwardingAudience.Single -
Field Summary
Fields inherited from class Instance
chunkViewDistance, INSTANCE_POINTERS_SUPPLIER, tagHandler, uuid -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanGets if two instances share the same chunks.booleanbreakBlock(Player player, Point blockPosition, BlockFace blockFace, boolean doBlockUpdates) Does callPlayerBlockBreakEventand send particle packetsvoidenableAutoChunkLoad(boolean enable) When set to true, chunks will load automatically when requested.generateChunk(int chunkX, int chunkZ, Generator generator) Runs the providedGeneratorto generate a chunk at the given position.Gets the generator associated with the instancegetChunk(int chunkX, int chunkZ) Gets the loadedChunkat a position.Gets all the instance's loaded chunks.Gets the chunk supplier of the instance.Gets theInstanceContainerfrom where this instance takes its chunks from.booleanGets if the instance should auto load chunks.booleanDetermines whether a position in the void.loadChunk(int chunkX, int chunkZ) 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) Saves multiple chunks to permanent storage.saveChunkToStorage(Chunk chunk) Saves aChunkto permanent storage.Saves the current instance tags.voidvoidsetChunkSupplier(ChunkSupplier chunkSupplier) voidsetGenerator(@Nullable Generator generator) Changes the generator of the instancevoidunloadChunk(Chunk chunk) Schedules the removal of aChunk, this method does not promise when it will be done.Methods inherited from class Instance
bossBars, breakBlock, createInitializeWorldBorderPacket, createTimePacket, eventNode, explode, explode, getBlock, getBlockLight, getCachedDimensionType, getChunkAt, getChunkAt, getChunkEntities, getCreatures, getDimensionName, getDimensionType, getEntities, getEntityById, getEntityByUuid, getEntityTracker, getExperienceOrbs, getExplosionSupplier, getNearbyEntities, getPlayerByUuid, getPlayers, getSkyLight, getTime, getTimeRate, getTimeSynchronizationTicks, getUniqueId, getUuid, getWeather, getWorldAge, getWorldBorder, hideBossBar, identity, invalidateSection, isChunkLoaded, isChunkLoaded, isRegistered, loadChunk, loadOptionalChunk, placeBlock, playSoundExcept, playSoundExcept, playSoundExcept, pointers, scheduleNextTick, scheduler, sendBlockAction, setBlock, setBlock, setExplosionSupplier, setRegistered, setTime, setTimeRate, setTimeSynchronizationTicks, setWeather, setWeather, setWorldAge, setWorldBorder, setWorldBorder, showBossBar, tagHandler, tick, unloadChunk, updateSnapshot, viewDistance, viewDistanceMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface 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 Block.Getter
getBlock, getBlock, getBlockMethods inherited from interface Block.Setter
setBlock, setBlockAreaMethods inherited from interface ForwardingAudience
clearResourcePacks, closeDialog, deleteMessage, filterAudience, forEachAudience, openBook, playSound, removeResourcePacks, removeResourcePacks, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendResourcePacks, showDialogMethods inherited from interface PacketGroupingAudience
audiences, clearTitle, playSound, playSound, playSound, resetTitle, sendActionBar, sendGroupedPacket, sendMessage, sendNotification, sendPlayerListHeaderAndFooter, sendTitlePart, stopSoundMethods inherited from interface Pointered
get, getOrDefault, getOrDefaultFromMethods inherited from interface Taggable
getAndSetTag, getAndUpdateTag, getTag, hasTag, removeTag, setTag, updateAndGetTag, updateTag
-
Constructor Details
-
SharedInstance
-
-
Method Details
-
setBlock
-
placeBlock
- Specified by:
placeBlockin classInstance
-
breakBlock
public boolean breakBlock(Player player, Point blockPosition, 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:Instance- 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
-
setGenerator
-
generateChunk
@Experimental public CompletableFuture<Void> generateChunk(int chunkX, int chunkZ, Generator generator) Description copied from class:InstanceRuns the providedGeneratorto generate a chunk at the given position.Loads the chunk if not already loaded.
- Specified by:
generateChunkin classInstance- Parameters:
chunkX- the chunk XchunkZ- the chunk Zgenerator- the generator to use- Returns:
- a future called once the generation is complete
-
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
-
getInstanceContainer
Gets theInstanceContainerfrom where this instance takes its chunks from.- Returns:
- the associated
InstanceContainer
-
areLinked
-