Jump to content

[1.4]Render problem


Moritz

Recommended Posts

Hello.

 

I have A Render Bug/Problem. The actually code is working but the problem is i want to make a XYZ Rotation and when i make a Y Rotation the block (texture not the block itself) stays x/z + 1 and y + 1 from his normal place.

 

Here is my code:

 

Moddel Hopper

 
package speiger.src.tinychest.client.models;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;

public class ModelHopper extends ModelBase
{
  //fields
    ModelRenderer Top;
    ModelRenderer Kanal;
    ModelRenderer Bottom;
    ModelRenderer Seite_Back;
    ModelRenderer Seite_Front;
    ModelRenderer Seite_Rechts;
    ModelRenderer Seite_Links;
  
  public ModelHopper()
  {
    textureWidth = 64;
    textureHeight = 64;
    
      Top = new ModelRenderer(this, 0, 0);
      Top.addBox(0F, 0F, 0F, 16, 6, 16);
      Top.setRotationPoint(-8F, 24F, 2F);
      Top.setTextureSize(64, 32);
      Top.mirror = true;
      setRotation(Top, 1.570796F, 0F, 0F);
      Kanal = new ModelRenderer(this, 0, 24);
      Kanal.addBox(0F, 0F, 0F, 3, 8, 3);
      Kanal.setRotationPoint(-1.5F, 17.5F, -6F);
      Kanal.setTextureSize(64, 32);
      Kanal.mirror = true;
      setRotation(Kanal, 1.570796F, 0F, 0F);
      Bottom = new ModelRenderer(this, 16, 24);
      Bottom.addBox(0F, 0F, 0F, 10, 1, 10);
      Bottom.setRotationPoint(-5F, 21F, -8F);
      Bottom.setTextureSize(64, 32);
      Bottom.mirror = true;
      setRotation(Bottom, 1.570796F, 0F, 0F);
      Seite_Back = new ModelRenderer(this, 25, 40);
      Seite_Back.addBox(0F, 0F, 0F, 10, 1, 1);
      Seite_Back.setRotationPoint(-5F, 21F, -7F);
      Seite_Back.setTextureSize(64, 32);
      Seite_Back.mirror = true;
      setRotation(Seite_Back, 1.570796F, 0F, 0F);
      Seite_Front = new ModelRenderer(this, 0, 40);
      Seite_Front.addBox(0F, 0F, 0F, 10, 1, 1);
      Seite_Front.setRotationPoint(-5F, 12F, -7F);
      Seite_Front.setTextureSize(64, 32);
      Seite_Front.mirror = true;
      setRotation(Seite_Front, 1.570796F, 0F, 0F);
      Seite_Rechts = new ModelRenderer(this, 0, 47);
      Seite_Rechts.addBox(0F, 0F, 0F, 1, 1, ;
      Seite_Rechts.setRotationPoint(-5F, 20F, -7F);
      Seite_Rechts.setTextureSize(64, 32);
      Seite_Rechts.mirror = true;
      setRotation(Seite_Rechts, 1.570796F, 0F, 0F);
      Seite_Links = new ModelRenderer(this, 21, 47);
      Seite_Links.addBox(0F, 0F, 0F, 1, 1, ;
      Seite_Links.setRotationPoint(4F, 20F, -7F);
      Seite_Links.setTextureSize(64, 32);
      Seite_Links.mirror = true;
      setRotation(Seite_Links, 1.570796F, 0F, 0F);
  }
  
  public void render(float size)
{
  Top.render(size);
  Kanal.render(size);
  Bottom.render(size);
  Seite_Back.render(size);
  Seite_Front.render(size);
  Seite_Rechts.render(size);
  Seite_Links.render(size);
}

public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
  super.render(entity, f, f1, f2, f3, f4, f5);
  setRotationAngles(f, f1, f2, f3, f4, f5, entity);
  Top.render(f5);
  Kanal.render(f5);
  Bottom.render(f5);
  Seite_Back.render(f5);
  Seite_Front.render(f5);
  Seite_Rechts.render(f5);
  Seite_Links.render(f5);
}

private void setRotation(ModelRenderer model, float x, float y, float z)
{
  model.rotateAngleX = x;
  model.rotateAngleY = y;
  model.rotateAngleZ = z;
}

public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity f6)
{
  super.setRotationAngles(f, f1, f2, f3, f4, f5, f6);
}

}

 

RenderHopper

package speiger.src.tinychest.client.render;

import org.lwjgl.opengl.GL11;

import speiger.src.tinychest.client.models.ModelHopper;
import speiger.src.tinychest.common.tileentity.TileEntityBasicTinyHopper;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;

public class RenderHopper extends TileEntitySpecialRenderer 
{

private ModelHopper hopper = new ModelHopper();


public RenderHopper() 
{
}

@Override
public void renderTileEntityAt(TileEntity var1, double var2, double var4, double var6, float var8) 
{
	renderHopper((TileEntityBasicTinyHopper)var1, var2, var4, var6, 1F);
}

private void renderHopper(TileEntityBasicTinyHopper par1, double par2, double par3, double par4, float par5)
{
	GL11.glPushMatrix();
	GL11.glTranslatef((float) par2 + 0.5f, (float) par3 + 1.5f, (float) par4 + 0.5f);
	bindTextureByName("/speiger/src/tinychest/textures/ModelHopper.png");

	switch(par1.getFacing())
	{
		case 0: GL11.glRotatef(-90, 1F, 0F, 0F); break;
		case 1: GL11.glRotatef(90, 1F, 0F, 0F); break;
    	case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; 
    	case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break;
    	case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break;
    	case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break;
	}

	GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
	hopper.render(0.0625F);
	GL11.glPopMatrix();
}

}

 

So what is the problem??

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.



×
×
  • Create New...

Important Information

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