Files
Purpur/patches/server/0092-Flying-squids-Oh-my.patch
2024-12-03 20:57:07 -08:00

94 lines
5.0 KiB
Diff

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 5a49c44b8f18a1c16f18a4798c733f99ca4e47b7..e282af89d635a2866a8655d1e4956f1bd2c6a85b 100644
--- a/src/main/java/net/minecraft/world/entity/GlowSquid.java
+++ b/src/main/java/net/minecraft/world/entity/GlowSquid.java
@@ -43,6 +43,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 c08de12a2857fef431621c2260274cbfc6032e73..8920fcbb5c76e11a91a9a8702525cd59b18fa057 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Squid.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Squid.java
@@ -84,6 +84,15 @@ public class Squid extends AgeableWaterCreature {
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));
@@ -162,6 +171,7 @@ public class Squid extends AgeableWaterCreature {
}
if (this.isInWaterOrBubble()) {
+ if (canFly()) setNoGravity(!wasTouchingWater); // Purpur
if (this.tentacleMovement < (float) Math.PI) {
float f = this.tentacleMovement / (float) Math.PI;
this.tentacleAngle = Mth.sin(f * f * (float) Math.PI) * (float) Math.PI * 0.25F;
@@ -374,7 +384,7 @@ public class Squid extends AgeableWaterCreature {
int i = this.squid.getNoActionTime();
if (i > 100) {
this.squid.movementVector = Vec3.ZERO;
- } 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() * (float) (Math.PI * 2);
this.squid.movementVector = new Vec3(
(double)(Mth.cos(f) * 0.2F), (double)(-0.1F + this.squid.getRandom().nextFloat() * 0.2F), (double)(Mth.sin(f) * 0.2F)
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
index f6771afafe3e9e672059f504982e90449492449c..fea279b9fbd7f989bf26f0fc1254b1ecb8ac4342 100644
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
@@ -946,11 +946,13 @@ public class PurpurWorldConfig {
public boolean glowSquidControllable = true;
public double glowSquidMaxHealth = 10.0D;
public double glowSquidScale = 1.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);
glowSquidScale = Mth.clamp(getDouble("mobs.glow_squid.attributes.scale", glowSquidScale), 0.0625D, 16.0D);
+ glowSquidsCanFly = getBoolean("mobs.glow_squid.can-fly", glowSquidsCanFly);
}
public boolean goatRidable = false;
@@ -1637,6 +1639,7 @@ public class PurpurWorldConfig {
public double squidScale = 1.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);
@@ -1649,6 +1652,7 @@ public class PurpurWorldConfig {
squidScale = Mth.clamp(getDouble("mobs.squid.attributes.scale", squidScale), 0.0625D, 16.0D);
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;