fix: allow minecraft patch versions to have 2 digits
patch includes game drops now but whatever
This commit is contained in:
parent
a27f529276
commit
e7dd18bbc0
4 changed files with 30 additions and 31 deletions
|
|
@ -10,7 +10,7 @@ import { numberToVersion, versionToNumber } from "@/utils/version";
|
||||||
import { HistoryContext } from "@/context/History";
|
import { HistoryContext } from "@/context/History";
|
||||||
|
|
||||||
const versions = [
|
const versions = [
|
||||||
"1.21.9",
|
"1.21.10",
|
||||||
"1.21.4",
|
"1.21.4",
|
||||||
"1.21",
|
"1.21",
|
||||||
"1.20",
|
"1.20",
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ export const CanvasProvider = ({ children }: Props) => {
|
||||||
const [blocks, setBlocks] = useState<Block[]>(welcomeBlocksData);
|
const [blocks, setBlocks] = useState<Block[]>(welcomeBlocksData);
|
||||||
const [coords, setCoords] = useState<Position>({ x: 0, y: 0 });
|
const [coords, setCoords] = useState<Position>({ x: 0, y: 0 });
|
||||||
const [scale, setScale] = useState(1);
|
const [scale, setScale] = useState(1);
|
||||||
const [version, setVersion] = useState(1219);
|
const [version, setVersion] = useState(12110);
|
||||||
|
|
||||||
// Get the farthest away blocks in each direction
|
// Get the farthest away blocks in each direction
|
||||||
const canvasSize = useMemo(() => {
|
const canvasSize = useMemo(() => {
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,17 @@
|
||||||
{
|
{
|
||||||
"1219": 4440,
|
"12110": 4440,
|
||||||
"1214": 4189,
|
"12104": 4189,
|
||||||
"1210": 3953,
|
"12100": 3953,
|
||||||
"1200": 3463,
|
"12000": 3463,
|
||||||
"1190": 3105,
|
"11900": 3105,
|
||||||
"1180": 2860,
|
"11800": 2860,
|
||||||
"1170": 2724,
|
"11700": 2724,
|
||||||
"1160": 2566,
|
"11600": 2566,
|
||||||
"1150": 2225,
|
"11500": 2225,
|
||||||
"1140": 1952,
|
"11400": 1952,
|
||||||
"1130": 1519,
|
"11300": 1519,
|
||||||
"1120": 1139,
|
"11200": 1139,
|
||||||
"1110": 819,
|
"11100": 819,
|
||||||
"1000": 510,
|
"10000": 510,
|
||||||
"1090": 169
|
"10900": 169
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,17 @@
|
||||||
export function versionToNumber(version: string) {
|
// For Minecraft versions
|
||||||
const parts = version.split(".").map(Number);
|
// 12110 = 1.21.10
|
||||||
return parts[0] * 1000 + (parts[1] || 0) * 10 + (parts[2] || 0);
|
// 12109 = 1.21.9
|
||||||
|
|
||||||
|
export function versionToNumber(version: string): number {
|
||||||
|
const [major, minor = 0, patch = 0] = version.split(".").map(Number);
|
||||||
|
return major * 10000 + minor * 100 + patch;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function numberToVersion(version: number) {
|
export function numberToVersion(version: number): string {
|
||||||
const major = Math.floor(version / 1000);
|
const major = Math.floor(version / 10000);
|
||||||
const minor = version % 1000; // Remainder becomes the minor and patch version
|
const minor = Math.floor((version % 10000) / 100);
|
||||||
|
const patch = version % 100;
|
||||||
|
|
||||||
// If minor is a multiple of 10, it's just minor with no patch
|
if (patch === 0) return `${major}.${minor}`;
|
||||||
if (minor % 10 === 0) {
|
return `${major}.${minor}.${patch}`;
|
||||||
return `${major}.${Math.floor(minor / 10)}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Otherwise, split into minor and patch
|
|
||||||
const patch = minor % 10;
|
|
||||||
return `${major}.${Math.floor(minor / 10)}.${patch}`;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue