Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call EntityExplosionPrimeEvent for end crystal explosion #2004

Merged
merged 4 commits into from
Jul 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions src/main/java/cn/nukkit/entity/item/EntityEndCrystal.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import cn.nukkit.entity.Entity;
import cn.nukkit.entity.EntityExplosive;
import cn.nukkit.event.entity.EntityDamageEvent;
import cn.nukkit.event.entity.EntityExplosionPrimeEvent;
import cn.nukkit.level.Explosion;
import cn.nukkit.level.GameRule;
import cn.nukkit.level.Position;
import cn.nukkit.level.format.FullChunk;
import cn.nukkit.nbt.tag.CompoundTag;

Expand Down Expand Up @@ -73,18 +73,22 @@ public boolean attack(EntityDamageEvent source) {

@Override
public void explode() {
if (!this.detonated) {
this.detonated = true;
this.close();

Position pos = this.getPosition();
Explosion explode = new Explosion(pos, 6, this);
if (!this.detonated && this.level.getGameRules().getBoolean(GameRule.MOB_GRIEFING)) {
EntityExplosionPrimeEvent ev = new EntityExplosionPrimeEvent(this, 6);
this.server.getPluginManager().callEvent(ev);
if (ev.isCancelled()) {
return;
}

this.close();
this.detonated = true;

if (this.level.getGameRules().getBoolean(GameRule.MOB_GRIEFING)) {
explode.explodeA();
explode.explodeB();
Explosion explosion = new Explosion(this, (float) ev.getForce(), this);
if (ev.isBlockBreaking()) {
explosion.explodeA();
}
explosion.explodeB();
}
}

Expand Down