use of org.spongepowered.common.item.recipe.smelting.MatchSmeltingVanillaItemStack in project SpongeCommon by SpongePowered.
the class MixinFurnaceRecipes method findMatchingRecipe.
@Override
public Optional<SmeltingRecipe> findMatchingRecipe(ItemStackSnapshot ingredient) {
checkNotNull(ingredient, "ingredient");
for (SmeltingRecipe customRecipe : this.customRecipes) {
if (customRecipe.isValid(ingredient)) {
return Optional.of(customRecipe);
}
}
ItemStack nativeIngredient = ItemStackUtil.fromSnapshotToNative(ingredient);
for (Map.Entry<ItemStack, ItemStack> entry : this.smeltingList.entrySet()) {
ItemStack nativeIngredientPrecise = entry.getKey();
if (compareItemStacks(nativeIngredient, nativeIngredientPrecise)) {
ItemStack nativeExemplaryResult = entry.getValue();
ItemStackSnapshot result = ItemStackUtil.snapshotOf(nativeExemplaryResult);
ItemStackSnapshot ingredientPrecise = ItemStackUtil.snapshotOf(nativeIngredientPrecise);
Predicate<ItemStackSnapshot> ingredientPredicate = new MatchSmeltingVanillaItemStack(ingredientPrecise);
double experience = this.experienceList.get(nativeExemplaryResult);
SmeltingRecipe recipe = new SpongeSmeltingRecipe(result, ingredientPrecise, ingredientPredicate, experience);
return Optional.of(recipe);
}
}
return Optional.empty();
}
use of org.spongepowered.common.item.recipe.smelting.MatchSmeltingVanillaItemStack in project SpongeCommon by SpongePowered.
the class MixinFurnaceRecipes method getRecipes.
@Override
public Collection<SmeltingRecipe> getRecipes() {
ImmutableList.Builder<SmeltingRecipe> builder = ImmutableList.builder();
for (Map.Entry<ItemStack, ItemStack> smeltingEntry : this.smeltingList.entrySet()) {
ItemStack nativeIngredient = smeltingEntry.getKey();
// If not a custom recipe, add first
if (!this.nativeIngredientToCustomRecipe.containsKey(nativeIngredient)) {
ItemStack nativeExemplaryResult = smeltingEntry.getValue();
ItemStackSnapshot exemplaryResult = ItemStackUtil.snapshotOf(nativeExemplaryResult);
ItemStackSnapshot exemplaryIngredient = ItemStackUtil.snapshotOf(nativeIngredient);
Predicate<ItemStackSnapshot> ingredientPredicate = new MatchSmeltingVanillaItemStack(exemplaryIngredient);
double experience = (double) this.experienceList.get(nativeExemplaryResult);
builder.add(new SpongeSmeltingRecipe(exemplaryResult, exemplaryIngredient, ingredientPredicate, experience));
}
}
builder.addAll(this.customRecipes);
return builder.build();
}
Aggregations