本文整理匯總了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);
}