using HarmonyLib; using System.Collections.Generic; using System.Linq; using System.Reflection.Emit; using System.Text; using Vintagestory.API.Common; using Vintagestory.API.Config; using Vintagestory.GameContent; namespace SteadyGreenHouses.ModPatches { [HarmonyPatch] internal class BerryBush : ModSystem { //WORKS ? //A B TEST with and wiwout mod on 80 - works [HarmonyTranspiler] [HarmonyPatch(typeof(BlockEntityBerryBush), "CheckGrow")] static IEnumerable Transpiler(IEnumerable instructions) { var codes = new List(instructions); for (int i = 0; i < codes.Count; i++) { // Locate the sequence: temperature += 5 if (codes[i].opcode == OpCodes.Ldloc_S && codes[i + 1].opcode == OpCodes.Ldc_R4 && (float)codes[i + 1].operand == 5f && codes[i + 2].opcode == OpCodes.Add) { // Replace it with conds.Temperature = 20f; codes[i + 1].operand = 20f; codes[i + 2].opcode = OpCodes.Nop; } } return codes.AsEnumerable(); } //WORKKS [HarmonyPostfix] [HarmonyPatch(typeof(BlockEntityBerryBush), "GetBlockInfo")] static void Postfix(StringBuilder sb) { // Replace the '5' in the greenhouse temp bonus string string originalString = Lang.Get("greenhousetempbonus"); string modifiedString = originalString.Replace("5", "X"); // Modify the description if (sb.ToString().Contains(originalString)) { sb.Replace(originalString, modifiedString); } } } }