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.Condition
Nested 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
ConstructorDescriptionSharedInstance
(@NotNull UUID uniqueId, @NotNull InstanceContainer instanceContainer) -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Gets if two instances share the same chunks.boolean
breakBlock
(@NotNull Player player, @NotNull Point blockPosition, @NotNull BlockFace blockFace, boolean doBlockUpdates) Does callPlayerBlockBreakEvent
and send particle packetsvoid
enableAutoChunkLoad
(boolean enable) When set to true, chunks will load automatically when requested.@Nullable Generator
Gets the generator associated with the instancegetChunk
(int chunkX, int chunkZ) Gets the loadedChunk
at a position.@NotNull Collection
<Chunk> Gets all the instance's loaded chunks.Gets the chunk supplier of the instance.@NotNull InstanceContainer
Gets theInstanceContainer
from where this instance takes its chunks from.boolean
Gets if the instance should auto load chunks.boolean
Determines whether a position in the void.@NotNull CompletableFuture
<Chunk> loadChunk
(int chunkX, int chunkZ) @NotNull CompletableFuture
<Chunk> loadOptionalChunk
(int chunkX, int chunkZ) Loads the chunk if the chunk is already loaded or ifInstance.hasEnabledAutoChunkLoad()
returns true.boolean
placeBlock
(BlockHandler.Placement placement, boolean doBlockUpdates) @NotNull CompletableFuture
<Void> Saves multiple chunks to permanent storage.@NotNull CompletableFuture
<Void> saveChunkToStorage
(@NotNull Chunk chunk) Saves aChunk
to permanent storage.@NotNull CompletableFuture
<Void> Saves the current instance tags.void
void
setChunkSupplier
(@NotNull ChunkSupplier chunkSupplier) void
setGenerator
(@Nullable Generator generator) Changes the generator of the instancevoid
unloadChunk
(@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, 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, getWeather, getWorldAge, getWorldBorder, 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, tagHandler, tick, unloadChunk, updateSnapshot
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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, stopSound
Methods inherited from interface net.minestom.server.instance.block.Block.Getter
getBlock, getBlock, getBlock
Methods inherited from interface net.minestom.server.instance.block.Block.Setter
setBlock
Methods inherited from interface net.kyori.adventure.audience.ForwardingAudience
clearResourcePacks, deleteMessage, filterAudience, forEachAudience, openBook, playSound, removeResourcePacks, removeResourcePacks, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListHeader, sendResourcePacks
Methods inherited from interface net.minestom.server.adventure.audience.PacketGroupingAudience
audiences, clearTitle, hideBossBar, playSound, playSound, playSound, resetTitle, sendActionBar, sendGroupedPacket, sendMessage, sendNotification, sendPlayerListHeaderAndFooter, sendTitlePart, showBossBar, stopSound
Methods inherited from interface net.kyori.adventure.pointer.Pointered
get, getOrDefault, getOrDefaultFrom
Methods inherited from interface net.minestom.server.tag.Taggable
getAndSetTag, getAndUpdateTag, getTag, hasTag, removeTag, setTag, updateAndGetTag, updateTag
-
Constructor Details
-
SharedInstance
public SharedInstance(@NotNull @NotNull UUID uniqueId, @NotNull @NotNull InstanceContainer instanceContainer)
-
-
Method Details
-
setBlock
-
placeBlock
- Specified by:
placeBlock
in classInstance
-
breakBlock
public boolean breakBlock(@NotNull @NotNull Player player, @NotNull @NotNull Point blockPosition, @NotNull @NotNull BlockFace blockFace, boolean doBlockUpdates) Description copied from class:Instance
Does callPlayerBlockBreakEvent
and send particle packets- Specified by:
breakBlock
in classInstance
- Parameters:
player
- thePlayer
who 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:
loadChunk
in classInstance
- Parameters:
chunkX
- the chunk XchunkZ
- the chunk Z- Returns:
- a
CompletableFuture
completed once the chunk has been loaded
-
loadOptionalChunk
Description copied from class:Instance
Loads the chunk if the chunk is already loaded or ifInstance.hasEnabledAutoChunkLoad()
returns true.- Specified by:
loadOptionalChunk
in classInstance
- Parameters:
chunkX
- the chunk XchunkZ
- the chunk Z- Returns:
- a
CompletableFuture
completed once the chunk has been processed, can be null if not loaded
-
unloadChunk
Description copied from class:Instance
Schedules the removal of aChunk
, this method does not promise when it will be done.WARNING: during unloading, all entities other than
Player
will be removed.- Specified by:
unloadChunk
in classInstance
- Parameters:
chunk
- the chunk to unload
-
getChunk
Description copied from class:Instance
Gets the loadedChunk
at 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:Instance
Saves 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:
saveInstance
in classInstance
- Returns:
- the future called once the instance data has been saved
-
saveChunkToStorage
Description copied from class:Instance
Saves aChunk
to permanent storage.- Specified by:
saveChunkToStorage
in classInstance
- Parameters:
chunk
- theChunk
to save- Returns:
- future called when the chunk is done saving
-
saveChunksToStorage
Description copied from class:Instance
Saves multiple chunks to permanent storage.- Specified by:
saveChunksToStorage
in classInstance
- Returns:
- future called when the chunks are done saving
-
setChunkSupplier
- Specified by:
setChunkSupplier
in classInstance
-
getChunkSupplier
Description copied from class:Instance
Gets the chunk supplier of the instance.- Specified by:
getChunkSupplier
in classInstance
- Returns:
- the chunk supplier of the instance
-
generator
Description copied from class:Instance
Gets the generator associated with the instance -
setGenerator
Description copied from class:Instance
Changes the generator of the instance- Specified by:
setGenerator
in classInstance
- Parameters:
generator
- the new generator, or null to disable generation
-
getChunks
Description copied from class:Instance
Gets all the instance's loaded chunks. -
enableAutoChunkLoad
public void enableAutoChunkLoad(boolean enable) Description copied from class:Instance
When set to true, chunks will load automatically when requested. Otherwise usingInstance.loadChunk(int, int)
will be required to even spawn a player- Specified by:
enableAutoChunkLoad
in classInstance
- Parameters:
enable
- enable the auto chunk load
-
hasEnabledAutoChunkLoad
public boolean hasEnabledAutoChunkLoad()Description copied from class:Instance
Gets if the instance should auto load chunks.- Specified by:
hasEnabledAutoChunkLoad
in classInstance
- Returns:
- true if auto chunk load is enabled, false otherwise
-
isInVoid
Description copied from class:Instance
Determines whether a position in the void. -
getInstanceContainer
Gets theInstanceContainer
from where this instance takes its chunks from.- Returns:
- the associated
InstanceContainer
-
areLinked
Gets if two instances share the same chunks.- Parameters:
instance1
- the first instanceinstance2
- the second instance- Returns:
- true if the two instances share the same chunks
-