Jump to content

[SOLVED]How can i add Drops in existing Mobs?


Tsiumi

Recommended Posts

I want to Loot in existing Mobs(Zombies, Creeper etc.) but i don't know how it works :(

I have try it:

package mib.item;

import mib.MIB;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.item.Item;
import net.minecraft.world.World;

public class EntityBloodDropLoot extends EntityZombie{

public EntityBloodDropLoot(World par1World) {
	super(par1World);

}
    protected int getDropItemId()
    {
        return MIB.bloodDrop.itemID;
    }

    }

It didn't work :(

Can you help me?

 

Link to comment
Share on other sites

This is not the best way to do this but! (Sorry im new to forge)

 

  @ForgeSubscribe

        public void Drops(LivingDropsEvent event)

        {

        if(event.entityLiving instanceof EntityZombie)

        {

          event.entityLiving.dropItem(Item.bone.itemId 1);

        }

        }

 

Note: will drop Every time just add Random to fix this

 

EE3 Uses:

 

  @ForgeSubscribe

    public void onEntityLivingDeath(LivingDeathEvent event) {

 

        if (event.source.getDamageType().equals("player")) {

            ItemHelper.dropMiniumShard((EntityPlayer) event.source.getSourceOfDamage(), event.entityLiving);

        }

        if (event.source.getSourceOfDamage() instanceof EntityArrow) {

            if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity != null) {

                if (((EntityArrow) event.source.getSourceOfDamage()).shootingEntity instanceof EntityPlayer) {

                    ItemHelper.dropMiniumShard((EntityPlayer) ((EntityArrow) event.source.getSourceOfDamage()).shootingEntity, event.entityLiving);

                }

- Wurmatron

Link to comment
Share on other sites

Make A new class. It should look something like this:

package dudesmods.lozmod2.entity;

import java.util.Random;

import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.*;
import net.minecraft.entity.passive.*;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraft.entity.EntityLiving;

public class ModLivingDropsEvent {

          public static double rand;
          public Random r = new Random();

          @ForgeSubscribe
          public void onEntityDrop(LivingDropsEvent event) {
        	  if(event.entityLiving instanceof EntityCow) {
        		  event.entityLiving.dropItem(LOZmod.green_tanned_leather.itemID, r.nextInt(3));
        	  }
          }
                  
}

change "EntityCow" to the desired Entity.

"r.nextInt(3)" indicates that it drops anywhere from 1-3 of the item

"LOZmod.green_tanned_leather.itemID" is the item

 

In your main class in the PreInt method:

MinecraftForge.EVENT_BUS.register(new ModLivingDropsEvent());

"ModLivingDropsEvent" being the class you made.

Legend of Zelda Mod[updated September 20th to 3.1.1]

Extra Achievements(Minecraft 1.8!)[updated April 3rd to 2.3.0]

Fancy Cheeses[updated May 8th to 0.5.0]

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.