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

WorldInfo modification #5

Open
ci010 opened this issue Sep 7, 2017 · 3 comments
Open

WorldInfo modification #5

ci010 opened this issue Sep 7, 2017 · 3 comments

Comments

@ci010
Copy link
Collaborator

ci010 commented Sep 7, 2017

Currently, we only support WorldInfo reading.

Though, we want the basic level of modification on the WorldInfo. (We already have a strong NBT support, which makes this much easier)

This is the current WorldInfo class. I only picked some important (I think) properties.
Feel free to support more properties you believe is fine to view/modify.

The readonly property don't need to write to nbt (of course).
The public property will be write into nbt.

export class WorldInfo {
    constructor(
        // readonly filename: string,
        public displayName: string,
        readonly sizeOnDisk: Long,
        readonly lastPlayed: Long,
        readonly gameRule: GameRule,
        readonly dataVersion: number,
        readonly version: { snapshot?: number, id: number, name: string },
        readonly generatorName: string,

        public difficulty: number,
        public gameType: GameType,
        public isHardCore: boolean,
        public enabledCheat: boolean,
        public spawnPoint: Pos3,

        public borderCenter: Pos2,
        public borderDamagePerBlock: number,
        public borderWarningBlocks: number,
        public BorderSizeLerpTarget: number
    ) { }
}

说了那么多其实就是让玩家能有直接改动世界设置的能力2333level.dat里也存了玩家的数据,如果以后有精力甚至可以改玩家状态和背包数据等……但无论如何这玩意写起来比较枯燥

@LasmGratel
Copy link
Contributor

Maybe u need a object <-> NBT convention utility.

@lukechu10
Copy link
Contributor

constructor(
// readonly filename: string,
public displayName: string,

Sorry if this is a stupid question: why is filename commented? Thanks

@ci010
Copy link
Collaborator Author

ci010 commented Nov 25, 2019

constructor(
// readonly filename: string,
public displayName: string,

Sorry if this is a stupid question: why is filename commented? Thanks

Ah, this is really an old post. At that time, I decided to stick with the Minecraft original spec, which means the lib should not wrap another layer of interface to those Minecraft data.

Therefore, current Save/World reading is follow the original NBT structure and naming -- no capital character transformed.

Back to question, at that time I somehow decide to refactor the module, and the fileName is not in the level.dat. Therefore, I comment it out.

For the current status, you can refer the packages/world/index.ts. It's now load by WorldReader#getLevelData, and you will get directly a NBT data frame, no extra naming transform. The mc wiki will help a lot in dev.

I kind of plan to make the WorldReader be able to read region data (chunk) in these two months, for both old chunk format (version < 1.13) and new chunk format (version >= 1.13). The testing data is kind of ready... I'm not sure when I'll finish this.

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

No branches or pull requests

4 participants