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,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()) {
|
||||
|
||||
Reference in New Issue
Block a user