本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingHurtEvent.setAmount方法的典型用法代码示例。如果您正苦于以下问题:Java LivingHurtEvent.setAmount方法的具体用法?Java LivingHurtEvent.setAmount怎么用?Java LivingHurtEvent.setAmount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.living.LivingHurtEvent
的用法示例。
在下文中一共展示了LivingHurtEvent.setAmount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onHurtEvent
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void onHurtEvent(LivingHurtEvent event)
{
EntityLivingBase entity = event.getEntityLiving();
DamageSource damageSource = event.getSource();
float damage = event.getAmount();
if(entity != null)
{
IAttributeInstance damageRate = null;
if(isPhysicalDamage(damageSource))
damageRate = entity.getEntityAttribute(PHYSICAL_DAMAGE_RATE);
if(damageSource.isFireDamage())
damageRate = entity.getEntityAttribute(FIRE_DAMAGE_RATE);
if(damageRate != null)
damage *= damageRate.getAttributeValue();
}
event.setAmount(damage);
}
示例2: obsidianArmor
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
/** Handle wearing obsidian armor */
private boolean obsidianArmor(LivingHurtEvent e) {
EntityLivingBase hurt = e.getEntityLiving();
// do things based on the armor status
int armorCount = getWearingSetCount(hurt, ItemArmorObsidian.class);
if(armorCount > 0) {
// blast resistance II
if(e.getSource().isExplosion()) {
e.setAmount(e.getAmount() * (1 - armorCount / 4F));
}
return true;
}
return false;
}
示例3: postInit
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void postInit(LivingHurtEvent e) {
DamageSource source = e.getSource();
Iterable<ItemStack> armorStacks = e.getEntityLiving().getArmorInventoryList();
// boolean hasHeavyArmor = false;
float reduction = 0;
for (ItemStack armorStack : armorStacks) {
if (isHeavyArmor(armorStack)) {
if (source.isProjectile() || source.isExplosion()) {
reduction += 0.2;
}
}
}
if (reduction > 0) {
float newDamage = (1 - reduction) * e.getAmount();
System.out.println("Heavy armor reduction: [" + reduction + "] IN[" + e.getAmount() + "] OUT[" + newDamage + "]");
e.setAmount(newDamage);
}
}
示例4: onPlayerFall
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
@SuppressWarnings("unused")
public void onPlayerFall(LivingHurtEvent event) {
if(!(event.getEntity() instanceof EntityPlayer)) {
return;
}
if(!event.getSource().damageType.equals(DamageSource.FALL.getDamageType())) {
return;
}
EntityPlayer player = (EntityPlayer) event.getEntity();
ItemStack boots = player.getItemStackFromSlot(EntityEquipmentSlot.FEET);
if(boots != null && boots.getItem() == ItemRegistry.getInstance().itemFallBoots) {
event.setAmount((1.0F-ConfigurationHandler.getInstance().bootFallDamageReduction)*event.getAmount());
}
}
示例5: onEntityDamage
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityDamage(LivingHurtEvent event) {
DamageSource source = event.getSource();
Entity attacker = source.getTrueSource();
if ((attacker instanceof EntityLivingBase) && ((EntityLivingBase) attacker).getCreatureAttribute() == EnumCreatureAttribute.UNDEAD) {
event.setAmount(event.getAmount() * 0.95F);
}
}
示例6: onLivingHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@HarshenEvent
public void onLivingHurt(LivingHurtEvent event)
{
if(event.getSource() instanceof EntityDamageSource && ((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityZombie &&
!(((EntityDamageSource)event.getSource()).getTrueSource() instanceof EntityPigZombie))
event.setAmount(1);
}
示例7: playerHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void playerHurt(LivingHurtEvent event)
{
if(!(event.getEntityLiving() instanceof EntityPlayer))
return;
List<ItemStack> stackList = EntityUtil.getFullPlayerInventory((EntityPlayer) event.getEntityLiving());
for(ItemStack stack : stackList)
{
if(!stack.isEmpty())
{
if(stack.getItem() instanceof ItemAnimaShield)
{
ItemAnimaShield item = (ItemAnimaShield) stack.getItem();
if(!item.isOn(stack))
continue;
if(item.getCurrentCharge(stack) > 0 && item.getShieldCharge(stack) > 0)
{
float amountTaken = event.getAmount();
float shieldScaled = item.getShieldCharge(stack) / 10;
float remain = Math.max(0, amountTaken - shieldScaled);
event.setAmount(remain);
item.depleteShield(stack, amountTaken * 10);
item.removeCharge(stack, (int) (amountTaken * 40));
if(item.getShieldCharge(stack) == 0)
{
item.getShield(stack).onDeplete(stack, event.getEntityLiving());
}
}
return;
}
}
}
}
示例8: onHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHurt(LivingHurtEvent event) {
DamageSource source = event.getSource();
if (source != null && source.getImmediateSource() != null) {
Entity entity = source.getImmediateSource();
if (entity != null && entity instanceof EntityLivingBase) {
EntityLivingBase attacker = (EntityLivingBase) entity;
if (attacker.getHeldItemMainhand().getItem() == ModItems.mace) {
float amount = Math.max(event.getAmount() - (20F / ((event.getEntityLiving().getTotalArmorValue() + 1F)) - 1F), (event.getAmount() / 3F));
event.setAmount(amount);
}
}
}
}
示例9: livingAttack
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority=EventPriority.HIGH)
public void livingAttack(LivingHurtEvent event) {
if(event.isCanceled() || event.getSource().isUnblockable())
return;
if(event.getEntityLiving().hasCapability(RIG.RIG_ITEM, null)) {
ItemStack rig=event.getEntityLiving().getCapability(RIG.RIG_ITEM, null).getStackInSlot(0);
if(rig.hasTagCompound()) {
int reslevel=1+rig.getTagCompound().getInteger("ResU");
if(event.getAmount() > 1f)
event.setAmount(Math.max(1f,event.getAmount() - reslevel * 0.5f));
}
}
}
示例10: netherFortressArmor
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
/** Handle wearing nether fortress armor */
private boolean netherFortressArmor(LivingHurtEvent e) {
EntityLivingBase hurt = e.getEntityLiving();
// do things based on the armor status
int armorCount = getWearingSetCount(hurt, ItemArmorNether.class);
if(armorCount > 0) {
// knockback resistance
IAttributeInstance inst = hurt.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE);
AttributeModifier mod = new AttributeModifier(knockbackID, "nfakb", armorCount / 4D, 0).setSaved(false);
if(inst.getModifier(knockbackID) == null) inst.applyModifier(mod);
// wither thorns
if(e.getSource().getTrueSource() != null && e.getSource().getTrueSource() instanceof EntityLivingBase) {
EntityLivingBase attacker = (EntityLivingBase)e.getSource().getTrueSource();
attacker.addPotionEffect(new PotionEffect(MobEffects.WITHER, armorCount * 20, armorCount > 2 ? 1 : 0));
}
// blast resistance I
if(e.getSource().isExplosion()) {
e.setAmount(e.getAmount() * (1 - armorCount / 8F));
}
return true;
}
return false;
}
示例11: livingHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void livingHurt(LivingHurtEvent event) {
if (event.getSource().getTrueSource() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
if (player.getHeldItemMainhand() != ItemStack.EMPTY) {
if (player.getHeldItemMainhand().getItem() == Items.APPLE) {
event.setAmount(10);
event.getEntity().setFire(10);
}
}
}
}
示例12: onLivingHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event)
{
if (event.getEntityLiving() instanceof EntityPlayer)
{
PlayerAether playerAether = PlayerAether.get((EntityPlayer) event.getEntityLiving());
if (playerAether != null && playerAether.isWearingObsidianSet())
{
float original = event.getAmount();
event.setAmount(original / 2);
}
}
}
示例13: onLivingHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event) {
if (!event.getEntity().worldObj.isRemote) {
if (event.getEntity() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getEntity();
// Exclude Creative Players
if (player.isCreative()) {
return;
}
// Check Armor in Inventory
for (ItemStack stack : player.getArmorInventoryList()) {
if (stack != null && stack.getItem() == this) {
if (player.experienceTotal > event.getAmount()) {
float amount = event.getAmount();
// Reduce the attack amount
event.setAmount(amount * (1 - reduction));
// Take the experience
int exp = (int) (amount * reduction);
player.experience -= exp / (float) player.xpBarCap();
for (player.experienceTotal -= exp; player.experience <= 0.0F;
player.experience /= player.xpBarCap()) {
player.experience = (player.experience + 1.0F) * player.xpBarCap();
player.removeExperienceLevel(1);
}
} else {
// Reduce the attack amount
event.setAmount(event.getAmount() - player.experienceTotal);
// Take the experience
player.experienceLevel = 0;
player.experience = 0.0F;
player.experienceTotal = 0;
}
return;
}
}
}
}
}
示例14: onLivingHurtStart
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurtStart(LivingHurtEvent event)
{
Entity sourceEntity = event.getSource().getTrueSource();
if (sourceEntity instanceof EntityLivingBase)
{
EntityLivingBase attacker = (EntityLivingBase) sourceEntity;
PotionEffect effect = attacker.getActivePotionEffect(PotionRegistry.MAX_CRIT);
if (effect != null && !Util.isCritting(attacker))
event.setAmount(event.getAmount() * 1.5F);
}
}
示例15: onLivingHurt
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurt(LivingHurtEvent event)
{
Entity sourceEntity = event.getSource().getTrueSource();
if (sourceEntity instanceof EntityLivingBase)
{
EntityLivingBase attacker = (EntityLivingBase) sourceEntity;
PotionEffect effect = attacker.getActivePotionEffect(PotionRegistry.CRIT_BONUS);
if (effect != null && Util.isCritting(attacker))
event.setAmount(event.getAmount() / 1.5F);
}
}