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

I understand how to make the mob drops 0-2 dropping only 1 out of 2 and sometimes nothing, but how would I increase that number to say 10? 1-10 and only 1 out of 10 items? This is what I have now.

 

    protected void dropFewItems(boolean par1, int par2)

    {

        int random = this.rand.nextInt(4) + this.rand.nextInt(1 + par2);

       

for (int k = 0; k < random; ++k)

        {

 

        if(k == 2){

       

            this.dropItem(PhantasyRealmsItems.blade, 1);

            }

       

        else

       

        if (k == 1){

       

        this.dropItem(PhantasyRealmsItems.brand, 1);

        }

  • Author

Well, just change how you calculate the number. Random.nextInt(n) gives you a number between 0 (inclusive) and n (exclusive).

So Random.nextInt(3) gives you 0, 1 or 2. Then just use math to get to the range you want.

 

yes but when I try to add on to this

      for (int k = 0; k < random; ++k)

        {

       

        if(k == 2){

         

              this.dropItem(PhantasyRealmsItems.blade, 1);

            }

       

        else

         

        if (k == 1){

         

          this.dropItem(PhantasyRealmsItems.brand, 1);

        }

 

        else

         

        if (k == 3){

         

          this.dropItem(PhantasyRealmsItems.brand, 1);

        }

 

and so on it just makes killing the mob  drop both items after the first else.. I dont know Im at a loss for what to do after setting Random.nextInt(n) to a higher number.

  • Author

Well, you used a 'for' loop, so if random is 3, you will drop both items '1' and '2'. Perhaps Java tutorials are in order?

 

Fair enough and perhaps though an answer would be nice too.

  • Author

So you have 10 possible drops. You want to drop only 1 of those at every given time and then 1-10 of that selected Item?

 

yes

  • Author

First select the drop type, it's a number from 0-9 (10 possible types):

int dropType = rand.nextInt(10);

 

Then select how many of that Item to drop (1-10):

int dropAmount = 1 + rand.nextInt(10);

 

Then switch on the drop type and drop the selected amount of it. This is not hard.

 

No sorry, I read your comment wrong, there are 10 possible Items a mob can drop, each time a mob is killed 1 out of those 10 items is dropped.

  • Author

Then just remove the drop amount part. Just select the drop type and drop it...

Thanks, I know it may seem basic to you guys but I learn by trial and error and by actually testing with things not just reading about them, and I appreciate you helping me out. Thank you

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.