Java 类net.minecraftforge.event.entity.player.EntityInteractEvent 实例源码

项目:connor41-etfuturum2    文件:ServerEventHandler.java   
@SubscribeEvent
public void interactEntityEvent(EntityInteractEvent event) {
    ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
    if (stack == null)
        return;
    if (!(event.target instanceof EntityAnimal))
        return;

    EntityAnimal animal = (EntityAnimal) event.target;
    if (!animal.isChild()) {
        if (animal instanceof EntityPig) {
            if (stack.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot)
                setAnimalInLove(animal, event.entityPlayer, stack);
        } else if (animal instanceof EntityChicken)
            if (stack.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot)
                setAnimalInLove(animal, event.entityPlayer, stack);
    } else if (EtFuturum.enableBabyGrowthBoost && isFoodItem(animal, stack))
        feedBaby(animal, event.entityPlayer, stack);
}
项目:ThermalRecycling    文件:BreedingItemManager.java   
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = false)
public void entityInteract(final EntityInteractEvent event) {
    if(event.entityPlayer instanceof EntityPlayerMP && event.target instanceof EntityAnimal) {
        final EntityPlayerMP player = (EntityPlayerMP)event.entityPlayer;
        final ItemStack heldItem = player.getCurrentEquippedItem();
        if(heldItem != null) {
            final EntityAnimal animal = (EntityAnimal)event.target;
            if(canBreed(animal, player)) {
                final Set<ItemStackKey> possibleFood = foodItems.get(event.target.getClass());
                if(possibleFood != null && possibleFood.contains(ItemStackKey.getCachedKey(heldItem))) {
                    if (!event.entityPlayer.capabilities.isCreativeMode) {
                        heldItem.stackSize--;
                        if (heldItem.stackSize <= 0)
                            player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
                    }
                    animal.func_146082_f(player);
                }
            }
        }
    }
}
项目:HorseFood    文件:ModHorseFood.java   
@SubscribeEvent
public void onEntityInteractEvent(EntityInteractEvent event){

    if(event.getEntity() instanceof EntityPlayer == false){
        return;
    }
    EntityPlayer entityPlayer = (EntityPlayer)event.getEntity();
    ItemStack held = entityPlayer.getHeldItemMainhand();

    if(held != null && held.getItem() instanceof ItemHorseFood){
        if(event.getTarget() instanceof EntityHorse){
            ItemHorseFood.onHorseInteract((EntityHorse) event.getTarget(), entityPlayer, held);

            event.setCanceled(true);// stop the GUI inventory opening
        }
    }
}
项目:Et-Futurum    文件:ServerEventHandler.java   
@SubscribeEvent
public void interactEntityEvent(EntityInteractEvent event) {
    ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
    if (stack == null)
        return;
    if (!(event.target instanceof EntityAnimal))
        return;

    EntityAnimal animal = (EntityAnimal) event.target;
    if (!animal.isChild()) {
        if (animal instanceof EntityPig) {
            if (stack.getItem() == ModItems.beetroot && EtFuturum.enableBeetroot)
                setAnimalInLove(animal, event.entityPlayer, stack);
        } else if (animal instanceof EntityChicken)
            if (stack.getItem() == ModItems.beetroot_seeds && EtFuturum.enableBeetroot)
                setAnimalInLove(animal, event.entityPlayer, stack);
    } else if (EtFuturum.enableBabyGrowthBoost && isFoodItem(animal, stack))
        feedBaby(animal, event.entityPlayer, stack);
}
项目:CustomAI    文件:EntityEvents.java   
@SubscribeEvent
public void onEntityInteraction(EntityInteractEvent e)
{
    ItemStack stack = e.entityPlayer.getCurrentEquippedItem();
    if(stack != null)
    {
        if(stack.getItem() == ModCustomAI.rewriterItem)
        {
            e.setCanceled(true);
            CustomAIPlayerExtendedProperties props = (CustomAIPlayerExtendedProperties)e.entityPlayer.getExtendedProperties(ModCustomAI.MODID);
            if(props == null)
            {
                e.entityPlayer.registerExtendedProperties(ModCustomAI.MODID, new CustomAIPlayerExtendedProperties());
            }
            props.setEntityInteractingWith(e.target.getEntityId(), e.target.getClass());
            FMLNetworkHandler.openGui(e.entityPlayer, ModCustomAI.instance, 0, e.entityPlayer.worldObj, (int)Math.floor(e.entityPlayer.posX), (int)Math.floor(e.entityPlayer.posY), (int)Math.floor(e.entityPlayer.posZ));
        }
        else if(stack.getItem() == ModCustomAI.copierItem)
        {
            e.setCanceled(!((AICopierItem)stack.getItem()).onInteract(e.entityPlayer.worldObj, stack, e.entityPlayer, e.target));
        }
    }
}
项目:archimedes-ships    文件:CommonHookContainer.java   
@SubscribeEvent
public void onInteractWithEntity(EntityInteractEvent event)
{
    if (event.entityPlayer != null)
    {
        int x = MathHelper.floor_double(event.target.posX);
        int y = MathHelper.floor_double(event.target.posY);
        int z = MathHelper.floor_double(event.target.posZ);

        TileEntity te = event.entity.worldObj.getTileEntity(x, y, z);
        if (te instanceof TileEntityCrate && ((TileEntityCrate) te).getContainedEntity() == event.target)
        {
            ((TileEntityCrate) te).releaseEntity();
            event.setCanceled(true);
        }
    }
}
项目:GriefGuardian    文件:ClaimGuardEventHandler.java   
@SubscribeEvent
public void onEntityInteract(EntityInteractEvent event){
    if (event.entityPlayer.worldObj.isRemote)
        return;

    if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(event.entityPlayer, PermissionsMutex.ENTITY_INTERACT, event.target.posX, event.target.posY, event.target.posZ))
        event.setCanceled(true);
    else
        GriefGuardian._dal.logAction(
                (EntityPlayerMP)event.entityPlayer, 
                Actions.ENTITY_INTERACT, 
                (int)Math.floor(event.entity.posX), 
                (int)Math.floor(event.entity.posY), 
                (int)Math.floor(event.entity.posZ), 
                event.entityPlayer.getCurrentEquippedItem(), 
                "");
}
项目:CartLivery    文件:CommonProxy.java   
@SubscribeEvent
public void handleMinecartPainting(EntityInteractEvent event) {
    if (event.entityPlayer.worldObj.isRemote) return;

    if (event.entityPlayer.isSneaking() && event.target.getExtendedProperties(CartLivery.EXT_PROP_NAME) != null) {
        ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
        CartLivery livery = (CartLivery) event.target.getExtendedProperties(CartLivery.EXT_PROP_NAME);
        int newColor = ColorUtils.getDyeColor(stack);   

        if (newColor != -1 && (!livery.pattern.isEmpty() || newColor != livery.baseColor)) {
            livery.baseColor = newColor;
            livery.pattern = "";
            stack.stackSize--;
            if (stack.stackSize == 0) event.entityPlayer.setCurrentItemOrArmor(0, null);

            CommonProxy.network.sendToAllAround(new LiveryUpdateMessage(event.target, livery), NetworkUtil.targetEntity(event.target));
            event.setCanceled(true);
        }
    }
}
项目:CartLivery    文件:CommonProxy.java   
@SubscribeEvent
public void handleMinecartStickerApply(EntityInteractEvent event) {
    if (event.entityPlayer.worldObj.isRemote) return;

    if (event.entityPlayer.isSneaking() && event.target.getExtendedProperties(CartLivery.EXT_PROP_NAME) != null) {
        ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
        if (stack == null || !(stack.getItem() instanceof ItemSticker) || stack.getTagCompound() == null) return;

        String pattern = stack.getTagCompound().getString("pattern");
        int patternColor = stack.getTagCompound().getInteger("patternColor");
        if (pattern.isEmpty()) return;

        CartLivery livery = (CartLivery) event.target.getExtendedProperties(CartLivery.EXT_PROP_NAME);
        if (!livery.pattern.isEmpty()) return;

        livery.pattern = pattern;
        livery.patternColor = patternColor;

        stack.stackSize--;
        if (stack.stackSize == 0) event.entityPlayer.setCurrentItemOrArmor(0, null);

        CommonProxy.network.sendToAllAround(new LiveryUpdateMessage(event.target, livery), NetworkUtil.targetEntity(event.target));
        event.setCanceled(true);
    }
}
项目:Morph    文件:EventHandler.java   
@SubscribeEvent
public void onInteract(EntityInteractEvent event)
{
    //      if(FMLCommonHandler.instance().getEffectiveSide().isServer() && event.target instanceof EntityLivingBase)
    //      {
    //          System.out.println(event.target);
    //          Morph.proxy.tickHandlerServer.trackingEntities.add();
    //      }
    //      if(FMLCommonHandler.instance().getEffectiveSide().isClient())
    //      {
    //          System.out.println("asdasdasdsad");
    //          if(event.target instanceof EntityLivingBase && !(event.target instanceof EntityMorphAcquisition))
    //          {
    //              event.entityPlayer.worldObj.spawnEntityInWorld(new EntityMorphAcquisition(event.entityPlayer.worldObj, (EntityLivingBase)event.target, event.entityPlayer));
    //          }
    //      }
    //      else
    //      {
    //          return;
    //      }
}
项目:ExtraUtilities    文件:EventHandlerServer.java   
@SubscribeEvent
public void goldenLasso(final EntityInteractEvent event) {
    final ItemStack itemstack = event.entityPlayer.getCurrentEquippedItem();
    if (itemstack != null && ExtraUtils.goldenLasso != null && itemstack.getItem() == ExtraUtils.goldenLasso && event.target instanceof EntityLivingBase && itemstack.interactWithEntity(event.entityPlayer, (EntityLivingBase)event.target)) {
        if (itemstack.stackSize <= 0) {
            event.entityPlayer.destroyCurrentEquippedItem();
        }
        event.setCanceled(true);
    }
}
项目:4Space-5    文件:EntityPlayer.java   
public boolean interactWith(Entity p_70998_1_)
{
    if (MinecraftForge.EVENT_BUS.post(new EntityInteractEvent(this, p_70998_1_))) {
        return false;
    }
    ItemStack itemstack = getCurrentEquippedItem();
    ItemStack itemstack1 = itemstack != null ? itemstack.copy() : null;
    if (!p_70998_1_.interactFirst(this))
    {
        if ((itemstack != null) && ((p_70998_1_ instanceof EntityLivingBase)))
        {
            if (this.capabilities.isCreativeMode) {
                itemstack = itemstack1;
            }
            if (itemstack.interactWithEntity(this, (EntityLivingBase)p_70998_1_))
            {
                if ((itemstack.stackSize <= 0) && (!this.capabilities.isCreativeMode)) {
                    destroyCurrentEquippedItem();
                }
                return true;
            }
        }
        return false;
    }
    if ((itemstack != null) && (itemstack == getCurrentEquippedItem())) {
        if ((itemstack.stackSize <= 0) && (!this.capabilities.isCreativeMode)) {
            destroyCurrentEquippedItem();
        } else if ((itemstack.stackSize < itemstack1.stackSize) && (this.capabilities.isCreativeMode)) {
            itemstack.stackSize = itemstack1.stackSize;
        }
    }
    return true;
}
项目:Factorization    文件:MiscellaneousNonsense.java   
@SubscribeEvent
public void doTheZorroThing(EntityInteractEvent event) {
    EntityPlayer player = event.entityPlayer;
    if (player.worldObj.isRemote) return;
    if (player.isRiding()) return;
    if (!(event.target instanceof EntityHorse)) return;
    EntityHorse horse = (EntityHorse) event.target;
    if (player.fallDistance <= 2) return;
    if (!horse.isHorseSaddled()) return;
    if (horse.getLeashed()) {
        if (!(horse.getLeashedToEntity() instanceof EntityLeashKnot)) return;
        horse.getLeashedToEntity().interactFirst(player);
    }
    boolean awesome = false;
    if (player.fallDistance > 5 && player.getHeldItem() != null) {
        Item held = player.getHeldItem().getItem();
        boolean has_baby = false;
        if (player.riddenByEntity instanceof EntityAgeable) {
            EntityAgeable ea = (EntityAgeable) player.riddenByEntity;
            has_baby = ea.isChild();
        }
        awesome = held instanceof ItemSword || held instanceof ItemAxe || held instanceof ItemBow || player.riddenByEntity instanceof EntityPlayer || has_baby;
    }
    if (awesome) {
        horse.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 20 * 40, 2, false, false));
        horse.addPotionEffect(new PotionEffect(Potion.resistance.id, 20 * 40, 1, true, true));
        horse.addPotionEffect(new PotionEffect(Potion.jump.id, 20 * 40, 1, true, true));
    } else {
        horse.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 20 * 8, 1, false, false));
    }
    horse.playLivingSound();
}
项目:Factorization    文件:BuffNametags.java   
@SubscribeEvent(priority = EventPriority.LOW)
public void buffedNametag(EntityInteractEvent event) {
    ItemStack is = event.entityPlayer.getHeldItem();
    if (is == null) return;
    if (is.getItem() != Items.name_tag) return;
    if (!(event.target instanceof EntityLiving)) return;
    final EntityLiving ent = (EntityLiving) event.target;
    final String origName = ent.getCustomNameTag();
    if (!Strings.isNullOrEmpty(origName)) return;
    NBTTagCompound tag = ent.getEntityData();
    final String name = "FZMiscBuffNametags";
    if (tag.hasKey(name)) return;
    tag.setBoolean(name, true);
    ent.tasks.addTask(0, new EntityAIBase() {
        boolean buffApplied = false; // Might not be necessary.

        @Override
        public boolean shouldExecute() {
            if (buffApplied) return false;
            buffApplied = true;
            if (ent.getCustomNameTag().equals(origName)) return false;
            float delta = 2*3;
            float origHealth = ent.getMaxHealth();
            float newMaxHealth = origHealth + delta;
            ent.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(newMaxHealth);
            ent.heal(delta);

            EnumParticleTypes particleType = EnumParticleTypes.HEART;
            if (ent instanceof IMob) {
                particleType = EnumParticleTypes.SMOKE_NORMAL;
            }
            if (ent.worldObj instanceof WorldServer) {
                WorldServer ws = (WorldServer) ent.worldObj;
                ws.spawnParticle(particleType, false, ent.posX, ent.posY, ent.posZ, 8, 0.0, 0.0, 0.0, 0.0);
            }
            return false;
        }
    });
}
项目:Real-Life-Mod-1.8    文件:ClientHandler.java   
@SubscribeEvent
public void onInteract(EntityInteractEvent e) {
    if (e.target instanceof EntityPlayer) {
        FMLClientHandler.instance().getClient().displayGuiScreen(new GuiMarriageProposal((EntityPlayer) e.target));
    }

}
项目:RacesForMinecraft    文件:EventHandler.java   
@SubscribeEvent
public void playerInteract_Entity(EntityInteractEvent event) {
    if (!this.canRun(event.entityPlayer)) {
        event.setCanceled(true);
    }
    else {
        RacePlayer.get(event.entityPlayer).applyEffectsForItem(
                event.entityPlayer.getHeldItem());
    }
}
项目:CcmBurialServicesInc    文件:EventHandler.java   
/**
 * For catching interactions with the Undertaker
 */
