# RegistryHelper

`com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper`

**Since:** 1.8.4

Provides registry lookups and listings as JsMacros helpers. Identifier arguments may omit the
`minecraft:` namespace. Unknown item and block ids resolve to their registry defaults
(air); unknown status effect and enchantment ids fail rather than falling back.  
Obtain an instance with `Client.getRegistryManager()`.  
```js
// a block by name, the block state it defaults to, and the three
// ways of listing what is there
const reg = Client.getRegistryManager();  
const block = reg.getBlock("stone");  
Chat.log(`${block.getId()} is ${block.getName()}`);  
const state = reg.getBlockState("oak_stairs", "[facing=north]");  
Chat.log(`a stair facing north is solid: ${state.isSolid()}`);  
Chat.log(`${reg.getBlockIds().size()} blocks and ${reg.getItemIds().size()} items`);  
```

## Constructors

### new RegistryHelper {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_constructor-}

```js
new RegistryHelper()
```

## Methods

### getActivityTypeIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getActivityTypeIds-}

```js
getActivityTypeIds(): List<String>
```

Returns identifiers for built-in activities, which represent activities a villager can
perform. The list comes from the local built-in registry, independent of a server connection
and without server data-pack additions.

**Returns:** the built-in activity identifiers.

**Since:** 1.8.4

### getBlock {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getBlock-String-}

```js
getBlock(String id): BlockHelper
```

Looks up a block by id, with or without its namespace. An unknown id resolves to the block
registry's default, air, rather than reporting an error.  
```js
// Unknown ids resolve to air, so read back the id to verify the lookup.  
const reg = Client.getRegistryManager();  
const block = reg.getBlock("stone");  
Chat.log(`${block.getId()} is ${block.getName()}`);  
```

**Parameters:**
- `id`: the block's id

**Returns:** an [BlockHelper](../helper/world/BlockHelper.md) for the given block.

**Since:** 1.8.4

### getBlockEntityTypeIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getBlockEntityTypeIds-}

```js
getBlockEntityTypeIds(): List<String>
```

Returns identifiers for block entity types in the local built-in registry.

**Returns:** a list of all block entity type ids.

**Since:** 1.8.4

### getBlockIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getBlockIds-}

```js
getBlockIds(): List<String>
```

