Skip to content

Commit

Permalink
make npm package and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gptlang committed Jan 13, 2024
1 parent f6078e6 commit 85c5904
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 46 deletions.
54 changes: 14 additions & 40 deletions locator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const EventEmitter = require("node:events");
const { superComplexWasm } = require("./superComplexWasm.js");
import { EventEmitter } from "events";
import { superComplexWasm } from "./superComplexWasm.js";
globalThis.emitter = new EventEmitter();

var jsonStableStringify = (function () {
Expand Down Expand Up @@ -123,7 +123,7 @@ function c(a, b, c) {
}
return { biomes: i, scale: 1 };
}
CB3SharedTaskManager = {
let CB3SharedTaskManager = {
create: function (a) {
var b = {};
return (
Expand Down Expand Up @@ -174,7 +174,7 @@ let CB3Libs = superComplexWasm();
var g = null,
h = null,
i = null;
j = CB3SharedTaskManager.create(globalThis);
let j = CB3SharedTaskManager.create(globalThis);
function a(b, c) {
if ("object" == typeof b && null != b && "object" == typeof c && null != c) {
var d = [0, 0];
Expand Down Expand Up @@ -245,7 +245,7 @@ function getResults(a) {
});
}

function getSupportedPPois(platform) {
export function getSupportedPPois(platform) {
let c = CB3Libs.getSupportedPois(platform.cb3World);
return {
type: "getSupportedPois",
Expand Down Expand Up @@ -299,7 +299,7 @@ function findClosest(coords, features){
* @param {string[]} pois - The structures to search for
* @param {object} optionals - Optional parameters
*/
async function getAreaResult(seed, coords, pois, optionals) {
export async function getAreaResult(seed, coords, pois, optionals) {
let params = {
tileSize: 16,
searchWidth: 8,
Expand All @@ -312,7 +312,7 @@ async function getAreaResult(seed, coords, pois, optionals) {
if (optionals) {
params = {...params, ...optionals}
}
[x, z] = coords
let [x, z] = coords
// Make the x and z center of the search area by subtracting half the search width
// Make sure it's still an integer
x -= Math.round(params.searchWidth * params.tileSize / 2)
Expand Down Expand Up @@ -396,36 +396,10 @@ async function getAreaResult(seed, coords, pois, optionals) {
}
return allResults
}
getAreaResult("4684276156830303372", [0, 0], [
// "buriedTreasure",
// "dungeon",
// "netherFortress",
// "bastionRemnant",
// "endCity",
// "slimeChunk",
"stronghold",
"village",
// "mineshaft",
// "woodlandMansion",
// "pillagerOutpost",
// "oceanRuin",
// "oceanMonument",
// "shipwreck",
// "desertTemple",
// "jungleTemple",
"witchHut",
"igloo",
// "ruinedPortalOverworld",
// "ruinedPortalNether",
// "spawn",
// "fossil",
// "ravine",
// "endGateway",
// "amethystGeode",
// "ancientCity",
// "itemOverworld",
// "oreVein",
// "cave",
// "desertWell",
// "trailRuin",
]).then(console.log)
try {
module.exports = {
getAreaResult: getAreaResult,
getSupportedPPois: getSupportedPPois,
};
} catch (e) {
}
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "mc-seedlocator",
"version": "0.0.1",
"description": " Find structures and features using minecraft seeds (Works up to 1.20.4) ",
"main": "locator.js",
"scripts": {
"test": "node test_locator.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/gptlang/MC-SeedLocator.git"
},
"keywords": [
"minecraft",
"hacking",
"cheating"
],
"author": "gptlang",
"license": "ISC",
"bugs": {
"url": "https://github.com/gptlang/MC-SeedLocator/issues"
},
"homepage": "https://github.com/gptlang/MC-SeedLocator",
"type": "module"
}
9 changes: 3 additions & 6 deletions superComplexWasm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require("fs");
const wasmbin = fs.readFileSync("./chunky.wasm");
function superComplexWasm() {
import { readFileSync } from "fs";
const wasmbin = readFileSync("./chunky.wasm");
export function superComplexWasm() {
return (function () {
function a(d) {
var e = c[d];
Expand Down Expand Up @@ -15581,7 +15581,4 @@ function superComplexWasm() {
);
})();

}
module.exports = {
superComplexWasm: superComplexWasm,
}
35 changes: 35 additions & 0 deletions test_locator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { getAreaResult } from "./locator.js";

getAreaResult("4684276156830303372", [0, 0], [
// "buriedTreasure",
// "dungeon",
// "netherFortress",
// "bastionRemnant",
// "endCity",
// "slimeChunk",
"stronghold",
"village",
// "mineshaft",
// "woodlandMansion",
// "pillagerOutpost",
// "oceanRuin",
// "oceanMonument",
// "shipwreck",
// "desertTemple",
// "jungleTemple",
"witchHut",
"igloo",
// "ruinedPortalOverworld",
// "ruinedPortalNether",
// "spawn",
// "fossil",
// "ravine",
// "endGateway",
// "amethystGeode",
// "ancientCity",
// "itemOverworld",
// "oreVein",
// "cave",
// "desertWell",
// "trailRuin",
]).then(console.log)

0 comments on commit 85c5904

Please sign in to comment.