Skip to content

Utilities

Crystal Spider edited this page Nov 15, 2026 · 2 revisions

In-game ID retrival

For both blocks and items, Cobweb provides a shorthand to retrieve their in-game IDs (e.g. Blocks.DIRT -> minecraft:dirt).

Blocks:

  • BlockUtils#getKey(Block)
    Returns the in-game ID of the given block as a Identifier.
  • BlockUtils#getStringKey(Block)
    Returns the in-game ID of the given block as a string.

Items:

  • ItemUtils#getKey(Item)
    Returns the in-game ID of the given item as a Identifier.
  • ItemUtils#getStringKey(Item)
    Returns the in-game ID of the given item as a string.

Platform queries

Use it.crystalnest.cobweb.api.platform.PlatformQueries from common code on Fabric and NeoForge. The Platform and Environment enums are in it.crystalnest.cobweb.platform.model.

Method Result
loader() The active loader as a Platform.
environment() Environment.DEVELOPMENT or Environment.PRODUCTION.
isDevelopment() Whether the active loader reports a development environment.
isModLoaded(modId) Whether the mod is loaded in this game instance.
loadedModIds() A sorted, unmodifiable list of the IDs reported by the local loader.
modVersion(modId) The loader's version string, or an empty optional if the mod is absent.

Mod queries are available once the loader makes its mod list available during initialization.