mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fn: Add Cat Collars (#20)
* Add Collar Colors! * fancynpcs: Add cat collar colors *meow* * fancynpcs: Add issue with color not existing on 1.20.6 * fancynpcs: Fixed Color - CollarColor for clarity and consistancy! * fancynpcs: Fix missed 1.21.1 change --------- Co-authored-by: Clove Twilight <admin@mazeymoos.com>
This commit is contained in:
@@ -6,7 +6,9 @@ import de.oliver.fancynpcs.v1_19_4.ReflectionHelper;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.animal.Cat;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.checkerframework.checker.units.qual.N;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -33,6 +35,13 @@ public class CatAttributes {
|
||||
CatAttributes::setPose
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.CAT),
|
||||
CatAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@@ -61,4 +70,23 @@ public class CatAttributes {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setCollarColor(Npc npc, String value){
|
||||
final Cat cat = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()){
|
||||
cat.setTame(false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
DyeColor color = DyeColor.valueOf(value.toUpperCase());
|
||||
if (!cat.isTame()){
|
||||
cat.setTame(true);
|
||||
}
|
||||
cat.setCollarColor(color);
|
||||
} catch (IllegalArgumentException e){
|
||||
System.out.print("Invalid Color: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,10 +31,10 @@ public class WolfAttributes {
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"color",
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.WOLF),
|
||||
WolfAttributes::setColor
|
||||
WolfAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
@@ -57,7 +57,7 @@ public class WolfAttributes {
|
||||
wolf.setRemainingPersistentAngerTime(angry ? 100 : 0);
|
||||
}
|
||||
|
||||
private static void setColor(Npc npc, String value) {
|
||||
private static void setCollarColor(Npc npc, String value) {
|
||||
Wolf wolf = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import de.oliver.fancynpcs.v1_20_1.ReflectionHelper;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.animal.Cat;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -33,6 +34,13 @@ public class CatAttributes {
|
||||
CatAttributes::setPose
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.CAT),
|
||||
CatAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@@ -61,4 +69,23 @@ public class CatAttributes {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setCollarColor(Npc npc, String value){
|
||||
final Cat cat = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()){
|
||||
cat.setTame(false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
DyeColor color = DyeColor.valueOf(value.toUpperCase());
|
||||
if (!cat.isTame()){
|
||||
cat.setTame(true);
|
||||
}
|
||||
cat.setCollarColor(color);
|
||||
} catch (IllegalArgumentException e){
|
||||
System.out.print("Invalid Color: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@ public class WolfAttributes {
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"color",
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.WOLF),
|
||||
WolfAttributes::setColor
|
||||
WolfAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
@@ -56,7 +56,7 @@ public class WolfAttributes {
|
||||
wolf.setRemainingPersistentAngerTime(angry ? 100 : 0);
|
||||
}
|
||||
|
||||
private static void setColor(Npc npc, String value) {
|
||||
private static void setCollarColor(Npc npc, String value) {
|
||||
Wolf wolf = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import de.oliver.fancynpcs.api.NpcAttribute;
|
||||
import de.oliver.fancynpcs.v1_20_2.ReflectionHelper;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.entity.animal.Cat;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
@@ -33,6 +34,13 @@ public class CatAttributes {
|
||||
CatAttributes::setPose
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.CAT),
|
||||
CatAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@@ -61,4 +69,23 @@ public class CatAttributes {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setCollarColor(Npc npc, String value){
|
||||
final Cat cat = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()){
|
||||
cat.setTame(false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
DyeColor color = DyeColor.valueOf(value.toUpperCase());
|
||||
if (!cat.isTame()){
|
||||
cat.setTame(true);
|
||||
}
|
||||
cat.setCollarColor(color);
|
||||
} catch (IllegalArgumentException e){
|
||||
System.out.print("Invalid Color: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@ public class WolfAttributes {
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"color",
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.WOLF),
|
||||
WolfAttributes::setColor
|
||||
WolfAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
@@ -56,7 +56,7 @@ public class WolfAttributes {
|
||||
wolf.setRemainingPersistentAngerTime(angry ? 100 : 0);
|
||||
}
|
||||
|
||||
private static void setColor(Npc npc, String value) {
|
||||
private static void setCollarColor(Npc npc, String value) {
|
||||
Wolf wolf = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import de.oliver.fancynpcs.v1_20_4.ReflectionHelper;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.animal.Cat;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -33,6 +34,13 @@ public class CatAttributes {
|
||||
CatAttributes::setPose
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.CAT),
|
||||
CatAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@@ -61,4 +69,23 @@ public class CatAttributes {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setCollarColor(Npc npc, String value){
|
||||
final Cat cat = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()){
|
||||
cat.setTame(false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
DyeColor color = DyeColor.valueOf(value.toUpperCase());
|
||||
if (!cat.isTame()){
|
||||
cat.setTame(true);
|
||||
}
|
||||
cat.setCollarColor(color);
|
||||
} catch (IllegalArgumentException e){
|
||||
System.out.print("Invalid Color: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@ public class WolfAttributes {
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"color",
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.WOLF),
|
||||
WolfAttributes::setColor
|
||||
WolfAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
@@ -56,7 +56,7 @@ public class WolfAttributes {
|
||||
wolf.setRemainingPersistentAngerTime(angry ? 100 : 0);
|
||||
}
|
||||
|
||||
private static void setColor(Npc npc, String value) {
|
||||
private static void setCollarColor(Npc npc, String value) {
|
||||
Wolf wolf = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import de.oliver.fancynpcs.v1_20_6.ReflectionHelper;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.animal.Cat;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -33,6 +34,13 @@ public class CatAttributes {
|
||||
CatAttributes::setPose
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.CAT),
|
||||
CatAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@@ -61,4 +69,23 @@ public class CatAttributes {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setCollarColor(Npc npc, String value){
|
||||
final Cat cat = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()){
|
||||
cat.setTame(false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
DyeColor color = DyeColor.valueOf(value.toUpperCase());
|
||||
if (!cat.isTame()){
|
||||
cat.setTame(true, false);
|
||||
}
|
||||
cat.setCollarColor(color);
|
||||
} catch (IllegalArgumentException e){
|
||||
System.out.print("Invalid Color: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ public class WolfAttributes {
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"color",
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.WOLF),
|
||||
WolfAttributes::setColor
|
||||
WolfAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
@@ -86,7 +86,7 @@ public class WolfAttributes {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setColor(Npc npc, String value) {
|
||||
private static void setCollarColor(Npc npc, String value) {
|
||||
Wolf wolf = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import de.oliver.fancynpcs.v1_21_1.ReflectionHelper;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.animal.Cat;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -30,6 +31,13 @@ public class CatAttributes {
|
||||
CatAttributes::setPose
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.CAT),
|
||||
CatAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@@ -58,4 +66,24 @@ public class CatAttributes {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setCollarColor(Npc npc, String value) {
|
||||
Cat cat = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()) {
|
||||
// Reset to no collar
|
||||
cat.setTame(false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
DyeColor color = DyeColor.valueOf(value.toUpperCase());
|
||||
if (!cat.isTame()){
|
||||
cat.setTame(true, false);
|
||||
}
|
||||
cat.setCollarColor(color);
|
||||
} catch (IllegalArgumentException e) {
|
||||
System.out.println("Invalid cat collar color: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,10 +43,10 @@ public class WolfAttributes {
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"color",
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.WOLF),
|
||||
WolfAttributes::setColor
|
||||
WolfAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
@@ -100,7 +100,7 @@ public class WolfAttributes {
|
||||
);
|
||||
}
|
||||
|
||||
private static void setColor(Npc npc, String value) {
|
||||
private static void setCollarColor(Npc npc, String value) {
|
||||
Wolf wolf = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import de.oliver.fancynpcs.v1_21_3.ReflectionHelper;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.animal.Cat;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -30,6 +31,13 @@ public class CatAttributes {
|
||||
CatAttributes::setPose
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.CAT),
|
||||
CatAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@@ -58,4 +66,25 @@ public class CatAttributes {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setCollarColor(Npc npc, String value) {
|
||||
Cat cat = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()) {
|
||||
// Reset to no collar
|
||||
cat.setTame(false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
DyeColor color = DyeColor.valueOf(value.toUpperCase());
|
||||
if (!cat.isTame()){
|
||||
cat.setTame(true, false);
|
||||
}
|
||||
cat.setCollarColor(color);
|
||||
} catch (IllegalArgumentException e) {
|
||||
System.out.println("Invalid cat collar color: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ public class WolfAttributes {
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"color",
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.WOLF),
|
||||
WolfAttributes::setColor
|
||||
WolfAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
@@ -95,7 +95,7 @@ public class WolfAttributes {
|
||||
);
|
||||
}
|
||||
|
||||
private static void setColor(Npc npc, String value) {
|
||||
private static void setCollarColor(Npc npc, String value) {
|
||||
Wolf wolf = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()) {
|
||||
|
||||
@@ -6,6 +6,7 @@ import de.oliver.fancynpcs.v1_21_4.ReflectionHelper;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.animal.Cat;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -30,6 +31,13 @@ public class CatAttributes {
|
||||
CatAttributes::setPose
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.CAT),
|
||||
CatAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@@ -58,4 +66,24 @@ public class CatAttributes {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setCollarColor(Npc npc, String value) {
|
||||
Cat cat = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()) {
|
||||
// Reset to no collar
|
||||
cat.setTame(false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
DyeColor color = DyeColor.valueOf(value.toUpperCase());
|
||||
if (!cat.isTame()){
|
||||
cat.setTame(true, false);
|
||||
}
|
||||
cat.setCollarColor(color);
|
||||
} catch (IllegalArgumentException e) {
|
||||
System.out.println("Invalid cat collar color: " + value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,10 +43,10 @@ public class WolfAttributes {
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"color",
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.WOLF),
|
||||
WolfAttributes::setColor
|
||||
WolfAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
@@ -96,7 +96,7 @@ public class WolfAttributes {
|
||||
);
|
||||
}
|
||||
|
||||
public static void setColor(Npc npc, String value) {
|
||||
public static void setCollarColor(Npc npc, String value) {
|
||||
Wolf wolf = ReflectionHelper.getEntity(npc); // NMS Wolf
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.world.entity.animal.Cat;
|
||||
import net.minecraft.world.entity.animal.CatVariant;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -38,6 +39,13 @@ public class CatAttributes {
|
||||
CatAttributes::setPose
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.CAT),
|
||||
CatAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@@ -79,4 +87,24 @@ public class CatAttributes {
|
||||
.lookup(Registries.CAT_VARIANT)
|
||||
.orElseThrow();
|
||||
}
|
||||
|
||||
private static void setCollarColor(Npc npc, String value) {
|
||||
Cat cat = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()) {
|
||||
// Reset to no collar
|
||||
cat.setTame(false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
DyeColor color = DyeColor.valueOf(value.toUpperCase());
|
||||
if (!cat.isTame()){
|
||||
cat.setTame(true, false);
|
||||
}
|
||||
cat.setCollarColor(color);
|
||||
} catch (IllegalArgumentException e) {
|
||||
System.out.println("Invalid cat collar color: " + value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,10 +47,10 @@ public class WolfAttributes {
|
||||
));
|
||||
|
||||
attributes.add(new NpcAttribute(
|
||||
"color",
|
||||
"collar_color",
|
||||
List.of("RED", "BLUE", "YELLOW", "GREEN", "PURPLE", "ORANGE", "LIME", "MAGENTA", "BROWN", "WHITE", "GRAY", "LIGHT_GRAY", "LIGHT_BLUE", "BLACK", "CYAN", "PINK", "NONE"),
|
||||
List.of(EntityType.WOLF),
|
||||
WolfAttributes::setColor
|
||||
WolfAttributes::setCollarColor
|
||||
));
|
||||
|
||||
return attributes;
|
||||
@@ -101,7 +101,7 @@ public class WolfAttributes {
|
||||
);
|
||||
}
|
||||
|
||||
private static void setColor(Npc npc, String value) {
|
||||
private static void setCollarColor(Npc npc, String value) {
|
||||
Wolf wolf = ReflectionHelper.getEntity(npc);
|
||||
|
||||
if (value.equalsIgnoreCase("none") || value.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user