@@ -10,13 +10,16 @@ use hyperion::{
1010 glam:: Vec3 ,
1111 net:: { agnostic, Compose } ,
1212 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 ,
1515 } ,
1616 storage:: EventQueue ,
1717 BlockKind ,
1818} ;
19- use valence_server:: ident;
19+ use valence_server:: {
20+ block:: { PropName , PropValue } ,
21+ ident,
22+ } ;
2023
2124use crate :: { damage_player, is_invincible, DamageCause , DamageType } ;
2225
@@ -79,9 +82,9 @@ impl Module for NaturalDamageModule {
7982 ) ;
8083
8184 #[ 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 )
8386 . with :: < Player > ( )
84- . each_iter ( |it, row, ( compose, blocks, position, size, gamemode) | {
87+ . each_iter ( |it, row, ( compose, blocks, position, size, gamemode, movement ) | {
8588 if is_invincible ( & gamemode. current ) {
8689 return ;
8790 }
@@ -131,6 +134,16 @@ impl Module for NaturalDamageModule {
131134 BlockKind :: SoulFire => {
132135 damage_player ( & entity, 2. , DamageCause :: new ( DamageType :: InFire ) , compose, system) ;
133136 }
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+ }
134147 _ => { }
135148 }
136149 }
0 commit comments