From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Encode42 <me@encode42.dev>
Date: Wed, 17 Mar 2021 10:12:53 -0400
Subject: [PATCH] Config to disable Llama caravans

Disables the mechanic where llamas follow leashed llamas.

diff --git a/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalLlamaFollow.java b/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalLlamaFollow.java
index 34a854131dd939693a6df4d52103714ebe373dc3..ea02a78c31ed43220a2b83be4bd2a896500a70b8 100644
--- a/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalLlamaFollow.java
+++ b/src/main/java/net/minecraft/world/entity/ai/goal/PathfinderGoalLlamaFollow.java
@@ -23,7 +23,7 @@ public class PathfinderGoalLlamaFollow extends PathfinderGoal {
 
     @Override
     public boolean a() {
-        if (!getLlama().shouldJoinCaravan) return false; // Purpur
+        if (!getLlama().world.purpurConfig.llamaCaravans || !getLlama().shouldJoinCaravan) return false; // Purpur
         if (!this.a.isLeashed() && !this.a.fC()) {
             List<Entity> list = this.a.world.getEntities(this.a, this.a.getBoundingBox().grow(9.0D, 4.0D, 9.0D), (entity) -> {
                 EntityTypes<?> entitytypes = entity.getEntityType();
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/EntityLlama.java b/src/main/java/net/minecraft/world/entity/animal/horse/EntityLlama.java
index 762fed5ba27474951c1962e6f034e8494b1035d6..567a1da3c167c20ae3fb86c2a1f3608ebb1056b6 100644
--- a/src/main/java/net/minecraft/world/entity/animal/horse/EntityLlama.java
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/EntityLlama.java
@@ -518,7 +518,7 @@ public class EntityLlama extends EntityHorseChestedAbstract implements IRangedEn
 
     public void joinCaravan(EntityLlama entitiyllama) { a(entitiyllama); } // Purpur - OBFHELPER
     public void a(EntityLlama entityllama) {
-        if (!shouldJoinCaravan || !new net.pl3x.purpur.event.entity.LlamaJoinCaravanEvent((org.bukkit.entity.Llama) getBukkitEntity(), (org.bukkit.entity.Llama) entityllama.getBukkitEntity()).callEvent()) return; // Purpur
+        if (!this.world.purpurConfig.llamaCaravans || !shouldJoinCaravan || !new net.pl3x.purpur.event.entity.LlamaJoinCaravanEvent((org.bukkit.entity.Llama) getBukkitEntity(), (org.bukkit.entity.Llama) entityllama.getBukkitEntity()).callEvent()) return; // Purpur
         this.bB = entityllama;
         this.bB.bC = this;
     }
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 8491e9198c302bf62648498d84f62b505695cfef..61361ca712cdc92c76b64dd2a87cea0080edc02e 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -1075,6 +1075,7 @@ public class PurpurWorldConfig {
 
     public boolean llamaRidable = false;
     public boolean llamaRidableInWater = false;
+    public boolean llamaCaravans = true;
     public int llamaBreedingTicks = 6000;
     public double llamaMaxHealthMin = 15.0D;
     public double llamaMaxHealthMax = 30.0D;
@@ -1085,6 +1086,7 @@ public class PurpurWorldConfig {
     private void llamaSettings() {
         llamaRidable = getBoolean("mobs.llama.ridable", llamaRidable);
         llamaRidableInWater = getBoolean("mobs.llama.ridable-in-water", llamaRidableInWater);
+        llamaCaravans = getBoolean("mobs.llama.join-caravans", llamaCaravans);
         llamaBreedingTicks = getInt("mobs.llama.breeding-delay-ticks", llamaBreedingTicks);
         if (PurpurConfig.version < 10) {
             double oldMin = getDouble("mobs.llama.attributes.max-health.min", llamaMaxHealthMin);
