You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf: rewrite food on meat hooks, baking trays and troughs only when it would look different - #126
Meat hook, baking tray and trough timers rebuilt and rewrote every food in their slots each second (model, lore, carve state, display item, hook display transform, furniture save) only to store the new clock. On Main at 15+ players that was ~11 s of main thread per hour (meat hooks alone ~5.5 s/h, spark 11-04).
Food ages by the wall clock from its stored clock, values and remainder, so the slots now use the inventory scan's rule (FoodScan, #124):
SlotAging writes a slot only for a new tag step, lost warmth, broken lore, a clock to set, or a rebuild that would differ (with the furniture's model). Otherwise the slot rests until a second before it can next look different. Any change to the item ends the rest, as do /cooking reload and /iareload.
Food with a sauce keeps the old every-second rewrite.
FoodScan.update takes the furniture id so the rebuild uses the furniture model.
Carving ages the roast to now before the cuts take its numbers (the roast left on the hook starts a new clock); before, those numbers were at most a second old.
The oven marks a baking tray dirty while its bake time runs, which the tray timer's per-second rewrite used to do for it.
Plates keep the old rewrite: adding a sauce copies the plated food onto a new clock and sauces only age when the food is rewritten.
No gameplay or visible change intended.
Tests
New SlotAgingTest: resting slots look exactly like the old every-second rewrite, with one write per visible change.
Carve aging test; skip tests for hook, tray and trough; oven save counts.
4 shipped-config/asset tests fail on Windows on unmodified main too.
Dev test
Dev (TFMCDev01, 11-05): hook roasts left untouched while resting, rewritten in the second they turn Stale/Rotten/Warm/cold; carving ages the roast first (cut matches); tray dough → loaves, bake Cooked/Burnt on schedule, bread taken out Hot; trough ejects rotten food on time; /cooking reload and /iareload mid-rest fine. Spark: MeatHookHandler 32 ms, TroughAging 20 ms, BakingTrayAging 16 ms over the hour with test furniture loaded. Not covered on Dev: bake time surviving a crash (unit test only).
…it would look different
The meat hook, baking tray and trough timers rebuilt and rewrote every food in
their slots each second (model, lore, carve state, display item, hook display
transform, furniture save) only to store the new clock and aged numbers. On
Main at 15+ players that was ~11 s of main thread per hour (meat hooks alone
5.5 s/h).
Food ages by the wall clock from its stored clock, values and remainder, so the
slots now use the inventory scan's rule (FoodScan, #124): SlotAging writes a
slot only for a new tag step, lost warmth, broken lore, a clock to set, or a
rebuild that would differ (with the furniture's model), and otherwise leaves it
resting until a second before it can next look different. Any change to the
item ends the rest, as do /cooking reload and /iareload (ItemRef.clearCache).
Food with a sauce keeps the old every-second rewrite.
Carving reads the roast's numbers into the cuts and starts the roast left on
the hook on a new clock, so it now ages the roast to now first; before, those
numbers were at most a second old.
Plates keep the old rewrite: adding a sauce copies the plated food onto a new
clock and sauces only age when the food is rewritten.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… any thread
Review: glazing relied on addOrModifyTrack aging the roast first; say it outright
like carving does. forgetAll may run from the ItemsAdder load event, so it now
moves a generation on instead of clearing the server thread's map.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: aging the roast before the glaze checks changed fire-pit glazing (a
roast gone off by the clock was refused); addOrModifyTrack already ages it
before the glaze track goes on, as before. The tray timer used to mark baking
trays dirty every second, which also saved the oven's per-slot bake time with
the minute autosave; the oven now marks the tray itself while that time runs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This repository does not receive automatic reviews because it has fewer than 10 stars.
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 7f4f6cb0-6798-4cd0-88c6-e3d50943acf1
No actionable comments were generated in the recent review.
Summary
Summary by CodeRabbit
Bug Fixes
Food in cooking furniture now avoids unnecessary updates while its appearance and freshness remain unchanged, and is checked again when it may need updating.
Carving a roast now accounts for its latest freshness before determining cut freshness.
Oven baking-time progress is saved even when no cooking or burning transition occurs.
Food aging now uses slot-specific recheck timing across furniture. Carving updates roast age before reading carve state. Oven tray ticks mark elapsed bake-time changes for saving.
SlotAging records unchanged items until their recheck time and invalidates records when the item changes, the time expires, or the item-reference cache is cleared. FoodScan passes furniture IDs when rebuilding food items. Tests cover recheck timing, updates, and invalidation.
Baking trays, meat hooks, and troughs now skip items that SlotAging reports as resting and use SlotAging.age for other items. Tests check that resting items do not trigger aging or furniture updates.
Roast age update before carving src/main/java/net/tfminecraft/cooking/carve/CarveHandler.java, src/test/java/net/tfminecraft/cooking/carve/CarvingAndMeatHookCoverageTest.java
tryCarve updates roast age before reading carve state. A test checks that elapsed freshness aging is applied before carving.
Oven tray ticks mark the tray as changed after increasing elapsed bake time. Tests check elapsed time and dirty marks when no baked-item render update occurs.
sequenceDiagram
participant BakingTrayAging
participant SlotAging
participant FoodScan
BakingTrayAging->>SlotAging: Check whether the slot item is resting
SlotAging-->>BakingTrayAging: Return the resting status
BakingTrayAging->>SlotAging: Age a non-resting item
SlotAging->>FoodScan: Update the item with its furniture ID
FoodScan-->>SlotAging: Return the update result and recheck time
Loading
Possibly related PRs
TF-Minecraft/Cooking#124: Adds the inventory food recheck schedule that this PR applies to furniture slots.
TF-Minecraft/Cooking#98: Clears the ItemRef template cache on reloads; this PR also invalidates resting-slot records when that cache is cleared.
Suggested reviewers:carolinebondhus, ryanbarlow97
Merge Risk: Minimal · previous review 6ce18
The change reduces unnecessary furniture-item rewrites and marks advancing bake times for saving. No actionable merge-blocking risk is established; normal build and test checks should still pass before merging.
- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
…it would look different (#126)
* perf: rewrite food on meat hooks, baking trays and troughs only when it would look different
The meat hook, baking tray and trough timers rebuilt and rewrote every food in
their slots each second (model, lore, carve state, display item, hook display
transform, furniture save) only to store the new clock and aged numbers. On
Main at 15+ players that was ~11 s of main thread per hour (meat hooks alone
5.5 s/h).
Food ages by the wall clock from its stored clock, values and remainder, so the
slots now use the inventory scan's rule (FoodScan, #124): SlotAging writes a
slot only for a new tag step, lost warmth, broken lore, a clock to set, or a
rebuild that would differ (with the furniture's model), and otherwise leaves it
resting until a second before it can next look different. Any change to the
item ends the rest, as do /cooking reload and /iareload (ItemRef.clearCache).
Food with a sauce keeps the old every-second rewrite.
Carving reads the roast's numbers into the cuts and starts the roast left on
the hook on a new clock, so it now ages the roast to now first; before, those
numbers were at most a second old.
Plates keep the old rewrite: adding a sauce copies the plated food onto a new
clock and sauces only age when the food is rewritten.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Age a glazed roast to now explicitly and let /iareload end rests from any thread
Review: glazing relied on addOrModifyTrack aging the roast first; say it outright
like carving does. forgetAll may run from the ItemsAdder load event, so it now
moves a generation on instead of clearing the server thread's map.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Keep glazing as it was and save oven bake time with the autosave
Review: aging the roast before the glaze checks changed fire-pit glazing (a
roast gone off by the clock was refused); addOrModifyTrack already ages it
before the glaze track goes on, as before. The tray timer used to mark baking
trays dirty every second, which also saved the oven's per-slot bake time with
the minute autosave; the oven now marks the tray itself while that time runs.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* test: bread taken from a resting tray slot is aged to now before it is made Hot
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
---------
Co-authored-by: XxFran10xX <318299142+XxFran10xX@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 46458b5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size:L100-499 effective changed lines (tests excluded in mixed PRs).
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Meat hook, baking tray and trough timers rebuilt and rewrote every food in their slots each second (model, lore, carve state, display item, hook display transform, furniture save) only to store the new clock. On Main at 15+ players that was ~11 s of main thread per hour (meat hooks alone ~5.5 s/h, spark 11-04).
Food ages by the wall clock from its stored clock, values and remainder, so the slots now use the inventory scan's rule (FoodScan, #124):
SlotAgingwrites a slot only for a new tag step, lost warmth, broken lore, a clock to set, or a rebuild that would differ (with the furniture's model). Otherwise the slot rests until a second before it can next look different. Any change to the item ends the rest, as do/cooking reloadand/iareload.FoodScan.updatetakes the furniture id so the rebuild uses the furniture model.No gameplay or visible change intended.
Tests
SlotAgingTest: resting slots look exactly like the old every-second rewrite, with one write per visible change.Dev test
Dev (TFMCDev01, 11-05): hook roasts left untouched while resting, rewritten in the second they turn Stale/Rotten/Warm/cold; carving ages the roast first (cut matches); tray dough → loaves, bake Cooked/Burnt on schedule, bread taken out Hot; trough ejects rotten food on time;
/cooking reloadand/iareloadmid-rest fine. Spark: MeatHookHandler 32 ms, TroughAging 20 ms, BakingTrayAging 16 ms over the hour with test furniture loaded. Not covered on Dev: bake time surviving a crash (unit test only).🤖 Generated with Claude Code