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

add data renames (blocks & items) #836

Closed
wants to merge 5 commits into from

Conversation

zardoy
Copy link

@zardoy zardoy commented Jan 17, 2024

fixes #833

@rom1504
Copy link
Member

rom1504 commented Jan 17, 2024

how did you generate it ?

@zardoy
Copy link
Author

zardoy commented Jan 18, 2024

For most versions I specified it manually (or almost manually by looking at data fixer code) since there are not many renames. But for the 1.13 version I used this script:

//@ts-check
import fs from 'fs'
import minecraftData from 'minecraft-data'

const mcData = minecraftData('1.12.2')

const file = JSON.parse(fs.readFileSync('node_modules/minecraft-data/minecraft-data/data/pc/common/legacy.json', 'utf8'))

let map = []
for (const [key, item] of Object.entries(file.blocks)) {
    const item2 = mcData.blocks[key.split(':')[0]];
    if (!item2) continue
    const oldName = item2.name
    const newName = item.split(':')[1].split('[')[0];
    if (map.find(x => x[1] === newName && x[0] === oldName)) {
        continue
    }
    if (newName === oldName) {
        continue
    }
    map.push([oldName, newName])
}

fs.writeFileSync('map.json', JSON.stringify(map, null, 2))

@zardoy
Copy link
Author

zardoy commented Jan 18, 2024

Im not sure if thats possible to generate with the server. I tried to extract using text manipulation (by looking at createRenamer in DataFixers, but I couldn't get all renames in that way). However, does the current format / file look good?

@zardoy
Copy link
Author

zardoy commented Jan 18, 2024

Waiting for this pr, then add a function to use it to node wrapper

@rom1504
Copy link
Member

rom1504 commented Jan 18, 2024

I'm looking at the file and actually I don't understand what this is.

What is a new name ? What is an old name ?

@zardoy
Copy link
Author

zardoy commented Jan 18, 2024

What is a new name ? What is an old name ?

Also, the code above mentions the process of creating the map for 1.13: map.push([oldName, newName]). Why array? Because you might also want to go from a new name to an old name (like also mentioned in docs).

I will also open a pr in nmd so you can better understand how real code works with this format.

@zardoy zardoy changed the title add data renames add data renames (blocks & items) Jan 18, 2024
@rom1504
Copy link
Member

rom1504 commented Jan 21, 2024

PrismarineJS/node-minecraft-data#335 (comment) following of the conversation there.

TLDR: most of these "renames" are not renames but actually just some block being removed in old version and some block being added in new version.

A better solution may be to create "group of similar blocks" like grass, chest,... That you could handle in a similar way in downstream code

@rom1504 rom1504 added this to Needs triage in PR Triage Jan 21, 2024
@rom1504 rom1504 moved this from Needs triage to Waiting for user input in PR Triage Jan 21, 2024
@rom1504
Copy link
Member

rom1504 commented Feb 5, 2024

The renames in this PR still contain many renames between blocks that do not have the same semantic

@rom1504 rom1504 moved this from Waiting for user input to Almost too old in PR Triage Mar 17, 2024
@rom1504
Copy link
Member

rom1504 commented Jun 9, 2024

Re open if you want to finish it

@rom1504 rom1504 closed this Jun 9, 2024
PR Triage automation moved this from Almost too old to Closed Jun 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
PR Triage
  
Closed
Development

Successfully merging this pull request may close these issues.

Add blocks & items pc renames data
2 participants