Skip to content

Commit

Permalink
modernize EntityTag.saddle and related tags
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Oct 6, 2021
1 parent 61c70b8 commit db0f056
Showing 1 changed file with 7 additions and 7 deletions.
Expand Up @@ -1287,10 +1287,10 @@ public static void registerTags() {
// If the entity is a horse or pig, returns the saddle as a ItemTag, or air if none.
// -->
registerSpawnedOnlyTag("saddle", (attribute, object) -> {
if (object.getLivingEntity().getType() == EntityType.HORSE) {
return new ItemTag(((Horse) object.getLivingEntity()).getInventory().getSaddle());
if (object.getLivingEntity() instanceof AbstractHorse) {
return new ItemTag(((AbstractHorse) object.getLivingEntity()).getInventory().getSaddle());
}
else if (object.getLivingEntity().getType() == EntityType.PIG) {
else if (object.getLivingEntity() instanceof Pig) {
return new ItemTag(((Pig) object.getLivingEntity()).hasSaddle() ? Material.SADDLE : Material.AIR);
}
return null;
Expand All @@ -1304,7 +1304,7 @@ else if (object.getLivingEntity().getType() == EntityType.PIG) {
// If the entity is a horse, returns the item equipped as the horses armor, or air if none.
// -->
registerSpawnedOnlyTag("horse_armor", (attribute, object) -> {
if (object.getBukkitEntityType() == EntityType.HORSE) {
if (object.getLivingEntity() instanceof Horse) {
return new ItemTag(((Horse) object.getLivingEntity()).getInventory().getArmor());
}
return null;
Expand All @@ -1318,10 +1318,10 @@ else if (object.getLivingEntity().getType() == EntityType.PIG) {
// If the entity is a pig or horse, returns whether it has a saddle equipped.
// -->
registerSpawnedOnlyTag("has_saddle", (attribute, object) -> {
if (object.getBukkitEntityType() == EntityType.HORSE) {
return new ElementTag(((Horse) object.getLivingEntity()).getInventory().getSaddle().getType() == Material.SADDLE);
if (object.getLivingEntity() instanceof AbstractHorse) {
return new ElementTag(((AbstractHorse) object.getLivingEntity()).getInventory().getSaddle().getType() == Material.SADDLE);
}
else if (object.getBukkitEntityType() == EntityType.PIG) {
else if (object.getLivingEntity() instanceof Pig) {
return new ElementTag(((Pig) object.getLivingEntity()).hasSaddle());
}
return null;
Expand Down

0 comments on commit db0f056

Please sign in to comment.