Use the berry damage type for sweet berry bushes and check the whole move for contact
This commit is contained in:
@@ -117,7 +117,8 @@ impl Game<'_> {
|
||||
"drown" => DamageKind::Drown,
|
||||
"magic" | "indirect_magic" | "dragon_breath" => DamageKind::Magic,
|
||||
"sting" => DamageKind::Sting,
|
||||
"cactus" | "sweet_berry_bush" => DamageKind::Cactus,
|
||||
"cactus" => DamageKind::Cactus,
|
||||
"sweet_berry_bush" => DamageKind::SweetBerryBush,
|
||||
"in_wall" => DamageKind::InWall,
|
||||
"thorns" => DamageKind::Thorns,
|
||||
_ => DamageKind::Generic,
|
||||
|
||||
@@ -3283,6 +3283,7 @@ pub(super) fn damage_type(kind: horizon_client::mobs::DamageKind, player: bool)
|
||||
K::Magic => "minecraft:magic",
|
||||
K::Sting => "minecraft:sting",
|
||||
K::Cactus => "minecraft:cactus",
|
||||
K::SweetBerryBush => "minecraft:sweet_berry_bush",
|
||||
K::Generic => "minecraft:generic",
|
||||
K::InWall => "minecraft:in_wall",
|
||||
K::Thorns => "minecraft:thorns",
|
||||
|
||||
@@ -518,6 +518,8 @@ pub enum DamageKind {
|
||||
Magic,
|
||||
Sting,
|
||||
Cactus,
|
||||
/// `sweet_berry_bush`.
|
||||
SweetBerryBush,
|
||||
Generic,
|
||||
InWall,
|
||||
Thorns,
|
||||
@@ -573,7 +575,11 @@ impl Damage {
|
||||
pub fn causes_panic(&self) -> bool {
|
||||
!matches!(
|
||||
self.kind,
|
||||
DamageKind::Fall | DamageKind::Drown | DamageKind::Generic | DamageKind::InWall
|
||||
DamageKind::Fall
|
||||
| DamageKind::Drown
|
||||
| DamageKind::Generic
|
||||
| DamageKind::InWall
|
||||
| DamageKind::SweetBerryBush
|
||||
)
|
||||
}
|
||||
/// DamageTypeTags.BYPASSES_ARMOR
|
||||
@@ -608,6 +614,7 @@ impl Damage {
|
||||
| DamageKind::Drown
|
||||
| DamageKind::Magic
|
||||
| DamageKind::Cactus
|
||||
| DamageKind::SweetBerryBush
|
||||
| DamageKind::Generic
|
||||
| DamageKind::InWall
|
||||
| DamageKind::OutOfWorld
|
||||
|
||||
@@ -433,14 +433,20 @@ pub fn tick(
|
||||
/// that hurt or hold a mob: the cactus (`CactusBlock.entityInside`, 1) and the
|
||||
/// sweet berry bush (`SweetBerryBushBlock.entityInside`: stuck at 0.8, 0.75,
|
||||
/// 0.8, and a grown bush pricks for 1 when the mob moved at least 0.003 on X
|
||||
/// or Z this tick). The blocks are those the mob's box touches where it
|
||||
/// started the tick and where it ended.
|
||||
/// or Z this tick). The blocks are those the mob's box touches anywhere along
|
||||
/// its move this tick, from where it started to where it ended.
|
||||
fn effects_from_blocks(m: &mut Mob, w: &MobWorld) {
|
||||
let mut visited: Vec<[i32; 3]> = Vec::new();
|
||||
for at in [m.previous, m.position] {
|
||||
let travel = m.position.subtract(m.previous);
|
||||
let longest = travel.x.abs().max(travel.y.abs()).max(travel.z.abs());
|
||||
let steps = ((longest / 0.2).ceil() as i32).clamp(1, 100);
|
||||
for step in 0..=steps {
|
||||
if !m.alive() {
|
||||
return;
|
||||
}
|
||||
let at = m
|
||||
.previous
|
||||
.add_vector(travel.scale(f64::from(step) / f64::from(steps)));
|
||||
let b = m.bounds_at(at).deflate(Vec3::new(1e-5, 1e-5, 1e-5));
|
||||
for x in b.min_position().x.floor() as i32..=b.max_position().x.floor() as i32 {
|
||||
for y in b.min_position().y.floor() as i32..=b.max_position().y.floor() as i32 {
|
||||
@@ -465,7 +471,7 @@ fn effects_from_blocks(m: &mut Mob, w: &MobWorld) {
|
||||
&& (moved.x.abs() >= f64::from(0.003_f32)
|
||||
|| moved.z.abs() >= f64::from(0.003_f32))
|
||||
{
|
||||
m.damage(1.0, Damage::of(DamageKind::Cactus));
|
||||
m.damage(1.0, Damage::of(DamageKind::SweetBerryBush));
|
||||
}
|
||||
}
|
||||
_ => continue,
|
||||
|
||||
@@ -297,6 +297,7 @@ pub fn accepts_damage(m: &mut Mob, source: &Damage, amount: f32) -> bool {
|
||||
| DamageKind::Fall
|
||||
| DamageKind::Sting
|
||||
| DamageKind::Cactus
|
||||
| DamageKind::SweetBerryBush
|
||||
);
|
||||
if immune {
|
||||
if let Some(from) = source.from {
|
||||
|
||||
Reference in New Issue
Block a user