Interface CommandBlock
- All Superinterfaces:
Audience, BlockEntity, Contextual, CopyableDataHolder, DataHolder, DataHolder.Mutable, DataSerializable, LocaleSource, Locatable, Nameable, Pointered, SerializableDataHolder, SerializableDataHolder.Mutable, Subject, ValueContainer
Represents a Command Block.
-
Nested Class Summary
Nested classes/interfaces inherited from interface DataHolder
DataHolder.Immutable<I>, DataHolder.MutableNested classes/interfaces inherited from interface SerializableDataHolder
SerializableDataHolder.Immutable<I>, SerializableDataHolder.Mutable -
Method Summary
Modifier and TypeMethodDescriptiondefault Value.Mutable<Boolean> Gets whether this command block will keep track of the output from the last command it executed.voidexecute()Executes the currently stored command.default Optional<Value.Mutable<Component>> Gets the last command output.default Value.Mutable<String> Gets the currently stored command.default Value.Mutable<Integer> Gets the success count of the last executed command.Methods inherited from interface Audience
clearResourcePacks, clearTitle, closeDialog, deleteMessage, deleteMessage, filterAudience, forEachAudience, hideBossBar, openBook, openBook, playSound, playSound, playSound, removeResourcePacks, removeResourcePacks, removeResourcePacks, removeResourcePacks, removeResourcePacks, resetTitle, sendActionBar, sendActionBar, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendMessage, sendPlayerListFooter, sendPlayerListFooter, sendPlayerListHeader, sendPlayerListHeader, sendPlayerListHeaderAndFooter, sendPlayerListHeaderAndFooter, sendResourcePacks, sendResourcePacks, sendResourcePacks, sendTitlePart, showBossBar, showDialog, showTitle, stopSound, stopSoundMethods inherited from interface BlockEntity
block, canTick, copy, createArchetype, isRemoved, isTicking, locatableBlock, mirror, mirror, remove, rotate, rotate, setTicking, typeMethods inherited from interface Contextual
friendlyIdentifier, identifierMethods inherited from interface 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, undoMethods inherited from interface DataSerializable
contentVersion, toContainer, toViewMethods inherited from interface LocaleSource
localeMethods inherited from interface Locatable
blockPosition, location, serverLocation, worldMethods inherited from interface Pointered
get, getOrDefault, getOrDefaultFrom, pointersMethods inherited from interface SerializableDataHolder
validateRawDataMethods inherited from interface SerializableDataHolder.Mutable
setRawDataMethods inherited from interface Subject
associatedObject, asSubjectReference, containingCollection, contextCause, hasPermission, hasPermission, hasPermission, isChildOf, isChildOf, isChildOf, isSubjectDataPersisted, option, option, option, parents, parents, parents, permissionValue, permissionValue, permissionValue, subjectData, transientSubjectDataMethods inherited from interface ValueContainer
get, getDouble, getInt, getKeys, getLong, getOrElse, getOrNull, getValue, getValues, require, requireValue, streamKeys, streamValues, supports, supports
-
Method Details
-
execute
void execute()Executes the currently stored command. -
storedCommand
Gets the currently stored command.- Returns:
- The command
-
successCount
Gets the success count of the last executed command.The success count is the number of times the most recently used command of this command block succeeded. Most commands can only succeed once per execution, but certain commands (such as those which accept players as arguments) can succeed multiple times, and this value will be set accordingly. This success count can also be polled via a redstone comparator.
- Returns:
- The last success count
-
doesTrackOutput
Gets whether this command block will keep track of the output from the last command it executed.- Returns:
- Whether the command output is tracked
-
lastOutput
Gets the last command output.This will only be available if
doesTrackOutput()is set to true, otherwiseOptional.empty()will be returned.- Returns:
- The last command output, if available
-