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


Java LivingHurtEvent.setCanceled方法代码示例

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


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

示例1: livingHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void livingHurt(LivingHurtEvent event) {
	if (!event.getEntity().world.isRemote)
		if(event.getSource().getTrueSource() instanceof EntityArmyMember) {
			if (event.getEntityLiving() instanceof EntityPlayerMP) {
				if (event.getSource().isProjectile()) {
					if (event.getSource().getTrueSource() instanceof EntitySkeletonWarrior && ((EntitySkeletonWarrior) event.getSource().getTrueSource()).getOwnerId().equals(event.getEntityLiving().getUniqueID()))
						CriterionRegistry.instance.SKELETON_STATUS_UPDATE.trigger((EntityPlayerMP) event.getEntityLiving(), event.getSource().getTrueSource(), Items.ARROW, 0);
					else if (event.getSource().getTrueSource() instanceof EntityConvertedSkeleton && ((EntityConvertedSkeleton) event.getSource().getTrueSource()).getOwnerId().equals(event.getEntityLiving().getUniqueID()))
						CriterionRegistry.instance.SKELETON_STATUS_UPDATE.trigger((EntityPlayerMP) event.getEntityLiving(), event.getSource().getTrueSource(), Items.ARROW, 1);
				}
				if(ConfigValues.FF && Alliances.getInstance().isAlliedTo(((EntityArmyMember) event.getSource().getTrueSource()).getOwnerId(), event.getEntityLiving().getUniqueID()))
					event.setCanceled(true);
			} else if(ConfigValues.FF && event.getEntityLiving() instanceof EntityArmyMember && Alliances.getInstance().isAlliedTo(((EntityArmyMember) event.getSource().getTrueSource()).getOwnerId(), ((EntityArmyMember)event.getEntityLiving()).getOwnerId()))
				event.setCanceled(true);
		} else if (ConfigValues.FF && event.getSource().getTrueSource() instanceof EntityPlayer) {
			if(event.getEntityLiving() instanceof EntityPlayer && Alliances.getInstance().isAlliedTo(event.getSource().getTrueSource().getUniqueID(), event.getEntityLiving().getUniqueID()))
				event.setCanceled(true);
			else if(event.getEntityLiving() instanceof EntityArmyMember && Alliances.getInstance().isAlliedTo(event.getSource().getTrueSource().getUniqueID(), ((EntityArmyMember)event.getEntityLiving()).getOwnerId()))
				event.setCanceled(true);
		}
}
 
开发者ID:The-Fireplace-Minecraft-Mods,项目名称:Overlord,代码行数:23,代码来源:CommonEvents.java

示例2: reflecteffect

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void reflecteffect(LivingHurtEvent lde,EntityPlayerMP sender)
  {
    if ((Main.allowPFeather) && ((lde.entityLiving instanceof EntityPlayer)))
    {
      EntityPlayer ep = (EntityPlayer)lde.entityLiving;
  	if (((EntityLivingBase) ep).isPotionActive(ItemRegistry1.customPotion2))
      {
        if (!ep.worldObj.isRemote)
        {
        	 lde.setCanceled(true);
        	 
          ep.worldObj.playSoundAtEntity(ep, "fireworks.launch", 5.0F, 1.0F);
          ep.worldObj.playSoundAtEntity(ep, "assets.speedboost", 0.4F, 0.3F);
          ((EntityLivingBase) ep).removePotionEffect(ItemRegistry1.customPotion2.id);
        }
       
       
      }
    }
  }
 
开发者ID:GhostMonk3408,项目名称:MidgarCrusade,代码行数:22,代码来源:ForgeEventHooksHandler.java

示例3: fallOutOfTeletory

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void fallOutOfTeletory(LivingHurtEvent ev) {
	if (ev.getEntity().getEntityWorld().isRemote || !(ev.getEntity() instanceof EntityPlayerMP)) {
		return;
	}

	if (ev.getSource() != DamageSource.OUT_OF_WORLD) {
		return;
	}

	EntityPlayerMP thePlayer = (EntityPlayerMP) ev.getEntity();

	if (thePlayer.dimension != Teletory.DIMID) {
		return;
	}
	ev.setCanceled(true);
	changeEntityDimension(thePlayer, TeleportorType.FALL);
}
 
开发者ID:ToroCraft,项目名称:TeleToro,代码行数:19,代码来源:Teletory.java

