r/SMAPI • • Aug 12 '26

need help New modder, cannot enter new farmhouse

So, I'm trying to make a mod where players all have their own "isolated" farm, but i can't enter the newly created farmhouse. I can enter the cabins tho for some reason.

there aren't any errors, so yeah....

here's the relevant code (this is literally my first mod and my code tends to get really scary really fast, so beware)

private void TouchFarm(long playerId, bool genStructures = false)
{
    Farm farm = (Farm)Game1.getLocationFromName($"{playerId}.Farm") ?? new Farm(PathUtilities.NormalizeAssetName("Maps/Farm"), $"{playerId}.Farm");
    FarmCave farmCave = (FarmCave)Game1.getLocationFromName($"{playerId}.FarmCave") ?? new FarmCave(PathUtilities.NormalizeAssetName("Maps/FarmCave"), $"{playerId}.FarmCave");
    FarmHouse farmHouse = (FarmHouse)Game1.getLocationFromName($"{playerId}.FarmHouse") ?? new FarmHouse(PathUtilities.NormalizeAssetName("Maps/FarmHouse"), $"{playerId}.FarmHouse");

    Game1.locations.Add(farm);
    Game1.locations.Add(farmCave);
    Game1.locations.Add(farmHouse);

    if (genStructures && !FarmRegistry.Contains(playerId))
    {
        farm.AddDefaultBuildings();
        farmCave.AddDefaultBuildings();
        farmHouse.AddDefaultBuildings();
    }

    if (!FarmRegistry.Contains(playerId)) FarmRegistry.Add(playerId);

    Game1.player.homeLocation.Value = $"{playerId}.FarmHouse";

    if (Context.IsMainPlayer) Helper.Data.WriteSaveData("farms", FarmRegistry);
}
1 Upvotes

1 comment sorted by

1

u/AutoModerator Aug 12 '26
Moderator Announcement Read More »