当前位置: 首页>>代码示例>>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;未经允许,请勿转载。