Перейти к содержимому
Mineforgian

Smart item deleter V2

Smart Item Deleter v2 is a server-side optimization mod designed to automatically clean up dropped item entities when the item count exceeds a defined threshold.

Загрузки
1K
Подписчики
1
Обновлён
19 января 2026 г.
Лицензия
MIT

Опубликован 7 октября 2025 г.

How it should work, why and the idea are done by Human
Coded and implemented by AI

🧹 Smart Item Deleter v2

A lightweight, intelligent item cleanup system for NeoForge 1.21.1


📘 Overview

Smart Item Deleter v2 is a server-side optimization mod designed to automatically clean up dropped item entities when the item count exceeds a defined threshold.
It tracks items individually to ensure fair, efficient, and safe removal — deleting only excess, old, and unimportant drops without disrupting normal gameplay.

✅ Supports NeoForge 21.1.215, Youer 1.21.1, AsyncYouer-1.21.1
⚙️ Designed for Create-based and heavily modded survival servers
💾 Low overhead, deterministic cleanup cycles


⚙️ Configuration (for server owners)

Configuration file:

config/smart_item_deleter_v2-common.toml
Option Type Default Description
entityCountThreshold int 200 Number of dropped item entities required before cleanup activates.
minItemAgeMs long 15000 Minimum age (in milliseconds) before an item becomes eligible for deletion. Prevents immediate removal of new drops.
scanIntervalTicks int 20 How often (in ticks) the system scans the world for items (20 ticks = 1 second).
scanJitterEnabled boolean true Adds small random offset (±scanJitterTicks) to interval to reduce server tick spikes when multiple mods act simultaneously.
scanJitterTicks int 2 Maximum jitter added/subtracted from each cleanup cycle’s timing.
consoleDebugLogging boolean true When false, suppresses cleanup summary messages in the server console.
deletePercentage int 90 Percentage of eligible items to delete each cycle (0–100). Protects the newest items even when threshold is exceeded.
whitelistMode boolean false Toggles whitelist (true) or blacklist (false) filtering behavior.
filteredItems list [] Accepts exact item IDs (minecraft:stone), tag references (#forge:ingots), or wildcard globs with */? (e.g., minecraft:*, minecraft:oak*) that define which items are protected (blacklist) or targeted (whitelist).

Example:

entityCountThreshold = 250
minItemAgeMs = 15000
scanIntervalTicks = 20
deletePercentage = 80
whitelistMode = false
filteredItems = ["minecraft:nether_star", "minecraft:diamond"]

Wildcard example

filteredItems = ["minecraft:oak*"]

This configuration means:

  • Cleanup runs roughly every second.
  • Only starts when >250 dropped items exist.
  • Deletes 80% of all items older than 15 seconds (prioritizing the oldest).
  • Diamonds and Nether Stars will never be deleted.

🧠 Technical Details (for developers and maintainers)

Core Behavior

  • Items are tracked in TrackedItemsData, using persistent per-level storage.
  • Each item stores:
    • UUID
    • dimension
    • firstSeenMs (time first detected)
    • lastSeenMs (time last confirmed)
  • Cleanup only occurs when the total item count exceeds the configured threshold.
  • Items are eligible if:
    1. Their age ≥ minItemAgeMs
    2. They pass the current policy filter (blacklist/whitelist mode)
  • When protectNamedItems is enabled, items with custom names are ignored entirely — they do not count toward the threshold and are never deleted.

Deletion Logic

  • All eligible items are sorted oldest first (ascending by firstSeenMs).
  • The number of deletions per cycle is:
    deletions = min(excess_items, eligible_items * (deletePercentage / 100))
    
  • This ensures:
    • The server maintains stable tick times.
    • Recent player drops are preserved.
    • Automated machines that constantly spill items are kept clean.

Jitter (scan desynchronization)

  • The system uses a randomized interval of:
    nextInterval = scanIntervalTicks ± scanJitterTicks
    
    to avoid simultaneous heavy-tick bursts when multiple mods or systems run periodic updates.

Code Structure

Package Purpose
core/ Cleanup logic, ticking, filtering, and execution
persist/ Persistent tracking data (SavedData) for per-world storage
config/ Configuration spec and loading
command/ Optional /cleanup admin command for manual triggering

Commands

Command Description
/cleanup run Forces a cleanup cycle manually.
/cleanup status (Planned) Displays tracked item count, eligible items, and current thresholds.
/cleanup config Changes values in the config on the fly.

💡 Future Plans

  • Provide in-game feedback via action bar or server console only
  • Expose metrics to /cleanup status or a scoreboard-compatible data point

📜 License

MIT License — freely usable and modifiable.
Please credit Metl_Play if redistributed.
Would be appreciated if I am mentioned in modpacks, but it's not required.


🧩 Credits

  • Developer: Metl_Play
  • Minecraft: 1.21.1 (NeoForge)
  • Mappings: Parchment mappings
  • Libraries: NeoForge API, standard Java collections

“It’s not just a cleaner mod — it’s a smarter janitor.” 🧠🧹

Ченджлог

0.4.9-neoforgedРелиз1.21.1 · 19 января 2026 г.

0.4.9-neoforged - 2026-01-19

Changes since 0.4.5-neoforged.

Changed

  • Filter rules are now precompiled on config bake (tags/exact/wildcards) and reused during matching.
  • Cleanup log writing moved off the tick thread via a single-threaded background writer.
  • Tracked item ages are clamped to avoid negative values after restarts; tracked data clears on server start.
  • Tracked item map accessor returns an unmodifiable view; invalid dimension IDs fall back to overworld.
  • Mod logo now uses icon.png (256x256 RGBA) at the JAR root.
  • Updated loader version range to [2,).

Removed

  • Removed the old Smart-Item-Deleter-v2-new.png logo asset.
0.4.5-neoforgedРелиз1.21.1 · 18 января 2026 г.

0.4.5-neoforged - 2026-01-18

Changes since 0.3.1-neoforged.

Added

  • Added logs/sidV2/cleanup.log and logs/sidV2/stats.log with automatic zip rotation on server start.
  • /cleanup stats output now appends to logs/sidV2/stats.log every run.
  • Added oldestAttemptedAgeMs to cleanup log entries for each dimension.
  • Added per-dimension color coding to /cleanup stats output (overworld green, nether red, end yellow, others purple).

Changed

  • Cleanup summaries are now aggregated across dimensions; console output is a single line when enabled.
  • Cleanup log output now always writes to logs/sidV2/cleanup.log when deletions occur; consoleDebugLogging only controls the console summary.
  • Threshold/excess calculations now ignore filtered or protected items (only deletable candidates count toward the threshold).

Removed

  • Removed /cleanup dryrun.
0.3.1-neoforgedРелиз1.21.1 · 29 ноября 2025 г.

Changelog

0.3.1-neoforged - 2025-11-29

Changes since 0.2.3
Now Compatible with NeoForge 21.1.215+, Youer-1.21.1, AsyncYouer-1.21.1

Added

  • Added /cleanup config commands to list, read, and set config values at runtime with tab completion, validation against the config spec, and saving changes before re-baking settings.
  • Added automatic discovery of config bindings and tracking of the active server config during load and reload so runtime updates target the correct spec.

Changed

  • Bumped NeoForge to 21.1.215 and retargeted the mod version to 0.3.1-neoforged.
  • Disabled console cleanup summaries by default (configurable via consoleDebugLogging).
  • Replaced chunk AABB scanning with level.getAllEntities() and per-level schedules to keep cleanup in lockstep with async ticking environments.
0.2.3Релиз1.21.1 · 9 ноября 2025 г.
  • Wildcard filter added. Please keep in mind that filtered Items still counts toward the threshold, as they still contribute to server load.

In Detail:
Added wildcard-aware matching in PolicyEngine.filterPredicate, enabling filterList entries to use * and ? patterns and translating them into regex via new helper methods so namespace-wide and prefix filters (e.g., minecraft:, minecraft:oak) are honored.

https://github.com/metl-play/smartitemdeleterv2/issues/3

0.2.2Релиз1.21.1 · 7 ноября 2025 г.

⚙️ Enhancement

  • Added a new configuration option to disable console output:
    consoleDebugLogging = false
    
  • It is recommended to keep console output enabled initially to verify your setup and disable it once confirmed. Re-enable logging whenever you suspect a bug or need to provide debug information.

🐞 Resolved

0.2.1Релиз1.21.1 · 3 ноября 2025 г.

New Features

  • Implemented /cleanup now, /cleanup now force, /cleanup stats, and /cleanup dryrun command handlers. (Not all working as intended for now, i.e. empty stats.)
    • Includes aggregated feedback for admins.
    • Supports dry-run previews and per-dimension reporting.

Refactors & Improvements

  • Refactored the cleanup engine to:

    • Expose reusable analysis summaries.
    • Support forced execution overrides.
    • Improve logging with detailed configuration context for each run.
  • Updated /cleanup command registration to use the standard permission system, allowing execution by OP players or the server console.

Code Maintenance

  • Removed the unused forced-analysis overload and redundant threshold accessor to eliminate dead code.
  • Ensured tracked item entries correctly mark saved data as dirty when their last-seen timestamp changes, improving persistence accuracy.
0.1.2Бета1.21.1 · 2 ноября 2025 г.

Fixed:

  • Jitter configuration is now respected.
  • Possible NullPointer-Exception resolved, if cleanup filter list was empty.
  • Potential infinite grow of persistent data, fixed.
  • Fixed problem where setDirty ran every tick.

resolved issue: https://github.com/metl-play/smartitemdeleterv2/issues/2#issue-3572517315

0.1.1Бета1.21.1 · 7 октября 2025 г.

Initial release for testing if this mod behaves as expected. This release is NOT compatible with AsyncYouer, but normal Youer is fine. Tested with 51 Mods Simultanously. -> Not in depth, not tested if other mods behavior breaks. This mod works with them installed.

Комментарии

Загружаем…