Jump to content

[SOLVED][1.6.4] Mob Name Not Showing


saxon564

Recommended Posts

this is the last error i have with my mod right now. for some reason it is not showing the name in game like it should and i didnt change the code for that from the last time it worked. it shows "Entity.mochickens.Blue Chicken.name" instead of the name. im sure i know the problem is because of that space, but where the space is getting added is what i dont get.

 

Here is the code:

package mods.mochickens;

import java.util.List;

import mods.mochickens.client.ClientProxyMoChickens;
import mods.mochickens.mobs.EntityBlueChicken;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityEggInfo;
import net.minecraft.entity.EntityList;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.EnumHelper;
import net.minecraftforge.common.MinecraftForge;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid = "mochickens", name = "Mo' Chickens", version = "1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = true)

public class MoChickens {

@Instance("mochickens")
    public static MoChickens instance;

@SidedProxy(clientSide = "mods.mochickens.client.ClientProxyMoChickens",
			serverSide = "mods.mochickens.common.CommonProxyMoChickens")
public static ClientProxyMoChickens proxy;

int blueChickenEggID;

static int startEntityId = 300;

@EventHandler
public void preInit(FMLPreInitializationEvent event) {

	Configuration config = new Configuration(event.getSuggestedConfigurationFile());

	blueChickenEggID = config.get("Item IDs", "Blue Chicken Egg ID", 514).getInt();

	config.save();

}

@EventHandler
public void load(FMLInitializationEvent event){

	languageRegisters();
	entityRegisters();
	EggRegisters();

	proxy.registerRenders();

}

// Add Spawn Egg
public static int getUniqueEntityID() {
	do {
		startEntityId++;
	} while(EntityList.getStringFromID(startEntityId) != null);
	return startEntityId;
}

public static void registerEntityEgg(Class <? extends Entity> entity, int primaryColor, int secondaryColor) {
	int id = getUniqueEntityID();
	EntityList.IDtoClassMapping.put(id, entity);
	EntityList.entityEggs.put(id, new EntityEggInfo(id, primaryColor, secondaryColor));
}

public void EggRegisters() {
	registerEntityEgg(EntityBlueChicken.class, 0x0000FF, 0x000000);
}

//Add Mobs
public void entityRegisters() {
	EntityRegistry.registerModEntity(EntityBlueChicken.class,"Blue Chicken", 2, this , 40, 3, true);
	EntityRegistry.addSpawn(EntityBlueChicken.class, 5, 1, 2, EnumCreatureType.creature, BiomeGenBase.beach, BiomeGenBase.extremeHills, BiomeGenBase.extremeHillsEdge, BiomeGenBase.forest, BiomeGenBase.forestHills, BiomeGenBase.jungle, BiomeGenBase.jungleHills, BiomeGenBase.mushroomIsland, BiomeGenBase.mushroomIslandShore, BiomeGenBase.ocean, BiomeGenBase.plains, BiomeGenBase.river, BiomeGenBase.swampland);
}

private static void languageRegisters() {
	LanguageRegistry.instance().addStringLocalization("entity.mochickens.BlueChicken.name", "Blue Chicken");
}


}

Link to comment
Share on other sites

and for those that want to see the end product of this mobs entity code, here it is!

 

 

package mods.mochickens.mobs;

import net.minecraft.block.Block;
import net.minecraft.block.BlockColored;
import net.minecraft.client.Minecraft;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.EnchantmentThorns;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIFollowParent;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIPanic;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITempt;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemSeeds;
import net.minecraft.item.ItemStack;
import net.minecraft.pathfinding.PathEntity;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;

