From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Sun, 4 Oct 2020 12:00:42 -0500
Subject: [PATCH] Flying squids! Oh my!


diff --git a/src/main/java/net/minecraft/world/entity/GlowSquid.java b/src/main/java/net/minecraft/world/entity/GlowSquid.java
index 87d01bebbb179eec53323e9e23db011a791660ed..02b79aa6f4c472a9450549b1730f026d6d93b87b 100644
--- a/src/main/java/net/minecraft/world/entity/GlowSquid.java
+++ b/src/main/java/net/minecraft/world/entity/GlowSquid.java
@@ -34,6 +34,11 @@ public class GlowSquid extends Squid {
     public void initAttributes() {
         this.getAttribute(net.minecraft.world.entity.ai.attributes.Attributes.MAX_HEALTH).setBaseValue(this.level.purpurConfig.glowSquidMaxHealth);
     }
+
+    @Override
+    public boolean canFly() {
+        return this.level.purpurConfig.glowSquidsCanFly;
+    }
     // Purpur end
 
     @Override
diff --git a/src/main/java/net/minecraft/world/entity/animal/Squid.java b/src/main/java/net/minecraft/world/entity/animal/Squid.java
index 2affff346a7fe81480e86cb61996039df0569853..12be4a2f25a7def8341acda47d10a256c044aec2 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Squid.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Squid.java
@@ -85,6 +85,15 @@ public class Squid extends WaterAnimal {
         // Stops squids from floating just over the water
         return this.getBoundingBox().deflate(0.001D).offsetY(level.purpurConfig.squidOffsetWaterCheck);
     }
+
+    public boolean canFly() {
+        return this.level.purpurConfig.squidsCanFly;
+    }
+
+    @Override
+    public boolean isInWater() {
+        return this.wasTouchingWater || canFly();
+    }
     // Purpur end
 
     @Override
@@ -159,6 +168,7 @@ public class Squid extends WaterAnimal {
         }
 
         if (this.isInWaterOrBubble()) {
+            if (canFly()) setNoGravity(!wasTouchingWater); // Purpur
             if (this.tentacleMovement < 3.1415927F) {
                 float f = this.tentacleMovement / 3.1415927F;
 
@@ -320,7 +330,7 @@ public class Squid extends WaterAnimal {
 
             if (i > 100) {
                 this.squid.setMovementVector(0.0F, 0.0F, 0.0F);
-            } else if (this.squid.getRandom().nextInt(50) == 0 || !this.squid.wasTouchingWater || !this.squid.hasMovementVector()) {
+            } else if (this.squid.getRandom().nextInt(50) == 0 || !this.squid.isInWater() || !this.squid.hasMovementVector()) { // Purpur
                 float f = this.squid.getRandom().nextFloat() * 6.2831855F;
                 float f1 = Mth.cos(f) * 0.2F;
                 float f2 = -0.1F + this.squid.getRandom().nextFloat() * 0.2F;
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index e1aab2eee7b3c3148f48417126bee94e91968033..0653652a130841d15365d4843f864c3169c82e12 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -818,9 +818,11 @@ public class PurpurWorldConfig {
 
     public boolean glowSquidRidable = false;
     public double glowSquidMaxHealth = 10.0D;
+    public boolean glowSquidsCanFly = false;
     private void glowSquidSettings() {
         glowSquidRidable = getBoolean("mobs.glow_squid.ridable", glowSquidRidable);
         glowSquidMaxHealth = getDouble("mobs.glow_squid.attributes.max_health", glowSquidMaxHealth);
+        glowSquidsCanFly = getBoolean("mobs.glow_squid.can-fly", glowSquidsCanFly);
     }
 
     public boolean goatRidable = false;
@@ -1376,6 +1378,7 @@ public class PurpurWorldConfig {
     public double squidMaxHealth = 10.0D;
     public boolean squidImmuneToEAR = true;
     public double squidOffsetWaterCheck = 0.0D;
+    public boolean squidsCanFly = false;
     private void squidSettings() {
         squidRidable = getBoolean("mobs.squid.ridable", squidRidable);
         if (PurpurConfig.version < 10) {
@@ -1386,6 +1389,7 @@ public class PurpurWorldConfig {
         squidMaxHealth = getDouble("mobs.squid.attributes.max_health", squidMaxHealth);
         squidImmuneToEAR = getBoolean("mobs.squid.immune-to-EAR", squidImmuneToEAR);
         squidOffsetWaterCheck = getDouble("mobs.squid.water-offset-check", squidOffsetWaterCheck);
+        squidsCanFly = getBoolean("mobs.squid.can-fly", squidsCanFly);
     }
 
     public boolean spiderRidable = false;
