Skip to content

Commit

Permalink
Fix cat cotw on older versions (#5096)
Browse files Browse the repository at this point in the history
  • Loading branch information
Warriorrrr authored Sep 28, 2024
1 parent 3d7810c commit 5c68a17
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ private void spawnWolf(Location spawnLocation) {
callOfWildEntity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", getPlayer().getName(), StringUtils.getPrettyEntityTypeString(EntityType.WOLF)));
}

@SuppressWarnings("deprecation")
private void spawnCat(Location spawnLocation, EntityType entityType) {
LivingEntity callOfWildEntity = (LivingEntity) getPlayer().getWorld().spawnEntity(spawnLocation, entityType);

Expand All @@ -414,15 +415,13 @@ private void spawnCat(Location spawnLocation, EntityType entityType) {

//Randomize the cat
if (callOfWildEntity instanceof Ocelot) {
// Ocelot.Type is deprecated, but that's fine since this only runs on 1.13
int numberOfTypes = Ocelot.Type.values().length;
((Ocelot) callOfWildEntity).setCatType(Ocelot.Type.values()[Misc.getRandom().nextInt(numberOfTypes)]);
((Ocelot) callOfWildEntity).setAdult();
} else if (callOfWildEntity instanceof Cat) {
int numberOfTypes = Cat.Type.values().length;
((Cat) callOfWildEntity).setCatType(Cat.Type.values()[Misc.getRandom().nextInt(numberOfTypes)]);
((Cat) callOfWildEntity).setAdult();
}

((Ageable) callOfWildEntity).setAdult();

callOfWildEntity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", getPlayer().getName(), StringUtils.getPrettyEntityTypeString(entityType)));

//Particle effect
Expand Down

0 comments on commit 5c68a17

Please sign in to comment.