本文整理匯總了Java中net.minecraftforge.event.entity.living.LivingAttackEvent.isCanceled方法的典型用法代碼示例。如果您正苦於以下問題:Java LivingAttackEvent.isCanceled方法的具體用法?Java LivingAttackEvent.isCanceled怎麽用?Java LivingAttackEvent.isCanceled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.event.entity.living.LivingAttackEvent
的用法示例。
在下文中一共展示了LivingAttackEvent.isCanceled方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: stopHurt
import net.minecraftforge.event.entity.living.LivingAttackEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void stopHurt(LivingAttackEvent event) {
if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityLivingBase &&
(event.getSource().damageType.equals("mob") || event.getSource().damageType.equals("player"))) {
EntityLivingBase damageSource = (EntityLivingBase) event.getSource().getTrueSource();
if (!TF2Util.canInteract(damageSource)) {
event.setCanceled(true);
}
if (damageSource.hasCapability(TF2weapons.WEAPONS_CAP, null) && WeaponsCapability.get(damageSource).isDisguised()) {
disguise(damageSource, false);
}
}
if (!event.isCanceled() && event.getAmount() > 0) {
/*
* if(event.getEntity().getEntityData().getByte("IsCloaked")!=0){
* event.getEntity().getEntityData().setInteger("VisTicks",
* Math.min(10,event.getEntity().getEntityData().getInteger(
* "VisTicks"))); event.getEntity().setInvisible(false);
* //System.out.println("notInvisible"); }
*/
event.getEntityLiving().getEntityData().setInteger("lasthit", event.getEntityLiving().ticksExisted);
}
}
示例2: livingAttacked
import net.minecraftforge.event.entity.living.LivingAttackEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void livingAttacked(LivingAttackEvent event) {
if (!event.getEntityLiving().world.isRemote) {
if (!event.isCanceled() && event.getAmount() > 0) {
EntityLivingBase living = event.getEntityLiving();
if (living.isPotionActive(ModPotions.cannonball) && (event.getSource().isExplosion() || event.getSource() == DamageSource.FALL)) {
if (event.getSource() == DamageSource.FALL) //No you don't get to have superbuffs that make you immune to creepers and falldamage.
living.removePotionEffect(ModPotions.cannonball);
event.setCanceled(true);
}
}
}
}
示例3: onLivingHurt
import net.minecraftforge.event.entity.living.LivingAttackEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST, receiveCanceled = true)
public void onLivingHurt(LivingAttackEvent event) {
// if it's cancelled it got handled by the battlesign (or something else. but it's a prerequisite.)
if(!event.isCanceled()) {
return;
}
if(event.getSource().isUnblockable() || !event.getSource().isProjectile() || event.getSource().getTrueSource() == null) {
return;
}
// hit entity is a player?
if(!(event.getEntity() instanceof EntityPlayer)) {
return;
}
EntityPlayer player = (EntityPlayer) event.getEntity();
// needs to be blocking with a battlesign
if(!player.isActiveItemStackBlocking() || player.getActiveItemStack().getItem() != TinkerMeleeWeapons.battleSign) {
return;
}
// broken battlesign.
if(ToolHelper.isBroken(player.getActiveItemStack())) {
return;
}
// at this point we duplicated all the logic if the battlesign should reflect a projectile.. bleh.
int xp = Math.max(1, Math.round(event.getAmount()));
addXp(player.getActiveItemStack(), xp, player);
}