use of net.minecraft.recipe.Recipe in project nbt-crafting by Siphalor.
the class MixinBrewingSlotIngredient method canInsert.
@Inject(method = "canInsert(Lnet/minecraft/item/ItemStack;)Z", at = @At("RETURN"), cancellable = true)
public void canInsert(ItemStack stack, CallbackInfoReturnable<Boolean> callbackInfoReturnable) {
if (callbackInfoReturnable.getReturnValue() || BrewingRecipeRegistry.isValidIngredient(stack)) {
callbackInfoReturnable.setReturnValue(true);
return;
}
RecipeManagerAccessor recipeManager;
if (inventory instanceof BrewingStandBlockEntity) {
recipeManager = (RecipeManagerAccessor) ((BrewingStandBlockEntity) inventory).getWorld().getRecipeManager();
} else if (FabricLoader.getInstance().getEnvironmentType() == EnvType.CLIENT) {
recipeManager = (RecipeManagerAccessor) NbtCraftingClient.getClientRecipeManager();
} else {
NbtCrafting.logError("Failed to get recipe manager in brewing stand container class!");
return;
}
Map<Identifier, Recipe<Inventory>> recipes = recipeManager.callGetAllOfType(NbtCrafting.BREWING_RECIPE_TYPE);
callbackInfoReturnable.setReturnValue(recipes.values().stream().anyMatch(recipe -> recipe instanceof BrewingRecipe && ((BrewingRecipe) recipe).getIngredient().test(stack)));
}
use of net.minecraft.recipe.Recipe in project Polymorph by TheIllusiveC4.
the class AbstractHighlightedRecipeData method getPacketData.
@Override
public Pair<SortedSet<RecipePair>, Identifier> getPacketData() {
SortedSet<RecipePair> recipesList = this.getRecipesList();
Identifier selected = null;
if (!recipesList.isEmpty()) {
selected = this.getSelectedRecipe().map(Recipe::getId).orElse(recipesList.first().getIdentifier());
}
return new Pair<>(recipesList, selected);
}
Aggregations