@ForgeSubscribe
public void interactEvent(EntityInteractEvent event)
{
    if (event.target instanceof EntityVillager && ((EntityVillager) event.target).getProfession() == BurialServices.getConfig().villagerID)
    {
        if (FMLCommonHandler.instance().getSide().isServer())
        {
            PacketDispatcher.sendPacketToPlayer(NetworkHelper.makeNBTPacket(BSConstants.CHANNEL_GRAVE_UPGRADE, MiscHelper.getPersistentDataTag(event.entityPlayer, BSConstants.NBT_PLAYER_GRAVE_DATA)), (Player) event.entityPlayer);
        }
        event.setCanceled(MinecraftServer.getServer().isSinglePlayer());
        FMLNetworkHandler.openGui(event.entityPlayer, BurialServices.instance, GuiHandler.undertakerID, event.entityPlayer.worldObj, 0, 0, 0);
    }
}
项目:4Space-1.7    文件:EntityPlayer.java   
public boolean interactWith(Entity p_70998_1_)
{
    if (MinecraftForge.EVENT_BUS.post(new EntityInteractEvent(this, p_70998_1_))) {
        return false;
    }
    ItemStack itemstack = getCurrentEquippedItem();
    ItemStack itemstack1 = itemstack != null ? itemstack.copy() : null;
    if (!p_70998_1_.interactFirst(this))
    {
        if ((itemstack != null) && ((p_70998_1_ instanceof EntityLivingBase)))
        {
            if (this.capabilities.isCreativeMode) {
                itemstack = itemstack1;
            }
            if (itemstack.interactWithEntity(this, (EntityLivingBase)p_70998_1_))
            {
                if ((itemstack.stackSize <= 0) && (!this.capabilities.isCreativeMode)) {
                    destroyCurrentEquippedItem();
                }
                return true;
            }
        }
        return false;
    }
    if ((itemstack != null) && (itemstack == getCurrentEquippedItem())) {
        if ((itemstack.stackSize <= 0) && (!this.capabilities.isCreativeMode)) {
            destroyCurrentEquippedItem();
        } else if ((itemstack.stackSize < itemstack1.stackSize) && (this.capabilities.isCreativeMode)) {
            itemstack.stackSize = itemstack1.stackSize;
        }
    }
    return true;
}
项目:Runes-And-Silver    文件:SilverBowlMilkEvent.java   
@ForgeSubscribe
public void onEntityInteract(EntityInteractEvent event)
{
if (event.entity instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.entity;
if (event.target != null && event.target instanceof EntityCow && player.getHeldItem() != null && player.getHeldItem().itemID == ModItems.RuneBowl.itemID)
{
        if (player.getHeldItem().stackSize-- == 1)
        {
                player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(ModItems.SilverBowlMilk));
        }
}
}
}
项目:AdventureBackpack2    文件:PlayerEventHandler.java   
@SubscribeEvent
public void interactWithCreatures(EntityInteractEvent event)
{
    EntityPlayer player = event.entityPlayer;
    if (!event.entityPlayer.worldObj.isRemote)
    {
        if (Utils.notNullAndInstanceOf(event.target, EntitySpider.class))
        {
            if (Wearing.isWearingTheRightBackpack(player, "Spider"))
            {
                EntityFriendlySpider pet = new EntityFriendlySpider(event.target.worldObj);
                pet.setLocationAndAngles(event.target.posX, event.target.posY, event.target.posZ, event.target.rotationYaw, event.target.rotationPitch);
                event.target.setDead();
                event.entityPlayer.worldObj.spawnEntityInWorld(pet);
                event.entityPlayer.mountEntity(pet);
            }
        }
        if (Utils.notNullAndInstanceOf(event.target, EntityHorse.class))
        {
            ItemStack stack = player.getCurrentEquippedItem();
            EntityHorse horse = (EntityHorse) event.target;
            if (stack != null && stack.getItem() != null && stack.getItem() instanceof ItemNameTag && stack.hasDisplayName())
            {
                if (horse.getCustomNameTag() == null || horse.getCustomNameTag().equals("") && horse.isTame())
                {
                    horse.setTamedBy(player);
                    horse.tasks.addTask(4, new EntityAIHorseFollowOwner(horse, 1.5d, 2.0f, 20.0f));

                    if (horse.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.followRange) != null)
                    {
                        horse.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.followRange).setBaseValue(100.0D);
                        LogHelper.info("The horse follow range is now: " + horse.getEntityAttribute(SharedMonsterAttributes.followRange).getBaseValue());
                    }
                }
            }
        }
    }
    event.setResult(Event.Result.ALLOW);
}
项目:MagicalRings    文件:EntityHandler.java   
@SubscribeEvent
public void onEntityInteract(EntityInteractEvent event) {
    Entity target = event.target;
    EntityPlayer player = event.entityPlayer;
    if (target != null && player != null && Rings.proxy.manaHandler.playerHasSession(player)) {
        ItemStack stack = player.getCurrentEquippedItem();
        if (stack != null && stack.getItem() instanceof ItemMagicRing) {
            if (stack.hasTagCompound()) {
                NBTTagCompound ringTag = SimpleUtil.getRingTag(stack);
                String spellID = SimpleUtil.getSpellIdFromTag(ringTag);
                if (spellID != null && ringTag != null) {
                    ISpell spell = Rings.proxy.spellRegistry.getSpell(spellID);
                    if (spell != null) {
                        int trueCost = -spell.cost() + (ringTag.getInteger(ModLibs.MATERIAL_BOOST) * 5);
                        IPlayerSession session = Rings.proxy.manaHandler.getPlayerSession(player);
                        SpellCastedEvent spellEvent = new SpellCastedEvent(player, spell, session);
                        if (MinecraftForge.EVENT_BUS.post(spellEvent))
                            return;
                        spell.applyToMob(player, session, target, ringTag.getInteger(ModLibs.MATERIAL_BOOST), trueCost);
                        if (FMLCommonHandler.instance().getEffectiveSide().isServer() && !player.capabilities.isCreativeMode)
                            Rings.proxy.manaHandler.updatePlayerSession(session, player.getEntityWorld().provider.dimensionId);
                    }
                }
            }
        }
    }
}
项目:Mankini    文件:BatHandler.java   
@SubscribeEvent
public void BatCapture(EntityInteractEvent event)
{
InventoryPlayer inv = event.entityPlayer.inventory;
ItemStack currentItem = event.entityPlayer.inventory.getCurrentItem();
ItemStack BatMankini = new ItemStack(ModItems.itemBatMankini);
ItemStack Mankini = new ItemStack(ModItems.itemDyeableMankini);
//event.entityPlayer.addChatComponentMessage(new ChatComponentText("Fired event"));
if(event.target instanceof EntityBat && event.entityPlayer.inventory.getCurrentItem().isItemEqual(Mankini) ){
{

    event.target.setDead();
   // Was used to test
//event.entityPlayer.addChatComponentMessage(new ChatComponentText("Detected entity"));
//event.entityPlayer.addChatComponentMessage(new ChatComponentText("Detected item"));
    batCount = batCount+0.5;
    setBatCount();
    //event.entityPlayer.addChatComponentMessage(new ChatComponentText("Current bat count is "+ batCount));
    if(batCount == 5.0F){
        event.entityPlayer.inventory.addItemStackToInventory(BatMankini);
        event.entityPlayer.inventory.consumeInventoryItem(ModItems.itemDyeableMankini);
        batCount = 0F;
    }

}
}
}
项目:SamsPowerups    文件:ModMobChanges.java   
@SubscribeEvent
public void onEntityInteractEvent(EntityInteractEvent event)
    {
    ItemStack held = event.entityPlayer.getCurrentEquippedItem(); 
    /*
    if(held != null && held.getItem() == ItemRegistry.respawn_egg_empty )
    {
        ItemRespawnEggEmpty.entitySpawnEgg(event.entityPlayer, event.target); 
    }*/

    if(ModMobChanges.cfg.canNameVillagers &&  //how to get this all into its own class
      held != null && held.getItem() == Items.name_tag && 
      held.hasDisplayName()  )
    {    
        if(event.target instanceof EntityVillager)
        {

            EntityVillager v = (EntityVillager)event.target;

            v.setCustomNameTag(held.getDisplayName()); 

            if (event.entityPlayer.capabilities.isCreativeMode == false)
            {
                event.entityPlayer.inventory.decrStackSize(event.entityPlayer.inventory.currentItem, 1);
            }

            event.setCanceled(true);//stop the GUI inventory opening 
        } 
    } 
    }
