RebarSimpleMultiblock

A multiblock that is made of a predefined set of components.

Automatically creates ghost blocks to show how to build your multiblock.

Automatically handles different possible rotations of your multiblock.

If you need something more flexible (eg: a fluid tank that can have up to 10 fluid casings added to increase the capacity), see RebarMultiblock.

Types

Link copied to clipboard

Represents a single block of a multiblock.

Properties

Link copied to clipboard
abstract val block: Block
Link copied to clipboard
open override val chunksOccupied: Set<ChunkPosition>

All chunks containing at least one component of the multiblock

Link copied to clipboard

The positions and corresponding components of the multiblock.

Link copied to clipboard
open override val culledEntityIds: Iterable<UUID>

Any entity id's that should be culled when the block is considered culled by the BlockTextureEngine. The default implementation of onVisible and onCulled assumes that these are real entities When using real entities you cannot include entities in this list that are invisible by default, if you do they will not be culled properly.

Link copied to clipboard
@get:ApiStatus.NonExtendable
open val heldEntities: MutableMap<String, UUID>
Link copied to clipboard

Imagine the smallest square containing the multiblock; this is the radius of that square.

Link copied to clipboard
open override val isCulledAsync: Boolean

If the entities should be shown/hidden asynchronously instead of scheduled to be shown/hidden on the main thread. By default, this is false and the entities will be shown/hidden on the main thread because they are real entities.

Link copied to clipboard

Imagine the smallest cuboid (with equal width and length) containing the multiblock; this is the corner with the highest X, Y, and Z coordinates.

Link copied to clipboard

Imagine the smallest cuboid (with equal width and length) containing the multiblock; this is the corner with the lowest X, Y, and Z coordinates.

Functions

Link copied to clipboard
open fun addEntity(name: String, entity: RebarEntity<*>)
open fun addEntity(name: String, entity: Entity)
Link copied to clipboard
open fun addGhostBlock(position: Vector3i, vanillaBlocks: List<BlockData>, rebarBlocks: List<NamespacedKey>)
Link copied to clipboard
@ApiStatus.NonExtendable
open fun areAllHeldEntitiesLoaded(): Boolean

Returns false if any entity is unloaded or does not exist.

Link copied to clipboard
open override fun checkFormed(): Boolean

Warning: You should not call this yourself. If you want to know if the multiblock is formed, use isFormedAndFullyLoaded(), which will read from a cache, so is much faster.

Link copied to clipboard
@ApiStatus.NonExtendable
open fun getHeldEntity(name: String): Entity?
@ApiStatus.NonExtendable
open fun <T : Entity> getHeldEntity(clazz: Class<T>, name: String): T?
Link copied to clipboard
@ApiStatus.NonExtendable
open fun getHeldEntityOrThrow(name: String): Entity
@ApiStatus.NonExtendable
open fun <T : Entity> getHeldEntityOrThrow(clazz: Class<T>, name: String): T
Link copied to clipboard
@ApiStatus.NonExtendable
open fun getHeldEntityUuid(name: String): UUID?
Link copied to clipboard
@ApiStatus.NonExtendable
open fun getHeldEntityUuidOrThrow(name: String): UUID
Link copied to clipboard
@ApiStatus.NonExtendable
open fun getHeldRebarEntity(name: String): RebarEntity<*>?
@ApiStatus.NonExtendable
open fun <T : RebarEntity<*>> getHeldRebarEntity(clazz: Class<T>, name: String): T?
Link copied to clipboard
@ApiStatus.NonExtendable
open fun <T : RebarEntity<*>> getHeldRebarEntityOrThrow(clazz: Class<T>, name: String): T
Link copied to clipboard
open fun getMultiblockBlock(position: Vector3i): @NotNull Block
Link copied to clipboard
open fun <T> getMultiblockComponent(clazz: Class<T>, position: Vector3i): T?
Link copied to clipboard
Link copied to clipboard

The 'direction' we expect the multiblock to be built in. This is not the actual direction that the multiblock has been built in.

Link copied to clipboard
open fun getRotatedPosition(rotatedPosition: Vector3i): Vector3i
Link copied to clipboard
abstract fun getWaila(player: Player): WailaDisplay?

Automatically implemented by RebarBlock

Link copied to clipboard
open fun hasGhostBlockAt(position: Vector3i): Boolean
Link copied to clipboard

Returns true if every component of the multiblock is loaded AND the multiblock is formed. Reads from a cache, so call as often as you want.

Link copied to clipboard
@ApiStatus.NonExtendable
open fun isHeldEntityPresent(name: String): Boolean

Returns false if the block holds no entity with the provided name, the entity is unloaded or does not physically exist.

Link copied to clipboard
open override fun isPartOfMultiblock(otherBlock: Block): Boolean

Should return true if there is any scenario in which this block's position could be part of a formed multiblock.

Link copied to clipboard
open override fun isVisible(player: Player): Boolean

If the block is currently visible to the player. By default, this checks that the first entity from culledEntityIds is not toggled invisible for the player If you are using fake/packet entities you must override this method.

Link copied to clipboard
open override fun onCulled(player: Player)

Hides all entities in culledEntityIds currently visible to the player. By default, this assumes that all entities in culledEntityIds are real entities, if they are not you must override this method.

Link copied to clipboard
@MustBeInvokedByOverriders
open override fun onMultiblockFormed()

Called when the multiblock is formed (i.e., was not formed before, but now is). This includes when the multiblock was previously formed, unloaded, and loaded again.

Link copied to clipboard

Called when the multiblock is refreshed (i.e., was formed before, and still is). This happens when something causes the Multiblock to re-check if it is formed, and it still is.

Link copied to clipboard
@MustBeInvokedByOverriders
open override fun onMultiblockUnformed(partUnloaded: Boolean)

Called when the multiblock is unformed (i.e., was formed before, but now is not). This includes when a part of the multiblock is unloaded and the multiblock becomes unformed because of it, or when part of the multiblock is broken/changed, and it becomes unformed because of it.

Link copied to clipboard
open override fun onVisible(player: Player)

Reveals all entities in culledEntityIds not currently visible to the player. By default, this assumes that all entities in culledEntityIds are real entities, if they are not you must override this method.

Link copied to clipboard
open fun removeGhostBlock(position: Vector3i)
Link copied to clipboard
open fun setMultiblockDirection(direction: BlockFace?)

Sets the 'direction' we expect the multiblock to be built in. North is considered the default facing direction - ie setFacing(BlockFace.NORTH) will preserve the original multiblock structure without rotating it.

Link copied to clipboard
Link copied to clipboard
open fun tryRemoveEntity(name: String)
Link copied to clipboard

Returns all the valid configurations of the multiblock. If any of these is satisfied, the multiblock will be considered complete.

Link copied to clipboard
@ApiStatus.NonExtendable
open fun whenHeldRebarEntityLoads(name: String, consumer: Consumer<RebarEntity<*>>)
@ApiStatus.NonExtendable
open fun <T : RebarEntity<*>> whenHeldRebarEntityLoads(clazz: Class<T>, name: String, consumer: Consumer<T>)