Jump to content

Recommended Posts

Posted

Hello reader,

 

I am trying to have a block with a TileEntitySpecialRenderer and a block model have animated textures. The workaround so far that I have is to change the texture every 5 times the method is called in the TileEntitySpecialRenderer implemented class, but this causes some strange behaviours.

 

If I look at the blocks on a more acute angle, the textures seem to speed up really fast compared to when the player stares at it directly. It also does not stop when the game is paused.

 

Because of this, I am wandering if there is another way to have block animations with blocks that have models than what I have already got. If there is no other way, does anyone know any OpenGL code to make the block render more correctly (uniform speed no matter what angle)?

 

An example of my workaround is below:

 

TileEntityLightBridgeSectionRenderer.java

 

package kris91268.lbd.Tileentity;

import kris91268.lbd.ModLBD;
import kris91268.lbd.Models.ModelLightBridgeSection;

import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.tileentity.TileEntity;

/**
* 
* @author Arbiter
*
*/
@SideOnly(Side.CLIENT)
public class TileEntityLightBridgeSectionRenderer extends TileEntitySpecialRenderer
{
private ModelLightBridgeSection model = new ModelLightBridgeSection();
    private byte index;

public void renderAModelAt(TileEntityLightBridgeSection par1TileEntityLightBridgeSection, double par2, double par3, double par4, float par5)
{
	int par6 = 0;
	if (par1TileEntityLightBridgeSection.getWorldObj() != null)
	{
		par6 = par1TileEntityLightBridgeSection.getBlockMetadata();
	}
	short par7 = (short)(par6 * 90);
	this.bindTexture(LightTextures.bridgeTextures[index / 5]);
	if (ModLBD.shouldAnimate)
	{
		index++;
		if (index / 5 == LightTextures.bridgeTextures.length)
		{
			index = 0;
		}
	}
	GL11.glPushMatrix();
	GL11.glTranslatef((float)par2 + 0.5F, (float)par3 + 1.5F, (float)par4 + 0.5F);
	GL11.glRotatef((float)par7, 0.0F, 1.0F, 0.0F);
	GL11.glScalef(1.0F, -1.0F, -1.0F);
	GL11.glDepthMask(true);
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glEnable(GL11.GL_LIGHTING);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);	
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glDepthMask(false);
	this.model.renderModel(0.0625F);
	GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
	GL11.glPopMatrix();
}
public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par3, double par4, float par5)
{
	this.renderAModelAt((TileEntityLightBridgeSection)par1TileEntity, par2, par3, par4, par5);
}
}

 

 

The reference to LightTextures.bridgeTextures is simply an array of ResourceLocations for the texture for every frame.

 

Any help is much appreciated  ;D

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.