Jump to content

[1.8] make zombie drops custom seeds<SOLVED>


perromercenary00

Recommended Posts

good nigths

i wanna make the zoombies drop mi custom seeds when dieded but it seems its dont wants to work

reading some guides i reach to this two methods but eithers works

 

  @EventHandler
    public void onEntityDrop(LivingDropsEvent event){
	  
	  
	  System.out.println("\nLivingDropsEvent");
	  
	if(event.entity instanceof EntityZombie){

		EntityZombie zom = (EntityZombie) event.entity;

		  int R = ((int) (Math.random() * 3)) ;
		  
		  Item tudrop = null;
		  
		  switch (R)
		  {
		  case 0: tudrop = MercenaryModItems.hierbaVerdeSemilla;
		  case 1: tudrop = MercenaryModItems.hierbaRojaSemilla;
		  case 2: tudrop = MercenaryModItems.hierbaAmarillaSemilla;
		  case 3: tudrop = MercenaryModItems.hierbaAzulSemilla;
		  }
		  
		  BlockPos bzom = zom.getPosition().add(0,1,0);
		  World bworld = zom.getEntityWorld();
		  
		  bworld.spawnEntityInWorld(new EntityItem(bworld, bzom.getX(), bzom.getY(), bzom.getZ(), new ItemStack(tudrop ,1,0)));

	}

	} 



  @EventHandler
    public void onEDeath(LivingDeathEvent   event)
    {
	  
	  System.out.println("\nLivingDeathEvent");
        //drops the item

	  if (event.entity instanceof EntityZombie) {
		  
		  EntityZombie zom = (EntityZombie) event.entity;
		  
		  System.out.println("\nZOMMMBIE");

		  int R = ((int) (Math.random() * 3)) ;
		  
		  Item tudrop = null;
		  
		  switch (R)
		  {
		  case 0: tudrop = MercenaryModItems.hierbaVerdeSemilla;
		  case 1: tudrop = MercenaryModItems.hierbaRojaSemilla;
		  case 2: tudrop = MercenaryModItems.hierbaAmarillaSemilla;
		  case 3: tudrop = MercenaryModItems.hierbaAzulSemilla;
		  }
		  
		  BlockPos bzom = zom.getPosition().add(0,1,0);
		  World bworld = zom.getEntityWorld();
		  
		  bworld.spawnEntityInWorld(new EntityItem(bworld, bzom.getX(), bzom.getY(), bzom.getZ(), new ItemStack(tudrop ,1,0)));

		   
	  }
	   

    }

 

some one can point wath i been doing wrong

 

thanks for reading

Link to comment
Share on other sites

eee

 

upss

 

Fixed

// Zombie drops
@SubscribeEvent
public void onEntityDrop(LivingDropsEvent event) {

	if (event.entity instanceof EntityZombie) {

		int R = ((int) (Math.random() * 100));

//5%
		if (R > 94) {
			event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, new ItemStack(MercenaryModItems.hierbaVerdeSemilla, 1)));
		}

//2%
		R = ((int) (Math.random() * 100));
		if (R > 98) {
			event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, new ItemStack(MercenaryModItems.hierbaRojaSemilla, 1)));
		}
//2%
		R = ((int) (Math.random() * 100));
		if (R > 98) {
			event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, new ItemStack(MercenaryModItems.hierbaAzulSemilla, 1)));
		}
//not for now
		R = ((int) (Math.random() * 100));
		if (R > 100) {
			event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, new ItemStack(MercenaryModItems.hierbaAmarillaSemilla, 1)));
		}

	}

}

Link to comment
Share on other sites

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.