Skip to content

Commit

Permalink
Search now looks in Tile Entities; fix undefined item ID
Browse files Browse the repository at this point in the history
  • Loading branch information
Z0rb14n committed May 30, 2024
1 parent 0b00dcf commit 176dc90
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
16 changes: 12 additions & 4 deletions resources/js/WorldLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,15 +731,19 @@ function readTileEntity(reader) {
let itemBitmask = reader.readUint8();
let dyeBitmask = reader.readUint8();
for (let i = 0; i < 8; i++) {
tileEntity.items[i] = {};
tileEntity.items[i] = {
id: 0
};
if (((itemBitmask >> i) & 1) === 1) {
tileEntity.items[i].id = reader.readInt16();
tileEntity.items[i].prefixId = reader.readUint8();
tileEntity.items[i].count = reader.readInt16();
}
}
for (let j = 0; j < 8; j++) {
tileEntity.dyes[j] = {};
tileEntity.dyes[j] = {
id: 0
};
if (((dyeBitmask >> j) & 1) === 1) {
tileEntity.dyes[j].id = reader.readInt16();
tileEntity.dyes[j].prefixId = reader.readUint8();
Expand All @@ -752,15 +756,19 @@ function readTileEntity(reader) {
tileEntity.dyes = Array(2);
let bitmask = reader.readUint8();
for (let i = 0; i < 2; i++) {
tileEntity.items[i] = {};
tileEntity.items[i] = {
id: 0
};
if (((bitmask >> i) & 1) === 1) {
tileEntity.items[i].id = reader.readInt16();
tileEntity.items[i].prefixId = reader.readUint8();
tileEntity.items[i].count = reader.readInt16();
}
}
for (let j = 0; j < 2; j++) {
tileEntity.dyes[j] = {};
tileEntity.dyes[j] = {
id: 0
};
if (((bitmask >> (j+2)) & 1) === 1) {
tileEntity.dyes[j].id = reader.readInt16();
tileEntity.dyes[j].prefixId = reader.readUint8();
Expand Down
25 changes: 25 additions & 0 deletions resources/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,31 @@ function isTileMatch(tile, selectedInfos, x, y) {
}
}
}

// check if the tile entity contains it
let tileEntity = tile.tileEntity;
if (tileEntity && info.isItem) {
switch (tileEntity.type) {
case 1: // item frame
case 4: // weapon rack
case 6: // plate
if (info.Id == tileEntity.item.id) {
return true;
}
break;
case 3: // (wo)mannequin
case 5: // hat rack
for (let i = 0; i < tileEntity.items.length; i++) {
if (info.Id == tileEntity.items[i].id) {
return true;
}
if (info.Id == tileEntity.dyes[i].id) {
return true;
}
}
break;
}
}
}

return false;
Expand Down

0 comments on commit 176dc90

Please sign in to comment.