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

Hi, I'm writing mod began studying Tessellator, all I want , but there is one catch , here's a video , please help

Sorry for the bad english .

 

I do not know where to go .

 

https://www.youtube.com/watch?v=3oseyxqsFik

 

 

package com.economy.render;

import com.economy.item.Items;
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.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import org.lwjgl.opengl.GL11;

/**
* Created by NEO on 31.12.2015.
*/
public class TileEntityTradeShopRenderer extends TileEntitySpecialRenderer {

    @Override
    public void renderTileEntityAt(TileEntity p_147500_1_, double x, double y, double z, float p_147500_8_) {
        GL11.glPushMatrix();
        GL11.glTranslated(x, y, z);
        GL11.glDisable(GL11.GL_LIGHTING);
        Tessellator tessellator = Tessellator.instance;
        Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
        tessellator.setBrightness (0);
        tessellator.setColorOpaque_F (1.0F, 1.0F, 1.0F);
        tessellator.startDrawingQuads();
        float miU, miV, maU, maV;

        miU = Blocks.glass.getIcon(0, 0).getMinU();
        miV = Blocks.glass.getIcon(0, 0).getMinV();
        maU = Blocks.glass.getIcon(0, 0).getMaxU();
        maV = Blocks.glass.getIcon(0, 0).getMaxV();

        tessellator.addVertexWithUV (0, 0, 0, miU, miV);
        tessellator.addVertexWithUV (0, 1, 0, miU, maV);
        tessellator.addVertexWithUV (1, 1, 0, maU , maV);
        tessellator.addVertexWithUV (1, 0, 0, maU, miV);

        tessellator.addVertexWithUV (0, 0, 0, miU, miV);
        tessellator.addVertexWithUV (0, 1, 0, miU, maV);
        tessellator.addVertexWithUV (0, 1, 1, maU , maV);
        tessellator.addVertexWithUV (0, 0, 1, maU, miV);

        tessellator.draw();

        tessellator.startDrawingQuads();
        GL11.glTranslated(0, 1, 0);
        tessellator.addVertexWithUV (0, 0, 0, miU, miV);
        tessellator.addVertexWithUV (0, 0, 1, miU, maV);
        tessellator.addVertexWithUV (1, 0, 1, maU , maV);
        tessellator.addVertexWithUV (1, 0, 0, maU, miV);
        tessellator.draw();
        GL11.glTranslated(0, -1, 0);

        tessellator.startDrawingQuads();
        GL11.glTranslated(0, 0, 1);
        tessellator.addVertexWithUV (0, 0, 0, miU, miV);
        tessellator.addVertexWithUV (0, 1, 0, miU, maV);
        tessellator.addVertexWithUV (1, 1, 0, maU , maV);
        tessellator.addVertexWithUV (1, 0, 0, maU, miV);

        tessellator.draw();

        tessellator.startDrawingQuads();
        GL11.glTranslated(1, 0, 0);

        tessellator.addVertexWithUV (0, 0, 0, miU, miV);
        tessellator.addVertexWithUV (0, 1, 0, miU, maV);
        tessellator.addVertexWithUV (0, 1, -1, maU , maV);
        tessellator.addVertexWithUV (0, 0, -1, maU, miV);

        tessellator.draw();

        miU = Blocks.iron_block.getIcon(0, 0).getMinU();
        miV = Blocks.iron_block.getIcon(0, 0).getMinV();
        maU = Blocks.iron_block.getIcon(0, 0).getMaxU();
        maV = Blocks.iron_block.getIcon(0, 0).getMaxV();


        tessellator.startDrawingQuads();
        GL11.glTranslated(0, 0, 0);

        tessellator.addVertexWithUV (0, 0, 0, miU, miV);
        tessellator.addVertexWithUV (0, 0, -1, miU, maV);
        tessellator.addVertexWithUV (-1, 0, -1, maU , maV);
        tessellator.addVertexWithUV (-1, 0, 0, maU, miV);

        tessellator.draw();

        //Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);

        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glPopMatrix();
    }
}

 

You have to add the vertices 'anti-clockwise', rather than 'clockwise'. This will make sure you are rendering the outside of the block, and not the inside.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author

You have to add the vertices 'anti-clockwise', rather than 'clockwise'. This will make sure you are rendering the outside of the block, and not the inside.

Thanks for the answer , I found a solution had to fulfill

  GL11.glDisable (GL11.GL_CULL_FACE);

  • Author

