Class RegistryBlock<T extends net.minecraft.world.level.block.Block>

java.lang.Object
net.xun.lib.common.api.registries.RegistryHolder<net.minecraft.world.level.block.Block,T>
net.xun.lib.common.api.registries.RegistryBlock<T>
Type Parameters:
T - The concrete block type (must extend Block)
All Implemented Interfaces:
Supplier<T>, net.minecraft.core.Holder<net.minecraft.world.level.block.Block>, net.minecraft.world.level.ItemLike, net.neoforged.neoforge.common.extensions.IHolderExtension<net.minecraft.world.level.block.Block>, net.neoforged.neoforge.registries.datamaps.IWithData<net.minecraft.world.level.block.Block>

public class RegistryBlock<T extends net.minecraft.world.level.block.Block> extends RegistryHolder<net.minecraft.world.level.block.Block,T> implements net.minecraft.world.level.ItemLike
A specialized registry holder implementation for blocks that implements ItemLike.

This class provides additional functionality specific to blocks, including conversion to item stacks and automatic handling of block-to-item relationships.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface net.minecraft.core.Holder

    net.minecraft.core.Holder.Direct<T>, net.minecraft.core.Holder.Kind, net.minecraft.core.Holder.Reference<T>
  • Field Summary

    Fields inherited from class net.xun.lib.common.api.registries.RegistryHolder

    key
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    RegistryBlock(net.minecraft.resources.ResourceKey<net.minecraft.world.level.block.Block> key, Supplier<T> supplier)
    Constructs a new block registry holder.
  • Method Summary

    Modifier and Type
    Method
    Description
    net.minecraft.world.item.Item
    Gets the corresponding item for this block.
    void
    bind(net.minecraft.core.Holder<net.minecraft.world.level.block.Block> holder)
    Binds this holder to a concrete registry holder.
    static <T extends net.minecraft.world.level.block.Block>
    RegistryBlock<T>
    createBlock(net.minecraft.resources.ResourceKey<net.minecraft.world.level.block.Block> key, Supplier<T> supplier)
    Creates a new block registry holder using a ResourceKey.
    static <T extends net.minecraft.world.level.block.Block>
    RegistryBlock<T>
    createBlock(net.minecraft.resources.ResourceLocation key, Supplier<T> supplier)
    Creates a new block registry holder using a ResourceLocation.
    net.minecraft.world.item.ItemStack
    Creates an ItemStack of this block with a count of 1.
    net.minecraft.world.item.ItemStack
    toStack(int count)
    Creates an ItemStack of this block with the specified count.

    Methods inherited from class net.xun.lib.common.api.registries.RegistryHolder

    canSerializeIn, create, equals, get, getSupplier, hashCode, holder, is, is, is, is, is, isBound, kind, tags, unwrap, unwrapKey, value

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface net.minecraft.core.Holder

    getRegisteredName

    Methods inherited from interface net.neoforged.neoforge.common.extensions.IHolderExtension

    getDelegate, getKey, unwrapLookup

    Methods inherited from interface net.neoforged.neoforge.registries.datamaps.IWithData

    getData
  • Constructor Details

    • RegistryBlock

      protected RegistryBlock(net.minecraft.resources.ResourceKey<net.minecraft.world.level.block.Block> key, Supplier<T> supplier)
      Constructs a new block registry holder.
      Parameters:
      key - The resource key identifying the block
      supplier - Supplier providing the block instance
  • Method Details

    • toStack

      public net.minecraft.world.item.ItemStack toStack()
      Creates an ItemStack of this block with a count of 1.
      Returns:
      The created item stack
      Throws:
      IllegalStateException - If the block doesn't have a corresponding item
    • toStack

      public net.minecraft.world.item.ItemStack toStack(int count)
      Creates an ItemStack of this block with the specified count.
      Parameters:
      count - The stack size
      Returns:
      The created item stack
      Throws:
      IllegalStateException - If the block doesn't have a corresponding item
    • createBlock

      public static <T extends net.minecraft.world.level.block.Block> RegistryBlock<T> createBlock(net.minecraft.resources.ResourceLocation key, Supplier<T> supplier)
      Creates a new block registry holder using a ResourceLocation.
      Type Parameters:
      T - The concrete block type
      Parameters:
      key - The resource location identifying the block
      supplier - Supplier providing the block instance
      Returns:
      The created registry holder
    • createBlock

      public static <T extends net.minecraft.world.level.block.Block> RegistryBlock<T> createBlock(net.minecraft.resources.ResourceKey<net.minecraft.world.level.block.Block> key, Supplier<T> supplier)
      Creates a new block registry holder using a ResourceKey.
      Type Parameters:
      T - The concrete block type
      Parameters:
      key - The resource key identifying the block
      supplier - Supplier providing the block instance
      Returns:
      The created registry holder
    • asItem

      public net.minecraft.world.item.Item asItem()
      Gets the corresponding item for this block.
      Specified by:
      asItem in interface net.minecraft.world.level.ItemLike
      Returns:
      The item representation of this block
    • bind

      public void bind(net.minecraft.core.Holder<net.minecraft.world.level.block.Block> holder)
      Binds this holder to a concrete registry holder.
      Overrides:
      bind in class RegistryHolder<net.minecraft.world.level.block.Block,T extends net.minecraft.world.level.block.Block>
      Parameters:
      holder - The concrete holder from the registry