Skip to content

perf: rewrite food on meat hooks, baking trays and troughs only when it would look different - #126

Merged
XxFran10xX merged 4 commits into
mainfrom
perf/meat-hook-tick
Nov 6, 2026
Merged

XxFran10xX merged 4 commits into
mainfrom
perf/meat-hook-tick

Conversation

@XxFran10xX

@XxFran10xX XxFran10xX commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

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):

  • 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).

🤖 Generated with Claude Code

XxFran10xX and others added 3 commits November 5, 2026 11:41
…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>
@coderabbitai

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

  • Trigger review

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.

Changes: Food aging and cooking updates

Layer / File(s) Summary
Slot-specific food rechecks
src/main/java/net/tfminecraft/cooking/utils/*, src/test/java/net/tfminecraft/cooking/utils/SlotAgingTest.java
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.
Furniture timer aging integration
src/main/java/net/tfminecraft/cooking/{baking/BakingTrayAging.java,hook/MeatHookHandler.java,trough/TroughAging.java}, src/test/java/net/tfminecraft/cooking/{baking/BakingTrayCoverageTest.java,carve/CarvingAndMeatHookCoverageTest.java,trough/TroughCoverageTest.java}
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 bake-time persistence
src/main/java/net/tfminecraft/cooking/oven/OvenCavityManager.java, src/test/java/net/tfminecraft/cooking/oven/OvenCoverageTest.java
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.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Sequence Diagram(s)

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.

Share

Recent review info

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: 448c2960-0c92-48e8-8388-26c66248b37b
Commits

Reviewing files that changed from the base of the PR and between bf83d09 and 6ce18c1.

Files selected for processing: 13

  • src/main/java/net/tfminecraft/cooking/baking/BakingTrayAging.java
  • src/main/java/net/tfminecraft/cooking/carve/CarveHandler.java
  • src/main/java/net/tfminecraft/cooking/hook/MeatHookHandler.java
  • src/main/java/net/tfminecraft/cooking/oven/OvenCavityManager.java
  • src/main/java/net/tfminecraft/cooking/trough/TroughAging.java
  • src/main/java/net/tfminecraft/cooking/utils/FoodScan.java
  • src/main/java/net/tfminecraft/cooking/utils/ItemRef.java
  • src/main/java/net/tfminecraft/cooking/utils/SlotAging.java
  • src/test/java/net/tfminecraft/cooking/baking/BakingTrayCoverageTest.java
  • src/test/java/net/tfminecraft/cooking/carve/CarvingAndMeatHookCoverageTest.java
  • src/test/java/net/tfminecraft/cooking/oven/OvenCoverageTest.java
  • src/test/java/net/tfminecraft/cooking/trough/TroughCoverageTest.java
  • src/test/java/net/tfminecraft/cooking/utils/SlotAgingTest.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@github-actions github-actions Bot added the size:L 100-499 effective changed lines (tests excluded in mixed PRs). label Nov 5, 2026
@XxFran10xX
XxFran10xX marked this pull request as ready for review November 6, 2026 14:27
@XxFran10xX

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Action performed

Full review finished.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Nov 6, 2026
…s made Hot

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@XxFran10xX
XxFran10xX merged commit 46458b5 into main Nov 6, 2026
3 checks passed
@XxFran10xX
XxFran10xX deleted the perf/meat-hook-tick branch November 6, 2026 15:28
XxFran10xX added a commit that referenced this pull request Nov 6, 2026
…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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 effective changed lines (tests excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant