use of org.spongepowered.common.accessor.world.inventory.CraftingMenuAccessor in project SpongeCommon by SpongePowered.
the class RecipeManagerMixin_API method findMatchingRecipe.
@Override
@SuppressWarnings("unchecked")
public Optional<Recipe> findMatchingRecipe(final Inventory inventory, final ServerWorld world) {
Preconditions.checkNotNull(inventory);
Preconditions.checkNotNull(world);
if (inventory instanceof AbstractFurnaceBlockEntity) {
final net.minecraft.world.item.crafting.RecipeType<? extends AbstractCookingRecipe> type = ((AbstractFurnaceBlockEntityAccessor) inventory).accessor$recipeType();
return this.<Container, AbstractCookingRecipe>shadow$getRecipeFor((net.minecraft.world.item.crafting.RecipeType<AbstractCookingRecipe>) type, (Container) inventory, (net.minecraft.world.level.Level) world).map(Recipe.class::cast);
}
if (inventory instanceof CampfireBlockEntity) {
return this.shadow$getRecipeFor(net.minecraft.world.item.crafting.RecipeType.CAMPFIRE_COOKING, (Container) inventory, (net.minecraft.world.level.Level) world).map(Recipe.class::cast);
}
if (inventory instanceof CraftingMenu) {
final CraftingContainer craftingInventory = ((CraftingMenuAccessor) inventory).accessor$craftSlots();
return this.shadow$getRecipeFor(net.minecraft.world.item.crafting.RecipeType.CRAFTING, craftingInventory, (net.minecraft.world.level.Level) world).map(Recipe.class::cast);
}
if (inventory instanceof InventoryMenu) {
final CraftingContainer craftingInventory = ((InventoryMenuAccessor) inventory).accessor$craftSlots();
return this.shadow$getRecipeFor(net.minecraft.world.item.crafting.RecipeType.CRAFTING, craftingInventory, (net.minecraft.world.level.Level) world).map(Recipe.class::cast);
}
if (inventory instanceof StonecutterMenu) {
final Container stonecutterInventory = ((StonecutterMenu) inventory).container;
return this.shadow$getRecipeFor(net.minecraft.world.item.crafting.RecipeType.STONECUTTING, stonecutterInventory, (net.minecraft.world.level.Level) world).map(Recipe.class::cast);
}
return Optional.empty();
}
Aggregations