示例4: onLivingHurtEvent

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
	public void onLivingHurtEvent(LivingHurtEvent event) {
		if (!event.entity.worldObj.isRemote && event.entity instanceof EntityPlayer && DragonPlayer.get((EntityPlayer) event.entity).isDragon()) {
			if (event.source.equals(DamageSource.lava) || event.source.equals(DamageSource.onFire) || event.source.equals(DamageSource.inFire)) {
				event.setCanceled(true);
//				LogHelper.info("DragonPlayerEventHandler: onLivingHurtEvent, no damage from lava!");
			}
			// Damage yourself (probably an explosion)
			else if (BALANCE.DRAGON_PLAYER_ABILITIES.RECEIVE_EXPLODING_FIREBALL_DAMAGE == false && event.source.isExplosion()) {
				event.setCanceled(true);
			}
			else if (ItemDragonEgg.hasAbility((EntityPlayer) event.entity, Abilities.NOBLOCKDAMAGE) && event.source.equals(DamageSource.inWall)) {
				event.setCanceled(true);
	        }
			else if (event.source.equals(DamageSource.fall)) {
				event.setCanceled(true);
			}
			// Prevent damage from entities that are picked up (that ride the dragon)
			else if (event.entity.riddenByEntity != null) {
				event.setCanceled(true);				
			}
		}
	}
 
开发者ID:DracoAnimus,项目名称:Coding,代码行数:24,代码来源:DragonPlayerEventHandler.java

示例5: onPlayerHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerHurt(LivingHurtEvent event) {
  if (event.getEntityLiving().getHealth() - event.getAmount() <= 0 && event.getEntityLiving() instanceof EntityPlayer) {
    EntityPlayer p = (EntityPlayer) event.getEntityLiving();
    for (int i = 0; i < p.inventory.getSizeInventory(); ++i) {
      ItemStack s = p.inventory.getStackInSlot(i);
      if (s.getItem() instanceof ItemSoulstone) {
        UtilChat.addChatMessage(p, event.getEntityLiving().getName() + UtilChat.lang("item.soulstone.used"));
        p.inventory.setInventorySlotContents(i, ItemStack.EMPTY);
        UtilSound.playSound(p, SoundEvents.BLOCK_GLASS_BREAK);
        p.setHealth(6);// 3 hearts
        int time = Const.TICKS_PER_SEC * 30;
        p.addPotionEffect(new PotionEffect(MobEffects.FIRE_RESISTANCE, time));
        time = Const.TICKS_PER_SEC * 60;//a full minute
        p.addPotionEffect(new PotionEffect(MobEffects.RESISTANCE, time));
        p.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, time, 4));
        //and bad luck lasts much longer
        time = Const.TICKS_PER_SEC * 60 * 10;
        p.addPotionEffect(new PotionEffect(MobEffects.UNLUCK, time));
        p.addPotionEffect(new PotionEffect(MobEffects.WEAKNESS, time, 1));
        event.setCanceled(true);
        break;
      }
    }
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:27,代码来源:ItemSoulstone.java

示例6: onLivingHurtEvent

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLivingHurtEvent(LivingHurtEvent event) {
	if (event.getEntity() != null && event.getEntity() instanceof EntityPlayer)
	{
		EntityPlayer player = (EntityPlayer)event.getEntity();
		
		for (ItemStack armor : player.getArmorInventoryList()) {
		    if (armor != null && armor.getItem() instanceof LongFallBoots)
		    {
		    	if (event.getSource() == DamageSource.FLY_INTO_WALL) {
		    		System.out.println("Flew into wall");
					// this cancels the fall event so you take no damage
					event.setCanceled(true);
		    	}
		    }
		}
	}
}
 
开发者ID:yyon,项目名称:grapplemod,代码行数:19,代码来源:LongFallBoots.java

示例7: shieldAbsorbDamage

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void shieldAbsorbDamage(LivingHurtEvent event)
{
	if (!event.source.isUnblockable())
	{
		ScienceShield shield = ScienceShield.loadShieldForEntity(event.entityLiving);
		float dmgRemaining = shield.tryAbsorbDamage(event.ammount);
		if (dmgRemaining <= 0) {
			event.setCanceled(true);
		}
		else {
			event.ammount = dmgRemaining;
		}
		shield.save();
	}
}
 
开发者ID:JasonYe4273,项目名称:Minecraft-Modding,代码行数:17,代码来源:ArmorHandler.java

示例8: onPreHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
/**
 * Pre-event to handle shield blocking (only posted when not in BG2 battle mode)
 */
@SubscribeEvent(priority=EventPriority.NORMAL)
public void onPreHurt(LivingHurtEvent event) {
	if (event.entity instanceof EntityPlayer) {
		EntityPlayer player = (EntityPlayer) event.entity;
		ItemStack stack = player.getHeldItem();
		if (stack != null && stack.getItem() instanceof ItemZeldaShield && player.isUsingItem()) {
			ItemZeldaShield shield = (ItemZeldaShield) stack.getItem();
			if (ZSSPlayerInfo.get(player).canBlock() && shield.canBlockDamage(stack, event.source)) {
				Entity opponent = event.source.getEntity();
				if (opponent != null && TargetUtils.isTargetInFrontOf(opponent, player, 60)) {
					event.ammount = shield.onBlock(player, stack, event.source, event.ammount);
					event.setCanceled(event.ammount < 0.1F);
				}
			}
		}
	}
}
 
