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.

How do I add my items to a vanilla mob(pig and sheep)without changing its class?

Featured Replies

try extending a class and loading it in your main class

 

i.e.

 

import net.minecraft.entity.passive.EntityPig;

import net.minecraft.item.Item;

import net.minecraft.world.World;

 

public class New_drop extends EntityPig {

 

public New_drop(World par1World) {

super(par1World);

this.dropItem(Item.appleRed.itemID, 6);

}

 

}

 

  • Author

It's not working either, I tried this:

package tutorial.coldblademod;

import net.minecraft.entity.passive.EntityPig;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import tutorial.coldblademod.ColdbladeMod;

public class EntityDropCBMod extends EntityPig {

public EntityDropCBMod(World par1World) {
	super(par1World);
}

protected void LivingDeathEvent(){
	this.dropItem(ColdbladeMod.baconRawID, 2);
}

   
}

But it doesn't drop anything. I've tried the LivingDeathEvent, LivingDropEvent and about other 5.

Create a new class:

import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.item.Item;
import net.minecraftforge.event.*;



public class yourclass{

@ForgeSubscribe
public void playerKilledSheep(LivingDeathEvent event)
{
 if(event.entityLiving instanceof EntitySheep)
 {
  event.entityLiving.dropItem( yourmod.youritem.itemId Amount);

 }
}
}

 

Then write in your main class in the public void load:

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

 

I hope i could help you.^^

here is an example i know works because i use it :)

for your main class before you init,

@PreInit
public void registerMyEvents(FMLPreInitializationEvent e){
	MinecraftForge.EVENT_BUS.register(new BatDrops());{
 }
	}

the seperate class

package ashtonsmod.common;

import net.minecraft.block.Block;
import net.minecraft.block.BlockBreakable;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.passive.EntityBat;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;

public class BatDrops {

          public static double rand;

          @ForgeSubscribe
          public void onEntityDrop(LivingDropsEvent event) {
                  if (event.source.getDamageType().equals("player")) {
                       rand = Math.random();
                        if (event.entityLiving instanceof EntityBat) {
                             //The integer at the end relates to how many Items will be dropped(percentage). 
                             if (rand < 0.75d){
                                //The integer at the end relates to how many Items will be dropped(amount). 
                                event.entityLiving.dropItem(Item.potatoe.itemID, 1);
                           }
                     }}}

this makes a bat on death have a 75% chance of dropping one potatoe

Use examples, i have aspergers.

Examples make sense to me.

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.