Skip to content

Commit

Permalink
finally got rid of debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
GenerelSchwerz committed Aug 19, 2024
1 parent 1a13037 commit a1dd14e
Show file tree
Hide file tree
Showing 25 changed files with 999 additions and 977 deletions.
4 changes: 2 additions & 2 deletions examples/basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ const bot = createBot({
auth: "offline",
// host: 'it-mil-1.halex.gg',
// port: 25046
version: '1.19.4',
version: '1.18.2',

// host: "node2.endelon-hosting.de", port: 5000
host: 'Ic3TankD2HO.aternos.me',
host: '36569.spain2.firecloudllc.info',
// port: 44656
// host: "us1.node.minecraft.sneakyhub.com",
// port: 25607,
Expand Down
28 changes: 28 additions & 0 deletions examples/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const ts = require("typescript");

const program = ts.createProgram(['examples/test.js'], {
target: ts.ScriptTarget.ESNext,
module: ts.ModuleKind.CommonJS,
noEmit: true // Avoid emitting any output files
});

function processScript(data) {
// Create the source file from the provided script data
const sourceFile = ts.createSourceFile('', data, ts.ScriptTarget.ESNext, true);

// Check for syntax errors
console.log(sourceFile.parseDiagnostics);
if (sourceFile.parseDiagnostics.length > 0) throw new Error('Syntax error(s) found');

// Check for semantic errors
// const semanticDiagnostics = program.getSemanticDiagnostics(sourceFile);
// console.log(semanticDiagnostics);
// if (semanticDiagnostics.length > 0) throw new Error('Semantic error(s) found');

// Check for declaration errors
const declarationDiagnostics = program.getDeclarationDiagnostics(sourceFile);
console.log(declarationDiagnostics);
if (declarationDiagnostics.length > 0) throw new Error('Declaration error(s) found');
}

processScript(`const a = 1`);
22 changes: 22 additions & 0 deletions examples/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import ts, { ScriptTarget, SourceFile, Program } from "typescript"

type ParseDiagnostics = ts.DiagnosticWithLocation & { code: number }

const program = ts.createProgram(['examples/test.ts'], {

}

)
function processScript (data: string) {
const sourceFile = ts.createSourceFile('', data, ScriptTarget.ESNext, true) as SourceFile & { parseDiagnostics: ParseDiagnostics[] }
console.log(sourceFile.parseDiagnostics)
if (sourceFile.parseDiagnostics.length > 0) throw new Error('Sytax error(s) found')
const semanticDiagnostics = program.getSemanticDiagnostics(sourceFile)
console.log(semanticDiagnostics)
if (semanticDiagnostics.length > 0) throw new Error('Semantic error(s) found')
const declarationDiagnostics = program.getDeclarationDiagnostics(sourceFile)
console.log(declarationDiagnostics)
if (declarationDiagnostics.length > 0) throw new Error('Declaration error(s) found')
}

processScript(`const a = 1`)
40 changes: 1 addition & 39 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,77 +1,39 @@
{

"name": "@nxg-org/mineflayer-pathfinder",

"version": "0.0.21",

"description": "Pathfinder using A* for mineflayer",

"main": "dist/index.js",

"repository": "https://github.com/Minecraft-Pathfinding/minecraft-pathfinding.git",

"author": "GenerelSchwerz <xXSG.KingXx@gmail.com>",

"license": "MIT",

"publishConfig": {

"access": "public"

},

"scripts": {
"postinstall": "npm run build",

"prepublishOnly": "npm run lint && npm run build",

"build": "tsc -p ./tsconfig.json",

"pub": "npm run lint && npm run build && npm publish --access public",

"lint": "ts-standard -y --fix"

},

"dependencies": {

"@nxg-org/mineflayer-physics-util": "1.5.8",

"@nxg-org/mineflayer-util-plugin": "^1.8.3",

"lru-cache": "^10.1.0"

},

"devDependencies": {

"@nxg-org/mineflayer-pathfinder": "file:./",

"@nxg-org/mineflayer-pathfinder": "file:.",
"cors": "^2.8.5",

"express": "^4.18.2",

"mineflayer": "^4.10.1",

"prismarine-viewer": "^1.28.0",

"ts-standard": "^12.0.2",

"typescript": "^5.3.3",

"vec3": "^0.1.8"

},

"ts-standard": {

"ignore": [

"examples"

]

}

}

6 changes: 3 additions & 3 deletions src/PathfinderHandling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export class PathfinderHandler {
}

async interrupt (timeout = 1000, cancelCalculation = true, reasonStr?: ResetReason): Promise<void> {
console.log('INTERRUPT CALLED')
// console.log('INTERRUPT CALLED')
if (this._currentProducer == null) return console.log('no producer')
this.abortCalculation = cancelCalculation

Expand Down Expand Up @@ -486,7 +486,7 @@ export class PathfinderHandler {
if (result.status === 'success') {
cleanup()
this.bot.emit('pathGenerated', result)
console.log('locality %', (MovementHandler.count / MovementHandler.totCount) * 100)
// console.log('locality %', (MovementHandler.count / MovementHandler.totCount) * 100)
MovementHandler.count = 0
MovementHandler.totCount = 0
yield { result, astarContext }
Expand Down Expand Up @@ -570,7 +570,7 @@ export class PathfinderHandler {
await this.cleanupBot()
this.world.cleanup?.()

console.log('CLEANUP CALLED')
// console.log('CLEANUP CALLED')

if (this.userAborted) this.bot.emit('goalAborted', goal)
else this.bot.emit('goalFinished', goal)
Expand Down
Loading

0 comments on commit a1dd14e

Please sign in to comment.