๐
1 file
3,198 chars
๐
pasted-code-1774871880810.txt
txt
157 lines
โถ
pasted-code-1774871880810.txt
txt
157 lines
You are an expert Minecraft Fabric mod developer.
Create a client-side Fabric mod named "FreecamRender" for Minecraft 1.21.4 using Yarn mappings.
## ๐ฏ Goal
Implement an advanced Freecam system where:
- Camera is fully detached from player
- Camera can fly freely like Creative mode (GMC)
- Chunks are loaded/rendered based on camera position (not player position)
---
## โ๏ธ Core Features
### 1. Toggle Freecam (KEYBIND)
- Default keybind: F4
When pressed:
- Toggle Freecam ON/OFF
When enabled:
- Save:
- Player position (x, y, z)
- Rotation (yaw, pitch)
- Velocity
- Freeze real player (no movement, no interaction)
- Detach camera from player
When disabled:
- Restore all saved data
---
### 2. ๐ Freecam Movement (LIKE CREATIVE MODE - IMPORTANT)
The Freecam MUST behave like Creative Mode flight:
- WASD โ move forward/back/strafe
- SPACE โ move up
- SHIFT โ move down
- Mouse โ rotate camera
- Scroll โ adjust speed dynamically
REQUIREMENTS:
- No gravity
- No collision (noclip)
- Can pass through blocks
- Smooth acceleration and deceleration
- No server-side movement
Implementation notes:
- DO NOT use Spectator mode directly
- Implement custom movement system:
- Maintain a separate `Vec3d cameraPos`
- Update position every client tick
- Apply directional vectors based on yaw/pitch
Example logic:
- Forward vector based on camera rotation
- Strafe vector perpendicular to forward
- Vertical control independent
---
### 3. ๐ฅ Chunk Loading Based on Camera
- Track camera position (NOT player)
- Load chunks within render distance around camera
Implementation options:
- Override ClientChunkManager behavior
- Use fake player position (client-side spoof)
- Force chunk rebuild via WorldRenderer
Requirements:
- Dynamic loading/unloading
- No memory leaks
- Smooth rendering
---
### 4. Camera Override
- Override camera position using Mixins:
- Camera class OR GameRenderer
- Replace:
- camera position โ cameraPos
- rotation โ custom yaw/pitch
---
### 5. Networking Safety
- Cancel ALL movement packets while Freecam is active
- Do NOT update server with camera position
- Prevent anti-cheat triggers
---
### 6. Player Handling
- Real player:
- Completely frozen
- No movement packets
- Optional: invisible
- Camera is NOT the player entity
---
### 7. Performance
- Efficient chunk tracking (Set)
- Limit chunk updates per tick
- Avoid redundant loads
---
### 8. Config
- Config file:
- Flight speed
- Speed multiplier (scroll)
- Toggle key (default F4)
---
### ๐ฆ Technical Requirements
- Fabric Loader (1.21.4)
- Yarn mappings
- Use Mixins for:
- Camera override
- Chunk loading
- Packet interception
---
### ๐ Output
Provide:
- Full mod source code
- Keybind implementation
- Camera movement system
- Mixins
- Comments explaining:
- Freecam movement math
- Chunk loading logic
---
IMPORTANT:
- Freecam MUST feel exactly like Creative mode flying (GMC)
- No laggy or spectator-like movement
- Client-side only
- Works on vanilla servers
Kodari can make mistakes. Review important code before using.
Files
No files in this session
Code