Skip to content

Commit 507b419

Browse files
committed
Fix inventory grid query
1 parent 958f22c commit 507b419

File tree

1 file changed

+6
-3
lines changed
  • src/main/java/org/spongepowered/common/inventory/query/type

1 file changed

+6
-3
lines changed

src/main/java/org/spongepowered/common/inventory/query/type/GridQuery.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,15 @@ public GridQuery(Vector2i offset, Vector2i size) {
4646
@Override
4747
public Inventory execute(Inventory inventory, InventoryAdapter adapter) {
4848

49-
if (!(adapter instanceof GridInventoryAdapter)) {
49+
final GridInventoryAdapter gridAdapter;
50+
if (adapter instanceof GridInventoryAdapter) {
51+
gridAdapter = (GridInventoryAdapter) adapter;
52+
} else if (adapter.inventoryAdapter$getRootLens() instanceof GridInventoryLens gridInventoryLens) {
53+
gridAdapter = (GridInventoryAdapter) gridInventoryLens.getAdapter(adapter.inventoryAdapter$getFabric(), inventory);
54+
} else {
5055
return new EmptyInventoryImpl(inventory);
5156
}
5257

53-
GridInventoryAdapter gridAdapter = (GridInventoryAdapter) adapter;
54-
5558
Vector2i max = gridAdapter.dimensions();
5659
if (max.x() < this.offset.x() + this.size.x() && max.y() < this.offset.y() + this.size.y()) {
5760
// queried grid does not fit inventory

0 commit comments

Comments
 (0)