Move broken tool head drop from DamageItem to DestroyItem - #139
Move broken tool head drop from DamageItem to DestroyItem#139MetaflameDragon wants to merge 2 commits into
Conversation
|
Warning Review limit reached
Next review available in: 12 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe tool recovery patch now hooks ChangesTool recovery
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@SmithingPlus/ToolRecovery/ItemDamagedPatches.cs`:
- Around line 56-65: Update Prefix_DestroyItem so recovery does not create or
give a broken head until DestroyItem has actually succeeded; account for
CollectibleBehavior.OnDestroyItem cancellation through a post-success hook or
equivalent validation. Preserve the existing server-side and zero-durability
checks, and ensure canceled destruction leaves the original item state
unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 105d094f-d96e-4858-953a-c2b591a96f31
📒 Files selected for processing (1)
SmithingPlus/ToolRecovery/ItemDamagedPatches.cs
|
As per the auto-review, running the tool head drop code would be the cleanest within an I'm unsure about the reason behind why a patch was used previously, and wanted to submit only minimal changes, but given the suggestion, might as well move everything to a method override. I've never modded VS, but it seemed like a sensible implementation change. The behavior already exists and was checked for in the prefix patch, so I believe this should behave the same way. The change also includes a few small fixes regarding nullability to make the linter happy. I think the previous code relied on these assumptions already, so I just tweaked some Use this second commit as-is if the method override in |
Previously, the mod would drop a broken tool head whenever a tool was about to get destroyed by checking the expected durability loss before
DamageItemruns. With this change, it instead reacts to when the tool is destroyed by havingDestroyItemcalled.This PR retains the previous logic of checking for durability. This was a necessity in
DamageItem, but doing this inDestroyItemmeans that we check whether the tool was at 0 durability the moment it was destroyed. This means that the broken tool head won't drop if the item is destroyed early for another reason, though this check may also be undesirable at this point. If the tool head should drop even if the item is destroyed by other means, this durability check should also be removed.This fixes #138 (and, by extension, Mario90900/Toolsmith#49)