Anvil crafting fixes

This commit is contained in:
Aleksey 2021-02-13 00:15:11 +03:00
parent c5182a4418
commit 7e367a1971
9 changed files with 76 additions and 83 deletions

View file

@ -5,27 +5,29 @@ import java.util.List;
import ru.betterend.recipe.builders.AnvilRecipe;
public interface AnvilScreenHandlerExtended {
public void be_updateCurrentRecipe(AnvilRecipe recipe);
public AnvilRecipe be_getCurrentRecipe();
public List<AnvilRecipe> be_getRecipes();
void be_updateCurrentRecipe(AnvilRecipe recipe);
AnvilRecipe be_getCurrentRecipe();
List<AnvilRecipe> be_getRecipes();
default void be_nextRecipe() {
List<AnvilRecipe> recipes = this.be_getRecipes();
AnvilRecipe current = this.be_getCurrentRecipe();
List<AnvilRecipe> recipes = be_getRecipes();
if (recipes.size() < 2) return;
AnvilRecipe current = be_getCurrentRecipe();
int i = recipes.indexOf(current) + 1;
if (i >= recipes.size()) {
i = 0;
}
this.be_updateCurrentRecipe(recipes.get(i));
be_updateCurrentRecipe(recipes.get(i));
}
default void be_previousRecipe() {
List<AnvilRecipe> recipes = this.be_getRecipes();
AnvilRecipe current = this.be_getCurrentRecipe();
List<AnvilRecipe> recipes = be_getRecipes();
if (recipes.size() < 2) return;
AnvilRecipe current = be_getCurrentRecipe();
int i = recipes.indexOf(current) - 1;
if (i <= 0) {
i = recipes.size() - 1;
}
this.be_updateCurrentRecipe(recipes.get(i));
be_updateCurrentRecipe(recipes.get(i));
}
}