本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingHurtEvent.isCanceled方法的典型用法代码示例。如果您正苦于以下问题:Java LivingHurtEvent.isCanceled方法的具体用法?Java LivingHurtEvent.isCanceled怎么用?Java LivingHurtEvent.isCanceled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.living.LivingHurtEvent
的用法示例。
在下文中一共展示了LivingHurtEvent.isCanceled方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onTakeDamage
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@Override
public void onTakeDamage(ItemStack itemStack, LivingHurtEvent event, boolean isWornArmor) {
//System.out.println("Player has been damaged!");
if(isWornArmor && !event.isCanceled()) {
if(itemStack.stackTagCompound.getInteger("adrenDelay_armor") <= 0 && event.entity instanceof EntityPlayer) {
//System.out.println("Attempting to apply potion effects to player.");
EntityPlayer p = (EntityPlayer)event.entity;
//if(p.getHealth() <= 4) {
//System.out.println("Applying Potion Effects.");
itemStack.stackTagCompound.setInteger("adrenDelay_armor", 300);
p.addPotionEffect(new PotionEffect(1, 100, 1));
p.addPotionEffect(new PotionEffect(5, 100, 1));
p.addPotionEffect(new PotionEffect(11, 100, 2));
//}
}
}
}
示例2: 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));
}
}
}
示例3: entityAttack
import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void entityAttack(LivingHurtEvent event) {
if (event.isCanceled())
return;
if (event.entity.worldObj.isRemote)
return;
EntityPlayer player;
boolean arrow = false;
double distance = 0;
if (event.source.getSourceOfDamage() instanceof EntityPlayer)
player = (EntityPlayer) event.source.getSourceOfDamage();
else if (event.source.getSourceOfDamage() instanceof EntityArrow) {
if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity instanceof EntityPlayer) {
player = (EntityPlayer) ((EntityArrow) event.source.getSourceOfDamage()).shootingEntity;
arrow = true;
distance = event.entity.getDistanceSqToEntity(player);
}
else
return;
}
else
return;
if (isPlayerFake(player))
return;
if (event.entityLiving == null)
return;
String entName = "entity.attack." + EntityList.getEntityString(event.entityLiving);
PlayerResearchHelper.progressResearch(player, entName, 1, true);
if (arrow)
PlayerResearchHelper.progressResearch(player, "entity.arrowHit", distance, true);
}