Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update JoE to work with SdV 1.6 #59

Open
wants to merge 43 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
0657a3a
Update zh.json
mc-kaishixiaxue Aug 5, 2021
1db87e2
Update zh.json
mc-kaishixiaxue Aug 5, 2021
4d72676
[Hackswell] Updated build files to work with net5.0. Reduce warnings.…
Hackswell Jan 20, 2024
34617da
[RCB] Added coffee maker and worm bin to machine list.
Hackswell Feb 16, 2024
645114c
[Hackswell] Preliminary 1.6 compatability. See testplan.txt for what …
Hackswell Mar 24, 2024
defaa1a
[Hackswell] ArtifactSpotDigger also digs SeedSpots.
Hackswell Mar 24, 2024
485778a
[Hackswell] Furnaces working again.
Hackswell Mar 25, 2024
26401a0
no reflections commit
rhuanmartinuzzo Mar 25, 2024
0cea32f
Merge pull request #1 from tonhodamoon/develop16
Hackswell Mar 26, 2024
836a377
Merge pull request #5 from mc-kaishixiaxue/develop
Hackswell Mar 26, 2024
1861eeb
[Hackswell] FishingProbabilityBox should be working much better now. …
Hackswell Mar 27, 2024
bd9c2cc
Fixed fishing probabilities to account for duplicate entries, non-cat…
Sandman534 Apr 7, 2024
850d086
Merge pull request #15 from Sandman534/develop16
Hackswell Apr 8, 2024
756f61f
Updated probability code, accounted for Magic Bait, expanded probabil…
Sandman534 Apr 9, 2024
711478b
Fix AutoHarvest on Mod crops
Sandman534 Apr 13, 2024
24c2b19
Fixed Harvest Automation for mod crops
Sandman534 Apr 13, 2024
a75a7a2
[Hackswell] Too much stuff to describe. Need to make smaller commits!
Hackswell Apr 23, 2024
4b30363
Merge branch 'develop16' into AutoHarvestFix
Hackswell Apr 23, 2024
362765e
Merge pull request #18 from Sandman534/AutoHarvestFix
Hackswell Apr 23, 2024
5aef12c
Merge branch 'develop16' into develop16
Hackswell Apr 23, 2024
e964544
Merge pull request #17 from Sandman534/develop16
Hackswell Apr 23, 2024
a803844
[Hackswell] Added check for WateringCan.IsBottomless before decreasin…
Hackswell Apr 23, 2024
094f95c
[Hackswell] Re-ordered some small blocks of code. Moved GetAnimalLis…
Hackswell Apr 24, 2024
4cdf6b4
[Hackswell] Reworked timing/tick handling. Now configurable: Balance…
Hackswell Apr 25, 2024
53e2a89
[Hackswell] Streamlined Utils.GetObjectsWithin(). Changed some confi…
Hackswell Apr 25, 2024
c21856a
[Hackswell] Alpha5: Fixed auto-petting bug.
Hackswell Apr 26, 2024
54575ea
Updated Feature and Config
Sandman534 Apr 27, 2024
c0c4076
Merge pull request #24 from Sandman534/develop16
Hackswell Apr 27, 2024
1c1d806
Add option to harvest slime balls
Mimodin May 1, 2024
00c939d
Merge pull request #26 from BananaFruit476/feature/add_option_to_harv…
Hackswell May 2, 2024
fa755fb
[Hackswell] Add new config option 'TrashDisgustsNPCs'. Set to true b…
Hackswell May 2, 2024
586ccf4
Tons of work on Fish Probabilities
Sandman534 May 6, 2024
36008d7
Merge pull request #27 from Sandman534/develop16
Hackswell May 6, 2024
05dcc6f
[Hackswell] Removed Anvil from list of machines; don't automate that!…
Hackswell May 10, 2024
aa8762c
Minor Fixes
Sandman534 May 12, 2024
39a7390
Merge branch 'develop16' of https://github.com/Sandman534/JoysOfEffic…
Sandman534 May 12, 2024
b4c26d4
Merge pull request #29 from Sandman534/develop16
Hackswell May 13, 2024
198ab35
Create fr.json
CaranudLapin May 19, 2024
9d09312
Merge pull request #30 from CaranudLapin/patch-1
Hackswell May 19, 2024
4202209
[Hackswell] Fix auto-close chest after fishing. Merged French i18n fr…
Hackswell May 20, 2024
f84bbc9
[Hackswell] Forking and Renaming to GloryOfEfficiency.
Hackswell May 21, 2024
95e55ed
Probility Fixes
Sandman534 Jun 19, 2024
da6abc6
Merge pull request #34 from Sandman534/develop16
Hackswell Jul 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,7 @@ MigrationBackup/
.ionide/

*.DotSettings
codepage.txt
codepage.txt

