Jump to content

Recommended Posts

Posted

Exactly what the titles says I will list what I Have tried.

Btw,I am adding a drop to sheep

 

  • I tried adding a sheep class which extended EntitySheep.and then used the constructor from entitieSheep that changed the drop(this just did absolutley nothing
  • I tried cloning the sheep class and just changing the drops.(The normal sheep spawned but no clone sheep did)
     

Please give me any suggestions .

~streq

Posted

Is the item your adding a custom item? Or an item that is already in Minecraft?

 

This is out of memory, so it might be wrong. But for vanilla you use:

return Block.blockDiamond.blockID //Replace blockDiamond with Vanilla block

return Item.diamond.shiftedIndex //Replace diamond with Vanilla item

 

And for a custom item or block you use:

return Class.Block.blockID //Replace Class with your mod class, and Block with your block name

return Class.Item.shiftedIndex //Replace Class with your mod class, and Item with your item name

Posted

It is custom

what I had

was

 

    protected int getDropItemId()

    {

        return streq.mod.sandwiches.RawMutton.blockID;

       

       

    }

but the sheep did not drop mutton still only wool

Posted

Use LivingDeathEvent if you want vanilla sheep to drop your item.

 

@ForgeSubscribe
public void playerKilledSheep(LivingDeathEvent event)
{
if(event.entityLiving instanceof EntitySheep)
{
	event.entityLiving.dropItem(Item.porkCooked.shiftedIndex, 1);
}
}

Posted

in your main class you do

@PreInit

public void registerMyEvents(FMLPreInitializationEvent e){

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

}

then u create a class with the

 

  Reveal hidden contents

 

Posted

Oh thankyou I will try this =P

edit: Awesome that worked all I had to change was in the event class instead of shiftedIndex I had to use itemID

otherwise it crashed upon killing a sheep

  • 4 months later...
Posted

You should use the LivingDropsEvent instead of the LivingDeathEvent, since it's specially designed to be fired when a mob srops something (even players I think)

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted
  On 6/5/2013 at 3:24 PM, SanAndreasP said:

You should use the LivingDropsEvent instead of the LivingDeathEvent, since it's specially designed to be fired when a mob srops something (even players I think)

Didn't work....

Posted
  On 6/5/2013 at 4:21 PM, Nieue said:

  Quote

You should use the LivingDropsEvent instead of the LivingDeathEvent, since it's specially designed to be fired when a mob srops something (even players I think)

Didn't work....

 

That is not very descriptive...

WHAT does not work exactly?

And where's your code you're using?

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

  Quote

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted
  On 6/5/2013 at 8:24 PM, SanAndreasP said:

  Quote

  Quote

You should use the LivingDropsEvent instead of the LivingDeathEvent, since it's specially designed to be fired when a mob srops something (even players I think)

Didn't work....

 

That is not very descriptive...

WHAT does not work exactly?

And where's your code you're using?

The custom item doesn't drop from the monster

Event class

 

  Reveal hidden contents

 

Main mod class

 

  Reveal hidden contents

 

  • 2 years later...
Posted

You need to add a second parameter to the if statement.

 

Code should be like this:

 

package mods.DennisMod.COMMON;

import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.item.Item;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingDropsEvent;

public class EventDropDarkBone {
   @ForgeSubscribe
   public void playerKilledWitherSkeleton(LivingDropsEvent event)
   {
      if(event.entityLiving instanceof EntitySkeleton)
      {
if (((EntitySkeleton)event.entityLiving).getSkeletonType() == 1)
        {
         event.entityLiving.dropItem(MoGems.DarkBone.itemID, 1);
        }
      }
    }
}

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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