Jump to content

Recommended Posts

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)

Posted

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.

Posted

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

Posted

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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