Jump to content

Recommended Posts

Posted

Hi,

 

My entity always shows its nametag, eventhough I didn't set it.

Here's a picture of it:

DpAiRCq.png

 

Here's my class for registering entities (this is where I think the problem is and can be fixed):

public class JoloEntities {
public static void init() {
	registerEntity(EntityMonster.class, Reference.MOD_ID + ":Monster");
	LanguageRegistry.instance().addStringLocalization("entity.jolo:Monster.name", "en_US", "Monster");
}

@SideOnly(Side.CLIENT)
public static void initRenders() {
	RenderingRegistry.registerEntityRenderingHandler(EntityMonster.class, new RenderMonster());
}

private static void registerEntity(Class<? extends EntityLiving> entity, String name) {
	EntityRegistry.registerGlobalEntityID(entity, name, EntityRegistry.findGlobalUniqueEntityId());
}
}

 

Any help is appreciated!

 

-pizzapim

Posted

1) show your render class

2) don't use registerGlobalEntityID

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Rendermonster:

[spoiler]
public class RenderMonster extends RendererLivingEntity {
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.MOD_ID + ":textures/entity/monster.png");

public RenderMonster() {
	super(Minecraft.getMinecraft().getRenderManager(), new ModelMonster() {
		@Override
		public void render(Entity entityIn, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float scale) {
			super.render(entityIn, p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, scale);
		}
	}, 1F);
}

@Override
protected void preRenderCallback(EntityLivingBase entity, float f) {
	if(entity instanceof EntityMonster) {
		EntityMonster monster = (EntityMonster) entity;
		GL11.glScalef(1F, 1F, 1F);
	}
}

@Override
protected ResourceLocation getEntityTexture(Entity entity) {
	return TEXTURE;
}
}
[/spoiler]

 

Also I tried using EntityRegistry.registerModEntity instead of EntityRegistry.registerGlobalEntityID, like this:

EntityRegistry.registerModEntity(entity, name, Reference.MOD_ID, this, 8, 3, false);

That didn't work because I 'can't use this in a static context'.

I then tried to put this in my main mod's class, called Jolo.class:

public static Object instance = new Jolo();

And then do this in the register class:

EntityRegistry.registerModEntity(entity, name, Reference.MOD_ID, Jolo.instance, 8, 3, false);

But that doesn't work...

 

Also sorry if I'm making stupid mistakes.

Posted

Make an instance field in your main mod class and mark it with

@Instance

, FML will fill it for you. Like so:

@Instance public static MyMod instance;

 

Thank you, I got the

registerModEntity

working now!

It didn't fix the initial problem though.

Posted

No, it wouldn't, it just isn't a thing you should be doing.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Are you setting it to have a custom name when you spawn it, or did you override #getCustomNameTag in your entity class to always return "Monster"?

 

Show the code that spawns your entity as well as your entity class.

 

I just used the /summon jolo:Monster command to spawn it, the entity doesn't spawn naturally right now.

Also I don't think I'm setting a custom name, but when I spawn the entity in it always has "entity.jolo.Monster.name" as his custom name.

Anyways, this is my entity class, EntityMonster.class:

public class EntityMonster extends EntityMob{
public EntityMonster (World worldIn) {
	super(worldIn);
	this.setSize(0.9F, 1.3F);
        ((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
        this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(1, new EntityAIPanic(this, 2.0D));
        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.setAlwaysRenderNameTag(false);
}
protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(10.0D);
        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.20000000298023224D);
    }

protected String getLivingSound() {
	return "mob.zombie.say";
}
protected String getHurtSound() {
	return "mob.zombie.hurt";
}
protected void playStepSound(BlockPos pos, Block blockIn) {
	this.playSound("mob.blaze.hit", 0.15F, 1.0F);
};
protected float getSoundVolume () {
	return 0.4F;
}
protected Item getDropItem () {
	return Items.cooked_beef;
}
protected void dropFewItems(boolean p_70628_1_, int p_70628_2_) {
        int i = this.rand.nextInt(3) + this.rand.nextInt(1 + p_70628_2_);

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

        i = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + p_70628_2_);

        for (int k = 0; k < i; ++k)
        {
            if (this.isBurning())
            {
                this.dropItem(Items.coal, 1);
            }
            else
            {
                this.dropItem(Items.cooked_beef, 1);
            }
        }
    }

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

        if (itemstack != null && itemstack.getItem() == Items.bucket && !player.capabilities.isCreativeMode && !this.isChild())
        {
            if (itemstack.stackSize-- == 1)
            {
                player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(Items.milk_bucket));
            }
            else if (!player.inventory.addItemStackToInventory(new ItemStack(Items.lava_bucket)))
            {
                player.dropPlayerItemWithRandomChoice(new ItemStack(Items.lava_bucket, 1, 0), false);
            }

            return true;
        }
        else
        {
            return super.interact(player);
        }
    }
public EntityMonster createChild(EntityAgeable ageable)
    {
        return new EntityMonster(this.worldObj);
    }
public float getEyeHeight()
    {
        return this.height;
    }
}

Posted

Indeed, that looks fine. The only thing I can think of, completely untested, is that your call to the LanguageRegistry is borking things:

LanguageRegistry.instance().addStringLocalization("entity.jolo:Monster.name", "en_US", "Monster");

Ever since at least 1.6.4, you should NOT be using the LanguageRegistry directly, but instead creating an en_US.lang file in your /resources/assets/yourmodid/lang folder - this is what handles all of the translations, e.g.:

entity.yourmodid.monster.name=Monster

I recommend you use all lowercase for every unlocalized name, be it Entity, Block, Item, or otherwise. Note that you do not need to prepend the entity name with your modid, that happens automatically, and the registration method requires an integer index, not your MOD_ID:

int index = 0; // start at 0 and add 1 for each custom entity registered
EntityRegistry.registerModEntity(EntityMonster.class, "monster", index++, Jolo.instance, 80, 3, false);

Posted

Thanks for the suggestion of not using the languageRegistry. I changed it and it's still working.

Was a bit frustrated because apparently the first line in the lang file isn't being read.

 

Also the name is still appearing above the entity's head.  :(

  • 1 year later...
Posted (edited)

Sorry to necro an old topic, but I just had the same problem and fixed it! Hopefully this will be helpful to people who experience the problem again like me.

 

The solution is: in your render class, extend RenderLiving instead of RenderLivingBase.

Edited by CrowsOfWar

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.

×
×
  • Create New...

Important Information

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