Jump to content

Once more into asking for help!(Updated:Found problem, now just need a solution)


Recommended Posts

Posted

Post has been edited incase anyone has looked at it before now 12/27/12!

 

It appears that when my tame function is thrown into action, that it is only saving the information to the client side. This causes all of the information not to save server side, thus not making a server side tamed digimon at all. I'm looking for a way to make all the info save both client side and server side.

 

 

In case thats not enough to go on(and its probably not), Below is my entire entity file.

Please just ignore all the things that have been commented out or otherwise look like they don't do anything. They are being reworked. :P

 

 

package digimobs.common;

import java.util.List;
import java.util.Random;

import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly;
import cpw.mods.fml.common.registry.EntityRegistry;

import net.minecraft.src.BiomeGenBase;
import net.minecraft.src.DamageSource;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityAIAttackOnCollide;
import net.minecraft.src.EntityAIBreakDoor;
import net.minecraft.src.EntityAIFollowOwner;
import net.minecraft.src.EntityAIHurtByTarget;
import net.minecraft.src.EntityAILeapAtTarget;
import net.minecraft.src.EntityAILookIdle;
import net.minecraft.src.EntityAIMate;
import net.minecraft.src.EntityAIOwnerHurtByTarget;
import net.minecraft.src.EntityAIOwnerHurtTarget;
import net.minecraft.src.EntityAISwimming;
import net.minecraft.src.EntityAITargetNonTamed;
import net.minecraft.src.EntityAITempt;
import net.minecraft.src.EntityAIWander;
import net.minecraft.src.EntityAIWatchClosest;
import net.minecraft.src.EntityAnimal;
import net.minecraft.src.EntityCreature;
import net.minecraft.src.EntityList;
import net.minecraft.src.EntityLiving;
import net.minecraft.src.EntityMob;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.EntityPlayerMP;
import net.minecraft.src.EntitySheep;
import net.minecraft.src.EntityTameable;
import net.minecraft.src.EntityVillager;
import net.minecraft.src.EnumCreatureType;
import net.minecraft.src.IAnimals;
import net.minecraft.src.IMob;
import net.minecraft.src.Item;
import net.minecraft.src.ItemFood;
import net.minecraft.src.ItemStack;
import net.minecraft.src.MathHelper;
import net.minecraft.src.ModLoader;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.PathEntity;
import net.minecraft.src.World;
import net.minecraft.src.WorldType;

public abstract class EntityDigimon extends EntityCreature implements IAnimals
{
    
public EntityDigimon(World world)
    {
        super(world);
        newDigimon();
        //posX = ModLoader.getMinecraftInstance().thePlayer.posX;
        //posY = ModLoader.getMinecraftInstance().thePlayer.posY;
        //posZ = ModLoader.getMinecraftInstance().thePlayer.posZ;
       // System.out.println("!");
        
       

    }

    public void entityInit()
    {
        super.entityInit();
    }

    public void newDigimon()
    {
        name = EntityList.getEntityString(this);
        baseExp = 5;
        baseatk = 1;
        factor = 2;
        owner = "";
        nickname = name;
        minimumRange = 4;
        maximumRange = 6;
        setLevel((short)(rand.nextInt(4) + 1)); //this will make levels 1-4  rand.nextInt(M-m+1)+m; M= max level m= min level
        exp = 0;
        health = baseHealth = 6;
        health = getMaxHealth();
        attackCounter = 0;
        sitting = false;
        inXros = false;
        home = new Vector3(0, 0, 0);
        atHome = false;
        npc = false;
        range = 2.0F;
        moveSpeed=1;
        //level = 1;
        //hunger=getMaxHunger();
    }

    public EntityDigimon isNpc()
    {
        npc = true;
        return this;
    }

    protected void fall(float f)
    {
        if (!tamed)
        {
            super.fall(f);
            return;
        }

        if (f > 6)
            ModLoader.getMinecraftInstance().thePlayer.addChatMessage("<"
                    + getNickname() + "> Help me! ...I fell");
    }

