Skip to content

Commit

Permalink
Water splash potion can extinguish fire (#2148)
Browse files Browse the repository at this point in the history
  • Loading branch information
PetteriM1 authored Oct 24, 2023
1 parent 6a5f276 commit 55c6dc8
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/cn/nukkit/block/BlockFire.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import cn.nukkit.Server;
import cn.nukkit.entity.Entity;
import cn.nukkit.entity.item.EntityPotion;
import cn.nukkit.entity.projectile.EntityArrow;
import cn.nukkit.event.block.BlockBurnEvent;
import cn.nukkit.event.block.BlockFadeEvent;
Expand All @@ -17,6 +18,7 @@
import cn.nukkit.math.BlockFace;
import cn.nukkit.math.Vector3;
import cn.nukkit.potion.Effect;
import cn.nukkit.potion.Potion;
import cn.nukkit.utils.BlockColor;

import java.util.Random;
Expand Down Expand Up @@ -68,6 +70,17 @@ public boolean canBeReplaced() {

@Override
public void onEntityCollide(Entity entity) {
if (entity instanceof EntityPotion) {
if (((EntityPotion) entity).potionId == Potion.WATER) {
BlockFadeEvent event = new BlockFadeEvent(this, Block.get(AIR));
this.level.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
this.level.setBlock(this, event.getNewState(), true);
}
return;
}
}

if (!entity.hasEffect(Effect.FIRE_RESISTANCE)) {
entity.attack(new EntityDamageByBlockEvent(this, entity, DamageCause.FIRE, 1));
}
Expand Down

0 comments on commit 55c6dc8

Please sign in to comment.