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