Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.101

- Allow everyone to gather loose flint, branches, and stones inside Protective Wards. Other pickables and ward protections are unchanged.

## 0.1.100

- Append active alternate biome names to the biome label beside the small minimap. The local `[Minimap] ShowAlternateBiomeName` setting defaults to true.
Expand Down
43 changes: 43 additions & 0 deletions Source/Compatibility/PublicBasicPickables.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using System;
using System.Reflection;
using BepInEx.Bootstrap;
using HarmonyLib;
using UnityEngine;

namespace PraetorisClient
{
internal static class PublicBasicPickables
{
internal const string ProtectiveWardsGuid = "shudnal.ProtectiveWards";

internal static void TryApply(Harmony harmony)
{
if (!Chainloader.PluginInfos.TryGetValue(ProtectiveWardsGuid, out BepInEx.PluginInfo plugin)) return;

try
{
MethodInfo target = AccessTools.DeclaredMethod(plugin.Instance.GetType(),
"BlockUnauthorizedWardInteraction", new[] { typeof(Component), typeof(Humanoid), typeof(bool) })
?? throw new MissingMethodException("ProtectiveWards.BlockUnauthorizedWardInteraction(Component, Humanoid, bool)");
harmony.Patch(target, prefix: new HarmonyMethod(typeof(PublicBasicPickables), nameof(AllowBasicPickable)));
PraetorisClientPlugin.Log.LogInfo("Protective Wards allows public flint, branch, and stone pickables.");
}
catch (Exception exception)
{
PraetorisClientPlugin.Log.LogWarning("Could not enable public basic pickables; ward protection remains unchanged: " + exception.Message);
}
}

private static bool AllowBasicPickable(Component __0, ref bool __result)
{
if (__0 is not Pickable pickable) return true;

string prefabName = Utils.GetPrefabName(pickable.gameObject);
if (prefabName != "Pickable_Flint" && prefabName != "Pickable_Branch" && prefabName != "Pickable_Stone") return true;

// Skip only Protective Wards' denial. Pickable.Interact still runs its normal checks and RPC.
__result = false;
return false;
}
}
}
4 changes: 3 additions & 1 deletion Source/Core/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ namespace PraetorisClient
[BepInDependency(Jotunn.Main.ModGuid)]
[BepInDependency(EpicLootApiBridge.PluginGuid, BepInDependency.DependencyFlags.SoftDependency)]
[BepInDependency("org.tristan.rcon", BepInDependency.DependencyFlags.SoftDependency)]
[BepInDependency(PublicBasicPickables.ProtectiveWardsGuid, BepInDependency.DependencyFlags.SoftDependency)]
[BepInDependency(ShippingPortDepartures.MwlGuid, BepInDependency.DependencyFlags.SoftDependency)]
[BepInDependency(Tombstones.TombstoneAccess.GroupsGuid, BepInDependency.DependencyFlags.SoftDependency)]

public class PraetorisClientPlugin : BaseUnityPlugin
{
private const string ModName = "PraetorisClient";
private const string ModVersion = "0.1.100";
private const string ModVersion = "0.1.101";
private const string Author = "warpalicious";
private const string ModGUID = Author + "." + ModName;
private const string EpicLootGuid = "randyknapp.mods.epicloot";
Expand Down Expand Up @@ -166,6 +167,7 @@ public void Awake()
RpcTraceTelemetry.Initialize();
ApplyHarmonyPatches(epicLootLoaded);
CraftyBoxesWardGuard.TryApply(_harmony);
PublicBasicPickables.TryApply(_harmony);
ShippingPortDepartures.Initialize(_harmony);
ProtectedLocationNoBuild.ApplyToLoadedLocations();
SocketMetricPatches.ApplyManualPatches(_harmony);
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "PraetorisClient",
"description": "Client-side Praetoris tools for Discord linking, creative server bridges, RPC tracing, socket metrics, and RPC probes.",
"version_number": "0.1.100",
"version_number": "0.1.101",
"website_url": "https://discord.gg/3aaru2VyHJ",
"dependencies": [
"denikson-BepInExPack_Valheim-5.4.2333",
Expand Down
2 changes: 1 addition & 1 deletion thunderstore.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ schemaVersion = "0.0.1"
[package]
namespace = "praetoris"
name = "PraetorisClient"
versionNumber = "0.1.98"
versionNumber = "0.1.101"
description = "Client-side Praetoris tools for Discord linking, creative server bridges, RPC tracing, socket metrics, and RPC probes."
websiteUrl = "https://discord.gg/3aaru2VyHJ"
containsNsfwContent = false
Expand Down
Loading