@SubscribeEvent public void arrowNock(ArrowNockEvent event) { if (event.result == null) return; IInventory invt = event.entityPlayer.inventory; for (int i = 0; i < invt.getSizeInventory(); i++) { ItemStack stack = invt.getStackInSlot(i); if (stack == null || stack.stackSize <= 0) continue; if (stack.getItem() == Items.arrow) return; if (stack.getItem() == ModItems.tipped_arrow) { event.setCanceled(true); event.entityPlayer.setItemInUse(event.result, event.result.getItem().getMaxItemUseDuration(event.result)); return; } } }
@SubscribeEvent public void handleNock(ArrowNockEvent event){ if(event.getEntityPlayer() !=null){ ExtendedPlayer exPlayer = ExtendedPlayerProvider.getExtendedPlayer(event.getEntityPlayer()); if(exPlayer !=null){ ExtendedPlayerInventory inv = exPlayer.getInventory(); ItemStack backpack = inv.getStackInSlot(ExtendedPlayerInventory.BACKPACK_SLOT_ID); if(ItemStackTools.isValid(backpack)){ InventoryBackpackUpgrades upgrades = BackpackUtil.getUpgradeInventory(event.getEntityPlayer(), backpack); if(upgrades !=null && upgrades.hasUpgrade(BackpackUpgrade.BOW)){ InventoryBackpack backpackInv = BackpackUtil.getInventory(event.getEntityPlayer(), backpack); if(backpackInv !=null){ for(int i = 0; i < backpackInv.getSize(); i++){ ItemStack st = backpackInv.getStackInSlot(i); if(ItemStackTools.isValid(st) && st.getItem() instanceof ItemArrow){ event.getEntityPlayer().setActiveHand(event.getHand()); event.setAction(new ActionResult<ItemStack>(EnumActionResult.SUCCESS, event.getBow())); return; } } } } } } } }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { ArrowNockEvent event = new ArrowNockEvent(p_77659_3_, p_77659_1_); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (p_77659_3_.capabilities.isCreativeMode || p_77659_3_.inventory.hasItem(ItemLoader.itemPatArrow)) { p_77659_3_.setItemInUse(p_77659_1_, this.getMaxItemUseDuration(p_77659_1_)); } return p_77659_1_; }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { ArrowNockEvent event = new ArrowNockEvent(p_77659_3_, p_77659_1_); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (p_77659_3_.capabilities.isCreativeMode || p_77659_3_.inventory.hasItem(ItemLoader.itemJenArrow)) { p_77659_3_.setItemInUse(p_77659_1_, this.getMaxItemUseDuration(p_77659_1_)); } return p_77659_1_; }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { ArrowNockEvent event = new ArrowNockEvent(p_77659_3_, p_77659_1_); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (p_77659_3_.capabilities.isCreativeMode || p_77659_3_.inventory.hasItem(Items.arrow)) { p_77659_3_.setItemInUse(p_77659_1_, this.getMaxItemUseDuration(p_77659_1_)); } return p_77659_1_; }
@Override public ItemStack onItemRightClick( ItemStack stack, World world, EntityPlayer player ) { ArrowNockEvent event = new ArrowNockEvent( player, stack ); MinecraftForge.EVENT_BUS.post( event ); if ( event.isCanceled() ) { return event.result; } // TODO: Custom arrows if ( getActiveArrow( player ) != null ) { player.setItemInUse( stack, this.getMaxItemUseDuration( stack ) ); } return stack; }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player) { ArrowNockEvent event = new ArrowNockEvent(player, item); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (player.capabilities.isCreativeMode || player.inventory.hasItem(Item.arrow.itemID)) { player.setItemInUse(item, this.getMaxItemUseDuration(item)); } return item; }
@Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(IlluminatedItems.illuminatedArrow)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || !par3EntityPlayer.capabilities.isCreativeMode) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.FireCastingPowder.itemID)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Item.arrow.itemID)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.WaterCastingPowder.itemID)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; }
@Override /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Main.flare)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Main.blowGunDart)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Items.arrow)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; }
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) { ArrowNockEvent event = new ArrowNockEvent(p_77659_3_, p_77659_1_); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (p_77659_3_.capabilities.isCreativeMode || p_77659_3_.inventory.hasItem(Items.arrow)) { p_77659_3_.setItemInUse(p_77659_1_, this.getMaxItemUseDuration(p_77659_1_)); } return p_77659_1_; }
@Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { ArrowNockEvent event = new ArrowNockEvent(player, stack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } // This can only be reached if BG2 is not installed or no arrow was found in the quiver if (nockArrowFromInventory(stack, player)) { int duration = getMaxItemUseDuration(stack); if (ZSSMain.isBG2Enabled) { duration -= (EnchantmentHelper.getEnchantmentLevel(BaseEnchantment.bowCharge.get().effectId, stack) * 20000); } player.setItemInUse(stack, duration); } return stack; }
@Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { ArrowNockEvent event = new ArrowNockEvent(player, stack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (player.capabilities.isCreativeMode || player.inventory.hasItem(ammo)) { player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); } return stack; }
@Override public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { ArrowNockEvent event = new ArrowNockEvent(player, itemStack); MinecraftForge.EVENT_BUS.post(event); if(event.isCanceled()) { return event.result; } if(player.capabilities.isCreativeMode || player.inventory.hasItem(Items.arrow)) { player.setItemInUse(itemStack, this.getMaxItemUseDuration(itemStack)); } return itemStack; }
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory .hasItem(EACommonProxy.itemEnderArrow)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; }
@SubscribeEvent public void onBowUse(ArrowNockEvent event){ // change to use Result: DENY (cannot fire), DEFAULT (attempt standard nocking algorithm), ALLOW (nock without further checks) Result canDrawBow = Result.DEFAULT; // insert special bow check here: if (event.getBow().getItem() instanceof ISpecialBow) { canDrawBow = ((ISpecialBow) event.getBow().getItem()).canDrawBow(event.getBow(), event.getEntityPlayer()); } // Special bow did not determine a result, so use standard algorithms instead: if (canDrawBow == Result.DEFAULT && (event.hasAmmo() || event.getEntityPlayer().capabilities.isCreativeMode)) { canDrawBow = Result.ALLOW; } if (canDrawBow == Result.DEFAULT) { ItemStack quiver = QuiverArrowRegistry.getArrowContainer(event.getBow(), event.getEntityPlayer()); if (!quiver.isEmpty() && ((IArrowContainer2)quiver.getItem()). hasArrowFor(quiver, event.getBow(), event.getEntityPlayer(), ((IArrowContainer2) quiver.getItem()).getSelectedSlot(quiver))) { canDrawBow = Result.ALLOW; } } // only nock if allowed if (canDrawBow == Result.ALLOW) { event.getEntityPlayer().setActiveHand(event.getHand()); event.setAction(ActionResult.newResult(EnumActionResult.SUCCESS, event.getBow())); } }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.bonespear)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; }
/** * Called whenever this item is equipped and the right mouse button is * pressed. Args: itemStack, world, entityPlayer */ @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) return event.result; if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.fan)) par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); par3EntityPlayer.setItemInUse(par1ItemStack, 72000000); return par1ItemStack; }
/** * Called whenever this item is equipped and the right mouse button is * pressed. Args: itemStack, world, entityPlayer */ @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) return event.result; if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.energyField)) par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); par3EntityPlayer.setItemInUse(par1ItemStack, 72000000); return par1ItemStack; }
/** * Called whenever this item is equipped and the right mouse button is * pressed. Args: itemStack, world, entityPlayer */ @Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) return event.result; if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(ModItems.glove)) par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); par3EntityPlayer.setItemInUse(par1ItemStack, 72000000); return par1ItemStack; }
/** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } boolean flag1 = par3EntityPlayer.inventory.hasItem(Item.snowball.itemID) && par3EntityPlayer.inventory.hasItem(WinterWarMain.chooserSnowball.itemID); boolean flag2 = par3EntityPlayer.inventory.hasItem(WinterWarMain.iceBall.itemID) && par3EntityPlayer.inventory.hasItem(WinterWarMain.chooserIceball.itemID); boolean flag3 = par3EntityPlayer.inventory.hasItem(WinterWarMain.rockySnowBall.itemID) && par3EntityPlayer.inventory.hasItem(WinterWarMain.chooserRockySnowball.itemID); boolean flag4 = par3EntityPlayer.inventory.hasItem(WinterWarMain.explodingSnowBall.itemID) && par3EntityPlayer.inventory.hasItem(WinterWarMain.chooserExplodingSnowball.itemID); boolean flag5 = par3EntityPlayer.inventory.hasItem(Item.potato.itemID) && par3EntityPlayer.inventory.hasItem(WinterWarMain.chooserPotato.itemID); if (par3EntityPlayer.capabilities.isCreativeMode || flag1 || flag2 || flag3 || flag4 || flag5); { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; }
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Weapons.rocket1.itemID)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); par3EntityPlayer.inventory.consumeInventoryItem(Weapons.rocket1.itemID); } par2World.playSoundAtEntity(par3EntityPlayer, "random.click", 1.0F, 2); return par1ItemStack; }
@SubscribeEvent public void onArrowNock(ArrowNockEvent evt) { if (evt.getEntityPlayer() != null && !evt.getEntityPlayer().isCreative() && evt.getHand() == EnumHand.MAIN_HAND) { // Needs to check for mainhand due to how the event works CapabilityDivination cap = evt.getEntityPlayer().getCapability(CapabilityDivination.CAPABILITY, null); if (cap.getFortune() == this && cap.isActive()) { if (evt.getEntityPlayer().dropItem(true) != null) { cap.setRemovable(); } } } }
@Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { ArrowNockEvent event = new ArrowNockEvent(player, stack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (player.capabilities.isCreativeMode || player.inventory.hasItemStack( new ItemStack(Items.arrow) ) ) { player.setItemInUse(stack, this.getMaxItemUseDuration(stack)); this.playerName = player.getDisplayName(); // Recording the player name here, so only they can see the projectile } return stack; }