New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CraftingInventory is not a Grid #1710
Conversation
@Faithcaio Could you also fix the following issue in this PR, it's related to |
@Cybermaxke it seems they dont even have an impl yet. |
The biggest problem with Inventories in my opinion is that there is no Thinking about it: would it be possible/viable to add something like public Inventory Inventory.getInventory(int... position) {
Inventory target = this;
int n=0;
for (int index : position) {
if (index < 0 || index >= target.capacity())
throw IllegalArgumentException("Index "+n+" ("+index+)" was out of inventory bounds (max: "+target.capacity()+")");
if (target.capacity()<=1) //Slot or Empty
throw IllegalArgumentException("Position argument has more depth than this inventory");
// go to 'index' sub-inventory:
Iterator<Inventory> it = iterator(); for (int i=0; i<index; i++) target = it.next();
n++;
}
return target;
} For example in the MainPlayerInventory this would allow access to a slot in the GridInventory with |
@Mumfrey ^? Thats what query is for. You can also query for Anyways this would have to be another PR. |
Oh, didn't know query accepts a SlotIndex instance as there's now overlaod with SlotIndex and the javadocs for query(Object...) don't mention it either as far as I can see 🤔 |
SlotIndex etc. are InventoryProperties |
9bd523b
to
916139a
Compare
SpongeAPI | SpongeCommon | SpongeForge
A crafting inventory is not a grid but contains one.