当前位置: 首页>>代码示例>>Java>>正文


Java LivingAttackEvent.setCanceled方法代码示例

本文整理汇总了Java中net.minecraftforge.event.entity.living.LivingAttackEvent.setCanceled方法的典型用法代码示例。如果您正苦于以下问题:Java LivingAttackEvent.setCanceled方法的具体用法?Java LivingAttackEvent.setCanceled怎么用?Java LivingAttackEvent.setCanceled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.event.entity.living.LivingAttackEvent的用法示例。


在下文中一共展示了LivingAttackEvent.setCanceled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
	}

}
 
开发者ID:rafradek,项目名称:Mods,代码行数:26,代码来源:TF2EventsCommon.java

示例2: onLivingHurt

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurt(LivingAttackEvent event)
{
	if (event.getSource() == null)
		return;
	if (event.getSource().getTrueSource() == null)
		return;
	if (event.getSource().getTrueSource() instanceof EntityLivingBase)
	{
		PotionEffect effect = ((EntityLivingBase) event.getSource().getTrueSource()).getActivePotionEffect(PotionRegistry.REDSTONE_NEEDLE);
		if (effect == null)
			return;
		if (effect.getAmplifier() >= 4)
			event.setCanceled(true);
	}
}
 
开发者ID:murapix,项目名称:Inhuman-Resources,代码行数:17,代码来源:PotionRedstoneNeedle.java

示例3: onPlayerHurt

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerHurt(LivingAttackEvent event) {
	if(FMLCommonHandler.instance().getEffectiveSide().isClient()) {
		return;
	}

	if(!(event.entity instanceof EntityPlayer)) {
		return;
	}

	EntityPlayer player = (EntityPlayer)event.entity;
	ItemStack itemstack = player.inventory.armorItemInSlot(2);
	if(itemstack == null || event.source.equals(DamageSource.outOfWorld)) {
		event.setCanceled(false);
		return;
	}
	if(ElectricItem.manager.canUse(itemstack, 1000.0D)) {
		event.setCanceled(true);
	}
}
 
开发者ID:estebes,项目名称:Gravitation-Suite-Reloaded,代码行数:21,代码来源:ItemElectricArmor.java

示例4: onLivingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent evt) {
	if (evt.getEntity() instanceof EntityPlayer && evt.getSource() instanceof EntityDamageSource) {
		EntityDamageSource source = (EntityDamageSource) evt.getSource();
		if (source.getEntity() instanceof EntityPlayer) {
			EntityPlayer attacker = (EntityPlayer) source.getEntity();
			EntityPlayer damagee = (EntityPlayer) evt.getEntity();

			ItemStack attackerBoots = attacker.inventory.armorItemInSlot(0);
			ItemStack damageeBoots = damagee.inventory.armorItemInSlot(0);
			if (attackerBoots != null && damageeBoots != null && attackerBoots == damageeBoots) {
				Item id = damageeBoots.getItem();
				if (id == WarsItems.redBoots || id == WarsItems.greenBoots || id == WarsItems.blueBoots || id == WarsItems.yellowBoots) {
					evt.setCanceled(true);
				}
			}
		}
	}
}
 
开发者ID:The-Fireplace-Minecraft-Mods,项目名称:Wars-Mod,代码行数:20,代码来源:CommonEvents.java

