Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.12.2] Nameplate appearing over custom mobs


Recommended Posts

19 hours ago, diesieben07 said:

Your code would be needed, especially your renderer class.

Here is the EntityWyrmling Class:

Quote

public class EntityWyrmling extends EntityCaveSpider {

    public EntityWyrmling(World worldIn)
    {
        super(worldIn);
    }

    @Override
    protected SoundEvent getAmbientSound()
    {
        return SoundEvents.ENTITY_SILVERFISH_AMBIENT;
    }
    
    @Override
    protected SoundEvent getHurtSound(DamageSource damageSourceIn)
    {
        return SoundEvents.ENTITY_SILVERFISH_HURT;
    }
    
    @Override
    protected SoundEvent getDeathSound()
    {
        return SoundEvents.ENTITY_SILVERFISH_DEATH;
    }
    
    @Override
    protected void applyEntityAttributes()
    {
        super.applyEntityAttributes();
        this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.28D);
        this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(16.0D);
        this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(4.0D);
    }
    
    @Override
    public EnumCreatureAttribute getCreatureAttribute()
    {
        return EnumCreatureAttribute.ARTHROPOD;
    }
    
    @Override
    protected ResourceLocation getLootTable()
    {
        return LootTableHandler.ZOMBUG;
    }
}

and here is the render class:

Quote

public class RenderWyrmling extends RenderLivingBase<EntityWyrmling>{

    public static final ResourceLocation TEXTURES = new ResourceLocation(Reference.MOD_ID + ":textures/entity/wyrmling.png");
    
    public RenderWyrmling(RenderManager renderManagerIn)
    {
        super(renderManagerIn, new ModelWyrmling(), 0.5f);
    }
    
    @Override
    protected ResourceLocation getEntityTexture(EntityWyrmling entity)
    {
        return TEXTURES;
    }
    
    @Override
    protected void applyRotations(EntityWyrmling entityWyrmling, float p_77043_2_, float rotationYaw, float partialTicks) {
        super.applyRotations(entityWyrmling, p_77043_2_, rotationYaw, partialTicks);
    }
}

And if you need it, here is my init class for entities:

Quote

public class EntityInit {

    public static void registerEntities()
    {
        registerEntity("scaleton", EntityScaleton.class, Reference.ENTITY_SCALETON, 24, 8598175, 6346362);
        registerEntity("zombug", EntityZombug.class, Reference.ENTITY_ZOMBUG, 32, 8598175, 6346362);
        registerEntity("wyrmling", EntityWyrmling.class, Reference.ENTITY_WYRMLING, 24, 8598175, 6346362);
    }
    
    public static void registerEntity(String name, Class<? extends Entity> entity, int id, int range, int color1, int color2)
    {
        EntityRegistry.registerModEntity(new ResourceLocation(Reference.MOD_ID + ":" + name), entity, name, id, Main.instance, range, 1, true, color1, color2);
    }
}

And I call this in my main, like this:

Quote

@EventHandler
    public static void PreInit(FMLPreInitializationEvent event)
    {
        GameRegistry.registerWorldGenerator(new ModWorldGen(), 3);
        DimensionInit.registerDimensions();
        GameRegistry.registerWorldGenerator(new GenerateCustomStructures(), 3);
        BiomeInit.registerBiomes();
        EntityInit.registerEntities();
        RenderHandler.registerEntityRenders();
    }

And here is my register class for the renders:

Quote

public class RenderHandler {

    public static void registerEntityRenders()
    {
        RenderingRegistry.registerEntityRenderingHandler(EntityScaleton.class, new IRenderFactory<EntityScaleton>()
        {
            @Override
            @SideOnly(Side.CLIENT)
            public Render<? super EntityScaleton> createRenderFor(RenderManager manager)
            {
                return new RenderScaleton(manager);
            }
        });
        
        RenderingRegistry.registerEntityRenderingHandler(EntityZombug.class, new IRenderFactory<EntityZombug>()
        {
            @Override
            @SideOnly(Side.CLIENT)
            public Render<? super EntityZombug> createRenderFor(RenderManager manager)
            {
                return new RenderZombug(manager);
            }
        });
        
        RenderingRegistry.registerEntityRenderingHandler(EntityWyrmling.class, new IRenderFactory<EntityWyrmling>()
        {
            @Override
            @SideOnly(Side.CLIENT)
            public Render<? super EntityWyrmling> createRenderFor(RenderManager manager)
            {
                return new RenderWyrmling(manager);
            }
        });
    }
}

The most interesting part to me is that I have 3 mobs, and neither of the other two have this problem.

Edited by JonIsPatented
Link to post
Share on other sites
  • Use EntityEntryBuilder and RegistryEvent.Register<EntityEntry> to register your entities, not registerModEntity.
  • The name for an entity (not the registry name!) must explicitly include your ModID to avoid conflicts (this is the "unlocalized name").
  • Do not use @SideOnly.
  • RenderingRegistry is a client-only class. By proxy this also makes your RenderHandler a client-only class. That means you cannot access it from common code.
  • RenderLivingBase renders name tags by default based on team settings. Use RenderLiving if you want the normal mob behavior.
  • Thanks 1
Link to post
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.

Guest
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 Privacy Policy.