optimize JEI transfer handler so it doesnt lock up the client
This commit is contained in:
@@ -57,7 +57,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
|||||||
IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
IItemList<IAEItemStack> used = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||||
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
||||||
found = false;
|
found = false;
|
||||||
if (i.isInput() && i.getAllIngredients().size() > 0) {
|
if (i.isInput() && !i.getAllIngredients().isEmpty()) {
|
||||||
List<?> allIngredients = i.getAllIngredients();
|
List<?> allIngredients = i.getAllIngredients();
|
||||||
for (Object allIngredient : allIngredients) {
|
for (Object allIngredient : allIngredients) {
|
||||||
if (allIngredient instanceof ItemStack) {
|
if (allIngredient instanceof ItemStack) {
|
||||||
@@ -66,7 +66,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
|||||||
IAEItemStack search = AEItemStack.fromItemStack(stack);
|
IAEItemStack search = AEItemStack.fromItemStack(stack);
|
||||||
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
|
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
|
||||||
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
|
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
|
||||||
if (fuzzy.size() > 0) {
|
if (!fuzzy.isEmpty()) {
|
||||||
for (IAEItemStack itemStack : fuzzy) {
|
for (IAEItemStack itemStack : fuzzy) {
|
||||||
if (itemStack.getStackSize() > 0) {
|
if (itemStack.getStackSize() > 0) {
|
||||||
if (Platform.isGTDamageableItem(stack.getItem())) {
|
if (Platform.isGTDamageableItem(stack.getItem())) {
|
||||||
@@ -145,7 +145,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
|||||||
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
for (IGuiIngredient<?> i : recipeLayout.getItemStacks().getGuiIngredients().values()) {
|
||||||
found = false;
|
found = false;
|
||||||
craftable = false;
|
craftable = false;
|
||||||
ArrayList<ItemStack> valid = new ArrayList<>();
|
IItemList<IAEItemStack> valid = AEApi.instance().storage().getStorageChannel(IItemStorageChannel.class).createList();
|
||||||
if (i.isInput()) {
|
if (i.isInput()) {
|
||||||
List<?> allIngredients = i.getAllIngredients();
|
List<?> allIngredients = i.getAllIngredients();
|
||||||
for (Object allIngredient : allIngredients) {
|
for (Object allIngredient : allIngredients) {
|
||||||
@@ -155,7 +155,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
|||||||
IAEItemStack search = AEItemStack.fromItemStack(stack);
|
IAEItemStack search = AEItemStack.fromItemStack(stack);
|
||||||
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
|
if (stack.getItem().isDamageable() || Platform.isGTDamageableItem(stack.getItem())) {
|
||||||
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
|
Collection<IAEItemStack> fuzzy = available.findFuzzy(search, FuzzyMode.IGNORE_ALL);
|
||||||
if (fuzzy.size() > 0) {
|
if (!fuzzy.isEmpty()) {
|
||||||
for (IAEItemStack itemStack : fuzzy) {
|
for (IAEItemStack itemStack : fuzzy) {
|
||||||
if (itemStack.getStackSize() > 0) {
|
if (itemStack.getStackSize() > 0) {
|
||||||
if (Platform.isGTDamageableItem(stack.getItem())) {
|
if (Platform.isGTDamageableItem(stack.getItem())) {
|
||||||
@@ -165,7 +165,7 @@ public class JEIMissingItem implements IRecipeTransferError {
|
|||||||
}
|
}
|
||||||
found = true;
|
found = true;
|
||||||
used.add(itemStack.copy().setStackSize(1));
|
used.add(itemStack.copy().setStackSize(1));
|
||||||
valid.add(itemStack.copy().setStackSize(1).createItemStack());
|
valid.add(itemStack.copy().setStackSize(1));
|
||||||
} else {
|
} else {
|
||||||
if (itemStack.isCraftable()) {
|
if (itemStack.isCraftable()) {
|
||||||
craftable = true;
|
craftable = true;
|
||||||
@@ -180,12 +180,12 @@ public class JEIMissingItem implements IRecipeTransferError {
|
|||||||
if (ext.getStackSize() > 0 && (usedStack == null || usedStack.getStackSize() < ext.getStackSize())) {
|
if (ext.getStackSize() > 0 && (usedStack == null || usedStack.getStackSize() < ext.getStackSize())) {
|
||||||
used.add(ext.copy().setStackSize(1));
|
used.add(ext.copy().setStackSize(1));
|
||||||
if (craftable) {
|
if (craftable) {
|
||||||
valid.clear();
|
valid = null;
|
||||||
}
|
}
|
||||||
valid.add(ext.copy().setStackSize(1).createItemStack());
|
valid.add(ext.copy().setStackSize(1));
|
||||||
found = true;
|
found = true;
|
||||||
} else if (ext.isCraftable()) {
|
} else if (ext.isCraftable()) {
|
||||||
valid.add(ext.copy().setStackSize(1).createItemStack());
|
valid.add(ext.copy().setStackSize(1));
|
||||||
craftable = true;
|
craftable = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,21 +195,29 @@ public class JEIMissingItem implements IRecipeTransferError {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i.getAllIngredients().size() == 0) {
|
if (i.getAllIngredients().isEmpty()) {
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
|
ArrayList<ItemStack> validStacks = new ArrayList<>();
|
||||||
|
if (valid != null) {
|
||||||
|
valid.forEach(v -> {
|
||||||
|
ItemStack validStack = v.createItemStack();
|
||||||
|
validStack.setCount(1);
|
||||||
|
validStacks.add(validStack);
|
||||||
|
});
|
||||||
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
if (craftable) {
|
if (craftable) {
|
||||||
i.drawHighlight(minecraft, new Color(0.0f, 0.0f, 1.0f, 0.4f), recipeX, recipeY);
|
i.drawHighlight(minecraft, new Color(0.0f, 0.0f, 1.0f, 0.4f), recipeX, recipeY);
|
||||||
this.craftableSlots.add(currentSlot);
|
this.craftableSlots.add(currentSlot);
|
||||||
recipeLayout.getItemStacks().set(currentSlot, valid);
|
recipeLayout.getItemStacks().set(currentSlot, validStacks);
|
||||||
} else {
|
} else {
|
||||||
i.drawHighlight(minecraft, new Color(1.0f, 0.0f, 0.0f, 0.4f), recipeX, recipeY);
|
i.drawHighlight(minecraft, new Color(1.0f, 0.0f, 0.0f, 0.4f), recipeX, recipeY);
|
||||||
}
|
}
|
||||||
this.errored = true;
|
this.errored = true;
|
||||||
} else {
|
} else {
|
||||||
this.foundSlots.add(currentSlot);
|
this.foundSlots.add(currentSlot);
|
||||||
recipeLayout.getItemStacks().set(currentSlot, valid);
|
recipeLayout.getItemStacks().set(currentSlot, validStacks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentSlot++;
|
currentSlot++;
|
||||||
|
|||||||
Reference in New Issue
Block a user