i did look the wolf code, and i tried to add the lines myself, but i got 17 errros, i dont know java to much for that yet lol, when i use EntityTameable on the beginning it gives me errors.. could you guys show me what i need to add? thanks!
ok so i figger it out; i did not had the tameable library on the imports lol, anyway it works now, my Mob is Tamable and Breedable, but its not right yet
It get tamed (i got the particle effect and such) but it wont follow me, protect me, nor sit... cant understand why yet.. here is the code now
import net.minecraftforge.fml.common.registry.EntityRegistry;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraft.world.gen.structure.template.Template;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.World;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.DamageSource;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.init.Items;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.Entity;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.ai.EntityAIFollowParent;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.EntityMoveHelper;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraft.util.math.MathHelper;
import net.minecraft.entity.ai.EntityAIEatGrass;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.ai.EntityAIFollowParent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget;
import net.minecraft.entity.ai.EntityAIOwnerHurtTarget;
import net.minecraft.entity.ai.EntityAISit;
import net.minecraft.entity.ai.EntityAIFollowOwner;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.EntityLiving;
import java.util.Random;
public class mcreator_capuchinBrown {
public static Object instance;
public static int mobid = 57;
public static int mobid2 = 58;
public void preInit(FMLPreInitializationEvent event) {
EntityRegistry.registerModEntity(new ResourceLocation("testenvironmentmod:capuchinbrown"), EntitycapuchinBrown.class, "capuchinbrown", mobid,
instance, 64, 1, true, -9813724, -14145496);
Biome[] spawnBiomes = {Biome.REGISTRY.getObject(new ResourceLocation("jungle")),};
EntityRegistry.addSpawn(EntitycapuchinBrown.class, 18, 2, 8, EnumCreatureType.CREATURE, spawnBiomes);
}
public void load(FMLInitializationEvent event) {
}
public void serverLoad(FMLServerStartingEvent event) {
}
@SideOnly(Side.CLIENT)
public void registerRenderers() {
RenderLiving customRender = new RenderLiving<EntityAgeable>(Minecraft.getMinecraft().getRenderManager(), new ModelCapuchin(), 0) {
protected ResourceLocation getEntityTexture(EntityAgeable par1Entity) {
return new ResourceLocation("Capuchin_Brown.png");
}
protected void preRenderCallback(EntityAgeable entitylivingbaseIn, float partialTickTime) {
float f = 0.8F;
if (entitylivingbaseIn.getGrowingAge() < 0) {
f = (float)((double)f * 0.5D);
this.shadowSize = 0.4F;
} else {
this.shadowSize = 0.8F;
}
GlStateManager.scale(f, f, f);
}
};
RenderingRegistry.registerEntityRenderingHandler(EntitycapuchinBrown.class, customRender);
}
public void generateNether(World world, Random random, int chunkX, int chunkZ) {
}
public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
}
public int addFuel(ItemStack fuel) {
return 0;
}
public static class EntitycapuchinBrown extends EntityTameable {
public EntitycapuchinBrown(World world) {
super(world);
addRandomArmor();
experienceValue = 4;
this.isImmuneToFire = false;
setNoAI(!true);
this.tasks.addTask(1, new EntityAIWander(this, 1.0D));
this.tasks.addTask(5, new EntityAILookIdle(this));
this.tasks.addTask(2, new EntityAITempt(this, 1.1D, Items.REEDS, false));
this.tasks.addTask(6, new EntityAIPanic(this, 1.2D));
this.tasks.addTask(3, new EntityAIMate(this, 1.0D));
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
this.tasks.addTask(4, new EntityAIFollowParent(this, 0.9D));
this.aiSit = new EntityAISit(this);
this.tasks.addTask(2, this.aiSit);
this.tasks.addTask(6, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
this.setSize(1F, 1F);
this.setTamed(false);
}
//TAME CODE
public void setTamed(boolean tamed)
{
super.setTamed(tamed);
//whatever you want your mob to do when it's tamed e.g. the wolf's class uses this to increase the mob's max health to 20 if it's tamed
}
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
ItemStack itemstack = player.getHeldItem(hand);
if (!this.isTamed() && itemstack.getItem() == Items.BONE)
{
if (!player.capabilities.isCreativeMode)
{
itemstack.shrink(1);
}
if (!this.world.isRemote)
{
if (this.rand.nextInt(3) == 0 && !net.minecraftforge.event.ForgeEventFactory.onAnimalTame(this, player))
{
this.setTamedBy(player);
this.navigator.clearPath();
this.setAttackTarget((EntityLivingBase)null);
this.aiSit.setSitting(true);
this.setHealth(20.0F);
this.playTameEffect(true);
this.world.setEntityState(this, (byte)7);
}
else
{
this.playTameEffect(false);
this.world.setEntityState(this, (byte)6);
}
}
return true;
}
return super.processInteract(player, hand);
}
//TAME CODE END
@Override
protected Item getDropItem() {
return new ItemStack(mcreator_monkeymeat.block, (int) (1)).getItem();
}
@Override
public net.minecraft.util.SoundEvent getAmbientSound() {
return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(
"testenvironmentmod:wizard.capuchin.ambient"));
}
@Override
public net.minecraft.util.SoundEvent getHurtSound(DamageSource ds) {
return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(
"testenvironmentmod:wizard.capuchin.hurt"));
}
@Override
public net.minecraft.util.SoundEvent getDeathSound() {
return (net.minecraft.util.SoundEvent) net.minecraft.util.SoundEvent.REGISTRY.getObject(new ResourceLocation(
"testenvironmentmod:wizard.capuchin.death"));
}
@Override
protected float getSoundVolume() {
return 1.0F;
}
@Override
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.35D);
this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(8D);
if (this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null)
this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(0D);
}
protected void addRandomArmor() {
}
@Override
public EntitycapuchinBrown createChild(EntityAgeable ageable) {
return new EntitycapuchinBrown(world);
}
@Override
public float getEyeHeight() {
return this.isChild() ? this.height : 1.3F;
}
@Override
public boolean isBreedingItem(ItemStack stack) {
if (stack == null)
return false;
if (new ItemStack(Items.REEDS, (int) (1)).getItem() == stack.getItem())
return true;
return false;
}
protected void dropRareDrop(int par1) {
this.dropItem(new ItemStack(Items.LEATHER, (int) (1)).getItem(), 1);
}
}
thanks again! yeah i read the errors but im learning java by myself lol its kinda tricky
i will check this new info asp,
what i mean before was that it does get tamed (i got the 'making friends' achvment), but it does not sit, do i have to make my own animations for sitting or it does it by itself?
hum i gotta be honest i dont understand what you said there
1) yes, it breeds with Reeds, follow reed, wander, follow parents, and it have a GIScale code to make the puppy half size of the parents.
2) yes, i right click with empty hand and with Apple and nothing happens, it wont follow me (it just follow me with reeds because its on the temp behavior for breeding)
3) no, the mob wont sit at all, the model does not change
i just want to be sure its tamed, since it wont follow me or sit, something is missing here :/
well this is strange, i paste your code on mine, and its still the same situation; i give the apple, it gives me the tame animations, but it wont sit nor follow me :/
Oh actually it DOES work, i checked now, the mob does follow me and its tamed, the reason i could not tell is that when it Sits, it wont animate (the model itself wont sit) but the entity is sit. how do i make the model itself sit too? thanks!
Im trying to finish my mod so i can release it, i already have more than 40 mobs!
But i need to learn to how to make them tameable can someone please help?)
Im new to java so i would apreciate if someone can help me here! thanks!
You should use EntityTameable instead of EntityAnimal for your pets, and look to any vanilla tameable mobs code (such as wolf or ocelot)
i did look the wolf code, and i tried to add the lines myself, but i got 17 errros, i dont know java to much for that yet lol, when i use EntityTameable on the beginning it gives me errors.. could you guys show me what i need to add? thanks!
its for 1.12 btw
Edited: Error Removed
ok so i figger it out; i did not had the tameable library on the imports lol, anyway it works now, my Mob is Tamable and Breedable, but its not right yet
It get tamed (i got the particle effect and such) but it wont follow me, protect me, nor sit... cant understand why yet.. here is the code now
Thank you so much btw that tutorial help a lot!
thanks again! yeah i read the errors but im learning java by myself lol its kinda tricky
i will check this new info asp,
what i mean before was that it does get tamed (i got the 'making friends' achvment), but it does not sit, do i have to make my own animations for sitting or it does it by itself?
hum i gotta be honest i dont understand what you said there
you talk about this part?
i found this on the wolf code;
but dont know if i can use it
lol ok but where i put that? thanks
still wont sit nor follow me after tamed.
here is the code now:
just replace like you said, still it wont sit/follow me
the code now
does the model have to have any special name on the legs so it will sit or something?
thank you again
1) yes, it breeds with Reeds, follow reed, wander, follow parents, and it have a GIScale code to make the puppy half size of the parents.
2) yes, i right click with empty hand and with Apple and nothing happens, it wont follow me (it just follow me with reeds because its on the temp behavior for breeding)
3) no, the mob wont sit at all, the model does not change
i just want to be sure its tamed, since it wont follow me or sit, something is missing here :/
well this is strange, i paste your code on mine, and its still the same situation; i give the apple, it gives me the tame animations, but it wont sit nor follow me :/
Oh actually it DOES work, i checked now, the mob does follow me and its tamed, the reason i could not tell is that when it Sits, it wont animate (the model itself wont sit) but the entity is sit. how do i make the model itself sit too? thanks!