Interface BlockEntity
- All Superinterfaces:
CopyableDataHolder
,DataHolder
,DataHolder.Mutable
,DataSerializable
,Locatable
,SerializableDataHolder
,SerializableDataHolder.Mutable
,ValueContainer
- All Known Subinterfaces:
Banner
,Barrel
,Beacon
,Bed
,Beehive
,Bell
,BlastFurnace
,BrewingStand
,Campfire
,CarrierBlockEntity
,Chest
,CommandBlock
,Comparator
,Conduit
,Crafter
,DaylightDetector
,DecoratedPot
,Dispenser
,Dropper
,EnchantmentTable
,EnderChest
,EndGateway
,EndPortal
,Furnace
,FurnaceBlockEntity
,Hopper
,Jigsaw
,Jukebox
,Lectern
,MobSpawner
,NameableBlockEntity
,NameableCarrierBlockEntity
,Piston
,SculkSensor
,ShulkerBox
,Sign
,Skull
,Smoker
,StructureBlock
,TrappedChest
,TrialSpawner
Represents a block entity. It is a functional block that is
continuously updated while residing in a world. It can perform specific
functions based on the data that it contains.
A BlockEntity
is contained within a ServerLocation
and will
continue to exists so long as the ServerLocation
is of the correct
block type.
Since a BlockEntity
is performing various actions, all methods
that are purely functional methods reside in the BlockEntity
, whereas
customizable data associated with a BlockEntity
is represented by
Values
.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.spongepowered.api.data.DataHolder
DataHolder.Immutable<I extends DataHolder.Immutable<I>>, DataHolder.Mutable
Nested classes/interfaces inherited from interface org.spongepowered.api.data.SerializableDataHolder
SerializableDataHolder.Immutable<I extends SerializableDataHolder.Immutable<I>>, SerializableDataHolder.Mutable
-
Method Summary
Modifier and TypeMethodDescriptionblock()
Gets theBlockState
that thisBlockEntity
represents.boolean
canTick()
Returns whether this block entity can tick.copy()
Creates a newBlockEntityArchetype
for use withSchematic
s and placing the archetype in multiple locations.Creates a newBlockEntityArchetype
for use withSchematic
s and placing the archetype in multiple locations.boolean
Returns whether this block entity has been removed.boolean
Returns whether this block entity is ticking.Creates aLocatableBlock
for thisBlockEntity
.default BlockEntity
Gets the appropriateBlockEntity
for the desiredMirror
.Gets the appropriateBlockEntity
for the desiredMirror
.void
remove()
Removes this block entity from the world and its corresponding block.default BlockEntity
Rotates thisBlockEntity
for the desiredRotation
.Rotates thisBlockEntity
for the desiredRotation
.boolean
setTicking
(boolean ticking) Attempts to set if this block entity will naturally tick.type()
Gets the type ofBlockEntity
this is.Methods inherited from interface org.spongepowered.api.data.DataHolder.Mutable
copyFrom, copyFrom, offer, offer, offer, offer, offerAll, offerAll, offerAll, offerAll, offerAll, offerAll, offerSingle, offerSingle, offerSingle, offerSingle, remove, remove, remove, removeAll, removeAll, removeAll, removeAll, removeAll, removeAll, removeKey, removeKey, removeSingle, removeSingle, transform, transform, tryOffer, tryOffer, tryOffer, undo
Methods inherited from interface org.spongepowered.api.data.persistence.DataSerializable
contentVersion, toContainer
Methods inherited from interface org.spongepowered.api.world.Locatable
blockPosition, location, serverLocation, world
Methods inherited from interface org.spongepowered.api.data.SerializableDataHolder
validateRawData
Methods inherited from interface org.spongepowered.api.data.SerializableDataHolder.Mutable
setRawData
-
Method Details
-
isRemoved
boolean isRemoved()Returns whether this block entity has been removed.- Returns:
- True if this block entity has been removed
-
remove
void remove()Removes this block entity from the world and its corresponding block. -
canTick
boolean canTick()Returns whether this block entity can tick.- Returns:
- True if this block entity can tick
-
isTicking
boolean isTicking()Returns whether this block entity is ticking.- Returns:
- True if this block entity is ticking
-
setTicking
boolean setTicking(boolean ticking) Attempts to set if this block entity will naturally tick.This will return
false
ifisRemoved()
returnstrue
orcanTick()
returnsfalse
- Parameters:
ticking
- The ticking state- Returns:
- True if ticking state was successfully set
-
type
BlockEntityType type()Gets the type ofBlockEntity
this is.- Returns:
- The type of block entity
-
block
BlockState block()Gets theBlockState
that thisBlockEntity
represents.- Returns:
- The blockstate
-
rotate
Rotates thisBlockEntity
for the desiredRotation
.- Parameters:
rotation
- The rotation- Returns:
- The rotated state if not this state
-
rotate
Rotates thisBlockEntity
for the desiredRotation
.- Parameters:
rotation
- The rotation- Returns:
- The rotated state if not this state
-
mirror
Gets the appropriateBlockEntity
for the desiredMirror
.- Parameters:
mirror
- The mirror- Returns:
- The mirrored BlockEntity
-
mirror
Gets the appropriateBlockEntity
for the desiredMirror
.- Parameters:
mirror
- The mirror- Returns:
- The mirrored BlockEntity
-
createArchetype
BlockEntityArchetype createArchetype()Creates a newBlockEntityArchetype
for use withSchematic
s and placing the archetype in multiple locations.- Returns:
- The created archetype for re-creating this block entity
-
locatableBlock
LocatableBlock locatableBlock()Creates aLocatableBlock
for thisBlockEntity
. Can be used as a simpler method of making them. Since this does not persist the data of thisBlockEntity
, it should not be used in place of aBlockSnapshot
where data is being safely cloned.- Returns:
- The created locatable block, not as a block snapshot
-
copy
BlockEntity copy()Creates a newBlockEntityArchetype
for use withSchematic
s and placing the archetype in multiple locations.- Specified by:
copy
in interfaceCopyableDataHolder
- Specified by:
copy
in interfaceSerializableDataHolder
- Specified by:
copy
in interfaceSerializableDataHolder.Mutable
- Returns:
- The created archetype for re-creating this block entity
-