From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ben Kerllenevich <me@notom3ga.me>
Date: Sat, 13 Feb 2021 09:28:56 -0500
Subject: [PATCH] End crystal explosion options


diff --git a/src/main/java/net/minecraft/server/EntityEnderCrystal.java b/src/main/java/net/minecraft/server/EntityEnderCrystal.java
index 1942fae27051af79b6eb1d790a219da100bf889e..0e2f9777fe1b62f8da20bf7559150e1dd041febc 100644
--- a/src/main/java/net/minecraft/server/EntityEnderCrystal.java
+++ b/src/main/java/net/minecraft/server/EntityEnderCrystal.java
@@ -100,6 +100,22 @@ public class EntityEnderCrystal extends Entity {
         phantomDamageCooldown = 0;
         idleCooldown = 60;
     }
+
+    public boolean shouldExplode() {
+        return isShowingBottom() ? world.purpurConfig.baseCrystalExplode : world.purpurConfig.baselessCrystalExplode;
+    }
+
+    public float getExplosionPower() {
+        return (float) (isShowingBottom() ? world.purpurConfig.baseCrystalExplosionPower : world.purpurConfig.baselessCrystalExplosionPower);
+    }
+
+    public boolean hasExplosionFire() {
+        return isShowingBottom() ? world.purpurConfig.baseCrystalExplosionFire : world.purpurConfig.baselessCrystalExplosionFire;
+    }
+
+    public Explosion.Effect getExplosionEffect() {
+        return isShowingBottom() ? world.purpurConfig.baseCrystalExplosionEffect : world.purpurConfig.baselessCrystalExplosionEffect;
+    }
     // Purpur end
 
     @Override
@@ -143,15 +159,17 @@ public class EntityEnderCrystal extends Entity {
                 // CraftBukkit end
                 this.die();
                 if (!damagesource.isExplosion()) {
+                    if (shouldExplode()) { // Purpur
                     // CraftBukkit start
-                    ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, false);
+                    ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), getExplosionPower(), hasExplosionFire()); // Purpur
                     this.world.getServer().getPluginManager().callEvent(event);
                     if (event.isCancelled()) {
                         this.dead = false;
                         return false;
                     }
-                    this.world.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), Explosion.Effect.DESTROY);
+                    this.world.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), getExplosionEffect()); // Purpur
                     // CraftBukkit end
+                    } else this.dead = false; // Purpur
                 }
 
                 this.a(damagesource);
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 6481f8a964846ee835c2196197bd765d013377a4..20c4cd5ffe4d132012f1e55401e08cb894b80294 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -1913,4 +1913,33 @@ public class PurpurWorldConfig {
     private void imposeTeleportRestrictionsOnGateways() {
         imposeTeleportRestrictionsOnGateways = getBoolean("gameplay-mechanics.impose-teleport-restrictions-on-gateways", imposeTeleportRestrictionsOnGateways);
     }
+
+    public boolean baselessCrystalExplode = true;
+    public double baselessCrystalExplosionPower = 6.0D;
+    public boolean baselessCrystalExplosionFire = false;
+    public Explosion.Effect baselessCrystalExplosionEffect = Explosion.Effect.DESTROY;
+    public boolean baseCrystalExplode = true;
+    public double baseCrystalExplosionPower = 6.0D;
+    public boolean baseCrystalExplosionFire = false;
+    public Explosion.Effect baseCrystalExplosionEffect = Explosion.Effect.DESTROY;
+    private void crystalSettings() {
+        baselessCrystalExplode = getBoolean("blocks.end-crystal.baseless.explode", baselessCrystalExplode);
+        baselessCrystalExplosionPower = getDouble("blocks.end-crystal.baseless.explosion-power", baselessCrystalExplosionPower);
+        baselessCrystalExplosionFire = getBoolean("blocks.end-crystal.baseless.explosion-fire", baselessCrystalExplosionFire);
+        try {
+            baselessCrystalExplosionEffect = Explosion.Effect.valueOf(getString("blocks.end-crystal.baseless.explosion-effect", baselessCrystalExplosionEffect.name()));
+        } catch (IllegalArgumentException e) {
+            log(Level.SEVERE, "Unknown value for `blocks.end-crystal.baseless.explosion-effect`! Using default of `DESTROY`");
+            baselessCrystalExplosionEffect = Explosion.Effect.DESTROY;
+        }
+        baseCrystalExplode = getBoolean("blocks.end-crystal.base.explode", baseCrystalExplode);
+        baseCrystalExplosionPower = getDouble("blocks.end-crystal.base.explosion-power", baseCrystalExplosionPower);
+        baseCrystalExplosionFire = getBoolean("blocks.end-crystal.base.explosion-fire", baseCrystalExplosionFire);
+        try {
+            baseCrystalExplosionEffect = Explosion.Effect.valueOf(getString("blocks.end-crystal.base.explosion-effect", baseCrystalExplosionEffect.name()));
+        } catch (IllegalArgumentException e) {
+            log(Level.SEVERE, "Unknown value for `blocks.end-crystal.base.explosion-effect`! Using default of `DESTROY`");
+            baseCrystalExplosionEffect = Explosion.Effect.DESTROY;
+        }
+    }
 }
