mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 11:36:43 +01:00
Fixed recipes not working when there are multiples of the same stack
This commit is contained in:
parent
5dd390140d
commit
cc162f22ac
1 changed files with 9 additions and 7 deletions
|
@ -33,8 +33,6 @@ public class SpellRecipe extends Impl<IRecipe> implements IRecipe {
|
||||||
|
|
||||||
Item item = o.has("item") ? Item.getByNameOrId(o.get("item").getAsString()) : null;
|
Item item = o.has("item") ? Item.getByNameOrId(o.get("item").getAsString()) : null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
int metadata = Math.max(0, o.has("data") ? o.get("data").getAsInt() : 0);
|
int metadata = Math.max(0, o.has("data") ? o.get("data").getAsInt() : 0);
|
||||||
int size = Math.max(1, o.has("count") ? o.get("count").getAsInt() : 1);
|
int size = Math.max(1, o.has("count") ? o.get("count").getAsInt() : 1);
|
||||||
|
@ -78,11 +76,7 @@ public class SpellRecipe extends Impl<IRecipe> implements IRecipe {
|
||||||
ItemStack stack = inv.getStackInSlot(i);
|
ItemStack stack = inv.getStackInSlot(i);
|
||||||
|
|
||||||
if (!stack.isEmpty()) {
|
if (!stack.isEmpty()) {
|
||||||
if (toMatch.isEmpty() && !stack.isEmpty()) {
|
if (toMatch.isEmpty() || !removeMatch(toMatch, stack, materialMult)) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!toMatch.isEmpty() && !toMatch.removeIf(s -> s.matches(stack, materialMult))) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,6 +84,14 @@ public class SpellRecipe extends Impl<IRecipe> implements IRecipe {
|
||||||
return toMatch.isEmpty();
|
return toMatch.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean removeMatch(ArrayList<RecipeItem> toMatch, ItemStack stack, int materialMult) {
|
||||||
|
return toMatch.stream()
|
||||||
|
.filter(s -> s.matches(stack, materialMult))
|
||||||
|
.findFirst()
|
||||||
|
.filter(toMatch::remove)
|
||||||
|
.isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getCraftingResult(InventoryCrafting inv) {
|
public ItemStack getCraftingResult(InventoryCrafting inv) {
|
||||||
return getRecipeOutput();
|
return getRecipeOutput();
|
||||||
|
|
Loading…
Reference in a new issue