mirror of
https://github.com/trafficlunar/blockmatic.git
synced 2026-06-28 14:44:12 +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
|
|
@ -5,6 +5,7 @@ import * as PIXI from "pixi.js";
|
|||
import { useApp } from "@pixi/react";
|
||||
import { CompositeTilemap, settings } from "@pixi/tilemap";
|
||||
|
||||
import { getBlockData } from "@/utils/getBlockData";
|
||||
import { findBlockFromRgb } from "@/utils/findBlockFromRgb";
|
||||
|
||||
interface Props {
|
||||
|
|
@ -17,16 +18,19 @@ interface Props {
|
|||
imageDimensions: Dimension;
|
||||
coords: Position;
|
||||
scale: number;
|
||||
version: number;
|
||||
setLoading: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
}
|
||||
|
||||
// Lifts 16,000 tiles limit
|
||||
settings.use32bitIndex = true;
|
||||
|
||||
function Blocks({ blocks, setBlocks, missingTexture, textures, solidTextures, image, imageDimensions, coords, scale, setLoading }: Props) {
|
||||
function Blocks({ blocks, setBlocks, missingTexture, textures, solidTextures, image, imageDimensions, coords, scale, version, setLoading }: Props) {
|
||||
const app = useApp();
|
||||
const tilemapRef = useRef<CompositeTilemap>();
|
||||
|
||||
const blockData = getBlockData(version);
|
||||
|
||||
const tileBlocks = () => {
|
||||
if (!tilemapRef.current) return;
|
||||
const tilemap = tilemapRef.current;
|
||||
|
|
@ -80,7 +84,7 @@ function Blocks({ blocks, setBlocks, missingTexture, textures, solidTextures, im
|
|||
const newBlocks: Block[] = [];
|
||||
|
||||
for (let i = 0; i < imageData.data.length; i += 4) {
|
||||
const block = findBlockFromRgb(imageData.data[i], imageData.data[i + 1], imageData.data[i + 2], imageData.data[i + 3]);
|
||||
const block = findBlockFromRgb(blockData, imageData.data[i], imageData.data[i + 1], imageData.data[i + 2], imageData.data[i + 3]);
|
||||
|
||||
const x = Math.floor((i / 4) % imageData.width);
|
||||
const y = Math.floor(i / 4 / imageData.width);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import welcomeBlocksData from "@/data/welcome.json";
|
|||
PIXI.settings.SCALE_MODE = PIXI.SCALE_MODES.NEAREST;
|
||||
|
||||
function Canvas() {
|
||||
const { stageSize, canvasSize, blocks, coords, scale, setStageSize, setBlocks, setCoords, setScale } = useContext(CanvasContext);
|
||||
const { stageSize, canvasSize, blocks, coords, scale, version, setStageSize, setBlocks, setCoords, setScale } = useContext(CanvasContext);
|
||||
const { image, imageDimensions } = useContext(ImageContext);
|
||||
const { setLoading } = useContext(LoadingContext);
|
||||
const { settings } = useContext(SettingsContext);
|
||||
|
|
@ -301,6 +301,7 @@ function Canvas() {
|
|||
imageDimensions={imageDimensions}
|
||||
coords={coords}
|
||||
scale={scale}
|
||||
version={version}
|
||||
setLoading={setLoading}
|
||||
/>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { CanvasContext } from "@/context/Canvas";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
|
||||
import _blockData from "@/data/blocks/programmer-art/data.json";
|
||||
import _blockData from "@/data/blocks/data.json";
|
||||
const blockData: BlockData = _blockData;
|
||||
|
||||
interface Props {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue