Skip to content

Commit

Permalink
Update index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
extremeheat authored Aug 29, 2024
1 parent d5f0efe commit 7d6b681
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ function loader (registryOrVersion) {
this.nbt = nbt || null

// pc 1.20.5, TODO: properly implement...
this.components = []
this.removedComponents = []
if (registry.supportFeature('itemsWithComponents')) {
this.components = []
this.removedComponents = []
}

// Probably add a new feature to mcdata, e.g itemsCanHaveStackId
if (registry.type === 'bedrock') {
Expand Down Expand Up @@ -81,7 +83,7 @@ function loader (registryOrVersion) {
const hasNBT = item && item.nbt && Object.keys(item.nbt.value).length > 0

if (registry.type === 'pc') {
if (registry.version['>=']('1.20.5')) {
if (registry.supportFeature('itemsWithComponents')) {
if (!item) return { itemCount: 0 }
return {
itemCount: item.count,
Expand Down Expand Up @@ -144,7 +146,7 @@ function loader (registryOrVersion) {

static fromNotch (networkItem, stackId) {
if (registry.type === 'pc') {
if (registry.version['>=']('1.20.5')) {
if (registry.supportFeature('itemsWithComponents')) {
if (networkItem.itemCount === 0) return null
const item = new Item(networkItem.itemId, networkItem.itemCount, null, null, true)
item.components = networkItem.components
Expand Down

0 comments on commit 7d6b681

Please sign in to comment.