Class AuditoryBlockEntity

java.lang.Object
net.minecraft.world.level.block.entity.BlockEntity
com.codinglitch.simpleradio.central.AuditoryBlockEntity
All Implemented Interfaces:
Socket, net.fabricmc.fabric.api.attachment.v1.AttachmentTarget, net.fabricmc.fabric.api.blockview.v2.RenderDataBlockEntity
Direct Known Subclasses:
CatalyzingBlockEntity, MicrophoneBlockEntity, RadioBlockEntity, SpeakerBlockEntity

public abstract class AuditoryBlockEntity extends net.minecraft.world.level.block.entity.BlockEntity implements Socket
A block entity which interacts with audio in some way;

Although this is not required to be extended, it provides helper methods and overrides to simplify the creation of auditory blocks.

  • Nested Class Summary

    Nested classes/interfaces inherited from class net.minecraft.world.level.block.entity.BlockEntity

    net.minecraft.world.level.block.entity.BlockEntity.DataComponentInput
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    boolean
     
     
     
    @Nullable Listener
     
    @Nullable Receiver
     
    @Nullable Speaker
     
    @Nullable Transmitter
     

    Fields inherited from class net.minecraft.world.level.block.entity.BlockEntity

    level, remove, worldPosition

    Fields inherited from interface net.fabricmc.fabric.api.attachment.v1.AttachmentTarget

    NBT_ATTACHMENT_KEY
  • Constructor Summary

    Constructors
    Constructor
    Description
    AuditoryBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType<?> blockEntityType, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This is called whenever the block is initially activated (placed, on world load, chunk loaded, etc.) Use this to create and register the associated routers for this block.
    void
    This is called whenever the block is deactivated (chunk unloaded, block broken, etc.) Use this to clean up the associated routers.
    net.minecraft.world.phys.Vec3
     
    Override this to expose a given router to wires.
    @Nullable net.minecraft.network.protocol.Packet<net.minecraft.network.protocol.game.ClientGamePacketListener>
     
    net.minecraft.nbt.CompoundTag
    getUpdateTag(net.minecraft.core.HolderLookup.Provider provider)
     
    void
    loadFromItem(net.minecraft.world.item.ItemStack stack)
     
    void
    loadTag(net.minecraft.nbt.CompoundTag tag)
     
    protected void
    saveAdditional(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider provider)
     
    void
    saveTag(net.minecraft.nbt.CompoundTag tag)
     
    void
    saveToItem(net.minecraft.world.item.ItemStack stack, net.minecraft.core.HolderLookup.Provider provider)
     
    void
    setLevel(net.minecraft.world.level.Level level)
     
    void
     
    static net.minecraft.nbt.CompoundTag
    tagFromComponents(net.minecraft.world.item.ItemStack stack, net.minecraft.nbt.CompoundTag tag)
     
    void
    Checks if this block should be deactivated due to an invalid router.

    Methods inherited from class net.minecraft.world.level.block.entity.BlockEntity

    addEntityType, applyComponents, applyComponentsFromItemStack, applyImplicitComponents, clearRemoved, collectComponents, collectImplicitComponents, components, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getPosFromTag, getType, hasLevel, isRemoved, isValidBlockState, loadAdditional, loadCustomOnly, loadStatic, loadWithComponents, onlyOpCanSetNbt, parseCustomNameSafe, removeComponentsFromTag, saveCustomAndMetadata, saveCustomOnly, saveWithFullMetadata, saveWithId, saveWithoutMetadata, setBlockState, setChanged, setChanged, setComponents, triggerEvent

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface net.fabricmc.fabric.api.attachment.v1.AttachmentTarget

    getAttached, getAttachedOrCreate, getAttachedOrCreate, getAttachedOrElse, getAttachedOrGet, getAttachedOrSet, getAttachedOrThrow, hasAttached, modifyAttached, removeAttached, setAttached

    Methods inherited from interface net.fabricmc.fabric.api.blockview.v2.RenderDataBlockEntity

    getRenderData

    Methods inherited from interface com.codinglitch.simpleradio.central.Socket

    canConnect, canConnectTo, connect, disconnect, disconnect, distribute, getIdentifier, getReference, getWires, hasWire, hasWire, shortCircuit
  • Field Details

    • frequency

      public Frequency frequency
    • id

      public UUID id
    • receiver

      @Nullable public @Nullable Receiver receiver
    • transmitter

      @Nullable public @Nullable Transmitter transmitter
    • listener

      @Nullable public @Nullable Listener listener
    • speaker

      @Nullable public @Nullable Speaker speaker
    • active

      public boolean active
  • Constructor Details

    • AuditoryBlockEntity

      public AuditoryBlockEntity(net.minecraft.world.level.block.entity.BlockEntityType<?> blockEntityType, net.minecraft.core.BlockPos pos, net.minecraft.world.level.block.state.BlockState state)
  • Method Details

    • validate

      public void validate()
      Checks if this block should be deactivated due to an invalid router.

      Ideally, you should call this every tick.

    • activate

      public void activate()
      This is called whenever the block is initially activated (placed, on world load, chunk loaded, etc.) Use this to create and register the associated routers for this block.
    • deactivate

      public void deactivate()
      This is called whenever the block is deactivated (chunk unloaded, block broken, etc.) Use this to clean up the associated routers.

      This method will also set all invalid routers to null.

    • setLevel

      public void setLevel(net.minecraft.world.level.Level level)
      Overrides:
      setLevel in class net.minecraft.world.level.block.entity.BlockEntity
    • setRemoved

      public void setRemoved()
      Overrides:
      setRemoved in class net.minecraft.world.level.block.entity.BlockEntity
    • getRouter

      public Router getRouter()
      Description copied from interface: Socket
      Override this to expose a given router to wires.
      Allows blocks with more than one router to choose which of their routers wires will connect to.
      Specified by:
      getRouter in interface Socket
      Returns:
      The router to be exposed
    • getConnectionPosition

      public net.minecraft.world.phys.Vec3 getConnectionPosition()
    • tagFromComponents

      public static net.minecraft.nbt.CompoundTag tagFromComponents(net.minecraft.world.item.ItemStack stack, net.minecraft.nbt.CompoundTag tag)
    • saveToItem

      public void saveToItem(net.minecraft.world.item.ItemStack stack, net.minecraft.core.HolderLookup.Provider provider)
      Overrides:
      saveToItem in class net.minecraft.world.level.block.entity.BlockEntity
    • loadFromItem

      public void loadFromItem(net.minecraft.world.item.ItemStack stack)
    • loadTag

      public void loadTag(net.minecraft.nbt.CompoundTag tag)
    • saveTag

      public void saveTag(net.minecraft.nbt.CompoundTag tag)
    • saveAdditional

      protected void saveAdditional(net.minecraft.nbt.CompoundTag tag, net.minecraft.core.HolderLookup.Provider provider)
      Overrides:
      saveAdditional in class net.minecraft.world.level.block.entity.BlockEntity
    • getUpdateTag

      public net.minecraft.nbt.CompoundTag getUpdateTag(net.minecraft.core.HolderLookup.Provider provider)
      Overrides:
      getUpdateTag in class net.minecraft.world.level.block.entity.BlockEntity
    • getUpdatePacket

      @Nullable public @Nullable net.minecraft.network.protocol.Packet<net.minecraft.network.protocol.game.ClientGamePacketListener> getUpdatePacket()
      Overrides:
      getUpdatePacket in class net.minecraft.world.level.block.entity.BlockEntity