How can I give two texture to my mod and how can I assign which parts are on which texture? (I'm asking this because my mob is to big to have only one texture)
Right now I don't think you can. large mobs don't have to be made big, or with big parts. scaling works, as well as texture overlapping. I too would like to see the current limitations taken away. I have also thought about looking in to overlays on other objects. If you want to get a head start on me in this area, look at things like signs and how objects break(the cracking overlay) Might get you to the 2 textured thing.
You could use the turbo model thingy for a 128x64 texture area.... but you have to download it first to be able to use them though. I wish I could figure out how lighting updating works in this game as I have gotten my mob to change the light value on the block beneath it, yet not cause the lighting to update with it.
[EDIT]: This tutorial will be replaced soon with what I learned doing the tamable mob super class. This works, but the tamable super class has this and more, as well as better control of the mob
This research was done looking at the pig entity and the boat entity. the code is simple enough, if you know what you are looking for. Now I dropped the stuff for adding the saddle on the back of the horse. If you want to do that, you could just switch the mob texture (I have shown how to do that), I didn't go into this, since I will do riding a different way.
Let's go over what you will need to do step by step.
Start with you new mob, what ever it will be(hey, make it a new person and give piggyback rides for all I care):
In the Entity java file for your mob,
first off, if you have scaled your mob, make sure that you fix setSize() to match what your scale is. This is important for sitting your mob on its back. I scaled my horse by 1.25F, so I need to do the same for it's collison box:
setSize(0.9F*1.25F, 0.9F*1.25F);
next, we need the basic interaction mounting code. If you want your mob to only be mountable when holding a specific object, look at the pig code. For now if the player right clicks on the mob, it will mount it. Remember, that if you have the method in use, just add to it. If you do so, think about the logical order of things. Once this method returns, NO FURTHER CODE WILL BE EXECUTED!
Simple enough. No one is on it, and you're not on it, it will mount. If you are on it, then you will dismount. I'm guessing the mountEntity code both mounts and unmounts. This works, so leave it be.
Next, lets stop this mob from moving while ridden. We first make a new global var in the entity java file:
Last, we can make some changes to the mob once it is being ridden. I have tried to do a bunch of stuff here, mainly trying to get it to stop looking around. If anyone knows how, please let me know. Also, if you wanted to throw a saddle on it, you can do the 2 texture thing. Here I change the texture when it's ridden, just to show you. The Yaw code is not working, but if I find out how, I will update this:
public void onUpdate()
{
super.onUpdate();
if(riddenByEntity != null) //check if there is a rider
{
//currentTarget = this;
texture = "/mob/dragon.png"; //test to show a different texture when mounted
this.randomYawVelocity = 0; //try not to let the horse control where to look.
this.rotationYaw =riddenByEntity.rotationYaw;
}else
{
if(texture != "/mods/horse.png")
{
texture = "/mods/horse.png"; //reset texture afte getting off.
}
}
}
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. Here is the full code:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) braces deadcode
package net.minecraft.src;
// Referenced classes of package net.minecraft.src:
// EntityAnimal, DataWatcher, NBTTagCompound, World,
// EntityPlayer, Item, EntityPigZombie, AchievementList,
// EntityLightningBolt
public class JWorld_HorseEntity extends EntityAnimal
{
public JWorld_HorseEntity(World world)
{
super(world);
texture = "/mods/horse.png";
setSize(0.9F*1.25F, 0.9F*1.25F);
stationary = false;
}
/* --don't think this is needed
protected void entityInit()
{
dataWatcher.addObject(16, Byte.valueOf((byte)0));
}
*/
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
super.writeEntityToNBT(nbttagcompound);
//nbttagcompound.setBoolean("Saddle", getSaddled());
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
super.readEntityFromNBT(nbttagcompound);
//setSaddled(nbttagcompound.getBoolean("Saddle"));
}
protected String getLivingSound()
{
return "mob.pig";
}
protected String getHurtSound()
{
return "mob.pig";
}
protected String getDeathSound()
{
return "mob.pigdeath";
}
public boolean interact(EntityPlayer entityplayer)
{
if(riddenByEntity == null || riddenByEntity == entityplayer)
{
entityplayer.mountEntity(this);
return true;
} else
{
return false;
}
}
protected boolean isMovementCeased()
{
return stationary;
}
public void moveEntity(double d, double d1, double d2)
{
if(riddenByEntity != null)
{
stationary = true;
motionX += riddenByEntity.motionX*10; // * 0.20000000000000001D;
motionZ += riddenByEntity.motionZ*10; // * 0.20000000000000001D;
if(isCollidedHorizontally)
{
isJumping = true;
}
super.moveEntity(motionX, motionY, motionZ);
}else
{
stationary = false;
super.moveEntity(d, d1, d2);
}
}
public void onUpdate()
{
super.onUpdate();
if(riddenByEntity != null) //check if there is a rider
{
//currentTarget = this;
texture = "/mob/dragon.png"; //test to show a different texture when mounted
this.randomYawVelocity = 0; //try not to let the horse control where to look.
this.rotationYaw =riddenByEntity.rotationYaw;
}else
{
if(texture != "/mods/horse.png")
{
texture = "/mods/horse.png"; //reset texture afte getting off.
}
}
}
protected int getDropItemId()
{
if(fire > 0)
{
return Item.porkCooked.shiftedIndex;
} else
{
return Item.porkRaw.shiftedIndex;
}
}
/*---------Not using saddle code!
public boolean getSaddled()
{
return (dataWatcher.getWatchableObjectByte(16) & 1) != 0;
}
public void setSaddled(boolean flag)
{
if(flag)
{
dataWatcher.updateObject(16, Byte.valueOf((byte)1));
} else
{
dataWatcher.updateObject(16, Byte.valueOf((byte)0));
}
}
/*
public void onStruckByLightning(EntityLightningBolt entitylightningbolt)
{
if(worldObj.multiplayerWorld)
{
return;
} else
{
EntityPigZombie entitypigzombie = new EntityPigZombie(worldObj);
entitypigzombie.setLocationAndAngles(posX, posY, posZ, rotationYaw, rotationPitch);
worldObj.entityJoinedWorld(entitypigzombie);
setEntityDead();
return;
}
}
*/
public boolean stationary;
}
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.
After fiddling with stuff all night and into the morning, this is as far as I have gotten. What is shown on the right is what is in game, on the left is my model.
After fiddling with stuff all night and into the morning, this is as far as I have gotten. What is shown on the right is what is in game, on the left is my model.
Try using extends ModelBase instead of the one you have up there, it seems like the ModelBiped or the ModelQuadruped, Like to cause some troubles with how the model looks sometimes.
That's pretty much it. Well, you say, how do I see it fly? well let's make a little code to "poke" it into flying. Add this other method:
public boolean interact(EntityPlayer entityplayer)
{
//rightclick on this entity to make it jump up
this.motionY += 1;
}
Don't use a big number, this will have it jump several feet into the air, then flap it's wings back down. If you notice, they use multipliers (of less than 1) when adjusting the motionY variable. I once set it to 5, and wondered where the mob went. It was way up in the sky, and took a while to get back down.
If you want to make a block that throws you into the air, you can use this idea on a block. Of course, if you don't have the flying code, you're in for quite a fall. :smile.gif:
it gives me an error "this method must return a type boolean"... idk what to do
and also what code could i change that makes it so that it could jump up and fly?
and possibly eventually control it? hmm :biggrin.gif:
but really all i need to know is the boolean thing and the jump and fly part haha.. cuz the way it works now it only slightly goes up
it gives me an error "this method must return a type boolean"... idk what to do
and also what code could i change that makes it so that it could jump up and fly?
and possibly eventually control it? hmm :biggrin.gif:
but really all i need to know is the boolean thing and the jump and fly part haha.. cuz the way it works now it only slightly goes up
I suck. I cleaned that up after, but it's an easy fix. just add
return true;
with the other code, if you set it's motionY to a positive value, it will go up. I would say try something between 0.5 and 2. Any more and it will shoot up so fast you'll think it disapeared. just look up and you will see it fluttering down.
As to having it fly around, you need to give it a location, or let it do it's own thing. I was about to look at code to make them glide forward, but I would actually leave the movement up to the AI for now.
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:
post your entity code, so I can see how you are setting/changing the name.
I suck. I cleaned that up after, but it's an easy fix. just add
return true;
with the other code, if you set it's motionY to a positive value, it will go up. I would say try something between 0.5 and 2. Any more and it will shoot up so fast you'll think it disapeared. just look up and you will see it fluttering down.
As to having it fly around, you need to give it a location, or let it do it's own thing. I was about to look at code to make them glide forward, but I would actually leave the movement up to the AI for now.
src\minecraft\net\minecraft\src\JWorld_AnibusEntity.java.java:12: class JWorld_
nibusEntity is public, should be declared in a file named JWorld_AnibusEntity.j
va
public class JWorld_AnibusEntity extends EntityAnimal
^
src\minecraft\net\minecraft\src\RenderEngine.java:649: cannot access net.minecr
ft.src.java
bad class file: src\minecraft\net\minecraft\src\JWorld_AnibusEntity.java.java
file does not contain class net.minecraft.src.java
Please remove or make sure it appears in the correct subdirectory of the classp
th.
private java.util.List textureList;
Right now I don't think you can. large mobs don't have to be made big, or with big parts. scaling works, as well as texture overlapping. I too would like to see the current limitations taken away. I have also thought about looking in to overlays on other objects. If you want to get a head start on me in this area, look at things like signs and how objects break(the cracking overlay) Might get you to the 2 textured thing.
Ok thanks but I said too big but in fact I should have said too detailed. My mob needs too much different textures to look like what I want it to look like.
Rollback Post to RevisionRollBack
Each day is a gift and not a given right, so live them all like your last
EDIT: No reply in awhile...guessing the person who was helping me went offline...someone else see anything wrong here in the code? (Look at my previous post too to see the 1 error i got when i recompiled...)
Right now I don't think you can. large mobs don't have to be made big, or with big parts. scaling works, as well as texture overlapping. I too would like to see the current limitations taken away. I have also thought about looking in to overlays on other objects. If you want to get a head start on me in this area, look at things like signs and how objects break(the cracking overlay) Might get you to the 2 textured thing.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
[EDIT]: This tutorial will be replaced soon with what I learned doing the tamable mob super class. This works, but the tamable super class has this and more, as well as better control of the mob
This research was done looking at the pig entity and the boat entity. the code is simple enough, if you know what you are looking for. Now I dropped the stuff for adding the saddle on the back of the horse. If you want to do that, you could just switch the mob texture (I have shown how to do that), I didn't go into this, since I will do riding a different way.
Let's go over what you will need to do step by step.
Start with you new mob, what ever it will be(hey, make it a new person and give piggyback rides for all I care):
In the Entity java file for your mob,
first off, if you have scaled your mob, make sure that you fix setSize() to match what your scale is. This is important for sitting your mob on its back. I scaled my horse by 1.25F, so I need to do the same for it's collison box:
next, we need the basic interaction mounting code. If you want your mob to only be mountable when holding a specific object, look at the pig code. For now if the player right clicks on the mob, it will mount it. Remember, that if you have the method in use, just add to it. If you do so, think about the logical order of things. Once this method returns, NO FURTHER CODE WILL BE EXECUTED!
Simple enough. No one is on it, and you're not on it, it will mount. If you are on it, then you will dismount. I'm guessing the mountEntity code both mounts and unmounts. This works, so leave it be.
Next, lets stop this mob from moving while ridden. We first make a new global var in the entity java file:
Then we set it in our constructor:
Then we modify one of the protected methods:
This method is called to stop the mob from moving, so let's use it.
Last we need to control the mob with the rider's movements. For this, we rework the moveEntity() method:
Last, we can make some changes to the mob once it is being ridden. I have tried to do a bunch of stuff here, mainly trying to get it to stop looking around. If anyone knows how, please let me know. Also, if you wanted to throw a saddle on it, you can do the 2 texture thing. Here I change the texture when it's ridden, just to show you. The Yaw code is not working, but if I find out how, I will update this:
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. Here is the full code:
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.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
Can anyone help out here?
Try using extends ModelBase instead of the one you have up there, it seems like the ModelBiped or the ModelQuadruped, Like to cause some troubles with how the model looks sometimes.
it gives me an error "this method must return a type boolean"... idk what to doand also what code could i change that makes it so that it could jump up and fly?
and possibly eventually control it? hmm :biggrin.gif:
but really all i need to know is
the boolean thing andthe jump and fly part haha.. cuz the way it works now it only slightly goes upI suck. I cleaned that up after, but it's an easy fix. just add
with the other code, if you set it's motionY to a positive value, it will go up. I would say try something between 0.5 and 2. Any more and it will shoot up so fast you'll think it disapeared. just look up and you will see it fluttering down.
As to having it fly around, you need to give it a location, or let it do it's own thing. I was about to look at code to make them glide forward, but I would actually leave the movement up to the AI for now.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
post your entity code, so I can see how you are setting/changing the name.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
I think you need to show the render code.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
ok i'll keep experimenting then thanks
== ERRORS FOUND ==
src\minecraft\net\minecraft\src\JWorld_AnibusEntity.java.java:12: class JWorld_
nibusEntity is public, should be declared in a file named JWorld_AnibusEntity.j
va
public class JWorld_AnibusEntity extends EntityAnimal
^
src\minecraft\net\minecraft\src\RenderEngine.java:649: cannot access net.minecr
ft.src.java
bad class file: src\minecraft\net\minecraft\src\JWorld_AnibusEntity.java.java
file does not contain class net.minecraft.src.java
Please remove or make sure it appears in the correct subdirectory of the classp
th.
private java.util.List textureList;
Help...please?
^
Ok thanks but I said too big but in fact I should have said too detailed. My mob needs too much different textures to look like what I want it to look like.
I dont get what you mean... All files have Anibus in title, It seems to be a problem only with JWorld_AnibusEntity.Java...
The file name is JWorld_AnibusEntity.java
can u give the code for that please? so i can see what could be the problem
Sure, here
package net.minecraft.src;
// Referenced classes of package net.minecraft.src:
// EntityAnimal, Item, EntityPlayer, InventoryPlayer,
// ItemStack, World, NBTTagCompound
public class JWorld_AnibusEntity extends EntityAnimal
{
public JWorld_AnibusEntity(World world)
{
super(world);
texture = "/mob/anibus.png";
setSize(0.9F, 1.3F);
moveSpeed = 0.75F;
//yOffset *= 6F;
health = 25;
}
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
super.writeEntityToNBT(nbttagcompound);
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
super.readEntityFromNBT(nbttagcompound);
}
protected String getLivingSound()
{
return "mob.cow";
}
protected String getHurtSound()
{
return "mob.cowhurt";
}
protected String getDeathSound()
{
return "mob.cowhurt";
}
protected float getSoundVolume()
{
return 0.4F;
}
protected int getDropItemId()
{
return Item.leather.shiftedIndex;
}
public boolean interact(EntityPlayer entityplayer)
{
ItemStack itemstack = entityplayer.inventory.getCurrentItem();
if(itemstack != null && itemstack.itemID == Item.bucketEmpty.shiftedIndex)
{
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, new ItemStack(Item.bucketMilk));
return true;
} else
{
return false;
}
}
}
EDIT: No reply in awhile...guessing the person who was helping me went offline...someone else see anything wrong here in the code? (Look at my previous post too to see the 1 error i got when i recompiled...)
Yeah..