Jump to content

[Reopened] Overriding mob drops


darthvader45

Recommended Posts

I'm working for a team creating the Realistic Animal Products and Drops Mod (link: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/wip-mods/2389704-realistic-animal-products-and-drops-mod)

 

One item is hide, which has different colors depending on the animal it drops from (pig, sheep, cow, horse, donkey, or mule), and another is pelt, which drops from ocelots, cats, and wolves.  How do I access the different mobs to determine the type of hide dropped?

 

 

Edit: Solved by searching the net for adding Wither skelly drops.  Turns out the solution shown there works for EntityHorse as well.  I definitely learned something new today.  Note to self: Find a similar problem and see if solution works with current issue.

Link to comment
Share on other sites

How would this deal with mobs that use multiple variations, such as horses, which have the variations donkey and mule(both stuck in the EntityHorse class as values of the variable i)?

You have to check for it. If you want to e.g. only drop things for mules, check first that the entity in the event is a horse and then check that it is also a mule.

Edit: Excuse me, Jabelar, you still there?

This is a forum, not a chat room.

 

I cannot seem to get the type of horse needed.  How would I call the variable that determines if the horse is a regular horse, a mule, or a donkey?

Link to comment
Share on other sites

also: How do people (you are not the only one) fail to perform these absolute basic steps all the f***ing time? I don't get it.

 

I don't know, I just don't know. ..

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

Ok, so. Let me teach you how to do absolute basic research in code.

We want to know something about horses. So, naturally, we start looking in the

EntityHorse

class. How do you find it? Use the "Go to class" action in your IDE (Ctrl-Shift-T in eclipse, Ctrl-N in IntelliJ).

Now that we have that open, let's check the outline (eclipse) or structure (IntelliJ) of the class (same thing). The fields don't really provide anything useful, so let's look at the methods, maybe there is a getter. And, who would have thought, there it is:

public int getHorseType

. Complete with JavaDocs explaining the return type.

 

What more do you want? :o And also: How do people (you are not the only one) fail to perform these absolute basic steps all the f***ing time? I don't get it.

 

Ok, ok, no need to get all wound up.  I only needed confirmation.  I'm only using this variable as a separate condition in an if statement.  For this to work, the left hand side must be a variable, therefore the getter will not work.

 

My code:

package net.sargeant.rapad.eventhandler;
import java.util.Random;

import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.sargeant.rapad.items.ModItems;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class HorseDropEvent 
{
public static Random random;
public static int dropped;

@SubscribeEvent
public void onEntityDrop(LivingDropsEvent event)
{
random = new Random();
dropped = random.nextInt(2) + 1; //DO NOT CHANGE THIS

if(event.entityLiving instanceof EntityHorse )
{
	if (EntityHorse#getHorseType() = 1){

	}
}
}
}

Link to comment
Share on other sites

Okay, so I type EntityHorse in, plus a period.  I don't see anything in the autocomplete even mentioning said variable of getHorseType().  I'd have to type in "this" to get anywhere, and even then it says "cannot convert from int to boolean".  I then try putting  =  1 at the end, and the error changes to "the left-hand side of an assignment must be a variable".

 

Edit:  Found my answer in a separate topic talking about adding drops after detecting Skeleton type.  Tried it with horses, and it worked.  Gonna remember this from now on.

Link to comment
Share on other sites

Okay, so I type EntityHorse in, plus a period.  I don't see anything in the autocomplete even mentioning said variable of getHorseType().  I'd have to type in "this" to get anywhere, and even then it says "cannot convert from int to boolean".  I then try putting  =  1 at the end, and the error changes to "the left-hand side of an assignment must be a variable".

EntityHorse#getHorseType() is not valid Java code (which you should know, since you know Java, right? Right?)

Apparently not...  :o

 

OP, the drop Event has the entity instance in it already. You cannot literally type 'EntityHorse.' and expect magic to happen - as diesieben said, it is NOT a static method.

 

Get the entity from the event, check if that entity is an instanceof EntityHorse, and then cast the entity to EntityHorse to access the method. If you don't know what any of those terms mean, Google them.

Link to comment
Share on other sites

Jesus Christ...

 

((EntityHorse)event.entityLiving).getHorseType() strike any bells?

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

Jesus Christ...

 

((EntityHorse)event.entityLiving).getHorseType() strike any bells?

 

I used to think to myself, man, these Forge guys on the forums are a bunch of a-holes to people trying to learn...

 

But then I saw this post...I apologize for my previous assumptions.

www.YouTube.com/WeiseGamer

www.twitter.com/WeiseGamer

Link to comment
Share on other sites

I used to think to myself, man, these Forge guys on the forums are a bunch of a-holes to people trying to learn...

 

We're not assholes, people are just stupid and claim to have programming knowledge they do not have.

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

Okay, some of the drops work, yet some lead to crashes; horse, ocelot and skeleton drops being the three that broke as I have found.

 

