Fix language entries for crafting monitor being too item-specific.

This commit is contained in:
raoulvdberge
2018-07-22 19:36:36 +02:00
parent 4d320d40ae
commit 13af18daab
12 changed files with 33 additions and 56 deletions

View File

@@ -42,6 +42,11 @@ public interface ICraftingTask {
*/
int getQuantity();
/**
* @return the amount that this task gives back
*/
int getQuantityPerCraft();
/**
* @return the stack requested
*/

View File

@@ -225,7 +225,7 @@ public class CraftingManager implements ICraftingManager {
for (ICraftingTask task : getTasks()) {
if (task.getRequested().getItem() != null) {
if (API.instance().getComparer().isEqualNoQuantity(task.getRequested().getItem(), stack)) {
amount -= task.getQuantity();
amount -= task.getQuantity() * task.getQuantityPerCraft();
}
}
}

View File

@@ -132,7 +132,7 @@ public class CraftingTask implements ICraftingTask {
this.calculationStarted = System.currentTimeMillis();
int qty = this.quantity;
int qtyPerCraft = getQuantityPerCraft(pattern, requested);
int qtyPerCraft = getQuantityPerCraft();
int crafted = 0;
IStackList<ItemStack> results = API.instance().createItemStackList();
@@ -424,7 +424,8 @@ public class CraftingTask implements ICraftingTask {
}
}
private int getQuantityPerCraft(ICraftingPattern pattern, ICraftingRequestInfo requested) {
@Override
public int getQuantityPerCraft() {
int qty = 0;
if (requested.getItem() != null) {
@@ -522,13 +523,12 @@ public class CraftingTask implements ICraftingTask {
return size;
}
// TODO: Fix lang keys.
@Override
public List<ICraftingMonitorElement> getCraftingMonitorElements() {
ICraftingMonitorElementList elements = API.instance().createCraftingMonitorElementList();
if (!missing.isEmpty() || !missingFluids.isEmpty()) {
elements.directAdd(new CraftingMonitorElementText("gui.refinedstorage:crafting_monitor.items_missing", 5));
elements.directAdd(new CraftingMonitorElementText("gui.refinedstorage:crafting_monitor.missing", 5));
}
if (!missing.isEmpty()) {
@@ -588,9 +588,8 @@ public class CraftingTask implements ICraftingTask {
elements.commit();
}
// TODO: Make better?
if (steps.stream().anyMatch(s -> s instanceof CraftingStepProcess && !s.isCompleted())) {
elements.directAdd(new CraftingMonitorElementText("gui.refinedstorage:crafting_monitor.items_processing", 5));
elements.directAdd(new CraftingMonitorElementText("gui.refinedstorage:crafting_monitor.processing", 5));
for (CraftingStep step : steps) {
if (step instanceof CraftingStepProcess && !step.isCompleted()) {
@@ -603,19 +602,7 @@ public class CraftingTask implements ICraftingTask {
continue;
}
ICraftingMonitorElement element = new CraftingMonitorElementItemRender(stack.getItem(), stack.getItem().getCount(), 0);
if (stack.getStatus() == CraftingExtractorStatus.MISSING) {
element = new CraftingMonitorElementColor(element, "gui.refinedstorage:crafting_monitor.waiting_for_items", CraftingMonitorElementColor.COLOR_INFO);
} else if (stack.getStatus() == CraftingExtractorStatus.MACHINE_DOES_NOT_ACCEPT) {
element = new CraftingMonitorElementColor(element, "gui.refinedstorage:crafting_monitor.machine_does_not_accept", CraftingMonitorElementColor.COLOR_ERROR);
} else if (stack.getStatus() == CraftingExtractorStatus.MACHINE_NONE) {
element = new CraftingMonitorElementColor(element, "gui.refinedstorage:crafting_monitor.machine_none", CraftingMonitorElementColor.COLOR_ERROR);
} else if (stack.getStatus() == CraftingExtractorStatus.EXTRACTED) {
element = new CraftingMonitorElementColor(element, "gui.refinedstorage:crafting_monitor.item_inserted_into_machine", CraftingMonitorElementColor.COLOR_SUCCESS);
}
elements.add(element);
elements.add(wrapAccordingToStatus(new CraftingMonitorElementItemRender(stack.getItem(), stack.getItem().getCount(), 0), stack));
}
}
}
@@ -629,25 +616,11 @@ public class CraftingTask implements ICraftingTask {
for (int i = 0; i < extractor.getStacks().size(); ++i) {
CraftingExtractorStack stack = extractor.getStacks().get(i);
ICraftingMonitorElement element;
if (stack.getItem() != null) {
continue;
}
element = new CraftingMonitorElementFluidRender(stack.getFluid(), stack.getFluid().amount, 0);
if (stack.getStatus() == CraftingExtractorStatus.MISSING) {
element = new CraftingMonitorElementColor(element, "gui.refinedstorage:crafting_monitor.waiting_for_items", CraftingMonitorElementColor.COLOR_INFO);
} else if (stack.getStatus() == CraftingExtractorStatus.MACHINE_DOES_NOT_ACCEPT) {
element = new CraftingMonitorElementColor(element, "gui.refinedstorage:crafting_monitor.machine_does_not_accept", CraftingMonitorElementColor.COLOR_ERROR);
} else if (stack.getStatus() == CraftingExtractorStatus.MACHINE_NONE) {
element = new CraftingMonitorElementColor(element, "gui.refinedstorage:crafting_monitor.machine_none", CraftingMonitorElementColor.COLOR_ERROR);
} else if (stack.getStatus() == CraftingExtractorStatus.EXTRACTED) {
element = new CraftingMonitorElementColor(element, "gui.refinedstorage:crafting_monitor.item_inserted_into_machine", CraftingMonitorElementColor.COLOR_SUCCESS);
}
elements.add(element);
elements.add(wrapAccordingToStatus(new CraftingMonitorElementFluidRender(stack.getFluid(), stack.getFluid().amount, 0), stack));
}
}
}
@@ -658,6 +631,20 @@ public class CraftingTask implements ICraftingTask {
return elements.getElements();
}
private ICraftingMonitorElement wrapAccordingToStatus(ICraftingMonitorElement element, CraftingExtractorStack stack) {
if (stack.getStatus() == CraftingExtractorStatus.MISSING) {
element = new CraftingMonitorElementColor(element, stack.getFluid() != null ? "gui.refinedstorage:crafting_monitor.waiting_for_fluids" : "gui.refinedstorage:crafting_monitor.waiting_for_items", CraftingMonitorElementColor.COLOR_INFO);
} else if (stack.getStatus() == CraftingExtractorStatus.MACHINE_DOES_NOT_ACCEPT) {
element = new CraftingMonitorElementColor(element, stack.getFluid() != null ? "gui.refinedstorage:crafting_monitor.machine_does_not_accept_fluid" : "gui.refinedstorage:crafting_monitor.machine_does_not_accept_item", CraftingMonitorElementColor.COLOR_ERROR);
} else if (stack.getStatus() == CraftingExtractorStatus.MACHINE_NONE) {
element = new CraftingMonitorElementColor(element, "gui.refinedstorage:crafting_monitor.machine_none", CraftingMonitorElementColor.COLOR_ERROR);
} else if (stack.getStatus() == CraftingExtractorStatus.EXTRACTED) {
element = new CraftingMonitorElementColor(element, "gui.refinedstorage:crafting_monitor.inserted_into_machine", CraftingMonitorElementColor.COLOR_SUCCESS);
}
return element;
}
@Override
public List<ICraftingPreviewElement> getPreviewStacks() {
Map<Integer, CraftingPreviewElementItemStack> map = new LinkedHashMap<>();