Implement first-person fire effect with reactive player state integration

Co-authored-by: vital2580 <vital2580@icloud.com>
This commit is contained in:
Cursor Agent 2025-06-29 18:42:41 +00:00
commit 68aa0a37bc

65
FIRE_EFFECT_PR_SUMMARY.md Normal file
View file

@ -0,0 +1,65 @@
# 🔥 Fire Effect Implementation - Pull Request Summary
## What We Accomplished
✅ **Found and updated the old fire-effect branch**
- Located the existing `fire-effect` branch with initial implementation
- Successfully merged latest `next` branch changes
- Resolved merge conflicts in `worldrendererThree.ts`
✅ **Enhanced the FirstPersonEffects class**
- **Multiple animation frames**: Now loads all available fire textures (fire_0, fire_1, fire_2, etc.) instead of just one
- **Improved positioning**: Fire overlay positioned very close to camera (0.1 distance) for immersive effect
- **Better scaling**: Fire sprite scales to 1.8x screen size with bottom offset like Minecraft
- **Enhanced materials**: Added `AdditiveBlending`, `depthTest: false`, and warm color tint for realistic fire effect
✅ **Integrated with player state system**
- **Added `onFire` field** to base player state (`renderer/viewer/lib/basePlayerState.ts`)
- **Fire status tracking** in `src/mineflayer/playerState.ts` that monitors `bot.entity.fireTicks`
- **Reactive updates** in `worldrendererThree.ts` that automatically show/hide fire effect
✅ **Complete fire detection pipeline**
- Detects when `bot.entity.fireTicks > 0` (player is burning)
- Updates `playerState.reactive.onFire` status
- Automatically triggers fire effect visibility via reactive state system
## Files Modified
1. **`renderer/viewer/lib/basePlayerState.ts`** - Added `onFire: false` to player state
2. **`src/mineflayer/playerState.ts`** - Added `updateFireStatus()` method and physics tick monitoring
3. **`renderer/viewer/three/firstPersonEffects.ts`** - Enhanced fire texture loading, positioning, and materials
4. **`renderer/viewer/three/worldrendererThree.ts`** - Added reactive listener for `onFire` state changes
## How It Works
1. **Detection**: Every physics tick, checks if `bot.entity.fireTicks > 0`
2. **State Update**: Updates `playerState.reactive.onFire` when fire status changes
3. **Visual Effect**: Reactive system triggers `firstPersonEffects.setIsOnFire(value)`
4. **Animation**: Fire sprite animates through multiple texture frames every 200ms
5. **Rendering**: Additive blending creates realistic fire glow effect
## Testing
To test the fire effect:
1. Join a Minecraft server/world
2. Set yourself on fire (lava, fire block, etc.)
3. The first-person fire overlay should appear with animated fire textures
4. Fire effect automatically disappears when fire damage stops
## Pull Request Details
**Title**: Implement First Person Fire Effect for Renderer
**Base Branch**: `next`
**Head Branch**: `fire-effect`
**Description**: Complete implementation of first-person fire effects in the renderer when the player is on fire. Updates the old fire-effect branch to latest codebase with enhanced fire animation, player state integration, and realistic fire overlay positioning.
## Next Steps
1. Navigate to the GitHub repository
2. Create a pull request from `fire-effect` branch to `next` branch
3. Use the title and description above
4. The implementation is ready for review and testing!
The fire effect implementation is now complete and integrated with the latest codebase! 🎉