My current CustomDropEvents code:

package net.sargeant.rapad.eventhandler;

import java.util.Random;

import net.minecraft.entity.boss.EntityWither;
import net.minecraft.entity.monster.EntityCaveSpider;
import net.minecraft.entity.monster.EntityEnderman;
import net.minecraft.entity.monster.EntityIronGolem;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntitySnowman;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityBat;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.EntitySquid;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.sargeant.rapad.items.ModItems;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;

public class CustomDropEvent 
{
public static Random random;
public static int dropped;
public EntitySkeleton skeleton;
public EntityHorse horse;
public EntityOcelot cat;

@SubscribeEvent
public void onEntityDrop(LivingDropsEvent event)
{
random = new Random();
dropped = random.nextInt(2) + 1; //DO NOT CHANGE THIS

if(event.entityLiving instanceof EntityHorse)
{
event.entityLiving.entityDropItem(new ItemStack(ModItems.horsemeatraw), dropped);
 if(horse.getHorseType() == 0)
{
	event.entityLiving.entityDropItem(new ItemStack(ModItems.horsehide), dropped);

}
else if(horse.getHorseType() == 1)
{
	event.entityLiving.entityDropItem(new ItemStack(ModItems.donkeyhide), dropped);
}
else if(horse.getHorseType() == 2)
{
	event.entityLiving.entityDropItem(new ItemStack(ModItems.mulehide), dropped);
}
if (event.entityLiving.isBurning())
{
	event.entityLiving.entityDropItem(new ItemStack(ModItems.horsemeatcooked), dropped);
}
}
else if(event.entityLiving instanceof EntityWolf)
{
	event.entityLiving.entityDropItem(new ItemStack(ModItems.wolfmeatraw), dropped);
	if (event.entityLiving.isBurning())
	{
		event.entityLiving.entityDropItem(new ItemStack(ModItems.wolfmeatcooked), dropped);
	}
}
else if(event.entityLiving instanceof EntityOcelot)
{
	event.entityLiving.entityDropItem(new ItemStack(ModItems.catmeatraw), dropped);
	if (cat.isTamed() == false){
	event.entityLiving.entityDropItem(new ItemStack(ModItems.ocelotpelt), dropped);
	}
	else if(cat.isTamed() == true){
		event.entityLiving.entityDropItem(new ItemStack(ModItems.catpelt), dropped);
	}
	}
	if (event.entityLiving.isBurning())
	{
		event.entityLiving.entityDropItem(new ItemStack(ModItems.catmeatcooked), dropped);
	}
else if(event.entityLiving instanceof EntitySpider)
{
	event.entityLiving.entityDropItem(new ItemStack(ModItems.venomsac), dropped);
}
else if(event.entityLiving instanceof EntitySquid)
{
	event.entityLiving.entityDropItem(new ItemStack(ModItems.squidraw), dropped);

}
else if(event.entityLiving instanceof EntityBat)
{
	event.entityLiving.entityDropItem(new ItemStack(ModItems.batraw), dropped);
	if (event.entityLiving.isBurning())
	{
		event.entityLiving.entityDropItem(new ItemStack(ModItems.batcooked), dropped);
	}


}
else if(event.entityLiving instanceof EntityPig)
{
	event.entityLiving.entityDropItem(new ItemStack(ModItems.animalfat), dropped);
	event.entityLiving.entityDropItem(new ItemStack(Items.bone), dropped);	
}
else if(event.entityLiving instanceof EntitySheep)
{
	event.entityLiving.entityDropItem(new ItemStack(ModItems.animalfat), dropped);
	event.entityLiving.entityDropItem(new ItemStack(Items.bone), dropped);
	event.entityLiving.entityDropItem(new ItemStack(ModItems.muttonraw), dropped);
	if (event.entity.isBurning())
	{
		event.entityLiving.entityDropItem(new ItemStack(ModItems.muttoncooked), dropped);
	}
}
else if(event.entityLiving instanceof EntityCow)
{
	event.entityLiving.entityDropItem(new ItemStack(ModItems.animalfat), dropped);
	event.entityLiving.entityDropItem(new ItemStack(Items.bone), dropped);		
}
else if(event.entityLiving instanceof EntityVillager)
{
	event.entityLiving.entityDropItem(new ItemStack(Items.emerald), dropped);
	event.entityLiving.entityDropItem(new ItemStack(Items.bread), dropped);
	event.entityLiving.entityDropItem(new ItemStack(Items.apple), dropped);
	event.entityLiving.entityDropItem(new ItemStack(Items.cooked_porkchop), dropped);
	event.entityLiving.entityDropItem(new ItemStack(Items.wheat), dropped);	
	event.entityLiving.entityDropItem(new ItemStack(Items.wheat_seeds), dropped);
	event.entityLiving.entityDropItem(new ItemStack(Items.potato), dropped);
	event.entityLiving.entityDropItem(new ItemStack(Items.carrot), dropped);	
}
else if(event.entityLiving instanceof EntityIronGolem)
{
	event.entityLiving.entityDropItem(new ItemStack(Blocks.iron_block), dropped);
	event.entityLiving.entityDropItem(new ItemStack(Items.iron_ingot), dropped);
	event.entityLiving.entityDropItem(new ItemStack(Blocks.vine), dropped);
	event.entityLiving.entityDropItem(new ItemStack(Blocks.red_flower), dropped);

}
else if(event.entityLiving instanceof EntitySnowman)
{
	event.entityLiving.entityDropItem(new ItemStack(Blocks.pumpkin), dropped);
	event.entityLiving.entityDropItem(new ItemStack(Items.snowball), dropped);		
}
else if(event.entityLiving instanceof EntityZombie)
{
	event.entityLiving.entityDropItem(new ItemStack(Items.bone), dropped);		
}
else if(event.entityLiving instanceof EntitySpider | event.entityLiving instanceof EntityCaveSpider)
{
	event.entityLiving.entityDropItem(new ItemStack(ModItems.venomsac), dropped);		
}
else if(event.entityLiving instanceof EntityWither)
{
	event.entityLiving.entityDropItem(new ItemStack(ModItems.witherbone), dropped);		
}

else if(event.entityLiving instanceof EntityPigZombie)
{
	event.entityLiving.entityDropItem(new ItemStack(ModItems.animalfat), dropped);
	event.entityLiving.entityDropItem(new ItemStack(ModItems.pighide), dropped);
}
else if(event.entityLiving instanceof EntityEnderman)
{
	event.entityLiving.entityDropItem(new ItemStack(Items.bone), dropped);

}

else if(event.entityLiving instanceof EntitySkeleton && skeleton.getSkeletonType() == 1)
{
	if (skeleton.getSkeletonType() == 1){
	event.entityLiving.entityDropItem(new ItemStack(ModItems.witherbone), dropped);	
	}
	else if (skeleton.getSkeletonType() != 1)
	{
		event.entityLiving.entityDropItem(new ItemStack(Items.bone), dropped);
		event.entityLiving.entityDropItem(new ItemStack(Items.arrow), dropped);
	}

}

}




}

 

 

 

