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

Is there any way to change the quantity/products of how/what a mob/block drops, with pre-existing mobs and blocks.

 

I figured out a way with my own created blocks, I know I could just re-create every block in minecraft with my own, and then just generate those instead of the ones used in minecraft. but I just wanted to check.

 

I feel like there could just be a simple way with object oriented programming, or (my brain thinks I would have to do what I stated in my second comment)

  • Author

Cool, that worked, when using the HarvestDropsEvent feature, now I have a new question, I am having an issue trying to make the drops either call twice.

 

I want some blocks to drop with the normal block that drops with it, plus a special block or chance. But what seems to be happening is that every item in the ItemStack gets the same drop chance.

 

For example,

I would want Stone to drop cobblestone with 100% and then a 10% chance for like normal stone to drop along with the cobblestone, (or however many different items with different chances I want).

 

I spent awhile on this code, even recreating the BlockEvent class (which may still be the route I need to go) but I still cannot get it to work.

Hi

 

I reckon you can probably do the extra drop in your harvest event

 

eg something like

 

public void myHarvestDropsEventHandler(HarvestDropsEvent event) {

  if  (10% chance of special drop succeeded) then {
                float f = 0.7F;
            double d0 = (double)(par1World.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
            double d1 = (double)(par1World.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
            double d2 = (double)(par1World.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
            EntityItem entityitem = new EntityItem(par1World, (double)x + d0, (double)y + d1, (double)z + d2, mySpecialDropItemStack);
            entityitem.delayBeforeCanPickup = 10;
            par1World.spawnEntityInWorld(entityitem);
  }  
  // code copied from Block.dropBlockAsItem_do

}

 

Haven't ever tried it but I think it will probably work with a bit of tweaking. 

 

-TGG

  • Author

Well I was just being dumb. I could have used the same code I had from my block class when creating the same idea.

 

 

If anyone wants code that does this:

 

if(block.blockID == Block.stone.blockID){
                                            event.drops.clear();
                                            event.drops.add(new ItemStack(Block.cobblestone, random.nextInt(2) + 1));
                                            
                                            if(random.nextInt(10) == 0){
                                            	event.drops.add(new ItemStack(Block.stone,1));
                                            }
                                            event.dropChance = 1.0F;
                                	}

 

I woke up this morning just thinking... why didn't you just do that lol.

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.