Skip to content

Commit

Permalink
Update for compatibility with SDV 1.6.9 and later.
Browse files Browse the repository at this point in the history
NOTE: Some features (esp. use of terrain features by bots) may not work properly in multiplayer SDV.
  • Loading branch information
JoeStrout committed Nov 7, 2024
1 parent 8394b2f commit 60a85b2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions Farmtronics/Bot/BotObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public BotObject(Vector2 tileLocation, GameLocation location = null) : base(tile
}

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

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

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

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

Item item = ItemRegistry.Create(d.itemId, 1, d.itemQuality);
Item item = ItemRegistry.Create(d.itemId.Value, 1, d.itemQuality);

if (item == null || !farmer.couldInventoryAcceptThisItem(item))
continue; // Skip if item is null or farmer can't accept it
Expand Down
4 changes: 2 additions & 2 deletions Farmtronics/Bot/ModData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ModData {
public float PositionY { get; internal set; }

public static void Initialize() {
_serializer ??= SaveGame.GetSerializer(typeof(NetObjectList<Item>));
_serializer = new XmlSerializer(typeof(NetObjectList<Item>));
}

private static string GetModDataValue(ModDataDictionary data, string key, string defaultValue = "") {
Expand All @@ -59,7 +59,7 @@ private string SerializeInventory(IList<Item> inventory) {
// ModEntry.instance.Monitor.Log($"Serialized inventory: {xml}");
return xml;
}

private NetObjectList<Item> DeserializeInventory(string inventoryXml) {
if (string.IsNullOrEmpty(inventoryXml)) return null;

Expand Down
2 changes: 1 addition & 1 deletion Farmtronics/Farmtronics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ModFolderName>Farmtronics</ModFolderName>
<BundleExtraAssemblies>ThirdParty</BundleExtraAssemblies>
<ReleaseVersion>1.4</ReleaseVersion>
<ReleaseVersion>1.4.1</ReleaseVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down
2 changes: 1 addition & 1 deletion Farmtronics/M1/Filesystem/Disk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ abstract class Disk {

public delegate void DiskActivityCallback(bool write);

public DiskActivityCallback diskActivityCallback;
public DiskActivityCallback diskActivityCallback = null;

protected void ShowDiskLight(bool write) {
if (diskActivityCallback != null) diskActivityCallback(write);
Expand Down
2 changes: 1 addition & 1 deletion Farmtronics/M1/M1API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ public static ValMap MeModule() {
owner = Game1.player.displayName;
} else {
// for bots, get the owner name as follows:
owner = Game1.getFarmerMaybeOffline(sh.bot.owner.Value).displayName;
owner = Game1.GetPlayer(sh.bot.owner.Value).displayName;
}
return new Intrinsic.Result(owner);
};
Expand Down
2 changes: 1 addition & 1 deletion Farmtronics/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "Farmtronics",
"Author": "Joe Strout",
"Version": "1.4.0",
"Version": "1.4.1",
"Description": "Adds a \"home computer\" and programmable bots!",
"UniqueID": "strout.farmtronics",
"EntryDll": "Farmtronics.dll",
Expand Down

0 comments on commit 60a85b2

Please sign in to comment.