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

Hello, I've been trying to put bones to a vanilla mob.

I did some research, and tried this:

        @ForgeSubscribe
        public void playerKilledSheep(LivingDropsEvent event)
        {
        	System.out.println("Killed something");
         if(event.entityLiving instanceof EntitySheep)
         {
          System.out.println("Killed a Sheep");
          event.entityLiving.dropItem(Item.bone.shiftedIndex, 1);
         }
        }

 

I have an error on the "shiftedIndex" part, but it doesn't even post something in the console, means it doesn't even detect if I killed something or not.

Please help.

 

Best regards,

MarioErmando

  • 1 month later...

Since I'm nice I'm going to make this the EASY way.

 

package your.package;

import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.item.Item;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingDropsEvent;

public class Event_LivingDrops {
public static double rand;

@ForgeSubscribe
public void onEntityDrop(LivingDropsEvent event) {
	if (event.source.getDamageType().equals("player")) { //Checks for Damage Type.
		rand = Math.random(); //Initializes double "rand"
		System.out.println("Killed something.");
		if (event.entityLiving instanceof EntitySheep) { //Checks the entity killed.
			System.out.println("Killed a sheep.");
			if (rand < 1D) { //Makes drop 100% drop chance. Example: (0.25D = 25%, 1D = 100%, etc.);
				event.entityLiving.dropItem(Item.bone.itemID); //Use "itemID" not "shiftedIndex"
				//itemID is used for MCP, shiftedIndex is only used when already converted to .class.
			}
		}
	}
}
}

 

Also, remember to put this in your Proxy class.

You need to register this class for Forge to be able to know it is an event.

Put it in the @Init of your proxy.

 

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

 

This should work! Read the "//"s for information.

 

Good Luck!

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.