Skip to content

Commit d7224a3

Browse files
authored
mcData to registry refactoring (step towards #2450) (#50)
* mcData to registry refactoring * Update package.json
1 parent 776ea90 commit d7224a3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
const Vec3 = require('vec3').Vec3
22
const EventEmitter = require('events').EventEmitter
33

4-
module.exports = (version) => {
5-
const ChatMessage = require('prismarine-chat')(version)
6-
const Item = require('prismarine-item')(version)
7-
const mcData = require('minecraft-data')(version)
4+
module.exports = (registryOrVersion) => {
5+
const registry = typeof registryOrVersion === 'string' ? require('prismarine-registry')(registryOrVersion) : registryOrVersion
6+
const ChatMessage = require('prismarine-chat')(registry)
7+
const Item = require('prismarine-item')(registry)
88
class Entity extends EventEmitter {
99
constructor (id) {
1010
super()
@@ -41,7 +41,7 @@ module.exports = (version) => {
4141
if (this.name !== 'item' && this.name !== 'Item' && this.name !== 'item_stack') {
4242
return null // not a dropped item
4343
}
44-
return Item.fromNotch(this.metadata[mcData.supportFeature('metadataIxOfItem')])
44+
return Item.fromNotch(this.metadata[registry.supportFeature('metadataIxOfItem')])
4545
}
4646
}
4747

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"minecraft-data": "^3.0.0",
1717
"prismarine-chat": "^1.4.1",
1818
"prismarine-item": "^1.11.2",
19+
"prismarine-registry": "^1.4.0",
1920
"vec3": "^0.1.4"
2021
},
2122
"keywords": [

0 commit comments

Comments
 (0)