Who can tell what is the problem ?

ZBpMq0Q.png

 

 

package com.economy.render;

import com.economy.tileentity.TileEntityTradeShop;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import org.lwjgl.opengl.GL11;

/**
* Created by NEO on 31.12.2015.
*/
public class TileEntityTradeShopRenderer extends TileEntitySpecialRenderer {
    private EntityItem entityItem;
    public static float angle;

    public TileEntityTradeShopRenderer() {
        angle = 0;
        entityItem = new EntityItem(Minecraft.getMinecraft().theWorld, 0, 0, 0, new ItemStack(Blocks.air));
    }

    @Override
    public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float a) {
        GL11.glPushMatrix();
        GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
        GL11.glTranslated(x, y, z);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDepthMask(true);
        bindTexture(TextureMap.locationBlocksTexture);
        Tessellator tessellator = Tessellator.instance;
        tessellator.setBrightness (0);
        tessellator.setColorOpaque_F (1.0F, 1.0F, 1.0F);
        tessellator.startDrawingQuads();
        float u, v, U, V;

        u = Blocks.glass.getIcon(0, 0).getMinU();
        v = Blocks.glass.getIcon(0, 0).getMinV();
        U = Blocks.glass.getIcon(0, 0).getMaxU();
        V = Blocks.glass.getIcon(0, 0).getMaxV();

        tessellator.addVertexWithUV(0, 0, 0, u, v);
        tessellator.addVertexWithUV(0, 1, 0, u, V);
        tessellator.addVertexWithUV(0, 1, 1, U, V);
        tessellator.addVertexWithUV(0, 0, 1, U, v);

        tessellator.addVertexWithUV(0, 0, 1, u, v);
        tessellator.addVertexWithUV(0, 1, 1, u, V);
        tessellator.addVertexWithUV(1, 1, 1, U, V);
        tessellator.addVertexWithUV(1, 0, 1, U, v);

        tessellator.addVertexWithUV(1, 0, 1, u, v);
        tessellator.addVertexWithUV(1, 1, 1, u, V);
        tessellator.addVertexWithUV(1, 1, 0, U, V);
        tessellator.addVertexWithUV(1, 0, 0, U, v);

        tessellator.addVertexWithUV(0, 0, 0, u, v);
        tessellator.addVertexWithUV(0, 1, 0, u, V);
        tessellator.addVertexWithUV(0, 1, 0, U, V);
        tessellator.addVertexWithUV(0, 0, 0, U, v);

        tessellator.addVertexWithUV(1, 0, 0, u, v);
        tessellator.addVertexWithUV(1, 1, 0, u, V);
        tessellator.addVertexWithUV(0, 1, 0, U, V);
        tessellator.addVertexWithUV(0, 0, 0, U, v);

        u = Blocks.iron_block.getIcon(0, 0).getMinU();
        v = Blocks.iron_block.getIcon(0, 0).getMinV();
        U = Blocks.iron_block.getIcon(0, 0).getMaxU();
        V = Blocks.iron_block.getIcon(0, 0).getMaxV();

        tessellator.addVertexWithUV(0, 0, 0, u, v);
        tessellator.addVertexWithUV(1, 0, 0, u, V);
        tessellator.addVertexWithUV(1, 0, 1, U, V);
        tessellator.addVertexWithUV(0, 0, 1, U, v);


        tessellator.draw();
        if(tileEntity instanceof TileEntityTradeShop){
            TileEntityTradeShop tradeShop = (TileEntityTradeShop)tileEntity;
            if(tradeShop.select_item != null && tradeShop.select_item.getItem() != null){
                ItemStack stack = new ItemStack(tradeShop.select_item.getItem());
                entityItem.setEntityItemStack(stack);

            }
        }
        if(entityItem.getEntityItem() != null){
            RenderManager.instance.renderEntityWithPosYaw(entityItem, 0.5f, 0.3f, 0.5f, 0, angle);
        }
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glPopAttrib();
        GL11.glPopMatrix();
    }

}

 

Minecraft assumes every block is an opaque cube by default, so it doesn't render faces that are covered.

 

Override

Block#isOpaqueCube

to return

false

so Minecraft always renders the faces adjacent to your block.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

  • Author

Minecraft assumes every block is an opaque cube by default, so it doesn't render faces that are covered.

 

Override

Block#isOpaqueCube

to return

false

so Minecraft always renders the faces adjacent to your block.

 

 

many thanks .

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.