项目:AlchemicalBling    文件:EntityEventHandler.java   
@SubscribeEvent
public void onEntityInteract(EntityInteractEvent event) {
    if (event.target instanceof EntitySpider && !(event.target instanceof EntityCrippledSpider) && !(event.target instanceof EntityCaveSpider)) {
        if (event.entityPlayer.getHeldItem() != null && event.entityPlayer.getHeldItem().getItem() == Items.shears) {
            EntityCrippledSpider.replace((EntitySpider) event.target, event.entityPlayer);
        }
    }
}
项目:RideableCows    文件:CommonProxy.java   
@SubscribeEvent
public void interactWithEntity(EntityInteractEvent event) {
    if (event.target instanceof EntityCow) {
        EntityCow cow = (EntityCow) event.target;
        if (!cow.interactFirst(event.entityPlayer)) {
            ItemStack heldItem = event.entityPlayer.getCurrentEquippedItem();
            if (!RideableCows.getSaddled(cow)) {
                if (!cow.isChild()) {
                    if (heldItem != null && heldItem.getItem() == Items.saddle) {
                        RideableCows.setSaddled(cow, true);
                        cow.worldObj.playSoundAtEntity(cow, "mob.horse.leather", 0.5F, 1.0F);
                        if (!event.entityPlayer.capabilities.isCreativeMode) {
                            --heldItem.stackSize;
                            if (heldItem.stackSize <= 0) event.entityPlayer.destroyCurrentEquippedItem();
                        }
                    }
                }
            } else {
                if (!cow.worldObj.isRemote) {
                    if (cow instanceof EntityMooshroom && heldItem != null && heldItem.getItem() == Items.shears) {
                        EntityItem ent = cow.entityDropItem(new ItemStack(Items.saddle), 1.0F);
                        ent.motionY += cow.getRNG().nextFloat() * 0.05F;
                        ent.motionX += (cow.getRNG().nextFloat() - cow.getRNG().nextFloat()) * 0.1F;
                        ent.motionZ += (cow.getRNG().nextFloat() - cow.getRNG().nextFloat()) * 0.1F;
                    } else if (cow.riddenByEntity == null || cow.riddenByEntity == event.entityPlayer) {
                        event.entityPlayer.mountEntity(cow);
                    }
                }
            }
        }
    }
}
项目:ZeldaSwordSkills    文件:ZSSEntityEvents.java   
/**
 * This event fires on BOTH sides
 */
