Jump to content

Texture /misc/beam.png not preloaded, will cause render glitches! Beacon Copy


Abascus

Recommended Posts

I tryed to copy the beam of the beacon to let my block also look like an beacon beam, but now this happend: Warning: Texture /misc/beam.png not preloaded, will cause render glitches! and sometimes the light in a chunk disappers.

 

package Abascus.common.Client;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.RenderEngine;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntityBeaconRenderer;
import net.minecraft.src.ModLoader;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;

import org.lwjgl.opengl.GL11;

import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;

public class RenderBeaconHat implements ISimpleBlockRenderingHandler
{
private int renderId = -1;
private long field_82137_b;
private float field_82138_c;

public RenderBeaconHat( int rId)
{
	renderId = rId;

}

public boolean shouldRender3DInInventory()
{
	return false;
}

public boolean hasLightning() 
{
	return true;
}
Tessellator var10 = Tessellator.instance;
public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer)
{
}

protected void bindTextureByName(String par1Str)
{
	RenderEngine var2 = ModLoader.getMinecraftInstance().renderEngine;
	var10 = Tessellator.instance;

	if (var2 != null)
	{
		//System.out.println("a");
		var2.bindTexture(var2.getTexture(par1Str));

	}
}

public static int performanceToFps(int par0)
{
	short var1 = 200;

	if (par0 == 1)
	{
		var1 = 120;
	}

	if (par0 == 2)
	{
		var1 = 35;
	}

	return var1;
}

public float func_82125_v_()
{

	int var1 = (int)(ModLoader.getMinecraftInstance().theWorld.getTotalWorldTime() - this.field_82137_b);
	this.field_82137_b = ModLoader.getMinecraftInstance().theWorld.getTotalWorldTime();

	if (var1 > 1)
	{
		this.field_82138_c -= (float)var1 / 40.0F;

		if (this.field_82138_c < 0.0F)
		{
			this.field_82138_c = 0.0F;
		}
	}

	this.field_82138_c += 0.025F;

	if (this.field_82138_c > 1.0F)
	{
		this.field_82138_c = 1.0F;
	}

	return this.field_82138_c;
}