    public void writeEntityToNBT(NBTTagCompound nbt)
    {
        super.writeEntityToNBT(nbt);
        nbt.setString("owner", owner);
        nbt.setDouble("homeX", home.X);
        nbt.setDouble("homeY", home.Y);
        nbt.setDouble("homeZ", home.Z);
        nbt.setShort("level", level);
        nbt.setString("name", name);
        nbt.setString("nickname", nickname);
        nbt.setBoolean("tamed", tamed);
        nbt.setInteger("exp", exp);
        nbt.setBoolean("sitting", sitting);
        nbt.setBoolean("inXros", inXros);
        nbt.setBoolean("atHome", atHome);
        nbt.setFloat("Hunger", hunger);

        if (tamerName != null)
        {
            nbt.setString("TamerName", tamerName);
        }
    }

    public void readEntityFromNBT(NBTTagCompound nbt)
    {
        super.readEntityFromNBT(nbt);
        level = nbt.getShort("level");
        name = nbt.getString("name");
        nickname = nbt.getString("nickname");
        tamed = nbt.getBoolean("tamed");
        owner = nbt.getString("owner");
        exp = nbt.getInteger("exp");
        sitting = nbt.getBoolean("sitting");
        inXros = nbt.getBoolean("inXros");
        home = new Vector3(nbt.getDouble("homeX"), nbt.getDouble("homeY"),
                nbt.getDouble("homeZ"));
        atHome = nbt.getBoolean("atHome");
        tamerName = nbt.getString("TamerName");
        hunger = nbt.getFloat("hunger");

        if (health == 0)
        {
            health = getMaxHealth();
        }
    }
    
    
    public Vector3 getHome()
    {
        return home;
    }

    public void attackEntity(Entity entity, float f)
    {
        if (attackTime <= 0 && f < range && entity.boundingBox.maxY > boundingBox.minY && entity.boundingBox.minY < boundingBox.maxY)
        {
            entity.attackEntityFrom(DamageSource.causeMobDamage(this), getAttack());
            attackTime = 20;
        }
    }

    public boolean attackEntityFrom(DamageSource damagesource, int i)
    {
      /*  if (damagesource == digimobs.ropeCapture)
        {
            i = getMaxHealth() / 5;

            if (i >= health)
            {
                i = health - 1;
            }
        }*/

        Entity entity = damagesource.getEntity();

        if (!tamed && entity instanceof EntityPlayer)
        {
            if (rand.nextInt(3) == 2)
            {
                dropItem(digimobs.digitear.shiftedIndex, 1);
            }
        }
        else
        {
            setTarget(entity);
        }

        i = calculateDefense(i);

       // if  ( health == level/4)
       // {
      //      prepareToTame();
     //   }

        return super.attackEntityFrom(damagesource, i);
    }

    public void prepareToTame()
    {
        readyToTame = true;
        timeToTame = 200;
    }

   

    public boolean isTamed()
    {
    	
        return tamed;
    }

    public boolean isHome()
    {
        return atHome;
    }

    public void setAtHome(boolean b)
    {
        atHome = b;
    }
   /*public int calculateSpeed(int i) {
    	
    	float j = (moveSpeed+level) / 10;
	return 1;
}*/
    public int calculateDefense(int i)
    {
        int j = level / 10;
        return j >= i ? 0 : i - j;
    }

    public int getMaxHealth()
    {
        return level / 2 + baseHealth; // Baby 4, Intraining 7, Rookie 12, Champion 17, Ultimate 27, Mega 42
    }

    public void lureMonsters()
    {
        List list = worldObj.getEntitiesWithinAABB(EntityMob.class,
                boundingBox.expand(10D, 10D, 10D));

        for (int i = 0; i < list.size(); i++)
        {
        	
            EntityMob mob = (EntityMob) list.get(i);

          /*\  if (mob instanceof EntitySpider)
            {
                if (worldObj.isDaytime()
                        && mob.entityToAttack != ModLoader
                        .getMinecraftInstance().thePlayer)
                {
                    continue;
                }
            }

            mob.entityToAttack = this;*/
        }
    }

