Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello MCF forums,

I would like to know how i would go about making a bow that fires multiple arrows but off-set from where the normal bow spawns its arrow. I have tried(i know that what i tried was most likely a nooby way to try to do it but i tried and its the effort that counts xD): 'if (!par2World.isRemote) {

            par2World.spawnEntityInWorld(entityarrow);

            par2World.spawnEntityInWorld(entityarrow) + 2;' in my onPlayerStopUsing method but it gives me any error.

 

Thank you,

Drok

You know how you create the EntityArrow in the first place?

EntityArrow arrow = new EntityArrow(world, player, charge);

Well, once you've done that and before you spawn it into the world, you can alter the arrow.posX, arrow.posY, arrow.posZ slightly. Create two (or more) arrow entities, leave the first one unchanged, and change the others as you need. You might want to look into the player's lookVector or you will find your arrows look right only in one direction.

  • Author

Ok cool i got it to work.  Thank you for you help collAlias. Here is what i used for anyone that needs it.


public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
    {
        int j = this.getMaxItemUseDuration(par1ItemStack) - par4;

        ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, j);
        MinecraftForge.EVENT_BUS.post(event);
        if (event.isCanceled())
        {
            return;
        }
        j = event.charge;

        boolean flag = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;

        if (flag || par3EntityPlayer.inventory.hasItem(Items.arrow))
        {
            float f = (float)j / 20.0F;
            f = (f * f + f * 2.0F) / 3.0F;

            if ((double)f < 0.1D) {
                return;
            }

            if (f > 1.0F) {
                f = 10.0F;
            }

            EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F);
            EntityArrow entityarrow1 = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F);
            EntityArrow entityarrow2 = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F);
            
            double pos1x = entityarrow1.posX + 0D;
            double pos1y = entityarrow1.posY + 1D;
            double pos1z = entityarrow1.posZ + 0D;
            
            entityarrow1.setPosition(pos1x, pos1y, pos1z);

            if (f == 1.0F) {
            	entityarrow.setIsCritical(true);
            	entityarrow1.setIsCritical(true);
            	entityarrow2.setIsCritical(true);
            }

            par1ItemStack.damageItem(1, par3EntityPlayer);
            par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);

            if (flag)  {
            	entityarrow.canBePickedUp = 2;
                
            }
            else {
                par3EntityPlayer.inventory.consumeInventoryItem(Items.arrow);
            }

            if (!par2World.isRemote) {
            	par2World.spawnEntityInWorld(entityarrow);
            	par2World.spawnEntityInWorld(entityarrow1);
            	par2World.spawnEntityInWorld(entityarrow2);
            	
            }
        }
    }

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.