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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • @Tsuk1 Also, new note, you can use blockbench to make the custom item model for when it is not on the head.   EDIT: Funny story, I am making a mod similar to yours! Mine is called NorseMC.
    • @Nood_dev Could you send a screenshot of your weapon code? Here is the one I made (for a dagger): The specific UUID does not matter, just that it is the same every time, which is why UUID#randomUUID does not work public class DaggerItem extends TieredItem implements Vanishable { protected static final double REACH_MODIFIER = -1.5D; protected final Multimap<Attribute, AttributeModifier> defaultModifiers; protected final UUID BASE_ATTACK_REACH_UUID = UUID.fromString("6fe75b5c-9d1b-4e83-9eea-a1d5a94e8dd5") public DaggerItem(Tier pTier, int pAttackDamageModifier, float pAttackSpeedModifier, Properties pProperties) { super(pTier, pAttackDamageModifier, pAttackSpeedModifier, pProperties); this.attackDamage = (float) pAttackDamageModifier + pTier.getAttackDamageBonus(); ImmutableMultimap.Builder<Attribute, AttributeModifier> builder = ImmutableMultimap.builder(); builder.put(Attributes.ATTACK_DAMAGE, new AttributeModifier(BASE_ATTACK_DAMAGE_UUID, "Weapon modifier", this.attackDamage, AttributeModifier.Operation.ADDITION)); builder.put(Attributes.ATTACK_SPEED, new AttributeModifier(BASE_ATTACK_SPEED_UUID, "Weapon modifier", pAttackSpeedModifier, AttributeModifier.Operation.ADDITION)); // THE ONE YOU WANT: builder.put(ForgeMod.ENTITY_REACH.get(), new AttributeModifier(BASE_ATTACK_REACH_UUID, "Weapon modifier", REACH_MODIFIER, AttributeModifier.Operation.ADDITION)); this.defaultModifiers = builder.build(); } @Override public Multimap<Attribute, AttributeModifier> getDefaultAttributeModifiers(EquipmentSlot pEquipmentSlot) { return pEquipmentSlot == EquipmentSlot.MAINHAND ? this.defaultModifiers : super.getDefaultAttributeModifiers(pEquipmentSlot); } }
    • https://images.app.goo.gl/1PxFKdxByTgkxvSu6
    • That's what we'll try out. I could never figure out how to recreate the crash, so I'll just have to wait and see.
    • Ok, I updated to the latest version and now the models are visible, the problem now is that the glowing eyes are not rendered nor any texture I render there when using shaders, even using the default Minecraft eyes RenderType, I use entityTranslucent and entityCutout, but it still won't render. Something I noticed when using shaders is that a texture, instead of appearing at the world position, would appear somewhere on the screen, following a curved path, it was strange, I haven't been able to reproduce it again. I thought it could be that since I render the texture in the AFTER ENTITIES stage which is posted after the batches used for entity rendering are finished, maybe that was the reason why the render types were not being drawn correctly, so I tried injecting code before finishing the batches but it still didn't work, plus the model was invisible when using shaders, there was a bug where if I look at the model from above it is visible but if I look at it from below it is invisible. So in summary, models are now visible but glowing eyes and textures are not rendered, that hasn't changed.
  • Topics

×
×
  • Create New...

Important Information

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