From 8e44443395091fe9e015a05104f8a8e6671a0df3 Mon Sep 17 00:00:00 2001 From: Jacob Keller Date: Tue, 9 Apr 2024 17:46:41 -0700 Subject: [PATCH] initial build fixes for BetterJunimosForestry This attempts to fix the BetterJunimosForestry mod to work with Stardew Valley 1.6, though it is currently build-tested only. The big changes include: * switching to string IDs instead of numerical indexes * fixing many function references * re-wrote the fruit tree harvest logic entirely * removed a bunch of references to debris logic that appears to have been removed from Stardew Valley 1.6 * Update the target to net6.0, and update the ModBuildConfig and JSON references. * Various other fixes require to get things compiling * Fix mod content loading to load icons and scroll2.png Signed-off-by: Jacob Keller --- .../Abilities/ChopTreesAbility.cs | 2 +- .../Abilities/CollectDroppedObjectsAbility.cs | 28 ++++------- .../Abilities/CollectSeedsAbility.cs | 4 +- .../Abilities/FertilizeTreesAbility.cs | 10 ++-- .../Abilities/HarvestDebrisAbility.cs | 6 +-- .../Abilities/HarvestFruitTreesAbility.cs | 43 +++++------------ .../Abilities/HarvestGrass.cs | 2 +- .../Abilities/HoeAroundTreesAbility.cs | 47 ++++++------------- .../Abilities/PlantFruitTreesAbility.cs | 16 +++---- .../Abilities/PlantTreesAbility.cs | 18 +++---- .../BetterJunimosForestry.csproj | 7 +-- .../BetterJunimosForestry/ModEntry.cs | 6 +-- .../BetterJunimosForestry/Util.cs | 25 +++++----- 13 files changed, 83 insertions(+), 131 deletions(-) diff --git a/BetterJunimosForestry/BetterJunimosForestry/Abilities/ChopTreesAbility.cs b/BetterJunimosForestry/BetterJunimosForestry/Abilities/ChopTreesAbility.cs index 4564c56..23e9bd0 100644 --- a/BetterJunimosForestry/BetterJunimosForestry/Abilities/ChopTreesAbility.cs +++ b/BetterJunimosForestry/BetterJunimosForestry/Abilities/ChopTreesAbility.cs @@ -98,7 +98,7 @@ private static Vector2 GetToolPixelPosition(Vector2 tile) { return (tile * Game1.tileSize) + new Vector2(Game1.tileSize / 2f); } - public List RequiredItems() { + public List RequiredItems() { return new(); } diff --git a/BetterJunimosForestry/BetterJunimosForestry/Abilities/CollectDroppedObjectsAbility.cs b/BetterJunimosForestry/BetterJunimosForestry/Abilities/CollectDroppedObjectsAbility.cs index 9c8e00b..fad21fc 100644 --- a/BetterJunimosForestry/BetterJunimosForestry/Abilities/CollectDroppedObjectsAbility.cs +++ b/BetterJunimosForestry/BetterJunimosForestry/Abilities/CollectDroppedObjectsAbility.cs @@ -45,7 +45,7 @@ public bool IsActionAvailable(GameLocation location, Vector2 pos, Guid guid) { } public bool PerformAction(GameLocation location, Vector2 pos, JunimoHarvester junimo, Guid guid) { - var chest = Util.GetHutFromId(guid).output.Value; + var chest = Util.GetHutFromId(guid).GetOutputChest(); var (x, y) = pos; var up = new Vector2(x, y + 1); @@ -57,7 +57,7 @@ public bool PerformAction(GameLocation location, Vector2 pos, JunimoHarvester ju Vector2[] positions = { up, right, down, left }; foreach (var nextPos in positions) { if (!Util.IsWithinRadius(location, Util.GetHutFromId(guid), nextPos)) continue; - if (DebrisIndexAtTile(nextPos) > 0) { + if (DebrisIndexAtTile(nextPos) != "") { junimo.faceDirection(direction); return MoveDebrisFromTileToChest(nextPos, location, chest); } @@ -67,13 +67,13 @@ public bool PerformAction(GameLocation location, Vector2 pos, JunimoHarvester ju } protected bool IsDebrisAtTile(Vector2 tile) { - return DebrisIndexAtTile(tile) > 0; + return DebrisIndexAtTile(tile) != ""; } - protected int DebrisIndexAtTile(Vector2 tile) { + protected string DebrisIndexAtTile(Vector2 tile) { // Monitor.Log($"IsDebrisAtTile {tile}", LogLevel.Debug); if (Game1.currentLocation.debris is null) { - return -1; + return ""; } foreach (Debris d in Game1.currentLocation.debris) { foreach (Chunk c in d.Chunks) { @@ -83,16 +83,12 @@ protected int DebrisIndexAtTile(Vector2 tile) { // Monitor.Log($" Debris chunks: {d.Chunks.Count} type: {d.debrisType} at {dx},{dy}", LogLevel.Debug); if (d.item is not null) { // Monitor.Log($" {d.item.Name} [{d.item.ParentSheetIndex}]", LogLevel.Debug); - return d.item.ParentSheetIndex; - } - else { - // Monitor.Log($" non-item debris [{c.debrisType}]", LogLevel.Debug); - return c.debrisType; + return d.item.ItemId; } } } } - return 0; + return ""; } protected bool MoveDebrisFromTileToChest(Vector2 tile, GameLocation farm, Chest chest) { @@ -123,20 +119,14 @@ protected bool MoveDebrisFromTileToChest(Vector2 tile, GameLocation farm, Chest protected void MoveDebrisToChest(Debris d, GameLocation farm, Chest chest) { foreach (Chunk c in d.Chunks) { if (d.item is not null) { - SObject item = new SObject(d.item.ParentSheetIndex, 1); + SObject item = new SObject(d.item.ItemId, 1); Util.AddItemToChest(farm, chest, item); //Monitor.Log($" MoveDebrisToChest {d.item.Name} [{d.item.ParentSheetIndex}]", LogLevel.Debug); - } else { - SObject item = new SObject(c.debrisType, 1); - if (item.Name != "Error Item") { - Util.AddItemToChest(farm, chest, item); - //Monitor.Log($" MoveDebrisToChest {item.Name} [{c.debrisType}]", LogLevel.Debug); - } } } } - public List RequiredItems() { + public List RequiredItems() { return new(); } diff --git a/BetterJunimosForestry/BetterJunimosForestry/Abilities/CollectSeedsAbility.cs b/BetterJunimosForestry/BetterJunimosForestry/Abilities/CollectSeedsAbility.cs index 3610cda..5113755 100644 --- a/BetterJunimosForestry/BetterJunimosForestry/Abilities/CollectSeedsAbility.cs +++ b/BetterJunimosForestry/BetterJunimosForestry/Abilities/CollectSeedsAbility.cs @@ -51,7 +51,7 @@ private static bool IsHarvestableSeed(TerrainFeature t, string mode) if (t is not Tree tree) return false; if (tree.growthStage.Value != 0) return false; if (mode == Modes.Normal) return false; - if (mode == Modes.Forest && PlantTreesAbility.IsTileInPattern(t.currentTileLocation)) return false; + if (mode == Modes.Forest && PlantTreesAbility.IsTileInPattern(t.Tile)) return false; return true; } @@ -66,7 +66,7 @@ private static Vector2 GetToolPixelPosition(Vector2 tile) return tile * Game1.tileSize + new Vector2(Game1.tileSize / 2f); } - public List RequiredItems() + public List RequiredItems() { return new(); } diff --git a/BetterJunimosForestry/BetterJunimosForestry/Abilities/FertilizeTreesAbility.cs b/BetterJunimosForestry/BetterJunimosForestry/Abilities/FertilizeTreesAbility.cs index a2af849..ce4a1f7 100644 --- a/BetterJunimosForestry/BetterJunimosForestry/Abilities/FertilizeTreesAbility.cs +++ b/BetterJunimosForestry/BetterJunimosForestry/Abilities/FertilizeTreesAbility.cs @@ -10,7 +10,7 @@ namespace BetterJunimosForestry.Abilities { public class FertilizeTreesAbility : IJunimoAbility { - private const int tree_fertilizer = 805; + private const string tree_fertilizer = "805"; public string AbilityName() { return "FertilizeTrees"; @@ -23,18 +23,18 @@ public bool IsActionAvailable(GameLocation farm, Vector2 pos, Guid guid) { } public bool PerformAction(GameLocation farm, Vector2 pos, JunimoHarvester junimo, Guid guid) { - var chest = Util.GetHutFromId(guid).output.Value; - var foundItem = chest.items.FirstOrDefault(item => item is {ParentSheetIndex: tree_fertilizer}); + var chest = Util.GetHutFromId(guid).GetOutputChest(); + var foundItem = chest.Items.FirstOrDefault(item => item is {ItemId: tree_fertilizer}); if (foundItem == null) return false; if (farm.terrainFeatures[pos] is not Tree t) return false; - t.fertilize(farm); + t.fertilize(); Util.RemoveItemFromChest(chest, foundItem); return true; } - public List RequiredItems() { + public List RequiredItems() { return new() { tree_fertilizer }; } diff --git a/BetterJunimosForestry/BetterJunimosForestry/Abilities/HarvestDebrisAbility.cs b/BetterJunimosForestry/BetterJunimosForestry/Abilities/HarvestDebrisAbility.cs index d87d590..2813794 100644 --- a/BetterJunimosForestry/BetterJunimosForestry/Abilities/HarvestDebrisAbility.cs +++ b/BetterJunimosForestry/BetterJunimosForestry/Abilities/HarvestDebrisAbility.cs @@ -18,7 +18,7 @@ public class HarvestDebrisAbility : IJunimoAbility { private readonly FakeFarmer FakeFarmer = new(); private readonly Pickaxe FakePickaxe = new(); private readonly Axe FakeAxe = new(); - private readonly MeleeWeapon Scythe = new(47); + private readonly MeleeWeapon Scythe = new("47"); internal HarvestDebrisAbility(IMonitor Monitor) { this.Monitor = Monitor; @@ -93,7 +93,7 @@ public bool PerformAction(GameLocation location, Vector2 pos, JunimoHarvester ju if (IsWeed(item)) { UseToolOnTile(Scythe, nextPos, location); - item.performToolAction(Scythe, location); + item.performToolAction(Scythe); location.removeObject(nextPos, false); } @@ -123,7 +123,7 @@ private static Vector2 GetToolPixelPosition(Vector2 tile) { return tile * Game1.tileSize + new Vector2(Game1.tileSize / 2f); } - public List RequiredItems() { + public List RequiredItems() { return new(); } diff --git a/BetterJunimosForestry/BetterJunimosForestry/Abilities/HarvestFruitTreesAbility.cs b/BetterJunimosForestry/BetterJunimosForestry/Abilities/HarvestFruitTreesAbility.cs index 8a35283..96dfb2c 100644 --- a/BetterJunimosForestry/BetterJunimosForestry/Abilities/HarvestFruitTreesAbility.cs +++ b/BetterJunimosForestry/BetterJunimosForestry/Abilities/HarvestFruitTreesAbility.cs @@ -22,7 +22,7 @@ public string AbilityName() { } private static bool IsHarvestableFruitTree(TerrainFeature tf) { - return tf is FruitTree tree && tree.fruitsOnTree.Value > 0; + return tf is FruitTree tree && tree.fruit.Any(); } public bool IsActionAvailable(GameLocation location, Vector2 pos, Guid guid) { @@ -61,40 +61,21 @@ public bool PerformAction(GameLocation location, Vector2 pos, JunimoHarvester ju return false; } - /// Harvest fruit from a FruitTree and update the tree accordingly. - private static SObject GetFruitFromTree(FruitTree tree) { - if (tree.fruitsOnTree.Value == 0) - return null; - - var quality = 0; - if (tree.daysUntilMature.Value <= -112) - quality = 1; - if (tree.daysUntilMature.Value <= -224) - quality = 2; - if (tree.daysUntilMature.Value <= -336) - quality = 4; - if (tree.struckByLightningCountdown.Value > 0) - quality = 0; - - tree.fruitsOnTree.Value --; - - var result = new SObject(Vector2.Zero, tree.struckByLightningCountdown.Value > 0 ? 382 : tree.indexOfFruit.Value, 1) { Quality = quality }; - return result; - } - private static bool HarvestFromTree(Vector2 pos, JunimoHarvester junimo, FruitTree tree) { - //shake the tree without it releasing any fruit - var fruitsOnTree = tree.fruitsOnTree.Value; - tree.fruitsOnTree.Value = 0; - tree.performUseAction(pos, junimo.currentLocation); - tree.fruitsOnTree.Value = fruitsOnTree; - var result = GetFruitFromTree(tree); - if (result == null) return false; - junimo.tryToAddItemToHut(result); + // do nothing if the tree has no item + if (!tree.fruit.Any()) + return false; + + // take all the item first + foreach (var item in tree.fruit) + junimo.tryToAddItemToHut(item); + tree.fruit.Clear(); + // shake the tree after + tree.performUseAction(pos); return true; } - public List RequiredItems() { + public List RequiredItems() { return new(); } diff --git a/BetterJunimosForestry/BetterJunimosForestry/Abilities/HarvestGrass.cs b/BetterJunimosForestry/BetterJunimosForestry/Abilities/HarvestGrass.cs index 0ff2cff..312bb74 100644 --- a/BetterJunimosForestry/BetterJunimosForestry/Abilities/HarvestGrass.cs +++ b/BetterJunimosForestry/BetterJunimosForestry/Abilities/HarvestGrass.cs @@ -49,7 +49,7 @@ protected bool TryHarvestGrass(Grass grass, GameLocation location, Vector2 tile) return true; } - public List RequiredItems() { + public List RequiredItems() { return new(); } diff --git a/BetterJunimosForestry/BetterJunimosForestry/Abilities/HoeAroundTreesAbility.cs b/BetterJunimosForestry/BetterJunimosForestry/Abilities/HoeAroundTreesAbility.cs index 41bb460..7f45e50 100644 --- a/BetterJunimosForestry/BetterJunimosForestry/Abilities/HoeAroundTreesAbility.cs +++ b/BetterJunimosForestry/BetterJunimosForestry/Abilities/HoeAroundTreesAbility.cs @@ -12,6 +12,7 @@ using StardewModdingAPI; using StardewValley.Buildings; using SObject = StardewValley.Object; +using StardewValley.GameData.Crops; // bits of this are from Tractor Mod; https://github.com/Pathoschild/StardewMods/blob/68628a40f992288278b724984c0ade200e6e4296/TractorMod/Framework/BaseAttachment.cs#L132 @@ -20,8 +21,8 @@ namespace BetterJunimosForestry.Abilities public class HoeAroundTreesAbility : IJunimoAbility { private readonly IMonitor Monitor; - private static readonly List WildTreeSeeds = new() {292, 309, 310, 311, 891}; - private static readonly Dictionary> cropSeasons = new(); + private static readonly List WildTreeSeeds = new() {"292", "309", "310", "311", "891"}; + private static readonly Dictionary> cropSeasons = new(); private const int SunflowerSeeds = 431; internal HoeAroundTreesAbility(IMonitor Monitor) @@ -30,7 +31,7 @@ internal HoeAroundTreesAbility(IMonitor Monitor) var seasons = new List {"spring", "summer", "fall", "winter"}; foreach (string season in seasons) { - cropSeasons[season] = new Dictionary(); + cropSeasons[season] = new Dictionary(); } } @@ -154,7 +155,7 @@ private bool SeedsAvailableToPlantThisTile(GameLocation location, JunimoHut hut, return false; } - Chest chest = hut.output.Value; + Chest chest = hut.GetOutputChest(); if (ModEntry.BJApi.GetCropMapForHut(guid) is null) { foundItem = PlantableSeed(location, chest); @@ -169,8 +170,8 @@ private bool SeedsAvailableToPlantThisTile(GameLocation location, JunimoHut hut, /// Get an item from the chest that is a crop seed, plantable in this season private Item PlantableSeed(GameLocation location, Chest chest, string cropType = null) { - List foundItems = chest.items.ToList().FindAll(item => - item is {Category: SObject.SeedsCategory} && !WildTreeSeeds.Contains(item.ParentSheetIndex) + List foundItems = chest.Items.ToList().FindAll(item => + item is {Category: SObject.SeedsCategory} && !WildTreeSeeds.Contains(item.ItemId) ); if (cropType == CropTypes.Trellis) @@ -194,7 +195,7 @@ private Item PlantableSeed(GameLocation location, Chest chest, string cropType = continue; } - var key = foundItem.ParentSheetIndex; + var key = foundItem.ItemId; try { if (cropSeasons[Game1.currentSeason][key]) @@ -204,22 +205,14 @@ private Item PlantableSeed(GameLocation location, Chest chest, string cropType = } catch (KeyNotFoundException) { - Monitor.Log($"Cache miss: {foundItem.ParentSheetIndex} {Game1.currentSeason}", LogLevel.Trace); - var crop = new Crop(foundItem.ParentSheetIndex, 0, 0); - cropSeasons[Game1.currentSeason][key] = crop.seasonsToGrowIn.Contains(Game1.currentSeason); + Monitor.Log($"Cache miss: {foundItem.ItemId} {Game1.currentSeason}", LogLevel.Trace); + Game1.cropData.TryGetValue(foundItem.ItemId, out CropData cropData); + cropSeasons[Game1.currentSeason][key] = cropData.Seasons.Contains(location.GetSeason()); if (cropSeasons[Game1.currentSeason][key]) { return foundItem; } } - - return foundItem; - - // - // Crop crop = new Crop(foundItem.ParentSheetIndex, 0, 0); - // if (crop.seasonsToGrowIn.Contains(Game1.currentSeason)) { - // return foundItem; - // } } return null; @@ -227,14 +220,14 @@ private Item PlantableSeed(GameLocation location, Chest chest, string cropType = private static bool IsTrellisCrop(Item item) { - var crop = new Crop(item.ParentSheetIndex, 0, 0); - return crop.raisedSeeds.Value; + Game1.cropData.TryGetValue(item.ItemId, out CropData cropData); + return cropData is not null && cropData.IsRaised; } private static bool CanHoeThisTile(GameLocation farm, Vector2 pos) { // is this tile plain dirt? - if (farm.isTileOccupied(pos)) return false; + if (farm.IsTileOccupiedBy(pos)) return false; if (Util.IsOccupied(farm, pos)) return false; if (!Util.CanBeHoed(farm, pos)) return false; if (farm.doesTileHaveProperty((int) pos.X, (int) pos.Y, "Diggable", "Back") != null) return true; @@ -275,21 +268,11 @@ private static bool UseToolOnTileManual(GameLocation location, Vector2 tileLocat location.playSound("hoeHit"); } - removeSquareDebrisFromTile(location, (int) tileLocation.X, (int) tileLocation.Y); location.checkForBuriedItem((int) tileLocation.X, (int) tileLocation.Y, false, false, Game1.player); return true; } - private static void removeSquareDebrisFromTile(GameLocation location, int tileX, int tileY) - { - location.debris.Filter( - debris => - debris.debrisType.Value != Debris.DebrisType.SQUARES - || (int) (debris.Chunks[0].position.X / 64.0) != tileX - || debris.chunkFinalYLevel / 64 != tileY); - } - - public List RequiredItems() + public List RequiredItems() { return new(); } diff --git a/BetterJunimosForestry/BetterJunimosForestry/Abilities/PlantFruitTreesAbility.cs b/BetterJunimosForestry/BetterJunimosForestry/Abilities/PlantFruitTreesAbility.cs index 3bfc45c..4f97a28 100644 --- a/BetterJunimosForestry/BetterJunimosForestry/Abilities/PlantFruitTreesAbility.cs +++ b/BetterJunimosForestry/BetterJunimosForestry/Abilities/PlantFruitTreesAbility.cs @@ -14,7 +14,7 @@ namespace BetterJunimosForestry.Abilities { public class PlantFruitTreesAbility : IJunimoAbility { - private List _RequiredItems; + private List _RequiredItems; private readonly IMonitor Monitor; internal PlantFruitTreesAbility(IMonitor Monitor) @@ -98,8 +98,8 @@ private static bool IsTileInPattern(Vector2 pos) public bool PerformAction(GameLocation location, Vector2 pos, JunimoHarvester junimo, Guid guid) { var hut = Util.GetHutFromId(guid); - var chest = hut.output.Value; - var foundItem = chest.items.FirstOrDefault(item => item != null && RequiredItems().Contains(item.ParentSheetIndex)); + var chest = hut.GetOutputChest(); + var foundItem = chest.Items.FirstOrDefault(item => item != null && RequiredItems().Contains(item.ItemId)); if (foundItem == null) return false; var up = new Vector2(pos.X, pos.Y + 1); @@ -110,19 +110,19 @@ public bool PerformAction(GameLocation location, Vector2 pos, JunimoHarvester ju Vector2[] positions = {up, right, down, left}; if (!positions.Where(nextPos => Util.IsWithinRadius(location, hut, pos)) .Where(nextPos => ShouldPlantFruitTreeOnTile(location, hut, nextPos)) - .Any(nextPos => Plant(location, nextPos, foundItem.ParentSheetIndex))) return false; + .Any(nextPos => Plant(location, nextPos, foundItem.ItemId))) return false; Util.RemoveItemFromChest(chest, foundItem); return true; } - private static bool Plant(GameLocation farm, Vector2 pos, int index) + private static bool Plant(GameLocation farm, Vector2 pos, string id) { if (farm.terrainFeatures.Keys.Contains(pos)) { return false; } - var tree = new FruitTree(index, ModEntry.Config.PlantFruitTreesSize); + var tree = new FruitTree(id, ModEntry.Config.PlantFruitTreesSize); farm.terrainFeatures.Add(pos, tree); if (!Utility.isOnScreen(Utility.Vector2ToPoint(pos), 64, farm)) return true; @@ -132,11 +132,11 @@ private static bool Plant(GameLocation farm, Vector2 pos, int index) return true; } - public List RequiredItems() + public List RequiredItems() { // this is heavy, cache it if (_RequiredItems is not null) return _RequiredItems; - var saplings = Game1.objectInformation.Where(pair => pair.Value.Split('/')[0].Contains("Sapling")); + var saplings = Game1.objectData.Where(pair => pair.Value.Name.Contains("Sapling")); _RequiredItems = (from kvp in saplings select kvp.Key).ToList(); return _RequiredItems; } diff --git a/BetterJunimosForestry/BetterJunimosForestry/Abilities/PlantTreesAbility.cs b/BetterJunimosForestry/BetterJunimosForestry/Abilities/PlantTreesAbility.cs index a7cf668..8d0cf65 100644 --- a/BetterJunimosForestry/BetterJunimosForestry/Abilities/PlantTreesAbility.cs +++ b/BetterJunimosForestry/BetterJunimosForestry/Abilities/PlantTreesAbility.cs @@ -63,10 +63,10 @@ public bool IsActionAvailable(GameLocation location, Vector2 pos, Guid guid) public bool PerformAction(GameLocation location, Vector2 pos, JunimoHarvester junimo, Guid guid) { - var hut = Util.GetHutFromId(guid); - var chest = hut.output.Value; - var foundItem = chest.items.FirstOrDefault(item => - item != null && Util.WildTreeSeeds.Keys.Contains(item.ParentSheetIndex)); + JunimoHut hut = Util.GetHutFromId(guid); + var chest = hut.GetOutputChest(); + var foundItem = chest.Items.FirstOrDefault(item => + item != null && Util.WildTreeSeeds.Keys.Contains(item.ItemId)); if (foundItem == null) return false; var (x, y) = pos; @@ -80,7 +80,7 @@ public bool PerformAction(GameLocation location, Vector2 pos, JunimoHarvester ju { if (!Util.IsWithinRadius(location, hut, nextPos)) continue; if (!ShouldPlantWildTreeHere(location, hut, nextPos)) continue; - if (!Plant(location, nextPos, foundItem.ParentSheetIndex)) continue; + if (!Plant(location, nextPos, foundItem.ItemId)) continue; Util.RemoveItemFromChest(chest, foundItem); return true; } @@ -118,7 +118,7 @@ private static bool Plantable(GameLocation location, Vector2 pos) { // is something standing on it? an impassable building? a terrain feature? // we want to use the game's occupied check, but also allow for un-hoeing empty hoedirt - if (location.isTileOccupied(pos) && !Util.IsHoed(location, pos)) return false; + if (location.IsTileOccupiedBy(pos) && !Util.IsHoed(location, pos)) return false; if (Util.HasCrop(location, pos)) return false; if (Util.IsOccupied(location, pos)) return false; @@ -127,7 +127,7 @@ private static bool Plantable(GameLocation location, Vector2 pos) return true; } - private bool Plant(GameLocation location, Vector2 pos, int index) + private bool Plant(GameLocation location, Vector2 pos, string id) { // check if the tile needs to be un-hoed if (location.terrainFeatures.TryGetValue(pos, out var feature)) @@ -144,7 +144,7 @@ private bool Plant(GameLocation location, Vector2 pos, int index) return false; } - var tree = new Tree(Util.WildTreeSeeds[index], ModEntry.Config.PlantWildTreesSize); + var tree = new Tree(Util.WildTreeSeeds[id], ModEntry.Config.PlantWildTreesSize); location.terrainFeatures.Add(pos, tree); if (Utility.isOnScreen(Utility.Vector2ToPoint(pos), 64, location)) @@ -158,7 +158,7 @@ private bool Plant(GameLocation location, Vector2 pos, int index) } - public List RequiredItems() + public List RequiredItems() { return Util.WildTreeSeeds.Keys.ToList(); } diff --git a/BetterJunimosForestry/BetterJunimosForestry/BetterJunimosForestry.csproj b/BetterJunimosForestry/BetterJunimosForestry/BetterJunimosForestry.csproj index f2a4a44..3286f9a 100644 --- a/BetterJunimosForestry/BetterJunimosForestry/BetterJunimosForestry.csproj +++ b/BetterJunimosForestry/BetterJunimosForestry/BetterJunimosForestry.csproj @@ -4,16 +4,17 @@ BetterJunimosForestry BetterJunimosForestry 1.0.7-beta9 - net5.0 + net6.0 latest - + + - ../../../hawkfalcon-Stardew-Mods/BetterJunimos/bin/Debug/net5.0/BetterJunimos.dll + ../../../HawkFalconStardewMods/BetterJunimos/bin/Debug/net6.0/BetterJunimos.dll False diff --git a/BetterJunimosForestry/BetterJunimosForestry/ModEntry.cs b/BetterJunimosForestry/BetterJunimosForestry/ModEntry.cs index 3080c4e..213a8c3 100644 --- a/BetterJunimosForestry/BetterJunimosForestry/ModEntry.cs +++ b/BetterJunimosForestry/BetterJunimosForestry/ModEntry.cs @@ -238,8 +238,8 @@ private void OnLaunched(object sender, GameLaunchedEventArgs e) { Monitor.Log($"Could not load Better Junimos API", LogLevel.Error); } - icons = Helper.Content.Load("assets/icons.png"); - scroll = Helper.Content.Load("assets/scroll2.png"); + icons = Helper.ModContent.Load("assets/icons.png"); + scroll = Helper.ModContent.Load("assets/scroll2.png"); // BJApi.RegisterJunimoAbility(new Abilities.LayPathsAbility(Monitor)); // Abilities now registered in OnSaveLoaded @@ -327,7 +327,7 @@ void OnDayStarted(object sender, DayStartedEventArgs e) { } // reset for rainy days, winter, or GMCM options change - Helper.Content.InvalidateCache(@"Characters\Junimo"); + Helper.GameContent.InvalidateCache(@"Characters\Junimo"); } /********* diff --git a/BetterJunimosForestry/BetterJunimosForestry/Util.cs b/BetterJunimosForestry/BetterJunimosForestry/Util.cs index 9a63e8b..3fdc1e9 100644 --- a/BetterJunimosForestry/BetterJunimosForestry/Util.cs +++ b/BetterJunimosForestry/BetterJunimosForestry/Util.cs @@ -24,13 +24,13 @@ public override Vector2 GetToolLocation(bool ignoreClick = false) } public static class Util { - internal static readonly Dictionary WildTreeSeeds = new() + internal static readonly Dictionary WildTreeSeeds = new() { - {292, 8}, // mahogany - {309, 1}, // acorn - {310, 2}, // maple - {311, 3}, // pine - {891, 7} // mushroom + {"292", "8"}, // mahogany + {"309", "1"}, // acorn + {"310", "2"}, // maple + {"311", "3"}, // pine + {"891", "7"} // mushroom }; /// Get whether a tile is blocked due to something it contains. @@ -44,7 +44,7 @@ public static bool IsOccupied(GameLocation location, Vector2 tile) return true; // objects & large terrain features - if (location.objects.ContainsKey(tile) || location.largeTerrainFeatures.Any(p => p.tilePosition.Value == tile)) + if (location.objects.ContainsKey(tile) || location.largeTerrainFeatures.Any(p => p.Tile == tile)) return true; // logs, boulders, etc @@ -62,11 +62,8 @@ public static bool IsOccupied(GameLocation location, Vector2 tile) } // buildings - if (location is BuildableGameLocation buildableLocation) - { - if (buildableLocation.buildings.Any(building => building.occupiesTile(tile))) + if (location.buildings.Any(building => building.occupiesTile(tile))) return true; - } // buildings from the map if (location.getTileIndexAt(Utility.Vector2ToPoint(tile), "Buildings") > -1) return true; @@ -221,19 +218,19 @@ public static JunimoHut GetHutFromPosition(Vector2 pos) { return null; } - public static void AddItemToChest(GameLocation farm, Chest chest, SObject item) { + public static void AddItemToChest(GameLocation farm, Chest chest, Item item) { Item obj = chest.addItem(item); if (obj == null) return; Vector2 pos = chest.TileLocation; for (int index = 0; index < obj.Stack; ++index) - Game1.createObjectDebris(item.ParentSheetIndex, (int)pos.X + 1, (int)pos.Y + 1, -1, item.Quality, 1f, farm); + Game1.createObjectDebris(item.ItemId, (int)pos.X + 1, (int)pos.Y + 1, -1, item.Quality, 1f, farm); } public static void RemoveItemFromChest(Chest chest, Item item) { if (ModEntry.Config.InfiniteJunimoInventory) { return; } item.Stack--; if (item.Stack == 0) { - chest.items.Remove(item); + chest.Items.Remove(item); } }