Jump to content

Recommended Posts

Posted (edited)

So I have 2 Render classes. But with one of the classes the model that I draw is drawn way too dark. Its using the same code for drawing the model.

Its looking like this https://gyazo.com/9f216b1b4ea4e1ecfde4eb41b7e3fb2e

 

It might be the blocks that are doing something to the render? I dont know...

 

Here is the code I am using:

 

public class RenderUtil{

    public static void renderItemFloatingOnTileEntity(ItemStack renderItem, TileEntity tileEntity){
        RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
        if (!renderItem.isEmpty()) {
            GlStateManager.translate(0.5, 2, 0.5);
            EntityItem entityitem = new EntityItem(tileEntity.getWorld(), 0.0D, 0.0D, 0.0D, renderItem);
            entityitem.getItem().setCount(1);
            entityitem.hoverStart = 0.0F;
            GlStateManager.pushMatrix();
            GlStateManager.disableLighting();

            float rotation = (float) (720.0 * (System.currentTimeMillis() & 0x3FFFL) / 0x3FFFL);

            GlStateManager.rotate(rotation, 0.0F, 1.0F, 0);
            GlStateManager.scale(0.5F, 0.5F, 0.5F);
            GlStateManager.pushAttrib();
            RenderHelper.enableStandardItemLighting();
            GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
            itemRenderer.renderItem(entityitem.getItem(), ItemCameraTransforms.TransformType.FIXED);
            RenderHelper.disableStandardItemLighting();
            GlStateManager.popAttrib();

            GlStateManager.enableLighting();
            GlStateManager.popMatrix();
        }
    }

}

 

And this is the render class:

public class RenderAltar extends TileEntitySpecialRenderer<TileAltar> {

    @Override
    public void render(TileAltar tileEntity, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {

        ItemStack renderItem = tileEntity.getHeldItem();

        GlStateManager.pushMatrix();
        GlStateManager.translate(x, y, z);

        RenderUtil.renderItemFloatingOnTileEntity(renderItem, tileEntity);

        GlStateManager.popMatrix();
    }


}

 

If you are interested in the tile class:

https://github.com/Martacus/Solar/blob/master/src/main/java/com/mart/solar/common/tileentities/TileAltar.java

 

And this is how I bind the models and register the renderers:

public class ClientProxy extends CommonProxy {

    @Override
    public void registerItemRenderer(Item item, int meta) {
        ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName(), "inventory"));
    }

    @Override
    public void preInit() {
        ClientRegistry.bindTileEntitySpecialRenderer(TileRuneInfuser.class, new RenderInfuser());
        ClientRegistry.bindTileEntitySpecialRenderer(TileAltar.class, new RenderAltar());
    }


}

 

Edited by MinecraftMart
typo

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.