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 Ive been trying to get my block to render whatever item  its given, but Im having trouble with the rendering part. I was trying to reuse/update code from a tutorial i followed back for 1.12 from shadowfacts with limited success. I haven't found a better example tho. The item renders as a weirdly textured square and only when observed from certain angles (as shown below) what am i doing wrong and if anyone has a good example of how to render stuff properly in 1.14-1.15 it would be greatly appreciated.

 

This is the code of my TER:

package com.mekelaina.gramarye.client.render;

import com.mekelaina.gramarye.blocks.tiles.ChargerTile;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.Texture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraftforge.client.ForgeHooksClient;
import org.lwjgl.opengl.GL11;

public class ChargerTileEntityRenderer extends TileEntityRenderer<ChargerTile> {

    public ChargerTileEntityRenderer() {

    }

    @Override
    public void render(ChargerTile tileEntityIn, double x, double y, double z, float partialTicks, int destroyStage) {

        ItemStack stack = new ItemStack(Items.DIAMOND);

        if(!stack.isEmpty()){
            GlStateManager.enableRescaleNormal();
            GlStateManager.alphaFunc(GL11.GL_GREATER, 0.1f);
            GlStateManager.enableBlend();
            RenderHelper.enableStandardItemLighting();
            GlStateManager.blendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
            GlStateManager.pushMatrix();

            //double offset = Math.sin((tileEntityIn.getWorld().getT))

            GlStateManager.translated(x + 0.5, y + 0.6, z + 0.5);
            GlStateManager.rotated((tileEntityIn.getWorld().getGameTime() + partialTicks) * 1.5, 0, 1, 0);

            IBakedModel model = Minecraft.getInstance().getItemRenderer().getItemModelWithOverrides(stack, tileEntityIn.getWorld(), null);
            model = ForgeHooksClient.handleCameraTransforms(model, ItemCameraTransforms.TransformType.GROUND, false);

            Minecraft.getInstance().getItemRenderer().renderItem(stack, model);

            GlStateManager.popMatrix();
            GlStateManager.disableRescaleNormal();
            GlStateManager.disableBlend();
        }

        super.render(tileEntityIn, x, y, z, partialTicks, destroyStage);
    }

    private void renderItem(ItemStack stack){

    }
}

 

and this is the result:

https://imgur.com/z2PgRVm

 

  • Author

Note this topic was posted multiple times, this was in error. I guess refreshing the error screen reposed it idk.

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.