Jump to content

[1.7.10] Game crashes when getting an UUID


knokko

Recommended Posts

hello guys,

I have found a problem with my mob.

If I come to the end with my mob, the game crashes with the next error.

"java.lang.IllegalArgumentException: Invalid UUID string: ".

 

It points directly at this method:

public void getSummoner() {
	if(summonerId != null && summonerUUID == null){
    		summonerUUID = UUID.fromString(summonerId);
    	}
    	if(summonerUUID != null && summoner == null){
    		summoner = worldObj.func_152378_a(summonerUUID);
    	}
    	if(summonerUUID != null){
        	summonerId = summonerUUID.toString();
        }
    	if(summoner != null && summonerUUID == null){
    		summonerUUID = summoner.getUniqueID();
    	}
}

 

And the rule that is marked is:

"summonerUUID = UUID.fromString(summonerId);".

 

Here is the whole class but I don't think you will need it:

public class EntityUndeadMage extends EntityAnimal{
/**
 * The summoner is the player that has summoned this mob.
 * This mob is programmed to help the summoner.
 */
public EntityPlayer summoner;
/**
 * The player name of the summoner.
 */
public String summonerName;
public UUID summonerUUID;
/**
 * The type of magic this mob uses.
 * 0 = healing
 * 1 = mixed
 * 2 = offensive
 */
public int mageType;
double movementSpeed = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getBaseValue();
/**
 * The current mana the mob has
 */
public int mobMana;
/**
 * The time this mob can't cast spells.
 */
public int manaCooldown;
public String summonerId;

/**
 * returns true if the mob should follow the summoner.
 * returns false if the mob should keep on the place where it is.
 */

public boolean guardSummoner = true;

public int fightType;

public Entity lastAttacker;

public EntityLivingBase target;



/**
 * A required constructor for a mob.
 * 
 * Do not use this constructor to summon this mob.
 * Use the constructor world, summoner, mageType, x, y, z.
 * @param world
 */
    public EntityUndeadMage(World world)
    {
        super(world);
        this.setSize(0.9F, 1.8F);
    }

    /**
     * 
     * @param world - The world the mob has to spawn.
     * @param summoner - The player that summons this mob.
     * @param mageType - The type of magic this mob will use. 0 = positive 1 = mixed 2 = offensive
     * @param x - The X location the mob has to spawn.
     * @param y - The Y location the mob has to spawn.
     * @param z - The Z location the mob has to spawn.
     */
    public EntityUndeadMage(World world, EntityPlayer summoner, int mageType, double x, double y, double z){
    	super(world);
    	this.setSize(0.6F, 1.8F);
    	setPosition(x, y, z);
        prevPosX = x;
        prevPosY = y;
        prevPosZ = z;
        this.summoner = summoner;
        this.mageType = mageType;
    	
    }

    /**
     * Returns true if the newer Entity AI code should be run
     */
    public boolean isAIEnabled()
    {
        return true;
    }
    
    /**
     * The base attributes of this mob.
     */
    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.35);
    }

    /**
     * Returns the sound this mob makes while it's alive.
     */
    protected String getLivingSound()
    {
        return null;
    }

    /**
     * Returns the sound this mob makes when it is hurt.
     */
    protected String getHurtSound()
    {
        return "mob.zombie.hurt";
    }

    /**
     * Returns the sound this mob makes on death.
     */
    protected String getDeathSound()
    {
        return "mob.zombie.hurt";
    }

    protected void func_145780_a(int x, int y, int z, Block block)
    {
        this.playSound("mob.zombie.step", 0.15F, 1.0F);
    }

    /**
     * Returns the volume for the sounds this mob makes.
     */
    protected float getSoundVolume()
    {
        return 0.4F;
    }

    protected Item getDropItem()
    {
        return Items.bone;
    }

    /**
     * Drop 0-2 items of this living's type. @param par1 - Whether this entity has recently been hit by a player. @param
     * par2 - Level of Looting used to kill this mob.
     */
    protected void dropFewItems(boolean hitbyplayer, int lootinglevel)
    {
        int j = this.rand.nextInt(3) + this.rand.nextInt(1 + lootinglevel);
        int k;

        for (k = 0; k < j; ++k)
        {
            this.dropItem(Items.bone, 1);
        }

        j = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + lootinglevel);

        for (k = 0; k < j; ++k)
        {
            if (this.isBurning())
            {
                this.dropItem(Items.skull, 1);
            }
            else
            {
                this.dropItem(Items.skull, 1);
            }
        }
    }

    /**
     * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
     */
    


    public EntityUndeadMage createChild(EntityAgeable ageable)
    {
        return new EntityUndeadMage(this.worldObj);
    }
    public void onUpdate(){
    	super.onUpdate();
    	updateMana();
    	getSummoner();
    	if(summoner != null){
    	useMagic();
    	if(guardSummoner){
    		followSummoner();
    		}
    	}
    }
