Skip to main content
Version: 26.2.x

Injected Interfaces

Architectury adds methods directly to several vanilla Minecraft types. Each added method uses the arch$ prefix and is called on an instance of the type; no registration or import is required.

Identifier id = MyMod.RUBY.get().arch$registryName();

These methods are available on Item, Block, Fluid, EntityType, Item.Properties, BucketItem, and LiquidBlock.

Registry name and holder​

Item, Block, Fluid, and EntityType each provide two accessors:

MethodReturnsDescription
arch$registryName()IdentifierThe entry's namespace:path identifier, or null if it is not registered.
arch$holder()Holder<T>The registry holder for the entry.

arch$registryName() resolves an entry's identifier without querying a specific registry:

Identifier blockId = level.getBlockState(pos).getBlock().arch$registryName();
Identifier itemId = stack.getItem().arch$registryName();
Identifier fluidId = fluidStack.getFluid().arch$registryName();

if (itemId != null && itemId.getNamespace().equals(MyMod.MOD_ID)) {
// entry belongs to this mod
}

arch$holder() returns the Holder<T> for an entry, for example when reconstructing a value from a stored identifier:

Holder<Fluid> holder = BuiltInRegistries.FLUID.getValue(savedId).arch$holder();

Creative tab on Item.Properties​

Item.Properties provides arch$tab(...), which assigns the item to a creative mode tab during construction. Three overloads are available:

OverloadAccepts
arch$tab(CreativeModeTab)A tab instance.
arch$tab(ResourceKey<CreativeModeTab>)A tab registry key, including vanilla tabs.
arch$tab(DeferredSupplier<CreativeModeTab>)A RegistrySupplier obtained from a DeferredRegister.

RegistrySupplier implements DeferredSupplier, so a registered tab can be passed directly:

public static final RegistrySupplier<Item> RUBY = ITEMS.register("ruby", () -> {
ResourceKey<Item> key = ResourceKey.create(Registries.ITEM,
Identifier.fromNamespaceAndPath(MyMod.MOD_ID, "ruby"));
return new Item(new Item.Properties().arch$tab(MyMod.MY_TAB).setId(key));
});
note

See Creative Tabs for adding items to tabs you do not own and for creating the tab itself, and DeferredRegister for the required setId.

Fluid accessors​

BucketItem and LiquidBlock expose the fluid they represent, resolved identically on both loaders:

TypeMethodReturns
BucketItemarch$getFluid()Fluid - the fluid the bucket contains.
LiquidBlockarch$getFluid()FlowingFluid - the fluid the block represents.
if (stack.getItem() instanceof BucketItem bucket) {
Fluid fluid = bucket.arch$getFluid();
}

This applies to vanilla buckets and to custom fluid buckets.

Reference​

MethodAvailable onReturns
arch$registryName()Item, Block, Fluid, EntityTypeIdentifier (nullable)
arch$holder()Item, Block, Fluid, EntityTypeHolder<T>
arch$tab(...)Item.PropertiesItem.Properties
arch$getFluid()BucketItem, LiquidBlockFluid / FlowingFluid