Jump to content

Help controlling climate of the greenhouses in Vintage Story. My mod worked for 1.21 but is not fully functional in 1.22.


Go to solution Solved by The Insanity God,

Recommended Posts

Posted

The goal of this mod is to set the temperatures of greenhouses to 20C all year long.

See attachments for my mod patches.  I THINK the BeeHives is still working exactly as it did in 1.21.  The SoilNutrition patch seems to correctly display the +X in the tooltip for the greenhouse bonus.

The two big problems I have are:

1) The Berry Bushes still seem to go dormant in winter in a greenhouse with this mod. I assume there is one other parameter I need to find and change.

2) The Fastforwardgrowth script looks like it should work in changing the greenhouse bonus, but it does not seem to stop the blockentityfarmland class from applying cold damage. I can't figure out if something is wrong in my code or that parameter just isn't being passed along to that class.

 

Any help on either item would be very appreciated!  My hope is I just missed a parameter somewhere...

FruitTree.cs SoilNut.cs BeeHives.cs BerryBush.cs FastForward.cs

Posted
18 minutes ago, The Insanity God said:

You forgot to mark the `FastForward` class itself with `[HarmonyPatch]`, resulting in the patch not being found.

oh damn.... if that was the problem this whole time, then I feel foolish... thank you!!!!  Let me compile and test....

  • 1 month later...
Posted

posting the latest version of my scripts here rather than creating another thread.  I seem to have another bug where the fruit tree script bypasses whether or not the fruit tree is actually in a greenhouse.  I can see why it's bypassing that, but am not really sure how to fix it.  This is because the actual vintage story code has one function that sets the temp bonus and checks if it's in a greenhouse at once.  My code just sets the output of the following function to a fixed 20C.

I suppose that ideally I'd detect if the greenhouse temp bonus was moved to 5C then force the output of that function to just a flat 20C.  ...I'm just not sure how to do that in the harmony patch syntax. @Nachie offered to take a look, so tell me if you know what to do.

Another possible bug that I've been observing in my own game is that the berry bushes are kept from going dormant by the greenhouse but seem to just freeze when fully grown and not produce fruit.  I'm not sure if this is a flaw in the mod or it's just slow.

BeeHives.cs BerryBush.cs FastForward.cs FruitTree.cs SoilNut.cs

Posted

OKAY after some digging what I'm seeing here...

You're *always* returning 20 for applyGreenhouseTempBonus, which normally either returns the current temperature or the current temperature plus 5. This causes fruit trees to always think they're in a 20C climate.

Is it possible to do the following? 

Quote

static void Postfix(ref float __result)
            {
                if (getGreenhouseTempBonus() == 5f) { 
                    // Change the returned number to 20
                    __result = 20f;
                }
            }

 

Posted
On 6/15/2026 at 9:20 PM, Nachie said:

OKAY after some digging what I'm seeing here...

You're *always* returning 20 for applyGreenhouseTempBonus, which normally either returns the current temperature or the current temperature plus 5. This causes fruit trees to always think they're in a 20C climate.

Is it possible to do the following? 

 

I'm sure it is.... BUT, I would need the right syntax to do this in harmony patch code. ...that's the part I don't know.  If I could directly write C# into the function, this would be done by now, haha.

Posted

I think I have a solution, but actually testing it thoroughly before deploying it will be a bit of a pain.  If I confirm it works as intended, I'll try to publish it this weekend:

 


namespace SteadyGreenHouses.ModPatches
{
    //WORKKS
    //A B TEST with and wiwout mod - works
    // TEST temp to high - works
    [HarmonyPatch]
    internal class FruitTree : ModSystem
    {

        [HarmonyPatch(typeof(FruitTreeRootBH), "applyGreenhouseTempBonus")]
        public class MyPostfixPatch
        {

            public static bool Prefix(ref float temp, float greenhouseTempBonus, FruitTreeRootBH __instance)
            {
                // If the condition is met, change the variable
                if (greenhouseTempBonus > 0f)
                {
                    temp = 15f; // Set the variable to something else
                }

                return true; // Return true to continue running the original method
            }

        }
    }
}

 

  • 2 weeks later...
