public static bool PatchMushroomBoxMachineOutput(ref object __instance) { try { if (mod.Config.AutomationHarvestsGrantXP) { TapperAndMushroomQualityLogic.RewardMushroomBoxExp(mod); } var mushroomBox = mod.Helper.Reflection.GetProperty <StardewObject>(__instance, "Machine").GetValue(); if (!mod.Config.MushroomBoxQuality) { mushroomBox.heldObject.Value.quality.Value = 0; } else { mushroomBox.heldObject.Value.quality.Value = ForageFantasy.DetermineForageQuality(Game1.player); } return(true); } catch (Exception e) { mod.ErrorLog("There was an exception in a patch", e); return(true); } }
public static bool PatchTapperAndMushroomQuality(ref StardewObject __instance, ref Farmer who, ref bool justCheckingForActivity) { try { if (!justCheckingForActivity && __instance != null && __instance.minutesUntilReady <= 0 && __instance.heldObject != null && __instance.heldObject.Value != null) { if (TapperAndMushroomQualityLogic.IsTapper(__instance)) { TapperAndMushroomQualityLogic.RewardTapperExp(mod); if (mod.Config.TapperQualityOptions <= 0 && mod.Config.TapperQualityOptions > 4) { __instance.heldObject.Value.quality.Value = 0; return(true); } TerrainFeature terrain; who.currentLocation.terrainFeatures.TryGetValue(__instance.TileLocation, out terrain); if (terrain != null && terrain is Tree tree) { __instance.heldObject.Value.quality.Value = TapperAndMushroomQualityLogic.DetermineTapperQuality(mod, who, __instance, tree); } else { __instance.heldObject.Value.quality.Value = 0; } return(true); } if (TapperAndMushroomQualityLogic.IsMushroomBox(__instance)) { TapperAndMushroomQualityLogic.RewardMushroomBoxExp(mod); if (!mod.Config.MushroomBoxQuality) { __instance.heldObject.Value.quality.Value = 0; } else { __instance.heldObject.Value.quality.Value = ForageFantasy.DetermineForageQuality(who); } return(true); } } return(true); } catch (Exception e) { mod.ErrorLog("There was an exception in a patch", e); return(true); } }
public static void TryAddItemToPlayerInventory_Post(ref StardewObject container, ref bool __result) { try { // I can't reduce the quality of a non successfully harvested box here, // because it doesn't get called if the method throws a inventoryfull exception if (__result && TapperAndMushroomQualityLogic.IsMushroomBox(container)) { if (mod.Config.AutomationHarvestsGrantXP) { TapperAndMushroomQualityLogic.RewardMushroomBoxExp(mod); } } } catch (Exception e) { mod.ErrorLog("There was an exception in a patch", e); } }