Interface ISemiBlock

All Superinterfaces:
net.minecraftforge.common.capabilities.ICapabilityProvider
All Known Implementing Classes:
AbstractLogisticsFrameEntity, AbstractSemiblockEntity, CropSupportEntity, HeatFrameEntity, LogisticsActiveProviderEntity, LogisticsDefaultStorageEntity, LogisticsPassiveProviderEntity, LogisticsRequesterEntity, LogisticsStorageEntity, SpawnerAgitatorEntity, TransferGadgetEntity

public interface ISemiBlock extends net.minecraftforge.common.capabilities.ICapabilityProvider
Represents a "semiblock" - an attachable gadget which sits on a real block, such as a logistics frame or crop support.
Implementation Note:
While semiblocks are implemented as entities, this is an implementation detail which should not be relied upon any more than strictly necessary.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    addTooltip(Consumer<net.minecraft.network.chat.Component> consumer, net.minecraft.world.entity.player.Player player, net.minecraft.nbt.CompoundTag tag, boolean extended)
    Add tooltip information for this semiblock.
    static ISemiBlock
    byTrackingId(net.minecraft.world.level.Level world, int id)
    Retrieve a semiblock by tracking ID.
    boolean
    canCoexist(ISemiBlock otherSemiblock)
    Check if this semiblock can coexist with the other semiblock, in the same block pos.
    boolean
    canPlace(net.minecraft.core.Direction facing)
    Check if this semiblock can be placed here.
    net.minecraft.core.BlockPos
    Get the block position this entity occupies.
    net.minecraft.world.level.block.entity.BlockEntity
    Get the block entity at the semiblock's position.
    default int
    A color in ARGB format.
    net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack>
    Add any dropped items from this semiblock to the given list.
    net.minecraft.network.chat.Component
    Get the displayed name for this semiblock.
    net.minecraft.resources.ResourceLocation
    Get a unique ID for this semiblock, which should match the corresponding item's registry name.
    int
    Get the tracking for this semiblock; this should only be used for network sync purposes, and is subject to change on a world reload.
    net.minecraft.world.level.Level
    Get the world this semiblock is in.
    boolean
    Check if this semiblock is still valid, i.e.
    void
    killedByEntity(net.minecraft.world.entity.Entity entity)
    Called when an entity has caused this semiblock to be removed; usually, but necessarily, a player wrenching or hitting it.
    default void
    onPlaced(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction facing)
    Called immediately after the semiblock entity has been added to the world.
    default boolean
    onRightClickWithConfigurator(net.minecraft.world.entity.player.Player player, net.minecraft.core.Direction side)
    Called when a semiblock is right-clicked with a Logistics Configurator
    void
    readFromBuf(net.minecraft.network.FriendlyByteBuf payload)
    Read this semiblock from network buffer for network sync purposes.
    net.minecraft.nbt.CompoundTag
    serializeNBT(net.minecraft.nbt.CompoundTag tag)
    Written to the dropped item (under the "EntityTag" subtag) when the semiblock is broken, to persisted entity data by Entity#writeAdditional(), and displayed by info mods such as TOP or Waila.
    void
    Implement tick logic here.
    void
    writeToBuf(net.minecraft.network.FriendlyByteBuf payload)
    Write this semiblock to network buffer for network sync purposes.

    Methods inherited from interface net.minecraftforge.common.capabilities.ICapabilityProvider

    getCapability, getCapability
  • Method Details

    • getSemiblockId

      net.minecraft.resources.ResourceLocation getSemiblockId()
      Get a unique ID for this semiblock, which should match the corresponding item's registry name.
      Returns:
      a semiblock ID
    • getSemiblockDisplayName

      net.minecraft.network.chat.Component getSemiblockDisplayName()
      Get the displayed name for this semiblock.
      Returns:
      the name
    • getWorld

      net.minecraft.world.level.Level getWorld()
      Get the world this semiblock is in.
      Returns:
      the world
    • getBlockPos

      net.minecraft.core.BlockPos getBlockPos()
      Get the block position this entity occupies.
      Returns:
      the block pos
    • getCachedTileEntity

      net.minecraft.world.level.block.entity.BlockEntity getCachedTileEntity()
      Get the block entity at the semiblock's position. This is cached for performance.
      Returns:
      the block entity, or null if there is none
    • serializeNBT

      net.minecraft.nbt.CompoundTag serializeNBT(net.minecraft.nbt.CompoundTag tag)
      Written to the dropped item (under the "EntityTag" subtag) when the semiblock is broken, to persisted entity data by Entity#writeAdditional(), and displayed by info mods such as TOP or Waila. Use this method rather than writeAdditional() for fields that either need to be serialized to the dropped item, or displayed on TOP/Waila.

      Parameters:
      tag - NBT tag to write data to
      Implementation Note:
      Data written to itemstacks is automatically applied to newly-spawned entities by EntityType.updateCustomEntityTag(Level, Player, Entity, CompoundTag) when the semiblock entity is spawned from an item (i.e. placed by a player).
    • tick

      void tick()
      Implement tick logic here. Always be sure to call super.tick() in subclass overrides!
    • isValid

      boolean isValid()
      Check if this semiblock is still valid, i.e. the underlying entity is still alive.
      Returns:
      true if this semiblock is valid, false otherwise
    • getDrops

      net.minecraft.core.NonNullList<net.minecraft.world.item.ItemStack> getDrops()
      Add any dropped items from this semiblock to the given list. By default, just the semiblock item itself is added, but this can be overridden to drop extra items if needed.
    • canPlace

      boolean canPlace(net.minecraft.core.Direction facing)
      Check if this semiblock can be placed here.
      Parameters:
      facing - the side of the block against which it is placed
      Returns:
      true if the semiblock is placeable here, false otherwise
    • onPlaced

      default void onPlaced(net.minecraft.world.entity.player.Player player, net.minecraft.world.item.ItemStack stack, net.minecraft.core.Direction facing)
      Called immediately after the semiblock entity has been added to the world.
      Parameters:
      player - player who is placing the semiblock
      stack - itemstack used to create the entity
      facing - the side of the block which was clicked to place the entity
    • onRightClickWithConfigurator

      default boolean onRightClickWithConfigurator(net.minecraft.world.entity.player.Player player, net.minecraft.core.Direction side)
      Called when a semiblock is right-clicked with a Logistics Configurator
      Parameters:
      player - the player
      side - the side of the block being clicked
      Returns:
      true if something was done, false if the semiblock doesn't care about being clicked
    • canCoexist

      boolean canCoexist(ISemiBlock otherSemiblock)
      Check if this semiblock can coexist with the other semiblock, in the same block pos. By default this is true if at least one of the semiblocks is a IDirectionalSemiblock and both semiblocks have a different side.
      Parameters:
      otherSemiblock - the other semiblock
      Returns:
      true if they can coexist, false otherwise
    • getTrackingId

      int getTrackingId()
      Get the tracking for this semiblock; this should only be used for network sync purposes, and is subject to change on a world reload.
      Returns:
      the underlying entity's ID, or -1 if the entity has not been added to the world
      See Also:
    • killedByEntity

      void killedByEntity(net.minecraft.world.entity.Entity entity)
      Called when an entity has caused this semiblock to be removed; usually, but necessarily, a player wrenching or hitting it.
      Parameters:
      entity - the killer entity
    • addTooltip

      default void addTooltip(Consumer<net.minecraft.network.chat.Component> consumer, net.minecraft.world.entity.player.Player player, net.minecraft.nbt.CompoundTag tag, boolean extended)
      Add tooltip information for this semiblock. This info is used by info mods such as Waila or TOP.
      Parameters:
      consumer - the component consumer
      player - the player looking at the entity or item
      tag - NBT data as saved by serializeNBT(CompoundTag)
      extended - true if extended data should be shown
    • writeToBuf

      void writeToBuf(net.minecraft.network.FriendlyByteBuf payload)
      Write this semiblock to network buffer for network sync purposes.
      Parameters:
      payload - the buffer
    • readFromBuf

      void readFromBuf(net.minecraft.network.FriendlyByteBuf payload)
      Read this semiblock from network buffer for network sync purposes.
      Parameters:
      payload - the buffer
    • getColor

      default int getColor()
      A color in ARGB format. Used for various things: GUI/item/render tinting, as well as TOP colour coding.
      Returns:
      a color for this semiblock type
    • byTrackingId

      static ISemiBlock byTrackingId(net.minecraft.world.level.Level world, int id)
      Retrieve a semiblock by tracking ID. This is only intended to be used for network sync purposes and is subject to change on a world reload.
      Parameters:
      world - the world
      id - the tracking ID
      Returns:
      a semiblock, or null if ID is not valid
      See Also: