Jump to content

Most effective way to remove vanilla mob drops, without editing anything?


Recommended Posts

Posted

So, what does Eclipse say of this underlined error ?

 

All possible fixes, but drop.remove was none of them. I thought since the "Iterator iterator" was nowhere defined, I had to define it. However, changing it to drop.remove fires out this error log...

Yeah, this is why Eclipse is only a tool, not your brain ;)

 

As for the error, gcewing explained it well enough.

[spoiler=The fix you should have found]

Move event.drops.add(args); line out of the while loop.

 

 

 

And please, stop ranting at pelep :)

Posted

Thank you very much guys, it's working perfectly so far, though I haven't tested it completely into detail. The final code:

 

 

package MetallurgyRealism;

import java.util.Iterator;

import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingDropsEvent;

public class MetallurgyRealismLivingDrops {
public static double rand;

@ForgeSubscribe
public void onEntityDrop(LivingDropsEvent event) {
	if (event.source.getDamageType().equals("player")) {
		rand = Math.random();
		System.out.println("Killed something.");
		if (event.entityLiving instanceof EntityCow || event.entityLiving instanceof EntitySheep || event.entityLiving instanceof EntityChicken || event.entityLiving instanceof EntityPig || event.entityLiving instanceof EntityWolf) {
			System.out.println("Killed a sheep.");
			if (rand < 0.1D) {
				event.entityLiving.dropItem(Item.bone.itemID, 2);
			}				
		}
		if(event.entityLiving instanceof EntityCow){

			ItemStack stack;
			Iterator drop = event.drops.iterator();
			while(drop.hasNext()){

				stack = ((EntityItem)drop.next()).getEntityItem();
				if(stack!=null && stack.getItem().itemID == Item.leather.itemID){
					drop.remove();
				}
			}
		event.drops.add(new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ, new ItemStack(MetallurgyRealismModBase.FoodEggBoiled)));
		}
	}
}
}

 

 

I know that this will be a great help to a lot of people, because I found tons of threads with people asking on how to remove vanilla drops, but no one really made it. So you did not only help a mere Copy Paster, but probably an army of unexperienced modders...I wonder if the creator of Mo Creatures ever thought about excluding vanilla drops?

 

However, for anyone using the code above, there's also a portion inside that let certain entitys drop Bones when killed, you probably want to remove this portion of code, if only want to use the remove vanilla drop feature.

 

And please, stop ranting at pelep :)

 

Ranting? In fact Pelep was ranting at me all the time just because he couldn't stand me telling him the truth about his attitude and being sarcastic to Hydroflame. He was even mocking my language, despite the fact that English only is my second language and he's not even capable of using big letters in Nomens and when a sentence starts. Honestly, if they're all so "mature" they should grow some balls and be less reactionary and exaggerated...and post that damn code... 8)

 

Read carefully through the thread to figure that there's no response from my side to any of his "rants".

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.