Edit: Nvm, Draco's code worked.  I was so stupid, checking a separate entity instead of casting.  Sorry for being a total idiot.  I'm kinda new to modifying vanilla mob drops(but NOT to coding).  I do occasionally make a few noobish mistakes, but that happens to even the most experienced coders.

Link to comment
Share on other sites

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

    • They are heartless scammers, they ruined my life, by making me develop an interest in investing my hard-earned money. I deposited 67,000 USD which was later turned into 110,450 USD including my payout bonus, there was an impressive improvement in a few weeks, later I had an emergency and needed money to pay my insurance fee, I tried reaching out to them to collect the money I invested, they cut the live chats and got me harassed then I realized that I was being scammed. I just wanted my money back! I was advised by a friend to seek help from a recovery firm to assist me in recovering my invested funds, God was so kind I came across some great positive reviews about BETAFORT ONLINE on how they helped scammed victims like me to recover their lost cryptocurrency assets, I took no delay and got in touch with BETAFORT ONLINE, the Expert immediately looked into my case and after providing all the required information they need, and it took them less then a day to recover all my funds. And now I really feel obligated to recommend BETAFORT ONLINE and their team, their recovery strategies, and for working relentlessly to help me recover my funds. Feel free to reach out to BETAFORT ONLINE via google search and they will guide you on how to recover your invested funds, I advise everyone to be careful with these heartless cryptocurrency scammers.  
    • yeah I believe so, its been something deep with the modpack I'm guessing. ill fix each error it states if its saying to replace or download a mod but I'm not sure where to go from here. I have been spending days and have yet to find the issue    
    • It worked, thank you very much 😭
    • https://spark.lucko.me/0ZaR1OAi2F I use spark mod to do a scan and send it here to search for help and if someone know about this issue I dont know to much about, but one thing i see in the record of the minecraft launcher when i play says: can't keep up server overloaded and etc, etc.  I assign 6GB ram to minecraft from the 16 GB of my pc, and fps is not a problem...(no to much) its something about tic rate/second and i am in SINGLE PLAYER. The funny thing is, minecraft vanilla (No mods) works normaly. My mods list (130): https://imgur.com/a/kY3yQr1  Datapacks: https://imgur.com/CTDBe7D ResourcePacks: https://imgur.com/AztTOOw so plis, is someone help me T_T a work  a loot of time in downloading and trying to all mods work but i dont know what to do anymore. Last thing  I SPEAK SPANISH so... sorry if my english is a little scuff or ... werever... bad. Thanks :3
    • Whenever I try to create an world my game crashes. I´ve tried to figure it out myself but wasnt able to do it.   Here are the logs
  • Topics

×
×
  • Create New...

Important Information

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