From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: William Blake Galbreath 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 730958dab7f074930cdccb88a89aa26e2b6a112b..b1ba0f24dd6f1ec4c60208564e4eb84bdcd457f4 100644 --- a/src/main/java/net/minecraft/world/entity/GlowSquid.java +++ b/src/main/java/net/minecraft/world/entity/GlowSquid.java @@ -41,6 +41,11 @@ public class GlowSquid extends Squid { 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; + } + @Override protected ParticleOptions getInkParticle() { return ParticleTypes.GLOW_SQUID_INK; 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 de0a015cc944c36358fc34a3142ecbf9d2a332b5..1431d7f295614641c1a5a5197f4bac3fd0cd9d71 100644 --- a/src/main/java/net/minecraft/world/entity/animal/Squid.java +++ b/src/main/java/net/minecraft/world/entity/animal/Squid.java @@ -83,6 +83,15 @@ public class Squid extends WaterAnimal { return super.getAxisForFluidCheck().offsetY(level().purpurConfig.squidOffsetWaterCheck); } + public boolean canFly() { + return this.level().purpurConfig.squidsCanFly; + } + + @Override + public boolean isInWater() { + return this.wasTouchingWater || canFly(); + } + @Override protected void registerGoals() { this.goalSelector.addGoal(0, new Squid.SquidRandomMovementGoal(this)); @@ -155,6 +164,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; @@ -314,7 +324,7 @@ public class Squid extends WaterAnimal { if (i > 100) { this.squid.setMovementVector(0.0F, 0.0F, 0.0F); - } else if (this.squid.getRandom().nextInt(reducedTickDelay(50)) == 0 || !this.squid.wasTouchingWater || !this.squid.hasMovementVector()) { + } else if (this.squid.getRandom().nextInt(reducedTickDelay(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/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java index 7d637e9139a3c2415c78bd238b0d105beb38daff..335189e415ed96c45d0d1b4e97098728da8512f3 100644 --- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java +++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java @@ -908,10 +908,12 @@ public class PurpurWorldConfig { public boolean glowSquidRidable = false; public boolean glowSquidControllable = true; public double glowSquidMaxHealth = 10.0D; + public boolean glowSquidsCanFly = false; private void glowSquidSettings() { glowSquidRidable = getBoolean("mobs.glow_squid.ridable", glowSquidRidable); glowSquidControllable = getBoolean("mobs.glow_squid.controllable", glowSquidControllable); glowSquidMaxHealth = getDouble("mobs.glow_squid.attributes.max_health", glowSquidMaxHealth); + glowSquidsCanFly = getBoolean("mobs.glow_squid.can-fly", glowSquidsCanFly); } public boolean goatRidable = false; @@ -1543,6 +1545,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); squidControllable = getBoolean("mobs.squid.controllable", squidControllable); @@ -1554,6 +1557,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;