Skip to content

Commit 60a85b2

Browse files
committed
Update for compatibility with SDV 1.6.9 and later.
NOTE: Some features (esp. use of terrain features by bots) may not work properly in multiplayer SDV.
1 parent 8394b2f commit 60a85b2

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

Farmtronics/Bot/BotObject.cs

+6-6
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public BotObject(Vector2 tileLocation, GameLocation location = null) : base(tile
121121
}
122122

123123
private void PerformOtherPlayerAction() {
124-
var farmer = Game1.getFarmerMaybeOffline(owner.Value);
124+
var farmer = Game1.GetPlayer(owner.Value);//getFarmerMaybeOffline(owner.Value);
125125
var name = farmer.Name;
126126
Game1.addHUDMessage(new HUDMessage($"{Name} belongs to {name}.", HUDMessage.error_type));
127127
}
@@ -233,9 +233,9 @@ public bool Harvest() {
233233
ModEntry.instance.Monitor.Log("Harvesting: TerrainFeature");
234234

235235
var origPlayer = Game1.player;
236-
Game1.player = farmer;
236+
// ToDo, something like: Game1.player = farmer;
237237
bool result = feature.performUseAction(tileLocation);
238-
Game1.player = origPlayer;
238+
// ToDo, something like: Game1.player = origPlayer;
239239
return result;
240240
} else if (loc.isObjectAtTile(tileLocation.GetIntX(), tileLocation.GetIntY())) {
241241
ModEntry.instance.Monitor.Log("Harvesting: Tile");
@@ -388,7 +388,7 @@ public bool doBotHarvestFromObject(StardewValley.Object what) {
388388

389389
what.AttemptAutoLoad(who);
390390
}
391-
MachineData? machineData = what.GetMachineData();
391+
MachineData machineData = what.GetMachineData();
392392
if (machineData != null && MachineDataUtility.TryGetMachineOutputRule(what, machineData, MachineOutputTrigger.OutputCollected, what.getOne(), null, what.Location, out MachineOutputRule outputCollectedRule, out _, out _, out _))
393393
what.OutputMachine(machineData, outputCollectedRule, what.lastInputItem.Value, null, what.Location, false);
394394
return true;
@@ -677,10 +677,10 @@ public void PickUpDebris(Farmtronics.Bot.BotFarmer farmer, GameTime gameTime) {
677677
for (int i = loc.debris.Count - 1; i >= 0; i--) {
678678
Debris d = loc.debris[i];
679679

680-
if (d == null || string.IsNullOrEmpty(d.itemId) || d.timeSinceDoneBouncing <= 0)
680+
if (d == null || string.IsNullOrEmpty(d.itemId.Value) || d.timeSinceDoneBouncing <= 0)
681681
continue; // Skip null or invalid debris
682682

683-
Item item = ItemRegistry.Create(d.itemId, 1, d.itemQuality);
683+
Item item = ItemRegistry.Create(d.itemId.Value, 1, d.itemQuality);
684684

685685
if (item == null || !farmer.couldInventoryAcceptThisItem(item))
686686
continue; // Skip if item is null or farmer can't accept it

Farmtronics/Bot/ModData.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ModData {
3232
public float PositionY { get; internal set; }
3333

3434
public static void Initialize() {
35-
_serializer ??= SaveGame.GetSerializer(typeof(NetObjectList<Item>));
35+
_serializer = new XmlSerializer(typeof(NetObjectList<Item>));
3636
}
3737

3838
private static string GetModDataValue(ModDataDictionary data, string key, string defaultValue = "") {
@@ -59,7 +59,7 @@ private string SerializeInventory(IList<Item> inventory) {
5959
// ModEntry.instance.Monitor.Log($"Serialized inventory: {xml}");
6060
return xml;
6161
}
62-
62+
6363
private NetObjectList<Item> DeserializeInventory(string inventoryXml) {
6464
if (string.IsNullOrEmpty(inventoryXml)) return null;
6565

Farmtronics/Farmtronics.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<TargetFramework>net6.0</TargetFramework>
66
<ModFolderName>Farmtronics</ModFolderName>
77
<BundleExtraAssemblies>ThirdParty</BundleExtraAssemblies>
8-
<ReleaseVersion>1.4</ReleaseVersion>
8+
<ReleaseVersion>1.4.1</ReleaseVersion>
99
</PropertyGroup>
1010

1111
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">

Farmtronics/M1/Filesystem/Disk.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ abstract class Disk {
55

66
public delegate void DiskActivityCallback(bool write);
77

8-
public DiskActivityCallback diskActivityCallback;
8+
public DiskActivityCallback diskActivityCallback = null;
99

1010
protected void ShowDiskLight(bool write) {
1111
if (diskActivityCallback != null) diskActivityCallback(write);

Farmtronics/M1/M1API.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ public static ValMap MeModule() {
582582
owner = Game1.player.displayName;
583583
} else {
584584
// for bots, get the owner name as follows:
585-
owner = Game1.getFarmerMaybeOffline(sh.bot.owner.Value).displayName;
585+
owner = Game1.GetPlayer(sh.bot.owner.Value).displayName;
586586
}
587587
return new Intrinsic.Result(owner);
588588
};

Farmtronics/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Name": "Farmtronics",
33
"Author": "Joe Strout",
4-
"Version": "1.4.0",
4+
"Version": "1.4.1",
55
"Description": "Adds a \"home computer\" and programmable bots!",
66
"UniqueID": "strout.farmtronics",
77
"EntryDll": "Farmtronics.dll",

0 commit comments

Comments
 (0)