Skip to content

Commit

Permalink
entity breeding tags: add cast check with default returns
Browse files Browse the repository at this point in the history
also fix ex command debug message mixup
  • Loading branch information
mcmonkey4eva committed Feb 20, 2021
1 parent dde4f80 commit e7643c5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Expand Up @@ -1732,7 +1732,10 @@ else if (mtr.angle == BlockFace.EAST) {
// Returns whether the animal entity is capable of mating with another of its kind.
// -->
registerSpawnedOnlyTag("can_breed", (attribute, object) -> {
return new ElementTag(((Ageable) object.getLivingEntity()).canBreed());
if (!(object.getLivingEntity() instanceof Breedable)) {
return new ElementTag(false);
}
return new ElementTag(((Breedable) object.getLivingEntity()).canBreed());
});

// <--[tag]
Expand All @@ -1744,6 +1747,9 @@ else if (mtr.angle == BlockFace.EAST) {
// Returns whether the animal entity is trying to with another of its kind.
// -->
registerSpawnedOnlyTag("breeding", (attribute, object) -> {
if (!(object.getLivingEntity() instanceof Animals)) {
return null;
}
return new ElementTag(((Animals) object.getLivingEntity()).getLoveModeTicks() > 0);
}, "is_breeding");

Expand Down
Expand Up @@ -87,7 +87,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String alias, String
sender.sendMessage(ChatColor.YELLOW + "Executing Denizen script command... check the console for full debug output!");
}
else {
sender.sendMessage(ChatColor.YELLOW + "Executing Denizen script command with no debug output...");
sender.sendMessage(ChatColor.YELLOW + "Executing Denizen script command...");
}
}
else {
Expand Down
Expand Up @@ -90,7 +90,7 @@ else if (Settings.showExHelp()) {
sender.sendMessage(ChatColor.YELLOW + "Executing Denizen script command... check the console for full debug output!");
}
else {
sender.sendMessage(ChatColor.YELLOW + "Executing Denizen script command with no debug output...");
sender.sendMessage(ChatColor.YELLOW + "Executing Denizen script command...");
}
}
else {
Expand Down

0 comments on commit e7643c5

Please sign in to comment.