public class EntityBlueChicken extends EntityTameable {
public boolean field_70885_d = false;
public float field_70886_e = 0.0F;
public float destPos = 0.0F;
public float field_70884_g;
public float field_70888_h;
public float field_70889_i = 1.0F;

/** The time until the next egg is spawned. */
public int timeUntilNextEgg;

public EntityBlueChicken(World par1World) {
	super(par1World);
	this.setSize(0.3F, 0.7F);
	this.timeUntilNextEgg = -1;
	float f = 0.25F;
	this.tasks.addTask(0, new EntityAISwimming(this));
	this.tasks.addTask(2, new EntityAIMate(this, 1.0D));
	this.tasks.addTask(4, new EntityAIFollowParent(this, 1.1D));
	this.tasks.addTask(5, new EntityAIWander(this, 1.0D));
	this.tasks.addTask(6, new EntityAIWatchClosest(this,
			EntityPlayer.class, 6.0F));
	this.tasks.addTask(7, new EntityAILookIdle(this));
	this.tasks.addTask(2, new EntityAIAttackOnCollide(this,
			EntityPlayer.class, 1.0D, false));
	this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this,
			EntityPlayer.class, 0, true));
	this.setTamed(false);
}

/**
 * Returns true if the newer Entity AI code should be run
 */
public boolean isAIEnabled() {
	return true;
}

protected void applyEntityAttributes() {
	super.applyEntityAttributes();
	this.getEntityAttribute(SharedMonsterAttributes.maxHealth)
			.setAttribute(4.0D);
	this.getEntityAttribute(SharedMonsterAttributes.movementSpeed)
			.setAttribute(0.25D);
}

public boolean attackEntityAsMob(Entity par1Entity) {
	if (!this.isTamed()) {
		EntityPlayer entityplayer = this.worldObj
				.getClosestVulnerablePlayerToEntity(this, 16.0D);
		// f = damage delt 2.0D = 1 heart
		float f = (float) 5.0D;
		int i = 0;

		if (entityplayer instanceof EntityLivingBase) {
			f += EnchantmentHelper.getEnchantmentModifierLiving(this,
					(EntityLivingBase) entityplayer);
			i += EnchantmentHelper.getKnockbackModifier(this,
					(EntityLivingBase) entityplayer);
			entityplayer.addPotionEffect(new PotionEffect(
					Potion.blindness.id, 200, 1));
			entityplayer.addPotionEffect(new PotionEffect(
					Potion.moveSlowdown.id, 200, 2));
		}

		boolean flag = par1Entity.attackEntityFrom(
				DamageSource.causeMobDamage(this), f);

		if (flag) {
			if (i > 0) {
				entityplayer.addVelocity(
						(double) (-MathHelper.sin(this.rotationYaw
								* (float) Math.PI / 180.0F)
								* (float) i * 0.5F),
						0.1D,
						(double) (MathHelper.cos(this.rotationYaw
								* (float) Math.PI / 180.0F)
								* (float) i * 0.5F));
				this.motionX *= 0.6D;
				this.motionZ *= 0.6D;
			}

			int j = EnchantmentHelper.getFireAspectModifier(this);

			if (j > 0) {
				entityplayer.setFire(j * 4);
			}

			if (entityplayer instanceof EntityLivingBase) {
				EnchantmentThorns.func_92096_a(this,
						(EntityLivingBase) entityplayer, this.rand);
			}
		}

		return flag;
	} else {
		return false;
	}
}

/**
 * Called frequently so the entity can update its state every tick as
 * required. For example, zombies and skeletons use this to react to
 * sunlight and start to burn.
 */
