@@ -10,13 +10,16 @@ use hyperion::{
10
10
glam:: Vec3 ,
11
11
net:: { agnostic, Compose } ,
12
12
simulation:: {
13
- aabb, block_bounds, blocks:: Blocks , event:: HitGroundEvent , EntitySize , Gamemode , Player ,
14
- Position ,
13
+ aabb, block_bounds, blocks:: Blocks , event:: HitGroundEvent , EntitySize , Gamemode ,
14
+ MovementTracking , Player , Position ,
15
15
} ,
16
16
storage:: EventQueue ,
17
17
BlockKind ,
18
18
} ;
19
- use valence_server:: ident;
19
+ use valence_server:: {
20
+ block:: { PropName , PropValue } ,
21
+ ident,
22
+ } ;
20
23
21
24
use crate :: { damage_player, is_invincible, DamageCause , DamageType } ;
22
25
@@ -79,9 +82,9 @@ impl Module for NaturalDamageModule {
79
82
) ;
80
83
81
84
#[ allow( clippy:: excessive_nesting) ]
82
- system ! ( "natural block damage" , world, & Compose ( $) , & Blocks ( $) , & Position , & EntitySize , & Gamemode )
85
+ system ! ( "natural block damage" , world, & Compose ( $) , & Blocks ( $) , & Position , & EntitySize , & Gamemode , & MovementTracking )
83
86
. with :: < Player > ( )
84
- . each_iter ( |it, row, ( compose, blocks, position, size, gamemode) | {
87
+ . each_iter ( |it, row, ( compose, blocks, position, size, gamemode, movement ) | {
85
88
if is_invincible ( & gamemode. current ) {
86
89
return ;
87
90
}
@@ -131,6 +134,16 @@ impl Module for NaturalDamageModule {
131
134
BlockKind :: SoulFire => {
132
135
damage_player ( & entity, 2. , DamageCause :: new ( DamageType :: InFire ) , compose, system) ;
133
136
}
137
+ BlockKind :: SweetBerryBush => {
138
+ let grown = block. get ( PropName :: Age )
139
+ . is_some_and ( |x| x != PropValue :: _0) ;
140
+ let delta_x = ( f64:: from ( position. x ) - f64:: from ( movement. last_tick_position . x ) ) . abs ( ) ;
141
+ let delta_y = ( f64:: from ( position. y ) - f64:: from ( movement. last_tick_position . y ) ) . abs ( ) ;
142
+
143
+ if grown && delta_x >= 0.003_000_000_026_077_032 && delta_y >= 0.003_000_000_026_077_032 && movement. last_tick_position != * * position {
144
+ damage_player ( & entity, 1. , DamageCause :: new ( DamageType :: SweetBerryBush ) , compose, system) ;
145
+ }
146
+ }
134
147
_ => { }
135
148
}
136
149
}
0 commit comments