Skip to content

Commit a058ac0

Browse files
authored
Dolphin API (#7102)
1 parent 9a19308 commit a058ac0

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed

patches/api/0361-Dolphin-API.patch

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
3+
Date: Tue, 7 Dec 2021 19:34:11 -0500
4+
Subject: [PATCH] Dolphin API
5+
6+
7+
diff --git a/src/main/java/org/bukkit/entity/Dolphin.java b/src/main/java/org/bukkit/entity/Dolphin.java
8+
index f00eaadcdde7ceef95def2d8ec6eb63a76c177bd..8ab329946daaff25646f3dd4582feb9e4c0685ca 100644
9+
--- a/src/main/java/org/bukkit/entity/Dolphin.java
10+
+++ b/src/main/java/org/bukkit/entity/Dolphin.java
11+
@@ -1,3 +1,52 @@
12+
package org.bukkit.entity;
13+
14+
-public interface Dolphin extends WaterMob { }
15+
+import org.bukkit.Location;
16+
+
17+
+public interface Dolphin extends WaterMob { // Paper start - Dolphin API
18+
+
19+
+ /**
20+
+ * Gets the moistness level of this dolphin
21+
+ */
22+
+ int getMoistness();
23+
+
24+
+ /**
25+
+ * Sets the moistness of this dolphin, once this is less than 0 the dolphin will start to take damage.
26+
+ *
27+
+ * @param moistness moistness level
28+
+ */
29+
+ void setMoistness(int moistness);
30+
+
31+
+ /**
32+
+ * Sets if this dolphin was fed a fish.
33+
+ *
34+
+ * @param hasFish has a fish
35+
+ */
36+
+ void setHasFish(boolean hasFish);
37+
+
38+
+ /**
39+
+ * Gets if this dolphin has a fish.
40+
+ *
41+
+ * @return has a fish
42+
+ */
43+
+ boolean hasFish();
44+
+
45+
+ /**
46+
+ * Gets the treasure location this dolphin tries to guide players to.
47+
+ * <p>
48+
+ * This value is calculated if the player has fed the dolphin a fish, and it tries to start the {@link com.destroystokyo.paper.entity.ai.VanillaGoal#DOLPHIN_SWIM_TO_TREASURE} goal.
49+
+ *
50+
+ * @return calculated closest treasure location
51+
+ */
52+
+ @org.jetbrains.annotations.NotNull
53+
+ Location getTreasureLocation();
54+
+
55+
+ /**
56+
+ * Sets the treasure location that this dolphin will try to lead the player to.
57+
+ * This only has an effect if the dolphin is currently leading a player, as this value is recalculated next time it leads a player.
58+
+ * <p>
59+
+ * The world of the location does not matter, as the dolphin will always use the world it is currently in.
60+
+ *
61+
+ * @param location location to guide to
62+
+ */
63+
+ void setTreasureLocation(@org.jetbrains.annotations.NotNull Location location);
64+
+} // Paper end - Dolphin API
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
3+
Date: Tue, 7 Dec 2021 19:34:23 -0500
4+
Subject: [PATCH] Dolphin API
5+
6+
7+
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java
8+
index 938e141f161acf5de5d3361382b514caea02c6fb..75919bf87b6f5cad06ca76888e284e2548594f00 100644
9+
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java
10+
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java
11+
@@ -24,4 +24,34 @@ public class CraftDolphin extends CraftWaterMob implements Dolphin {
12+
public EntityType getType() {
13+
return EntityType.DOLPHIN;
14+
}
15+
+
16+
+ @Override
17+
+ public int getMoistness() {
18+
+ return this.getHandle().getMoistnessLevel();
19+
+ }
20+
+
21+
+ @Override
22+
+ public void setMoistness(int moistness) {
23+
+ this.getHandle().setMoisntessLevel(moistness);
24+
+ }
25+
+
26+
+ @Override
27+
+ public void setHasFish(boolean hasFish) {
28+
+ this.getHandle().setGotFish(hasFish);
29+
+ }
30+
+
31+
+ @Override
32+
+ public boolean hasFish() {
33+
+ return this.getHandle().gotFish();
34+
+ }
35+
+
36+
+ @Override
37+
+ public org.bukkit.Location getTreasureLocation() {
38+
+ return net.minecraft.server.MCUtil.toLocation(this.getHandle().level, this.getHandle().getTreasurePos());
39+
+ }
40+
+
41+
+ @Override
42+
+ public void setTreasureLocation(org.bukkit.Location location) {
43+
+ this.getHandle().setTreasurePos(net.minecraft.server.MCUtil.toBlockPosition(location));
44+
+ }
45+
}

0 commit comments

Comments
 (0)