Respect mobGriefing for mob explosions and endermen
Mob explosions (creepers, ghast fireballs, wither skulls and the wither spawn blast) now keep blocks when mobGriefing is off, and follow the mob_explosion_drop_decay rule when it is on. Endermen no longer pick up or put down blocks with mobGriefing off.
This commit is contained in:
@@ -7657,15 +7657,18 @@ impl Game<'_> {
|
||||
}
|
||||
}
|
||||
/// ServerExplosion: rays from a 16^3 grid lose (resistance + 0.3) * 0.3 per step.
|
||||
/// A mob explosion (`Level.ExplosionInteraction.MOB`: drop decay with the
|
||||
/// default mobGriefing rule).
|
||||
/// A mob explosion (`ServerLevel.explode` with `ExplosionInteraction.MOB`:
|
||||
/// blocks are kept without mobGriefing, else the mob_explosion_drop_decay
|
||||
/// rule picks decay).
|
||||
fn explode(&mut self, center: [f64; 3], radius: f32) -> Result<()> {
|
||||
self.server_explode(
|
||||
center,
|
||||
radius,
|
||||
explosion::BlockInteraction::DestroyWithDecay,
|
||||
false,
|
||||
)
|
||||
let interaction = if !self.ui.rules.bool("mob_griefing") {
|
||||
explosion::BlockInteraction::Keep
|
||||
} else if self.ui.rules.bool("mob_explosion_drop_decay") {
|
||||
explosion::BlockInteraction::DestroyWithDecay
|
||||
} else {
|
||||
explosion::BlockInteraction::Destroy
|
||||
};
|
||||
self.server_explode(center, radius, interaction, false)
|
||||
}
|
||||
/// Copies of a save batch carrying its live block entities and save data.
|
||||
fn with_entities<'a>(
|
||||
|
||||
@@ -331,8 +331,11 @@ impl Goal for TakeBlock {
|
||||
fn flags(&self) -> u8 {
|
||||
0
|
||||
}
|
||||
fn can_use(&mut self, m: &mut Mob, _: &mut Cx) -> bool {
|
||||
m.extra.carried.is_none() && m.random.next_int_bound(reduced(20)).unwrap_or(1) == 0
|
||||
fn can_use(&mut self, m: &mut Mob, cx: &mut Cx) -> bool {
|
||||
// EndermanTakeBlockGoal.canUse: needs mobGriefing, checked before the draw.
|
||||
m.extra.carried.is_none()
|
||||
&& cx.w.mob_griefing
|
||||
&& m.random.next_int_bound(reduced(20)).unwrap_or(1) == 0
|
||||
}
|
||||
fn tick(&mut self, m: &mut Mob, cx: &mut Cx) {
|
||||
let x = (m.position.x - 2.0 + m.random.next_double() * 4.0).floor() as i32;
|
||||
@@ -379,8 +382,11 @@ impl Goal for LeaveBlock {
|
||||
fn flags(&self) -> u8 {
|
||||
0
|
||||
}
|
||||
fn can_use(&mut self, m: &mut Mob, _: &mut Cx) -> bool {
|
||||
m.extra.carried.is_some() && m.random.next_int_bound(reduced(2000)).unwrap_or(1) == 0
|
||||
fn can_use(&mut self, m: &mut Mob, cx: &mut Cx) -> bool {
|
||||
// EndermanLeaveBlockGoal.canUse: needs mobGriefing, checked before the draw.
|
||||
m.extra.carried.is_some()
|
||||
&& cx.w.mob_griefing
|
||||
&& m.random.next_int_bound(reduced(2000)).unwrap_or(1) == 0
|
||||
}
|
||||
fn tick(&mut self, m: &mut Mob, cx: &mut Cx) {
|
||||
let Some(carried) = m.extra.carried else {
|
||||
|
||||
Reference in New Issue
Block a user