# IDEA / JetBrains Rider
.idea/
19 changes: 10 additions & 9 deletions JoysOfEfficiency.sln → GloryOfEfficiency.sln
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29424.173
# Visual Studio Version 17
VisualStudioVersion = 17.9.34714.143
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JoysOfEfficiency", "JoysOfEfficiency\JoysOfEfficiency.csproj", "{0302444C-4190-4C5D-A873-A1F80267961A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GloryOfEfficiency", "GloryOfEfficiency\GloryOfEfficiency.csproj", "{0302444C-4190-4C5D-A873-A1F80267961A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -12,14 +12,15 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0302444C-4190-4C5D-A873-A1F80267961A}.Debug|Any CPU.ActiveCfg = Release|x86
{0302444C-4190-4C5D-A873-A1F80267961A}.Debug|Any CPU.Build.0 = Release|x86
{0302444C-4190-4C5D-A873-A1F80267961A}.Debug|x86.ActiveCfg = Debug|x86
{0302444C-4190-4C5D-A873-A1F80267961A}.Debug|x86.Build.0 = Debug|x86
{0302444C-4190-4C5D-A873-A1F80267961A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0302444C-4190-4C5D-A873-A1F80267961A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0302444C-4190-4C5D-A873-A1F80267961A}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{0302444C-4190-4C5D-A873-A1F80267961A}.Debug|x86.ActiveCfg = Debug|Any CPU
{0302444C-4190-4C5D-A873-A1F80267961A}.Debug|x86.Build.0 = Debug|Any CPU
{0302444C-4190-4C5D-A873-A1F80267961A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0302444C-4190-4C5D-A873-A1F80267961A}.Release|Any CPU.Build.0 = Release|Any CPU
{0302444C-4190-4C5D-A873-A1F80267961A}.Release|x86.ActiveCfg = Release|x86
{0302444C-4190-4C5D-A873-A1F80267961A}.Release|x86.Build.0 = Release|x86
{0302444C-4190-4C5D-A873-A1F80267961A}.Release|x86.ActiveCfg = Release|Any CPU
{0302444C-4190-4C5D-A873-A1F80267961A}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
using System.Collections.Generic;
using System.Linq;
using JoysOfEfficiency.Core;
using JoysOfEfficiency.Utils;
using GloryOfEfficiency.Core;
using GloryOfEfficiency.Utils;
using Microsoft.Xna.Framework;
using Netcode;
using StardewModdingAPI;
using StardewValley;
using StardewValley.Buildings;
using StardewValley.Characters;
using StardewValley.Extensions;
using StardewValley.Tools;

namespace JoysOfEfficiency.Automation
namespace GloryOfEfficiency.Automation
{
internal class AnimalAutomation
{
private static IReflectionHelper Reflection => InstanceHolder.Reflection;
private static Config Config => InstanceHolder.Config;

private static readonly Logger Logger = new Logger("AnimalAutomation");
Expand All @@ -26,8 +24,8 @@ public static void LetAnimalsInHome()
{
FarmAnimal animal = kv.Value;
Logger.Log(
$"Warped {animal.displayName}({animal.shortDisplayType()}) to {animal.displayHouse}@[{animal.homeLocation.X}, {animal.homeLocation.Y}]");
animal.warpHome(farm, animal);
$"Warped {animal.displayName}({animal.shortDisplayType()}) to {animal.displayHouse}@[{animal.home.animalDoor.X}, {animal.home.animalDoor.Y}]");
animal.warpHome();
}
}

Expand All @@ -49,34 +47,18 @@ public static void AutoOpenAnimalDoor()
Farm farm = Game1.getFarm();
foreach (Building building in farm.buildings)
{
switch (building)
switch (building.buildingType.Value)
{
case Coop coop:
case "Coop":
case "Barn":
{
if (coop.indoors.Value is AnimalHouse house)
if (building.indoors.Value is AnimalHouse house)
{
if (house.animals.Any() && !coop.animalDoorOpen.Value)
if (house.animals.Any() && !building.animalDoorOpen.Value)
{
Logger.Log($"Opening coop door @[{coop.animalDoor.X},{coop.animalDoor.Y}]");
coop.animalDoorOpen.Value = true;
Reflection.GetField<NetInt>(coop, "animalDoorMotion").SetValue(new NetInt(-2));
building.ToggleAnimalDoor(Game1.player);
}
}

break;
}
case Barn barn:
{
if (barn.indoors.Value is AnimalHouse house)
{
if (house.animals.Any() && !barn.animalDoorOpen.Value)
{
Logger.Log($"Opening barn door @[{barn.animalDoor.X},{barn.animalDoor.Y}]");
barn.animalDoorOpen.Value = true;
Reflection.GetField<NetInt>(barn, "animalDoorMotion").SetValue(new NetInt(-3));
}
}

break;
}
}
Expand All @@ -88,32 +70,18 @@ public static void AutoCloseAnimalDoor()
Farm farm = Game1.getFarm();
foreach (Building building in farm.buildings)
{
switch (building)
switch (building.buildingType.Value)
{
case Coop coop:
case "Coop":
case "Barn":
{
if (coop.indoors.Value is AnimalHouse house)
if (building.indoors.Value is AnimalHouse house)
{
if (house.animals.Any() && coop.animalDoorOpen.Value)
if (house.animals.Any() && building.animalDoorOpen.Value)
{
coop.animalDoorOpen.Value = false;
Reflection.GetField<NetInt>(coop, "animalDoorMotion").SetValue(new NetInt(2));
building.ToggleAnimalDoor(Game1.player);
}
}

break;
}
case Barn barn:
{
if (barn.indoors.Value is AnimalHouse house)
{
if (house.animals.Any() && barn.animalDoorOpen.Value)
{
barn.animalDoorOpen.Value = false;
Reflection.GetField<NetInt>(barn, "animalDoorMotion").SetValue(new NetInt(2));
}
}

break;
}
}
Expand All @@ -132,8 +100,9 @@ public static void PetNearbyPets()
bool wasPet = WasPetToday(pet);
if (!wasPet)
{
Logger.Log($"Petted {(pet is Dog ? "Dog" : "Cat")}'{pet.Name}' @{pet.getTileLocationPoint()}");
Logger.Log($"Petted {(pet.petType.Value == "Dog" ? "Dog" : "Cat")}'{pet.Name}' @{pet.position}");
pet.checkAction(player, location); // Pet pet... lol

}
}
}
Expand All @@ -142,18 +111,18 @@ public static void PetNearbyAnimals()
{
int radius = Config.AutoPetRadius * Game1.tileSize;
Rectangle bb = Util.Expand(Game1.player.GetBoundingBox(), radius);
foreach (FarmAnimal animal in Util.GetAnimalsList(Game1.player))
foreach (FarmAnimal animal in GetAnimalsList(Game1.player))
{
if (!bb.Contains((int) animal.Position.X, (int) animal.Position.Y) || animal.wasPet.Value)
if (Game1.timeOfDay >= 1900 && !animal.isMoving())
{
continue;
}

if (Game1.timeOfDay >= 1900 && !animal.isMoving())
if (!bb.Contains((int) animal.Position.X, (int) animal.Position.Y) || animal.wasPet.Value)
{
continue;
}
Logger.Log($"Petted {animal.displayType}'{animal.Name}' @{animal.getTileLocationPoint()}");

Logger.Log($"Petted {animal.displayType}'{animal.Name}' @{animal.position}");
animal.pet(Game1.player);
}
}
Expand All @@ -162,10 +131,10 @@ public static void ShearingAndMilking(Farmer player)
{
int radius = InstanceHolder.Config.AnimalHarvestRadius * Game1.tileSize;
Rectangle bb = Util.Expand(player.GetBoundingBox(), radius);
foreach (FarmAnimal animal in Util.GetAnimalsList(player))
foreach (FarmAnimal animal in GetAnimalsList(player))
{
string lowerType = animal.type.Value.ToLower();
if (animal.currentProduce.Value < 0 || animal.age.Value < animal.ageWhenMature.Value ||
if (animal.currentProduce.Value is null || animal.isBaby() ||
player.CurrentTool == null || !animal.GetBoundingBox().Intersects(bb))
{
continue;
Expand All @@ -177,20 +146,21 @@ public static void ShearingAndMilking(Farmer player)
continue;

if (!player.addItemToInventoryBool(
new Object(Vector2.Zero, animal.currentProduce.Value, null, false, true, false, false)
{
Quality = animal.produceQuality.Value
}))
new StardewValley.Object(animal.currentProduce.Value,
animal.hasEatenAnimalCracker.Value ? 2 : 1,
false,
-1,
animal.produceQuality.Value)))
{
continue;
}

switch (player.CurrentTool)
{
case Shears _:
case Shears:
Shears.playSnip(player);
break;
case MilkPail _:
case MilkPail:
player.currentLocation.localSound("Milking");
DelayedAction.playSoundAfterDelay("fishingRodBend", 300);
DelayedAction.playSoundAfterDelay("fishingRodBend", 1200);
Expand All @@ -200,12 +170,8 @@ public static void ShearingAndMilking(Farmer player)

animal.doEmote(20);
Game1.playSound("coin");
animal.currentProduce.Value = -1;
if (animal.showDifferentTextureWhenReadyForHarvest.Value)
{
animal.Sprite.LoadTexture("Animals\\Sheared" + animal.type.Value);
}

animal.currentProduce.Value = null;
animal.ReloadTextureIfNeeded();
player.gainExperience(0, 5);
}
}
Expand All @@ -215,5 +181,27 @@ private static bool WasPetToday(Pet pet)
return pet.lastPetDay.ContainsKey(Game1.player.UniqueMultiplayerID) &&
pet.lastPetDay[Game1.player.UniqueMultiplayerID] == Game1.Date.TotalDays;
}


private static IEnumerable<FarmAnimal> GetAnimalsList(Character player)
{
HashSet<FarmAnimal> list = new HashSet<FarmAnimal>();
switch (player.currentLocation)
{
case Farm farm:
{
list.AddRange(farm.animals.Values);
break;
}

case AnimalHouse house:
{
list.AddRange(house.animals.Values);
break;
}
}
return list;
}

}
}
}
Loading