mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
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.
This commit is contained in:
@@ -1,88 +0,0 @@
|
|||||||
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.
|
|
||||||
|
|
||||||
diff --git a/net/minecraft/world/entity/animal/Cat.java b/net/minecraft/world/entity/animal/Cat.java
|
|
||||||
index 06b68fcf750a637e1f41eecacca2969cb55a8fa8..8d20b19b65616d8470542cc7337c8ddd7418be0b 100644
|
|
||||||
--- a/net/minecraft/world/entity/animal/Cat.java
|
|
||||||
+++ b/net/minecraft/world/entity/animal/Cat.java
|
|
||||||
@@ -357,6 +357,14 @@ public class Cat extends TamableAnimal implements VariantHolder<Holder<CatVarian
|
|
||||||
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
|
|
||||||
+
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Cat getBreedOffspring(ServerLevel world, AgeableMob entity) {
|
|
||||||
diff --git a/net/minecraft/world/entity/animal/Wolf.java b/net/minecraft/world/entity/animal/Wolf.java
|
|
||||||
index 966fe4544212cc831ae617bc2eb05189102ff470..f1d2e40f55a91810693a5604f3060e284f615fa0 100644
|
|
||||||
--- a/net/minecraft/world/entity/animal/Wolf.java
|
|
||||||
+++ b/net/minecraft/world/entity/animal/Wolf.java
|
|
||||||
@@ -215,6 +215,12 @@ public class Wolf extends TamableAnimal implements NeutralMob, VariantHolder<Hol
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Purpur end - Configurable chance for wolves to spawn rabid
|
|
||||||
+ @Override
|
|
||||||
+ public void tame(Player player) {
|
|
||||||
+ setCollarColor(level().purpurConfig.wolfDefaultCollarColor);
|
|
||||||
+ super.tame(player);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
@Override
|
|
||||||
protected void registerGoals() {
|
|
||||||
this.goalSelector.addGoal(1, new FloatGoal(this));
|
|
||||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
||||||
index ece3de874b4ad6dd9f17190281dcad2eab6a3097..8caef74b83984c6351f7366376b64be50b50a41c 100644
|
|
||||||
--- a/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
||||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurWorldConfig.java
|
|
||||||
@@ -619,6 +619,7 @@ public class PurpurWorldConfig {
|
|
||||||
public int catSpawnSwampHutScanRange = 16;
|
|
||||||
public int catSpawnVillageScanRange = 48;
|
|
||||||
public int catBreedingTicks = 6000;
|
|
||||||
+ public DyeColor catDefaultCollarColor = DyeColor.RED;
|
|
||||||
private void catSettings() {
|
|
||||||
catRidable = getBoolean("mobs.cat.ridable", catRidable);
|
|
||||||
catRidableInWater = getBoolean("mobs.cat.ridable-in-water", catRidableInWater);
|
|
||||||
@@ -634,6 +635,11 @@ public class PurpurWorldConfig {
|
|
||||||
catSpawnSwampHutScanRange = getInt("mobs.cat.scan-range-for-other-cats.swamp-hut", catSpawnSwampHutScanRange);
|
|
||||||
catSpawnVillageScanRange = getInt("mobs.cat.scan-range-for-other-cats.village", catSpawnVillageScanRange);
|
|
||||||
catBreedingTicks = getInt("mobs.cat.breeding-delay-ticks", catBreedingTicks);
|
|
||||||
+ try {
|
|
||||||
+ catDefaultCollarColor = DyeColor.valueOf(getString("mobs.cat.default-collar-color", catDefaultCollarColor.name()));
|
|
||||||
+ } catch (IllegalArgumentException ignore) {
|
|
||||||
+ catDefaultCollarColor = DyeColor.RED;
|
|
||||||
+ }
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean caveSpiderRidable = false;
|
|
||||||
@@ -2064,6 +2070,7 @@ public class PurpurWorldConfig {
|
|
||||||
public boolean wolfControllable = true;
|
|
||||||
public double wolfMaxHealth = 8.0D;
|
|
||||||
public double wolfScale = 1.0D;
|
|
||||||
+ public DyeColor wolfDefaultCollarColor = DyeColor.RED;
|
|
||||||
public boolean wolfMilkCuresRabies = true;
|
|
||||||
public double wolfNaturalRabid = 0.0D;
|
|
||||||
public int wolfBreedingTicks = 6000;
|
|
||||||
@@ -2078,6 +2085,11 @@ public class PurpurWorldConfig {
|
|
||||||
}
|
|
||||||
wolfMaxHealth = getDouble("mobs.wolf.attributes.max_health", wolfMaxHealth);
|
|
||||||
wolfScale = Mth.clamp(getDouble("mobs.wolf.attributes.scale", wolfScale), 0.0625D, 16.0D);
|
|
||||||
+ 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);
|
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
--- a/net/minecraft/world/entity/animal/Cat.java
|
||||||
|
+++ b/net/minecraft/world/entity/animal/Cat.java
|
||||||
|
@@ -332,6 +_,14 @@
|
||||||
|
return this.isTame() && otherAnimal instanceof Cat cat && cat.isTame() && super.canMate(otherAnimal);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ // Purpur start - Configurable default collar color
|
||||||
|
+ @Override
|
||||||
|
+ public void tame(Player player) {
|
||||||
|
+ setCollarColor(level().purpurConfig.catDefaultCollarColor);
|
||||||
|
+ super.tame(player);
|
||||||
|
+ }
|
||||||
|
+ // Purpur end - Configurable default collar color
|
||||||
|
+
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public SpawnGroupData finalizeSpawn(
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
private static final float START_HEALTH = 8.0F;
|
private static final float START_HEALTH = 8.0F;
|
||||||
private static final float TAME_HEALTH = 40.0F;
|
private static final float TAME_HEALTH = 40.0F;
|
||||||
private static final float ARMOR_REPAIR_UNIT = 0.125F;
|
private static final float ARMOR_REPAIR_UNIT = 0.125F;
|
||||||
@@ -115,12 +_,39 @@
|
@@ -115,12 +_,47 @@
|
||||||
this.setPathfindingMalus(PathType.DANGER_POWDER_SNOW, -1.0F);
|
this.setPathfindingMalus(PathType.DANGER_POWDER_SNOW, -1.0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,6 +67,14 @@
|
|||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // Purpur end - Configurable chance for wolves to spawn rabid
|
+ // Purpur end - Configurable chance for wolves to spawn rabid
|
||||||
|
+
|
||||||
|
+ // Purpur start - Configurable default collar color
|
||||||
|
+ @Override
|
||||||
|
+ public void tame(Player player) {
|
||||||
|
+ setCollarColor(level().purpurConfig.wolfDefaultCollarColor);
|
||||||
|
+ super.tame(player);
|
||||||
|
+ }
|
||||||
|
+ // Purpur end - Configurable default collar color
|
||||||
+
|
+
|
||||||
@Override
|
@Override
|
||||||
protected void registerGoals() {
|
protected void registerGoals() {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import net.minecraft.core.registries.BuiltInRegistries;
|
|||||||
import net.minecraft.resources.ResourceLocation;
|
import net.minecraft.resources.ResourceLocation;
|
||||||
import net.minecraft.util.Mth;
|
import net.minecraft.util.Mth;
|
||||||
import net.minecraft.world.entity.monster.Shulker;
|
import net.minecraft.world.entity.monster.Shulker;
|
||||||
|
import net.minecraft.world.item.DyeColor;
|
||||||
import net.minecraft.world.item.Item;
|
import net.minecraft.world.item.Item;
|
||||||
import net.minecraft.world.item.Items;
|
import net.minecraft.world.item.Items;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
@@ -610,6 +611,7 @@ public class PurpurWorldConfig {
|
|||||||
public int catSpawnSwampHutScanRange = 16;
|
public int catSpawnSwampHutScanRange = 16;
|
||||||
public int catSpawnVillageScanRange = 48;
|
public int catSpawnVillageScanRange = 48;
|
||||||
public int catBreedingTicks = 6000;
|
public int catBreedingTicks = 6000;
|
||||||
|
public DyeColor catDefaultCollarColor = DyeColor.RED;
|
||||||
private void catSettings() {
|
private void catSettings() {
|
||||||
catRidable = getBoolean("mobs.cat.ridable", catRidable);
|
catRidable = getBoolean("mobs.cat.ridable", catRidable);
|
||||||
catRidableInWater = getBoolean("mobs.cat.ridable-in-water", catRidableInWater);
|
catRidableInWater = getBoolean("mobs.cat.ridable-in-water", catRidableInWater);
|
||||||
@@ -625,6 +627,11 @@ public class PurpurWorldConfig {
|
|||||||
catSpawnSwampHutScanRange = getInt("mobs.cat.scan-range-for-other-cats.swamp-hut", catSpawnSwampHutScanRange);
|
catSpawnSwampHutScanRange = getInt("mobs.cat.scan-range-for-other-cats.swamp-hut", catSpawnSwampHutScanRange);
|
||||||
catSpawnVillageScanRange = getInt("mobs.cat.scan-range-for-other-cats.village", catSpawnVillageScanRange);
|
catSpawnVillageScanRange = getInt("mobs.cat.scan-range-for-other-cats.village", catSpawnVillageScanRange);
|
||||||
catBreedingTicks = getInt("mobs.cat.breeding-delay-ticks", catBreedingTicks);
|
catBreedingTicks = getInt("mobs.cat.breeding-delay-ticks", catBreedingTicks);
|
||||||
|
try {
|
||||||
|
catDefaultCollarColor = DyeColor.valueOf(getString("mobs.cat.default-collar-color", catDefaultCollarColor.name()));
|
||||||
|
} catch (IllegalArgumentException ignore) {
|
||||||
|
catDefaultCollarColor = DyeColor.RED;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean caveSpiderRidable = false;
|
public boolean caveSpiderRidable = false;
|
||||||
@@ -2055,6 +2062,7 @@ public class PurpurWorldConfig {
|
|||||||
public boolean wolfControllable = true;
|
public boolean wolfControllable = true;
|
||||||
public double wolfMaxHealth = 8.0D;
|
public double wolfMaxHealth = 8.0D;
|
||||||
public double wolfScale = 1.0D;
|
public double wolfScale = 1.0D;
|
||||||
|
public DyeColor wolfDefaultCollarColor = DyeColor.RED;
|
||||||
public boolean wolfMilkCuresRabies = true;
|
public boolean wolfMilkCuresRabies = true;
|
||||||
public double wolfNaturalRabid = 0.0D;
|
public double wolfNaturalRabid = 0.0D;
|
||||||
public int wolfBreedingTicks = 6000;
|
public int wolfBreedingTicks = 6000;
|
||||||
@@ -2069,6 +2077,11 @@ public class PurpurWorldConfig {
|
|||||||
}
|
}
|
||||||
wolfMaxHealth = getDouble("mobs.wolf.attributes.max_health", wolfMaxHealth);
|
wolfMaxHealth = getDouble("mobs.wolf.attributes.max_health", wolfMaxHealth);
|
||||||
wolfScale = Mth.clamp(getDouble("mobs.wolf.attributes.scale", wolfScale), 0.0625D, 16.0D);
|
wolfScale = Mth.clamp(getDouble("mobs.wolf.attributes.scale", wolfScale), 0.0625D, 16.0D);
|
||||||
|
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);
|
wolfMilkCuresRabies = getBoolean("mobs.wolf.milk-cures-rabid-wolves", wolfMilkCuresRabies);
|
||||||
wolfNaturalRabid = getDouble("mobs.wolf.spawn-rabid-chance", wolfNaturalRabid);
|
wolfNaturalRabid = getDouble("mobs.wolf.spawn-rabid-chance", wolfNaturalRabid);
|
||||||
wolfBreedingTicks = getInt("mobs.wolf.breeding-delay-ticks", wolfBreedingTicks);
|
wolfBreedingTicks = getInt("mobs.wolf.breeding-delay-ticks", wolfBreedingTicks);
|
||||||
|
|||||||
Reference in New Issue
Block a user