@@ -78,6 +78,7 @@ impl Module for NaturalDamageModule {
78
78
} ,
79
79
) ;
80
80
81
+ #[ allow( clippy:: excessive_nesting) ]
81
82
system ! ( "natural block damage" , world, & Compose ( $) , & Blocks ( $) , & Position , & EntitySize , & Gamemode )
82
83
. with :: < Player > ( )
83
84
. each_iter ( |it, row, ( compose, blocks, position, size, gamemode) | {
@@ -89,6 +90,7 @@ impl Module for NaturalDamageModule {
89
90
let entity = it. entity ( row) ;
90
91
91
92
let ( min, max) = block_bounds ( * * position, * size) ;
93
+ let min = min. with_y ( min. y -1 ) ;
92
94
let bounding_box = aabb ( * * position, * size) ;
93
95
94
96
blocks. get_blocks ( min, max, |pos, block| {
@@ -108,19 +110,30 @@ impl Module for NaturalDamageModule {
108
110
BlockKind :: Cactus => {
109
111
damage_player ( & entity, 1. , DamageCause :: new ( DamageType :: Cactus ) , compose, system) ;
110
112
}
111
- BlockKind :: Fire => {
112
- // Todo check for overlap not just collision
113
- damage_player ( & entity, 1. , DamageCause :: new ( DamageType :: InFire ) , compose, system) ;
114
- }
115
- BlockKind :: SoulFire => {
116
- damage_player ( & entity, 2. , DamageCause :: new ( DamageType :: InFire ) , compose, system) ;
113
+ BlockKind :: MagmaBlock => {
114
+ if position. y > pos. y {
115
+ damage_player ( & entity, 1. , DamageCause :: new ( DamageType :: HotFloor ) , compose, system) ;
116
+ }
117
117
}
118
118
_ => { }
119
119
}
120
120
return ControlFlow :: Break ( ( ) ) ;
121
121
}
122
122
}
123
123
124
+ let aabb = Aabb :: new ( Vec3 :: ZERO , Vec3 :: ONE ) . move_by ( pos) ;
125
+
126
+ if Aabb :: overlap ( & aabb, & bounding_box) . is_some ( ) {
127
+ match kind {
128
+ BlockKind :: Fire => {
129
+ damage_player ( & entity, 1. , DamageCause :: new ( DamageType :: InFire ) , compose, system) ;
130
+ }
131
+ BlockKind :: SoulFire => {
132
+ damage_player ( & entity, 2. , DamageCause :: new ( DamageType :: InFire ) , compose, system) ;
133
+ }
134
+ _ => { }
135
+ }
136
+ }
124
137
ControlFlow :: Continue ( ( ) )
125
138
} ) ;
126
139
} ) ;
0 commit comments