Skip to content

Commit 4c6652a

Browse files
committed
Begin custom recipe
1 parent 1d8f3ce commit 4c6652a

3 files changed

Lines changed: 169 additions & 1 deletion

File tree

src/main/java/us/drullk/examplemod/ExampleMod.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package us.drullk.examplemod;
22

3+
import io.github.mortuusars.exposure.world.item.crafting.recipe.serializer.ComponentTransferringRecipeSerializer;
4+
import net.minecraft.core.registries.Registries;
5+
import net.minecraft.world.item.crafting.RecipeSerializer;
6+
import net.neoforged.neoforge.registries.DeferredHolder;
7+
import net.neoforged.neoforge.registries.DeferredRegister;
38
import org.slf4j.Logger;
49

510
import com.mojang.logging.LogUtils;
@@ -13,6 +18,12 @@ public class ExampleMod {
1318
public static final String MODID = "examplemod";
1419
public static final Logger LOGGER = LogUtils.getLogger();
1520

16-
public ExampleMod(IEventBus modEventBus, ModContainer modContainer) {
21+
private final DeferredRegister<RecipeSerializer<?>> recipeSerializers = DeferredRegister.create(Registries.RECIPE_SERIALIZER, MODID);
22+
private final DeferredHolder<RecipeSerializer<?>, ComponentTransferringRecipeSerializer<FlaskDevelopmentRecipe>> flaskRecipeSerializer;
23+
24+
public ExampleMod(IEventBus modEventBus, ModContainer modContainer) {
25+
this.recipeSerializers.register(modEventBus);
26+
27+
this.flaskRecipeSerializer = this.recipeSerializers.register("flask_film_development", () -> new ComponentTransferringRecipeSerializer<>("flask_film_development", "film", FlaskDevelopmentRecipe::new));
1728
}
1829
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package us.drullk.examplemod;
2+
3+
import io.github.mortuusars.exposure.world.item.crafting.recipe.FilmDevelopingRecipe;
4+
import net.minecraft.core.NonNullList;
5+
import net.minecraft.world.item.ItemStack;
6+
import net.minecraft.world.item.crafting.CraftingBookCategory;
7+
import net.minecraft.world.item.crafting.CraftingInput;
8+
import net.minecraft.world.item.crafting.Ingredient;
9+
import org.jetbrains.annotations.NotNull;
10+
import twilightforest.components.item.PotionFlaskComponent;
11+
import twilightforest.init.TFDataComponents;
12+
13+
public class FlaskDevelopmentRecipe extends FilmDevelopingRecipe {
14+
public FlaskDevelopmentRecipe(CraftingBookCategory category, Ingredient filmIngredient, NonNullList<Ingredient> ingredients, ItemStack result) {
15+
super(category, filmIngredient, ingredients, result);
16+
}
17+
18+
@Override
19+
public @NotNull NonNullList<ItemStack> getRemainingItems(CraftingInput input) {
20+
NonNullList<ItemStack> remainingItems = super.getRemainingItems(input);
21+
22+
for (int i = 0; i < remainingItems.size(); i++) {
23+
ItemStack remainingItem = input.getItem(i).copy();
24+
if (!remainingItem.has(TFDataComponents.POTION_FLASK_CONTENTS)) {
25+
continue;
26+
}
27+
28+
PotionFlaskComponent potionFlaskComponent = remainingItem.get(TFDataComponents.POTION_FLASK_CONTENTS).removeDose();
29+
if (potionFlaskComponent.breakage() >= 3) {
30+
remainingItem.shrink(1);
31+
}
32+
remainingItem.set(TFDataComponents.POTION_FLASK_CONTENTS, potionFlaskComponent);
33+
remainingItems.set(i, remainingItem);
34+
}
35+
36+
return remainingItems;
37+
}
38+
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
{
2+
"type": "examplemod:flask_film_development",
3+
"film": {
4+
"tag": "exposure:color_film_rolls"
5+
},
6+
"ingredients": [
7+
[
8+
{
9+
"type": "neoforge:components",
10+
"items": "minecraft:potion",
11+
"components": {
12+
"minecraft:potion_contents": {
13+
"potion": "minecraft:awkward"
14+
}
15+
}
16+
},
17+
{
18+
"type": "neoforge:components",
19+
"items": "twilightforest:brittle_potion_flask",
20+
"components": {
21+
"twilightforest:flask_contents": {
22+
"potion": {
23+
"potion": "minecraft:awkward"
24+
},
25+
"doses": 3
26+
}
27+
}
28+
},
29+
{
30+
"type": "neoforge:components",
31+
"items": "twilightforest:greater_potion_flask",
32+
"components": {
33+
"twilightforest:flask_contents": {
34+
"potion": {
35+
"potion": "minecraft:awkward"
36+
},
37+
"doses": 3,
38+
"breakable": false
39+
}
40+
}
41+
}
42+
],
43+
[
44+
{
45+
"type": "neoforge:components",
46+
"items": "minecraft:potion",
47+
"components": {
48+
"minecraft:potion_contents": {
49+
"potion": "minecraft:thick"
50+
}
51+
}
52+
},
53+
{
54+
"type": "neoforge:components",
55+
"items": "twilightforest:brittle_potion_flask",
56+
"components": {
57+
"twilightforest:flask_contents": {
58+
"potion": {
59+
"potion": "minecraft:thick"
60+
},
61+
"doses": 3
62+
}
63+
}
64+
},
65+
{
66+
"type": "neoforge:components",
67+
"items": "twilightforest:greater_potion_flask",
68+
"components": {
69+
"twilightforest:flask_contents": {
70+
"potion": {
71+
"potion": "minecraft:thick"
72+
},
73+
"doses": 3,
74+
"breakable": false
75+
}
76+
}
77+
}
78+
],
79+
[
80+
{
81+
"type": "neoforge:components",
82+
"items": "minecraft:potion",
83+
"components": {
84+
"minecraft:potion_contents": {
85+
"potion": "minecraft:mundane"
86+
}
87+
}
88+
},
89+
{
90+
"type": "neoforge:components",
91+
"items": "twilightforest:brittle_potion_flask",
92+
"components": {
93+
"twilightforest:flask_contents": {
94+
"potion": {
95+
"potion": "minecraft:mundane"
96+
},
97+
"doses": 3
98+
}
99+
}
100+
},
101+
{
102+
"type": "neoforge:components",
103+
"items": "twilightforest:greater_potion_flask",
104+
"components": {
105+
"twilightforest:flask_contents": {
106+
"potion": {
107+
"potion": "minecraft:mundane"
108+
},
109+
"doses": 3,
110+
"breakable": false
111+
}
112+
}
113+
}
114+
]
115+
],
116+
"result": {
117+
"id": "exposure:developed_color_film"
118+
}
119+
}

0 commit comments

Comments
 (0)