Skip to content
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

Fixes RecipeManager #4157

Open
wants to merge 1 commit into
base: api-12
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,31 @@
public abstract class RecipeManagerMixin_API implements RecipeManager {

// @formatter:off
@Shadow public abstract Optional<? extends net.minecraft.world.item.crafting.Recipe<?>> shadow$byKey(ResourceLocation recipeId);
@Shadow public abstract Optional<? extends net.minecraft.world.item.crafting.RecipeHolder<?>> shadow$byKey(ResourceLocation recipeId);
@Shadow protected abstract <I extends RecipeInput, T extends net.minecraft.world.item.crafting.Recipe<I>> Collection<RecipeHolder<T>> shadow$byType(net.minecraft.world.item.crafting.RecipeType<T> recipeTypeIn);
@Shadow public abstract Collection<net.minecraft.world.item.crafting.Recipe<?>> shadow$getRecipes();
@Shadow public abstract <I extends RecipeInput, T extends net.minecraft.world.item.crafting.Recipe<I>> Optional<T> shadow$getRecipeFor(net.minecraft.world.item.crafting.RecipeType<T> recipeTypeIn, I inventoryIn, net.minecraft.world.level.Level worldIn);
@Shadow public abstract Collection<net.minecraft.world.item.crafting.RecipeHolder<?>> shadow$getRecipes();
@Shadow public abstract <I extends RecipeInput, T extends net.minecraft.world.item.crafting.Recipe<I>> Optional<RecipeHolder<T>> shadow$getRecipeFor(net.minecraft.world.item.crafting.RecipeType<T> recipeTypeIn, I inventoryIn, net.minecraft.world.level.Level worldIn);

// @formatter:on

@SuppressWarnings({"DataFlowIssue", "unchecked"})
@Override
public Optional<Recipe<?>> byKey(final ResourceKey key) {
Objects.requireNonNull(key);
return this.shadow$byKey((ResourceLocation) (Object) key).map(Recipe.class::cast);
return this.shadow$byKey((ResourceLocation) (Object) key).map(RecipeHolder::value).map(Recipe.class::cast);
}

@Override
@SuppressWarnings(value = {"unchecked", "rawtypes"})
public Collection<Recipe<?>> all() {
return (Collection) this.shadow$getRecipes();
return (Collection) this.shadow$getRecipes().stream().map(RecipeHolder::value).toList();
}

@Override
@SuppressWarnings(value = {"unchecked", "rawtypes"})
public <T extends Recipe<?>> Collection<T> allOfType(final RecipeType<T> type) {
Objects.requireNonNull(type);
return this.shadow$byType((net.minecraft.world.item.crafting.RecipeType)type);
return this.shadow$byType((net.minecraft.world.item.crafting.RecipeType)type).stream().map(h -> ((RecipeHolder)h).value()).toList();
}

@Override
Expand Down Expand Up @@ -115,6 +116,6 @@ public <T extends CookingRecipe> Optional<T> findCookingRecipe(final RecipeType<
Objects.requireNonNull(ingredient);

final SingleRecipeInput input = new SingleRecipeInput(ItemStackUtil.fromLikeToNative(ingredient));
return this.shadow$getRecipeFor((net.minecraft.world.item.crafting.RecipeType) type, input, null);
return this.shadow$getRecipeFor((net.minecraft.world.item.crafting.RecipeType) type, input, null).map(h -> ((RecipeHolder<?>)h).value());
}
}
Loading