diff options
| author | mat <27899617+mat-1@users.noreply.github.com> | 2023-07-14 22:20:40 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-14 22:20:40 -0500 |
| commit | 7405427199e5a994d4a6a706f84434a69cb7a7d9 (patch) | |
| tree | ca537e5d761bc053187d952fced0915c850b92aa /azalea-block/src/behavior.rs | |
| parent | d1afd02aa84e7b4450c1607277f078eb2a0f1bf3 (diff) | |
| download | azalea-drasl-7405427199e5a994d4a6a706f84434a69cb7a7d9.tar.xz | |
Mining (#95)
* more mining stuff
* initialize azalea-tags crate
* more mining stuff 2
* mining in ecs
* well technically mining works but
no codegen for how long it takes to mine each block yet
* rename downloads to __cache__
it was bothering me since it's not *just* downloads
* codegen block behavior
* fix not sending packet to finish breaking block
* mining animation 🎉
* clippy
* cleanup, move Client::mine into a client extension
* add azalea/src/mining.rs
---------
Co-authored-by: mat <git@matdoes.dev>
Diffstat (limited to 'azalea-block/src/behavior.rs')
| -rwxr-xr-x | azalea-block/src/behavior.rs | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/azalea-block/src/behavior.rs b/azalea-block/src/behavior.rs index 18854fff..498ba06f 100755 --- a/azalea-block/src/behavior.rs +++ b/azalea-block/src/behavior.rs @@ -1,35 +1,55 @@ pub struct BlockBehavior { - pub has_collision: bool, pub friction: f32, pub jump_factor: f32, + pub destroy_time: f32, + pub explosion_resistance: f32, + pub requires_correct_tool_for_drops: bool, } impl Default for BlockBehavior { fn default() -> Self { Self { - has_collision: true, friction: 0.6, jump_factor: 1.0, + destroy_time: 0., + explosion_resistance: 0., + requires_correct_tool_for_drops: false, } } } impl BlockBehavior { - #[inline] - pub fn no_collision(mut self) -> Self { - self.has_collision = false; - self + pub fn new() -> Self { + Self::default() } - #[inline] pub fn friction(mut self, friction: f32) -> Self { self.friction = friction; self } - #[inline] pub fn jump_factor(mut self, jump_factor: f32) -> Self { self.jump_factor = jump_factor; self } + + pub fn destroy_time(mut self, destroy_time: f32) -> Self { + self.destroy_time = destroy_time; + self + } + + pub fn explosion_resistance(mut self, explosion_resistance: f32) -> Self { + self.explosion_resistance = f32::max(0., explosion_resistance); + self + } + + pub fn strength(self, destroy_time: f32, explosion_resistance: f32) -> Self { + self.destroy_time(destroy_time) + .explosion_resistance(explosion_resistance) + } + + pub fn requires_correct_tool_for_drops(mut self) -> Self { + self.requires_correct_tool_for_drops = true; + self + } } |
