Can you help me with item spawn mob?
Here is my code:
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l)
{
if (!world.isRemote)
{
ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Summoned a Military Teddy Bear!");
EntityLiving entityliving = (EntityLiving)EntityList.createEntityByID(-126, entityplayer.worldObj);
entityliving.setLocationAndAngles(i, j + 1, k, 0.0F, 0.0F);
entityplayer.worldObj.spawnEntityInWorld(entityliving);
entityplayer.swingItem();
itemstack.stackSize--;
}
return true;
}
Can you help me with item spawn mob?
Here is my code:
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l)
{
if (!world.isRemote)
{
ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Summoned a Military Teddy Bear!");
EntityLiving entityliving = (EntityLiving)EntityList.createEntityByID(-126, entityplayer.worldObj);
entityliving.setLocationAndAngles(i, j + 1, k, 0.0F, 0.0F);
entityplayer.worldObj.spawnEntityInWorld(entityliving);
entityplayer.swingItem();
itemstack.stackSize--;
}
return true;
}
Just swinging the item its not spawning.
Try removing the isRemote check.
Rollback Post to RevisionRollBack
“Computers are incredibly fast, accurate and stupid; humans are incredibly slow, inaccurate and brilliant; together they are powerful beyond imagination."
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l)
{
ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Summoned a Military Teddy Bear!");
EntityLiving entityliving = (EntityLiving)EntityList.createEntityByID(-126, entityplayer.worldObj);
entityliving.setLocationAndAngles(i, j + 1, k, 0.0F, 0.0F);
entityplayer.worldObj.spawnEntityInWorld(entityliving);
entityplayer.swingItem();
itemstack.stackSize--;
return true;
}
The isRemote check is there to spawn the entity only on the client, that way you don't get a ghost entity in the server that is running along side the client. I was having issues with ghost entities, and that fixed it for me.
But its doesnt even spawning I tried by name and by ID and still..
Btw i dont think that its even get the method because its not write:
ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Summoned a Military Teddy Bear!");
Oh yeah....onItemUse is out. Either use:
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
return par1ItemStack;
}
or
public boolean tryPlaceIntoWorld(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
return false;
}
java.lang.reflect.InvocationTargetException
Skipping Entity with id -126
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at net.minecraft.src.EntityList.createEntityByID(EntityList.java:118)
at net.minecraft.src.ToyModItemMagicalMilitaryTeddyEmblem.tryPlaceIntoWorld(ToyModItemMagicalMilitaryTeddyEmblem.java:19)
at net.minecraft.src.ItemStack.tryPlaceItemIntoWorld(ItemStack.java:111)
at net.minecraft.src.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:328)
at net.minecraft.client.Minecraft.clickMouse(Minecraft.java:1291)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1701)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:821)
at net.minecraft.client.Minecraft.run(Minecraft.java:751)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Duplicate id value for 16!
at net.minecraft.src.DataWatcher.addObject(DataWatcher.java:41)
at net.minecraft.src.ToyModEntityMilitaryTeddyBear.entityInit(ToyModEntityMilitaryTeddyBear.java:34)
at net.minecraft.src.Entity.<init>(Entity.java:220)
at net.minecraft.src.EntityLiving.<init>(EntityLiving.java:189)
at net.minecraft.src.EntityCreature.<init>(EntityCreature.java:20)
at net.minecraft.src.EntityAgeable.<init>(EntityAgeable.java:7)
at net.minecraft.src.EntityAnimal.<init>(EntityAnimal.java:18)
at net.minecraft.src.EntityTameable.<init>(EntityTameable.java:9)
at net.minecraft.src.ToyModEntityMilitaryTeddyBear.<init>(ToyModEntityMilitaryTeddyBear.java:13)
... 13 more
java.lang.NullPointerException
at net.minecraft.src.ToyModItemMagicalMilitaryTeddyEmblem.tryPlaceIntoWorld(ToyModItemMagicalMilitaryTeddyEmblem.java:20)
at net.minecraft.src.ItemStack.tryPlaceItemIntoWorld(ItemStack.java:111)
at net.minecraft.src.PlayerControllerMP.onPlayerRightClick(PlayerControllerMP.java:328)
at net.minecraft.client.Minecraft.clickMouse(Minecraft.java:1291)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1701)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:821)
at net.minecraft.client.Minecraft.run(Minecraft.java:751)
at java.lang.Thread.run(Unknown Source)
אוג 23, 2012 9:11:49 AM net.minecraft.src.NetworkListenThread networkTick
WARNING: Failed to handle packet: java.lang.NullPointerException
java.lang.NullPointerException
at net.minecraft.src.ToyModItemMagicalMilitaryTeddyEmblem.tryPlaceIntoWorld(ToyModItemMagicalMilitaryTeddyEmblem.java:18)
at net.minecraft.src.ItemStack.tryPlaceItemIntoWorld(ItemStack.java:111)
at net.minecraft.src.ItemInWorldManager.activateBlockOrUseItem(ItemInWorldManager.java:330)
at net.minecraft.src.NetServerHandler.handlePlace(NetServerHandler.java:491)
at net.minecraft.src.Packet15Place.processPacket(Packet15Place.java:75)
at net.minecraft.src.MemoryConnection.processReadPackets(MemoryConnection.java:70)
at net.minecraft.src.NetServerHandler.networkTick(NetServerHandler.java:73)
at net.minecraft.src.NetworkListenThread.networkTick(NetworkListenThread.java:45)
at net.minecraft.src.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:98)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:638)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:553)
at net.minecraft.src.IntegratedServer.tick(IntegratedServer.java:122)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:462)
at net.minecraft.src.ThreadServerApplication.run(ThreadServerApplication.java:17)
Code:
public boolean tryPlaceIntoWorld(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Summoned a Military Teddy Bear!");
EntityLiving entityliving = (EntityLiving)EntityList.createEntityByID(-126, par2EntityPlayer.worldObj);
entityliving.setLocationAndAngles(par5, par4, par6, par3World.rand.nextFloat() * 360.0F, 0.0F);
par2EntityPlayer.worldObj.spawnEntityInWorld(entityliving);
par2EntityPlayer.swingItem();
par1ItemStack.stackSize--;
return true;
}
Im working with forge so Im hoping that it will intergrate the EntityTracker function in the next FML build. However if I read the changelog for the unofficial releases, it seems that they are going to do it differently. Hmmm Anyway Ill bookmark this for future reference. Thanks guys!
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l)
{
ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Summoned a Military Teddy Bear!");
EntityLiving entityliving = (EntityLiving)EntityList.createEntityByID(-126, entityplayer.worldObj);
entityliving.setLocationAndAngles(i, j + 1, k, 0.0F, 0.0F);
entityplayer.worldObj.spawnEntityInWorld(entityliving);
entityplayer.swingItem();
itemstack.stackSize--;
return true;
}
Still not working..
Try this:
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
MovingObjectPosition movingobjectposition = entityplayer.rayTrace(100.0D, 1.0F);
if(movingobjectposition == null)
{
return itemstack;
}
if (movingobjectposition != null)
{
Vec3 vec3d = movingobjectposition.hitVec;
double i = vec3d.xCoord;
double j = vec3d.yCoord;
double k = vec3d.zCoord;
EntityLiving entityliving = (EntityLiving)EntityList.createEntityByID(-126, entityplayer.worldObj);
if (!world.isRemote)
{ entityliving.setLocationAndAngles(i, j + 1, k, 0.0F, 0.0F);
entityplayer.worldObj.spawnEntityInWorld(entityliving);
entityplayer.swingItem();
ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Summoned a Military Teddy Bear!");
}
itemstack.stackSize--;
}
return itemstack;
}
This should spawn the mob wherever you are looking at... if you want to spawn it where the player is at, then change the double vec3d part to entityplayer.posX, ect. If it is in multiplayer, then delete the !world.isRemote if statement. This should fix your problem, if not then it could be a render error or entity tracking error as modLoader does not seem to work for tracking mob entities on its own... You want to register the entity ID and track it if the solution above does not work, and you also want to registerEntity to be above the track entity(i don't think you need the tracking for client if that is what it is for). All of this is basing off of my mod and issues I had with it.
My entity spawns perfectly.. only problem is i can't see it.... i've tried to figure out how to fix it based on post in this thread.. i can't get it...
My entity spawns perfectly.. only problem is i can't see it.... i've tried to figure out how to fix it based on post in this thread.. i can't get it...
Maybe because i'm new to modding..
Anyone can help me? Maybe dumb it down a bit?
I created a new mob and i go into my game, no crashing or anything.. and i can hear it loud and clear.. i used the cow sound and i made it louder than all other mobs.. as soon as i spawn in i hear unusually loud cows.. meaning my mobs are there.. i just cant see them.. anyone know why?
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
{
MovingObjectPosition movingobjectposition = entityplayer.rayTrace(100.0D, 1.0F);
if(movingobjectposition == null)
{
return itemstack;
}
if (movingobjectposition != null)
{
Vec3 vec3d = movingobjectposition.hitVec;
double i = vec3d.xCoord;
double j = vec3d.yCoord;
double k = vec3d.zCoord;
EntityLiving entityliving = (EntityLiving)EntityList.createEntityByID(-126, entityplayer.worldObj);
if (!world.isRemote)
{ entityliving.setLocationAndAngles(i, j + 1, k, 0.0F, 0.0F);
entityplayer.worldObj.spawnEntityInWorld(entityliving);
entityplayer.swingItem();
ModLoader.getMinecraftInstance().thePlayer.addChatMessage("Summoned a Military Teddy Bear!");
}
itemstack.stackSize--;
}
return itemstack;
}
This should spawn the mob wherever you are looking at... if you want to spawn it where the player is at, then change the double vec3d part to entityplayer.posX, ect. If it is in multiplayer, then delete the !world.isRemote if statement. This should fix your problem, if not then it could be a render error or entity tracking error as modLoader does not seem to work for tracking mob entities on its own... You want to register the entity ID and track it if the solution above does not work, and you also want to registerEntity to be above the track entity(i don't think you need the tracking for client if that is what it is for). All of this is basing off of my mod and issues I had with it.
Its gives me an error when i right click:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at net.minecraft.src.EntityList.createEntityByName(EntityList.java:61)
at net.minecraft.src.ToyModItemMagicalMilitaryTeddyEmblem.onItemRightClick(ToyModItemMagicalMilitaryTeddyEmblem.java:29)
at net.minecraft.src.ItemStack.useItemRightClick(ItemStack.java:135)
at net.minecraft.src.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:347)
at net.minecraft.client.Minecraft.clickMouse(Minecraft.java:1317)
at net.minecraft.client.Minecraft.runTick(Minecraft.java:1701)
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:821)
at net.minecraft.client.Minecraft.run(Minecraft.java:751)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Duplicate id value for 16!
at net.minecraft.src.DataWatcher.addObject(DataWatcher.java:41)
at net.minecraft.src.ToyModEntityMilitaryTeddyBear.entityInit(ToyModEntityMilitaryTeddyBear.java:34)
at net.minecraft.src.Entity.<init>(Entity.java:220)
at net.minecraft.src.EntityLiving.<init>(EntityLiving.java:189)
at net.minecraft.src.EntityCreature.<init>(EntityCreature.java:20)
at net.minecraft.src.EntityAgeable.<init>(EntityAgeable.java:7)
at net.minecraft.src.EntityAnimal.<init>(EntityAnimal.java:18)
at net.minecraft.src.EntityTameable.<init>(EntityTameable.java:9)
at net.minecraft.src.ToyModEntityMilitaryTeddyBear.<init>(ToyModEntityMilitaryTeddyBear.java:13)
... 13 more
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at net.minecraft.src.EntityList.createEntityByName(EntityList.java:61)
at net.minecraft.src.ToyModItemMagicalMilitaryTeddyEmblem.onItemRightClick(ToyModItemMagicalMilitaryTeddyEmblem.java:29)
at net.minecraft.src.ItemStack.useItemRightClick(ItemStack.java:135)
at net.minecraft.src.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:285)
at net.minecraft.src.NetServerHandler.handlePlace(NetServerHandler.java:471)
at net.minecraft.src.Packet15Place.processPacket(Packet15Place.java:75)
at net.minecraft.src.MemoryConnection.processReadPackets(MemoryConnection.java:70)
at net.minecraft.src.NetServerHandler.networkTick(NetServerHandler.java:73)
at net.minecraft.src.NetworkListenThread.networkTick(NetworkListenThread.java:45)
at net.minecraft.src.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:98)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:638)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:553)
at net.minecraft.src.IntegratedServer.tick(IntegratedServer.java:122)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:462)
at net.minecraft.src.ThreadServerApplication.run(ThreadServerApplication.java:17)
Caused by: java.lang.IllegalArgumentException: Duplicate id value for 16!
at net.minecraft.src.DataWatcher.addObject(DataWatcher.java:41)
at net.minecraft.src.ToyModEntityMilitaryTeddyBear.entityInit(ToyModEntityMilitaryTeddyBear.java:34)
at net.minecraft.src.Entity.<init>(Entity.java:220)
at net.minecraft.src.EntityLiving.<init>(EntityLiving.java:189)
at net.minecraft.src.EntityCreature.<init>(EntityCreature.java:20)
at net.minecraft.src.EntityAgeable.<init>(EntityAgeable.java:7)
at net.minecraft.src.EntityAnimal.<init>(EntityAnimal.java:18)
at net.minecraft.src.EntityTameable.<init>(EntityTameable.java:9)
at net.minecraft.src.ToyModEntityMilitaryTeddyBear.<init>(ToyModEntityMilitaryTeddyBear.java:13)
... 19 more
אוג 23, 2012 10:49:50 PM net.minecraft.src.NetworkListenThread networkTick
WARNING: Failed to handle packet: java.lang.NullPointerException
java.lang.NullPointerException
at net.minecraft.src.ToyModItemMagicalMilitaryTeddyEmblem.onItemRightClick(ToyModItemMagicalMilitaryTeddyEmblem.java:32)
at net.minecraft.src.ItemStack.useItemRightClick(ItemStack.java:135)
at net.minecraft.src.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:285)
at net.minecraft.src.NetServerHandler.handlePlace(NetServerHandler.java:471)
at net.minecraft.src.Packet15Place.processPacket(Packet15Place.java:75)
at net.minecraft.src.MemoryConnection.processReadPackets(MemoryConnection.java:70)
at net.minecraft.src.NetServerHandler.networkTick(NetServerHandler.java:73)
at net.minecraft.src.NetworkListenThread.networkTick(NetworkListenThread.java:45)
at net.minecraft.src.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:98)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:638)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:553)
at net.minecraft.src.IntegratedServer.tick(IntegratedServer.java:122)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:462)
at net.minecraft.src.ThreadServerApplication.run(ThreadServerApplication.java:17)
I created a new mob and i go into my game, no crashing or anything.. and i can hear it loud and clear.. i used the cow sound and i made it louder than all other mobs.. as soon as i spawn in i hear unusually loud cows.. meaning my mobs are there.. i just cant see them.. anyone know why?
Render error probably... Make sure you have a render class an do something like this in your main mod class:
public void addRenderer(Map map)
{
map.put(EntityZombie.class, new RenderBiped(new ModelZombie(), 0.5F));
}
what that does is when the entity spawns, it will render and create the model of the entity that you created. All you need to do is to change the classes there to whatever you want based on your mob. If you already have this in your code try looking at tutorials that are updated because I don't think it is an entity error if the sound and stuff work. Look up some mob tutorials is all I can say..I know TechGuy had a great tutorial list, but the issue you are looking for is not updated as far as I believe, but you can still use that as a reference. (also post code if you have an issue as we have know idea what is wrong without the code... all we can do is just guess). Link to his tutorial: http://www.minecraft...ding-tutorials/
Render error probably... Make sure you have a render class an do something like this in your main mod class:
public void addRenderer(Map map)
{
map.put(EntityZombie.class, new RenderBiped(new ModelZombie(), 0.5F));
}
what that does is when the entity spawns, it will render and create the model of the entity that you created. All you need to do is to change the classes there to whatever you want based on your mob. If you already have this in your code try looking at tutorials that are updated because I don't think it is an entity error if the sound and stuff work. Look up some mob tutorials is all I can say..I know TechGuy had a great tutorial list, but the issue you are looking for is not updated as far as I believe, but you can still use that as a reference. (also post code if you have an issue as we have know idea what is wrong without the code... all we can do is just guess). Link to his tutorial: http://www.minecraft...ding-tutorials/
Nevermind i fixed that problem Thanks!
But i want to have limited distance an only when i right click the ground.. not everywhere.
Render error probably... Make sure you have a render class an do something like this in your main mod class:
public void addRenderer(Map map)
{
map.put(EntityZombie.class, new RenderBiped(new ModelZombie(), 0.5F));
}
what that does is when the entity spawns, it will render and create the model of the entity that you created. All you need to do is to change the classes there to whatever you want based on your mob. If you already have this in your code try looking at tutorials that are updated because I don't think it is an entity error if the sound and stuff work. Look up some mob tutorials is all I can say..I know TechGuy had a great tutorial list, but the issue you are looking for is not updated as far as I believe, but you can still use that as a reference. (also post code if you have an issue as we have know idea what is wrong without the code... all we can do is just guess). Link to his tutorial: http://www.minecraft...ding-tutorials/
I added that code you provided and i get an error that renderbiped is undefined.. that happened when i changed the Zombie Model to the one i created with techne
The ground thing I have no idea as in my mod some things you can only use on ground and others anywhere (I did it on accident)... try looking in the EntityFireball for a solution there cause that will only spawn if you are looking at the ground for some reason (It is an issue in your entity class and how it handles spawning I think).
I added I added that code you provided and i get an error that renderbiped is undefined.. that happened when i changed the Zombie Model to the one i created with techne
You have to change/make the render class too per mob.
Render error probably... Make sure you have a render class an do something like this in your main mod class:
public void addRenderer(Map map)
{
map.put(EntityZombie.class, new RenderBiped(new ModelZombie(), 0.5F));
}
what that does is when the entity spawns, it will render and create the model of the entity that you created. All you need to do is to change the classes there to whatever you want based on your mob. If you already have this in your code try looking at tutorials that are updated because I don't think it is an entity error if the sound and stuff work. Look up some mob tutorials is all I can say..I know TechGuy had a great tutorial list, but the issue you are looking for is not updated as far as I believe, but you can still use that as a reference. (also post code if you have an issue as we have know idea what is wrong without the code... all we can do is just guess). Link to his tutorial: http://www.minecraft...ding-tutorials/
That didn't fix anything.. at all
Here are my codes
mod_CobbleStoneMob:
package net.minecraft.src;
import java.util.Map;
import java.util.Random;
public class mod_CobbleStoneMob extends BaseMod{
public void load(){
/** Mob **/
//tells what class the entity is in, sets name, gets a unique id for the mob
//what class the entity is in , The Item weight, minGroup #, max Group #, Creature type (creature, monster, waterCreature)
ModLoader.addSpawn(EntityCobbleStoneMOB.class, 15, 5, 8, EnumCreatureType.creature);
ModLoader.registerEntityID(EntityCobbleStoneMOB.class, "EntityCobbleStoneMOB", 19);
}
//renders the entity
public void addRenderer(Map map){
//puts the Entity on screen, renders it as a biped using a the model of a biped
map.put(EntityCobbleStoneMOB.class, new RenderCobbleStoneMob(new ModelCobbleStoneMob(), 0.5F));
ModLoader.addEntityTracker(this, EntityCobbleStoneMOB.class, 19, 64, 20,true);
}
//mod version
public String getVersion(){
return "v1.3.1";
}
}
CobbleStoneMOD:
package net.minecraft.src;
import java.util.Random;
public class EntityCobbleStoneMOB extends EntityAnimal
{
public EntityCobbleStoneMOB(World world)
{
super(world);
texture = "/Items/EntityCobbleStoneMOB";
setSize(5.5F, 6.9F); // this sets the hit area of the mob
getNavigator().func_48664_a(true);
tasks.addTask(0, new EntityAISwimming(this));
tasks.addTask(1, new EntityAIPanic(this, 0.38F));
tasks.addTask(2, new EntityAIMate(this, 0.2F));
tasks.addTask(3, new EntityAITempt(this, 0.25F, Item.wheat.shiftedIndex, false));
tasks.addTask(4, new EntityAIFollowParent(this, 0.25F));
tasks.addTask(5, new EntityAIWander(this, 0.2F));
tasks.addTask(6, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 6F));
tasks.addTask(7, new EntityAILookIdle(this));
}
public boolean isAIEnabled()
{
return true;
}
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
super.writeEntityToNBT(nbttagcompound); // this saves the mob to disk
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
super.readEntityFromNBT(nbttagcompound); // this loads the mob from disk
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "mob.cow";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.cow";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.cowhurt";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 5.0F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected Block getDropBlockId()
{
return Block.cobblestone;
}
@Override
public EntityAnimal spawnBabyAnimal(EntityAnimal entityanimal)
{
return new EntityCobbleStoneMOB(worldObj);// TODO Auto-generated method stub
}
@Override
public int getMaxHealth()
{
// TODO Auto-generated method stub
return 20;
}
public String getVersion()
{
return "tutorial mod v0.6";
}
}
And the Render/Model files aren't the problem, i used the Biped Render/Model files and still, i can hear them but not see them.I decided to throw in the render/model files JUST IN CASE
ModelCobbleStoneMob
// Date: 8/23/2012 12:20:59 PM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX
package net.minecraft.src;
public class ModelCobbleStoneMob extends ModelBase
{
//fields
ModelRenderer CobbleStone;
public ModelCobbleStoneMob()
{
textureWidth = 128;
textureHeight = 128;
CobbleStone = new ModelRenderer(this, 0, 0);
CobbleStone.addBox(0F, 0F, 0F, 16, 16, 16);
CobbleStone.setRotationPoint(-8F, 8F, -8F);
CobbleStone.setTextureSize(128, 128);
CobbleStone.mirror = true;
setRotation(CobbleStone, 0F, 0F, 0F);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5);
CobbleStone.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5);
}
}
package net.minecraft.src;
import java.util.Map;
import java.util.Random;
public class mod_CobbleStoneMob extends BaseMod{
public void load(){
/** Mob **/
//tells what class the entity is in, sets name, gets a unique id for the mob
//what class the entity is in , The Item weight, minGroup #, max Group #, Creature type (creature, monster, waterCreature)
ModLoader.addSpawn(EntityCobbleStoneMOB.class, 15, 5, 8, EnumCreatureType.creature);
ModLoader.registerEntityID(EntityCobbleStoneMOB.class, "EntityCobbleStoneMOB", 19);
}
//renders the entity
public void addRenderer(Map map){
//puts the Entity on screen, renders it as a biped using a the model of a biped
map.put(EntityCobbleStoneMOB.class, new RenderCobbleStoneMob(new ModelCobbleStoneMob(), 0.5F));
ModLoader.addEntityTracker(this, EntityCobbleStoneMOB.class, 19, 64, 20,true);
}
//mod version
public String getVersion(){
return "v1.3.1";
}
}
CobbleStoneMOD:
package net.minecraft.src;
import java.util.Random;
public class EntityCobbleStoneMOB extends EntityAnimal
{
public EntityCobbleStoneMOB(World world)
{
super(world);
texture = "/Items/EntityCobbleStoneMOB";
setSize(5.5F, 6.9F); // this sets the hit area of the mob
getNavigator().func_48664_a(true);
tasks.addTask(0, new EntityAISwimming(this));
tasks.addTask(1, new EntityAIPanic(this, 0.38F));
tasks.addTask(2, new EntityAIMate(this, 0.2F));
tasks.addTask(3, new EntityAITempt(this, 0.25F, Item.wheat.shiftedIndex, false));
tasks.addTask(4, new EntityAIFollowParent(this, 0.25F));
tasks.addTask(5, new EntityAIWander(this, 0.2F));
tasks.addTask(6, new EntityAIWatchClosest(this, net.minecraft.src.EntityPlayer.class, 6F));
tasks.addTask(7, new EntityAILookIdle(this));
}
public boolean isAIEnabled()
{
return true;
}
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
super.writeEntityToNBT(nbttagcompound); // this saves the mob to disk
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
super.readEntityFromNBT(nbttagcompound); // this loads the mob from disk
}
/**
* Returns the sound this mob makes while it's alive.
*/
protected String getLivingSound()
{
return "mob.cow";
}
/**
* Returns the sound this mob makes when it is hurt.
*/
protected String getHurtSound()
{
return "mob.cow";
}
/**
* Returns the sound this mob makes on death.
*/
protected String getDeathSound()
{
return "mob.cowhurt";
}
/**
* Returns the volume for the sounds this mob makes.
*/
protected float getSoundVolume()
{
return 5.0F;
}
/**
* Returns the item ID for the item the mob drops on death.
*/
protected Block getDropBlockId()
{
return Block.cobblestone;
}
@Override
public EntityAnimal spawnBabyAnimal(EntityAnimal entityanimal)
{
return new EntityCobbleStoneMOB(worldObj);// TODO Auto-generated method stub
}
@Override
public int getMaxHealth()
{
// TODO Auto-generated method stub
return 20;
}
public String getVersion()
{
return "tutorial mod v0.6";
}
}
And the Render/Model files aren't the problem, i used the Biped Render/Model files and still, i can hear them but not see them.
I decided to throw in the render/model files JUST IN CASE
ModelCobbleStoneMob
// Date: 8/23/2012 12:20:59 PM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX
package net.minecraft.src;
public class ModelCobbleStoneMob extends ModelBase
{
//fields
ModelRenderer CobbleStone;
public ModelCobbleStoneMob()
{
textureWidth = 128;
textureHeight = 128;
CobbleStone = new ModelRenderer(this, 0, 0);
CobbleStone.addBox(0F, 0F, 0F, 16, 16, 16);
CobbleStone.setRotationPoint(-8F, 8F, -8F);
CobbleStone.setTextureSize(128, 128);
CobbleStone.mirror = true;
setRotation(CobbleStone, 0F, 0F, 0F);
}
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
super.render(entity, f, f1, f2, f3, f4, f5);
setRotationAngles(f, f1, f2, f3, f4, f5);
CobbleStone.render(f5);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
{
super.setRotationAngles(f, f1, f2, f3, f4, f5);
}
}
It is not an entity problem because you can hear the entity(which the sounds are in the entity class) so the only issue is the rendering because it is spawning fine if you can hear it. I don't use custom mobs(change entities for other mobs already in game to be use as your own) so I cant say... I know for a fact that you need what I told you to put in so that was not the only issue... from everything else I see it look like you have the tracker in the render method, and you do not want that in there(put that in load)(I doubt that is the issue but it could be for all I know). Try asking this (with your code) in a tutorial that is up to date that has mob tutorials as they might know as I don't know custom rendering as I haven't done that in my mod yet... Sorry if I wan't any help there...
Here is my code:
Just swinging the item its not spawning.
Try removing the isRemote check.
together they are powerful beyond imagination."
Still not working..
Btw i dont think that its even get the method because its not write:
Oh yeah....onItemUse is out. Either use:
or
Code:
Try this:
Maybe because i'm new to modding..
Anyone can help me? Maybe dumb it down a bit?
I created a new mob and i go into my game, no crashing or anything.. and i can hear it loud and clear.. i used the cow sound and i made it louder than all other mobs.. as soon as i spawn in i hear unusually loud cows.. meaning my mobs are there.. i just cant see them.. anyone know why?
Its gives me an error when i right click:
Render error probably... Make sure you have a render class an do something like this in your main mod class:
what that does is when the entity spawns, it will render and create the model of the entity that you created. All you need to do is to change the classes there to whatever you want based on your mob. If you already have this in your code try looking at tutorials that are updated because I don't think it is an entity error if the sound and stuff work. Look up some mob tutorials is all I can say..I know TechGuy had a great tutorial list, but the issue you are looking for is not updated as far as I believe, but you can still use that as a reference. (also post code if you have an issue as we have know idea what is wrong without the code... all we can do is just guess). Link to his tutorial:
http://www.minecraft...ding-tutorials/
Nevermind i fixed that problem Thanks!
But i want to have limited distance an only when i right click the ground.. not everywhere.
I am not 100% sure, but if you want shorter distance change the 100.0D to whatever you want here:
The ground thing I have no idea as in my mod some things you can only use on ground and others anywhere (I did it on accident)... try looking in the EntityFireball for a solution there cause that will only spawn if you are looking at the ground for some reason (It is an issue in your entity class and how it handles spawning I think).
You have to change/make the render class too per mob.
That didn't fix anything.. at all
Here are my codes
mod_CobbleStoneMob:
CobbleStoneMOD:
And the Render/Model files aren't the problem, i used the Biped Render/Model files and still, i can hear them but not see them.I decided to throw in the render/model files JUST IN CASE
ModelCobbleStoneMob
Render
It is not an entity problem because you can hear the entity(which the sounds are in the entity class) so the only issue is the rendering because it is spawning fine if you can hear it. I don't use custom mobs(change entities for other mobs already in game to be use as your own) so I cant say... I know for a fact that you need what I told you to put in so that was not the only issue... from everything else I see it look like you have the tracker in the render method, and you do not want that in there(put that in load)(I doubt that is the issue but it could be for all I know). Try asking this (with your code) in a tutorial that is up to date that has mob tutorials as they might know as I don't know custom rendering as I haven't done that in my mod yet... Sorry if I wan't any help there...