mirror of
https://github.com/trafficlunar/blockmatic.git
synced 2026-06-28 06:34:13 +00:00
fix: update data to 1.21.4
This commit is contained in:
parent
a5bea3b585
commit
e4719200d3
19 changed files with 3281 additions and 300 deletions
|
|
@ -1,8 +1,5 @@
|
|||
import _blockData from "@/data/blocks/programmer-art/data.json";
|
||||
const blockData: BlockData = _blockData;
|
||||
|
||||
export const findBlockFromRgb = (r: number, g: number, b: number, a: number): string => {
|
||||
return Object.entries(blockData).reduce(
|
||||
export const findBlockFromRgb = (data: BlockData, r: number, g: number, b: number, a: number): string => {
|
||||
return Object.entries(data).reduce(
|
||||
(closestBlock, [block, data]) => {
|
||||
const distance = Math.sqrt(
|
||||
Math.pow(r - data.color[0], 2) + Math.pow(g - data.color[1], 2) + Math.pow(b - data.color[2], 2) + Math.pow(a - data.color[3], 2)
|
||||
|
|
|
|||
14
src/utils/getBlockData.ts
Normal file
14
src/utils/getBlockData.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import _blockData from "@/data/blocks/data.json";
|
||||
const blockData: BlockData = _blockData;
|
||||
|
||||
export function getBlockData(version: number) {
|
||||
const filteredData: BlockData = {};
|
||||
|
||||
for (const key in blockData) {
|
||||
if (blockData[key].version <= version) {
|
||||
filteredData[key] = blockData[key];
|
||||
}
|
||||
}
|
||||
|
||||
return filteredData;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue