Files
ngzz-mc/cmd/client/entities_gl.go
NianGao Dev 9e2f5a6186 fix(game): 崩溃修复(卸载区块实体冻结)+ 立面光照、掉落可见、打击感、水下效果、空手拳头、血条左/饥饿右
- 崩溃(index out of range):实体所在区块卸载后失去碰撞支撑无限下坠到
  负坐标,光查询越界 panic——WorldView 增 ChunkLoaded,未加载区块实体冻结;
  chunk 光查询加越界防御(双保险)
- 立面光照:mesh 每面取**邻格**光照(原版光照模型)——此前用方块自身光照
  (sky=0)导致悬崖/矿洞立面全黑(泥土竖向黑色根因)
- 掉落可见:生成后 1 秒拾取延迟 + 图标加大到 0.45
- 打击感:攻击命中音(block.hit)+ 实体受击白闪(uTint)+ 手持挥动动画
- 水下效果:相机入水蓝色叠加(渲染.md §8 水体)
- 空手显示肤色拳头(白羊毛 × 肤色 tint),持方块正常显示
- HUD 布局:血条左下、饥饿右下(经典布局)
2026-08-16 20:59:28 +08:00

44 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//go:build gl
// 实体可视映射:实体类型 → 广告牌贴图键与高度(渲染.md §5.3)。
package main
import (
"mc/internal/entity"
"mc/internal/item"
)
// entityVisual 返回实体的贴图键与身高(米)。
// 动物按 ID 轮换四种外观(cow/pig/sheep/chicken);掉落物用物品图标(0.3 米小广告牌)。
func entityVisual(e *entity.Entity, items *item.Registry) (key string, height float32) {
switch e.Kind {
case entity.KindZombie:
return "entity/zombie/zombie", 1.95
case entity.KindVillager:
return "entity/villager/villager", 1.95
case entity.KindAnimal:
switch e.ID % 4 {
case 0:
return "entity/cow/cow_temperate", 1.4
case 1:
return "entity/pig/pig_temperate", 0.9
case 2:
return "entity/sheep/sheep", 1.3
default:
return "entity/chicken/chicken_temperate", 0.7
}
case entity.KindItemDrop:
d, ok := e.Data.(*entity.Drop)
if !ok || items == nil {
return "", 0
}
def, ok := items.Get(d.Item)
if !ok {
return "", 0
}
return def.Texture, 0.45
default:
return "", 0
}
}