Skip to content

Commit 7f29c95

Browse files
authored
Merge pull request #16 from Asis2019/main
Fixed any item being insertable into seed mutator.
2 parents bb063c1 + 825fe4f commit 7f29c95

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/main/java/net/micaxs/smokeleafindustry/block/entity/HerbMutationBlockEntity.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.jetbrains.annotations.NotNull;
4040
import org.jetbrains.annotations.Nullable;
4141

42+
import java.util.List;
4243
import java.util.Optional;
4344

4445
public class HerbMutationBlockEntity extends BlockEntity implements MenuProvider {
@@ -54,9 +55,25 @@ protected void onContentsChanged(int slot) {
5455

5556
@Override
5657
public boolean isItemValid(int slot, @NotNull ItemStack stack) {
58+
List<HerbMutationRecipe> recipes = level.getRecipeManager().getAllRecipesFor(HerbMutationRecipe.Type.INSTANCE);
5759
return switch (slot) {
5860
case 0 -> stack.getCapability(ForgeCapabilities.FLUID_HANDLER_ITEM).isPresent();
59-
case 1 -> true;
61+
case 1 -> {
62+
for (HerbMutationRecipe recipe : recipes) {
63+
if (recipe.matches(new SimpleContainer(stack), level, 0)) {
64+
yield true;
65+
}
66+
}
67+
yield false;
68+
}
69+
case 2 -> {
70+
for (HerbMutationRecipe recipe : recipes) {
71+
if (recipe.matches(new SimpleContainer(stack), level, 1)) {
72+
yield true;
73+
}
74+
}
75+
yield false;
76+
}
6077
case 3 -> false; // Don't put stuff in output slot bro.
6178
default -> super.isItemValid(slot, stack);
6279
};

src/main/java/net/micaxs/smokeleafindustry/recipe/machines/HerbMutationRecipe.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ public boolean matches(SimpleContainer pSimpleContainer, Level pLevel) {
4646
return true;
4747
}
4848

49+
public boolean matches(SimpleContainer simpleContainer, Level level, int slot) {
50+
if (level.isClientSide() || slot >= 2) {
51+
return false;
52+
}
53+
return inputItems.get(slot).test(simpleContainer.getItem(0));
54+
}
55+
4956
public FluidStack getFluid() {
5057
return this.fluidStack;
5158
}
@@ -87,7 +94,7 @@ public RecipeType<?> getType() {
8794

8895
public static class Type implements RecipeType<HerbMutationRecipe> {
8996
public static final Type INSTANCE = new Type();
90-
public static final String ID = "herb_mutation";
97+
public static final String ID = "herb_mutation";
9198
}
9299

93100
public static class Serializer implements RecipeSerializer<HerbMutationRecipe> {

0 commit comments

Comments
 (0)