Skip to content

Commit 83a74fc

Browse files
u9grom1504
andauthored
use nmd supportFeature (#60)
* use nmd supportFeature * Update index.js --------- Co-authored-by: Romain Beaumont <[email protected]>
1 parent e9955a0 commit 83a74fc

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

index.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,12 @@ const legacyPcBlocksByIdmeta = Object.entries(mcData.legacy.pc.blocks).reduce((o
2424
function loader (registryOrVersion) {
2525
const registry = typeof registryOrVersion === 'string' ? require('prismarine-registry')(registryOrVersion) : registryOrVersion
2626
const version = registry.version
27-
const features = {
28-
usesBlockStates: (version.type === 'pc' && version['>=']('1.13')) || (version.type === 'bedrock'),
29-
effectNamesMatchRegistryName: version['>=']('1.17')
30-
}
31-
32-
return provider(registry, { Biome: require('prismarine-biome')(registry), features, version })
27+
return provider(registry, { Biome: require('prismarine-biome')(version), version })
3328
}
3429

35-
function provider (registry, { Biome, version, features }) {
30+
function provider (registry, { Biome, version }) {
3631
const blockMethods = require('./blockEntity')(registry)
32+
const usesBlockStates = (version.type === 'pc' && registry.supportFeature('blockStateId')) || (version.type === 'bedrock')
3733
const shapes = registry.blockCollisionShapes
3834
if (shapes) {
3935
// Prepare block shapes
@@ -169,7 +165,7 @@ function provider (registry, { Biome, version, features }) {
169165

170166
this._properties = {}
171167
if (version.type === 'pc') {
172-
if (features.usesBlockStates) {
168+
if (usesBlockStates) {
173169
const blockEnum = registry.blocksByStateId[this.stateId]
174170
if (blockEnum && blockEnum.states) {
175171
let data = this.metadata
@@ -203,7 +199,7 @@ function provider (registry, { Biome, version, features }) {
203199

204200
static fromStateId (stateId, biomeId) {
205201
// 1.13+: metadata is completely removed and only block state IDs are used
206-
if (features.usesBlockStates) {
202+
if (usesBlockStates) {
207203
return new Block(undefined, biomeId, 0, stateId)
208204
} else {
209205
return new Block(stateId >> 4, biomeId, stateId & 15, stateId)

0 commit comments

Comments
 (0)