Returns all registered block ids in namespaced form, suitable for
[getBlock(String)](#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getBlock-String-).  
```js
// Filter the namespaced ids as needed.  
const reg = Client.getRegistryManager();  
const ids = reg.getBlockIds();  
Chat.log(`${ids.size()} blocks registered`);  
let ores = 0;  
for (const id of ids) {
  if (id.endsWith("_ore")) {
    ores = ores + 1;  
  }
}
Chat.log(`${ores} of them are ores`);  
```

**Returns:** a list of all registered block ids.

**Since:** 1.8.4

### getBlocks {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getBlocks-}

```js
getBlocks(): List<BlockHelper>
```

Returns every registered block as a helper.  
```js
// Access each registered block through its helper.  
const reg = Client.getRegistryManager();  
const blocks = reg.getBlocks();  
const first = blocks.get(0);  
Chat.log(`${blocks.size()} blocks, the first is ${first.getId()}`);  
```

**Returns:** a list of all registered blocks.

**Since:** 1.8.4

### getBlockState {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getBlockState-String-}

```js
getBlockState(String id): BlockStateHelper
```

Returns the block's default state; use [getBlockState(String, String)](#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getBlockState-String-String-) to select
properties. An unknown id resolves to the default block, air.  
```js
// Get the default state; supply properties to select a variant.  
const reg = Client.getRegistryManager();  
const state = reg.getBlockState("oak_stairs");  
Chat.log(`${state.getId()} facing ${state.getPistonBehaviour()} is solid: ${state.isSolid()}`);  
```

**Parameters:**
- `id`: the block's id

**Returns:** an [BlockStateHelper](../helper/world/BlockStateHelper.md) for the given block.

**Since:** 1.8.4

### getBlockState {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getBlockState-String-String-}

```js
getBlockState(String id, String nbt): BlockStateHelper
```

Parses block properties in the game's command syntax, appended directly after the block id
(for example, `[facing=north]`). Invalid syntax, block ids, properties, or values throw
CommandSyntaxException.  
```js
// Select a particular state using the game's block-property syntax.  
const reg = Client.getRegistryManager();  
const stairs = reg.getBlockState("oak_stairs", "[facing=north,half=top]");  
Chat.log(`${stairs.getId()} solid: ${stairs.isSolid()}`);  
```

**Parameters:**
- `id`: the block's id
- `nbt`: the block-state properties in command syntax, such as `[facing=north]`

**Returns:** the block state with the specified properties

**Since:** 1.8.4

### getEnchantment {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getEnchantment-String-}

```js
getEnchantment(String id): EnchantmentHelper
```

Looks up an enchantment in the connected server's registry. The returned helper has level
zero; use [getEnchantment(String, int)](#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getEnchantment-String-int-) to supply a level. Unknown ids fail rather
than falling back, and a server connection is required.  
```js
// Look up the enchantment without assigning it an item level.  
const reg = Client.getRegistryManager();  
const ench = reg.getEnchantment("minecraft:sharpness");  
Chat.log(`${ench.getId()} level ${ench.getLevel()} of ${ench.getMaxLevel()}`);  
```

**Parameters:**
- `id`: the enchantment's id

**Returns:** an [EnchantmentHelper](../helper/inventory/EnchantmentHelper.md) for the given enchantment.

**Since:** 1.8.4

### getEnchantment {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getEnchantment-String-int-}

```js
getEnchantment(String id, int level): EnchantmentHelper
```

Looks up an enchantment in the connected server's registry and associates the supplied level
with its helper. The level is not clamped to the enchantment's maximum. Unknown ids fail
rather than falling back, and a server connection is required.  
```js
// Associate a level with an enchantment from the server registry.  
const reg = Client.getRegistryManager();  
const ench = reg.getEnchantment("sharpness", 5);  
Chat.log(`${ench.getId()} ${ench.getLevel()} of ${ench.getMaxLevel()}`);  
```

**Parameters:**
- `id`: the enchantment's id
- `level`: the level of the enchantment

**Returns:** an [EnchantmentHelper](../helper/inventory/EnchantmentHelper.md) for the given enchantment with the specified level.

**Since:** 1.8.4

### getEnchantmentIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getEnchantmentIds-}

```js
getEnchantmentIds(): List<String>
```

Returns the ids in the connected server's enchantment registry. A connection is required;  
without one, dereferencing it fails rather than returning an empty list.

**Returns:** a list of all registered enchantment ids.

**Since:** 1.8.4

### getEnchantments {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getEnchantments-}

```js
getEnchantments(): List<EnchantmentHelper>
```

Returns helpers for the enchantments in the connected server's registry, each with its
default helper level. A connection is required; without one, dereferencing it fails.

**Returns:** a list of all registered enchantments.

**Since:** 1.8.4

### getEntity {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getEntity-String-}

```js
getEntity(String type): EntityHelper<?>
```

Creates an entity of the registry type named by `type`, using command spawn reason;  
the entity is not added to the world. A world must be loaded. Unknown ids resolve to the
built-in registry default (the pig). Types that cannot be created in the current world
produce no entity, which fails when wrapping the result.

**Parameters:**
- `type`: the id of the entity's type

**Returns:** an [EntityHelper](../helper/world/entity/EntityHelper.md) for the given entity.

**Since:** 1.8.4

### getEntityAttributeIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getEntityAttributeIds-}

```js
getEntityAttributeIds(): List<String>
```

Returns identifiers for built-in entity attributes, such as health and movement speed. The
list comes from the local built-in registry, independent of a server connection and without
server data-pack additions.

**Returns:** the built-in entity attribute identifiers.

**Since:** 1.8.4

### getEntityTypeIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getEntityTypeIds-}

```js
getEntityTypeIds(): List<String>
```

Returns ids from the built-in entity type registry, including types that are placeholders
and cannot be instantiated.

**Returns:** a list of all entity type ids.

**Since:** 1.8.4

### getFeatureIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getFeatureIds-}

```js
getFeatureIds(): List<String>
```

Returns ids from the built-in world-generation feature registry, independent of the
connected server's data packs.

**Returns:** a list of all feature ids.

**Since:** 1.8.4

### getFluidState {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getFluidState-String-}

```js
getFluidState(String id): FluidStateHelper
```

Returns the default state of the built-in fluid named by `id`, not a state sampled
from a world. Unknown ids resolve to the registry default (the empty fluid).

**Parameters:**
- `id`: the fluid's id

**Returns:** an [FluidStateHelper](../helper/world/FluidStateHelper.md) for the given fluid.

**Since:** 1.8.4

### getGameEventNames {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getGameEventNames-}

```js
getGameEventNames(): List<String>
```

Returns identifiers for game events in the local built-in registry.

**Returns:** a list of all game event names.

**Since:** 1.8.4

### getIdentifier {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getIdentifier-String-}

```js
getIdentifier(String identifier): Identifier
```

Parses an identifier string without looking it up in a registry. A missing namespace is
supplied as `minecraft`.

**Parameters:**
- `identifier`: an identifier string, with or without a namespace

**Returns:** the parsed identifier

**Since:** 1.8.4

### getItem {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getItem-String-}

```js
getItem(String id): ItemHelper
```

Looks up an item by id, which may omit the `minecraft:` namespace. Unknown ids
resolve to the item registry's default, air.

**Parameters:**
- `id`: the item's id

**Returns:** an [ItemHelper](../helper/inventory/ItemHelper.md) for the given item.

**Since:** 1.8.4

### getItemIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getItemIds-}

```js
getItemIds(): List<String>
```

Returns all item ids in namespaced form, suitable for [getItem(String)](#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getItem-String-).

**Returns:** a list of all registered item ids.

**Since:** 1.8.4

### getItems {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getItems-}

```js
getItems(): List<ItemHelper>
```

Returns a helper for each registered item.

**Returns:** a list of all registered items.

**Since:** 1.8.4

### getItemStack {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getItemStack-String-}

```js
getItemStack(String id): ItemStackHelper
```

Creates a one-item stack without components. Use [getItemStack(String, String)](#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getItemStack-String-String-) to
parse components. Unknown ids resolve to the item registry's default, air.

**Parameters:**
- `id`: the item's id

**Returns:** an [ItemStackHelper](../helper/inventory/ItemStackHelper.md) for the given item.

**Since:** 1.8.4

### getItemStack {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getItemStack-String-String-}

```js
getItemStack(String id, String nbt): ItemStackHelper
```

Parses item components using command item-argument syntax appended directly to the id
(for example, `[damage=12]`). The returned stack has count one. A connection is
required; invalid syntax throws CommandSyntaxException.

**Parameters:**
- `id`: the item's id
- `nbt`: component data in the game's item-argument syntax, including square brackets

**Returns:** an [ItemStackHelper](../helper/inventory/ItemStackHelper.md) for the item with the parsed components.

**Since:** 1.8.4

### getMemoryModuleTypeIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getMemoryModuleTypeIds-}

```js
getMemoryModuleTypeIds(): List<String>
```

Returns identifiers for memory module types in the local built-in registry.

**Returns:** a list of all memory module type ids.

**Since:** 1.8.4

### getNbtOps {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getNbtOps-}

```js
static getNbtOps(): RegistryOps<Tag>
```

Creates registry-aware NBT operations from the current connection's registry access. Use
these instead of `NbtOps.INSTANCE` to encode registry-backed data. Each call creates
new operations; without a connection this throws [IllegalStateException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html).

**Returns:** new registry-aware NBT operations for the current connection

### getPaintingIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getPaintingIds-}

```js
getPaintingIds(): List<String>
```

Returns ids from the connected server's painting variant registry. A connection is required;  
without one, dereferencing it fails rather than returning an empty list.

**Returns:** a list of all painting motive ids.

**Since:** 1.8.4

### getParticleTypeIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getParticleTypeIds-}

```js
getParticleTypeIds(): List<String>
```

Returns identifiers for particle types in the local built-in registry, not individual
particle instances or their parameters.

**Returns:** a list of all particle type ids.

**Since:** 1.8.4

### getPointOfInterestTypeIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getPointOfInterestTypeIds-}

```js
getPointOfInterestTypeIds(): List<String>
```

Returns identifiers for point of interest types in the local built-in registry.

**Returns:** a list of all point of interest type ids.

**Since:** 1.8.4

### getPotionTypeIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getPotionTypeIds-}

```js
getPotionTypeIds(): List<String>
```

Returns identifiers for built-in potion types (brews), not the effects they carry. The list
comes from the local built-in registry, independent of a server connection and without server
data-pack additions.

**Returns:** the built-in potion type identifiers.

**Since:** 1.8.4

### getRawEntityType {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getRawEntityType-String-}

```js
getRawEntityType(String type): EntityType<?>
```

Returns the built-in entity type for `type`; this does not create an entity and needs
no world. Unknown ids resolve to the registry default (the pig).

**Parameters:**
- `type`: the id of the entity's type

**Returns:** an [EntityType](https://mcsrc.dev/2/26.2/net/minecraft/world/entity/EntityType) for the given entity.

**Since:** 1.8.4

### getRecipeTypeIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getRecipeTypeIds-}

```js
getRecipeTypeIds(): List<String>
```

Returns identifiers for recipe types in the local built-in registry, not individual recipes.

**Returns:** a list of all recipe type ids.

**Since:** 1.8.4

### getScreenHandlerIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getScreenHandlerIds-}

```js
getScreenHandlerIds(): List<String>
```

Returns identifiers for screen handlers in the local built-in registry.

**Returns:** a list of all screen handler ids.

**Since:** 1.8.4

### getSensorTypeIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getSensorTypeIds-}

```js
getSensorTypeIds(): List<String>
```

Returns identifiers for the built-in sensor types; these represent senses a mob's brain uses
to notice things, not the things sensed. The list comes from the local built-in registry,  
independent of a server connection and without server data-pack additions.

**Returns:** the built-in sensor type identifiers.

**Since:** 1.8.4

### getStatTypeIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getStatTypeIds-}

```js
getStatTypeIds(): List<String>
```

Returns identifiers for built-in statistic types, not advancements. The list comes from the
local built-in registry, independent of a server connection and without server data-pack additions.

**Returns:** the built-in statistic type identifiers.

**Since:** 1.8.4

### getStatusEffect {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getStatusEffect-String-}

```js
getStatusEffect(String id): StatusEffectHelper
```

Looks up a status effect by id, with or without its namespace. An unknown id does not produce
a usable helper: constructing it with the missing effect fails.

**Parameters:**
- `id`: the status effect's id

**Returns:** a helper for the effect with 0 ticks duration

### getStatusEffectIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getStatusEffectIds-}

```js
getStatusEffectIds(): List<String>
```

Returns identifiers for status effects in the local built-in registry.

**Returns:** a list of all status effect ids.

**Since:** 1.8.4

### getStatusEffects {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getStatusEffects-}

```js
getStatusEffects(): List<StatusEffectHelper>
```

Returns each registered status effect as a helper without a duration.  
```js
// List all registered status effects.  
const reg = Client.getRegistryManager();  
const effects = reg.getStatusEffects();  
Chat.log(`${effects.size()} status effects`);  
const first = effects.get(0);  
Chat.log(`the first is ${first.getId()}`);  
```

**Returns:** a list of all registered status effects as [StatusEffectHelper](../helper/StatusEffectHelper.md)s with 0 ticks duration.

**Since:** 1.8.4

### getStructureFeatureIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getStructureFeatureIds-}

```js
getStructureFeatureIds(): List<String>
```

Returns ids from the built-in structure-piece registry, not ids for complete structures;  
connected-server data packs are not reflected.

**Returns:** a list of all structure feature ids.

**Since:** 1.8.4

### getVillagerProfessionIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getVillagerProfessionIds-}

```js
getVillagerProfessionIds(): List<String>
```

Returns identifiers for villager professions in the local built-in registry.

**Returns:** a list of all villager profession ids.

**Since:** 1.8.4

### getVillagerTypeIds {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getVillagerTypeIds-}

```js
getVillagerTypeIds(): List<String>
```

Returns identifiers for villager types in the local built-in registry.

**Returns:** a list of all villager type ids.

**Since:** 1.8.4

### getWrapperLookup {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getWrapperLookup-}

```js
static getWrapperLookup(): HolderLookup.Provider
```

Returns the current connection's registry lookup provider, the provider used to create
[getNbtOps()](#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_getNbtOps-). Without a connection this throws [IllegalStateException](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/IllegalStateException.html).

**Returns:** the current connection's registry lookup provider

### parseIdentifier {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_parseIdentifier-String-}

```js
static parseIdentifier(String id): Identifier
```

Parses an identifier string without checking whether it is registered. A missing namespace
is supplied as `minecraft`; invalid identifier syntax is rejected by Minecraft.

**Parameters:**
- `id`: an identifier string, with or without a namespace

**Returns:** the parsed identifier

**Since:** 1.8.4

### parseNameSpace {#com.jsmacrosce.jsmacros.client.api.classes.RegistryHelper_parseNameSpace-String-}

```js
static parseNameSpace(String id): String
```

Prepends `minecraft:` when the input contains no colon; otherwise returns it unchanged.

**Parameters:**
- `id`: the string to prefix when it contains no colon

**Returns:** the input prefixed with `minecraft:` if it contains no colon, or unchanged otherwise

**Since:** 1.8.4
