Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fromJson is not defined #116

Closed
codingMASTER398 opened this issue Apr 24, 2021 · 5 comments
Closed

fromJson is not defined #116

codingMASTER398 opened this issue Apr 24, 2021 · 5 comments

Comments

@codingMASTER398
Copy link

(node:15636) UnhandledPromiseRejectionWarning: TypeError: j.fromJson is not a function

Documentation:
"Chunk.fromJson(j)
Load chunk from json"

My code:

async function go() {
    var Anvil = require('prismarine-provider-anvil').Anvil('1.16')
    var v = require('vec3');
    const Chunk = require('prismarine-chunk')('1.8')
    var anv = new Anvil('/home/USER/.minecraft/saves/ack/region')
    console.log(anv)
    ack = await anv.getRegion(0, 0)
    console.log(ack)
    j = new Chunk()
    j.fromJson(ack)
    j.getBlock(v(0, 0, 0))
    
}
go()

Output:

(node:15636) UnhandledPromiseRejectionWarning: TypeError: j.fromJson is not a function
    at go (/home/lachie/Documents/mcworld/index.js:10:7)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:15636) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:15636) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

What is wrong here???

@rom1504
Copy link
Member

rom1504 commented Apr 24, 2021

Please check provider anvil doc.
Json is not involved here

@Karang
Copy link
Contributor

Karang commented Apr 24, 2021

How did you come up with this code ? Is this randomly generated ?

and the fromJson() function is a static function of Chunk, not an instance method

@codingMASTER398
Copy link
Author

I just want to access my world from node.js, so i came up with this code.
@Karang, thank you! I will try to use fromJson from Chunk

@rom1504
Copy link
Member

rom1504 commented Apr 25, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants