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

@aresrpg/aresrpg-map-colors

v3.1.0

Published

Aresrpg map item colors utility

Downloads

42

Readme

aresrpg-map-colors

I'm a performances focused tool to help you manage minecraft map colors. I provide utilities to bridge between any colors to minecraft compatible colors

since 1.1.4 i also provide a transform stream under aresrpg-map-colors/minecraftTransform that take images as input and output only updated frames to avoid sending the whole image each time the feature is not documented yet so refer to test/index.js


Installation

npm i @aresrpg/aresrpg-map-colors

Minecraft colors


Usage

import { nearestMatch, color, hex, fromImage, COLORS } from '@aresrpg/aresrpg-map-colors'

Convert an image into an array of minecraft compatible ids

void (async function() {
	const { width, height, datas } = await fromImage('https://i.imgur.com/28NLJWg.png')
	console.log(datas.length) // imageWidth * imageHeight
	console.log(datas) // [id,id,...] // uInt8
})()

use it with @Prismarine/node-minecraft-protocol

Note that you will need to handle image sizes and multiples neighbors map (via item frames) by your own, we only provide conversions

import { fromImage } from '@aresrpg/aresrpg-map-colors'
import mc from 'minecraft-protocol'

void (async function() {
	const size = 128
	const { datas } = await fromImage('https://i.imgur.com/h8g7SEf.jpg')
	this.client.write('map', {
		itemDamage: 0,
		scale: 4,
		trackingPosition: false,
		icons: [],
		columns: -size,
		rows: -size,
		x: 0,
		y: 0,
		data: Buffer.from(data),
	})
})()

In case you want to build an item frame wall with multiple blocks you'll need to handle the buffer to split every 128 values, see Map item format

Find the closest color available in minecraft from any color

Arguments and return value are memoized for performances

We use a weighted aproach of the color space, read more on Here

const colorId = nearestMatch(70, 120, 35)

Find a color by id

same as doing COLORS[id-4]

const { r, g, b } = color(4)

You can also get the decimal/hexadecimal value

const color = hex(4).toString(16)