I made a custom entity (mob) but I don't know how to add a custom texture icon-like thing for the spawn egg. Like the alien vs predator mod, the spawn of the aliens had a custom icon on it.
I also wanted to know how to add a description to the custom entity spawn egg, I'm a beginner to modding.
Do you know how to make an Item? That's all you need to do, basically, and just register whatever Icon you want for that item. Override #onItemUse, #onItemRightClick, and, if you want to spawn child entities, #onRightClickEntity, then copy/paste the code from the vanilla monster spawner item methods of the same name, change it to spawn your Entity instead of using the EntityList, and bam, you're done.
Thanks man for the help, but I also wondered how you put your custom egg in to your custom creative tabs? I read some threads but none of them weren't solved yet.
I made a custom entity (mob) but I don't know how to add a custom texture icon-like thing for the spawn egg. Like the alien vs predator mod, the spawn of the aliens had a custom icon on it.
I also wanted to know how to add a description to the custom entity spawn egg, I'm a beginner to modding.
Yep, like coolAlias said.
Then to add a custom description, override addInformation in your Item class.
See this GitHub for an example of an item that adds a custom description. This specific one supports language translation, but you do not have to do that right away.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
public static void mainRegistry() {
registerEntity();
}
public static void registerEntity() {
createEntity(EntityTobyTrainMob.class, "TobyTrain", 0x000000, 0x000000);
}
public static void createEntity(Class entityClass, String entityName, int solidColor, int spotColor) {
int randomId = EntityRegistry.findGlobalUniqueEntityId();
EntityRegistry.registerGlobalEntityID(entityClass, entityName, randomId);
EntityRegistry.registerModEntity(entityClass, entityName, randomId, MainClass.modInstance, 64, 1, true);
EntityRegistry.addSpawn(entityClass, 10, 4, 5, EnumCreatureType.creature, BiomeGenBase.desert);
createEgg(randomId, solidColor, spotColor);
}
private static void createEgg(int randomId, int solidColor, int spotColor) {
EntityList.entityEggs.put(Integer.valueOf(randomId), new EntityList.EntityEggInfo(randomId, spotColor, solidColor));
Don't use #findGlobalUniqueEntityId or #registerGlobalEntityId - all you need is EntityRegistry#registerModEntity with your IDs starting at 0 and incrementing.
However, that will prevent you from being able to use the vanilla spawn eggs, which I didn't realize you were wanting to do. Pre-1.8, it's not possible to do without using global entity IDs, and that is not recommended. Instead, you have to create your own custom egg Item like I mentioned in my first reply.
I made a custom entity (mob) but I don't know how to add a custom texture icon-like thing for the spawn egg. Like the alien vs predator mod, the spawn of the aliens had a custom icon on it.
I also wanted to know how to add a description to the custom entity spawn egg, I'm a beginner to modding.
Do you know how to make an Item? That's all you need to do, basically, and just register whatever Icon you want for that item. Override #onItemUse, #onItemRightClick, and, if you want to spawn child entities, #onRightClickEntity, then copy/paste the code from the vanilla monster spawner item methods of the same name, change it to spawn your Entity instead of using the EntityList, and bam, you're done.
Thanks man for the help, but I also wondered how you put your custom egg in to your custom creative tabs? I read some threads but none of them weren't solved yet.
Yep, like coolAlias said.
Then to add a custom description, override addInformation in your Item class.
See this GitHub for an example of an item that adds a custom description. This specific one supports language translation, but you do not have to do that right away.
I tried to put it but I made my entity in this type of way, I am not sure where to place it since that it is not an item. Sorry for bothering you man.
This class is the creation of the entity
package com.chamchi.mobs;
import java.util.List;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.world.biome.BiomeGenBase;
import com.chamchi.main.Strings;
import com.chamchi.main.MainClass;
import cpw.mods.fml.common.registry.EntityRegistry;
public class EntityTobyTrain {
public static void mainRegistry() {
registerEntity();
}
public static void registerEntity() {
createEntity(EntityTobyTrainMob.class, "TobyTrain", 0x000000, 0x000000);
}
public static void createEntity(Class entityClass, String entityName, int solidColor, int spotColor) {
int randomId = EntityRegistry.findGlobalUniqueEntityId();
EntityRegistry.registerGlobalEntityID(entityClass, entityName, randomId);
EntityRegistry.registerModEntity(entityClass, entityName, randomId, MainClass.modInstance, 64, 1, true);
EntityRegistry.addSpawn(entityClass, 10, 4, 5, EnumCreatureType.creature, BiomeGenBase.desert);
createEgg(randomId, solidColor, spotColor);
}
private static void createEgg(int randomId, int solidColor, int spotColor) {
EntityList.entityEggs.put(Integer.valueOf(randomId), new EntityList.EntityEggInfo(randomId, spotColor, solidColor));
}
}
This class is the AI of the entity
package com.chamchi.mobs;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.passive.EntityChicken;
import net.minecraft.entity.passive.EntityCow;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import com.chamchi.main.MainClass;
public class EntityTobyTrainMob extends EntityMob{
public EntityTobyTrainMob(World par1World) {
super(par1World);
this.setSize(4.0F, 4.0F);
this.getNavigator().setAvoidsWater(true);
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(1, new EntityAIPanic(this, 0.9D));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 0.6D, false));
this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityPig.class, 0.6D, true));
this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityCow.class, 0.6D, true));
this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityChicken.class, 0.6D, true));
this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityWolf.class, 0.6D, true));
this.tasks.addTask(3, new EntityAITempt(this, 0.9D, MainClass.itemTobySoul, false));
this.tasks.addTask(7, new EntityAIWander(this, 0.9D));
this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
this.tasks.addTask(8, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPig.class, 0, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityCow.class, 0, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityChicken.class, 0, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityWolf.class, 0, true));
}
public boolean isAIEnabled() {
return true;
}
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(40.0D);
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0F);
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.9D);
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(0.7D);
}
public EntityTobyTrainMob createChild(EntityAgeable p_90011_1_) {
return new EntityTobyTrainMob(worldObj);
}
@Override
protected String getLivingSound()
{
return "rdtem:mob.TobyTrain.live";
}
@Override
protected String getDeathSound()
{
return "rdtem:mob.TobyTrain.death";
}
}
And this class is the render of the entity
package com.chamchi.mobs;
import com.chamchi.main.Strings;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.renderer.entity.RenderLiving;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
public class RenderTobyTrain extends RenderLiving {
private static final ResourceLocation mobTextures = new ResourceLocation(Strings.MODID + ":textures/entity/ModelTobyTrainTexture.png");
public RenderTobyTrain(ModelBase par1ModelBase, float par2) {
super(par1ModelBase, par2);
}
protected ResourceLocation getEntityTexture(EntityTobyTrainMob entity) {
return mobTextures;
}
protected ResourceLocation getEntityTexture(Entity entity) {
return this.getEntityTexture((EntityTobyTrainMob)entity);
}
}
Don't use #findGlobalUniqueEntityId or #registerGlobalEntityId - all you need is EntityRegistry#registerModEntity with your IDs starting at 0 and incrementing.
However, that will prevent you from being able to use the vanilla spawn eggs, which I didn't realize you were wanting to do. Pre-1.8, it's not possible to do without using global entity IDs, and that is not recommended. Instead, you have to create your own custom egg Item like I mentioned in my first reply.
Ill try to make my own spawn egg, thanks for your help and advice
Thanks man for your reply, I will try this!