npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

voxel-registry

v0.8.3

Published

A shared registry for managing item and block IDs (voxel.js plugin)

Downloads

31

Readme

voxel-registry

A shared registry for managing item and block IDs (voxel.js plugin)

Build Status

Usage

Load with voxel-plugins, then get the registry instance:

var registry = game.plugins.get('voxel-registry');

To register a new block:

registry.registerBlock(name, props);

name should be a fixed textual identifier, props an object with information about the block. The block will be allocated a numerical index value automatically, which can be used in the voxel.js chunk data arrays. (The initial motivation for voxel-registry was to avoid hardcoded numerical IDs, allowing blocks to be referred to across plugins by name, instead.) You can translate between IDs and names using this module (see the source for details).

Property names can be anything, but the following conventions are known:

  • texture: textures for rendering voxels
  • hardness: required time (seconds) to mine the block with no tool, used by voxel-mine
  • effectiveTool: tool class name which gives a speedup when mining, used by voxel-mine
  • itemDrop: name of item to drop when block is harvested, used by voxel-harvest

Items are registered similarly:

registry.registerItem(name, props);
  • itemTexture: texture for rendering in an inventory-window
  • maxDamage: maximum damage before a tool breaks, used by voxel-harvest, inventory-window
  • toolClass: general category of the tool, matches effectiveTool, used by voxel-mine
  • speed: mining speedup multiplier when toolClass matches effectiveTool, used by voxel-mine
  • displayName: human-readable name for GUI displays, returned by getItemDisplayName(name)

Blocks are implicitly considered items.

Dynamic properties

If a property value is set to a function, then registry.getProp(itemName, propName[, arg]) will execute the function and return the result. If arg is given it will be passed to the function.

Item textures

getItemPileTexture(itemPile) gets the texture URL(s) for an itempile for display in GUIs. If the texture is a 3D cube, this will be an array for each face, otherwise a string. Texture URLs are resolved through game.materials.artPacks, assumed to be an instance of artpacks.

If itemTexture or texture is a dynamic property, then it will be called with the item pile's tags as an argument.

Metablocks and states

Sometimes it is desirable to associate a small amount of extra data with a block (examples: on/off, orientation, age, height, growth, subtype, color, etc.). The registerBlocks() method can be used for this purpose:

registry.registerBlocks(name, count, props);

where count is the number of "states" needed. Dynamic property functions will be called with each corresponding metadata value (for example, count=16 corresponds to 0 to 15) as the argument. For examples of this API in action, see the voxel-pumpkin and voxel-wool plugins.

Internally, count blocks are registered with identical props, and the index offset is used as the metadata/state, so count should be a small integer, as it is limited by and shared with the available block index space (e.g. 2^16 if voxel-engine arrayType is Uint16Array). However, unlike Minecraft, it is not restricted to 4-bits (16) and can be sized precisely as needed.

If larger amounts of data are needed, arbitrary objects can be stored at a block location using voxel-blockdata instead.

License

MIT