Skip to content

Commit

Permalink
Fix #1, update to 1.15
Browse files Browse the repository at this point in the history
  • Loading branch information
copygirl committed Jun 18, 2021
1 parent 9d69292 commit efcf2f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions FarmlandDropsSoil.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<AssemblyTitle>Farmland Drops Soil</AssemblyTitle>
<Description>Vintage Story mod that makes farmland have a chance to drop soil depending on nutrient levels</Description>
<Authors>copygirl</Authors>
<Version>1.2.0</Version>
<Version>1.4.0</Version>

<TargetFramework>net452</TargetFramework>
<TargetFramework>net461</TargetFramework>
<LangVersion>latest</LangVersion>

</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions resources/modinfo.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"type": "code",
"name": "Farmland Drops Soil",
"version": "1.3.0",
"version": "1.4.0",

"description": "Farmland has a change to drop soil depending on nutrient levels",
"website": "https://www.vintagestory.at/forums/topic/1209-farmland-drops-soil-v120/",
"authors": [ "copygirl" ],

"dependencies": {
"game": "*"
"game": "1.15.0-pre.3"
}
}
7 changes: 4 additions & 3 deletions src/FarmlandDropsSoilBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ public override ItemStack[] GetDrops(
// Prevent other behaviors from running after this one.
handling = EnumHandling.PreventSubsequent;

// Get the lowest nutrient value (out of N, P and K) relative
// to the farmland's default nutrient levels (its fertility).
var nutrients = farmland.Nutrients.Min() / farmland.OriginalFertility;
// Divide each type of nutrient (N, P and K) by its original, "full"
// fertility to get a value from 0 to 1. Then pick the lowest one.
var nutrients = farmland.Nutrients.Zip(farmland.OriginalFertility,
(current, original) => current / original).Min();

// If this nutrient is below 95%, there is a chance the soil won't drop.
if ((nutrients < 0.95) && (world.Rand.NextDouble() > nutrients))
Expand Down

0 comments on commit efcf2f3

Please sign in to comment.