Skip to content

Commit 94a84d0

Browse files
committed
Allow seed items to change into different crops based on the soil they are planted on. #213
1 parent 8cb8f0c commit 94a84d0

File tree

1 file changed

+13
-0
lines changed
  • Common/src/main/java/net/darkhax/botanypots/data/recipes/crop

1 file changed

+13
-0
lines changed

Common/src/main/java/net/darkhax/botanypots/data/recipes/crop/BasicCrop.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,19 @@ public BasicCrop(ResourceLocation id, Ingredient seed, Set<String> soilCategorie
6666
@Override
6767
public boolean matchesLookup(Level level, BlockPos pos, BlockEntityBotanyPot pot, ItemStack placedStack) {
6868

69+
if (pot != null) {
70+
71+
final Soil soil = pot.getSoil();
72+
73+
// When a soil exists, check if the soil is valid first. This is slightly redundant but allows multiple
74+
// seeds with the same item to change crop type based on conditions such as soil by failing the lookup
75+
// stage and passing the lookup on to other candidates.
76+
if (soil != null && !BotanyPotHelper.canCropGrow(level, pos, pot, soil, this)) {
77+
78+
return false;
79+
}
80+
}
81+
6982
return this.seed.test(placedStack);
7083
}
7184

0 commit comments

Comments
 (0)