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

Prevent crashes when scaling a (multi)tool to zero #3

Merged
merged 1 commit into from
Dec 15, 2024
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: 3 additions & 1 deletion CommunityBugFixCollection/Locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"authors": [ "Banane9" ],
"messages": {
"CommunityBugFixCollection.Name": "Community Bug-Fix Collection",
"CommunityBugFixCollection.Description": "This mod contains fixes for various small Resonite Issues that are still open."
"CommunityBugFixCollection.Description": "This mod contains fixes for various small Resonite Issues that are still open.",

"CommunityBugFixCollection.NoZeroScaleToolRaycast": "Fixes Resonite Issue #98: World crashes when a (multi)tool is scaled to zero."
}
}
23 changes: 23 additions & 0 deletions CommunityBugFixCollection/NoZeroScaleToolRaycast.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Elements.Core;
using FrooxEngine;
using HarmonyLib;
using MonkeyLoader.Resonite;
using System;
using System.Collections.Generic;
using System.Text;

namespace CommunityBugFixCollection
{
[HarmonyPatch(typeof(Tool), nameof(Tool.GetHit))]
[HarmonyPatchCategory(nameof(NoZeroScaleToolRaycast))]
internal sealed class NoZeroScaleToolRaycast : ResoniteMonkey<NoZeroScaleToolRaycast>
{
public override bool CanBeDisabled => true;

private static bool Prepare() => Enabled;

[HarmonyPrefix]
private static bool GetHitPrefix(Tool __instance)
=> __instance.TipForward.IsValid() && __instance.TipForward != float3.Zero;
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ The issues fixed by this mod will be linked in the following list.
If any of them have been closed and not removed from the mod,
just disable them in the settings in the meantime.

* World crash when a (multi)tool is scaled to zero (https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/98)
Loading