@Override public float getCharge(){ MinecraftForge.EVENT_BUS.post(this); switch (this.getResult()){ case ALLOW: return charge; case DENY: return 0; } return ItemBow.getArrowVelocity((int)super.getCharge()); }
@Override public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entity, int chargeTimer) { if (entity instanceof EntityPlayer == false) { return; } EntityPlayer player = (EntityPlayer) entity; int charge = this.getMaxItemUseDuration(stack) - chargeTimer; float percentageCharged = ItemBow.getArrowVelocity(charge);//never zero, its from [0.03,1]; float amountCharged = percentageCharged * MAX_CHARGE; float velocityFactor = percentageCharged * 1.5F;//flat upscale float damage = MathHelper.floor(amountCharged) / 2;//so its an even 3 or 2.5 EntityBoomerang projectile = (EntityBoomerang) shootMain(world, player, velocityFactor, damage); UtilItemStack.damageItem(player, stack); projectile.setBoomerangThrown(stack.copy()); player.setHeldItem(EnumHand.MAIN_HAND, ItemStack.EMPTY); }
@Override public void onPlayerStoppedUsing(ItemStack stack, World world, EntityLivingBase entity, int chargeTimer) { // if (entity.onGround == false) { return; } if (entity instanceof EntityPlayer == false) { return; } EntityPlayer player = (EntityPlayer) entity; if (player.getCooldownTracker().hasCooldown(stack.getItem())) { return; } int charge = this.getMaxItemUseDuration(stack) - chargeTimer; //bow konws how to say , how charged up am i, ok heres your power float power = Math.min(MAX_POWER, ItemBow.getArrowVelocity(charge) * POWER_UPSCALE); Vec3d vec = player.getLookVec().normalize(); int rev = (ActionType.isForward(stack)) ? 1 : -1; power *= rev;//flip it the other way if we are going backwards player.addVelocity(vec.x * power, vec.y * power / VERTICAL_FACTOR, vec.z * power); player.addPotionEffect(new PotionEffect(PotionEffectRegistry.BOUNCE, POTION_TIME, 0)); UtilSound.playSound(player, player.getPosition(), SoundRegistry.machine_launch, SoundCategory.PLAYERS); player.getCooldownTracker().setCooldown(stack.getItem(), COOLDOWN); super.onUse(stack, player, world, EnumHand.MAIN_HAND); }
@SubscribeEvent public void onPlayerUpdate(ArrowLooseEvent event) { ItemStack stackBow = event.getBow(); int level = this.getCurrentLevelTool(stackBow); if (level <= 0) { return; } EntityPlayer player = event.getEntityPlayer(); World worldIn = player.world; if (worldIn.isRemote == false) { float charge = ItemBow.getArrowVelocity(stackBow.getMaxItemUseDuration() - event.getCharge()); //use cross product to push arrows out to left and right Vec3d playerDirection = UtilEntity.lookVector(player.rotationYaw, player.rotationPitch); Vec3d left = playerDirection.crossProduct(new Vec3d(0, 1, 0)); Vec3d right = playerDirection.crossProduct(new Vec3d(0, -1, 0)); spawnArrow(worldIn, player, stackBow, charge, left.normalize()); spawnArrow(worldIn, player, stackBow, charge, right.normalize()); } }
this.entity.attackEntityWithRangedAttack(entitylivingbase, ItemBow.getArrowVelocity(i)); this.attackTime = this.attackCooldown;
float percentageCharged = ItemBow.getArrowVelocity(charge);//never zero, its from [0.03,1]; float amountCharged = percentageCharged * MAX_CHARGE; float velocityFactor = percentageCharged * 1.5F;//flat upscale
archer.attackEntityWithRangedAttack(entitylivingbase, ItemBow.getArrowVelocity(i)); attackTime = attackCooldown;
float percentageCharged = ItemBow.getArrowVelocity(charge);//never zero, its from [0.03,1]; float amountCharged = percentageCharged * MAX_CHARGE; float velocityFactor = percentageCharged * 1.5F;//flat upscale
arrowStack = new ItemStack(Items.ARROW); float f = ItemBow.getArrowVelocity(event.getCharge()); float speedMod = 1.0F;