示例5: onEntityAttacked

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityAttacked(LivingAttackEvent event)
{
	EntityLivingBase base = event.entityLiving;

	if(base.getEquipmentInSlot(4) != null && base.getEquipmentInSlot(4).getItem() instanceof ItemGasMask)
	{
		ItemGasMask mask = (ItemGasMask)base.getEquipmentInSlot(4).getItem();

		if(base.getEquipmentInSlot(3) != null && base.getEquipmentInSlot(3).getItem() instanceof ItemScubaTank)
		{
			ItemScubaTank tank = (ItemScubaTank)base.getEquipmentInSlot(3).getItem();

			if(tank.getFlowing(base.getEquipmentInSlot(3)) && tank.getGas(base.getEquipmentInSlot(3)) != null)
			{
				if(event.source == DamageSource.magic)
				{
					event.setCanceled(true);
				}
			}
		}
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:24,代码来源:ItemGasMask.java

示例6: onEntityAttacked

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityAttacked(LivingAttackEvent event)
{
	EntityLivingBase base = event.entityLiving;

	if(base.getEquipmentInSlot(1) != null && base.getEquipmentInSlot(1).getItem() instanceof ItemFreeRunners)
	{
		ItemStack stack = base.getEquipmentInSlot(1);
		ItemFreeRunners boots = (ItemFreeRunners)stack.getItem();

		if(boots.getEnergy(stack) > 0 && event.source == DamageSource.fall)
		{
			boots.setEnergy(stack, boots.getEnergy(stack)-event.ammount*50);
			event.setCanceled(true);
		}
	}
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:18,代码来源:ItemFreeRunners.java

示例7: attackedEntity

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void attackedEntity(LivingAttackEvent event) {
	if (event.getSource().getEntity() instanceof EntityPlayerMP && event.getSource().damageType.equals("player")
			&& Settings.Silly.moonPhasesOPPlzNerf) {
		EntityPlayerMP player = (EntityPlayerMP) event.getSource().getEntity();
		if (player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() instanceof IMoonDamage
				&& event.getEntityLiving().getHealth() > 0) {
			event.setCanceled(true);
			if (!player.worldObj.isRemote) {
				event.getEntity().attackEntityFrom(new MoonModifierDamageSource("moonModifier", player),
						getMoonDamage(player.worldObj.getCurrentMoonPhaseFactor(), event.getAmount()));
				int itemDamage = player.getHeldItemMainhand().getItemDamage() + 1;
				player.getHeldItemMainhand().getItem().setDamage(player.getHeldItemMainhand(), itemDamage);
			}
		}
	}
}
 
开发者ID:Nincraft,项目名称:NincraftLib,代码行数:18,代码来源:DamageModifierHandler.java

示例8: onAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@ForgeSubscribe
public void onAttack(LivingAttackEvent event)
{
	Entity source = event.source.getSourceOfDamage();
	
	if(source != null && source instanceof EntityLiving && !event.source.isProjectile())
	{
		EntityLiving attacker = (EntityLiving)source;
		
		PotionEffect affliction = attacker.getActivePotionEffect(Potion.confusion);
		
		if(affliction != null)
		{
			Random rand = attacker.getRNG();
			int tier = affliction.getAmplifier();
			
			if(rand.nextInt(5) <= tier)
			{
				event.setCanceled(true);
			}
		}
	}
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:24,代码来源:EventManagerMF.java

示例9: onLivingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent event)
{
    if (stoppedDamageSources.keySet().contains(event.source.damageType) && SprinklesForVanilla.isOnServer)
    {
        int value = stoppedDamageSources.get(event.source.damageType);
        switch(value)
        {
            case 1:
                if (!(event.entity instanceof EntityPlayer))
                    break;
            case 2:
                event.setCanceled(true);
                break;
            default:
                LogHelper.warn("Found incorrect value in stoppedDamageSources: " + event.source.damageType + ", " + value);
                break;
        }
    }
}
 
开发者ID:VikeStep,项目名称:sprinkles_for_vanilla,代码行数:21,代码来源:EntityHandlers.java

示例10: onLivingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent event) {
	EntityLivingBase entityLiving = event.entityLiving;

	if ((event.source != null && event.source == DamageSource.lava
			|| event.source == DamageSource.inFire || event.source == DamageSource.onFire)
			&& (hasEquippedSet(entityLiving, ModArmor.fireHelmet,
					ModArmor.fireChest, ModArmor.fireLeggings,
					ModArmor.fireBoots)
					|| hasEquippedSet(entityLiving, ModArmor.chaosHelmet,
							ModArmor.chaosChest, ModArmor.chaosLeggings,
							ModArmor.chaosBoots) || hasEquippedSet(
						entityLiving, ModArmor.orderHelmet,
						ModArmor.orderChest, ModArmor.orderLeggings,
						ModArmor.orderBoots))) {
		event.setCanceled(true);
		entityLiving.extinguish();
	}
}
 
开发者ID:testmad,项目名称:GaiaMod,代码行数:20,代码来源:GaiaModEventHandler.java

示例11: onLivingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent event){
    if(DifficultyManager.enabled) {
        Entity causeMob = event.getSource().getTrueSource();
        if (causeMob instanceof EntityLiving
                && event.getEntity() instanceof EntityPlayer
                && MobNBTHandler.isModifiedMob((EntityLiving) causeMob)) {
            Map<String, Integer> changes = MobNBTHandler.getChangeMap((EntityLiving) causeMob);
            String regionName = MobNBTHandler.getEntityRegion((EntityLiving) causeMob);
            Region mobRegion = DifficultyManager.getRegionByName(regionName);
            String mobId = EntityList.getEntityString(causeMob);
            for (String change : changes.keySet()) {
                try {
                    DifficultyModifier modifier = mobRegion.getModifierForMobById(mobId, change);
                    if (modifier != null) {
                        modifier.handleDamageEvent(event);
                    }
                } catch (Exception e) {
                    LOG.warn("Error applying modifier at onLivingAttack.  Mob was " + causeMob.getName() + ", Modifier was " + change + ".  Please report to Progressive Difficulty Developer!");
                    LOG.warn("\tCaught Exception had message " + e.getMessage());
                }
            }
        } else if (event.getSource().getImmediateSource() instanceof PotionCloudModifier.PlayerEffectingOnlyEntityAreaEffectCloud
                && !(event.getEntity() instanceof EntityPlayer)) {
            event.setCanceled(true);
        }
    }
}
 
开发者ID:talandar,项目名称:ProgressiveDifficulty,代码行数:29,代码来源:EventHandler.java

示例12: autoShield

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void autoShield(LivingAttackEvent event) {
	
	if (!(event.getEntityLiving() instanceof EntityPlayer)) return;
	if (!(event.getSource().getSourceOfDamage() instanceof EntityArrow)) return;
	
	ItemStack shield = ((EntityPlayer)event.getEntityLiving()).getHeldItemOffhand();
	ItemStack emblem = BaublesApi.getBaublesHandler((EntityPlayer)event.getEntityLiving()).getStackInSlot(6);
	if (shield == null || emblem == null) return;
	if (emblem.getItem() != this || !(shield.getItem() instanceof ItemShield)) return;
	
	shield.attemptDamageItem(1, event.getEntityLiving().worldObj.rand);
	event.setCanceled(true);
}
 
开发者ID:bafomdad,项目名称:uniquecrops,代码行数:15,代码来源:EmblemDefense.java

示例13: onLivingAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingAttack(LivingAttackEvent event)
{
	if (event.getSource() != null && event.getSource().getTrueSource() != null)
	{
		if (event.getSource().getTrueSource() instanceof EntityLivingBase && ((EntityLivingBase)event.getSource().getTrueSource()).isPotionActive(ExPPotions.stunned))
		{
			event.setCanceled(true);
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:12,代码来源:ExPHandlerServer.java

示例14: onAttack

import net.minecraftforge.event.entity.living.LivingAttackEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onAttack(LivingAttackEvent event) {
    if (event.getEntityLiving() instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) event.getEntityLiving();
        PossessivePlayer possessivePlayer = PossessHandler.get(player);
        if (possessivePlayer != null) {
            if (event.getSource().isFireDamage()) {
                event.setCanceled(true);
            } else {
                possessivePlayer.getPossessing().attackEntityFrom(event.getSource(), event.getAmount());
                event.setCanceled(true);
                if (!player.capabilities.isCreativeMode && !event.getSource().canHarmInCreative() && possessivePlayer.getPossessing().hurtTime <= 0) {
                    this.playPossessedHurtAnimation(player);
                }
            }
        }
    } else {
        EntityPlayer possessor = PossessHandler.getPossesor(event.getEntityLiving());
        if (possessor != null) {
            if (possessor.capabilities.isCreativeMode && !event.getSource().canHarmInCreative()) {
                event.setCanceled(true);
            } else if (possessor.hurtTime <= 0) {
                this.playPossessedHurtAnimation(possessor);
            }
        }
    }
}
 
开发者ID:Fararise,项目名称:Possessed,代码行数:28,代码来源:ServerEventHandler.java

示例15: 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);
            }
        }
    }
}
 
开发者ID:DaedalusGame,项目名称:BetterWithAddons,代码行数:15,代码来源:AssortedHandler.java


注:本文中的net.minecraftforge.event.entity.living.LivingAttackEvent.setCanceled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。