net.minecraftforge.event.entity.player.ArrowLooseEvent Java Examples
The following examples show how to use
net.minecraftforge.event.entity.player.ArrowLooseEvent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EventBarrage.java From Levels with GNU General Public License v2.0 | 6 votes |
@SuppressWarnings("static-access") @SubscribeEvent public void onBowFire(ArrowLooseEvent event) { EntityPlayer player = event.getEntityPlayer(); ItemStack stack = event.getBow(); NBTTagCompound nbt = NBTHelper.loadStackNBT(stack); if (player != null && stack != null && nbt != null && !player.getEntityWorld().isRemote) { if (BowAttribute.BARRAGE.hasAttribute(nbt)) { for (int i = 0; i < (int) BowAttribute.BARRAGE.getCalculatedValue(nbt, 3, 1.5); i++) { EntityArrow entityarrow = new EntityTippedArrow(player.getEntityWorld(), player); entityarrow.setAim(player, player.rotationPitch, player.rotationYaw, 0, ((ItemBow) event.getBow().getItem()).getArrowVelocity(event.getCharge()) * 3, 20F); entityarrow.pickupStatus = PickupStatus.DISALLOWED; player.getEntityWorld().spawnEntity(entityarrow); } } } }
Example #2
Source File: PotionCannon.java From Sakura_mod with MIT License | 5 votes |
@SubscribeEvent public void onAttacking(ArrowLooseEvent event) { EntityPlayer player = event.getEntityPlayer(); if(player.isPotionActive(this)){ event.setCharge(event.getCharge()+player.getActivePotionEffect(this).getAmplifier()*25); event.setResult(Result.ALLOW); } }
Example #3
Source File: ServerEventHandler.java From Et-Futurum with The Unlicense | 4 votes |
@SubscribeEvent public void arrowLoose(ArrowLooseEvent event) { if (event.bow == null) return; IInventory invt = event.entityPlayer.inventory; for (int i = 0; i < invt.getSizeInventory(); i++) { ItemStack arrow = invt.getStackInSlot(i); if (arrow != null && arrow.stackSize > 0 && arrow.getItem() == ModItems.tipped_arrow) { float charge = event.charge / 20.0F; charge = (charge * charge + charge * 2.0F) / 3.0F; if (charge < 0.1D) return; if (charge > 1.0F) charge = 1.0F; EntityTippedArrow arrowEntity = new EntityTippedArrow(event.entityPlayer.worldObj, event.entityPlayer, charge * 2.0F); arrowEntity.setEffect(TippedArrow.getEffect(arrow)); if (charge == 1.0F) arrowEntity.setIsCritical(true); int power = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, event.bow); if (power > 0) arrowEntity.setDamage(arrowEntity.getDamage() + power * 0.5D + 0.5D); int punch = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, event.bow); if (punch > 0) arrowEntity.setKnockbackStrength(punch); if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, event.bow) > 0) arrowEntity.setFire(100); event.bow.damageItem(1, event.entityPlayer); event.entityPlayer.worldObj.playSoundAtEntity(event.entityPlayer, "random.bow", 1.0F, 1.0F / (event.entityPlayer.worldObj.rand.nextFloat() * 0.4F + 1.2F) + charge * 0.5F); if (!event.entityPlayer.capabilities.isCreativeMode && --arrow.stackSize <= 0) event.entityPlayer.inventory.setInventorySlotContents(i, null); if (!event.entityPlayer.worldObj.isRemote) event.entityPlayer.worldObj.spawnEntityInWorld(arrowEntity); event.setCanceled(true); return; } } }