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

I'm having a bit of an issue with rendering an item.

 

My item renderer basically renders the default 3D item and then scales it to make it bigger. The problem is, there are some grainy, noise-like rendering on the item.

qxB2gdi.png

 

Here's my item renderer:

package terrarium.client.render.item;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.IItemRenderer;

import org.lwjgl.opengl.GL11;

import terrarium.item.IScaledRender;
import terrarium.util.Util;

public class RenderScaledItem implements IItemRenderer {
@Override
public boolean handleRenderType(ItemStack itemStack, ItemRenderType type) {
	return (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) ? true : false;
}

@Override
public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack itemStack, ItemRendererHelper helper) {
	return (type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) ? true : false;
}

@Override
public void renderItem(ItemRenderType type, ItemStack itemStack, Object... data) {
	Item item = itemStack.getItem();

	if(item instanceof IScaledRender) {
		double scale = ((IScaledRender) item).getScale(itemStack);
		IIcon icon = item.getIcon(itemStack, 0);

		Minecraft mc = Util.getMC();
		mc.renderEngine.bindTexture(TextureMap.locationItemsTexture);

		if(type == ItemRenderType.EQUIPPED) {
			scale *= 2;

			GL11.glPushMatrix();

			GL11.glScaled(scale, scale, scale);

			GL11.glTranslated(0.05D, 0.875D, -0.05D);

			GL11.glRotated(130D, 0D, 1D, 0D);
			GL11.glRotated(-120D, 0D, 0D, 1D);

			ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), 255, 255, 0.0625F);

			GL11.glPopMatrix();
		} else if(type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
			scale *= 200;

			GL11.glPushMatrix();

			GL11.glScaled(scale, scale, scale);

			GL11.glTranslated(0.4D, -0.2D, 0.45D);

			GL11.glRotated(37.5D, 0D, 1D, 0D);
			GL11.glRotated(-30D, 0D, 0D, 1D);

			ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(), icon.getMaxV(), 255, 255, 0.0625F);

			GL11.glPopMatrix();
		}
	}
}
}

Kain

Hi

 

That is caused by the vanilla minecraft code, which converts a 2D icon into "thickness" slice.  The gaps are caused by the way it cuts it into slices.

 

Look in ItemRenderer.renderItemIn2D() for more clues.  The only way to fix it is to copy the renderer and optimise it for your larger icon (or, if it's just this one item - create a proper model for it)

 

-TGG

 

 

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.