开发者ID:coolAlias,项目名称:ZeldaSwordSkills,代码行数:21,代码来源:ZSSCombatEvents.java

示例9: onEntityHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityHurt(LivingHurtEvent event){
	if (event.entity.worldObj.isRemote)
		return;

	EntityPlayer player = null;
	if (event.source.getSourceOfDamage() != null && event.source.getSourceOfDamage() instanceof EntityPlayer){
		player = (EntityPlayer)event.source.getSourceOfDamage();
	}
	if (player == null)
		return;

	if (event.entity instanceof EntityPlayer)
		if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(player, PermissionsMutex.HARM_PLAYERS, event.entity.posX, event.entity.posY, event.entity.posZ))
			event.setCanceled(true);

	if (event.entity instanceof EntityCreature)
		if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(player, PermissionsMutex.HARM_CREATURES, event.entity.posX, event.entity.posY, event.entity.posZ))
			event.setCanceled(true);

	if (event.entity instanceof EntityMob)
		if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(player, PermissionsMutex.HARM_MONSTERS, event.entity.posX, event.entity.posY, event.entity.posZ))
			event.setCanceled(true);
}
 
开发者ID:Mithion,项目名称:GriefGuardian,代码行数:25,代码来源:ClaimGuardEventHandler.java

示例10: onHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@Override
public void onHurt(LivingHurtEvent event, DamageSource source, EntityLivingBase affected, int amplifier) {
	Entity attacker = source.getImmediateSource();
	if (attacker != null) {
		event.setCanceled(true);
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:8,代码来源:OvercoatBrew.java

示例11: onHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@Override
public void onHurt(LivingHurtEvent event, DamageSource source, EntityLivingBase affected, int amplifier) {
	Entity attacker = source.getImmediateSource();
	if (attacker != null && source.isProjectile()) {
		event.setCanceled(true);
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:8,代码来源:BulletProofBrew.java

示例12: onLivingHurt

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@HarshenEvent
public void onLivingHurt(LivingHurtEvent event)
{
	if(HarshenUtils.toArray(DamageSource.FLY_INTO_WALL, DamageSource.FALL).contains(event.getSource())
			&& event.getEntityLiving().getItemStackFromSlot(EntityEquipmentSlot.CHEST).getItem() == Items.ELYTRA)
		event.setCanceled(true);		
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:8,代码来源:ElytraPendant.java

示例13: PlayerInteraction

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
  public void PlayerInteraction(LivingHurtEvent evt) {
	if(Main.debug==1)System.out.println(evt.getEntity().getName() + " called PlayerHurt  " + evt.getEntity().toString());
	
	if(evt.getEntity() instanceof EntityPlayer && !Main.logged.contains(evt.getEntity().getName())){
		evt.setCanceled(true);
	}
}
 
开发者ID:Fungie2134,项目名称:AuthMod,代码行数:9,代码来源:PlayerHurt.java

示例14: onDamageTaken

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onDamageTaken(LivingHurtEvent event)
{
	if (event.getEntityLiving() instanceof EntityPlayer && !event.getEntityLiving().world.isRemote)
	{
		if (event.getSource() != null && !event.getSource().canHarmInCreative())
		{
			PlayerManager.takeDamage((EntityPlayer) event.getEntityLiving(), event.getSource(), event.getAmount());
			event.setCanceled(true);
		}
	}
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:13,代码来源:ExPHandlerServer.java

示例15: onEntityDamage

import net.minecraftforge.event.entity.living.LivingHurtEvent; //导入方法依赖的package包/类
@SideOnly(Side.SERVER)
@SubscribeEvent
public void onEntityDamage(LivingHurtEvent e) {
    if(e.source.getEntity() instanceof EntityPlayer) {
        EntityPlayer    attacker = (EntityPlayer) e.source.getEntity();
        PlayerAokIEEP attackerAok = PlayerAokIEEP.get(attacker);
        TileCore nearByCore = AgeOfKingdom.serverProxy.getClosestTileCoreInField(attacker);
        if(nearByCore == null || nearByCore.getAokName().equals("null") || nearByCore.getAokName().equals(attackerAok.getAokName())) {
            return;
        }
        attacker.addChatComponentMessage(new ChatComponentText( StatCollector.translateToLocal("event.onEntityDamage.NoPermission")));
        e.setCanceled(true);
    }
}
 
开发者ID:jackey8616,项目名称:Age-of-Kingdom,代码行数:15,代码来源:EventManager.java


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