public void getSummoner() {
	if(summonerId != null && summonerUUID == null){
    		summonerUUID = UUID.fromString(summonerId);
    	}
    	if(summonerUUID != null && summoner == null){
    		summoner = worldObj.func_152378_a(summonerUUID);
    	}
    	if(summonerUUID != null){
        	summonerId = summonerUUID.toString();
        }
    	if(summoner != null && summonerUUID == null){
    		summonerUUID = summoner.getUniqueID();
    	}
}

public void useMagic() {
	if(mageType == 0){
		useHealingMagic();
	}
	if(mageType == 1){
		useMixedMagic();
	}
	if(mageType == 2){
		useOffensiveMagic();
	}
}

public void useOffensiveMagic() {

}

public void useMixedMagic() {
	System.out.println(this.target);
	List partners = worldObj.getEntitiesWithinAABB(EntityUndeadMage.class, AxisAlignedBB.getBoundingBox(summoner.posX - 20, summoner.posY - 20, summoner.posZ - 20, summoner.posX + 20, summoner.posY + 20, summoner.posZ + 20));
	for (int j = 0; j < partners.size(); ++j){
		EntityUndeadMage partner = (EntityUndeadMage) partners.get(j);
		if(partner.getLastAttacker() != null && fightType == 0){
			this.target = partner.getLastAttacker();
			if(!this.target.isPotionActive(2) && mobMana >= 200){
				this.target.addPotionEffect(new PotionEffect(2, 100, 5));
				mobMana -= 200;
			}
		}
	}
	if(this.target != null && fightType == 0){
		if(!this.target.isPotionActive(2) && mobMana >= 200){
			this.target.addPotionEffect(new PotionEffect(2, 100, 5));
			mobMana -= 200;
		}
	}
}

public void useHealingMagic() {
	if(summoner.isBurning() && !summoner.isPotionActive(12) && mobMana >= 200){
		summoner.addPotionEffect(new PotionEffect(12, 40));
		mobMana -= 200;
		worldObj.spawnParticle("flame", posX, posY, posZ, 0D, 0D, 0D);
	}
	List partners = worldObj.getEntitiesWithinAABB(EntityUndeadMage.class, AxisAlignedBB.getBoundingBox(summoner.posX - 20, summoner.posY - 20, summoner.posZ - 20, summoner.posX + 20, summoner.posY + 20, summoner.posZ + 20));
	for (int j = 0; j < partners.size(); ++j){
		EntityUndeadMage partner = (EntityUndeadMage) partners.get(j);
		if(partner.summoner == summoner){
		if(partner.isBurning() && !partner.isPotionActive(12)){
			if(mobMana >= 200){
			partner.addPotionEffect(new PotionEffect(12, 40));
			mobMana -= 200;
			}
		}
		if(partner.getHealth() >= 11 && partner.getHealth() <= 19 && !partner.isPotionActive(10) && mobMana >= 20){
				partner.addPotionEffect(new PotionEffect(10, 100));
				mobMana -= 20;
		}
		if(partner.fallDistance >= 4 && mobMana >= 100){
				partner.fallDistance = 0;
				mobMana -= 100;
		}
		if(partner.getHealth() <= 10 && partner.getHealth() >= 6 && mobMana >= 100 && !partner.isPotionActive(10)){
			partner.addPotionEffect(new PotionEffect(10, 100, 1));
			mobMana -= 100;
		}
		if(partner.getHealth() <= 10 && partner.getHealth() >= 6 && partner.isPotionActive(10) && mobMana >= 100){
			partner.heal(1F);
			mobMana -= 100;
		}
		if(partner.getHealth() <= 5 && partner.getHealth() >= 1 && mobMana >= 500 && !partner.isPotionActive(10)){
			partner.addPotionEffect(new PotionEffect(10, 100, 2));
			mobMana -= 500;
		}
		if(partner.getHealth() <= 5 && partner.getHealth() >= 1 && mobMana >= 1000){
			mobMana -= 1000;
			partner.heal(5F);
		}
		}
	}
	if(summoner.getHealth() >= 11 && summoner.getHealth() <= 19 && !summoner.isPotionActive(10) && mobMana >= 20){
			summoner.addPotionEffect(new PotionEffect(10,100));
			mobMana -= 20;
	}
	if(summoner.fallDistance >= 4 && mobMana >= 100){
			summoner.fallDistance = 0;
			mobMana -= 100;
	}
	if(summoner.getHealth() <= 10 && summoner.getHealth() >= 6 && !summoner.isPotionActive(10) && mobMana >= 100){
			summoner.addPotionEffect(new PotionEffect(10, 10, 1));
			mobMana -= 100;
	}
	if(summoner.getHealth() <= 10 && summoner.getHealth() >= 6 && summoner.isPotionActive(10) && mobMana >= 100){
		summoner.heal(1F);
		mobMana -= 100;
	}
	if(summoner.getHealth() <= 5 && summoner.getHealth() >= 1 && !summoner.isPotionActive(10) && mobMana >= 500){
			summoner.addPotionEffect(new PotionEffect(10, 100, 2));
			mobMana -= 500;
	}
	if(summoner.getHealth() <= 5 && summoner.getHealth() >= 1 && mobMana >= 1000){
		mobMana -= 1000;
		summoner.heal(5F);
	}

}


