Skip to content

Commit

Permalink
Merge pull request #3 from Miguel-Thewolf/modded_crop_fix
Browse files Browse the repository at this point in the history
Modded crop fix
  • Loading branch information
EienWolf authored Jun 1, 2024
2 parents e48ab3b + 01e597c commit 2a3708b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions BetterJunimos/Abilities/Base/PlantCropsAbility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ public bool PerformAction(GameLocation location, Vector2 pos, JunimoHarvester ju
private Item PlantableSeed(GameLocation location, Chest chest, string cropType=null) {
var foundItems = chest.Items.ToList().FindAll(item =>
item != null
&& (new StardewValley.Object(item.ItemId, 1)).Type == "Seeds"
//&& new StardewValley.Object(item.ItemId, 1).Type == "Seeds"
&& !(BetterJunimos.Config.JunimoImprovements.AvoidPlantingCoffee && item.ParentSheetIndex == Util.CoffeeId)
);

foundItems = foundItems.FindAll(item => IsCrop(item, location));
switch (cropType)
{
case CropTypes.Trellis:
Expand Down Expand Up @@ -117,6 +117,7 @@ private Item PlantableSeed(GameLocation location, Chest chest, string cropType=n
}
} catch (KeyNotFoundException)
{

// Monitor.Log($"Cache miss: {key} {Game1.currentSeason}", LogLevel.Debug);
var crop = new Crop(key, 0, 0, location);
cropSeasons[Game1.currentSeason][key] = crop.IsInSeason(location);
Expand All @@ -135,6 +136,12 @@ private bool IsTrellisCrop(Item item, GameLocation location) {
return crop.raisedSeeds.Value;
}

//Verify if the item is a crop seed
private bool IsCrop(Item item, GameLocation location) {
Crop crop = new Crop(item.ItemId, 0, 0, location);
return !crop.IsErrorCrop();
}

public List<string> RequiredItems() {
return new List<string> { ItemCategory.ToString() };
}
Expand Down

0 comments on commit 2a3708b

Please sign in to comment.