From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Encode42 <me@encode42.dev>
Date: Thu, 10 Dec 2020 13:43:28 -0500
Subject: [PATCH] Configurable default wolf collar color

This allows for the server to set a default collar color when a wolf is tamed.
Resets to RED when the value is invalid.

diff --git a/src/main/java/net/minecraft/world/entity/animal/Wolf.java b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
index 3e7409ebf1f94b9cf55f2d0b0fe17ca8ec44659f..518dd0e6b4889c049e438b393baa795a5eac3e7d 100644
--- a/src/main/java/net/minecraft/world/entity/animal/Wolf.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
@@ -188,6 +188,12 @@ public class Wolf extends TamableAnimal implements NeutralMob {
         this.updatePathfinders(false);
         return super.finalizeSpawn(world, difficulty, type, data, nbt);
     }
+
+    @Override
+    public void tame(Player player) {
+        setCollarColor(level.purpurConfig.wolfDefaultCollarColor);
+        super.tame(player);
+    }
     // Purpur end
 
     @Override
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 9d17110efe1d606fcc446654d55d09716fd53e2c..125aceb43ce18c1dd0dae41c444394c3953773e1 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -1773,6 +1773,7 @@ public class PurpurWorldConfig {
     public boolean wolfRidable = false;
     public boolean wolfRidableInWater = false;
     public double wolfMaxHealth = 8.0D;
+    public DyeColor wolfDefaultCollarColor = DyeColor.RED;
     public boolean wolfMilkCuresRabies = true;
     public double wolfNaturalRabid = 0.0D;
     public int wolfBreedingTicks = 6000;
@@ -1785,6 +1786,11 @@ public class PurpurWorldConfig {
             set("mobs.wolf.attributes.max_health", oldValue);
         }
         wolfMaxHealth = getDouble("mobs.wolf.attributes.max_health", wolfMaxHealth);
+        try {
+            wolfDefaultCollarColor = DyeColor.valueOf(getString("mobs.wolf.default-collar-color", wolfDefaultCollarColor.name()));
+        } catch (IllegalArgumentException ignore) {
+            wolfDefaultCollarColor = DyeColor.RED;
+        }
         wolfMilkCuresRabies = getBoolean("mobs.wolf.milk-cures-rabid-wolves", wolfMilkCuresRabies);
         wolfNaturalRabid = getDouble("mobs.wolf.spawn-rabid-chance", wolfNaturalRabid);
         wolfBreedingTicks = getInt("mobs.wolf.breeding-delay-ticks", wolfBreedingTicks);