public void onLivingUpdate() {
	super.onLivingUpdate();
	this.field_70888_h = this.field_70886_e;
	this.field_70884_g = this.destPos;
	this.destPos = (float) ((double) this.destPos + (double) (this.onGround ? -1
			: 4) * 0.3D);

	if (this.destPos < 0.0F) {
		this.destPos = 0.0F;
	}

	if (this.destPos > 1.0F) {
		this.destPos = 1.0F;
	}

	if (!this.onGround && this.field_70889_i < 1.0F) {
		this.field_70889_i = 1.0F;
	}

	this.field_70889_i = (float) ((double) this.field_70889_i * 0.9D);

	if (!this.onGround && this.motionY < 0.0D) {
		this.motionY *= 0.6D;
	}

	this.field_70886_e += this.field_70889_i * 2.0F;

	if (!this.isChild() && !this.worldObj.isRemote
			&& --this.timeUntilNextEgg == 0) {
		this.playSound(
				"mob.chicken.plop",
				1.0F,
				(this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
		this.dropItem(Item.diamond.itemID, 1);
		this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
	}
}

/**
 * Called when the mob is falling. Calculates and applies fall damage.
 */
protected void fall(float par1) {
}

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

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

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

/**
 * Plays step sound at given x, y, z for the entity
 */
protected void playStepSound(int par1, int par2, int par3, int par4) {
	this.playSound("mob.chicken.step", 0.15F, 1.0F);
}

/**
 * Returns the item ID for the item the mob drops on death.
 */
protected int getDropItemId() {
	return Item.feather.itemID;
}

/**
 * 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 par1, int par2) {
	int j = this.rand.nextInt(3) + this.rand.nextInt(1 + par2);

	for (int k = 0; k < j; ++k) {
		this.dropItem(Item.diamond.itemID, 1);
	}

	if (this.isBurning()) {
		this.dropItem(Item.chickenCooked.itemID, 1);
	} else {
		this.dropItem(Item.chickenRaw.itemID, 1);
	}
}

/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow,
 * gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer par1EntityPlayer) {
	ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
	if (!this.isTamed()) {
		if (itemstack != null && itemstack.itemID == Item.diamond.itemID) {
			if (!par1EntityPlayer.capabilities.isCreativeMode) {
				--itemstack.stackSize;
			}

			if (itemstack.stackSize <= 0) {
				par1EntityPlayer.inventory.setInventorySlotContents(
						par1EntityPlayer.inventory.currentItem,
						(ItemStack) null);
			}

			if (!this.worldObj.isRemote) {
				if (this.rand.nextInt(3) == 0) {
					this.setTamed(true);
					this.setPathToEntity((PathEntity) null);
					this.setAttackTarget((EntityLivingBase) null);
					this.setTarget(null);
					this.setOwner(par1EntityPlayer.getCommandSenderName());
					this.playTameEffect(true);
					this.worldObj.setEntityState(this, (byte) 7);
					this.tasks.removeTask(new EntityAIAttackOnCollide(this,
							EntityPlayer.class, 1.0D, false));
					this.targetTasks
							.removeTask(new EntityAINearestAttackableTarget(
									this, EntityPlayer.class, 0, true));
					this.tasks.addTask(3, new EntityAITempt(this, 1.0D,
							Block.blockDiamond.blockID, false));
					this.timeUntilNextEgg = this.rand.nextInt(6000) + 6000;
				} else {
					this.playTameEffect(false);
					this.worldObj.setEntityState(this, (byte) 6);
				}
			}

			return true;
		}
	}

	return super.interact(par1EntityPlayer);
}

/**
 * This function is used when two same-species animals in 'love mode' breed
 * to generate the new baby animal.
 */
public EntityBlueChicken spawnBabyAnimal(EntityAgeable par1EntityAgeable) {
	EntityBlueChicken entitybluechicken = new EntityBlueChicken(
			this.worldObj);
	String s = this.getOwnerName();

	if (s != null && s.trim().length() > 0) {
		entitybluechicken.setOwner(s);
		entitybluechicken.setTamed(true);
	}

	return entitybluechicken;
}

/**
 * Checks if the parameter is an item which this animal can be fed to breed
 * it (wheat, carrots or seeds depending on the animal type)
 */
public boolean isBreedingItem(ItemStack par1ItemStack) {
	return par1ItemStack != null
			&& par1ItemStack.itemID == Item.diamond.itemID;
}

public EntityAgeable createChild(EntityAgeable par1EntityAgeable) {
	return this.spawnBabyAnimal(par1EntityAgeable);
}
}

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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