Jump to content

[1.8.9] Custom Mob Drops Only With Specific Item?


Monstrous_Apple

Recommended Posts

@SubscribeEvent
public void addEntityDrop50(LivingDropsEvent event)
{
	if (event.getEntity() instanceof EntityCow)
	{
		if (event.getSource() != null && event.getSource().getEntity() instanceof EntityPlayer)
		{
			EntityPlayer player = ((EntityPlayer) event.getSource().getEntity());
			if (player != null)
			{
				ItemStack holding =  player.inventory.getStackInSlot(player.inventory.currentItem);
				if (holding != null && holding.getItem() instanceof MASoulHarvester)
				{
					ItemStack itemstack = new ItemStack(MASouls.CowSoul, 1);
					event.getDrops().add(new EntityItem(event.getEntity().worldObj, event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, itemstack));
				}
			}
		}
	}
}

 

Jeeezz... Go back to Java tutorials. (I am serious dude, you won't get far with copy pasting from forums, and "that's how I learn" is no excuse).

  • Like 1

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

@SubscribeEvent
public void addEntityDrop50(LivingDropsEvent event)
{
	if (event.getEntity() instanceof EntityCow)
	{
		if (event.getSource() != null && event.getSource().getEntity() instanceof EntityPlayer)
		{
			EntityPlayer player = ((EntityPlayer) event.getSource().getEntity());
			if (player != null)
			{
				ItemStack holding =  player.inventory.getStackInSlot(player.inventory.currentItem);
				if (holding != null && holding.getItem() instanceof MASoulHarvester)
				{
					ItemStack itemstack = new ItemStack(MASouls.CowSoul, 1);
					event.getDrops().add(new EntityItem(event.getEntity().worldObj, event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, itemstack));
				}
			}
		}
	}
}

 

Jeeezz... Go back to Java tutorials. (I am serious dude, you won't get far with copy pasting from forums, and "that's how I learn" is no excuse).

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Well this seems to be working, so you think this is correct, yeah?

 

@SubscribeEvent
	public void addEntityDrop58(LivingDropsEvent event)
	{
		if (event.entity instanceof EntityCow)
		{
			if (event.source != null)
			{
				EntityPlayer player = ((EntityPlayer) event.source.getEntity());
				if (player != null)
				{
					ItemStack holding =  player.inventory.getStackInSlot(player.inventory.currentItem);
					if (holding != null && holding.getItem() instanceof MASoulHarvester)
					{
						ItemStack itemstack = new ItemStack(MASouls.CowSoul, 1);
						event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, itemstack));
					}
				}
			}
		}
	}

Link to comment
Share on other sites

Well this seems to be working, so you think this is correct, yeah?

 

@SubscribeEvent
	public void addEntityDrop58(LivingDropsEvent event)
	{
		if (event.entity instanceof EntityCow)
		{
			if (event.source != null)
			{
				EntityPlayer player = ((EntityPlayer) event.source.getEntity());
				if (player != null)
				{
					ItemStack holding =  player.inventory.getStackInSlot(player.inventory.currentItem);
					if (holding != null && holding.getItem() instanceof MASoulHarvester)
					{
						ItemStack itemstack = new ItemStack(MASouls.CowSoul, 1);
						event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX, event.entity.posY, event.entity.posZ, itemstack));
					}
				}
			}
		}
	}

Link to comment
Share on other sites

By the way why did you give me that code if it wasn't complete/ doesn't work?

It is complete and it is working (for 1.9+).

 

The fact that you don't have clue what you are doing is a different thing - if you can't figure out that event.getEntity() is the same as just event.entity then you simply don't know how Java/programming works and have no idea how to use your IDE.

 

Now before hating:

 

1. Read this sub-forum description.

 

2. Try to imagine situation where someone who has no idea how to work with physics goes to laboratory and starts asking questions on how to build an atomic bomb. Then imgaine that labs usually have documentation on everything that happens there. Then imagine that person asking about bomb, while not even LOOKING into those documents and getting crystal clear answers from those scientist in lab - still doesn't understand shit! Why? Because he is not a scientist. That is what is hapening here (hint, you are this guy, forum is lab and google/source is documentation). You can't expect to understand anything without actually learning it.

 

3. Seriously - go learn Java.

 

---------------------------------------------------------------------------

 

2nd post: Add this:

if (event.getSource() != null && event.getSource().getEntity() instanceof EntityPlayer)

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

By the way why did you give me that code if it wasn't complete/ doesn't work?

It is complete and it is working (for 1.9+).

 

The fact that you don't have clue what you are doing is a different thing - if you can't figure out that event.getEntity() is the same as just event.entity then you simply don't know how Java/programming works and have no idea how to use your IDE.

 

Now before hating:

 

1. Read this sub-forum description.

 

2. Try to imagine situation where someone who has no idea how to work with physics goes to laboratory and starts asking questions on how to build an atomic bomb. Then imgaine that labs usually have documentation on everything that happens there. Then imagine that person asking about bomb, while not even LOOKING into those documents and getting crystal clear answers from those scientist in lab - still doesn't understand shit! Why? Because he is not a scientist. That is what is hapening here (hint, you are this guy, forum is lab and google/source is documentation). You can't expect to understand anything without actually learning it.

 

3. Seriously - go learn Java.

 

---------------------------------------------------------------------------

 

2nd post: Add this:

if (event.getSource() != null && event.getSource().getEntity() instanceof EntityPlayer)

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

I understand what you're saying but not everyone has the time, I wish I did have the time to learn java, but unfortunately thanks to certain circumstances I can't do it, so instead with the little time I have I'm just doing it the faster way using tutorials on straight up modding which is working so far, honestly if I was able to learn Java I would.. anyway thanks for your help and thanks for being patient enough to stick around and help me. :)

Link to comment
Share on other sites

I understand what you're saying but not everyone has the time, I wish I did have the time to learn java, but unfortunately thanks to certain circumstances I can't do it, so instead with the little time I have I'm just doing it the faster way using tutorials on straight up modding which is working so far, honestly if I was able to learn Java I would.. anyway thanks for your help and thanks for being patient enough to stick around and help me. :)

Link to comment
Share on other sites

And make sure its not null

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

And make sure its not null

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

It's not rude, I have a personal reason as to why I can't, I did not come onto this forum and say "You all MUST help me" that is your choice if you want to use your own time to help me, I post for help and hope for help, I don't force you into helping me so if you don't want to, then don't. It's not like you was being forced into helping me anyway.

 

Edit: Everyone who tries and has tried to help me already knows I don't know much about Java so it's their choice to give up time to help another person. There's no forcing here.

Link to comment
Share on other sites

It's not rude, I have a personal reason as to why I can't, I did not come onto this forum and say "You all MUST help me" that is your choice if you want to use your own time to help me, I post for help and hope for help, I don't force you into helping me so if you don't want to, then don't. It's not like you was being forced into helping me anyway.

 

Edit: Everyone who tries and has tried to help me already knows I don't know much about Java so it's their choice to give up time to help another person. There's no forcing here.

Link to comment
Share on other sites

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.