Fixes some possible NPEs in PotionEventHandler (#1668)
* Fixes some possible NPEs in PotionEventHandler * Added Brackets for clarification * Update PotionEventHandlers.java
This commit is contained in:
parent
5f31f8c69a
commit
268469f078
1 changed files with 18 additions and 12 deletions
|
@ -93,6 +93,7 @@ public class PotionEventHandlers {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
List<EntityLivingBase> noGravityList = noGravityListMap.getOrDefault(event.getEntityLiving().getEntityWorld(), Lists.newArrayList());
|
List<EntityLivingBase> noGravityList = noGravityListMap.getOrDefault(event.getEntityLiving().getEntityWorld(), Lists.newArrayList());
|
||||||
|
if (noGravityList != null) {
|
||||||
if (eventEntityLiving.isPotionActive(RegistrarBloodMagic.SUSPENDED) && !eventEntityLiving.hasNoGravity()) {
|
if (eventEntityLiving.isPotionActive(RegistrarBloodMagic.SUSPENDED) && !eventEntityLiving.hasNoGravity()) {
|
||||||
eventEntityLiving.setNoGravity(true);
|
eventEntityLiving.setNoGravity(true);
|
||||||
noGravityList.add(eventEntityLiving);
|
noGravityList.add(eventEntityLiving);
|
||||||
|
@ -100,12 +101,17 @@ public class PotionEventHandlers {
|
||||||
eventEntityLiving.setNoGravity(false);
|
eventEntityLiving.setNoGravity(false);
|
||||||
noGravityList.remove(eventEntityLiving);
|
noGravityList.remove(eventEntityLiving);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (eventEntityLiving.isPotionActive(RegistrarBloodMagic.GROUNDED))
|
if (eventEntityLiving.isPotionActive(RegistrarBloodMagic.GROUNDED)) {
|
||||||
|
PotionEffect activeEffect = eventEntityLiving.getActivePotionEffect(RegistrarBloodMagic.GROUNDED);
|
||||||
|
if (activeEffect != null) {
|
||||||
if (eventEntityLiving instanceof EntityPlayer && ((EntityPlayer) eventEntityLiving).capabilities.isFlying)
|
if (eventEntityLiving instanceof EntityPlayer && ((EntityPlayer) eventEntityLiving).capabilities.isFlying)
|
||||||
eventEntityLiving.motionY -= (0.05D * (double) (eventEntityLiving.getActivePotionEffect(RegistrarBloodMagic.GROUNDED).getAmplifier() + 1) - eventEntityLiving.motionY) * 0.2D;
|
eventEntityLiving.motionY -= (0.05D * (double) activeEffect.getAmplifier() + 1 - eventEntityLiving.motionY) * 0.2D;
|
||||||
else
|
else
|
||||||
eventEntityLiving.motionY -= (0.1D * (double) (eventEntityLiving.getActivePotionEffect(RegistrarBloodMagic.GROUNDED).getAmplifier() + 1) - eventEntityLiving.motionY) * 0.2D;
|
eventEntityLiving.motionY -= (0.1D * (double) activeEffect.getAmplifier() + 1 - eventEntityLiving.motionY) * 0.2D;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (eventEntityLiving.isPotionActive(RegistrarBloodMagic.WHIRLWIND)) {
|
if (eventEntityLiving.isPotionActive(RegistrarBloodMagic.WHIRLWIND)) {
|
||||||
int d0 = 3;
|
int d0 = 3;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue