mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-21 10:27:44 +01:00
Llama API
This commit is contained in:
committed by
granny
parent
3f0b653764
commit
c5902528c1
@@ -2409,10 +2409,10 @@ index c6d0700f29d6c8123e96efe225faf2d99202ac81..361bf346153912bcbfcf962d7f716dfe
|
||||
protected void randomizeAttributes(RandomSource random) {
|
||||
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(generateMaxHealth(random::nextInt));
|
||||
diff --git a/net/minecraft/world/entity/animal/horse/Llama.java b/net/minecraft/world/entity/animal/horse/Llama.java
|
||||
index 58bb056ce934c793b16e63e44a4029be955c7caa..81a72b5ddbf7644d65dea972821d19e8fccd9b48 100644
|
||||
index 7618207f4ec7adeec8496e426037e6d17689daab..be40cfeb2f387ba50dea086432a453a268f18579 100644
|
||||
--- a/net/minecraft/world/entity/animal/horse/Llama.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/Llama.java
|
||||
@@ -77,7 +77,51 @@ public class Llama extends AbstractChestedHorse implements VariantHolder<Llama.V
|
||||
@@ -78,7 +78,51 @@ public class Llama extends AbstractChestedHorse implements VariantHolder<Llama.V
|
||||
super(entityType, level);
|
||||
this.getNavigation().setRequiredPathLength(40.0F);
|
||||
this.maxDomestication = 30; // Paper - Missing entity API; configure max temper instead of a hardcoded value
|
||||
@@ -2464,7 +2464,7 @@ index 58bb056ce934c793b16e63e44a4029be955c7caa..81a72b5ddbf7644d65dea972821d19e8
|
||||
|
||||
public boolean isTraderLlama() {
|
||||
return false;
|
||||
@@ -118,6 +162,7 @@ public class Llama extends AbstractChestedHorse implements VariantHolder<Llama.V
|
||||
@@ -121,6 +165,7 @@ public class Llama extends AbstractChestedHorse implements VariantHolder<Llama.V
|
||||
@Override
|
||||
protected void registerGoals() {
|
||||
this.goalSelector.addGoal(0, new FloatGoal(this));
|
||||
@@ -2472,7 +2472,7 @@ index 58bb056ce934c793b16e63e44a4029be955c7caa..81a72b5ddbf7644d65dea972821d19e8
|
||||
this.goalSelector.addGoal(1, new RunAroundLikeCrazyGoal(this, 1.2));
|
||||
this.goalSelector.addGoal(2, new LlamaFollowCaravanGoal(this, 2.1F));
|
||||
this.goalSelector.addGoal(3, new RangedAttackGoal(this, 1.25, 40, 20.0F));
|
||||
@@ -128,6 +173,7 @@ public class Llama extends AbstractChestedHorse implements VariantHolder<Llama.V
|
||||
@@ -131,6 +176,7 @@ public class Llama extends AbstractChestedHorse implements VariantHolder<Llama.V
|
||||
this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 0.7));
|
||||
this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 6.0F));
|
||||
this.goalSelector.addGoal(9, new RandomLookAroundGoal(this));
|
||||
|
||||
@@ -717,10 +717,10 @@ index 361bf346153912bcbfcf962d7f716dfe12ae2a7b..8bd118e82da9e4d4153de0a3efaf6d69
|
||||
protected void randomizeAttributes(RandomSource random) {
|
||||
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(generateMaxHealth(random::nextInt));
|
||||
diff --git a/net/minecraft/world/entity/animal/horse/Llama.java b/net/minecraft/world/entity/animal/horse/Llama.java
|
||||
index 81a72b5ddbf7644d65dea972821d19e8fccd9b48..4946bc7140ca7859d908bcd46a9acb4dac3f3417 100644
|
||||
index be40cfeb2f387ba50dea086432a453a268f18579..8b6beeff7ad0c7ca7bc09f505891f560096d5c9a 100644
|
||||
--- a/net/minecraft/world/entity/animal/horse/Llama.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/Llama.java
|
||||
@@ -123,6 +123,23 @@ public class Llama extends AbstractChestedHorse implements VariantHolder<Llama.V
|
||||
@@ -124,6 +124,23 @@ public class Llama extends AbstractChestedHorse implements VariantHolder<Llama.V
|
||||
}
|
||||
// Purpur end - Ridables
|
||||
|
||||
@@ -1321,7 +1321,7 @@ index a58a0d5d3872a57c8c5e464bd0f6d2fd7a054990..acfb473c0a085ed516ff25ebac366700
|
||||
protected void registerGoals() {
|
||||
super.registerGoals();
|
||||
diff --git a/net/minecraft/world/entity/monster/Shulker.java b/net/minecraft/world/entity/monster/Shulker.java
|
||||
index 4dfc35f04ff841aa4fa198412c97cf59f843b4c2..83a8efba5937d61437c745f9b4be5aa02e7aac83 100644
|
||||
index 87507f5fad41e7339b02e8a425d41d6213656fbb..9c17ffa96361ad374ec2d0d5816f3cb300b45b15 100644
|
||||
--- a/net/minecraft/world/entity/monster/Shulker.java
|
||||
+++ b/net/minecraft/world/entity/monster/Shulker.java
|
||||
@@ -105,6 +105,12 @@ public class Shulker extends AbstractGolem implements VariantHolder<Optional<Dye
|
||||
|
||||
@@ -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) {
|
||||
@@ -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;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java
|
||||
@@ -90,4 +_,16 @@
|
||||
return this.getHandle().caravanTail == null ? null : (Llama) this.getHandle().caravanTail.getBukkitEntity();
|
||||
}
|
||||
// Paper end
|
||||
+
|
||||
+ // Purpur start
|
||||
+ @Override
|
||||
+ public boolean shouldJoinCaravan() {
|
||||
+ return getHandle().shouldJoinCaravan;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setShouldJoinCaravan(boolean shouldJoinCaravan) {
|
||||
+ getHandle().shouldJoinCaravan = shouldJoinCaravan;
|
||||
+ }
|
||||
+ // Purpur end
|
||||
}
|
||||
Reference in New Issue
Block a user