Class BaseCommandBlock

java.lang.Object
net.minecraft.world.level.BaseCommandBlock
All Implemented Interfaces:
CommandSource
Direct Known Subclasses:
MinecartCommandBlock.MinecartCommandBase

public abstract class BaseCommandBlock extends Object implements CommandSource
  • Field Details

    • TIME_FORMAT

      private static final SimpleDateFormat TIME_FORMAT
      The formatting for the timestamp on commands run.
    • DEFAULT_NAME

      private static final Component DEFAULT_NAME
    • lastExecution

      private long lastExecution
    • updateLastExecution

      private boolean updateLastExecution
    • successCount

      private int successCount
      The number of successful commands run. (used for redstone output)
    • trackOutput

      private boolean trackOutput
    • lastOutput

      @Nullable private Component lastOutput
      The previously run command.
    • command

      private String command
      The command stored in the command block.
    • customName

      @Nullable private Component customName
  • Constructor Details

    • BaseCommandBlock

      public BaseCommandBlock()
  • Method Details

    • getSuccessCount

      public int getSuccessCount()
    • setSuccessCount

      public void setSuccessCount(int pSuccessCount)
    • getLastOutput

      public Component getLastOutput()
    • save

      public CompoundTag save(CompoundTag pTag, HolderLookup.Provider pLevelRegistry)
    • load

      public void load(CompoundTag pTag, HolderLookup.Provider pLevelRegistry)
    • setCommand

      public void setCommand(String pCommand)
      Sets the command.
    • getCommand

      public String getCommand()
    • performCommand

      public boolean performCommand(Level pLevel)
    • getName

      public Component getName()
    • getCustomName

      @Nullable public Component getCustomName()
    • setCustomName

      public void setCustomName(@Nullable Component pCustomName)
    • sendSystemMessage

      public void sendSystemMessage(Component pComponent)
      Specified by:
      sendSystemMessage in interface CommandSource
    • getLevel

      public abstract ServerLevel getLevel()
    • onUpdated

      public abstract void onUpdated()
    • setLastOutput

      public void setLastOutput(@Nullable Component pLastOutputMessage)
    • setTrackOutput

      public void setTrackOutput(boolean pShouldTrackOutput)
    • isTrackOutput

      public boolean isTrackOutput()
    • usedBy

      public InteractionResult usedBy(Player pPlayer)
    • getPosition

      public abstract Vec3 getPosition()
    • createCommandSourceStack

      public abstract CommandSourceStack createCommandSourceStack()
    • acceptsSuccess

      public boolean acceptsSuccess()
      Specified by:
      acceptsSuccess in interface CommandSource
    • acceptsFailure

      public boolean acceptsFailure()
      Specified by:
      acceptsFailure in interface CommandSource
    • shouldInformAdmins

      public boolean shouldInformAdmins()
      Specified by:
      shouldInformAdmins in interface CommandSource
    • isValid

      public abstract boolean isValid()