Jump to content

Recommended Posts

Posted

Hey Guys!

I created a sign, which can be used to write colored text. If you press a button in the GUI, a EnumChatFormatting object is added to the signs string.

 

The problem is, that the text is rendered wrong.

Here is one Text in the GUI (where everything is fine)

LqE2qds.png

And here is the same text ingame:

3O19otz.png

 

The Renderer method:

 

 

(Placed in a method extended from the Renderer superclass, shown below)

@Override
public void renderTileEntity(TileEntity te, World world, int x, int y, int z, int meta, Block block, boolean isItemRendered) {
	if (isItemRendered) {
		GL11.glScalef(1.2F, 1.2F, 1.2F);
		GL11.glTranslatef(0.0F, -0.1F, 0.4F);
	}

	this.startDrawingQuads();
	this.rotate4Steps(meta);
	this.bindMCTexture(((ModBlockLargeSign)block).getBacksideName());
	this.setNormal(0.0F, 0.0F, -1.0F);
	this.renderFace(0.0D, 0.0D, 0.0D, 1.0D, 0.0D, 0.0D, 1.0D, 1.0D, 0.0D, 0.0D, 1.0D, 0.0D);
	this.setNormal(0.0F, 1.0F, 0.0F);
	this.renderFaceTexCut(1.0D, 0.125D, 0.0D, 1.0D, 0.0D, 1.0D, 1.0D, 0.0D, 1.0D, 1.0D, 0.125D, 0.0D, 1.0D, 0.125D);
	this.setNormal(0.0F, -1.0F, 0.0F);
	this.renderFaceTexCut(1.0D, 0.125D, 0.0D, 0.0D, 0.125D, 1.0D, 0.0D, 0.125D, 1.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
	this.setNormal(1.0F, 0.0F, 0.0F);
	this.renderFaceTexCut(0.125D, 1.0D, 0.0D, 0.0D, 0.125D, 0.0D, 0.0D, 0.0D, 0.0D, 1.0D, 0.0D, 0.0D, 1.0D, 0.125D);
	this.setNormal(-1.0F, 0.0F, 0.0F);
	this.renderFaceTexCut(0.125D, 1.0D, 1.0D, 0.0D, 0.0D, 1.0D, 0.0D, 0.125D, 1.0D, 1.0D, 0.125D, 1.0D, 1.0D, 0.0D);
	this.finishDrawing();
	this.startDrawingQuads();
	this.setNormal(0.0F, 0.0F, 1.0F);
	this.bindModTexture(((ModBlockLargeSign)block).getFrontsideName());
	this.renderFace(1.0D, 0.0D, 0.125D, 0.0D, 0.0D, 0.125D, 0.0D, 1.0D, 0.125D, 1.0D, 1.0D, 0.125D);
	this.finishDrawing();

	if (!isItemRendered) {
		FontRenderer f = this.func_147498_b();
		TileEntityLargeSign tile = (TileEntityLargeSign)te;

		float scale = 0.01F;
		GL11.glTranslatef(0.5F, 0.5F, 0.5F);
		GL11.glScalef(scale, -scale, scale);
		GL11.glTranslatef(0.0F, 0.0F, -0.374F / scale);

		for (int i = 0; i < 6; i ++) {
			String s = tile.getCurrentText()[i];
			if (s != "")
				f.drawString(s, -f.getStringWidth(s) / 2, i*16 - 45, 0); //Color is set to 0 to render in black by default!
		}
	}
}

 

 

The Renderer Superclass:

 

 

Only the things at the top are important.

package com.bedrockminer.signcraft.client.renderer.block;

import org.lwjgl.opengl.GL11;

import com.bedrockminer.signcraft.Main;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

public abstract class ModTileEntityRenderer extends TileEntitySpecialRenderer {

protected Tessellator t;

@Override
/**
 * Initializes the renderer and overrides the abstract method
 */
    public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {
	GL11.glPushMatrix();
	GL11.glTranslated(x, y, z);
	this.t = Tessellator.instance;

	int teX = te.xCoord;
	int teY = te.yCoord;
	int teZ = te.zCoord;
	World world = te.getWorldObj();

	Block block = te.getBlockType();

	float bright = block.getMixedBrightnessForBlock(world, teX, teY, teZ);
	int l = world.getLightBrightnessForSkyBlocks(teX, teY, teZ, 0);
	int l1 = l % 65536;
	int l2 = l / 65536;
	this.t.setColorOpaque_F(bright, bright, bright);
	OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, l1, l2);

	int meta = te.blockMetadata;

        GL11.glPushMatrix();
	renderTileEntity(te, te.getWorldObj(), te.xCoord, te.yCoord, te.zCoord, meta, te.getWorldObj().getBlock(te.xCoord, te.yCoord, te.zCoord), false);
        GL11.glPopMatrix();
        GL11.glPopMatrix();
    }

public void renderTileEntityAsItem(TileEntity te, ItemStack stack) {
	GL11.glPushMatrix();
	this.field_147501_a = TileEntityRendererDispatcher.instance;

	this.t = Tessellator.instance;

	this.t.setColorOpaque_F(1.0F, 1.0F, 1.0F);

	int meta = stack.getItemDamage();

        GL11.glPushMatrix();
	renderTileEntity(te, null, 0, 0, 0, meta, Block.getBlockFromItem(stack.getItem()), true);
        GL11.glPopMatrix();
        GL11.glPopMatrix();
}

    public abstract void renderTileEntity(TileEntity te, World world, int x, int y, int z, int meta, Block block, boolean isItemRendered);
    
    /**
     * Sets the texture of the renderer to a new Texture in the folder named like the modid
     */
    protected void bindModTexture(String texture) {
    	bindTexture(Main.MODID, texture);
    }
    
    /**
     * Sets the texture of the renderer to a new Texture from Minecraft
     */
    protected void bindMCTexture(String texture) {
    	bindTexture("minecraft", texture);
    }
    
    /**
     * Sets the texture of the renderer to a new Texture
     */
    protected void bindTexture(String modid, String texture) {
    	this.bindTexture(new ResourceLocation(modid, texture));
    }
    
    /**
     * executes startDrawingQuads of the tessellator
     */
    protected void startDrawingQuads() { 
    	this.t.startDrawingQuads();
    }
    
    /**
     * executes draw of the tessellator
     */
    protected void finishDrawing() {
    	this.t.draw();
    }
    
    /**
     * Rotates the renderer by 90° for each step
     */
    protected void rotate4Steps(int steps) {
    	GL11.glTranslatef(0.5F, 0, 0.5F);
        GL11.glRotatef(steps * -90F, 0F, 1F, 0F);
        GL11.glTranslatef(-0.5F, 0, -0.5F);
    }
    
    /**
     * Rotates the renderer by 45° for each step
     */
    protected void rotate8Steps(int steps) {
    	GL11.glTranslatef(0.5F, 0, 0.5F);
        GL11.glRotatef(steps * -45F, 0F, 1F, 0F);
        GL11.glTranslatef(-0.5F, 0, -0.5F);
    }
    
    /**
     * Rotates the renderer by 22.5° for each step
     */
    protected void rotate16Steps(int steps) {
    	GL11.glTranslatef(0.5F, 0, 0.5F);
        GL11.glRotatef(steps * -22.5F, 0F, 1F, 0F);
        GL11.glTranslatef(-0.5F, 0, -0.5F);
    }
    
    /**
     * Sets the normal for current draw
     */
    protected void setNormal(float x, float y, float z) {
    	this.t.setNormal(x, y, z);
    }

/**
 * Draws a face with the given coordinates (counter-clockwise; starting at lower-left)
 */
protected void renderFace(double xa, double ya, double za, double xb, double yb, double zb, double xc, double yc, double zc, double , double yd, double zd) {
	renderFaceTexCut(1.0D, 1.0D, xa, ya, za, xb, yb, zb, xc, yc, zc, , yd, zd);		
}

/**
 * Draws a face with the given coordinates (counter-clockwise; starting at lower-left)
 * Cuts the texture at given points.
 */
protected void renderFaceTexCut(double width, double heigth, double xa, double ya, double za, double xb, double yb, double zb, double xc, double yc, double zc, double , double yd, double zd) {
	renderFaceTexCutOffset(width, heigth, 0, 0, xa, ya, za, xb, yb, zb, xc, yc, zc, , yd, zd);		
}

/**
 * Draws a face with the given coordinates (counter-clockwise; starting at lower-left)
 * Cuts the texture at given points.
 * Offsets the cutted texture by given values.
 */
protected void renderFaceTexCutOffset(double width, double heigth, double uOffset, double vOffset, double xa, double ya, double za, double xb, double yb, double zb, double xc, double yc, double zc, double , double yd, double zd) {
	this.t.addVertexWithUV(, yd, zd, width + uOffset, vOffset);
	this.t.addVertexWithUV(xc, yc, zc, uOffset, vOffset);
	this.t.addVertexWithUV(xb, yb, zb, uOffset, heigth + vOffset);
	this.t.addVertexWithUV(xa, ya, za, width + uOffset, heigth + vOffset);		
}
}

 

