mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 05:47:45 +01:00
Tadpole lock API (#8297)
This commit is contained in:
parent
6b4dfb9627
commit
5297d99a4e
@ -896,6 +896,32 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
*/
|
*/
|
||||||
-public interface Salmon extends Fish { }
|
-public interface Salmon extends Fish { }
|
||||||
+public interface Salmon extends io.papermc.paper.entity.SchoolableFish { } // Paper - Schooling Fish API
|
+public interface Salmon extends io.papermc.paper.entity.SchoolableFish { } // Paper - Schooling Fish API
|
||||||
|
diff --git a/src/main/java/org/bukkit/entity/Tadpole.java b/src/main/java/org/bukkit/entity/Tadpole.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/entity/Tadpole.java
|
||||||
|
+++ b/src/main/java/org/bukkit/entity/Tadpole.java
|
||||||
|
@@ -0,0 +0,0 @@ public interface Tadpole extends Fish {
|
||||||
|
* @param age New age
|
||||||
|
*/
|
||||||
|
public void setAge(int age);
|
||||||
|
+
|
||||||
|
+ // Paper start - Tadpole age lock api
|
||||||
|
+ /**
|
||||||
|
+ * Lock the age of the animal, setting this will prevent the animal from
|
||||||
|
+ * maturing.
|
||||||
|
+ *
|
||||||
|
+ * @param lock new lock
|
||||||
|
+ */
|
||||||
|
+ void setAgeLock(boolean lock);
|
||||||
|
+
|
||||||
|
+ /**
|
||||||
|
+ * Gets the current agelock.
|
||||||
|
+ *
|
||||||
|
+ * @return the current agelock
|
||||||
|
+ */
|
||||||
|
+ boolean getAgeLock();
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/entity/Trident.java b/src/main/java/org/bukkit/entity/Trident.java
|
diff --git a/src/main/java/org/bukkit/entity/Trident.java b/src/main/java/org/bukkit/entity/Trident.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/entity/Trident.java
|
--- a/src/main/java/org/bukkit/entity/Trident.java
|
||||||
|
@ -135,6 +135,66 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
this.setFlag(2, nearTarget);
|
this.setFlag(2, nearTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||||
|
+++ b/src/main/java/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||||
|
@@ -0,0 +0,0 @@ public class Tadpole extends AbstractFish {
|
||||||
|
public int age;
|
||||||
|
protected static final ImmutableList<SensorType<? extends Sensor<? super Tadpole>>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.HURT_BY, SensorType.FROG_TEMPTATIONS);
|
||||||
|
protected static final ImmutableList<MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.NEAREST_VISIBLE_ADULT, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.BREED_TARGET, MemoryModuleType.IS_PANICKING);
|
||||||
|
+ public boolean ageLocked; // Paper
|
||||||
|
|
||||||
|
public Tadpole(EntityType<? extends AbstractFish> type, Level world) {
|
||||||
|
super(type, world);
|
||||||
|
@@ -0,0 +0,0 @@ public class Tadpole extends AbstractFish {
|
||||||
|
@Override
|
||||||
|
public void aiStep() {
|
||||||
|
super.aiStep();
|
||||||
|
- if (!this.level.isClientSide) {
|
||||||
|
+ if (!this.level.isClientSide && !this.ageLocked) { // Paper
|
||||||
|
this.setAge(this.age + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +0,0 @@ public class Tadpole extends AbstractFish {
|
||||||
|
public void addAdditionalSaveData(CompoundTag nbt) {
|
||||||
|
super.addAdditionalSaveData(nbt);
|
||||||
|
nbt.putInt("Age", this.age);
|
||||||
|
+ nbt.putBoolean("AgeLocked", this.ageLocked); // Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||||
|
super.readAdditionalSaveData(nbt);
|
||||||
|
this.setAge(nbt.getInt("Age"));
|
||||||
|
+ this.ageLocked = nbt.getBoolean("AgeLocked"); // Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@@ -0,0 +0,0 @@ public class Tadpole extends AbstractFish {
|
||||||
|
CompoundTag nbttagcompound = stack.getOrCreateTag();
|
||||||
|
|
||||||
|
nbttagcompound.putInt("Age", this.getAge());
|
||||||
|
+ nbttagcompound.putBoolean("AgeLocked", this.ageLocked); // Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -0,0 +0,0 @@ public class Tadpole extends AbstractFish {
|
||||||
|
this.setAge(nbt.getInt("Age"));
|
||||||
|
}
|
||||||
|
|
||||||
|
+ this.ageLocked = nbt.getBoolean("AgeLocked"); // Paper
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@@ -0,0 +0,0 @@ public class Tadpole extends AbstractFish {
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ageUp(int seconds) {
|
||||||
|
+ if (this.ageLocked) return; // Paper
|
||||||
|
this.setAge(this.age + seconds * 20);
|
||||||
|
}
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
--- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||||
@ -1005,6 +1065,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
|||||||
|
|
||||||
public CraftSalmon(CraftServer server, net.minecraft.world.entity.animal.Salmon entity) {
|
public CraftSalmon(CraftServer server, net.minecraft.world.entity.animal.Salmon entity) {
|
||||||
super(server, entity);
|
super(server, entity);
|
||||||
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java
|
||||||
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java
|
||||||
|
@@ -0,0 +0,0 @@ public class CraftTadpole extends CraftFish implements org.bukkit.entity.Tadpole
|
||||||
|
public void setAge(int age) {
|
||||||
|
this.getHandle().age = age;
|
||||||
|
}
|
||||||
|
+ // Paper start
|
||||||
|
+ @Override
|
||||||
|
+ public void setAgeLock(boolean lock) {
|
||||||
|
+ this.getHandle().ageLocked = lock;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ @Override
|
||||||
|
+ public boolean getAgeLock() {
|
||||||
|
+ return this.getHandle().ageLocked;
|
||||||
|
+ }
|
||||||
|
+ // Paper end
|
||||||
|
}
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java
|
||||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java
|
||||||
|
Loading…
Reference in New Issue
Block a user