EntityMorph.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:metamorph 作者:
/**
 * Get the renderer's texture
 * 
 * Very hard stuff are going on here
 */
@SideOnly(Side.CLIENT)
@SuppressWarnings({"unchecked", "rawtypes"})
protected void setupTexture()
{
    Class<Render> clazz = (Class<Render>) this.renderer.getClass();

    for (Method method : clazz.getDeclaredMethods())
    {
        Class[] args = method.getParameterTypes();

        boolean hasEntityArg = args.length == 1 && args[0].isAssignableFrom(Entity.class);
        boolean returnsRL = method.getReturnType().isAssignableFrom(ResourceLocation.class);

        if (hasEntityArg && returnsRL)
        {
            try
            {
                method.setAccessible(true);
                this.texture = (ResourceLocation) method.invoke(this.renderer, this.entity);
            }
            catch (Exception e)
            {
                Metamorph.log("Failed to get texture of a morph '" + this.name + "'!");
                e.printStackTrace();
            }

            break;
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号