    public void onLivingUpdate()
    {
        if (worldObj.getBlockTileEntity((int) posX, (int) posY - 1, (int) posZ) instanceof TileEntityDigiCage
                && !isTamed())
        {
            TileEntityDigiCage cage = (TileEntityDigiCage) worldObj
                    .getBlockTileEntity((int) posX, (int) posY - 1, (int) posZ);

            if (cage.hasAcorn())
            {
                cage.hasAcorn = false;
                tame(ModLoader.getMinecraftInstance().thePlayer);
                if(entityToAttack==null && isSitting())setPathToEntity(worldObj.getPathEntityToEntity (this,getTamer(),24F,true,false,false,true));
            }
        }

        lureMonsters();

        if (getNeededExp() <= 0)
        {
            level++;
            exp = 0;
        }

        super.onLivingUpdate();
    }

    public void onUpdate()
    {
        if (timeToTame > 0)
        {
            timeToTame--;

            if (timeToTame <= 0)
            {
                readyToTame = false;
            }
        }

        if (!readyToTame)
        {
            super.onUpdate();
        }
        else
        {
            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("crit", (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);
            }
        }

        if (tamed && entityToAttack instanceof EntityPlayer)
        {
            entityToAttack = null;
        }
        
       // if (tamed && hunger>0)hunger-=0.0001F;
       // if((int)hunger==(int)getMaxHunger())autoheal();
        
       


        
    }

    public void onDeath(DamageSource ds)
    {
       /* if (isTamed()) //&& ds.getEntity() instanceof EntityCreeper)
        {
            ModLoader.getMinecraftInstance().thePlayer.triggerAchievement(mod_digimon.missed);
        }*/

        super.onDeath(ds);

        if (isTamed() && canDropEgg())
        {
            EntityDigiEgg digiegg = new EntityDigiEgg(worldObj);
            digiegg.randomID = eggDrop();
            digiegg.setPosition(posX, posY, posZ);
            worldObj.spawnEntityInWorld(digiegg);
        }
    }

    public EntityPlayer getTamer()
    {
        if (tamerName == null)
        {
            return null;
        }

        return worldObj.getPlayerEntityByName(tamerName);
    }
    
  
    public void tame(EntityPlayer player)
    {
    	
        tamerName=player.username;
        sitting = true;
        motionX = 0;
        motionY = 0;
        motionZ = 0;
        tamed = true;
        exp = 0;
        atHome = false;
        hostile = false;
        rival = null;
        health = getMaxHealth();
        }
    
    
    
    //protected boolean isAIEnabled()
    //{
    //    return true;
   // }

