-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
293 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/main/java/nova/core/recipes/smelting/BasicSmeltingRecipe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright (c) 2017 NOVA, All rights reserved. | ||
* This library is free software, licensed under GNU Lesser General Public License version 3 | ||
* | ||
* This file is part of NOVA. | ||
* | ||
* NOVA is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* NOVA is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with NOVA. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package nova.core.recipes.smelting; | ||
|
||
import nova.core.item.Item; | ||
import nova.core.item.ItemFactory; | ||
import nova.core.recipes.ItemIngredient; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* @author ExE Boss | ||
*/ | ||
public class BasicSmeltingRecipe implements SmeltingRecipe { | ||
|
||
private final ItemFactory nominalOutput; | ||
private final ItemIngredient ingredient; | ||
|
||
/** | ||
* Defines a basic structured crafting recipe, using a format string. | ||
* @param output Output {@link Item} of the recipe | ||
* @param ingredient {@link ItemIngredient} | ||
*/ | ||
public BasicSmeltingRecipe(ItemFactory output, ItemIngredient ingredient) { | ||
this.nominalOutput = output; | ||
this.ingredient = ingredient; | ||
} | ||
|
||
@Override | ||
public boolean matches(Optional<Item> input) { | ||
return input.isPresent() && this.ingredient.matches(input.get()); | ||
} | ||
|
||
@Override | ||
public Optional<Item> getCraftingResult(Optional<Item> input) { | ||
return matches(input) ? getNominalOutput() : Optional.empty(); | ||
} | ||
|
||
@Override | ||
public Optional<Item> getNominalInput() { | ||
return this.ingredient.getExampleItems().flatMap(c -> c.stream().findFirst()); | ||
} | ||
|
||
@Override | ||
public Optional<Item> getNominalOutput() { | ||
return Optional.of(this.nominalOutput.build()); | ||
} | ||
|
||
@Override | ||
public Optional<ItemIngredient> getInput() { | ||
return Optional.of(this.ingredient); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
src/main/java/nova/core/recipes/smelting/SmeltingRecipe.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright (c) 2017 NOVA, All rights reserved. | ||
* This library is free software, licensed under GNU Lesser General Public License version 3 | ||
* | ||
* This file is part of NOVA. | ||
* | ||
* NOVA is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* NOVA is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with NOVA. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package nova.core.recipes.smelting; | ||
|
||
import nova.core.item.Item; | ||
import nova.core.recipes.ItemIngredient; | ||
import nova.core.recipes.Recipe; | ||
|
||
import java.util.Optional; | ||
|
||
/** | ||
* @author ExE Boss | ||
*/ | ||
public interface SmeltingRecipe extends Recipe { | ||
/** | ||
* Checks if this crafting recipe matches the content of the given smelting input. | ||
* | ||
* @param input smelting input to read from | ||
* @return true if a smelting operation would return a valid result | ||
*/ | ||
boolean matches(Optional<Item> input); | ||
|
||
/** | ||
* Calculates the crafting result for the given crafting grid. Does not | ||
* modify the contents of the crafting grid. | ||
* | ||
* @param input crafting grid | ||
* @return crafting result, empty if the recipe doesn't match | ||
*/ | ||
Optional<Item> getCraftingResult(Optional<Item> input); | ||
|
||
/** | ||
* Gets a nominal (example) input for this recipe. Used in recipe display. | ||
* | ||
* @return example input | ||
*/ | ||
Optional<Item> getNominalInput(); | ||
|
||
/** | ||
* Gets a nominal (example) output for this recipe. Used in recipe display. | ||
* | ||
* @return example output | ||
*/ | ||
Optional<Item> getNominalOutput(); | ||
|
||
/** | ||
* Gets the input for this recipe. Used during registration. | ||
* | ||
* @return the input | ||
*/ | ||
Optional<ItemIngredient> getInput(); | ||
} |
Oops, something went wrong.