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 8f6c3e9eaefc0a15aefde7119f2e123894d434b7..bc088e237e6f1f2a4cde766b7586a621f1cb54e2 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Cat.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Cat.java
|
|
@@ -367,6 +367,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(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 1c971eaf2fca2d1cdc89809f673e49de107a4a46..a669a00d68807ed451a1b0def7a92e17ffb7bee1 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Wolf.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Wolf.java
|
|
@@ -193,6 +193,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 da0849e6e38a2c54410bd158b16f8f3e79e60066..4e889a369b1bf75e6ed3f175997b4604eaeb4414 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -588,6 +588,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;
|
|
@@ -601,6 +602,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);
|
|
@@ -1753,6 +1759,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;
|
|
@@ -1765,6 +1772,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);
|