    public void updateEntityActionState()
    {
        super.updateEntityActionState();

        if (isSitting())
        {
            return;
        }

        if (tamed)
        {
    if(entityToAttack==null){
            List list2 = worldObj.getEntitiesWithinAABB(net.minecraft.src.EntityCreature.class, boundingBox.expand(10D, 10D, 10D));
                for (int i =list2.size()-1; i >=0; i--)
            {
                if(isAlly(((EntityCreature)list2.get(i)).getEntityToAttack()))setTarget((Entity)list2.get(i));
            }
	if(entityToAttack==null && getTamer()!=null && getDistanceToEntity(getTamer())>4F)
	{
	PathEntity pathentity4 = worldObj.getPathEntityToEntity(this, getTamer(), 16F, true, false, false, true);
	setPathToEntity(pathentity4);
	}
}
            if (getTamer()!=null && getDistanceToEntity(getTamer())>20F && !isSitting())
            {
                setPosition(getTamer().posX, getTamer().posY + 2.0D, getTamer().posZ);
            }
        }
        else
        {
            List list1 = worldObj.getEntitiesWithinAABB(net.minecraft.src.EntityPlayer.class, boundingBox.expand(10D, 10D, 10D));

            for (int i = 0; i < list1.size(); i++)
            {
                EntityPlayer entityplayer = (EntityPlayer)list1.get(i);
                PathEntity pathentity = worldObj.getPathEntityToEntity(this, entityplayer, 10F, true, false, false, true);
                ItemStack itemstack = entityplayer.inventory.getCurrentItem();

                if (itemstack != null && (itemstack.getItem().shiftedIndex == Item.cookie.shiftedIndex || itemstack.getItem().shiftedIndex == digimobs.acorn.shiftedIndex))
                {
                    setPathToEntity(pathentity);
                }
            }
        }

        if (hostile && entityToAttack == null)
        {
            List players = worldObj.getEntitiesWithinAABB(EntityPlayer.class, boundingBox.expand(8D, 8D, 8D));

            if (players.size() > 0)
            {
                setTarget((Entity)players.get(rand.nextInt(players.size())));
            }
            else
            {
                List animals = worldObj.getEntitiesWithinAABB(EntityAnimal.class, boundingBox.expand(8D, 8D, 8D));

                if (animals.size() > 0)
                {
                    setTarget((Entity)animals.get(rand.nextInt(animals.size())));
                }
                else
                {
                    List digimon = worldObj.getEntitiesWithinAABB(EntityDigimon.class, boundingBox.expand(8D, 8D, 8D));

                    if (digimon.size() > 0)
                    {
                        Entity entity = (Entity)digimon.get(rand.nextInt(digimon.size()));

                        if (entity!=this && entity != null && !isAlly(entity))
                        {
                        	  setTarget(entity);
                        }
                    }
                }
            }
        }

        if (rival != null && !tamed)
        {
            List rivals = worldObj.getEntitiesWithinAABB(rival, boundingBox.expand(8D, 8D, 8D));

            if (rivals.size() > 0)
            {
                setTarget((Entity)rivals.get(rand.nextInt(rivals.size())));
            }
        }
    }

   
    
    
    //Lets make things fly
    protected void flyMovement(int min,int max,int tmin,int tmax, double spdup, double spddown)
    {
if(entityToAttack!=null)
{
	faceEntity(entityToAttack,range,maximumRange);
	motionY=spdup;
	if((int)boundingBox.minY>=(int)entityToAttack.boundingBox.maxY)motionY=spddown*2D;
	if((int)boundingBox.maxY<=(int)entityToAttack.boundingBox.minY)motionY=-spddown*2D;
}
else
{
if(riddenByEntity!=null ||!isEntityAlive())return;
if(!inflight)
{
	flyTime=rand.nextInt(tmax-tmin+1)+tmin;
	if(toGround()>min)motionY=spddown;
	else motionY=spdup/10D;
	if(rand.nextInt(64)==0 && posY<126D)
	{
		inflight=true;
	}
}
else
{
flyTime--;
if(!isSitting() && posY<126D && toGround()<max)motionY=spdup;
else inflight=false;
if(isEntityAlive())moveEntityWithHeading(1.0F - rand.nextFloat() * 2.0F, moveSpeed);
if(flyTime<=0)inflight=false;
}}
fallDistance=0F;
    }
    protected void startFly(double d,int min,int max)
    {
if(evo)return;
motionY=d;
inflight=true;
flyTime=rand.nextInt(max-min+1)+min;
    }
    
    public void animateFly(float min,float max,float add1)
    {
animateFly(min, max, add1, add1);
    }
    
    public void animateFly(float min,float max,float add1,float add2)
    {
if(!rotateDown && !rotateUp)rotateUp=true;
//if(evo)return;
if(rotateDown)
{
	rotateUp=false;
	wingrotation-=add1;
}
if(rotateUp)
{
	rotateDown=false;
	wingrotation+=add2;
}
if(wingrotation>max)
{
	wingrotation=max;
	rotateDown=true;
	rotateUp=false;
}
if(wingrotation<min)
{
	wingrotation=min;
	rotateUp=true;
	rotateDown=false;}
}
    
    public int toGround()
    {
    	return toGround(this);
    }
public int toGround(Entity entity)
    {
int i=MathHelper.floor_double(entity.posX);
int j=MathHelper.floor_double(entity.boundingBox.minY);
int k=MathHelper.floor_double(entity.posZ);
int l=0;
for(int k1 = 0; k1 <= 40; k1++)
{
if(worldObj.isAirBlock(i, j, k))
{
	l++;
	j--;

}
else
break;
}
return l;
    }