@SubscribeEvent
public void onInteract(EntityInteractEvent event) {
    ItemStack stack = event.entityPlayer.getHeldItem();
    if (event.target instanceof EntityVillager && Result.DEFAULT != NpcHelper.convertVillager(event.entityPlayer, (EntityVillager) event.target, true)) {
        event.setCanceled(true);
    }
    // Check if the held item has any special interaction upon right-clicking an entity
    if (!event.isCanceled() && stack != null && stack.getItem() instanceof IRightClickEntity) {
        event.setCanceled(((IRightClickEntity) stack.getItem()).onRightClickEntity(stack, event.entityPlayer, event.target));
    }
    // If the event is not yet canceled, check for Mask interactions
    if (!event.isCanceled() && event.target instanceof INpc) {
        ItemStack helm = event.entityPlayer.getCurrentArmor(ArmorIndex.WORN_HELM);
        if (helm != null && helm.getItem() instanceof ItemMask) {
            event.setCanceled(((ItemMask) helm.getItem()).onInteract(helm, event.entityPlayer, event.target));
        }
    }
    // Check for Lon Lon Milk cow interaction
    if (!event.isCanceled() && stack != null && stack.getItem() == Items.glass_bottle && event.target.getClass() == EntityCow.class) {
        event.setCanceled(ZSSPlayerSongs.get(event.entityPlayer).milkLonLonCow(event.entityPlayer, (EntityCow) event.target));
    }
    // Finally, check for interactions with the Cursed Man
    if (!event.isCanceled() && event.target.getClass() == EntityVillager.class && ("Cursed Man").equals(event.target.getCustomNameTag())) {
        EntityVillager villager = (EntityVillager) event.target;
        if (stack == null || (stack.getItem() != ZSSItems.skulltulaToken && stack.getItem() != Items.name_tag)) {
            int tokens = ZSSPlayerInfo.get(event.entityPlayer).getSkulltulaTokens();
            if (villager.worldObj.isRemote) {
                // don't send chat - will be sent from server
            } else if (villager.isChild()) {
                PlayerUtils.sendTranslatedChat(event.entityPlayer, "chat.zss.npc.cursed_man.child");
            } else if (tokens > 0) {
                PlayerUtils.sendTranslatedChat(event.entityPlayer, "chat.zss.npc.cursed_man.amount", tokens);
            } else {
                PlayerUtils.sendTranslatedChat(event.entityPlayer, "chat.zss.npc.cursed_man." + event.entity.worldObj.rand.nextInt(4));
            }
            event.setCanceled(true);
        }
    }
}
项目:CartLivery    文件:CommonProxy.java   
@SubscribeEvent
public void handleMinecartStickerRemove(EntityInteractEvent event) {
    if (event.entityPlayer.worldObj.isRemote) return;

    if (event.entityPlayer.isSneaking() && event.target.getExtendedProperties(CartLivery.EXT_PROP_NAME) != null) {
        ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
        if (stack == null || !(stack.getItem() instanceof ItemCutter)) return;

        CartLivery livery = (CartLivery) event.target.getExtendedProperties(CartLivery.EXT_PROP_NAME);
        livery.pattern = "";

        CommonProxy.network.sendToAllAround(new LiveryUpdateMessage(event.target, livery), NetworkUtil.targetEntity(event.target));
        event.setCanceled(true);
    }
}
项目:Photoreal    文件:EventHandler.java   
@SubscribeEvent
public void onInteract(EntityInteractEvent event)
{
       if(holdingCamera(event.entityPlayer))
    {
        event.setCanceled(true);
    }
}
项目:Xth-uoth    文件:EntityHandler.java   
/**
 * This event allows the player to also destroy a rift while wielding the veil shears
 */
