Skip to content

Commit

Permalink
some recipe stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Abbie5 committed Nov 11, 2024
1 parent ee0da20 commit 2e5933e
Show file tree
Hide file tree
Showing 48 changed files with 416 additions and 420 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
*/
package vazkii.botania.api.recipe;

import net.minecraft.core.HolderLookup;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeInput;
import net.minecraft.world.item.crafting.RecipeType;

import org.jetbrains.annotations.NotNull;
Expand All @@ -22,7 +24,7 @@
import vazkii.botania.api.brew.Brew;
import static vazkii.botania.api.BotaniaAPI.botaniaRL;

public interface BotanicalBreweryRecipe extends Recipe<Container> {
public interface BotanicalBreweryRecipe extends Recipe<RecipeInput> {
ResourceLocation TYPE_ID = botaniaRL("brew");

Brew getBrew();
Expand All @@ -39,13 +41,13 @@ default RecipeType<?> getType() {

@NotNull
@Override
default ItemStack getResultItem(@NotNull RegistryAccess registries) {
default ItemStack getResultItem(@NotNull HolderLookup.Provider registries) {
return ItemStack.EMPTY;
}

@NotNull
@Override
default ItemStack assemble(@NotNull Container inv, @NotNull RegistryAccess registries) {
default ItemStack assemble(@NotNull RecipeInput inv, @NotNull HolderLookup.Provider registries) {
return ItemStack.EMPTY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/
package vazkii.botania.api.recipe;

import net.minecraft.core.HolderLookup;
import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.BuiltInRegistries;
Expand All @@ -16,6 +17,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeInput;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;

Expand All @@ -27,7 +29,7 @@
import java.util.Optional;
import static vazkii.botania.api.BotaniaAPI.botaniaRL;

public interface ElvenTradeRecipe extends Recipe<Container> {
public interface ElvenTradeRecipe extends Recipe<RecipeInput> {
ResourceLocation TYPE_ID = botaniaRL("elven_trade");
ResourceLocation TYPE_ID_LEXICON = botaniaRL("elven_trade_lexicon");

Expand Down Expand Up @@ -71,13 +73,13 @@ default RecipeType<?> getType() {
// Ignored IRecipe boilerplate

@Override
default boolean matches(@NotNull Container inv, @NotNull Level world) {
default boolean matches(@NotNull RecipeInput inv, @NotNull Level world) {
return false;
}

@NotNull
@Override
default ItemStack assemble(@NotNull Container inv, @NotNull RegistryAccess registries) {
default ItemStack assemble(@NotNull RecipeInput inv, @NotNull HolderLookup.Provider registries) {
return ItemStack.EMPTY;
}

Expand All @@ -87,7 +89,7 @@ default boolean canCraftInDimensions(int width, int height) {
}

@Override
default ItemStack getResultItem(@NotNull RegistryAccess registries) {
default ItemStack getResultItem(@NotNull HolderLookup.Provider registries) {
return ItemStack.EMPTY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
*/
package vazkii.botania.api.recipe;

import net.minecraft.core.HolderLookup;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeInput;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;

Expand All @@ -22,7 +24,7 @@
import vazkii.botania.api.BotaniaAPI;
import static vazkii.botania.api.BotaniaAPI.botaniaRL;

public interface ManaInfusionRecipe extends Recipe<Container> {
public interface ManaInfusionRecipe extends Recipe<RecipeInput> {
ResourceLocation TYPE_ID = botaniaRL("mana_infusion");

/**
Expand All @@ -42,7 +44,7 @@ public interface ManaInfusionRecipe extends Recipe<Container> {
*/
@NotNull
@Override
ItemStack getResultItem(@NotNull RegistryAccess registries);
ItemStack getResultItem(@NotNull HolderLookup.Provider registries);

/**
* Get the actual recipe output, not just for display. Defaults to a copy of {@link #getResultItem}.
Expand Down Expand Up @@ -78,12 +80,12 @@ default RecipeType<?> getType() {

@NotNull
@Override
default ItemStack assemble(@NotNull Container inv, @NotNull RegistryAccess registries) {
default ItemStack assemble(@NotNull RecipeInput inv, @NotNull HolderLookup.Provider registries) {
return ItemStack.EMPTY;
}

@Override
default boolean matches(@NotNull Container inv, @NotNull Level world) {
default boolean matches(@NotNull RecipeInput inv, @NotNull Level world) {
return false;
}

Expand Down
10 changes: 6 additions & 4 deletions Xplat/src/main/java/vazkii/botania/api/recipe/OrechidRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@

import net.minecraft.commands.CacheableFunction;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeInput;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;

Expand All @@ -25,7 +27,7 @@

import java.util.Optional;

public interface OrechidRecipe extends Recipe<Container> {
public interface OrechidRecipe extends Recipe<RecipeInput> {
ResourceLocation TYPE_ID = botaniaRL("orechid");
ResourceLocation IGNEM_TYPE_ID = botaniaRL("orechid_ignem");
ResourceLocation MARIMORPHOSIS_TYPE_ID = botaniaRL("marimorphosis");
Expand Down Expand Up @@ -63,7 +65,7 @@ default int getWeight(@NotNull Level level, @NotNull BlockPos pos) {
*/
@Override
@Deprecated
default boolean matches(Container container, Level level) {
default boolean matches(RecipeInput container, Level level) {
return false;
}

Expand All @@ -72,7 +74,7 @@ default boolean matches(Container container, Level level) {
*/
@Override
@Deprecated
default ItemStack assemble(Container container, @NotNull RegistryAccess registryAccess) {
default ItemStack assemble(RecipeInput container, @NotNull HolderLookup.Provider registryAccess) {
return ItemStack.EMPTY;
}

Expand All @@ -90,7 +92,7 @@ default boolean canCraftInDimensions(int width, int height) {
*/
@Override
@Deprecated
default ItemStack getResultItem(@NotNull RegistryAccess registryAccess) {
default ItemStack getResultItem(@NotNull HolderLookup.Provider registryAccess) {
return ItemStack.EMPTY;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

import net.minecraft.commands.CacheableFunction;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeInput;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
Expand All @@ -27,7 +29,7 @@

import java.util.Optional;

public interface PureDaisyRecipe extends Recipe<Container> {
public interface PureDaisyRecipe extends Recipe<RecipeInput> {
ResourceLocation TYPE_ID = botaniaRL("pure_daisy");

/**
Expand Down Expand Up @@ -75,7 +77,7 @@ default RecipeType<?> getType() {
*/
@Override
@Deprecated
default boolean matches(Container container, Level level) {
default boolean matches(RecipeInput container, Level level) {
return false;
}

Expand All @@ -84,7 +86,7 @@ default boolean matches(Container container, Level level) {
*/
@Override
@Deprecated
default ItemStack assemble(Container container, @NotNull RegistryAccess registryAccess) {
default ItemStack assemble(RecipeInput container, @NotNull HolderLookup.Provider registryAccess) {
return ItemStack.EMPTY;
}

Expand All @@ -102,7 +104,7 @@ default boolean canCraftInDimensions(int width, int height) {
*/
@Override
@Deprecated
default ItemStack getResultItem(@NotNull RegistryAccess registryAccess) {
default ItemStack getResultItem(@NotNull HolderLookup.Provider registryAccess) {
return ItemStack.EMPTY;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package vazkii.botania.api.recipe;

import net.minecraft.world.Container;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeInput;

public interface RecipeWithReagent extends Recipe<Container> {
public interface RecipeWithReagent extends Recipe<RecipeInput> {
/**
* @return Ingredient matching the final item that needs to be thrown into the apothecary
* to perform a craft after a matching recipe is in.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Ingredient;
import net.minecraft.world.item.crafting.RecipeInput;
import net.minecraft.world.item.crafting.RecipeType;

import org.jetbrains.annotations.NotNull;
Expand All @@ -31,7 +32,7 @@ public interface RunicAltarRecipe extends RecipeWithReagent {

@NotNull
@Override
NonNullList<ItemStack> getRemainingItems(Container container);
NonNullList<ItemStack> getRemainingItems(RecipeInput container);

@NotNull
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@
*/
package vazkii.botania.api.recipe;

import com.mojang.serialization.Codec;

import com.mojang.serialization.MapCodec;
import net.minecraft.network.FriendlyByteBuf;

public interface StateIngredientType<T extends StateIngredient> {
Codec<T> codec();
MapCodec<T> codec();

T fromNetwork(FriendlyByteBuf buffer);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
import net.minecraft.world.Container;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeInput;
import net.minecraft.world.item.crafting.RecipeType;

import org.jetbrains.annotations.NotNull;

import vazkii.botania.api.BotaniaAPI;
import static vazkii.botania.api.BotaniaAPI.botaniaRL;

public interface TerrestrialAgglomerationRecipe extends Recipe<Container> {
public interface TerrestrialAgglomerationRecipe extends Recipe<RecipeInput> {
ResourceLocation TERRA_PLATE_ID = botaniaRL("terra_plate");
ResourceLocation TYPE_ID = TERRA_PLATE_ID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public List<ItemStack> getDisplayedStacks() {
@Nullable
@Override
public List<Component> descriptionTooltip() {
ImmutableMap<Property<?>, Comparable<?>> map = state.getValues();
Map<Property<?>, Comparable<?>> map = state.getValues();
if (map.isEmpty()) {
return StateIngredient.super.descriptionTooltip();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.world.Container;
import net.minecraft.world.item.crafting.Recipe;
import net.minecraft.world.item.crafting.RecipeHolder;
import net.minecraft.world.item.crafting.RecipeInput;
import net.minecraft.world.item.crafting.RecipeSerializer;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.Level;
Expand Down Expand Up @@ -94,12 +95,12 @@ public String toString() {
}
}

public static <C extends Container, T extends Recipe<C>> Map<ResourceLocation, T> getRecipes(Level world, RecipeType<T> type) {
public static <C extends RecipeInput, T extends Recipe<C>> Map<ResourceLocation, T> getRecipes(Level world, RecipeType<T> type) {
return ((RecipeManagerAccessor) world.getRecipeManager()).botania_getAll(type);
}

@SuppressWarnings("unchecked")
public static <C extends Container, T extends Recipe<C>> Optional<RecipeHolder<T>> getRecipe(Level world, ResourceLocation id, RecipeType<T> expectedType) {
public static <C extends RecipeInput, T extends Recipe<C>> Optional<RecipeHolder<T>> getRecipe(Level world, ResourceLocation id, RecipeType<T> expectedType) {
var holder = world.getRecipeManager().byKey(id);
return holder.isPresent() && holder.get().value().getType() == expectedType
? holder.map(h -> (RecipeHolder<T>) h)
Expand Down
Loading

0 comments on commit 2e5933e

Please sign in to comment.