 public float getWingRotation()
 {return wingrotation;}

//End Flight movements

//Get Digimon unique attacks   
 /* public  void rangedAttack()
  {    
	  if(entityToAttack==null)return;
	  faceEntity(entityToAttack, 10F, 20F);
	  EntityRangedAttack rangedAttack=new EntityRangedAttack(worldObj);
	  rangedAttack.setLocationAndAngles(posX,posY+height/2,posZ,rotationYaw,rotationPitch);
	  double d = width;
	  Vec3D vec3d = getLook(1.0F);
	  rangedAttack.posX = posX + vec3d.xCoord * d;
	  rangedAttack.posY = posY + (double)height - 0.5D;
	  rangedAttack.posZ = posZ + vec3d.zCoord * d;
	  worldObj.playSoundAtEntity(this, attackName, 4F, 1.0F);
	  worldObj.spawnEntityInWorld(rangedAttack);}*/
  
  //public String getEntityTexture()
  //{
  //    return "/Digimon/Attacks/"+name+".png";
  //}
  //End Attacks
    

    public void evolve()
    {
        if (evolution != null && level >= evolveForm && tamed)
        {
            EntityDigimon entitydigimon = evolution;
            entitydigimon.tamerName = tamerName;
            evolveAnimation();
            entitydigimon.level = level;
            entitydigimon.nickname = nickname;
            entitydigimon.tamed = tamed;
            entitydigimon.owner = owner;
            entitydigimon.exp = exp;
            entitydigimon.health = entitydigimon.getMaxHealth();
            entitydigimon.setPosition(posX, posY, posZ);
            funParticles(posX, posY, posZ);
            ModLoader.getMinecraftInstance().thePlayer
            .addChatMessage((new StringBuilder())
                    .append(getNickname())
                    .append(" digivolve to... ")
                    .append(entitydigimon.name)
                    .append("!").toString());
            worldObj.spawnEntityInWorld(entitydigimon);
            setDead();
            //DigimonSaveHandler.saveDigimon(this);
        }
        else if (evolution == null)
            ModLoader.getMinecraftInstance().thePlayer
            .addChatMessage((new StringBuilder()).append("Sorry, ")
                    .append(getNickname())
                    .append(" doesn't have an evolution!").toString());
        else if (level < 11 * evolveForm)
            ModLoader.getMinecraftInstance().thePlayer
            .addChatMessage((new StringBuilder()).append("Sorry, ")
                    .append(getNickname())
                    .append(" needs more data to digivolve!").toString());
    }