@SubscribeEvent
public void onEntityInteract(EntityInteractEvent e) {
    if (e.entityPlayer.getCurrentEquippedItem() == null) return;

    if (e.entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemVeilShears && e.target instanceof EntityRift) {
        e.target.setDead();
    }
}
项目:Xth-uoth    文件:EntityHandler.java   
/**
 * This event allows the player to also destroy a rift while wielding the veil shears
 */
@SubscribeEvent
public void onEntityInteract(EntityInteractEvent e) {
    if (e.entityPlayer.getCurrentEquippedItem() == null) return;

    if (e.entityPlayer.getCurrentEquippedItem().getItem() instanceof ItemVeilShears && e.target instanceof EntityRift) {
        e.target.setDead();
    }
}
项目:Factorization    文件:ClickHandler.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void rightClick(EntityInteractEvent event) {
    handle(event, event.target, true);
}
项目:Skills    文件:EventHandler.java   
@SubscribeEvent
public void onInteractWitEntity(EntityInteractEvent event)
{

}
项目:MineFantasy    文件:PlayerEventChild.java   
public OffhandAttackEvent(EntityInteractEvent parent, ItemStack mainHand, ItemStack offHand) {
    super(parent);
    this.event = parent;
    this.mainHand = mainHand;
    this.offHand = offHand;
}
项目:rpginventory    文件:RPGEventHooks.java   
@SubscribeEvent
public void entityInteract(EntityInteractEvent evt){
    if(PlayerRpgInventory.get(evt.entityPlayer).getShield() != null && evt.entityPlayer.isSneaking())
        evt.setResult(Result.DENY);
}
项目:Quantum-Anomalies    文件:DiscoveryListener.java   
@SubscribeEvent
public void interact(EntityInteractEvent event) {
    ItemStack stack = event.entityPlayer.getHeldItem();
    if (isServer() && stack != null && stack.getItem() == Items.name_tag)
        DiscoveryManager.unlockItem(QADiscoveries.Item.PENCIL.get().getKey(), (EntityPlayer) event.entityLiving, false);
}
项目:Cauldron    文件:EntityPlayer.java   
public boolean interactWith(Entity p_70998_1_)
{
    if (MinecraftForge.EVENT_BUS.post(new EntityInteractEvent(this, p_70998_1_))) return false;
    ItemStack itemstack = this.getCurrentEquippedItem();
    ItemStack itemstack1 = itemstack != null ? itemstack.copy() : null;

    if (!p_70998_1_.interactFirst(this))
    {
        if (itemstack != null && p_70998_1_ instanceof EntityLivingBase)
        {
            if (this.capabilities.isCreativeMode)
            {
                itemstack = itemstack1;
            }

            if (itemstack.interactWithEntity(this, (EntityLivingBase)p_70998_1_))
            {
                // CraftBukkit - bypass infinite items; <= 0 -> == 0
                if (itemstack.stackSize == 0 && !this.capabilities.isCreativeMode)
                {
                    this.destroyCurrentEquippedItem();
                }

                return true;
            }
        }

        return false;
    }
    else
    {
        if (itemstack != null && itemstack == this.getCurrentEquippedItem())
        {
            if (itemstack.stackSize <= 0 && !this.capabilities.isCreativeMode)
            {
                this.destroyCurrentEquippedItem();
            }
            else if (itemstack.stackSize < itemstack1.stackSize && this.capabilities.isCreativeMode)
            {
                itemstack.stackSize = itemstack1.stackSize;
            }
        }

        return true;
    }
}
项目:Cauldron    文件:EntityPlayer.java   
public boolean interactWith(Entity p_70998_1_)
{
    if (MinecraftForge.EVENT_BUS.post(new EntityInteractEvent(this, p_70998_1_))) return false;
    ItemStack itemstack = this.getCurrentEquippedItem();
    ItemStack itemstack1 = itemstack != null ? itemstack.copy() : null;

    if (!p_70998_1_.interactFirst(this))
    {
        if (itemstack != null && p_70998_1_ instanceof EntityLivingBase)
        {
            if (this.capabilities.isCreativeMode)
            {
                itemstack = itemstack1;
            }

            if (itemstack.interactWithEntity(this, (EntityLivingBase)p_70998_1_))
            {
                if (itemstack.stackSize <= 0 && !this.capabilities.isCreativeMode)
                {
                    this.destroyCurrentEquippedItem();
                }

                return true;
            }
        }

        return false;
    }
    else
    {
        if (itemstack != null && itemstack == this.getCurrentEquippedItem())
        {
            if (itemstack.stackSize <= 0 && !this.capabilities.isCreativeMode)
            {
                this.destroyCurrentEquippedItem();
            }
            else if (itemstack.stackSize < itemstack1.stackSize && this.capabilities.isCreativeMode)
            {
                itemstack.stackSize = itemstack1.stackSize;
            }
        }

        return true;
    }
}
项目:RuneCraftery    文件:EntityPlayer.java   
public boolean interactWith(Entity par1Entity)
{
    if (MinecraftForge.EVENT_BUS.post(new EntityInteractEvent(this, par1Entity))) return false;
    ItemStack itemstack = this.getCurrentEquippedItem();
    ItemStack itemstack1 = itemstack != null ? itemstack.copy() : null;

    if (!par1Entity.interactFirst(this))
    {
        if (itemstack != null && par1Entity instanceof EntityLivingBase)
        {
            if (this.capabilities.isCreativeMode)
            {
                itemstack = itemstack1;
            }

            if (itemstack.func_111282_a(this, (EntityLivingBase)par1Entity))
            {
                if (itemstack.stackSize <= 0 && !this.capabilities.isCreativeMode)
                {
                    this.destroyCurrentEquippedItem();
                }

                return true;
            }
        }

        return false;
    }
    else
    {
        if (itemstack != null && itemstack == this.getCurrentEquippedItem())
        {
            if (itemstack.stackSize <= 0 && !this.capabilities.isCreativeMode)
            {
                this.destroyCurrentEquippedItem();
            }
            else if (itemstack.stackSize < itemstack1.stackSize && this.capabilities.isCreativeMode)
            {
                itemstack.stackSize = itemstack1.stackSize;
            }
        }

        return true;
    }
}
项目:BetterNutritionMod    文件:EntityPlayer.java   
public boolean interactWith(Entity par1Entity)
{
    if (MinecraftForge.EVENT_BUS.post(new EntityInteractEvent(this, par1Entity))) return false;
    ItemStack itemstack = this.getCurrentEquippedItem();
    ItemStack itemstack1 = itemstack != null ? itemstack.copy() : null;

    if (!par1Entity.interactFirst(this))
    {
        if (itemstack != null && par1Entity instanceof EntityLivingBase)
        {
            if (this.capabilities.isCreativeMode)
            {
                itemstack = itemstack1;
            }

            if (itemstack.func_111282_a(this, (EntityLivingBase)par1Entity))
            {
                if (itemstack.stackSize <= 0 && !this.capabilities.isCreativeMode)
                {
                    this.destroyCurrentEquippedItem();
                }

                return true;
            }
        }

        return false;
    }
    else
    {
        if (itemstack != null && itemstack == this.getCurrentEquippedItem())
        {
            if (itemstack.stackSize <= 0 && !this.capabilities.isCreativeMode)
            {
                this.destroyCurrentEquippedItem();
            }
            else if (itemstack.stackSize < itemstack1.stackSize && this.capabilities.isCreativeMode)
            {
                itemstack.stackSize = itemstack1.stackSize;
            }
        }

        return true;
    }
}
项目:MineDonate    文件:EntitySelectEventHandler.java   
@SideOnly ( Side . SERVER )
@SubscribeEvent ( priority = EventPriority . NORMAL )
public void onEntityInteractEvent ( EntityInteractEvent e ) {

    if ( e . entityPlayer instanceof EntityPlayerMP ) {

        Account acc = MineDonate . getAccountFromCache ( e . entityPlayer ) ;

        if ( acc != null ) {

            if ( acc . manageSession . mobSelect ) {

                if ( ! ( e . target instanceof EntityLivingBase ) ) {

                    e . entityPlayer.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "Error add entity! EntityLivingBase check error!"));

                    ModNetworkRegistry . sendToManageResponsePacket ( ( EntityPlayerMP ) e . entityPlayer, ResponseType . ENTITY, ResponseCode . SELECT, ResponseStatus . ERROR_ENTITY_CHECK_LIVINGBASE ) ;

                } else {

                try {

                    Class . forName ( e . target . getClass ( ) . getName ( ) ) . getDeclaredConstructor ( net . minecraft . world . World . class ) . newInstance ( e . entityPlayer . getEntityWorld ( ) ) ;

                } catch ( Exception ex ) {

                    ModNetworkRegistry . sendToManageResponsePacket ( ( EntityPlayerMP ) e . entityPlayer, ResponseType . ENTITY, ResponseCode . SELECT, ResponseStatus . ERROR_ENTITY_CHECK_INIT ) ;

                    e . setCanceled ( true ) ;
                     acc .manageSession . setMobSelect ( false ) ;

                    return;

                } 

                acc .manageSession . setCurrentMob ( e . target ) ;

                ModNetworkRegistry . sendToManageResponsePacket ( ( EntityPlayerMP ) e . entityPlayer, ResponseType . ENTITY, ResponseCode . SELECT, ResponseStatus . OK ) ;

                ModNetworkRegistry . sendToMobSelectPacket ( ( EntityPlayerMP ) e . entityPlayer, 1 ) ;

                }

                e . setCanceled ( true ) ;
                acc .manageSession . setMobSelect ( false ) ;

                ModNetworkRegistry . sendToManageResponsePacket ( ( EntityPlayerMP ) e . entityPlayer, ResponseType . ENTITY, ResponseCode . ADD, ResponseStatus . ENTITY_SELECT_STOP ) ;

            }

        }

    }

}