public void updateMana() {
	if(mobMana <= 5000){
		mobMana += 1;
	}
	if(mobMana >= 5001){
		mobMana = 5000;
	}
	if(manaCooldown >= 1){
		manaCooldown -= 1;
	}
	if(manaCooldown <= 0){
		manaCooldown = 0;
	}
}

public void followSummoner() {
	if(summoner != null){
		if(summoner.posX >= posX + 5){

			moveEntity(movementSpeed , 0, 0);
		}
		else if(summoner.posX <= posX - 5){
			moveEntity(-1 * movementSpeed, 0, 0);
		}
		if(summoner.posZ >= posZ + 5){
			moveEntity(0, 0, movementSpeed);
		}
		else if(summoner.posZ <= posZ - 5){
			moveEntity(0, 0, -1 * movementSpeed);
		}
		if(this.onGround && summoner.posY >= posY + 2){
			moveEntity(0, 3.0, 0);
		}
		if(summoner.posX >= posX + 16 || summoner.posX <= posX - 16 ||summoner.posY >= posY + 16 || summoner.posY <= posY - 16 || summoner.posZ >= posZ  + 16|| summoner.posZ <= posZ - 16){
			if(summoner.onGround || summoner.handleWaterMovement()){
			setPosition(summoner.posX, summoner.posY, summoner.posZ);
			}
		}
		if(summoner.posX >= posX + 100 || summoner.posX <= posX - 100 || summoner.posZ >= posZ + 100 || summoner.posZ <= posZ - 100){
			setPosition(summoner.posX, summoner.posY, summoner.posZ);
		}
	}
}
public void writeEntityToNBT(NBTTagCompound nbt){
	super.writeEntityToNBT(nbt);
	if(summoner != null){
		nbt.setString("summonerUUID", summonerId);
	}
	nbt.setInteger("mobMana", mobMana);
	nbt.setBoolean("guardSummoner", guardSummoner);
	nbt.setInteger("mageType", mageType);
	nbt.setInteger("fightType", fightType);
}
public void readEntityFromNBT(NBTTagCompound nbt){
	super.readEntityFromNBT(nbt);
	mobMana = nbt.getInteger("mobMana");
	summonerId = nbt.getString("summonerUUID");
	guardSummoner = nbt.getBoolean("guardSummoner");
	mageType = nbt.getInteger("mageType");
	fightType = nbt.getInteger("fightType");
}
public boolean interact(EntityPlayer player){
	if(!worldObj.isRemote){
		if(player == summoner){
	System.out.println(summoner);
	System.out.println(summonerUUID);
	System.out.println(summonerId);
	ItemStack currentItem = player.inventory.getCurrentItem();
	if(currentItem != null){
	if(currentItem.getItem() == EnderpowerItems.positiveSpellBook && mageType != 0){
		mageType = 0;
		player.addChatMessage(new ChatComponentTranslation("I am now a healing mage."));
	}
	if(currentItem.getItem() == EnderpowerItems.mixedSpellBook && mageType != 1){
		mageType = 1;
		player.addChatMessage(new ChatComponentTranslation("I am now a mixed mage."));
	}
	if(currentItem.getItem() == EnderpowerItems.offensiveSpellBook && mageType != 2){
		mageType = 2;
		player.addChatMessage(new ChatComponentTranslation("I am now an offensive mage."));
	}
	if(currentItem.getItem() == Items.wooden_sword || currentItem.getItem() == Items.stone_sword || currentItem.getItem() == Items.iron_sword || currentItem.getItem() == Items.golden_sword || currentItem.getItem() == Items.diamond_sword){
		if(fightType == 0 && mageType != 0){
			fightType = 1;
			player.addChatMessage(new ChatComponentTranslation("I will attack every mob that attacks you or you attack."));
		}
	}
	}
	if(currentItem == null && guardSummoner == true && !worldObj.isRemote){
		guardSummoner = false;
		player.addChatMessage(new ChatComponentTranslation("I will guard it here."));
	}
	else if(currentItem == null && guardSummoner == false && !worldObj.isRemote){
		guardSummoner = true;
		player.addChatMessage(new ChatComponentTranslation("I will follow you now."));
	}
	}
		}
	return super.interact(player);
}
public boolean attackEntityFrom(DamageSource damage, float f){
	lastAttacker = damage.getEntity();
	return super.attackEntityFrom(damage, f);

}


}

Link to comment
Share on other sites

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.