/**
* Computes chance that the gun misfires! Yikes.
*
* Misfire is based on when you last repaired the gun. A misfire has a chance of causing a gun to explode (handled in another function)
*
*
*
* @param entity the entity shooting the gun
* @param bulletType the type of bullet
* @param item the gunItem, could be modified by this.
* @param gunData the gunData
* @param hand the hand holding the gun.
*
* @return true if misfired, false otherwise.
*/
public boolean misfire(LivingEntity entity, Bullet bulletType, ItemStack item, Map<String, Object> gunData,
EquipmentSlot hand) {
if (entity == null || !enabled)
return true;
Integer health = (Integer) gunData.get("health"); // gunhealth!
double misfireChance = 1.0d - sigmoid((double) health, (double) this.middleRisk,0.5d, (double) this.riskSpread);
double random = Math.random();
AddGun.getPlugin().debug("Misfire computation: {0} health {1} misfireChance {2} random", health, misfireChance, random);
if (random < misfireChance) {
return true;
}
return false;
}
StandardGun.java 文件源码
java
阅读 22
收藏 0
点赞 0
评论 0
项目:AddGun
作者:
评论列表
文章目录