Call in the GUI:

 

GL11.glPushMatrix();
        
        GL11.glTranslatef(this.width / 2, 80.0F, 0.0F);
        float f1 = 120.0F;
        GL11.glScalef(-f1, -f1, -f1);
        GL11.glTranslatef(0.0F, -0.5F, -0.5F);
        GL11.glRotatef(180, 0, 1, 0);
        GL11.glTranslatef(0.0F, 0.5F, 0.0F);
        
        TileEntityRendererDispatcher.instance.renderTileEntityAt(this.te, -0.5D, -0.75D, -0.5D, 0.0F);

        GL11.glScalef(f1, f1, f1);
        GL11.glPopMatrix();

 

 

Why is the sign rendered different ingame than in the GUI?!

Posted

The problem is, that the error appears not in the gui, but in the world.

I want this sign to be grey, but in the world it's white.

Everything from §8 up to §f is rendered white in the world, but it shouldn't!

 

A problem might be this method:

brightness = block.getMixedBrightnessForBlock(world, teX, teY, teZ);

because with this code line brightness is set to 1.572864E7 as my debugging test showed.

But I also tried setting it to different values manually, nothing worked.

 

It could be this problem, but I don't know, how I could solve it:

The brightness of the texture is always set to 1.0F.

So, if you get orange (R:1.0F; G:0.5F; B:0.0F) it is turned to yellow (R:1.0F; G:1.0F; B:0.0F).

