Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion CakeBuild/CakeBuild.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RunWorkingDirectory>$(MSBuildProjectDirectory)</RunWorkingDirectory>
</PropertyGroup>

Expand Down
7 changes: 7 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sdk": {
"version": "8.0.0",
"rollForward": "latestMajor",
"allowPrerelease": false
}
}
2 changes: 1 addition & 1 deletion resources/modinfo.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"authors": [ "Grifthegnome" ],
"contributors": [ "Professor Cupcake" ],
"description": "Adds dynamic evolving trail and roads. Backup your world before using!",
"version": "1.2.1",
"version": "1.3.0",
"dependencies": {
"game": "*"
}
Expand Down
17 changes: 13 additions & 4 deletions trailmodcupdate/src/Patches.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using HarmonyLib;
using System.Reflection;
using System.Diagnostics;
using Vintagestory.API.Common;
using Vintagestory.API.Common.Entities;
using Vintagestory.GameContent;
using Vintagestory.API.MathTools;
using System;
using Vintagestory.API.Client;
using System.Linq;
using Vintagestory.API.Server;
using static Vintagestory.API.Server.EnumClientState;


namespace TrailMod
Expand Down Expand Up @@ -46,8 +47,16 @@ static void OnEntityCollideOverride(Block __instance, IWorldAccessor world, Enti
if (entity is not EntityAgent)
return;

//Only run trail logic within 100 blocks of a player.
if (entity.minHorRangeToClient > 100)
const int playerRangeCap = 100;
var validStates = new[] { Playing, Connected };

var onlinePlayersInRange = world.AllOnlinePlayers.Where(player =>
player is IServerPlayer serverPlayer
&& validStates.Contains(serverPlayer.ConnectionState)
&& entity.Pos.InRangeOf(player.Entity.Pos, playerRangeCap * playerRangeCap));

//Only run trail logic within 100 blocks of any online player.
if (!onlinePlayersInRange.Any())
return;

if ( entity is EntityPlayer )
Expand Down
2 changes: 1 addition & 1 deletion trailmodcupdate/trailmodcupdate.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<OutputPath>bin\$(Configuration)\Mods\mod</OutputPath>
</PropertyGroup>
Expand Down