public boolean renderWorldBlock(IBlockAccess blockAccess, int par2, int par4, int par6, Block block, int modelId, RenderBlocks renderer)
{
	/*try
	{
	//float var9 = par1TileEntityBeacon.func_82125_v_();
		float var9 = 2.0F;
		float r = performanceToFps(ModLoader.getMinecraftInstance().gameSettings.limitFramerate);
		float parx = System.nanoTime() + (long)(1000000000 / r);
		var10 = Tessellator.instance;

            this.bindTextureByName("/misc/beam.png");
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F);
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F);
            GL11.glDisable(GL11.GL_LIGHTING);
            GL11.glDisable(GL11.GL_CULL_FACE);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glDepthMask(true);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);

            float var11 = (float)ModLoader.getMinecraftInstance().theWorld.getTotalWorldTime() +parx;
            float var12 = -var11 * 0.2F - (float)MathHelper.floor_float(-var11 * 0.1F);
            byte var13 = 1;
           double var14 = (double)var11 * 0.025D * (1.0D - (double)(var13 & 1) * 2.5D);
          // var10.isDrawing = false;
           var10.draw();
            var10.startDrawingQuads();
            var10.setColorRGBA(255, 255, 255, 32);

            double var16 = (double)var13 * 0.2D;
            double var18 = 0.5D + Math.cos(var14 + 2.356194490192345D) * var16;
            double var20 = 0.5D + Math.sin(var14 + 2.356194490192345D) * var16;
            double var22 = 0.5D + Math.cos(var14 + (Math.PI / 4D)) * var16;
            double var24 = 0.5D + Math.sin(var14 + (Math.PI / 4D)) * var16;
            double var26 = 0.5D + Math.cos(var14 + 3.9269908169872414D) * var16;
            double var28 = 0.5D + Math.sin(var14 + 3.9269908169872414D) * var16;
            double var30 = 0.5D + Math.cos(var14 + 5.497787143782138D) * var16;
            double var32 = 0.5D + Math.sin(var14 + 5.497787143782138D) * var16;
            double var34 = (double)(256.0F * var9);
            double var36 = 0.0D;
            double var38 = 1.0D;
            double var40 = (double)(-1.0F + var12);
            double var42 = (double)(256.0F * var9) * (0.5D / var16) + var40;
            var10.addVertexWithUV(par2 + var18, par4 + var34, par6 + var20, var38, var42);
            var10.addVertexWithUV(par2 + var18, par4, par6 + var20, var38, var40);
            var10.addVertexWithUV(par2 + var22, par4, par6 + var24, var36, var40);
            var10.addVertexWithUV(par2 + var22, par4 + var34, par6 + var24, var36, var42);
            var10.addVertexWithUV(par2 + var30, par4 + var34, par6 + var32, var38, var42);
            var10.addVertexWithUV(par2 + var30, par4, par6 + var32, var38, var40);
            var10.addVertexWithUV(par2 + var26, par4, par6 + var28, var36, var40);
            var10.addVertexWithUV(par2 + var26, par4 + var34, par6 + var28, var36, var42);
            var10.addVertexWithUV(par2 + var22, par4 + var34, par6 + var24, var38, var42);
            var10.addVertexWithUV(par2 + var22, par4, par6 + var24, var38, var40);
            var10.addVertexWithUV(par2 + var30, par4, par6 + var32, var36, var40);
            var10.addVertexWithUV(par2 + var30, par4 + var34, par6 + var32, var36, var42);
            var10.addVertexWithUV(par2 + var26, par4 + var34, par6 + var28, var38, var42);
            var10.addVertexWithUV(par2 + var26, par4, par6 + var28, var38, var40);
            var10.addVertexWithUV(par2 + var18, par4, par6 + var20, var36, var40);
            var10.addVertexWithUV(par2 + var18, par4 + var34, par6 + var20, var36, var42);
            var10.draw();
            GL11.glEnable(GL11.GL_BLEND);
            GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
            GL11.glDepthMask(false);

            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            GL11.glDepthMask(true);
	}
	catch(Exception e){e.printStackTrace();*/
	float var9 = func_82125_v_();

	if (var9 > 0.0F)
	{
		Tessellator var10 = Tessellator.instance;
		float r = performanceToFps(ModLoader.getMinecraftInstance().gameSettings.limitFramerate);
		float parx = System.nanoTime() + (long)(1000000000 / r);
		this.bindTextureByName("/misc/beam.png");
		GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F);
		GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F);
		GL11.glDisable(GL11.GL_LIGHTING);
		GL11.glDisable(GL11.GL_CULL_FACE);
		GL11.glDisable(GL11.GL_BLEND);
		GL11.glDepthMask(true);
		GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
		float var11 = (float)ModLoader.getMinecraftInstance().theWorld.getTotalWorldTime() +parx;
		float var12 = -var11 * 0.2F - (float)MathHelper.floor_float(-var11 * 0.1F);
		byte var13 = 1;
		double var14 = (double)var11 * 0.025D * (1.0D - (double)(var13 & 1) * 2.5D);
		if(!var10.isDrawing)
		{
			var10.startDrawingQuads();
		}
		var10.setColorRGBA(255, 255, 255, 32);
		double var16 = (double)var13 * 0.2D;
		double var18 = 0.5D + Math.cos(var14 + 2.356194490192345D) * var16;
		double var20 = 0.5D + Math.sin(var14 + 2.356194490192345D) * var16;
		double var22 = 0.5D + Math.cos(var14 + (Math.PI / 4D)) * var16;
		double var24 = 0.5D + Math.sin(var14 + (Math.PI / 4D)) * var16;
		double var26 = 0.5D + Math.cos(var14 + 3.9269908169872414D) * var16;
		double var28 = 0.5D + Math.sin(var14 + 3.9269908169872414D) * var16;
		double var30 = 0.5D + Math.cos(var14 + 5.497787143782138D) * var16;
		double var32 = 0.5D + Math.sin(var14 + 5.497787143782138D) * var16;
		double var34 = (double)(256.0F * var9);
		double var36 = 0.0D;
		double var38 = 1.0D;
		double var40 = (double)(-1.0F + var12);
		double var42 = (double)(256.0F * var9) * (0.5D / var16) + var40;
		var10.addVertexWithUV(par2 + var18, par4 + var34, par6 + var20, var38, var42);
		var10.addVertexWithUV(par2 + var18, par4, par6 + var20, var38, var40);
		var10.addVertexWithUV(par2 + var22, par4, par6 + var24, var36, var40);
		var10.addVertexWithUV(par2 + var22, par4 + var34, par6 + var24, var36, var42);
		var10.addVertexWithUV(par2 + var30, par4 + var34, par6 + var32, var38, var42);
		var10.addVertexWithUV(par2 + var30, par4, par6 + var32, var38, var40);
		var10.addVertexWithUV(par2 + var26, par4, par6 + var28, var36, var40);
		var10.addVertexWithUV(par2 + var26, par4 + var34, par6 + var28, var36, var42);
		var10.addVertexWithUV(par2 + var22, par4 + var34, par6 + var24, var38, var42);
		var10.addVertexWithUV(par2 + var22, par4, par6 + var24, var38, var40);
		var10.addVertexWithUV(par2 + var30, par4, par6 + var32, var36, var40);
		var10.addVertexWithUV(par2 + var30, par4 + var34, par6 + var32, var36, var42);
		var10.addVertexWithUV(par2 + var26, par4 + var34, par6 + var28, var38, var42);
		var10.addVertexWithUV(par2 + var26, par4, par6 + var28, var38, var40);
		var10.addVertexWithUV(par2 + var18, par4, par6 + var20, var36, var40);
		var10.addVertexWithUV(par2 + var18, par4 + var34, par6 + var20, var36, var42);
		if(var10.isDrawing)
		{
			var10.draw();
		}
		GL11.glEnable(GL11.GL_BLEND);
		GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
		GL11.glDepthMask(false);
		if(!var10.isDrawing)
		{
			var10.startDrawingQuads();
		}
		var10.setColorRGBA(255, 255, 255, 32);
		double var44 = 0.2D;
		double var15 = 0.2D;
		double var17 = 0.8D;
		double var19 = 0.2D;
		double var21 = 0.2D;
		double var23 = 0.8D;
		double var25 = 0.8D;
		double var27 = 0.8D;
		double var29 = (double)(256.0F * var9);
		double var31 = 0.0D;
		double var33 = 1.0D;
		double var35 = (double)(-1.0F + var12);
		double var37 = (double)(256.0F * var9) + var35;
		var10.addVertexWithUV(par2 + var44, par4 + var29, par6 + var15, var33, var37);
		var10.addVertexWithUV(par2 + var44, par4, par6 + var15, var33, var35);
		var10.addVertexWithUV(par2 + var17, par4, par6 + var19, var31, var35);
		var10.addVertexWithUV(par2 + var17, par4 + var29, par6 + var19, var31, var37);
		var10.addVertexWithUV(par2 + var25, par4 + var29, par6 + var27, var33, var37);
		var10.addVertexWithUV(par2 + var25, par4, par6 + var27, var33, var35);
		var10.addVertexWithUV(par2 + var21, par4, par6 + var23, var31, var35);
		var10.addVertexWithUV(par2 + var21, par4 + var29, par6 + var23, var31, var37);
		var10.addVertexWithUV(par2 + var17, par4 + var29, par6 + var19, var33, var37);
		var10.addVertexWithUV(par2 + var17, par4, par6 + var19, var33, var35);
		var10.addVertexWithUV(par2 + var25, par4, par6 + var27, var31, var35);
		var10.addVertexWithUV(par2 + var25, par4 + var29, par6 + var27, var31, var37);
		var10.addVertexWithUV(par2 + var21, par4 + var29, par6 + var23, var33, var37);
		var10.addVertexWithUV(par2 + var21, par4, par6 + var23, var33, var35);
		var10.addVertexWithUV(par2 + var44, par4, par6 + var15, var31, var35);
		var10.addVertexWithUV(par2 + var44, par4 + var29, par6 + var15, var31, var37);
		if(var10.isDrawing)
		{
			var10.draw();
		}
		GL11.glEnable(GL11.GL_LIGHTING);
		GL11.glEnable(GL11.GL_TEXTURE_2D);
		GL11.glDepthMask(true);
	}
	return true;
}


public int getRenderId()
{
	return this.renderId;
}
}

 

Link to comment
Share on other sites

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



×
×
  • Create New...

Important Information

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