Also, al the Colors up from §8 have little parts of all color and this is set to 1.0F each.

 

This could be the problem, but I don't know why it appears

 

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • You need a new "items" folder at  resources/assets/yourmodid/ there you add for every item model a .json file with the exact item/block name and fill it like this if it's an item: { "model": { "type": "minecraft:model", "model": "yourmodid:item/youritem" } } and so if its a block: { "model": { "type": "minecraft:model", "model": "yourmodid:block/youritem" } } There is also a generator for it you can do namy crazy things with it which replaces the previous hard coded Item Properties implementaion method (Bow pulling animation for example). https://misode.github.io/assets/item/
    • Hello! I'm playing a modpack (custom made) with some friends, and we have the server running on BisectHosting. We encountered a bug with an entity from The Box Of Horrors mod, that would crash the game whenever someone nearby it would log in. We tried to fix it by: 1) Editing the player.dat files to change the location of the affected players (something I had done successfully previously) 2) Updating the version of the mod we had (0.0.8.2) to the latest alpha version (0.0.8.3 However, after doing both of those, none of us are able to join the server, and we get the following errors: Server side: https://pastebin.com/J5sc3VQN Client side: Internal Server Error (that's basically all I've gotten) Please help! I've tried restoring the player data to how it was before I made the changes (Bisect allows you to restore deleted files) and deleting all of my player data files and I still get the same error. Deleting Box Of Horrors causes the error: Failed to load datapacks, cannot continue with server load.
    • Get $100 Off temu Coupon Code { ald123454 } | for new users + 30% Discount for all users You can get a $100 Off temu Coupon code using the code { ald123454 }. This temu $100 Off code is specifically for new customers and can be redeemed to receive a $100 discount on your purchase. Our exclusive temu Coupon code offers a flat $100 Off your purchase, plus an additional 30% discount. As a new temu customer, you can slash prices by up to 30% as a new temu customer using code { ald123454 }. Existing users can enjoy $100 Off their next haul with this code. But that’s not all! With our temu coupon code get up to 90% discount on select items and clearance sales. Whether you’re a new customer or an existing shopper, our temu codes provide extra discounts tailored just for you. Save up to 30% with these current temu Coupons { ald123454 } for February 2025. The latest temu coupon codes at here. Free temu codes $100 Off — { ald123454 } temu Coupon $100 Off — { ald123454 } temu Coupon $100 Off — { ald123454 } temu Memorial Day Sale 75% off — { ald123454 } temu Coupon code today — { ald123454 } temu free gift code — { ald123454 } Without inviting friends or family member  Coupon code for Canada - $100 Off— { ald123454 } temu Coupon code Australia - $100 Off— { ald123454 } temu Coupon code New Zealand - $100 Off — { ald123454 } temu Coupon code Japan -$100 Off — { ald123454 } temu Coupon code Mexico - $100 Off — { ald123454 } temu Coupon code Chile - $100 Off — { ald123454 } temu Coupon code Peru - $100 Off — { ald123454 } temu Coupon code Colombia - $100 Off — { ald123454 } temu Coupon code Malaysia - $100 Off — { ald123454 } temu Coupon code the Philippines - $100 Off — { ald123454 } temu Coupon code South Korea - $100 Off — { ald123454 } Redeem Free temu Coupon Code { ald123454 }for first time user Get $100 discount on your temu order with the promo code "acr804084". You can get a discount by clicking on the item to purchase and entering this temu Coupon code $100 Off "{ ald123454 }". temu Coupon Code { ald123454 }: Get Up To $100 Off In June 2025 Are you looking for the best temu Coupon codes to get amazing discounts? Our temu Coupons are perfect for getting those extra savings you crave. We regularly test our coupon codes for temu to ensure they work flawlessly, giving you a guaranteed discount every time. temu New User Coupon { ald123454 }: Up To 75% OFF For First-Time Users Our temu first-time user coupon codes are designed just for new customers, offering the biggest discounts and the best deals currently available on temu. To maximize your savings, download the temu Coupon For $100 Off { ald123454 }: Get A Flat $100 Discount On Order Value Get ready to save big with our incredible temu Coupon code for $100 Off! Our amazing temu $100 Off coupon code will give you a flat $100 discount on your order value, making your shopping experience even more rewarding. temu Coupon Code For $100 Off { ald123454 } For Both New And Existing Customers Our incredible temu Coupon code for $100 Off is here to help you save big on your purchases. Whether you’re a new user or an existing customer, our $100 Off code for temu will give you an additional discount! temu Coupon Bundle { ald123454 }: Flat $100 Off + Up To 30% Discount Get ready for an unbelievable deal with our temu Coupon bundle for 2025! Our temu Coupon bundles will give you a flat $100 discount and an additional $100 Off on top of it. Free temu Coupons { ald123454 }: Unlock Unlimited Savings! Get ready to unlock a world of savings with our free temu Coupons! We’ve got you covered with a wide range of temu Coupon code options that will help you maximize your shopping experience. $100 Off temu Coupons, Promo Codes + 25% Cash Back { ald123454 } Redeem temu Coupon Code { ald123454 }
    • Get $100 Off temu Coupon Code { ald123454 } | for new users + 30% Discount for all users You can get a $100 Off temu Coupon code using the code { ald123454 }. This temu $100 Off code is specifically for new customers and can be redeemed to receive a $100 discount on your purchase. Our exclusive temu Coupon code offers a flat $100 Off your purchase, plus an additional 30% discount. As a new temu customer, you can slash prices by up to 30% as a new temu customer using code { ald123454 }. Existing users can enjoy $100 Off their next haul with this code. But that’s not all! With our temu coupon code get up to 90% discount on select items and clearance sales. Whether you’re a new customer or an existing shopper, our temu codes provide extra discounts tailored just for you. Save up to 30% with these current temu Coupons { ald123454 } for February 2025. The latest temu coupon codes at here. Free temu codes $100 Off — { ald123454 } temu Coupon $100 Off — { ald123454 } temu Coupon $100 Off — { ald123454 } temu Memorial Day Sale 75% off — { ald123454 } temu Coupon code today — { ald123454 } temu free gift code — { ald123454 } Without inviting friends or family member  Coupon code for Canada - $100 Off— { ald123454 } temu Coupon code Australia - $100 Off— { ald123454 } temu Coupon code New Zealand - $100 Off — { ald123454 } temu Coupon code Japan -$100 Off — { ald123454 } temu Coupon code Mexico - $100 Off — { ald123454 } temu Coupon code Chile - $100 Off — { ald123454 } temu Coupon code Peru - $100 Off — { ald123454 } temu Coupon code Colombia - $100 Off — { ald123454 } temu Coupon code Malaysia - $100 Off — { ald123454 } temu Coupon code the Philippines - $100 Off — { ald123454 } temu Coupon code South Korea - $100 Off — { ald123454 } Redeem Free temu Coupon Code { ald123454 }for first time user Get $100 discount on your temu order with the promo code "acr804084". You can get a discount by clicking on the item to purchase and entering this temu Coupon code $100 Off "{ ald123454 }". temu Coupon Code { ald123454 }: Get Up To $100 Off In June 2025 Are you looking for the best temu Coupon codes to get amazing discounts? Our temu Coupons are perfect for getting those extra savings you crave. We regularly test our coupon codes for temu to ensure they work flawlessly, giving you a guaranteed discount every time. temu New User Coupon { ald123454 }: Up To 75% OFF For First-Time Users Our temu first-time user coupon codes are designed just for new customers, offering the biggest discounts and the best deals currently available on temu. To maximize your savings, download the temu Coupon For $100 Off { ald123454 }: Get A Flat $100 Discount On Order Value Get ready to save big with our incredible temu Coupon code for $100 Off! Our amazing temu $100 Off coupon code will give you a flat $100 discount on your order value, making your shopping experience even more rewarding. temu Coupon Code For $100 Off { ald123454 } For Both New And Existing Customers Our incredible temu Coupon code for $100 Off is here to help you save big on your purchases. Whether you’re a new user or an existing customer, our $100 Off code for temu will give you an additional discount! temu Coupon Bundle { ald123454 }: Flat $100 Off + Up To 30% Discount Get ready for an unbelievable deal with our temu Coupon bundle for 2025! Our temu Coupon bundles will give you a flat $100 discount and an additional $100 Off on top of it. Free temu Coupons { ald123454 }: Unlock Unlimited Savings! Get ready to unlock a world of savings with our free temu Coupons! We’ve got you covered with a wide range of temu Coupon code options that will help you maximize your shopping experience. $100 Off temu Coupons, Promo Codes + 25% Cash Back { ald123454 } Redeem temu Coupon Code { ald123454 }
  • Topics

×
×
  • Create New...

Important Information

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