Where is the code for adding the mod to the game (not your full mod_ file just the part where you set up the mobs). I think you are missing the map.put() line, or you indicate the wrong model file.
I have same problem but i've put my image in EVERY minecraft.jar file I found but still my buddy is blank with G1 in black on his head ;(
Edit: Found it.. In my code I had called the image with lower case letters and the image was uppercase
But now another question: How can I make my mob spawn at day and make it attack out of its self? I now have EnumCreatureType.monster and I extend EntityZombie in my entity code but thos two(EnumCreatureType.monste and EntityZombie) only makes them spawn in night and burn at day right?
And when he moves the leggs and the arms won't move.. They are just sliding over the ground...
Render:
package net.minecraft.src;
import java.util.*;
import java.util.Map;
public class mod_AddSpawnMob extends BaseMod
{
public mod_AddSpawnMob()
{
ModLoader.RegisterEntityID(mod_HerobrineEntity.class, "Herobrine", ModLoader.getUniqueEntityId());
ModLoader.AddSpawn(mod_HerobrineEntity.class, 16, EnumCreatureType.monster);
}
// RENDERERS
public void AddRenderer(Map map)
{
map.put(mod_HerobrineEntity.class, new mod_HerobrineRender(new mod_HerobrineModel(), 0.5F));
}
public String Version()
{
return "Herobrine V1.1 MC v1.7.3";
}
}
Entity:
package net.minecraft.src;
public class mod_HerobrineEntity extends EntityZombie
{
public mod_HerobrineEntity(World world)
{
super(world);
texture = "/mob/herobrine.png";
setSize(0.9F,1.3F);
moveSpeed = 1.1F;
attackStrength = 20;
health = 20;
}
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
super.writeEntityToNBT(nbttagcompound);
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
super.readEntityFromNBT(nbttagcompound);
}
protected String getLivingSound()
{
return "mob.char";
}
protected String getHurtSound()
{
return "mob.char";
}
protected String getDeathSound()
{
return "mob.char";
}
protected float getSoundVolume()
{
return 0.4F;
}
protected int getDropItemId()
{
return Item.flintAndSteel.shiftedIndex;
}
public boolean interact(EntityPlayer entityplayer)
{
//can use this for right click reactions
return false;
}
}
I have not gotten into spawning, besides forcing a spawn. I'm guessing you could make a time check in your made code, find and area around the player and force a spawn.
The creature type tells how it spawns to the game engine. As to the burning and the animation stuff, well, you had it extend the zombie. It has the same behavour. You will need to look at the zombie code and find the flag for burning in sunlight and turn that to off in your code.
As for the movement, you extend modelbase, which has no animation set to it. Look in the modelquadruped file in the set rotation section. it will show you what you need.
On that note, I think I got the animation stuff worked out. Will be offline for a bit while I make a test vid.
I think that error means that you forgot a } in your mod_Anibus file....
Yeah...that was it.....
*FACEPALM* Derp o_o.
I dont suppose you know how to add a level up system and a healthbar for a tamed pet now do you? If you do, maybe that could be your next(or next next tutorial since you said your already fumbling around with a tutorial) tutorial. I request it and custom animations.....Yeah im asking for too much now am i xD?
Rollback Post to RevisionRollBack
Famous Nyan seed has caves now along with 3 other special maps for MCPE! Check here for downloads: http://tinyurl.com/c75ax6y
I dont suppose you know how to add a level up system and a healthbar for a tamed pet now do you? If you do, maybe that could be your next(or next next tutorial since you said your already fumbling around with a tutorial) tutorial. I request it and custom animations.....Yeah im asking for too much now am i xD?
Just about done with "added" animations. I guess since I was overriding the wing flap, I could possibly override walking but I would have to check for walking and the direction, though that would be quite a bit of code... Not really looking to re-invent the wheel. BUT, what I will be showing is how to add an new animation and how to trigger it.
Just about done with "added" animations. I guess since I was overriding the wing flap, I could possibly override walking but I would have to check for walking and the direction, though that would be quite a bit of code... Not really looking to re-invent the wheel. BUT, what I will be showing is how to add an new animation and how to trigger it.
i got a problem, no errors and it says Mod Loaded when launched, but i dont see anibus anywhere. And dont tell me to use spawn block because i do not get how to setup the coding in the main mod file. Confusing to me...
Do you need to see my main mod file or should i keep looking?(Been searching for awhile >.<)
EDIT: Yeah, Anibus isnt spawning.... The most patient i ever been
Main mod file:
package net.minecraft.src;
import java.util.Map;
public class mod_Anibus extends BaseMod
{
public void JWorldAddMobs()
{
ModLoader.RegisterEntityID(JWorld_AnibusEntity.class, "Anibus",
ModLoader.getUniqueEntityId());
ModLoader.AddSpawn(JWorld_AnibusEntity.class, 100, EnumCreatureType.creature);
}
public void AddRenderer(Map map)
{
map.put(JWorld_AnibusEntity.class, new JWorld_AnibusRender(new JWorld_AnibusModel(), 0.5F));
}
public String Version()
{
return"Anibus V1.1 MC v1.7.3";
}
Recompile gives no errors, yet the mob doesnt spawn, but the startup says its loaded...Help.
Rollback Post to RevisionRollBack
Famous Nyan seed has caves now along with 3 other special maps for MCPE! Check here for downloads: http://tinyurl.com/c75ax6y
Yeah thats what it is doing (overriding it for the entity), do you know how to fix this? I have been playing around with it for ages and i cant seem to get it to work :unsure.gif:
Use:
protected String name = "";
When you set something to public, it affects all instances, while protected makes it only affect the one instance.
i got a problem, no errors and it says Mod Loaded when launched, but i dont see anibus anywhere. And dont tell me to use spawn block because i do not get how to setup the coding in the main mod file. Confusing to me...
Do you need to see my main mod file or should i keep looking?(Been searching for awhile >.<)
EDIT: Yeah, Anibus isnt spawning.... The most patient i ever been
Main mod file:
package net.minecraft.src;
import java.util.Map;
public class mod_Anibus extends BaseMod
{
public void JWorldAddMobs()
{
ModLoader.RegisterEntityID(JWorld_AnibusEntity.class, "Anibus",
ModLoader.getUniqueEntityId());
ModLoader.AddSpawn(JWorld_AnibusEntity.class, 100, EnumCreatureType.creature);
}
public void AddRenderer(Map map)
{
map.put(JWorld_AnibusEntity.class, new JWorld_AnibusRender(new JWorld_AnibusModel(), 0.5F));
}
public String Version()
{
return"Anibus V1.1 MC v1.7.3";
}
Recompile gives no errors, yet the mob doesnt spawn, but the startup says its loaded...Help.
Did you wander around or just wait? I'm not sure what to tell you. The main reason I made the spawn block is cause the same was happening to me. Now I seem my horse, anibus, and flything everywhere, though the gnome seems to be less frequent.
you could also run a bit of code in your main mod file to spawn in near where the player starts, though I don't know how to check the height of the ground to makesure it's not in the ground... let me try and code up something quick...
Ok, all you dudes with spawning problems, here is a quick bit that will spawn a mob in front of you when you first enter the game:
private boolean didspawn = false;
public boolean OnTickInGame(Minecraft mc)
{
worldObj = mc.theWorld;
EntityPlayer theplayer = mc.thePlayer;
if(theplayer != null && !didspawn) //wait for the player to be made, and then spawn near him
{
//spawn a char near the player
EntityLiving entityliving = (EntityLiving)EntityList.createEntityInWorld("Anibus", worldObj);
entityliving.setLocationAndAngles(theplayer.posX + 0, theplayer.posY + 1, theplayer.posZ - 4, 0F, 0F); //x, y, z, yaw, pitch
worldObj.entityJoinedWorld(entityliving);
didspawn = !didspawn;
}
}
This goes in your main mod_ .java file. In my case it would be mod_JWorld.java. If you are already using this method, just add to it. Notice the variable declairation at the begining.
I just did this and he spawned right infront of me. For a good result, use test as your seed for the world creation. Start the game and turn to your right.
Replace "Anibus" with your mob's registered entity ID taken from this line of code:
When you set something to public, it affects all instances, while protected makes it only affect the one instance.
is that what protected means? I know public is accessable outside the class, such as when you make an instance of that class in another java file, you can access/change that variable. Private means you cannot. I never really go the protected.
Ok, all you dudes with spawning problems, here is a quick bit that will spawn a mob in front of you when you first enter the game:
private boolean didspawn = false;
public boolean OnTickInGame(Minecraft mc)
{
worldObj = mc.theWorld;
EntityPlayer theplayer = mc.thePlayer;
if(theplayer != null && !didspawn) //wait for the player to be made, and then spawn near him
{
//spawn a char near the player
EntityLiving entityliving = (EntityLiving)EntityList.createEntityInWorld("Anibus", worldObj);
entityliving.setLocationAndAngles(theplayer.posX + 0, theplayer.posY + 1, theplayer.posZ - 4, 0F, 0F); //x, y, z, yaw, pitch
worldObj.entityJoinedWorld(entityliving);
didspawn = !didspawn;
}
}
This goes in your main mod_ .java file. In my case it would be mod_JWorld.java. If you are already using this method, just add to it. Notice the variable declairation at the begining.
I just did this and he spawned right infront of me. For a good result, use test as your seed for the world creation. Start the game and turn to your right.
Replace "Anibus" with your mob's registered entity ID taken from this line of code:
There you go. I will post a video soon. It still looks around on it's own, and in turn, forces you to look in the same direction.
One last note for the more advanced modders. If you are going to have several mountable animals, you may want to make the a class that you extend for your rideable mobs. To make sure that the scale size is passed to this to fix the hit box.
I figured out that if you add another line to onUpdate() to control rotation pitch, you can force the mob to not turn its head (or at least that appears to happen in my testing). Also, I multiplied by .1F because otherwise the turning was far too sensitive.
I figured out that if you add another line to onUpdate() to control rotation pitch, you can force the mob to not turn its head (or at least that appears to happen in my testing). Also, I multiplied by .1F because otherwise the turning was far too sensitive.
I had that, but ya it was hard to control. Nice addition. But it still doesn't turn all the time to where you are looking. It sometimes moves sideways. Still need to work on that.
yup, but inside the last } . Really you can put it anywhere in the class definition.
Doing so gives me 4 errors....
== ERRORS FOUND ==
src\minecraft\net\minecraft\src\mod_Anibus.java:31: cannot find symbol
symbol : class Minecraft
location: class net.minecraft.src.mod_Anibus
public boolean OnTickInGame(Minecraft mc)
^
src\minecraft\net\minecraft\src\mod_Anibus.java:33: cannot find symbol
symbol : variable worldObj
location: class net.minecraft.src.mod_Anibus
worldObj = mc.theWorld;
^
src\minecraft\net\minecraft\src\mod_Anibus.java:38: cannot find symbol
symbol : variable worldObj
location: class net.minecraft.src.mod_Anibus
EntityLiving entityliving = (EntityLiving)EntityList.createEntityInWorld("Anibus
", worldObj);
^
src\minecraft\net\minecraft\src\mod_Anibus.java:40: cannot find symbol
symbol : variable worldObj
location: class net.minecraft.src.mod_Anibus
worldObj.entityJoinedWorld(entityliving);
^
4 errors
Also, does this fix the problem by making it so that the mob will always spawn near the player? Because i dont want the mob always spawning near me/user. That would be annoying, seeing them in caves and unusual places :/
Rollback Post to RevisionRollBack
Famous Nyan seed has caves now along with 3 other special maps for MCPE! Check here for downloads: http://tinyurl.com/c75ax6y
== ERRORS FOUND ==
src\minecraft\net\minecraft\src\mod_Anibus.java:31: cannot find symbol
symbol : class Minecraft
location: class net.minecraft.src.mod_Anibus
public boolean OnTickInGame(Minecraft mc)
^
src\minecraft\net\minecraft\src\mod_Anibus.java:33: cannot find symbol
symbol : variable worldObj
location: class net.minecraft.src.mod_Anibus
worldObj = mc.theWorld;
^
src\minecraft\net\minecraft\src\mod_Anibus.java:38: cannot find symbol
symbol : variable worldObj
location: class net.minecraft.src.mod_Anibus
EntityLiving entityliving = (EntityLiving)EntityList.createEntityInWorld("Anibus
", worldObj);
^
src\minecraft\net\minecraft\src\mod_Anibus.java:40: cannot find symbol
symbol : variable worldObj
location: class net.minecraft.src.mod_Anibus
worldObj.entityJoinedWorld(entityliving);
^
4 errors
Also, does this fix the problem by making it so that the mob will always spawn near the player? Because i dont want the mob always spawning near me/user. That would be annoying, seeing them in caves and unusual places :/
Showing your mod_Anibus file would help. Do you have a declaration of the variable worldObj in the file? And yes, this makes it so the creature will always spawn next to you whenever you load into a world. Its simply for testing purposes to make sure the mob is spawning/appears correctly etc.
Custom Animations
Here is a little teaser while I write up the tutorial. Let's watch Anibus do some jumping jacks. Kind of. :wink.gif:
(BTW, I'll fix his snout and ears later....)
Ok, now to the code stuff. Again, this is a bit more advance, and an understanding about 3D rotations. In anycase, thanks to my new best friend slant, I got this working. First off, we will look at setting up the call for the movement. Entity Java File
There are several ways you can do this, I am triggering it with an interaction (right) click. To manage the rotation, I am using a public variable armrotation. Public, becuase we will be checkin this value for the rotation. Here is the variable, and the interaction (existing super class) method:
Simple. You click on him, the angle changes to 1.570796F (90 degrees)if it is 0, or to 0 if it's already greater than 0. Simple logic. You could get fancy and also use the onLivingUpdate() method, just make sure to call super.onLivingUpdate(); in there, or the mob won't move. Hmm, maybe that's what's needed for the mount count... enough of that... In anycase, you could increment this value during the onLivingUpdate() mehtod, until it hits 1.57, then rotate it back. That's up to you. Let's move on to the Model file. Model java file
This is where you let it know what is moving. Remember that the rotation is based on it's rotation point (seen better in Techne). Also remeber that if certain rotations should be mirrored on the other side. I do this here. Here is a new method added:
As you can see this method takes a float variable pass, and appiles it to the leg1.rotationAngleZ. With this model, leg1 and 2 are the arms (from the modelquadruped as the super class this extends). Note that I made the rotation for the other arm negative. This makes both arms go out. Simple enough. Now for the part that gave me the most trouble. the render file Render java file
This was trial and error, and if someone else knows a better/cleaner method please let me know. Now I had to rebuild my render file for Anibus, do issues I was having. I have (hopefully) streamlined it a bit. There are still methods for render java files that I don't understand, but these will let you do what you need. I'm going to give the whole file first, then talk about the parts:
I do it this way, because they are called in in different methods here, and I need to have them available in other methods. Private because they are only needed here. In the constructor, we are passed a ModelBase object, which I will cast to my Anibus model type. I can do this because I am sure that my class is being passed as seen in this line from my mod_JWorld.java file :
map.put(JWorld_AnibusEntity.class, new JWorld_AnibusRender(new JWorld_AnibusModel(), 0.5F));
(This is just to help you understand why I can do this, DO NOT add this line to your render java file)
So we come to this line in the constructor:
holdModel = (JWorld_AnibusModel) modelbase;
Even though the object class of modelbase is ModelBase, I can still cast it to my JWorldAnibusModel by forcing the cast like this. If the object passed was not of the class JWorldAnibusModel this would probably crash, or error out when the game is run, but as shown above, we do pass my anibus model class. This is needed to run that method we created in the model class.
The next method is where we can make or call to change the rotation. Let's take a closer look:
if you look to the bottom of the code, you can see that this method is called by the doRender and the doRenderLiving mehtods. I'm sure they are both needed, and I did not create this flow or format. Just go with it. In any case of the variables passed, only the our entity object is needed. Also I could not tell you what the others are for. So the fisrt thing I do is to grab the entity into my holdEnt object. I didn't have to cast it, since it was already of the class needed. This may be able to be dropped, but I wasn't sure if it was needed elsewhere. It is important to leave the super.doRenderLiving call here, and add your animation stuff after. After becase if something is set by doRenderLiving, you want your changes to be applied after.
So here we come down to the line that does it all:
holdModel.ArmsUp(holdEnt.armangle);
This is why we needed those 2 objects. Fisrt, we need the model object so we can call the rotation method. We need the entity object to get the value to pass to the model's rotation method.
There you go. This is a basic (yet still advanced) example of how to do this. I'm pretty sure you could move parts of the mob around and such. It would take a bit of work, but you could do multi joint animations by moving the rotation points, but I leave that up to you. Happy modding.
package net.minecraft.src;
import java.util.Map;
public class mod_Anibus extends BaseMod
{
public void JWorldAddMobs()
{
ModLoader.RegisterEntityID(JWorld_AnibusEntity.class, "Anibus",
ModLoader.getUniqueEntityId());
ModLoader.AddSpawn(JWorld_AnibusEntity.class, 100, EnumCreatureType.creature);
}
public void AddRenderer(Map map)
{
map.put(JWorld_AnibusEntity.class, new JWorld_AnibusRender(new JWorld_AnibusModel(), 0.5F));
}
public String Version()
{
return"Anibus V1.1 MC v1.7.3";
}
private boolean didspawn = false;
public boolean OnTickInGame(Minecraft mc)
{
worldObj = mc.theWorld;
EntityPlayer theplayer = mc.thePlayer;
if(theplayer != null && !didspawn) //wait for the player to be made, and then spawn near him
{
//spawn a char near the player
EntityLiving entityliving = (EntityLiving)EntityList.createEntityInWorld("Anibus", worldObj);
entityliving.setLocationAndAngles(theplayer.posX + 0, theplayer.posY + 1, theplayer.posZ - 4, 0F, 0F); //x, y, z, yaw, pitch
worldObj.entityJoinedWorld(entityliving);
didspawn = !didspawn;
}
}
}
@Inlanoche....I crave to know the custom animations *drools* (Dont rush the tutorial through though!)
Rollback Post to RevisionRollBack
Famous Nyan seed has caves now along with 3 other special maps for MCPE! Check here for downloads: http://tinyurl.com/c75ax6y
public void AddRenderer(Map map)
{ map.put(JWorld_AnibusEntity.class, new JWorld_AnibusRender(new JWorld_AnibusModel(), 0.5F));
}
The above are underlined as warning's in my Eclipse and the warning is: "Map is a raw type. References to generic type Map<K,V> should be parameterized."
And worldObj in the "public boolean OnTickInGame" has an error "worldObj cannot be resolved into a variable".
Know any fixes and is the warnings ok to go on with?
Where is the code for adding the mod to the game (not your full mod_ file just the part where you set up the mobs). I think you are missing the map.put() line, or you indicate the wrong model file.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
I have not gotten into spawning, besides forcing a spawn. I'm guessing you could make a time check in your made code, find and area around the player and force a spawn.
The creature type tells how it spawns to the game engine. As to the burning and the animation stuff, well, you had it extend the zombie. It has the same behavour. You will need to look at the zombie code and find the flag for burning in sunlight and turn that to off in your code.
As for the movement, you extend modelbase, which has no animation set to it. Look in the modelquadruped file in the set rotation section. it will show you what you need.
On that note, I think I got the animation stuff worked out. Will be offline for a bit while I make a test vid.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
is your texture a .png?
Yeah...that was it.....
*FACEPALM* Derp o_o.
I dont suppose you know how to add a level up system and a healthbar for a tamed pet now do you? If you do, maybe that could be your next(or next next tutorial since you said your already fumbling around with a tutorial) tutorial. I request it and custom animations.....Yeah im asking for too much now am i xD?
Just about done with "added" animations. I guess since I was overriding the wing flap, I could possibly override walking but I would have to check for walking and the direction, though that would be quite a bit of code... Not really looking to re-invent the wheel. BUT, what I will be showing is how to add an new animation and how to trigger it.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
i got a problem, no errors and it says Mod Loaded when launched, but i dont see anibus anywhere. And dont tell me to use spawn block because i do not get how to setup the coding in the main mod file. Confusing to me...
Do you need to see my main mod file or should i keep looking?(Been searching for awhile >.<)
EDIT: Yeah, Anibus isnt spawning.... The most patient i ever been
Main mod file:
Recompile gives no errors, yet the mob doesnt spawn, but the startup says its loaded...Help.
Use:
When you set something to public, it affects all instances, while protected makes it only affect the one instance.
Did you wander around or just wait? I'm not sure what to tell you. The main reason I made the spawn block is cause the same was happening to me. Now I seem my horse, anibus, and flything everywhere, though the gnome seems to be less frequent.
you could also run a bit of code in your main mod file to spawn in near where the player starts, though I don't know how to check the height of the ground to makesure it's not in the ground... let me try and code up something quick...
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
This goes in your main mod_ .java file. In my case it would be mod_JWorld.java. If you are already using this method, just add to it. Notice the variable declairation at the begining.
I just did this and he spawned right infront of me. For a good result, use test as your seed for the world creation. Start the game and turn to your right.
Replace "Anibus" with your mob's registered entity ID taken from this line of code:
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
is that what protected means? I know public is accessable outside the class, such as when you make an instance of that class in another java file, you can access/change that variable. Private means you cannot. I never really go the protected.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
Wait wait wait, where do you put this exactly in the main_mod file? Do you just add on to it at the bottom?
I figured out that if you add another line to onUpdate() to control rotation pitch, you can force the mob to not turn its head (or at least that appears to happen in my testing). Also, I multiplied by .1F because otherwise the turning was far too sensitive.
Here is my code:
yup, but inside the last } . Really you can put it anywhere in the class definition.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
The same way I did the spawnblock GUI. the interact method.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
I had that, but ya it was hard to control. Nice addition. But it still doesn't turn all the time to where you are looking. It sometimes moves sideways. Still need to work on that.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
Doing so gives me 4 errors....
Also, does this fix the problem by making it so that the mob will always spawn near the player? Because i dont want the mob always spawning near me/user. That would be annoying, seeing them in caves and unusual places :/
Showing your mod_Anibus file would help. Do you have a declaration of the variable worldObj in the file? And yes, this makes it so the creature will always spawn next to you whenever you load into a world. Its simply for testing purposes to make sure the mob is spawning/appears correctly etc.
Here is a little teaser while I write up the tutorial. Let's watch Anibus do some jumping jacks. Kind of. :wink.gif:
(BTW, I'll fix his snout and ears later....)
Ok, now to the code stuff. Again, this is a bit more advance, and an understanding about 3D rotations. In anycase, thanks to my new best friend slant, I got this working. First off, we will look at setting up the call for the movement.
Entity Java File
There are several ways you can do this, I am triggering it with an interaction (right) click. To manage the rotation, I am using a public variable armrotation. Public, becuase we will be checkin this value for the rotation. Here is the variable, and the interaction (existing super class) method:
Simple. You click on him, the angle changes to 1.570796F (90 degrees)if it is 0, or to 0 if it's already greater than 0. Simple logic. You could get fancy and also use the onLivingUpdate() method, just make sure to call super.onLivingUpdate(); in there, or the mob won't move. Hmm, maybe that's what's needed for the mount count... enough of that... In anycase, you could increment this value during the onLivingUpdate() mehtod, until it hits 1.57, then rotate it back. That's up to you. Let's move on to the Model file.
Model java file
This is where you let it know what is moving. Remember that the rotation is based on it's rotation point (seen better in Techne). Also remeber that if certain rotations should be mirrored on the other side. I do this here. Here is a new method added:
As you can see this method takes a float variable pass, and appiles it to the leg1.rotationAngleZ. With this model, leg1 and 2 are the arms (from the modelquadruped as the super class this extends). Note that I made the rotation for the other arm negative. This makes both arms go out. Simple enough. Now for the part that gave me the most trouble. the render file
Render java file
This was trial and error, and if someone else knows a better/cleaner method please let me know. Now I had to rebuild my render file for Anibus, do issues I was having. I have (hopefully) streamlined it a bit. There are still methods for render java files that I don't understand, but these will let you do what you need. I'm going to give the whole file first, then talk about the parts:
First, becuase I need to call on them, and there fore need to get objects of that class, I create to private variables:
I do it this way, because they are called in in different methods here, and I need to have them available in other methods. Private because they are only needed here. In the constructor, we are passed a ModelBase object, which I will cast to my Anibus model type. I can do this because I am sure that my class is being passed as seen in this line from my mod_JWorld.java file :
map.put(JWorld_AnibusEntity.class, new JWorld_AnibusRender(new JWorld_AnibusModel(), 0.5F));
(This is just to help you understand why I can do this, DO NOT add this line to your render java file)
So we come to this line in the constructor:
Even though the object class of modelbase is ModelBase, I can still cast it to my JWorldAnibusModel by forcing the cast like this. If the object passed was not of the class JWorldAnibusModel this would probably crash, or error out when the game is run, but as shown above, we do pass my anibus model class. This is needed to run that method we created in the model class.
The next method is where we can make or call to change the rotation. Let's take a closer look:
if you look to the bottom of the code, you can see that this method is called by the doRender and the doRenderLiving mehtods. I'm sure they are both needed, and I did not create this flow or format. Just go with it. In any case of the variables passed, only the our entity object is needed. Also I could not tell you what the others are for. So the fisrt thing I do is to grab the entity into my holdEnt object. I didn't have to cast it, since it was already of the class needed. This may be able to be dropped, but I wasn't sure if it was needed elsewhere. It is important to leave the super.doRenderLiving call here, and add your animation stuff after. After becase if something is set by doRenderLiving, you want your changes to be applied after.
So here we come down to the line that does it all:
This is why we needed those 2 objects. Fisrt, we need the model object so we can call the rotation method. We need the entity object to get the value to pass to the model's rotation method.
There you go. This is a basic (yet still advanced) example of how to do this. I'm pretty sure you could move parts of the mob around and such. It would take a bit of work, but you could do multi joint animations by moving the rotation points, but I leave that up to you. Happy modding.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
Here
@Inlanoche....I crave to know the custom animations *drools* (Dont rush the tutorial through though!)
public void AddRenderer(Map map)
{
map.put(JWorld_AnibusEntity.class, new JWorld_AnibusRender(new JWorld_AnibusModel(), 0.5F));
}
The above are underlined as warning's in my Eclipse and the warning is: "Map is a raw type. References to generic type Map<K,V> should be parameterized."
And worldObj in the "public boolean OnTickInGame" has an error "worldObj cannot be resolved into a variable".
Know any fixes and is the warnings ok to go on with?
More Hostile Dungeon's 1.0