Posted
On 6/18/2026 at 9:07 AM, Vexxvididu said:

I think I have a solution, but actually testing it thoroughly before deploying it will be a bit of a pain.  If I confirm it works as intended, I'll try to publish it this weekend:

 


namespace SteadyGreenHouses.ModPatches
{
    //WORKKS
    //A B TEST with and wiwout mod - works
    // TEST temp to high - works
    [HarmonyPatch]
    internal class FruitTree : ModSystem
    {

        [HarmonyPatch(typeof(FruitTreeRootBH), "applyGreenhouseTempBonus")]
        public class MyPostfixPatch
        {

            public static bool Prefix(ref float temp, float greenhouseTempBonus, FruitTreeRootBH __instance)
            {
                // If the condition is met, change the variable
                if (greenhouseTempBonus > 0f)
                {
                    temp = 15f; // Set the variable to something else
                }

                return true; // Return true to continue running the original method
            }

        }
    }
}

 

guess no luck with getting it to work as intended?

Posted
15 hours ago, VulkanicJ said:

guess no luck with getting it to work as intended?

sorry!  I admit I haven't gotten around to testing it yet... been busy and lazy...

But yeah, testing this is a huge pain since I have to spam time skip commands for in game years to see what the fruit trees will do.

Posted
15 hours ago, VulkanicJ said:

guess no luck with getting it to work as intended?

 

I confirmed it is not working yet.... I got the below error.  Not yet sure what is wrong.... I am not sure exactly what is wrong but think it might be that the harmonypatch syntax is not quite right for the type of variable that greenhouseTempBonus is... I will do more research but maybe somebody here will know what is wrong.

 

 ---> System.Exception: Parameter "greenhouseTempBonus" not found in method System.Single Vintagestory.GameContent.FruitTreeRootBH::applyGreenhouseTempBonus(System.Single temp)

 

  • 3 weeks later...
Posted (edited)
On 6/15/2026 at 3:51 PM, Vexxvididu said:

posting the latest version of my scripts here rather than creating another thread.

Just a heads up but this thread is marked as "Solved" so it's very easy to miss this thread.
 

On 7/3/2026 at 5:40 PM, Vexxvididu said:

I am not sure exactly what is wrong but think it might be that the harmonypatch syntax is not quite right for the type of variable that greenhouseTempBonus is... I will do more research but maybe somebody here will know what is wrong.


Syntax issue indeed: `greenhouseTempBonus` is a field and not a method parameter so you have to pass it differently... with triple underscore that is (so `___greenhouseTempBonus`) see the harmony docs for more info.

On a side note: in this case it might be better to change the result rather then the input (temp) that way you can avoid other patches that change the bonus of greenhouse from affecting you (currently if someone where to increase the bonus tom 10C then your code would make it be a static 25C instead of 20C)

public static bool Prefix(ref float __result, float ___greenhouseTempBonus)
{
    if (___greenhouseTempBonus > 0f) //check if we are in a greenhouse
    {
        //Overwrite result and skip original
        __result = 20f;
        return false;
    }

    return true; // Let the original method do it's thing
}

 

Edited by The Insanity God
  • Like 1
Posted
6 hours ago, The Insanity God said:

Just a heads up but this thread is marked as "Solved" so it's very easy to miss this thread.
 


Syntax issue indeed: `greenhouseTempBonus` is a field and not a method parameter so you have to pass it differently... with triple underscore that is (so `___greenhouseTempBonus`) see the harmony docs for more info.

On a side note: in this case it might be better to change the result rather then the input (temp) that way you can avoid other patches that change the bonus of greenhouse from affecting you (currently if someone where to increase the bonus tom 10C then your code would make it be a static 25C instead of 20C)

public static bool Prefix(ref float __result, float ___greenhouseTempBonus)
{
    if (___greenhouseTempBonus > 0f) //check if we are in a greenhouse
    {
        //Overwrite result and skip original
        __result = 20f;
        return false;
    }

    return true; // Let the original method do it's thing
}

 

THANK YOU again!  I really owe you one... or a few.

I knew it was something like this, but didn't know the exact terms and I admit I haven't had a ton of time to work on this.  I'll compile it now and try to get to testing this soon.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.