-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix honey bottles not returning glass bottles when condensed #6576
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
base: 2.x
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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(); | ||
|
|
||
| if (amount > 0) { | ||
| input.setAmount(amount); | ||
| result.setAmount(output); | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
| } | ||
| } | ||
|
|
@@ -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); | ||
| } | ||
| } | ||
|
|
@@ -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 | ||
|
|
@@ -201,6 +214,24 @@ public ItemStack getResult() { | |
| public ItemStack getInput() { | ||
| return input.clone(); | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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<>(); | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()); | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
| } | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)); | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.