Skip to content

Commit 32af87c

Browse files
committed
小改了配方
1 parent 3060adb commit 32af87c

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

src/main/java/top/ctnstudio/futurefood/api/recipe/ParticleColliderRecipe.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,29 @@
33
import net.minecraft.world.item.ItemStack;
44
import net.minecraft.world.item.crafting.Ingredient;
55

6-
public record ParticleColliderRecipe(Ingredient input1, Ingredient input2, ItemStack output,
6+
public record ParticleColliderRecipe(Ingredient input1, Ingredient input2,int input1Count,int input2Count, ItemStack output,
77
int energyCost, int processingTime) {
8-
public ParticleColliderRecipe(Ingredient input1, Ingredient input2, ItemStack output, int energyCost, int processingTime) {
8+
public ParticleColliderRecipe(Ingredient input1, Ingredient input2,int input1Count,int input2Count, ItemStack output, int energyCost, int processingTime) {
99
this.input1 = input1;
1010
this.input2 = input2;
11+
this.input1Count = input1Count;
12+
this.input2Count = input2Count;
1113
this.output = output.copy();
1214
this.energyCost = energyCost;
1315
this.processingTime = processingTime;
1416
}
1517

1618
public boolean matches(ItemStack inputStack1, ItemStack inputStack2) {
1719
// 检查两个输入是否匹配(顺序)
18-
return this.input1.test(inputStack1) && this.input2.test(inputStack2);
20+
return this.input1.test(inputStack1) && this.input2.test(inputStack2) && inputStack1.getCount() >= this.input1Count && inputStack2.getCount() >= this.input2Count;
1921
}
2022

21-
public boolean matchesReverse(ItemStack inputStack1, ItemStack inputStack2) {
22-
// 检查两个输入是否匹配(无序)
23-
return matches(inputStack1, inputStack2) || matches(inputStack2, inputStack1);
23+
public int getInputCount(int index) {
24+
return switch (index) {
25+
case 1 -> this.input1Count;
26+
case 2 -> this.input2Count;
27+
default -> 0;
28+
};
2429
}
2530

2631
@Override

src/main/java/top/ctnstudio/futurefood/api/recipe/ParticleColliderRecipeManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ public static void initRecipes(){
1919
addRecipe(new ParticleColliderRecipe(
2020
Ingredient.of(Items.IRON_INGOT),
2121
Ingredient.of(Items.GOLD_INGOT),
22+
1,1,
2223
new ItemStack(Items.DIAMOND, 1),
2324
0, // 能量消耗
2425
200 // 处理时间 (ticks)
2526
));
2627
addRecipe(new ParticleColliderRecipe(
2728
Ingredient.of(Items.GOLD_INGOT),
2829
Ingredient.of(Items.GOLD_INGOT),
30+
1,1,
2931
new ItemStack(Items.DIAMOND, 2),
3032
100, // 能量消耗
3133
100 // 处理时间 (ticks)
@@ -37,7 +39,7 @@ public static void addRecipe(ParticleColliderRecipe recipe) {
3739

3840
public static Optional<ParticleColliderRecipe> findRecipe(ItemStack input1, ItemStack input2){
3941
return RECIPES.stream()
40-
.filter(recipe -> recipe.matchesReverse(input1, input2))// 检查两个输入是否匹配(无序)
42+
.filter(recipe -> recipe.matches(input1, input2))// 检查两个输入是否匹配(无序)
4143
.findFirst();
4244
}
4345

src/main/java/top/ctnstudio/futurefood/common/block/tile/ParticleColliderBlockEntity.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,14 @@ private void processRecipe() {
148148

149149
if (recipe.isEmpty()) {
150150
progressTick = 0;
151+
maxWorkTick = 0;
151152
return;
152153
}
153154

154155
ParticleColliderRecipe currentRecipe = recipe.get();
155156
if (!canCraft(currentRecipe)) {
156157
progressTick = 0;
158+
maxWorkTick = 0;
157159
return;
158160
}
159161

@@ -208,8 +210,8 @@ private void craftItem(ParticleColliderRecipe recipe) {
208210
output.grow(result.getCount());
209211
}
210212

211-
itemHandler.extractItem(INPUT_SLOT_1, 1, false);
212-
itemHandler.extractItem(INPUT_SLOT_2, 1, false);
213+
itemHandler.extractItem(INPUT_SLOT_1, recipe.getInputCount(1), false);
214+
itemHandler.extractItem(INPUT_SLOT_2, recipe.getInputCount(2), false);
213215

214216
progressTick = 0;
215217
}

0 commit comments

Comments
 (0)