#How to detect double chests positions?
1 messages · Page 1 of 1 (latest)
- check if the block's id is double chest
- check for neighbor blocks
- check if the neighbor block is also double chest
- check the inventory of both block if they are the same
oh damn didnt know minecraft:double_chest was a thing
thanks
how do i check if the inventory of the 2 chests are the same? i tried using if chest.getComponent('inventory').container.getItem(i) == chest2.getComponent('inventory').container.getItem(i) inside of a for(i = 0; i < ....) {} but it got me confused
let i = 0
let stop = false
if (!stop) {
for(i = 0; i < chest.getComponent('inventory').container.size; i++) {
if (chest.getComponent('inventory').container.getItem(i) == chest2.getComponent('inventory').container.getItem(i)) {
if (i == chest.getComponent('inventory').container.size) {
//do something
}
}else{
stop = true
}
}
}```
also minecraft:double_chest aint a thing
oh, then just check for inventory size of the block
That’s what I did but like still if there are 2 big chests near each other it won’t work well
But it’s alright
yeah thats why you ready should compare the items inside first