    public void funParticles(double posX, double posY, double posZ)
    {
        String s = "magicCrit";

        for (int i = 0; i < 7; i++)
        {
            double d = rand.nextGaussian() * 0.52D - rand.nextGaussian();
            double d1 = rand.nextGaussian() * 0.52D - rand.nextGaussian();
            double d2 = rand.nextGaussian() * 0.52D - rand.nextGaussian();
            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);
        }
    }

    public boolean isAlly(Entity entity)
    {
        if(entity == null)return false;
        if(entity instanceof EntityDigimon && tamed)return ((EntityDigimon)entity).isTamed();
        if(entity instanceof EntityVillager)return true;
if(tamed && entity==getTamer())return true;
        return false;
    }

    public boolean interact(EntityPlayer entityplayer)
    {
    	
    	
    	
    		ItemStack itemstack = entityplayer.inventory.getCurrentItem();

        if (readyToTame && itemstack.itemID == digimobs.tamerdigivice.shiftedIndex)
        {
            tame(ModLoader.getMinecraftInstance().thePlayer);

            return true;
        }

        if (itemstack == null && isTamed())
        {
            sitting = !sitting;
            motionY = 0;
            motionX = 0;
            motionZ = 0;
            return true;
        }

       /*   if(itemstack!=null && itemstack.itemID == digimobs.xros.shiftedIndex)
        {
            itemstack = null;
            return false;
        }
        
        if (itemstack!=null && itemstack.itemID == digimobs.digirope.shiftedIndex)
        {
            itemstack = null;
            return false;
        }
        */
        
        if (itemstack!=null && itemstack.itemID == digimobs.tamerdigivice.shiftedIndex)
        {	itemstack = null;
        tame(ModLoader.getMinecraftInstance().thePlayer);
            return true;
        }
        

        if (isTamed() && itemstack.itemID == digimobs.data.shiftedIndex)
        {
        	switch(itemstack.getItemDamage()){
        	case 3:exp+=45;
        	case 2:exp+=35;
        	case 1:exp+=15;
        	case 0:exp+=10;
        	}
            entityplayer.inventory.consumeInventoryItem(itemstack.itemID);
            return true;
        }

        if (itemstack!=null && itemstack.getItem().shiftedIndex == digimobs.acorn.shiftedIndex
                ||itemstack!=null && itemstack.getItem().shiftedIndex == digimobs.acorn.shiftedIndex)
        {
            heal(;
            //if((int)hunger!=(int)getMaxHunger() && itemstack!=null && itemstack.getItem() instanceof ItemFood)hunger+=2;
            /*
             * worldObj.playSoundAtEntity( this, "sound.secret", 0.6F,
             * ((rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F) / 0.8F);
             */
            worldObj.spawnParticle("heart", posX, posY + height, posZ, 0,
                    0, 0);
            entityplayer.inventory.consumeInventoryItem(itemstack.itemID);
            return true;
        }

        if (isEvolveItem(itemstack) && isTamed())
        {
            evolve();
            //DigimonSaveHandler.saveDigimon(this);
            return true;
        }

        if (isTamed())
        {
            sitting = !sitting;
            motionY = 0;
            motionX = 0;
            motionZ = 0;
        }

        
    	
    	return super.interact(entityplayer);      
        

      
        
    }

   
    
    
    
    public int getAttack()
    {
    	return level / 5 + baseatk;
    	}

    public String getNickname()
    {
        if (nickname != "")
        {
            return nickname;
        }
        else
        {
            return name;
        }
    }
    
  //Evolution Items go here
    public boolean isEvolveItem(ItemStack itemstack)
    {
        if (itemstack == null)
        {
            return false;
        }

        if (digiLevel == 0)
        {
            return itemstack.itemID == digimobs.digivice.shiftedIndex; 
        }

        if (digiLevel == 1)
            return itemstack.itemID == digimobs.card.shiftedIndex
                    && isCorespondingType(itemstack.getItemDamage());

        if (digiLevel == 2)
            return itemstack.itemID == digimobs.crest.shiftedIndex
                    && isCorespondingType(itemstack.getItemDamage());

        if (digiLevel == 3)
            return itemstack.itemID == digimobs.mega.shiftedIndex
                    && isCorespondingType(itemstack.getItemDamage());

        //if (digiLevel == 4)
        //return itemstack.itemID == mod_digimon.mega.shiftedIndex
        //	&& isCorespondingType(itemstack.getItemDamage());
        return false;
    }

    public boolean isCorespondingType(int i)
    {
        return false;
    }
    //End Evolution Items

    //Drops go here
    protected void dropFewItems(boolean par1, int par2)
    {
      
    	//if(digiLevel==1)entityDropItem(new ItemStack(digimobs.chip,1,getDropDamage()),0.3F);
    	//if(digiLevel==3)entityDropItem(new ItemStack(digimobs.rawcrest,1,getDropDamage()),0.3F);
    	 
    }
    
    public int getDropDamage()
    {
    	return EntityDigiEgg.chipdata[eggDrop()];
    	}
   
    void dropChip()
    {
entityDropItem(new ItemStack(digimobs.chip.shiftedIndex, 1,EntityDigiEgg.chipdata[eggDrop()]), 0.5F);
    }
    
    public boolean canDropEgg()
    {
        return isTamed() && eggDrop() >= 0;
    }
    
    public int eggDrop()
    {
        return -1;
    }
    //End Drops
    
    //Other/Unfinished
// public float getMaxHunger()
    
    //{return 2F+(float)digiLevel;}
    
   // public void autoheal() {
   // 	healcounter++;
   //     if(healcounter>40){health+=1;
   //     healcounter=0;}
//}
    
    public void evolveAnimation()
    {
        // TODO: Get a animation!
    }
    //End Unfinished/Other
    
    protected boolean isMovementCeased()
    {
        return isSitting() && entityToAttack == null;
    }

    protected boolean canDespawn()
    {
        return !tamed;
    }

    public void setLevel(short s)
    {
        level = s;
    }
    

    public void setNickname(String s)
    {
        nickname = s;
    }

    public void setTamed(boolean f)
    {
        tamed = f;
    }

    public short getLevel()
    {
        return level;
    }

    public boolean isSitting()
    {
        return sitting;
    }

    public boolean inXros()
    {
        return inXros;
    }

    public void setinXros(boolean flag)
    {
        inXros = flag;
    }

    public void setSitting(boolean flag)
    {
        sitting = flag;
    }

    //Exp Stuff
    public int getExp()
    {
        return exp;
    }

    public int getNeededExp()
    {
        int maxNeeded = baseExp + level * factor;
        return maxNeeded - exp;
    }
    
    public int getExperiencePoints(EntityPlayer player)
    {
        return level + (level / 4);
    }
    //End Exp
    
    public int baseatk;
    public int evolveForm;
    public int timeToTame;
    public int baseExp;
    public int factor;
    public int baseHealth;
    public int digiLevel;
    public int flyTime;
    //private int healcounter;
    private int attackCounter;
    private int exp;
    private short level;
    public String attackName;
    public String tamerName;
    public String name;
    private String nickname;
    private String owner;
    public boolean readyToTame;
    public boolean tamed;
    public boolean hostile;
    public boolean npc;
    public boolean inflight;
    public boolean rotateUp;
    public boolean rotateDown;
    public boolean evo;
    private boolean sitting;
    private boolean atHome;
    private boolean inXros;
    public float range;
    public float minimumRange;
    public float maximumRange;
    public float hunger;
    public float wingrotation;
    private Vector3 home;
    public EntityDigimon evolution;
    public Class rival;
    public EntityDigimon alt;
}

 

 

