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/world/entity/monster/EntityGhast.java b/src/main/java/net/minecraft/world/entity/monster/EntityGhast.java
index 5c39a9aec865d25a9aa5edcfd3a0fd6d1166cbd1..4bc8b6ec44a03390ced313e84b03ab6662a3c0a2 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EntityGhast.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EntityGhast.java
@@ -230,6 +230,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/world/entity/projectile/EntityLargeFireball.java b/src/main/java/net/minecraft/world/entity/projectile/EntityLargeFireball.java
index 61f06eacb4ea4ef869b60c9014cc23b25583eead..627915ee205fdcc93c5424ad7d7ea05783bc07ad 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/EntityLargeFireball.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/EntityLargeFireball.java
@@ -16,6 +16,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);
@@ -31,7 +32,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 535d30e65fcdf59aa42af0564aa8747504b804d5..3ea3c35865e0a467f86b93377dd069c3cf59ceb4 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -880,6 +880,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);
@@ -890,6 +891,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);
     }
 
