Jump to content

Recommended Posts

Posted

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.

Posted

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)?

 

 

Edit: Excuse me, Jabelar, you still there?

Posted

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?

Posted
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.

Posted

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){

	}
}
}
}

Posted

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.

Posted

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.

Posted

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.

Posted

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

Posted
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.

Posted

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.

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.

×
×
  • Create New...

Important Information

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