Llama API

This commit is contained in:
William Blake Galbreath
2025-01-04 19:21:35 -08:00
committed by granny
parent 3f0b653764
commit c5902528c1
10 changed files with 203 additions and 235 deletions

View File

@@ -0,0 +1,18 @@
--- a/net/minecraft/world/entity/ai/goal/LlamaFollowCaravanGoal.java
+++ b/net/minecraft/world/entity/ai/goal/LlamaFollowCaravanGoal.java
@@ -22,6 +_,7 @@
@Override
public boolean canUse() {
+ if (!this.llama.shouldJoinCaravan) return false; // Purpur - Llama API
if (!this.llama.isLeashed() && !this.llama.inCaravan()) {
List<Entity> entities = this.llama.level().getEntities(this.llama, this.llama.getBoundingBox().inflate(9.0, 4.0, 9.0), entity1 -> {
EntityType<?> type = entity1.getType();
@@ -71,6 +_,7 @@
@Override
public boolean canContinueToUse() {
+ if (!this.llama.shouldJoinCaravan) return false; // Purpur - Llama API
if (this.llama.inCaravan() && this.llama.getCaravanHead().isAlive() && this.firstIsLeashed(this.llama, 0)) {
double d = this.llama.distanceToSqr(this.llama.getCaravanHead());
if (d > 676.0) {

View File

@@ -0,0 +1,42 @@
--- a/net/minecraft/world/entity/animal/horse/Llama.java
+++ b/net/minecraft/world/entity/animal/horse/Llama.java
@@ -72,6 +_,7 @@
private Llama caravanHead;
@Nullable
public Llama caravanTail; // Paper
+ public boolean shouldJoinCaravan = true; // Purpur - Llama API
public Llama(EntityType<? extends Llama> entityType, Level level) {
super(entityType, level);
@@ -106,6 +_,7 @@
super.addAdditionalSaveData(compound);
compound.putInt("Variant", this.getVariant().id);
compound.putInt("Strength", this.getStrength());
+ compound.putBoolean("Purpur.ShouldJoinCaravan", shouldJoinCaravan); // Purpur - Llama API
}
@Override
@@ -113,6 +_,7 @@
this.setStrength(compound.getInt("Strength"));
super.readAdditionalSaveData(compound);
this.setVariant(Llama.Variant.byId(compound.getInt("Variant")));
+ if (compound.contains("Purpur.ShouldJoinCaravan")) this.shouldJoinCaravan = compound.getBoolean("Purpur.ShouldJoinCaravan"); // Purpur - Llama API
}
@Override
@@ -386,6 +_,7 @@
public void leaveCaravan() {
if (this.caravanHead != null) {
+ new org.purpurmc.purpur.event.entity.LlamaLeaveCaravanEvent((org.bukkit.entity.Llama) getBukkitEntity()).callEvent(); // Purpur - Llama API
this.caravanHead.caravanTail = null;
}
@@ -393,6 +_,7 @@
}
public void joinCaravan(Llama caravanHead) {
+ if (!shouldJoinCaravan || !new org.purpurmc.purpur.event.entity.LlamaJoinCaravanEvent((org.bukkit.entity.Llama) getBukkitEntity(), (org.bukkit.entity.Llama) caravanHead.getBukkitEntity()).callEvent()) return; // Purpur - Llama API
this.caravanHead = caravanHead;
this.caravanHead.caravanTail = this;
}