mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-02-02 11:21:20 +01:00
Multiple recipes of the same thing no longer possible.
Fixes #mmoitems-1407
This commit is contained in:
parent
bc4bb96fd5
commit
eef0414a35
@ -193,7 +193,7 @@ public class CustomRecipe implements Comparable<CustomRecipe> {
|
|||||||
* @return A baked recipe, ready to deploy.
|
* @return A baked recipe, ready to deploy.
|
||||||
* @throws IllegalArgumentException If the recipe is in incorrect format
|
* @throws IllegalArgumentException If the recipe is in incorrect format
|
||||||
*/
|
*/
|
||||||
@NotNull public static MythicRecipeBlueprint generateShapeless(@NotNull Type type, @NotNull String id, @NotNull List<String> recipe) throws IllegalArgumentException {
|
@NotNull public static MythicRecipeBlueprint generateShapeless(@NotNull Type type, @NotNull String id, @NotNull List<String> recipe, @NotNull String namespaceKey) throws IllegalArgumentException {
|
||||||
|
|
||||||
// Get it
|
// Get it
|
||||||
MMOItemTemplate template = MMOItems.plugin.getTemplates().getTemplate(type, id);
|
MMOItemTemplate template = MMOItems.plugin.getTemplates().getTemplate(type, id);
|
||||||
@ -219,13 +219,12 @@ public class CustomRecipe implements Comparable<CustomRecipe> {
|
|||||||
poofs.add(new MythicRecipeIngredient(p));
|
poofs.add(new MythicRecipeIngredient(p));
|
||||||
}
|
}
|
||||||
if (!nonAirFound) { throw new IllegalArgumentException(FriendlyFeedbackProvider.quickForConsole(FFPMMOItems.get(), "Shapeless recipe containing only AIR, $fignored$b.")); }
|
if (!nonAirFound) { throw new IllegalArgumentException(FriendlyFeedbackProvider.quickForConsole(FFPMMOItems.get(), "Shapeless recipe containing only AIR, $fignored$b.")); }
|
||||||
String recipeName = type + "." + id;
|
|
||||||
|
|
||||||
// Build Main
|
// Build Main
|
||||||
ShapedRecipe shapedRecipe = ShapedRecipe.single(recipeName, new ProvidedUIFilter(MMOItemUIFilter.get(), type.getId(), id, Math.max(template.getCraftedAmount(), 1)));
|
ShapedRecipe shapedRecipe = ShapedRecipe.single(namespaceKey, new ProvidedUIFilter(MMOItemUIFilter.get(), type.getId(), id, Math.max(template.getCraftedAmount(), 1)));
|
||||||
|
|
||||||
// Make ingredients
|
// Make ingredients
|
||||||
ShapelessRecipe inputRecipe = new ShapelessRecipe(recipeName, poofs);
|
ShapelessRecipe inputRecipe = new ShapelessRecipe(namespaceKey, poofs);
|
||||||
|
|
||||||
// Create Output
|
// Create Output
|
||||||
MythicRecipeOutput outputRecipe = new MRORecipe(shapedRecipe);
|
MythicRecipeOutput outputRecipe = new MRORecipe(shapedRecipe);
|
||||||
@ -244,7 +243,7 @@ public class CustomRecipe implements Comparable<CustomRecipe> {
|
|||||||
* @return A baked recipe, ready to deploy.
|
* @return A baked recipe, ready to deploy.
|
||||||
* @throws IllegalArgumentException If the recipe is in incorrect format
|
* @throws IllegalArgumentException If the recipe is in incorrect format
|
||||||
*/
|
*/
|
||||||
@NotNull public static MythicRecipeBlueprint generateShaped(@NotNull Type type, @NotNull String id, @NotNull List<String> recipe) throws IllegalArgumentException {
|
@NotNull public static MythicRecipeBlueprint generateShaped(@NotNull Type type, @NotNull String id, @NotNull List<String> recipe, @NotNull String namespaceKey) throws IllegalArgumentException {
|
||||||
|
|
||||||
// Get it
|
// Get it
|
||||||
MMOItemTemplate template = MMOItems.plugin.getTemplates().getTemplate(type, id);
|
MMOItemTemplate template = MMOItems.plugin.getTemplates().getTemplate(type, id);
|
||||||
@ -323,13 +322,12 @@ public class CustomRecipe implements Comparable<CustomRecipe> {
|
|||||||
rowNumber++;
|
rowNumber++;
|
||||||
}
|
}
|
||||||
if (!nonAirFound) { throw new IllegalArgumentException(FriendlyFeedbackProvider.quickForConsole(FFPMMOItems.get(), "Shaped recipe containing only AIR, $fignored$b.")); }
|
if (!nonAirFound) { throw new IllegalArgumentException(FriendlyFeedbackProvider.quickForConsole(FFPMMOItems.get(), "Shaped recipe containing only AIR, $fignored$b.")); }
|
||||||
String recipeName = type + "." + id;
|
|
||||||
|
|
||||||
// Build Main
|
// Build Main
|
||||||
ShapedRecipe shapedRecipe = ShapedRecipe.single(recipeName, new ProvidedUIFilter(MMOItemUIFilter.get(), type.getId(), id, Math.max(template.getCraftedAmount(), 1)));
|
ShapedRecipe shapedRecipe = ShapedRecipe.single(namespaceKey, new ProvidedUIFilter(MMOItemUIFilter.get(), type.getId(), id, Math.max(template.getCraftedAmount(), 1)));
|
||||||
|
|
||||||
// Make ingredients
|
// Make ingredients
|
||||||
ShapedRecipe inputRecipe = ShapedRecipe.unsharpen((new ShapedRecipe(recipeName, poofs)));
|
ShapedRecipe inputRecipe = ShapedRecipe.unsharpen((new ShapedRecipe(namespaceKey, poofs)));
|
||||||
|
|
||||||
// Create Output
|
// Create Output
|
||||||
MythicRecipeOutput outputRecipe = new MRORecipe(shapedRecipe);
|
MythicRecipeOutput outputRecipe = new MRORecipe(shapedRecipe);
|
||||||
@ -348,7 +346,7 @@ public class CustomRecipe implements Comparable<CustomRecipe> {
|
|||||||
* @return A baked recipe, ready to deploy.
|
* @return A baked recipe, ready to deploy.
|
||||||
* @throws IllegalArgumentException If the recipe is in incorrect format
|
* @throws IllegalArgumentException If the recipe is in incorrect format
|
||||||
*/
|
*/
|
||||||
@NotNull public static MythicRecipeBlueprint generateSmithing(@NotNull Type type, @NotNull String id, @NotNull String item, @NotNull String ingot, boolean dropGems, @NotNull String enchantmentBehaviour, @NotNull String upgradeBehaviour) throws IllegalArgumentException {
|
@NotNull public static MythicRecipeBlueprint generateSmithing(@NotNull Type type, @NotNull String id, @NotNull String item, @NotNull String ingot, boolean dropGems, @NotNull String enchantmentBehaviour, @NotNull String upgradeBehaviour, @NotNull String namespaceKey) throws IllegalArgumentException {
|
||||||
|
|
||||||
// Get it
|
// Get it
|
||||||
MMOItemTemplate template = MMOItems.plugin.getTemplates().getTemplate(type, id);
|
MMOItemTemplate template = MMOItems.plugin.getTemplates().getTemplate(type, id);
|
||||||
@ -371,14 +369,10 @@ public class CustomRecipe implements Comparable<CustomRecipe> {
|
|||||||
|
|
||||||
MythicRecipeIngredient itemIngredient = new MythicRecipeIngredient(itemPoof);
|
MythicRecipeIngredient itemIngredient = new MythicRecipeIngredient(itemPoof);
|
||||||
MythicRecipeIngredient ingotIngredient = new MythicRecipeIngredient(ingotPoof);
|
MythicRecipeIngredient ingotIngredient = new MythicRecipeIngredient(ingotPoof);
|
||||||
String recipeName = type + "." + id;
|
|
||||||
|
|
||||||
// Build Main
|
|
||||||
ShapedRecipe shapedRecipe = ShapedRecipe.single(recipeName, new ProvidedUIFilter(MMOItemUIFilter.get(), type.getId(), id, Math.max(template.getCraftedAmount(), 1)));
|
|
||||||
|
|
||||||
// Make ingredients
|
// Make ingredients
|
||||||
ShapelessRecipe inputItem = new ShapelessRecipe(recipeName, itemIngredient);
|
ShapelessRecipe inputItem = new ShapelessRecipe(namespaceKey, itemIngredient);
|
||||||
ShapelessRecipe inputIngot = new ShapelessRecipe(recipeName, ingotIngredient);
|
ShapelessRecipe inputIngot = new ShapelessRecipe(namespaceKey, ingotIngredient);
|
||||||
|
|
||||||
// Create Output
|
// Create Output
|
||||||
MythicRecipeOutput outputRecipe = new CustomSmithingRecipe(template, dropGems, enchantEffect, upgradeEffect);
|
MythicRecipeOutput outputRecipe = new CustomSmithingRecipe(template, dropGems, enchantEffect, upgradeEffect);
|
||||||
|
@ -175,7 +175,7 @@ public class RecipeManager implements Reloadable {
|
|||||||
if (upgrade == null) { upgrade = SmithingCombinationType.MAXIMUM.toString(); }
|
if (upgrade == null) { upgrade = SmithingCombinationType.MAXIMUM.toString(); }
|
||||||
if (enchants == null) { enchants = SmithingCombinationType.MAXIMUM.toString(); }
|
if (enchants == null) { enchants = SmithingCombinationType.MAXIMUM.toString(); }
|
||||||
|
|
||||||
MythicRecipeBlueprint blueprint = CustomRecipe.generateSmithing(type, id, item, ingot, dropGems, enchants, upgrade);
|
MythicRecipeBlueprint blueprint = CustomRecipe.generateSmithing(type, id, item, ingot, dropGems, enchants, upgrade, number);
|
||||||
|
|
||||||
// Enable it
|
// Enable it
|
||||||
Ref<NamespacedKey> nk = new Ref<>();
|
Ref<NamespacedKey> nk = new Ref<>();
|
||||||
@ -220,11 +220,11 @@ public class RecipeManager implements Reloadable {
|
|||||||
if (shapeless) {
|
if (shapeless) {
|
||||||
|
|
||||||
// Generate with no shape
|
// Generate with no shape
|
||||||
blueprint = CustomRecipe.generateShapeless(type, id, list);
|
blueprint = CustomRecipe.generateShapeless(type, id, list, recipeID);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
// Generate shaped
|
// Generate shaped
|
||||||
blueprint = CustomRecipe.generateShaped(type, id, list);
|
blueprint = CustomRecipe.generateShaped(type, id, list, recipeID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable it
|
// Enable it
|
||||||
@ -283,7 +283,7 @@ public class RecipeManager implements Reloadable {
|
|||||||
legacyCraftingRecipes.addAll(temporary.stream().sorted().collect(Collectors.toList()));
|
legacyCraftingRecipes.addAll(temporary.stream().sorted().collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public NamespacedKey getRecipeKey(Type type, String id, String recipeType, String number) {
|
@NotNull public NamespacedKey getRecipeKey(@NotNull Type type, @NotNull String id, @NotNull String recipeType, @NotNull String number) {
|
||||||
return new NamespacedKey(MMOItems.plugin, recipeType + "_" + type.getId() + "_" + id + "_" + number);
|
return new NamespacedKey(MMOItems.plugin, recipeType + "_" + type.getId() + "_" + id + "_" + number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user