Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,27 @@ private boolean condenseStack(final User user, final ItemStack stack, final bool
amount += contents.getAmount();
}
}

final int output = (amount / input.getAmount()) * result.getAmount();

final int crafts = amount / input.getAmount();
final int output = crafts * result.getAmount();

amount -= amount % input.getAmount();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

if (amount > 0) {
input.setAmount(amount);
result.setAmount(output);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra spaces here (I'm not objecting to the linebreak, but the spaces on the line).

final Trade remove = new Trade(input, ess);
final Trade add = new Trade(result, ess);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra spaces here (I'm not objecting to the linebreak, but the spaces on the line).

remove.charge(user);
add.pay(user, OverflowType.DROP);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra spaces here (I'm not objecting to the linebreak, but the spaces on the line).

for (final ItemStack remainingItem : condenseType.getRemainingItems()) {
remainingItem.setAmount(remainingItem.getAmount() * crafts);
new Trade(remainingItem, ess).pay(user, OverflowType.DROP);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra spaces here (I'm not objecting to the linebreak, but the spaces on the line).

return true;
}
}
Expand All @@ -120,7 +130,8 @@ private SimpleRecipe getCondenseType(final ItemStack stack) {
if (recipeItems != null && (recipeItems.size() == 4 || recipeItems.size() == 9) && (recipeItems.size() > recipe.getResult().getAmount())) {
final ItemStack input = stack.clone();
input.setAmount(recipeItems.size());
final SimpleRecipe newRecipe = new SimpleRecipe(recipe.getResult(), input);
final List<ItemStack> remainingItems = getRemainingItems(stack, recipeItems.size());
final SimpleRecipe newRecipe = new SimpleRecipe(recipe.getResult(), input, remainingItems);
bestRecipes.add(newRecipe);
}
}
Expand Down Expand Up @@ -187,10 +198,12 @@ protected List<String> getTabCompleteOptions(final Server server, final User use
private static final class SimpleRecipe implements Recipe {
private final ItemStack result;
private final ItemStack input;
private final List<ItemStack> remainingItems;

private SimpleRecipe(final ItemStack result, final ItemStack input) {
private SimpleRecipe(final ItemStack result, final ItemStack input, final List<ItemStack> remainingItems) {
this.result = result;
this.input = input;
this.remainingItems = remainingItems;
}

@Override
Expand All @@ -201,6 +214,24 @@ public ItemStack getResult() {
public ItemStack getInput() {
return input.clone();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra spaces here (I'm not objecting to the linebreak, but the spaces on the line).

public List<ItemStack> getRemainingItems() {
final List<ItemStack> clonedItems = new ArrayList<>();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra spaces here (I'm not objecting to the linebreak, but the spaces on the line).

for (final ItemStack item : remainingItems) {
clonedItems.add(item.clone());
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra spaces here (I'm not objecting to the linebreak, but the spaces on the line).

return clonedItems;
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra spaces here (I'm not objecting to the linebreak, but the spaces on the line).

private List<ItemStack> getRemainingItems(final ItemStack input, final int inputAmount) {
if (input.getType() == Material.HONEY_BOTTLE) {
return Collections.singletonList(new ItemStack(Material.GLASS_BOTTLE, inputAmount));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra spaces here (I'm not objecting to the linebreak, but the spaces on the line).

return Collections.emptyList();
}

private static class SimpleRecipeComparator implements Comparator<SimpleRecipe> {
Expand Down
Loading