當前位置: 首頁>>代碼示例>>Java>>正文


Java AttackEntityEvent.setCanceled方法代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.player.AttackEntityEvent.setCanceled方法的典型用法代碼示例。如果您正苦於以下問題:Java AttackEntityEvent.setCanceled方法的具體用法?Java AttackEntityEvent.setCanceled怎麽用?Java AttackEntityEvent.setCanceled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.event.entity.player.AttackEntityEvent的用法示例。


在下文中一共展示了AttackEntityEvent.setCanceled方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onAttack

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onAttack(AttackEntityEvent event) {
	if (!event.getEntityLiving().getHeldItemMainhand().isEmpty()) {
		if (disabledItems.contains(event.getEntityLiving().getHeldItemMainhand().getItem())) {
			event.setCanceled(true);
			if (event.getTarget().canBeAttackedWithItem()) {
				if (!event.getTarget().hitByEntity(event.getEntity())) {
					event.getEntityPlayer().setLastAttackedEntity(event.getTarget());
					event.getEntityPlayer().world.playSound((EntityPlayer) null, event.getEntityPlayer().posX, event.getEntityPlayer().posY, event.getEntityPlayer().posZ, SoundEvents.ENTITY_PLAYER_ATTACK_WEAK, event.getEntityPlayer().getSoundCategory(), 1.0F, 1.0F);
					event.getTarget().attackEntityFrom(DamageSource.causePlayerDamage(event.getEntityPlayer()), event.getEntityPlayer().getCooledAttackStrength(1F));
					event.getEntityPlayer().addExhaustion(0.1F);
				}
			}
		}
	}
}
 
開發者ID:tom5454,項目名稱:Toms-Mod,代碼行數:17,代碼來源:EventHandler.java

示例2: onAttack

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onAttack(AttackEntityEvent event){
	if(event.entityPlayer != null && event.entityPlayer.getHeldItem() != null)
		if(event.entityPlayer.getHeldItem().hasTagCompound())
			if(event.entityPlayer.getHeldItem().getTagCompound().hasKey("Fidelis"))
			{
				String fidelisID = event.entityPlayer.getHeldItem().getTagCompound().getString("Fidelis");
				if(event.entityPlayer.getGameProfile().getId().toString().equals(fidelisID))
					return;
				else if(fidelisID.equals(""))
				{
					event.entityPlayer.getHeldItem().getTagCompound().setString("Fidelis", event.entityPlayer.getGameProfile().getId().toString());
					event.entityPlayer.getHeldItem().getTagCompound().setString("FidelisDisplay", event.entityPlayer.getDisplayName());
				}
				else
					event.setCanceled(true);
			}
}
 
開發者ID:UnderMybrella,項目名稱:Fidelis,代碼行數:19,代碼來源:Fidelis.java

示例3: onEntityAttacked

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityAttacked(AttackEntityEvent event){
	if (event.entityPlayer.worldObj.isRemote)
		return;

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

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

	if (event.target instanceof EntityMob)
		if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(event.entityPlayer, PermissionsMutex.HARM_MONSTERS, event.target.posX, event.target.posY, event.target.posZ))
			event.setCanceled(true);		
}
 
開發者ID:Mithion,項目名稱:GriefGuardian,代碼行數:18,代碼來源:ClaimGuardEventHandler.java

示例4: onAttack

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
	public void onAttack(AttackEntityEvent event) {
		EntityPlayer player = event.getEntityPlayer();
		if (player != null && player.getHealth() <= 0f) {
//			if(ModConfig.allowUnarmedMelee && player.getHeldItemMainhand().isEmpty()) {
//				return;
//			}
			event.setCanceled(true);
		}
	}
 
開發者ID:blay09,項目名稱:HardcoreRevival,代碼行數:11,代碼來源:RestrictionHandler.java

示例5: onAttack

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@SuppressWarnings("BooleanVariableAlwaysNegated")
@SubscribeEvent(priority = EventPriority.HIGH)
public void onAttack(AttackEntityEvent event)
{
    //Process for chiseling a sheep
    final Entity sheep = event.getTarget();
    if (sheep == null) return;

    final EntityPlayer entityPlayer = event.getEntityPlayer();
    ItemStack activeStack = entityPlayer.inventory.getCurrentItem();
    boolean attackedWithChisel = false;
    if (activeStack != null && ChiselLibrary.isChisel(activeStack.getItem()))
    {
        attackedWithChisel = true;
    } else
    {
        activeStack = entityPlayer.inventory.offHandInventory[0];
        if (activeStack != null && ChiselLibrary.isChisel(activeStack.getItem()))
        {
            attackedWithChisel = true;
        }
    }
    if (!attackedWithChisel)
    {
        return;
    }

    if (!sheep.hasCapability(Capability.CHISELED_SHEEP, null)) {
        return;
    }

    event.setCanceled(true);

    Chiseling.chiselSheep(sheep, entityPlayer, activeStack);
}
 