Posted

for my tamed mobs i use instead of

 

 

public abstract class EntityDigimon extends EntityCreature implements IAnimals

 

 

this

 

 

public class EntityDigimon extends EntityTameable

 

 

if u wanna to your mob atack other players that hurt you, or mobs (like normal wolf)just create another EntityAiBeg changing the EntityWolf to EntityDigimon.

Posted

I thought you might have been on to something, but unfortunately I get the same problem :(

 

I updated my isTamed() and setTamed() functions with the info from EntityTameable, but it still resulted with the digimon not saving.

 

I'm thinking that the newDigimon() function is overriding the tame() function still.  I think I need a way to save the info from my tame() function to the server so that when the game starts, the newDigimon() does not override the tame()

 

Is this even possible to do without an outside file? I figure I could save the entities to a file and have them reloaded into the game everytime someone loads a world up, but that complicates the purpose of the function a little too much.

 

 

Edit: Okay. So experimenting with this a little more, the entity itself does save. But moving out of range/logging out resets the tame function.

 

So I guess what I am asking is how I can make the tame() function stay in effect after I have logged out.

 

Posted

I have registered them with registerModEntity, registerGlobalEntityID, and even both at the same time to no avail.

 

 

Edit: I have found the issue. The tamed digimon is only being saved client side, and not server side.

Now if only I could figure out how to save it server side.

Posted

You can use packets

 

I may need more explanation than that. I was under the impression that implementing IAnimals would send the packets to and from the server?

Posted

I have never played with mobs myself but you may need to create custom packets to send the data, but i am unsure.

I also think i heard about a datawatcher somewhen, but again i am unsure

Posted

So...I am back to update this topic as I am still having the same issue. I've tried using both the datawatchers and making a custom packet handler to work with the tame function, and have still come up with nothing.

 

A solution to this would be greatly appreciated :(

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.