From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Thu, 13 Aug 2020 04:00:26 -0500
Subject: [PATCH] Stop squids floating on top of water


diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index fd3aff71f8e4ffd4faabc2650d8d83c8e6e85946..6bd301f998f66eb8c4f9cccac2f72f42be4c1b00 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -3868,11 +3868,17 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
         this.yRotO = this.getYRot();
     }
 
+    // Purpur start
+    public AABB getAxisForFluidCheck() {
+        return this.getBoundingBox().deflate(0.001D);
+    }
+    // Purpur end
+
     public boolean updateFluidHeightAndDoFluidPushing(Tag<Fluid> tag, double d0) {
         if (this.touchingUnloadedChunk()) {
             return false;
         } else {
-            AABB axisalignedbb = this.getBoundingBox().deflate(0.001D);
+            AABB axisalignedbb = getAxisForFluidCheck(); // Purpur
             int i = Mth.floor(axisalignedbb.minX);
             int j = Mth.ceil(axisalignedbb.maxX);
             int k = Mth.floor(axisalignedbb.minY);
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 f96def2ebdf114823c322c2d4318d039e20eab97..2affff346a7fe81480e86cb61996039df0569853 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Squid.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Squid.java
@@ -79,6 +79,12 @@ public class Squid extends WaterAnimal {
     public void initAttributes() {
         this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(this.level.purpurConfig.squidMaxHealth);
     }
+
+    @Override
+    public net.minecraft.world.phys.AABB getAxisForFluidCheck() {
+        // Stops squids from floating just over the water
+        return this.getBoundingBox().deflate(0.001D).offsetY(level.purpurConfig.squidOffsetWaterCheck);
+    }
     // Purpur end
 
     @Override
diff --git a/src/main/java/net/minecraft/world/phys/AABB.java b/src/main/java/net/minecraft/world/phys/AABB.java
index 6f7e6429c35eea346517cbf08cf223fc6d838a8c..6a77112180556675af38cb1b3ce0b38a42ce9525 100644
--- a/src/main/java/net/minecraft/world/phys/AABB.java
+++ b/src/main/java/net/minecraft/world/phys/AABB.java
@@ -367,4 +367,10 @@ public class AABB {
     public static AABB ofSize(Vec3 center, double dx, double dy, double dz) {
         return new AABB(center.x - dx / 2.0D, center.y - dy / 2.0D, center.z - dz / 2.0D, center.x + dx / 2.0D, center.y + dy / 2.0D, center.z + dz / 2.0D);
     }
+
+    // Purpur - tuinity added method
+    public final AABB offsetY(double dy) {
+        return new AABB(this.minX, this.minY + dy, this.minZ, this.maxX, this.maxY + dy, this.maxZ);
+    }
+    // Purpur
 }
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index a9388714c4bbe576dd0b4dd4f11a346d12d9f002..e59c9a2a4624ac89de30f486dac6d1aef3d914e5 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -1319,6 +1319,7 @@ public class PurpurWorldConfig {
     public boolean squidRidable = false;
     public double squidMaxHealth = 10.0D;
     public boolean squidImmuneToEAR = true;
+    public double squidOffsetWaterCheck = 0.0D;
     private void squidSettings() {
         squidRidable = getBoolean("mobs.squid.ridable", squidRidable);
         if (PurpurConfig.version < 10) {
@@ -1328,6 +1329,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);
     }
 
     public boolean spiderRidable = false;
