Pulcedocs

Resource validation

The host's enabled resource stack is authoritative.

On this page

Overview

The host's enabled resource stack is authoritative. A plugin declares logical aliases with .Icon(...), .Texture(...) and .Geometry(...); the host validates those requirements before publication. Ordinary items and blocks need no manual ZIP parsing, filesystem checks, pack UUID checks or access to Engine().Config().ResourcePacks.

Administrators enable packs

# resource_packs/resource_packs.yml
force_resources: true
resource_stack:
  - example-pack.zip

Stack order is preserved, highest priority first. The loader supports .zip and .mcpack; config entries are filenames within the resource directory. Absolute paths and traversal are not valid stack configuration. A ZIP being present in the directory does not enable it.

Filenames, manifest names and UUIDs are not part of the semantic plugin contract. When a ZIP is renamed, the administrator updates stack configuration; plugin declarations stay the same. Another enabled pack can satisfy the same asset requirements. Specific provider identity is not guaranteed.

There is no required PackID, RequirePack, pack_bindings or Descriptor.Resources: these typed APIs do not currently exist. Descriptor.Dependencies describes module dependencies, not ZIP dependencies. Existing ctx.ResourcePacks() is a transport/owned artifact capability, not the asset lookup API. Registering a transport artifact does not automatically include it in the authoritative enabled stack.

Read-only capability

References in declarations normally suffice. To check assets explicitly during Load, use:

assets, err := module.Resources(ctx)
if err != nil {
    return err
}
if err := assets.ResolveItemTexture(resources.ItemTexture("token")); err != nil {
    return err
}
if err := assets.ResolveBlockTexture(resources.BlockTexture("example_stone")); err != nil {
    return err
}
return assets.ResolveGeometry(resources.Geometry("geometry.example_stone"))

These methods return only error: validated checks, not filesystem handles, URLs, bytes or metadata structs. The last line demonstrates an independent custom geometry reference, not required by the full-block example. Normalization assigns the builtin full-block default and skips ResolveGeometry for it; no ZIP model is required.

Validation scope

The loader validates the archive, manifest and pack identity. The catalog snapshot validates atlas/model JSON, duplicate JSON keys, atlas shapes, geometry identifiers, asset paths and provenance. Item and terrain atlas aliases have separate namespaces. References support strings, variant arrays and supported texture objects with path/textures. Empty variants, unsupported shapes and extensions fail; the current image validator supports PNG, not arbitrary image formats.

Referenced images must exist, fully decode and fit dimension/size bounds. A path without an extension resolves to .png. Validation checks traversal, absolute/noncanonical paths, duplicate archive files and malformed catalog JSON. It does not require decoding every unused image; this is not a complete resource-pack editor or linter. A structurally malformed catalog is not accepted merely because the needed alias appeared before the error.

The snapshot retains detached archive bytes and provenance. Editing a ZIP after catalog construction does not change validation results in that snapshot. Where transport hash/size are available, the catalog verifies artifact identity. Replacing an RP requires a new startup/snapshot, not runtime mutation.

Multiple packs and collisions

An atlas alias can reference a physical asset from another enabled pack. Resolution considers the effective stack asset, not only the ZIP declaring the alias. If a higher-priority pack replaces the physical texture/model path with different bytes or a different definition, the host must not validate a different asset from the one the client receives.

Referenced aliases with different candidates fail as ambiguous; there is no silent first/last-writer-wins policy. Equivalent candidates are allowed when their normalized definitions and asset closures match. Geometry comparison includes its definition and format version; JSON formatting and equivalent numeric notation alone do not make geometry different. Conflicting duplicate geometry within a ZIP is rejected; proven equivalent geometry declarations are allowed and retain provenance.

Unreferenced cross-pack overrides do not become plugin dependencies. Explicit provider selection, pack-qualified references and an override policy are not implemented. Two plugins cannot be promised different textures under the same global client alias.

Normalization errors include the module/content ID/reference and underlying cause, such as a missing alias or effective asset conflict. Do not parse diagnostic text programmatically: use errors.Is(err, content.ErrMissingResource) for semantic classification. See validation.

Legacy-only consumers do not automatically receive all typed guarantees: bootstrap preserves the compatibility path and reports failed catalog construction to resource consumers. Do not promise fatal validation of every unused asset on every legacy server.

Sources: stack.go, catalog.go, resources.go.

Documentation source

Snapshot from Pulce 4fc8a1bb. This page is generated from committed Markdown; code examples are preserved unchanged.