List list1 = worldObj.getCollidingBoundingBoxes(this, boundingBox.func_28195_e(0.03125D, 0.0D, 0.03125D));
error/s: The method func_28195_e (double, double , double) is undefined for type AxisAlignedBB,
List is a raw type .References to generic type list <E> should be parameterized.
and
super.updatePlayerActionState();
error: The method updatePlayerActionState is undefined for the type EntityAnimal
Entitycode (its basicly a copy of your tamable entity, just modified to another name)
// 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
/*JWorld_TamableEntiy class
* 19 Aug 2011
* http://www.minecraftforum.net/topic/529327-modloader-adding-custom-mobs-and-more/
*
* NEEDED support java files:
* JWorldGUICreatureInteract.java, JWorld_TamableRender.java, KeyBinding in your main mod_ java file.
*/
package net.minecraft.src;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.client.Minecraft;
// Referenced classes of package net.minecraft.src:
// EntityAnimal, World, Item, NBTTagCompound
public class EntityDonkey extends EntityAnimal
{
//fields that are needed for all tameable mobs. Tie in to tameable menus
public String entityType; //used for the menus and other checks
public int hostile; //if the mob will attack other mobs or not. -1 not hostile, 0 attacks player only, 1 attacks any other mob
public int owner; //the entityID of the mob that tamed this
public String ownerName; //String name for the owner, if it is the player
public int mountable; //flag to see if you can mount this mob. -2 means never, 0 means need item, 1 means yes.
public int favItem; //What they like (to tame them)
public int favBoost; //how much it boosts the mood
public int mood; //how happy it is
public int tamemood; //how much mood needed to tame it
public int MountItem; //What is needed to mount them
public String myName; //if it's tamed you can name it
public boolean fly; //flag for if this mob can fly
public boolean leap; //used for flying mount control
public int myAge; //age of the mob, only really tracked in tamed mobs
public int maxAge; //age when full size
public float maxSpeed; //as fast as it goes normally
public boolean follow; //is the mob set to follow the owner
public int attackStrength; //how much damage this inflicts when it attacks. Can be scaled by age
public int maxStrength; //basic str. value
private World worldObj;
public float sizeX;
public float sizeY;
public boolean hasHead;
public EntityDonkey(World world)
{
super(world);
sizeX = 1F; //set and do not change!
sizeY = 1F; //set and do not change!
texture = "/Kafes/donkey.png"; //texture needs to be set in sub class
setSize(sizeX, sizeY); //USE sizeX and sizeY to initialize this!
health = 10; //keep defaults
maxSpeed = 1.5F; //basic unmodified speed
moveSpeed = maxSpeed;
worldObj = world; //get the world object
//***set vars for tamable mobs***
entityType = ""; //set in sub class, bread name of creature
hostile = -1; //will it attack the player/other mobs or not.
owner = -1; //in case entityID 0 is used. <0 means no owner. > 0 means tamed with an owner
ownerName = ""; //needed for finding player by owner
mountable = -2; //default to not possible
favItem = -1; //leave it negative, meaning not possible to tame. Based on Item.shiftedIndex
favBoost = 1; //default boost of 1 to mood.
mood = 0; //negative is angry, positive is happy. 10 will tame?
tamemood = 10; //how much needed to tame it
MountItem = -1; //-1 means no item needed if mountable. Based on Item.shiftedIndex
myName = ""; //Leave it un-named to not render name tag.
fly = false; //can it fly or not
leap = false; //for flying mounts
myAge = 1; //can be used for scaling and other age related code
maxAge = 10; //age when fully grown (can be older)
follow = false;
attackStrength = 2; //base attack strength, can be modified by age
inventory = new TamableInventory(this);
}
//START:Age and scaling code-------------------------------------------------
public float getAgeScale()
{
//this will return a scale value that can be passed to the render java file to set a scale by age
//this should also be applied to setSize to fix bounding box. Not used by default
float scaler = 1F;
scaler = (float)myAge/(float)maxAge;
if(scaler <= 0.5) //set minimum scale factor
{
return 0.5F;
}
if(scaler <= 0.9) //medium size scale factor
{
return 0.75F;
}
return 1.25F; //if not then full size
}
public void updateAge()
{
//should be run every time the age is updated to fix speed, bounding box, etc.
float aScale = getAgeScale();
setSize(sizeX*aScale,sizeY*aScale); //the only way the size should change, do not adjust sizeX and sizeY after constructor
moveSpeed = maxSpeed*aScale; //scale movement to size
attackStrength = (int)(maxStrength * aScale);
if(attackStrength < 1) attackStrength = 1; //cannot be less that 1
}
//END:Age and scaling code-----------------------------------------------------
protected boolean canDespawn()
{
if(ownerName != "") //means it's owned
{
return false; //means should stay in the game
}
return true;
}
//START:Inventory code-----------------------------------------------------------
public TamableInventory inventory; //inventory object for tamable pack animals
public void openInventory(EntityPlayer theplayer)
{
ModLoader.OpenGUI(theplayer, new TamableInvGui(theplayer, this));
}
public void onDeath(Entity entity) //when mob dies
{
inventory.dropAllItems(); // when dead drop all inventory! **
super.onDeath(entity);
}
//END:Inventory code-----------------------------------------------------------
//START: Update code. Put stuff here that needs to be constantly checked-----------------
public void onLivingUpdate()
{
//imported super.onLivingUpdate()
if(newPosRotationIncrements > 0)
{
double d = posX + (newPosX - posX) / (double)newPosRotationIncrements;
double d1 = posY + (newPosY - posY) / (double)newPosRotationIncrements;
double d2 = posZ + (newPosZ - posZ) / (double)newPosRotationIncrements;
double d3;
for(d3 = newRotationYaw - (double)rotationYaw; d3 < -180D; d3 += 360D) { }
for(; d3 >= 180D; d3 -= 360D) { }
rotationYaw += d3 / (double)newPosRotationIncrements;
rotationPitch += (newRotationPitch - (double)rotationPitch) / (double)newPosRotationIncrements;
newPosRotationIncrements--;
setPosition(d, d1, d2);
setRotation(rotationYaw, rotationPitch);
List list1 = worldObj.getCollidingBoundingBoxes(this, boundingBox.func_28195_e(0.03125D, 0.0D, 0.03125D));
if(list1.size() > 0)
{
double d4 = 0.0D;
for(int j = 0; j < list1.size(); j++)
{
AxisAlignedBB axisalignedbb = (AxisAlignedBB)list1.get(j);
if(axisalignedbb.maxY > d4)
{
d4 = axisalignedbb.maxY;
}
}
d1 += d4 - boundingBox.minY;
setPosition(d, d1, d2);
}
}
if(isMovementBlocked())
{
isJumping = false;
moveStrafing = 0.0F;
moveForward = 0.0F;
randomYawVelocity = 0.0F;
} else
if(!isMultiplayerEntity)
{
updatePlayerActionState();
}
boolean flag = isInWater();
boolean flag1 = handleLavaMovement();
if(isJumping)
{
if(flag)
{
motionY += 0.039999999105930328D;
} else
if(flag1)
{
motionY += 0.039999999105930328D;
} else
if(onGround)
{
jump();
}
}
moveStrafing *= 0.98F;
moveForward *= 0.98F;
randomYawVelocity *= 0.9F;
//test for halting movement if ridden, only part edited by inLanoche
if(riddenByEntity != null)
{
//halt attempts to move or look around
moveStrafing = 0;
moveForward = 0;
randomYawVelocity = 0;
defaultPitch = 0;
}
//End of test */
moveEntityWithHeading(moveStrafing, moveForward);
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
if(list != null && list.size() > 0)
{
for(int i = 0; i < list.size(); i++)
{
Entity entity = (Entity)list.get(i);
if(entity.canBePushed())
{
entity.applyEntityCollision(this);
}
}
}
}
protected void updatePlayerActionState()
{
float f = 18; //outside of follow range
super.updatePlayerActionState();
if(follow) //make it follow you
{
{
EntityPlayer entityplayer = worldObj.getPlayerEntityByName(ownerName); //has to be done this way, no other method I know
if(entityplayer != null)
{
f = entityplayer.getDistanceToEntity(this);
if(f > 5F && f < 18F)
{
PathEntity pathentity = worldObj.getPathToEntity(this, entityplayer, 16F);
setPathToEntity(pathentity);
}else
{
setPathToEntity(null); //have it stop following if too close or out of range.
}
}
}
}
if(f > 18)
{
setPathToEntity(null); //Forget following, no path set.
follow = false; //stop following when too far away
}
}
//END: Update code. Put stuff here that needs to be constantly checked-----------------
//START: Manage movement code------------------------------------------------------
public void moveEntity(double d, double d1, double d2)
{
if(riddenByEntity != null)
{
isJumping = false; //seems to want to jump around by itself
riddenByEntity.prevRotationYaw *= 0.9F; //slow the rotation a bit...
rotationYaw = riddenByEntity.prevRotationYaw;
rotationPitch = riddenByEntity.rotationPitch * 0.5F;
if(leap)
{//have it fly up a bit
motionX += riddenByEntity.motionX*moveSpeed; //Should find a way to set this to normal mob speed
motionZ += riddenByEntity.motionZ*moveSpeed; //ditto
motionY += 1F;
leap = false;
}else
{//regular run on the ground movement
motionX += riddenByEntity.motionX*moveSpeed; //ditto
motionZ += riddenByEntity.motionZ*moveSpeed; //ditto
if(onGround)
{
motionY = 0; //for some reason it likes to hop
}
}
if(isCollidedHorizontally)
{
if(fly) //if it can fly
{
motionY += 0.15F; //allows it to drift up if you are hitting an obstacle in front of you
}else
{
if(onGround) //else not fly
{
jump(); //let it try to jump over obstacle
}
}
}
super.moveEntity(motionX, motionY, motionZ);
}else
{
super.moveEntity(d, d1, d2);
}
}
// from super super class Entity
public void updateRidden()
{
if(ridingEntity.isDead)//if rider is dead, drop it
{
ridingEntity = null;
return;
}
motionX = 0.0D; //set all movement to 0. Let player control it.
motionY = 0.0D;
motionZ = 0.0D;
onUpdate();
if(ridingEntity == null)
{
return;
}
ridingEntity.updateRiderPosition();
//cut a lot from the Entity.updateRidden
}
//END: Manage movement code------------------------------------------------------
//START: Player interaction with mob-------------------------------------------
public boolean interact(EntityPlayer entityplayer)
{
ItemStack itemstack = entityplayer.inventory.getCurrentItem(); //see what the interacting player is holding
if(MountItem >= 0 && mountable != -2) //you need an item to mount
{
mountable = 0; //reset mountable in case an item is needed to mount. No cheating!
}
//if you have noting, and it's not yours, nothing will happen
if(itemstack == null && owner < 0)
{
return false;
}
//if riding, dismount, no matter what is in hand
if(riddenByEntity != null && riddenByEntity == entityplayer)
{
mountThis(entityplayer);
return true;
}
if(mountable == 0) //if you need an item to mount,
{
for(int j = 0; j < entityplayer.inventory.mainInventory.length; j++)
{
if(entityplayer.inventory.mainInventory[j] != null && entityplayer.inventory.mainInventory[j].itemID == MountItem)
{
mountable = 1;
break;
}
}
}
//if you have nothing, but own this mob, bring up the menu
if(itemstack == null && owner == entityplayer.entityId)
{
//one liner with ModLoader to open GUIs
ModLoader.OpenGUI(entityplayer, new TamableGUIMenu(this, entityplayer));
}
//To tame it, you have to give it something it likes, and it can't be already owned
if(itemstack != null && itemstack.itemID == favItem && owner < 0)
{
itemstack.stackSize--; //you give the item
if(itemstack.stackSize <= 0)
{
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null);
}
mood += favBoost; //boost its mood
if(mood >= tamemood) //check if you tamed it
{
owner = entityplayer.entityId; //if so, it's yours now.
ownerName = entityplayer.username; //need this for finding the player in the world
//should call naming GUI at this point
Minecraft mc = ModLoader.getMinecraftInstance();
ParticleFX("heart");
mc.displayGuiScreen(new TamableGUIMenu(this, entityplayer)); //Should the GUI pop up the right now?
//maybe use just a naming GUI here...
return true;
}else
{
ParticleFX("note"); //it's happy it got something good
}
return true;
}
return false;
}
//END: Player interaction with mob-------------------------------------------
//START: Call to mount--------------------------------------------------------
public void mountThis(EntityPlayer entityplayer) //use this for mounting from GUI or direct mount
{
if (riddenByEntity == null || riddenByEntity == entityplayer)
{
follow = false; //reset follow toggle
entityplayer.mountEntity(this); //climb on/get off
}
}
//END: Call to mount--------------------------------------------------------
//START: File handling code
//these need to be used to save tamed/owned creatures - in progress...
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
super.writeEntityToNBT(nbttagcompound);
if(ownerName != "") //if it has an owner, might want to save the stats
{
nbttagcompound.setString("Ownername", ownerName);
nbttagcompound.setTag("Inventory", inventory.writeToNBT(new NBTTagList())); // it writes the inventory to file
nbttagcompound.setInteger("Age", myAge);
nbttagcompound.setDouble("myX", posX);
nbttagcompound.setDouble("myY", posY);
nbttagcompound.setDouble("myZ", posZ);
}
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
super.readEntityFromNBT(nbttagcompound);
ownerName = nbttagcompound.getString("Ownername"); //should only have this if there was an owner
myAge = nbttagcompound.getInteger("Age");
NBTTagList nbttaglist = nbttagcompound.getTagList("Inventory"); // must read inventory
inventory.readFromNBT(nbttaglist);
posX = nbttagcompound.getDouble("myX");
posY = nbttagcompound.getDouble("myY");
posZ = nbttagcompound.getDouble("myZ");
//not working. Mob does not spawn when game is reloaded....
}
//END: File handling code------------------------------------------------------
//START: Audio sounds----------------------------------------------------------
protected String getLivingSound()
{
return "mob.chicken";
}
protected String getHurtSound()
{
return "mob.chickenhurt";
}
protected String getDeathSound()
{
return "mob.chickenhurt";
}
//END: Audio sounds----------------------------------------------------------
protected int getDropItemId()
{
return 0; //set what this drops when it dies
}
//Used for Particle effect when tamed or other particles.
public static ArrayList particleList = new ArrayList();
void ParticleFX(String fx)
{
//these are found in RenderGlobal.java
particleList.add("heart");
particleList.add("smoke");
particleList.add("splash");
particleList.add("note");
particleList.add("flame");
particleList.add("bubble");
String s = fx;
if(particleList.indexOf(fx) < 0)
{
return; //passed an improper particle type and do nothing
}
for(int i = 0; i < 7; i++)
{
double d = rand.nextGaussian() * 0.02D;
double d1 = rand.nextGaussian() * 0.02D;
double d2 = rand.nextGaussian() * 0.02D;
worldObj.spawnParticle(s, (posX + (double)(rand.nextFloat() * width * 2.0F)) - (double)width, posY + 0.5D + (double)(rand.nextFloat() * height), (posZ + (double)(rand.nextFloat() * width * 2.0F)) - (double)width, d, d1, d2);
}
}
}
List list1 = worldObj.getCollidingBoundingBoxes(this, boundingBox.func_28195_e(0.03125D, 0.0D, 0.03125D));
error/s: The method func_28195_e (double, double , double) is undefined for type AxisAlignedBB,
List is a raw type .References to generic type list <E> should be parameterized.
and
super.updatePlayerActionState();
error: The method updatePlayerActionState is undefined for the type EntityAnimal
Entitycode (its basicly a copy of your tamable entity, just modified to another name)
// 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
/*JWorld_TamableEntiy class
* 19 Aug 2011
* http://www.minecraftforum.net/topic/529327-modloader-adding-custom-mobs-and-more/
*
* NEEDED support java files:
* JWorldGUICreatureInteract.java, JWorld_TamableRender.java, KeyBinding in your main mod_ java file.
*/
package net.minecraft.src;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.client.Minecraft;
// Referenced classes of package net.minecraft.src:
// EntityAnimal, World, Item, NBTTagCompound
public class EntityDonkey extends EntityAnimal
{
//fields that are needed for all tameable mobs. Tie in to tameable menus
public String entityType; //used for the menus and other checks
public int hostile; //if the mob will attack other mobs or not. -1 not hostile, 0 attacks player only, 1 attacks any other mob
public int owner; //the entityID of the mob that tamed this
public String ownerName; //String name for the owner, if it is the player
public int mountable; //flag to see if you can mount this mob. -2 means never, 0 means need item, 1 means yes.
public int favItem; //What they like (to tame them)
public int favBoost; //how much it boosts the mood
public int mood; //how happy it is
public int tamemood; //how much mood needed to tame it
public int MountItem; //What is needed to mount them
public String myName; //if it's tamed you can name it
public boolean fly; //flag for if this mob can fly
public boolean leap; //used for flying mount control
public int myAge; //age of the mob, only really tracked in tamed mobs
public int maxAge; //age when full size
public float maxSpeed; //as fast as it goes normally
public boolean follow; //is the mob set to follow the owner
public int attackStrength; //how much damage this inflicts when it attacks. Can be scaled by age
public int maxStrength; //basic str. value
private World worldObj;
public float sizeX;
public float sizeY;
public boolean hasHead;
public EntityDonkey(World world)
{
super(world);
sizeX = 1F; //set and do not change!
sizeY = 1F; //set and do not change!
texture = "/Kafes/donkey.png"; //texture needs to be set in sub class
setSize(sizeX, sizeY); //USE sizeX and sizeY to initialize this!
health = 10; //keep defaults
maxSpeed = 1.5F; //basic unmodified speed
moveSpeed = maxSpeed;
worldObj = world; //get the world object
//***set vars for tamable mobs***
entityType = ""; //set in sub class, bread name of creature
hostile = -1; //will it attack the player/other mobs or not.
owner = -1; //in case entityID 0 is used. <0 means no owner. > 0 means tamed with an owner
ownerName = ""; //needed for finding player by owner
mountable = -2; //default to not possible
favItem = -1; //leave it negative, meaning not possible to tame. Based on Item.shiftedIndex
favBoost = 1; //default boost of 1 to mood.
mood = 0; //negative is angry, positive is happy. 10 will tame?
tamemood = 10; //how much needed to tame it
MountItem = -1; //-1 means no item needed if mountable. Based on Item.shiftedIndex
myName = ""; //Leave it un-named to not render name tag.
fly = false; //can it fly or not
leap = false; //for flying mounts
myAge = 1; //can be used for scaling and other age related code
maxAge = 10; //age when fully grown (can be older)
follow = false;
attackStrength = 2; //base attack strength, can be modified by age
inventory = new TamableInventory(this);
}
//START:Age and scaling code-------------------------------------------------
public float getAgeScale()
{
//this will return a scale value that can be passed to the render java file to set a scale by age
//this should also be applied to setSize to fix bounding box. Not used by default
float scaler = 1F;
scaler = (float)myAge/(float)maxAge;
if(scaler <= 0.5) //set minimum scale factor
{
return 0.5F;
}
if(scaler <= 0.9) //medium size scale factor
{
return 0.75F;
}
return 1.25F; //if not then full size
}
public void updateAge()
{
//should be run every time the age is updated to fix speed, bounding box, etc.
float aScale = getAgeScale();
setSize(sizeX*aScale,sizeY*aScale); //the only way the size should change, do not adjust sizeX and sizeY after constructor
moveSpeed = maxSpeed*aScale; //scale movement to size
attackStrength = (int)(maxStrength * aScale);
if(attackStrength < 1) attackStrength = 1; //cannot be less that 1
}
//END:Age and scaling code-----------------------------------------------------
protected boolean canDespawn()
{
if(ownerName != "") //means it's owned
{
return false; //means should stay in the game
}
return true;
}
//START:Inventory code-----------------------------------------------------------
public TamableInventory inventory; //inventory object for tamable pack animals
public void openInventory(EntityPlayer theplayer)
{
ModLoader.OpenGUI(theplayer, new TamableInvGui(theplayer, this));
}
public void onDeath(Entity entity) //when mob dies
{
inventory.dropAllItems(); // when dead drop all inventory! **
super.onDeath(entity);
}
//END:Inventory code-----------------------------------------------------------
//START: Update code. Put stuff here that needs to be constantly checked-----------------
public void onLivingUpdate()
{
//imported super.onLivingUpdate()
if(newPosRotationIncrements > 0)
{
double d = posX + (newPosX - posX) / (double)newPosRotationIncrements;
double d1 = posY + (newPosY - posY) / (double)newPosRotationIncrements;
double d2 = posZ + (newPosZ - posZ) / (double)newPosRotationIncrements;
double d3;
for(d3 = newRotationYaw - (double)rotationYaw; d3 < -180D; d3 += 360D) { }
for(; d3 >= 180D; d3 -= 360D) { }
rotationYaw += d3 / (double)newPosRotationIncrements;
rotationPitch += (newRotationPitch - (double)rotationPitch) / (double)newPosRotationIncrements;
newPosRotationIncrements--;
setPosition(d, d1, d2);
setRotation(rotationYaw, rotationPitch);
List list1 = worldObj.getCollidingBoundingBoxes(this, boundingBox.func_28195_e(0.03125D, 0.0D, 0.03125D));
if(list1.size() > 0)
{
double d4 = 0.0D;
for(int j = 0; j < list1.size(); j++)
{
AxisAlignedBB axisalignedbb = (AxisAlignedBB)list1.get(j);
if(axisalignedbb.maxY > d4)
{
d4 = axisalignedbb.maxY;
}
}
d1 += d4 - boundingBox.minY;
setPosition(d, d1, d2);
}
}
if(isMovementBlocked())
{
isJumping = false;
moveStrafing = 0.0F;
moveForward = 0.0F;
randomYawVelocity = 0.0F;
} else
if(!isMultiplayerEntity)
{
updatePlayerActionState();
}
boolean flag = isInWater();
boolean flag1 = handleLavaMovement();
if(isJumping)
{
if(flag)
{
motionY += 0.039999999105930328D;
} else
if(flag1)
{
motionY += 0.039999999105930328D;
} else
if(onGround)
{
jump();
}
}
moveStrafing *= 0.98F;
moveForward *= 0.98F;
randomYawVelocity *= 0.9F;
//test for halting movement if ridden, only part edited by inLanoche
if(riddenByEntity != null)
{
//halt attempts to move or look around
moveStrafing = 0;
moveForward = 0;
randomYawVelocity = 0;
defaultPitch = 0;
}
//End of test */
moveEntityWithHeading(moveStrafing, moveForward);
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
if(list != null && list.size() > 0)
{
for(int i = 0; i < list.size(); i++)
{
Entity entity = (Entity)list.get(i);
if(entity.canBePushed())
{
entity.applyEntityCollision(this);
}
}
}
}
protected void updatePlayerActionState()
{
float f = 18; //outside of follow range
super.updatePlayerActionState();
if(follow) //make it follow you
{
{
EntityPlayer entityplayer = worldObj.getPlayerEntityByName(ownerName); //has to be done this way, no other method I know
if(entityplayer != null)
{
f = entityplayer.getDistanceToEntity(this);
if(f > 5F && f < 18F)
{
PathEntity pathentity = worldObj.getPathToEntity(this, entityplayer, 16F);
setPathToEntity(pathentity);
}else
{
setPathToEntity(null); //have it stop following if too close or out of range.
}
}
}
}
if(f > 18)
{
setPathToEntity(null); //Forget following, no path set.
follow = false; //stop following when too far away
}
}
//END: Update code. Put stuff here that needs to be constantly checked-----------------
//START: Manage movement code------------------------------------------------------
public void moveEntity(double d, double d1, double d2)
{
if(riddenByEntity != null)
{
isJumping = false; //seems to want to jump around by itself
riddenByEntity.prevRotationYaw *= 0.9F; //slow the rotation a bit...
rotationYaw = riddenByEntity.prevRotationYaw;
rotationPitch = riddenByEntity.rotationPitch * 0.5F;
if(leap)
{//have it fly up a bit
motionX += riddenByEntity.motionX*moveSpeed; //Should find a way to set this to normal mob speed
motionZ += riddenByEntity.motionZ*moveSpeed; //ditto
motionY += 1F;
leap = false;
}else
{//regular run on the ground movement
motionX += riddenByEntity.motionX*moveSpeed; //ditto
motionZ += riddenByEntity.motionZ*moveSpeed; //ditto
if(onGround)
{
motionY = 0; //for some reason it likes to hop
}
}
if(isCollidedHorizontally)
{
if(fly) //if it can fly
{
motionY += 0.15F; //allows it to drift up if you are hitting an obstacle in front of you
}else
{
if(onGround) //else not fly
{
jump(); //let it try to jump over obstacle
}
}
}
super.moveEntity(motionX, motionY, motionZ);
}else
{
super.moveEntity(d, d1, d2);
}
}
// from super super class Entity
public void updateRidden()
{
if(ridingEntity.isDead)//if rider is dead, drop it
{
ridingEntity = null;
return;
}
motionX = 0.0D; //set all movement to 0. Let player control it.
motionY = 0.0D;
motionZ = 0.0D;
onUpdate();
if(ridingEntity == null)
{
return;
}
ridingEntity.updateRiderPosition();
//cut a lot from the Entity.updateRidden
}
//END: Manage movement code------------------------------------------------------
//START: Player interaction with mob-------------------------------------------
public boolean interact(EntityPlayer entityplayer)
{
ItemStack itemstack = entityplayer.inventory.getCurrentItem(); //see what the interacting player is holding
if(MountItem >= 0 && mountable != -2) //you need an item to mount
{
mountable = 0; //reset mountable in case an item is needed to mount. No cheating!
}
//if you have noting, and it's not yours, nothing will happen
if(itemstack == null && owner < 0)
{
return false;
}
//if riding, dismount, no matter what is in hand
if(riddenByEntity != null && riddenByEntity == entityplayer)
{
mountThis(entityplayer);
return true;
}
if(mountable == 0) //if you need an item to mount,
{
for(int j = 0; j < entityplayer.inventory.mainInventory.length; j++)
{
if(entityplayer.inventory.mainInventory[j] != null && entityplayer.inventory.mainInventory[j].itemID == MountItem)
{
mountable = 1;
break;
}
}
}
//if you have nothing, but own this mob, bring up the menu
if(itemstack == null && owner == entityplayer.entityId)
{
//one liner with ModLoader to open GUIs
ModLoader.OpenGUI(entityplayer, new TamableGUIMenu(this, entityplayer));
}
//To tame it, you have to give it something it likes, and it can't be already owned
if(itemstack != null && itemstack.itemID == favItem && owner < 0)
{
itemstack.stackSize--; //you give the item
if(itemstack.stackSize <= 0)
{
entityplayer.inventory.setInventorySlotContents(entityplayer.inventory.currentItem, null);
}
mood += favBoost; //boost its mood
if(mood >= tamemood) //check if you tamed it
{
owner = entityplayer.entityId; //if so, it's yours now.
ownerName = entityplayer.username; //need this for finding the player in the world
//should call naming GUI at this point
Minecraft mc = ModLoader.getMinecraftInstance();
ParticleFX("heart");
mc.displayGuiScreen(new TamableGUIMenu(this, entityplayer)); //Should the GUI pop up the right now?
//maybe use just a naming GUI here...
return true;
}else
{
ParticleFX("note"); //it's happy it got something good
}
return true;
}
return false;
}
//END: Player interaction with mob-------------------------------------------
//START: Call to mount--------------------------------------------------------
public void mountThis(EntityPlayer entityplayer) //use this for mounting from GUI or direct mount
{
if (riddenByEntity == null || riddenByEntity == entityplayer)
{
follow = false; //reset follow toggle
entityplayer.mountEntity(this); //climb on/get off
}
}
//END: Call to mount--------------------------------------------------------
//START: File handling code
//these need to be used to save tamed/owned creatures - in progress...
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
super.writeEntityToNBT(nbttagcompound);
if(ownerName != "") //if it has an owner, might want to save the stats
{
nbttagcompound.setString("Ownername", ownerName);
nbttagcompound.setTag("Inventory", inventory.writeToNBT(new NBTTagList())); // it writes the inventory to file
nbttagcompound.setInteger("Age", myAge);
nbttagcompound.setDouble("myX", posX);
nbttagcompound.setDouble("myY", posY);
nbttagcompound.setDouble("myZ", posZ);
}
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
super.readEntityFromNBT(nbttagcompound);
ownerName = nbttagcompound.getString("Ownername"); //should only have this if there was an owner
myAge = nbttagcompound.getInteger("Age");
NBTTagList nbttaglist = nbttagcompound.getTagList("Inventory"); // must read inventory
inventory.readFromNBT(nbttaglist);
posX = nbttagcompound.getDouble("myX");
posY = nbttagcompound.getDouble("myY");
posZ = nbttagcompound.getDouble("myZ");
//not working. Mob does not spawn when game is reloaded....
}
//END: File handling code------------------------------------------------------
//START: Audio sounds----------------------------------------------------------
protected String getLivingSound()
{
return "mob.chicken";
}
protected String getHurtSound()
{
return "mob.chickenhurt";
}
protected String getDeathSound()
{
return "mob.chickenhurt";
}
//END: Audio sounds----------------------------------------------------------
protected int getDropItemId()
{
return 0; //set what this drops when it dies
}
//Used for Particle effect when tamed or other particles.
public static ArrayList particleList = new ArrayList();
void ParticleFX(String fx)
{
//these are found in RenderGlobal.java
particleList.add("heart");
particleList.add("smoke");
particleList.add("splash");
particleList.add("note");
particleList.add("flame");
particleList.add("bubble");
String s = fx;
if(particleList.indexOf(fx) < 0)
{
return; //passed an improper particle type and do nothing
}
for(int i = 0; i < 7; i++)
{
double d = rand.nextGaussian() * 0.02D;
double d1 = rand.nextGaussian() * 0.02D;
double d2 = rand.nextGaussian() * 0.02D;
worldObj.spawnParticle(s, (posX + (double)(rand.nextFloat() * width * 2.0F)) - (double)width, posY + 0.5D + (double)(rand.nextFloat() * height), (posZ + (double)(rand.nextFloat() * width * 2.0F)) - (double)width, d, d1, d2);
}
}
}
hmmm. I'm confused... I pulled that from entitywolf. Also when I mouse over the super call (another great thing about eclipse) it tells me it's taken from EntityCreature. Well, I was thinking that if you wanted (and might be more acturate, but more processing) you can move the follow if statement to onLivingUpdate. I will make the change and see if it works...
With the first error, is it a warning or an error (red)? Warnings are fine.
List list1 = worldObj.getCollidingBoundingBoxes(this, boundingBox.func_28195_e(0.03125D, 0.0D, 0.03125D));
error/s: The method func_28195_e (double, double , double) is undefined for type AxisAlignedBB,
List is a raw type .References to generic type list <E> should be parameterized.
and
super.updatePlayerActionState();
error: The method updatePlayerActionState is undefined for the type EntityAnimal
...
I see what's going on. You must have updated your MCP. I posted about this issue in my OP. I just did the same, and some of the func_### are now changed to real function names in the super classes. Here:
List list1 = worldObj.getCollidingBoundingBoxes(this, boundingBox.contract(0.03125D, 0.0D, 0.03125D));
that should fix that line (from EntityLiving).
Still don't know why the super call gives an error... Ops, I got it to now... Looks like that method was culled out, and is only in the player entity. That's fine, I'll move the code to a new spot. Will be posting an update later today.
[EDIT] fixed that too. The method name has changed:
protected void updateEntityActionState()
And therefore the super call name should be changed too:
By the way you can set what animals or creatures you want your mob to attack, in what difficulties your mob should spawn and a limit to it. You can also set your mob to attack IF the difficulty is easy,normal,hard,peacefull etc.
First off, here is the full code of a mob ( mostly taken from zombiepigman code) that disappears when the difficulty is set to 0 (which is peacefull) and attacks other creatures but not animals or you. It also has random drops.
This mob also has the zombiepigmen anger code so if you attack his friend it will attack you.
So take the full code and tinker it into yours.
[code]package net.minecraft.src;
import java.util.List;
import java.util.Random;
public class EntitySomething extends EntityCreature
{
public EntitySomething(World world)
{
super(world);
//This is the texture for your mob
texture = "/something.png";
attackStrength = 1; //how much damage mob does, i think 2 is equal to 1 heart of damage
moveSpeed = 0.5F; // how fast the mob moves
randomSoundDelay = 0;
angerLevel = 0; // the mob starts out peacefull(towards player) if you hit him or his friends they will have more anger level and attack you
field_21005_force = 5;
field_21004_a = 16D;
field_21002_heldedItem = rand.nextInt(field_21003_a.length);
}
public void onUpdate()
{
moveSpeed = entityToAttack == null ? 0.5F : 0.95F;
if(randomSoundDelay > 0 && --randomSoundDelay == 0)
{
worldObj.playSoundAtEntity(this, "mob.zombiepig.zpigangry", getSoundVolume() * 2.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F) * 1.8F);
}
super.onUpdate();
if(worldObj.difficultySetting == 0)
{
setEntityDead();
}
}
public int getMaxSpawnedInChunk()
{
return 3;
}
/*public boolean getCanSpawnHere()
{
int i = MathHelper.floor_double(posX);
int j = MathHelper.floor_double(boundingBox.minY);
int k = MathHelper.floor_double(posZ);
int l = worldObj.getBlockId(i, j - 1, k);
return worldObj.checkIfAABBIsClear(boundingBox) && worldObj.getCollidingBoundingBoxes(this, boundingBox).size() == 0 && !worldObj.getIsAnyLiquid(boundingBox) && (l == Block.cloth.blockID || l == Block.planks.blockID);
}
*/
public void writeEntityToNBT(NBTTagCompound nbttagcompound)
{
super.writeEntityToNBT(nbttagcompound);
nbttagcompound.setShort("Anger", (short)angerLevel);
}
public void readEntityFromNBT(NBTTagCompound nbttagcompound)
{
super.readEntityFromNBT(nbttagcompound);
angerLevel = nbttagcompound.getShort("Anger");
}
protected Entity findPlayerToAttack()
{
if(worldObj.difficultySetting > 2)
{
float f = getEntityBrightness(1.0F);
if(f < 0.0F)
{
EntityPlayer entityplayer = worldObj.getClosestPlayerToEntity(this, field_21004_a);
if(entityplayer != null)
{
return entityplayer;
}
}
if(rand.nextInt(10) == 0)
{
EntityLiving entityliving = func_21002_o(this, 10D);
return entityliving;
}
}
return null;
}
public EntityLiving func_21002_o(Entity entity, double d)
{
double d1 = -1D;
EntityLiving entityliving = null;
for(int i = 0; i < worldObj.loadedEntityList.size(); i++)
{
Entity entity1 = (Entity)worldObj.loadedEntityList.get(i);
if(!(entity1 instanceof EntityLiving) || entity1 == entity || entity1 == entity.riddenByEntity || entity1 == entity.ridingEntity || (entity1 instanceof EntityPlayer) || (entity1 instanceof EntityAnimal) )
{
continue;
}
double d2 = entity1.getDistanceSq(entity.posX, entity.posY, entity.posZ);
if((d < 0.0D || d2 < d * d) && (d1 == -1D || d2 < d1) && ((EntityLiving)entity1).canEntityBeSeen(entity))
{
d1 = d2;
entityliving = (EntityLiving)entity1;
}
}
return entityliving;
}
public void onLivingUpdate()
{
super.onLivingUpdate();
}
public boolean attackEntityFrom(Entity entity, int i)
{
if(entity instanceof EntityPlayer)
{
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.expand(32D, 32D, 32D));
for(int j = 0; j < list.size(); j++)
{
Entity entity1 = (Entity)list.get(j);
if(entity1 instanceof EntitySomething)
{
EntitySomething entitysomething= (EntitySomething)entity1;
entitysomething.becomeAngryAt(entity);
}
}
becomeAngryAt(entity);
}
return super.attackEntityFrom(entity, i);
}
private void becomeAngryAt(Entity entity)
{
entityToAttack = entity;
angerLevel = 400 + rand.nextInt(400);
randomSoundDelay = rand.nextInt(40);
}
protected void attackEntity(Entity entity, float f)
{
if((double)f < 2.5D && entity.boundingBox.maxY > boundingBox.minY && entity.boundingBox.minY < boundingBox.maxY)
{
attackTime = 20;
entity.attackEntityFrom(this, field_21005_force);
}
}
protected String getLivingSound()
{
return "mob.zombiepig.zpig";
}
protected String getHurtSound()
{
return "mob.zombiepig.zpighurt";
}
protected String getDeathSound()
{
return "mob.zombiepig.zpigdeath";
}
public ItemStack getHeldItem()
{
return field_21003_a[field_21002_heldedItem];
}
protected int getDropItemId()
{
return field_21001_dropItems[rand.nextInt(field_21001_dropItems.length)];
}
private int angerLevel;
private int randomSoundDelay;
protected double field_21004_a;
public boolean field_21004_bearboolean;
protected int field_21005_force;
private int field_21002_heldedItem;
private static final ItemStack field_21003_a[];
private static final int field_21001_dropItems[];
static
{
field_21003_a = (new ItemStack[] {
new ItemStack(Item.stick, 1), new ItemStack(Item.book, 1), new ItemStack(Item.compass, 1), new ItemStack(Item.fishingRod, 1), new ItemStack(Item.bread, 1), new ItemStack(Block.torchRedstoneActive, 1), new ItemStack(Item.paper, 1)
});
field_21001_dropItems = (new int[] {
Item.bread.shiftedIndex, Item.stick.shiftedIndex, Item.fishRaw.shiftedIndex, Block.torchWood.blockID, Item.appleRed.shiftedIndex, Item.appleRed.shiftedIndex
});
}
protected int attackStrength;
}[/code]
Allright, lets look at this code and the parts that interest us.
Setting on which diffuculty the mob should disappear:( It still spawns actually, but disappears in a milisecond... so yea.)
Now on top of this full code there is this:
Now part of this was taken from zombiepigmen, I personally haven't focused on the randomsounddelay part of this. However you can see that this part here is used to set on which difficulty the entity will disappear from the world.
This one is kind of obvious too. Set the difficulty setting here(0,1,2,3) and if the difficulty setting is bigger than that setting the mob will attack the mobs you define BELOW.
Setting what mobs the entity should attack:
Now a lot of people probably wants to do this. Here you go,over this part:
[code] public EntityLiving func_21002_o(Entity entity, double d)[/code]
Here you set what mobs it should NOT attack. I have set it so this mob will( when difficulty level is set) attack any other mob but not the player or any animals. So it will attack creatures(skeleton,zombie vs) and new mobs that you created.
So to make the entity NOT attack creatures, we make it like this:
So we quickly added [code]|| (entity1 instanceof EntityCreature)[/code] to the end before the last ")".
Setting what item the mob should hold and drop:
Well for this a list is created. So the mob randomly drops or holds something in this list. I believe you should be able to make it a one item list too. So no probs there.
Now, go to the end of the full code. You see here:
[code] static
{
field_21003_a = (new ItemStack[] {
new ItemStack(Item.stick, 1), new ItemStack(Item.book, 1), new ItemStack(Item.compass, 1), new ItemStack(Item.fishingRod, 1), new ItemStack(Item.bread, 1), new ItemStack(Block.torchRedstoneActive, 1), new ItemStack(Item.paper, 1)
});
field_21001_dropItems = (new int[] {
Item.bread.shiftedIndex, Item.stick.shiftedIndex, Item.fishRaw.shiftedIndex, Block.torchWood.blockID, Item.appleRed.shiftedIndex, Item.appleRed.shiftedIndex
});
} [/code]
The first list is what he holds and the other list is what it drops when dead. So you can put whatever items or blocks you want here. Pretty simpleish.
I hope this helps people. I don't know how this code applies on other models or renders though. I have only tried this on ModelBiped and RenderBiped. So good luck.
By the way you can set what animals or creatures you want your mob to attack, in what difficulties your mob should spawn and a limit to it. You can also set your mob to attack IF the difficulty is easy,normal,hard,peacefull etc.
First off, here is the full code of a mob ( mostly taken from zombiepigman code) that disappears when the difficulty is set to 0 (which is peacefull) and attacks other creatures but not animals or you. It also has random drops.
This mob also has the zombiepigmen anger code so if you attack his friend it will attack you.
So take the full code and tinker it into yours
.
..
...
I hope this helps people. I don't know how this code applies on other models or renders though. I have only tried this on ModelBiped and RenderBiped. So good luck.
Good deal here killNature. This should work for any mob type. Good explainations. Will add this need data to my class, which should be coming to an end. Still working the save code... Not sure what is called by the wolf to make it save a re-appear with all info. I'd added all the save code it had. I'm having to go outside with slant's DataSaver class add on...
Well, I would think that you would have to make a new method in your Model code, deleting the old boxes, and defining new ones. This could be called the same way I did my custom animations. I haven't tried it, but it's easy to check.
If you have a GUI make a button that will call up a method in your model class to delete, say, the head. If you can do that, then it should work. Interesting idea, I can do a test sample and post it later.
Nope. Theres a better way: in EntityPig, down at the bottom, there is a piece of code that instantiates a zombie pigman when the pig is struck by lightning. Create a counter, when the counter reaches a certain point: BAM! The new mob is there, old one isn't.
Is there a way to get a mob to only spawn on a specific type of blocks, say I want it to only spawn in trees, would the getBlockId(int x, int y, int z) method in the world class be the one that could help in this.
I'm working on the moving animations for my mobs in Animals+. I got so my Platypus is working correctly, except when I look at it, my screen goes crazy and I can't move or see a thing. I tried to take a screenshot, but it wouldn't let me, with F2 or PrintScreen. Myself and SnowFox102 are both stuck and can't figure it out. It recompiles fine, but once I look at the platypus, the cmd for minecraft gets spammed this error tons of times a minute.
This is the Error I get on the command prompt thing when I look at the platypus.
[17:05] ########## GL ERROR ##########
[17:05] @ Post render
[17:05] 1282: Invalid operation
[17:05] java.lang.NullPointerException
[17:05] at net.minecraft.src.ModelRenderer.compileDisplayList(ModelRenderer.java
:218)
[17:05] at net.minecraft.src.ModelRenderer.render(ModelRenderer.java:113)
[17:05] at net.minecraft.src.ModelPlatypus.render(ModelPlatypus.java:106)
[17:05] at net.minecraft.src.RenderLiving.doRenderLiving(RenderLiving.java:65)
[17:05] at net.minecraft.src.RenderPlatypus.func_177_a(RenderPlatypus.java:15)
[17:05] at net.minecraft.src.RenderPlatypus.doRender(RenderPlatypus.java:27)
[17:05] at net.minecraft.src.RenderManager.renderEntityWithPosYaw(RenderManager.
java:134)
[17:05] at net.minecraft.src.RenderManager.renderEntity(RenderManager.java:125)
[17:05] at net.minecraft.src.RenderGlobal.renderEntities(RenderGlobal.java:307)
[17:05] at net.minecraft.src.EntityRenderer.renderWorld(EntityRenderer.java:567)
[17:05] at net.minecraft.src.EntityRenderer.updateCameraAndRender(EntityRenderer
.java:430)
[17:05] at net.minecraft.src.EntityRendererProxy.updateCameraAndRender(EntityRen
dererProxy.java:23)
[17:05] at net.minecraft.client.Minecraft.run(Minecraft.java:514)
[17:05] at java.lang.Thread.run(Unknown Source)
Is there a way to get a mob to only spawn on a specific type of blocks, say I want it to only spawn in trees, would the getBlockId(int x, int y, int z) method in the world class be the one that could help in this.
Yes, check out the method getCanSpawnHere() in EntityAnimal for a good example. It makes it so animals can only spawn on grass blocks with enough light.
wow that's absolutely brilliant!
i just wonder if all the mobs who spawn on the same time will 'transform' to an other model :tongue.gif:
but this is really brilliant, i'd like to test it, if i manage to.
By counter I mean it counts the amount of items you give it. I didn't even think of using it with clocks! This opens up a world of opportunities.
1. Make the mob fly when another mob that is flying hits it
2. Make the mob fly randomly (by itself) and then randomly returning to the ground
To no avail I tried playing with:
this.motionY +=0.400000000001D or even make it += 1.0000000000001D and place it under onLivingUpdate()
but this code never tells it to fly when its hit by another mob that is not on ground :sad.gif:
I also tried
if (!entity.onGround && entity.hasAttacked && this.beenAttacked) //the (!) means not //
{
this.motionY +=0.4000000001D //because i wanted it to cruise up easily and gently
if(this.posY >= entity.posY) //this suppose to tell if the mobs position is more than
{ // the entity that attacked position then be equal to it
this.posY = entity.posY
}
}
okay but here is the problem the code does not recognize that (entity) is suppose to be the entity that attacked my mob (this). :sad.gif:
I'm working on the moving animations for my mobs in Animals+. I got so my Platypus is working correctly, except when I look at it, my screen goes crazy and I can't move or see a thing. I tried to take a screenshot, but it wouldn't let me, with F2 or PrintScreen. Myself and SnowFox102 are both stuck and can't figure it out. It recompiles fine, but once I look at the platypus, the cmd for minecraft gets spammed this error tons of times a minute.
This is the Error I get on the command prompt thing when I look at the platypus.
[17:05] ########## GL ERROR ##########
[17:05] @ Post render
[17:05] 1282: Invalid operation
[17:05] java.lang.NullPointerException
[17:05] at net.minecraft.src.ModelRenderer.compileDisplayList(ModelRenderer.java
:218)
[17:05] at net.minecraft.src.ModelRenderer.render(ModelRenderer.java:113)
[17:05] at net.minecraft.src.ModelPlatypus.render(ModelPlatypus.java:106)
[17:05] at net.minecraft.src.RenderLiving.doRenderLiving(RenderLiving.java:65)
[17:05] at net.minecraft.src.RenderPlatypus.func_177_a(RenderPlatypus.java:15)
[17:05] at net.minecraft.src.RenderPlatypus.doRender(RenderPlatypus.java:27)
[17:05] at net.minecraft.src.RenderManager.renderEntityWithPosYaw(RenderManager.
java:134)
[17:05] at net.minecraft.src.RenderManager.renderEntity(RenderManager.java:125)
[17:05] at net.minecraft.src.RenderGlobal.renderEntities(RenderGlobal.java:307)
[17:05] at net.minecraft.src.EntityRenderer.renderWorld(EntityRenderer.java:567)
[17:05] at net.minecraft.src.EntityRenderer.updateCameraAndRender(EntityRenderer
.java:430)
[17:05] at net.minecraft.src.EntityRendererProxy.updateCameraAndRender(EntityRen
dererProxy.java:23)
[17:05] at net.minecraft.client.Minecraft.run(Minecraft.java:514)
[17:05] at java.lang.Thread.run(Unknown Source)
It could be because you are rendering the head, body and legs twice. super.render(f, f1, f2, f3, f4, f5); covers those renders from the super class. Same with in the variable declairations at the bottom.
o and i just want to say there is nothing wrong with the code like no errors but nothing spawns of even shows up on spc
And how exactly are you spawning this? I have posted 2 ways to spawn this in game (one has it spawn when the game starts). Try those first. Sometimes it takes a while for them to spawn.
error/s: The method func_28195_e (double, double , double) is undefined for type AxisAlignedBB,
List is a raw type .References to generic type list <E> should be parameterized.
and
error: The method updatePlayerActionState is undefined for the type EntityAnimal
Entitycode (its basicly a copy of your tamable entity, just modified to another name)
hmmm. I'm confused... I pulled that from entitywolf. Also when I mouse over the super call (another great thing about eclipse) it tells me it's taken from EntityCreature. Well, I was thinking that if you wanted (and might be more acturate, but more processing) you can move the follow if statement to onLivingUpdate. I will make the change and see if it works...
With the first error, is it a warning or an error (red)? Warnings are fine.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
Put back in the quantityDropped(Random random) method, and have it return 1; or how ever many you want to drop
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
I see what's going on. You must have updated your MCP. I posted about this issue in my OP. I just did the same, and some of the func_### are now changed to real function names in the super classes. Here:
that should fix that line (from EntityLiving).
Still don't know why the super call gives an error... Ops, I got it to now... Looks like that method was culled out, and is only in the player entity. That's fine, I'll move the code to a new spot. Will be posting an update later today.
[EDIT] fixed that too. The method name has changed:
And therefore the super call name should be changed too:
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
First off, here is the full code of a mob ( mostly taken from zombiepigman code) that disappears when the difficulty is set to 0 (which is peacefull) and attacks other creatures but not animals or you. It also has random drops.
This mob also has the zombiepigmen anger code so if you attack his friend it will attack you.
So take the full code and tinker it into yours.
Allright, lets look at this code and the parts that interest us.
Setting on which diffuculty the mob should disappear:( It still spawns actually, but disappears in a milisecond... so yea.)
Now on top of this full code there is this:
Now part of this was taken from zombiepigmen, I personally haven't focused on the randomsounddelay part of this. However you can see that this part here is used to set on which difficulty the entity will disappear from the world.
[code] super.onUpdate(); if(worldObj.difficultySetting == 0) { setEntityDead(); }[/code]
0,1,2,3 is peacefull,easy,normal,hard respectively. So that part is that.
Setting how many max of the mob should spawn in a chunk:
Now , over here right below is this:
[code] public int getMaxSpawnedInChunk() { return 3; }[/code]
It is kind of obvious. You can set how many of this entity can spawn in a chunk at a time. Here it is set to 3 at a time.
Setting on which difficulty the mob should attack.
The next part here:
[code] protected Entity findPlayerToAttack() { if(worldObj.difficultySetting > 2) {[/code]
This one is kind of obvious too. Set the difficulty setting here(0,1,2,3) and if the difficulty setting is bigger than that setting the mob will attack the mobs you define BELOW.
Setting what mobs the entity should attack:
Now a lot of people probably wants to do this. Here you go,over this part:
[code] public EntityLiving func_21002_o(Entity entity, double d)[/code]
When you go below a bit you will see this:
[code] if(!(entity1 instanceof EntityLiving) || entity1 == entity || entity1 == entity.riddenByEntity || entity1 == entity.ridingEntity || (entity1 instanceof EntityPlayer) || (entity1 instanceof EntityAnimal) )[/code]
Here you set what mobs it should NOT attack. I have set it so this mob will( when difficulty level is set) attack any other mob but not the player or any animals. So it will attack creatures(skeleton,zombie vs) and new mobs that you created.
So to make the entity NOT attack creatures, we make it like this:
[code][code] if(!(entity1 instanceof EntityLiving) || entity1 == entity || entity1 == entity.riddenByEntity || entity1 == entity.ridingEntity || (entity1 instanceof EntityPlayer) || (entity1 instanceof EntityAnimal) || (entity1 instanceof EntityCreature) )[/code][/code]
So we quickly added [code]|| (entity1 instanceof EntityCreature)[/code] to the end before the last ")".
Setting what item the mob should hold and drop:
Well for this a list is created. So the mob randomly drops or holds something in this list. I believe you should be able to make it a one item list too. So no probs there.
Now, go to the end of the full code. You see here:
[code] static { field_21003_a = (new ItemStack[] { new ItemStack(Item.stick, 1), new ItemStack(Item.book, 1), new ItemStack(Item.compass, 1), new ItemStack(Item.fishingRod, 1), new ItemStack(Item.bread, 1), new ItemStack(Block.torchRedstoneActive, 1), new ItemStack(Item.paper, 1) }); field_21001_dropItems = (new int[] { Item.bread.shiftedIndex, Item.stick.shiftedIndex, Item.fishRaw.shiftedIndex, Block.torchWood.blockID, Item.appleRed.shiftedIndex, Item.appleRed.shiftedIndex }); } [/code]
The first list is what he holds and the other list is what it drops when dead. So you can put whatever items or blocks you want here. Pretty simpleish.
I hope this helps people. I don't know how this code applies on other models or renders though. I have only tried this on ModelBiped and RenderBiped. So good luck.
Good deal here killNature. This should work for any mob type. Good explainations. Will add this need data to my class, which should be coming to an end. Still working the save code... Not sure what is called by the wolf to make it save a re-appear with all info. I'd added all the save code it had. I'm having to go outside with slant's DataSaver class add on...
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
Render file
import org.lwjgl.opengl.GL11;
// Referenced classes of package net.minecraft.src:
// RenderLiving, JWorld_EntityExample, ModelBase, EntityLiving,
// Entity
public class JWorld_AnibusRender extends RenderLiving
{
public JWorld_AnibusRender(JWorld_AnibusModel modelbase, float f)
{
super(modelbase, f);
}
public void func_177_a(JWorld_AnibusEntity entity, double d, double d1, double d2,
float f, float f1)
{
super.doRenderLiving(entity, d, d1, d2, f, f1);
}
public void doRenderLiving(EntityLiving entityliving, double d, double d1, double d2,
float f, float f1)
{
super.doRenderLiving((JWorld_AnibusEntity) entityliving, d, d1, d2, f, f1);
}
public void doRender(Entity entity, double d, double d1, double d2,
float f, float f1)
{
doRenderLiving((JWorld_AnibusEntity)entity, d, d1, d2, f, f1);
}
//attempting to scale
protected void preRenderScale(JWorld_AnibusEntity entity, float f)
{
GL11.glScalef(1.25F, 1.25F, 1.25F);
}
protected void preRenderCallback(EntityLiving entityliving, float f)
{
preRenderScale((JWorld_AnibusEntity)entityliving, f);
}
}
Entity file
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.cow";
}
protected String getDeathSound()
{
return "mob.cow";
}
protected float getSoundVolume()
{
return 0.4F;
}
protected int getDropItemId()
{
return 0;
}
public boolean interact(EntityPlayer entityplayer)
{
//can use this for right click reactions
return false;
}
}
Mod file
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 "1.7_3";
}
Render file
Entity file
Mod file
In the mod file try changing:
To:
Thanks im going to try it right now
o and i just want to say there is nothing wrong with the code like no errors but nothing spawns of even shows up on spc
Nope. Theres a better way: in EntityPig, down at the bottom, there is a piece of code that instantiates a zombie pigman when the pig is struck by lightning. Create a counter, when the counter reaches a certain point: BAM! The new mob is there, old one isn't.
Come on, bro, I got CREEPER BLOOD! (winning!)
This is the Error I get on the command prompt thing when I look at the platypus.
Render Code
Model Code
Thanks,
Muserae
Yes, check out the method getCanSpawnHere() in EntityAnimal for a good example. It makes it so animals can only spawn on grass blocks with enough light.
By counter I mean it counts the amount of items you give it. I didn't even think of using it with clocks! This opens up a world of opportunities.
Come on, bro, I got CREEPER BLOOD! (winning!)
1. Make the mob fly when another mob that is flying hits it
2. Make the mob fly randomly (by itself) and then randomly returning to the ground
To no avail I tried playing with:
this.motionY +=0.400000000001D or even make it += 1.0000000000001D and place it under onLivingUpdate()
but this code never tells it to fly when its hit by another mob that is not on ground :sad.gif:
I also tried
if (!entity.onGround && entity.hasAttacked && this.beenAttacked) //the (!) means not //
{
this.motionY +=0.4000000001D //because i wanted it to cruise up easily and gently
if(this.posY >= entity.posY) //this suppose to tell if the mobs position is more than
{ // the entity that attacked position then be equal to it
this.posY = entity.posY
}
}
okay but here is the problem the code does not recognize that (entity) is suppose to be the entity that attacked my mob (this). :sad.gif:
is there any work around for this
link: The Dragon Ball Mod Alpha 1.1
By implementing two external methods
first method: was to notify my code that my entity was hurt which I used data.Watcher coming from EntityLiving.class
the data.Watcher can be seen in code when viewing the EntityWolf.class (isWolfAngry) method
second method: was to assign a method to make my mob follow any entity living found in a range of 30D (Double Numbers)
then I called this under the common method onLivingUpdate()
It works now :smile.gif:
p.s. Ive used this.motionY += 0.40000000001D this makes a smooth climb
link: The Dragon Ball Mod Alpha 1.1
It could be because you are rendering the head, body and legs twice. super.render(f, f1, f2, f3, f4, f5); covers those renders from the super class. Same with in the variable declairations at the bottom.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE
And how exactly are you spawning this? I have posted 2 ways to spawn this in game (one has it spawn when the game starts). Try those first. Sometimes it takes a while for them to spawn.
OLD 1.7: http://www.minecraftforum.net/topic/529327-modloader173-adding-custom-mobs-and-more/ ---inLanoche says : USE ECLIPSE