Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.