📄
pasted-code-1789737367723.txt
txt
257 lines
▶
Create a lightweight client-side Minecraft Fabric mod from scratch for Minecraft Java Edition 26.2.
TARGET
* Minecraft Java Edition 26.2
* Fabric Loader
* Fabric API
* Client-side only
* No server-side installation required
* Implement independently from scratch; do not copy proprietary code from existing mods.
1. STATUS EFFECT TIMER
Display the remaining duration of every active potion/status effect directly on or beside its vanilla status-effect icon.
Examples:
* 2:35
* 1:04
* 0:59
* 29
* 8
Timer formatting:
* More than 60 seconds → M:SS
* Less than 60 seconds → SS
The timer must update accurately in real time and support multiple simultaneous effects.
2. NORMAL TIMER COLOR — MATCH THE POTION EFFECT
When an effect has 30 seconds or more remaining, the timer text must automatically use the color associated with that status effect/potion.
Do NOT use one universal timer color.
The timer should dynamically determine the effect’s vanilla/status-effect color and use that color for the timer.
Examples:
* Instant Health / Healing → red/pink-toned timer
* Invisibility → white/light-gray timer
* Speed → appropriate Speed effect color
* Strength → appropriate Strength effect color
* Regeneration → appropriate Regeneration effect color
* Fire Resistance → appropriate Fire Resistance effect color
* etc.
The system must work automatically for:
* Vanilla effects
* Modded status effects
Do not hardcode only a few potion colors.
Use the status effect’s actual Minecraft-defined color where possible so the timer automatically follows the effect.
The normal timer should be:
* Bright enough to read clearly
* Slightly polished if necessary for readability
* Compatible with Minecraft’s native font
* Consistent with the vanilla HUD
3. UNDER-30-SECOND WARNING
When the remaining duration becomes less than 30 seconds, the timer should automatically switch from the effect’s normal color to a red warning animation.
Threshold:
* 30.00 seconds or higher → normal potion/effect color
* < 30 seconds → warning mode
4. RED BLINKING WARNING
During the final 30 seconds:
* Only the timer text should blink/pulse.
* Do NOT blink the status-effect icon.
* Do NOT blink the entire HUD.
* Do NOT make the background blink.
Use multiple red shades during the animation:
* Dark red
* Red
* Bright red
* Light/bright red
The timer should smoothly transition between these shades.
Example:
29 → dark red
28 → bright red
27 → light red
26 → red
25 → dark red
The animation should continuously pulse/blink while the effect remains below 30 seconds.
The warning should be highly visible but still clean and Minecraft-like.
5. SMOOTH COLOR ANIMATION
Do not simply switch instantly between colors.
Use smooth interpolation between red shades.
The animation should:
* Pulse continuously
* Be smooth
* Avoid distracting flashing
* Remain readable
* Have a configurable blink speed
Suggested default:
* Approximately 2 pulses per second
6. EFFECT-SPECIFIC COLORS
The timer color must be calculated separately for each effect.
For example, if the player has:
Speed — 45 seconds
→ timer uses Speed’s normal effect color.
Strength — 20 seconds
→ timer uses animated red warning colors.
Invisibility — 1:20
→ timer uses the Invisibility color.
Regeneration — 12 seconds
→ timer uses animated red warning colors.
Each effect must independently switch into warning mode when its own duration reaches below 30 seconds.
7. EFFECT REFRESHING
If an effect is refreshed or extended:
Example:
Strength: 12s → refreshed → Strength: 1:30
The timer must immediately return to the normal effect color because it is no longer below 30 seconds.
If it goes from:
35s → 29s
It should immediately enter the red warning animation.
8. INFINITE EFFECTS
Handle infinite-duration effects correctly.
Infinite effects should:
* Display an appropriate infinite indicator or timer representation.
* Use their normal effect color.
* Never enter the 30-second warning animation.
9. HUD / RENDERING
Use Minecraft’s native status-effect HUD.
Requirements:
* Keep vanilla effect icons unchanged.
* Do not replace the vanilla icons.
* Render the timer cleanly over/near the icon.
* Use Minecraft’s native font renderer.
* Make the timer readable at different GUI scales.
* Prevent overlapping timers.
* Support multiple active effects.
The result should look like a polished vanilla-style feature rather than a completely separate UI.
10. CONFIGURATION
Provide a client-side configuration with:
* Warning threshold — default 30 seconds
* Enable/disable warning animation
* Blink speed
* Enable/disable effect-based timer colors
* Enable/disable red warning colors
* Timer position/offset
* Optional timer scale
Default configuration should require no setup.
11. PERFORMANCE
Keep the mod extremely lightweight.
* Client-side only
* Efficient rendering
* No unnecessary heavy calculations
* No excessive object creation every frame
* No noticeable FPS impact
* Correctly handle effects being added, removed, refreshed, or extended
12. EDGE CASES
Correctly handle:
* Exactly 30 seconds
* 29.99 seconds
* 1 second
* 0 seconds
* Infinite effects
* Multiple effects
* Effects refreshing
* Effects being removed
* World changes
* Server changes
* Game pause/unpause
* GUI scale changes
* Inventory and other Minecraft screens
* Modded status effects
13. PROJECT REQUIREMENTS
Provide a complete compilable Fabric project containing:
* Gradle configuration
* fabric.mod.json
* Main mod initializer
* Client initializer
* HUD/status-effect rendering implementation
* Timer formatting system
* Dynamic effect-color detection
* Red warning animation system
* Configuration system
* Required mixins/hooks
* README
* Build instructions
The final project must compile successfully into a .jar and work on:
Minecraft Java Edition 26.2 + Fabric
MOST IMPORTANT BEHAVIOR
Normal state:
Potion Effect → Timer uses that effect’s own vanilla color.
Final 30 seconds:
Potion Effect → Timer switches to smoothly blinking/pulsing red shades.
Only the timer changes color/animation. The status-effect icon remains completely normal.
Set up the Fabric 26.2 Gradle project and metadata for a client-only mod.
Add client HUD rendering, dynamic effect-color timers, warning animation, and formatting.
Add a lightweight file-backed client configuration with the requested defaults and controls.
Add README/build instructions and required client mixin/resource wiring.
Created the complete Fabric 26.2 client-side project.
Added Gradle/Loom configuration targeting Java 25, Minecraft 26.2, Fabric Loader 0.19.3, and Fabric API 0.158.0.
Added main and client mod initializers.
Implemented vanilla HUD-integrated status-effect timers using
HudElementRegistry.Added:
M:SS/ seconds formattingInfinite-effect
∞displayDynamic vanilla and modded effect colors
Per-effect under-30-second warning behavior
Smooth animated red warning palette
Configurable threshold, animation, blink speed, colors, offsets, and scale
Added generated
config/effecttimer.propertiessupport.Added
fabric.mod.json, language resource, and README with build/configuration instructions.No mixin is required; the Fabric HUD API provides the rendering hook.
The timer i want like 1M or 2M not like 3:00 and want this in center bottom of the hud
Change duration formatting to minute suffixes such as
1Mand2M.Move the timer display to the bottom-center HUD position.
Updated:
Durations of 60 seconds or longer now display as:
1M2M3M
Durations below one minute still display as seconds.
Timers now appear centered at the bottom of the HUD.
Multiple timers are spaced evenly and wrap into additional centered rows if needed.
Vanilla status-effect icons remain unchanged.
Existing
offsetX,offsetY, andtimerScaleconfiguration options still apply.
The blinking effect of 30 seconds made slower
Changed the default warning blink speed from 2.0 to 0.75 cycles per second, making the final-30-second animation noticeably slower.
If the config file already exists, set:
blinkSpeed=0.75
in:
config/effecttimer.properties
There is issue in night vision when position is on 30 sec my full screen is blinking
Fixed the Night Vision full-screen blinking.
Added a client mixin that disables vanilla’s Night Vision screen pulse near expiration.
The status-effect timer warning animation remains active.
Only the timer text changes color/animates; the screen and effect icon no longer blink.
Registered the client mixin in
fabric.mod.json.
I want bottom center in this boxes not in screen center
Replace the text-only centered row with fixed 24×24 slots matching the effect boxes.
Center each timer inside its corresponding box, while preserving multiple effects, wrapping, offsets, and scaling.
Update the README to describe box-aligned bottom-center placement.
Updated the timer placement:
Timers now use fixed 24×24 effect-box slots.
Each timer is centered inside its matching status-effect box.
The box row is centered at the bottom of the HUD.
Multiple effects wrap into additional centered rows.
Existing timer scale and
offsetX/offsetYsettings still work.Updated the README accordingly.
Bhai iske andar nahi karna h
Ab timer boxes ke andar nahi, har effect box ke neeche render hoga.
Timer box ke center ke saath horizontally aligned rahega.
Bottom-center position maintain rahegi.
Multiple rows mein timers overlap nahi honge.
Timer ka color, blinking,
1Mformat sab same rahega.
package com.kodari.effecttimer;
import net.fabricmc.api.ModInitializer;
public final class EffectTimerMod implements ModInitializer {
public static final String MOD_ID = "effecttimer";
@Override
public void onInitialize() {
}
}