From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <blake.galbreath@gmail.com>
Date: Sat, 13 Feb 2021 14:02:43 -0600
Subject: [PATCH] Add ghast allow-griefing option


diff --git a/src/main/java/net/minecraft/server/EntityGhast.java b/src/main/java/net/minecraft/server/EntityGhast.java
index 2c0148229283f95bed3c8f33cc02a31d6f682191..db96d2bb02dfeea4136eb587a7bd744c9eb30bf3 100644
--- a/src/main/java/net/minecraft/server/EntityGhast.java
+++ b/src/main/java/net/minecraft/server/EntityGhast.java
@@ -198,6 +198,7 @@ public class EntityGhast extends EntityFlying implements IMonster {
                     }
 
                     EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4);
+                    entitylargefireball.canCauseGrief = world.purpurConfig.ghastAllowGriefing; // Purpur
 
                     // CraftBukkit - set bukkitYield when setting explosionpower
                     entitylargefireball.bukkitYield = entitylargefireball.yield = this.ghast.getPower();
diff --git a/src/main/java/net/minecraft/server/EntityLargeFireball.java b/src/main/java/net/minecraft/server/EntityLargeFireball.java
index 3f3be1b2ded6ad118ae7860c1231c7affc0715b6..48174610518af8d053149e609c1b140e1ae6ba61 100644
--- a/src/main/java/net/minecraft/server/EntityLargeFireball.java
+++ b/src/main/java/net/minecraft/server/EntityLargeFireball.java
@@ -5,6 +5,7 @@ import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
 public class EntityLargeFireball extends EntityFireballFireball {
 
     public int yield = 1;
+    public boolean canCauseGrief = true; // Purpur
 
     public EntityLargeFireball(EntityTypes<? extends EntityLargeFireball> entitytypes, World world) {
         super(entitytypes, world);
@@ -20,7 +21,7 @@ public class EntityLargeFireball extends EntityFireballFireball {
     protected void a(MovingObjectPosition movingobjectposition) {
         super.a(movingobjectposition);
         if (!this.world.isClientSide) {
-            boolean flag = this.world.purpurConfig.fireballsBypassMobGriefing || this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING); // Purpur
+            boolean flag = isIncendiary = canCauseGrief && (this.world.purpurConfig.fireballsBypassMobGriefing || this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)); // Purpur
 
             // CraftBukkit start - fire ExplosionPrimeEvent
             ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity());
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 20c4cd5ffe4d132012f1e55401e08cb894b80294..64657c3c9250d8767702a54bb0ee3a23f43da04a 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -866,6 +866,7 @@ public class PurpurWorldConfig {
     public boolean ghastRidable = false;
     public boolean ghastRidableInWater = false;
     public double ghastMaxY = 256D;
+    public boolean ghastAllowGriefing = true;
     public double ghastMaxHealth = 10.0D;
     private void ghastSettings() {
         ghastRidable = getBoolean("mobs.ghast.ridable", ghastRidable);
@@ -876,6 +877,7 @@ public class PurpurWorldConfig {
             set("mobs.ghast.attributes.max-health", null);
             set("mobs.ghast.attributes.max_health", oldValue);
         }
+        ghastAllowGriefing = getBoolean("mobs.ghast.allow-griefing", ghastAllowGriefing);
         ghastMaxHealth = getDouble("mobs.ghast.attributes.max_health", ghastMaxHealth);
     }
 