開發者ID:AtomicBlom,項目名稱:ShearMadness,代碼行數:36,代碼來源:CommonForgeEventProxy.java

示例6: onEvent

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@Override
public void onEvent(AttackEntityEvent event) {
	if (event.getEntity() instanceof EntityPlayerMP) {
		ServerPlayerSettings settings = getPlayerSettings((EntityPlayerMP) event.getEntity());
		
		if (settings.superpunch > 0) {
			event.setCanceled(true);
			this.attackWithSuperpunch((EntityPlayer) event.getEntity(), event.getTarget(), settings.superpunch);
		}
	}
}
 
開發者ID:MrNobody98,項目名稱:morecommands,代碼行數:12,代碼來源:CommandSuperpunch.java

示例7: onEntityAttack

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityAttack(AttackEntityEvent event) {
	if (event.entity instanceof EntityAmbientCreature || event.entity instanceof EntityAnimal || event.entity instanceof EntityPlayer) {
		EntityPlayerMP player = (EntityPlayerMP) event.entityPlayer;
		if (CoreClaim.claimManager.checkEventCancel(event.entityPlayer, (int) event.entity.posX, (int) event.entity.posZ)) {
			event.setCanceled(true);
			Utils.messageToPlayer(player, EnumChatFormatting.RED + "Oh snap, you are not allowed to harm this entity!");
		}
	}
}
 
開發者ID:unitedworldminers,項目名稱:ClaimIO,代碼行數:11,代碼來源:EventBus.java

示例8: on

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void on(AttackEntityEvent e) {
    EntityPlayer player = e.entityPlayer;
    if(!e.target.worldObj.isRemote && e.target instanceof EntityGolemTH
            && player.isSneaking()) {
        e.setCanceled(true);

        ItemStack stack = player.getCurrentEquippedItem();
        if (stack != null && stack.getItem().onLeftClickEntity(stack, player, e.target)
                && e.target.isDead) {
            CommonProxy.EVENT_HANDLER_GOLEM.on(new PlaySoundAtEntityEvent(e.target, "thaumcraft:zap", 0.5f, 1.0f));
        }
    }
}
 
開發者ID:makeoo,項目名稱:Gadomancy,代碼行數:15,代碼來源:IntegrationThaumicHorizions.java

示例9: onAttackEntity

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@SuppressWarnings("unused")
@SubscribeEvent
public void onAttackEntity(AttackEntityEvent event) {
    if (event.entityPlayer != null &&
        event.entityPlayer.getHeldItem() != null &&
        ItemWeapon.class.isAssignableFrom(event.entityPlayer.getHeldItem().getItem().getClass())
        ) {
        event.setCanceled(true);
    }
}
 
開發者ID:gigimoi,項目名稱:Zombie-Total-Conversion-Craft,代碼行數:11,代碼來源:PlayerManager.java

示例10: attackEntity

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
/**
 * Cancel the attack if the player reach is lowered by some types of items, or if barehanded
 * Note: Applies to either hands, since item is hotswap before this event for offhand weapons
 * @param event for the player attacking an entity
 */
@SubscribeEvent
public void attackEntity(AttackEntityEvent event){
    if(((IBattlePlayer) event.getEntityPlayer()).getSpecialActionTimer() > 0){
        event.setCanceled(true);
        return;
    }
    double reachMod = maxReachDistance(event.getEntityPlayer());
    if (reachMod < event.getEntityPlayer().getDistanceToEntity(event.getTarget())) {
        event.setCanceled(true);
    }
}
 
開發者ID:Mine-and-blade-admin,項目名稱:Battlegear2,代碼行數:17,代碼來源:BattlemodeHookContainerClass.java

示例11: AttackEntity

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void AttackEntity(AttackEntityEvent event) {
	if (event.getEntityPlayer().getEntityData().hasKey("renderViewCamera"))
		event.setCanceled(true);
}
 
開發者ID:PorPit,項目名稱:MineCamera,代碼行數:6,代碼來源:EventLoader.java

示例12: hitEntity

import net.minecraftforge.event.entity.player.AttackEntityEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void hitEntity(AttackEntityEvent event)
{
	if (DisabledHandler.isDisabledStack(event.entityPlayer)) event.setCanceled(true);
}
 
開發者ID:hilburn,項目名稱:DimensionGuard,代碼行數:6,代碼來源:EventHandler.java


注:本文中的net.minecraftforge.event.entity.player.AttackEntityEvent.setCanceled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。