mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-25 14:46:46 +01:00
Avoid NPE on beast lore jump strength checks
This commit is contained in:
parent
c27b8dbd66
commit
fbd2eeb93d
@ -29,6 +29,7 @@ import com.gmail.nossr50.util.text.StringUtils;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
|
import org.bukkit.attribute.AttributeInstance;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -251,12 +252,16 @@ public class TamingManager extends SkillManager {
|
|||||||
|
|
||||||
// Bred mules & donkeys can actually have horse-like stats, but llamas cannot.
|
// Bred mules & donkeys can actually have horse-like stats, but llamas cannot.
|
||||||
if (beast instanceof AbstractHorse && !(beast instanceof Llama)) {
|
if (beast instanceof AbstractHorse && !(beast instanceof Llama)) {
|
||||||
AbstractHorse horse = (AbstractHorse) beast;
|
AbstractHorse horseLikeCreature = (AbstractHorse) beast;
|
||||||
double jumpStrength = horse.getAttribute(Attribute.HORSE_JUMP_STRENGTH).getValue();
|
AttributeInstance jumpAttribute = horseLikeCreature.getAttribute(Attribute.HORSE_JUMP_STRENGTH);
|
||||||
// Taken from https://minecraft.gamepedia.com/Horse#Jump_strength
|
|
||||||
jumpStrength = -0.1817584952 * Math.pow(jumpStrength, 3) + 3.689713992 * Math.pow(jumpStrength, 2) + 2.128599134 * jumpStrength - 0.343930367;
|
if(jumpAttribute != null) {
|
||||||
message = message.concat("\n" + LocaleLoader.getString("Combat.BeastLoreHorseSpeed", horse.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getValue() * 43))
|
double jumpStrength = jumpAttribute.getValue();
|
||||||
.concat("\n" + LocaleLoader.getString("Combat.BeastLoreHorseJumpStrength", jumpStrength));
|
// Taken from https://minecraft.gamepedia.com/Horse#Jump_strength
|
||||||
|
jumpStrength = -0.1817584952 * Math.pow(jumpStrength, 3) + 3.689713992 * Math.pow(jumpStrength, 2) + 2.128599134 * jumpStrength - 0.343930367;
|
||||||
|
message = message.concat("\n" + LocaleLoader.getString("Combat.BeastLoreHorseSpeed", horseLikeCreature.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getValue() * 43))
|
||||||
|
.concat("\n" + LocaleLoader.getString("Combat.BeastLoreHorseJumpStrength", jumpStrength));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage(message);
|
player.sendMessage(message);
|
||||||
|
Loading…
Reference in New Issue
Block a user