mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
91 lines
4.4 KiB
Diff
91 lines
4.4 KiB
Diff
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 collar color
|
|
|
|
This allows for the server to set a default collar color when a wolf or cat is tamed.
|
|
Resets to RED when the value is invalid.
|
|
|
|
test
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Cat.java b/src/main/java/net/minecraft/world/entity/animal/Cat.java
|
|
index bad5b47f3df186c77e578d5953cf1798179639d3..8355aa65b6f8be5027370fada8758510b774b4b2 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Cat.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Cat.java
|
|
@@ -366,6 +366,14 @@ public class Cat extends TamableAnimal {
|
|
return Mth.lerp(tickDelta, this.relaxStateOneAmountO, this.relaxStateOneAmount);
|
|
}
|
|
|
|
+ // Purpur start
|
|
+ @Override
|
|
+ public void tame(Player player) {
|
|
+ setCollarColor(level.purpurConfig.catDefaultCollarColor);
|
|
+ super.tame(player);
|
|
+ }
|
|
+ // Purpur end
|
|
+
|
|
@Override
|
|
public Cat getBreedOffspring(ServerLevel world, AgeableMob entity) {
|
|
Cat entitycat = (Cat) EntityType.CAT.create((Level) world);
|
|
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 055cc874ec5fb9c3268b566620bf62adda6aa85a..bad3b1e32a8c8035542243a69028b3a8622019b8 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 b6967a953b8e3bf96653ce6f32af2c5a4a9d0509..0bf9306bb31e975101dccc3df4c776f16af84391 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -614,6 +614,7 @@ public class PurpurWorldConfig {
|
|
|
|
public boolean catRidable = false;
|
|
public boolean catRidableInWater = false;
|
|
+ public DyeColor catDefaultCollarColor = DyeColor.RED;
|
|
public double catMaxHealth = 10.0D;
|
|
public int catSpawnDelay = 1200;
|
|
public int catSpawnSwampHutScanRange = 16;
|
|
@@ -627,6 +628,11 @@ public class PurpurWorldConfig {
|
|
set("mobs.cat.attributes.max-health", null);
|
|
set("mobs.cat.attributes.max_health", oldValue);
|
|
}
|
|
+ try {
|
|
+ catDefaultCollarColor = DyeColor.valueOf(getString("mobs.cat.default-collar-color", wolfDefaultCollarColor.name()));
|
|
+ } catch (IllegalArgumentException ignore) {
|
|
+ catDefaultCollarColor = DyeColor.RED;
|
|
+ }
|
|
catMaxHealth = getDouble("mobs.cat.attributes.max_health", catMaxHealth);
|
|
catSpawnDelay = getInt("mobs.cat.spawn-delay", catSpawnDelay);
|
|
catSpawnSwampHutScanRange = getInt("mobs.cat.scan-range-for-other-cats.swamp-hut", catSpawnSwampHutScanRange);
|
|
@@ -1788,6 +1794,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;
|
|
@@ -1800,6 +1807,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);
|