Skip to content

Commit

Permalink
Added recipe.consumeIngredient(filter) method for when you want to ma…
Browse files Browse the repository at this point in the history
…ke sure item gets destroyed when normally it wouldn't, like water bucket -> bucket now can be water bucket -> air
  • Loading branch information
LatvianModder committed Feb 21, 2024
1 parent c427dbc commit c31bcda
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import dev.latvian.mods.kubejs.recipe.component.MissingComponentException;
import dev.latvian.mods.kubejs.recipe.component.RecipeComponentBuilderMap;
import dev.latvian.mods.kubejs.recipe.component.RecipeComponentValue;
import dev.latvian.mods.kubejs.recipe.ingredientaction.ConsumeAction;
import dev.latvian.mods.kubejs.recipe.ingredientaction.CustomIngredientAction;
import dev.latvian.mods.kubejs.recipe.ingredientaction.DamageAction;
import dev.latvian.mods.kubejs.recipe.ingredientaction.IngredientAction;
Expand Down Expand Up @@ -589,6 +590,10 @@ public final RecipeJS keepIngredient(IngredientActionFilter filter) {
return ingredientAction(filter, new KeepAction());
}

public final RecipeJS consumeIngredient(IngredientActionFilter filter) {
return ingredientAction(filter, new ConsumeAction());
}

public final RecipeJS modifyResult(ModifyRecipeResultCallback callback) {
modifyResult = callback;
save();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package dev.latvian.mods.kubejs.recipe.ingredientaction;

import net.minecraft.world.inventory.CraftingContainer;
import net.minecraft.world.item.ItemStack;

public class ConsumeAction extends IngredientAction {
@Override
public ItemStack transform(ItemStack old, int index, CraftingContainer container) {
return ItemStack.EMPTY;
}

@Override
public String getType() {
return "consume";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public abstract class IngredientAction extends IngredientActionFilter {
FACTORY_MAP.put("damage", json -> new DamageAction(json.get("damage").getAsInt()));
FACTORY_MAP.put("replace", json -> new ReplaceAction(ItemStackJS.resultFromRecipeJson(json.get("item"))));
FACTORY_MAP.put("keep", json -> new KeepAction());
FACTORY_MAP.put("consume", json -> new ConsumeAction());
}

public static List<IngredientAction> parseList(JsonElement json) {
Expand Down

0 comments on commit c31bcda

Please sign in to comment.