Jump to content

Recommended Posts

Posted

I have tried adjusting all values in my GL11.glRotatef([params]) function but non of them are rotating the block properly. It should just rotate where the player is facing, like a furnace. Not up and down.

 

Here's my code:

TileEntityOvenRenderer

 

package tk.yteditors.requiredstuffz.renderer;

 

import net.minecraft.block.Block;

import net.minecraft.client.Minecraft;

import net.minecraft.client.renderer.OpenGlHelper;

import net.minecraft.client.renderer.Tessellator;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.ResourceLocation;

import net.minecraft.world.World;

 

import org.lwjgl.opengl.GL11;

 

import tk.yteditors.requiredstuffz.RequiredStuffz;

import tk.yteditors.requiredstuffz.models.OvenModel;

import tk.yteditors.requiredstuffz.reference.ModInfo;

import tk.yteditors.requiredstuffz.tileEntity.TileEntityOven;

 

public class TileEntityOvenRenderer extends TileEntitySpecialRenderer {

 

public final OvenModel model;

private static final ResourceLocation resourceloc = new ResourceLocation(ModInfo.MOD_ID + ":" + "textures/tileentity/computer.png");

 

public TileEntityOvenRenderer() {

model = new OvenModel();

}

 

@Override

public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {

if (te == null)

return;

TileEntityOven tileEntity = (TileEntityOven) te;

 

GL11.glPushMatrix();

GL11.glTranslatef((float) x + 0.5F, (float) y + .5f, (float) z + 0.5F);

Minecraft.getMinecraft().renderEngine.bindTexture(resourceloc);

GL11.glPushMatrix();

GL11.glRotatef(tileEntity.direction * (-90), 0.0F, 0.0F, 1.0F);

GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);

model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);

GL11.glPopMatrix();

GL11.glPopMatrix();

}

 

}

 

 

OvenModel:

 

 

 

package tk.yteditors.requiredstuffz.models;

 

import net.minecraft.client.model.ModelBase;

import net.minecraft.client.model.ModelRenderer;

import net.minecraft.entity.Entity;

 

public class OvenModel extends ModelBase {

// fields

ModelRenderer Base;

ModelRenderer Side1;

ModelRenderer Side2;

ModelRenderer Top;

ModelRenderer Chimney1;

ModelRenderer Chimney2;

ModelRenderer Chimney3;

ModelRenderer Chimney4;

ModelRenderer Back;

ModelRenderer TopCorner1;

ModelRenderer TopCorner2;

 

public OvenModel() {

textureWidth = 64;

textureHeight = 64;

 

Base = new ModelRenderer(this, 0, 0);

Base.addBox(0F, 0F, 0F, 16, 1, 16);

Base.setRotationPoint(-8F, 7F, -8F);

Base.setTextureSize(64, 32);

Base.mirror = true;

setRotation(Base, 0F, 0F, 0F);

Side1 = new ModelRenderer(this, 0, 0);

Side1.addBox(0F, 0F, 0F, 1, 5, 16);

Side1.setRotationPoint(-8F, 2F, -8F);

Side1.setTextureSize(64, 32);

Side1.mirror = true;

setRotation(Side1, 0F, 0F, 0F);

Side2 = new ModelRenderer(this, 0, 0);

Side2.addBox(0F, 0F, 0F, 1, 5, 16);

Side2.setRotationPoint(7F, 2F, -8F);

Side2.setTextureSize(64, 32);

Side2.mirror = true;

setRotation(Side2, 0F, 0F, 0F);

Top = new ModelRenderer(this, 0, 0);

Top.addBox(0F, 0F, 0F, 12, 1, 16);

Top.setRotationPoint(-6F, 0F, -8F);

Top.setTextureSize(64, 32);

Top.mirror = true;

setRotation(Top, 0F, 0F, 0F);

Chimney1 = new ModelRenderer(this, 0, 0);

Chimney1.addBox(0F, 0F, 0F, 1, 8, 3);

Chimney1.setRotationPoint(-2F, -8F, -1F);

Chimney1.setTextureSize(64, 64);

Chimney1.mirror = true;

setRotation(Chimney1, 0F, 0F, 0F);

Chimney2 = new ModelRenderer(this, 0, 0);

Chimney2.addBox(0F, 0F, 0F, 3, 8, 1);

Chimney2.setRotationPoint(-2F, -8F, 2F);

Chimney2.setTextureSize(64, 64);

Chimney2.mirror = true;

setRotation(Chimney2, 0F, 0F, 0F);

Chimney3 = new ModelRenderer(this, 0, 0);

Chimney3.addBox(0F, 0F, 0F, 1, 8, 3);

Chimney3.setRotationPoint(1F, -8F, 0F);

Chimney3.setTextureSize(64, 64);

Chimney3.mirror = true;

setRotation(Chimney3, 0F, 0F, 0F);

Chimney4 = new ModelRenderer(this, 0, 0);

Chimney4.addBox(0F, 0F, 0F, 3, 8, 1);

Chimney4.setRotationPoint(-1F, -8F, -1F);

Chimney4.setTextureSize(64, 64);

Chimney4.mirror = true;

setRotation(Chimney4, 0F, 0F, 0F);

Back = new ModelRenderer(this, 0, 0);

Back.addBox(0F, 0F, 0F, 14, 6, 1);

Back.setRotationPoint(-7F, 1F, 7F);

Back.setTextureSize(64, 64);

Back.mirror = true;

setRotation(Back, 0F, 0F, 0F);

TopCorner1 = new ModelRenderer(this, 0, 0);

TopCorner1.addBox(0F, 0F, 0F, 1, 1, 15);

TopCorner1.setRotationPoint(-7F, 1F, -8F);

TopCorner1.setTextureSize(64, 64);

TopCorner1.mirror = true;

setRotation(TopCorner1, 0F, 0F, 0F);

TopCorner2 = new ModelRenderer(this, 0, 0);

TopCorner2.addBox(0F, 0F, 0F, 1, 1, 15);

TopCorner2.setRotationPoint(6F, 1F, -8F);

TopCorner2.setTextureSize(64, 64);

TopCorner2.mirror = true;

setRotation(TopCorner2, 0F, 0F, 0F);

}

 

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);

Base.render(f5);

Side1.render(f5);

Side2.render(f5);

Top.render(f5);

Chimney1.render(f5);

Chimney2.render(f5);

Chimney3.render(f5);

Chimney4.render(f5);

Back.render(f5);

TopCorner1.render(f5);

TopCorner2.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 entity) {

super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);

}

 

}

 

 

 

 

BlockOven@onBlockPlacedBy:

 

 

@Override

public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemStack) {

if(entityliving == null){

return;

}

 

TileEntityOven tileEntity = (TileEntityOven) world.getTileEntity(x, y, z);

tileEntity.direction = MathHelper.floor_double((double) (entityliving.rotationYaw * 4f / 360f) + .5D) & 3;

}

 

 

Check out my mod!

Posted

I am going to say this: Try the x axis instead and come back and say what happened. If it worked, great, if it didn't... We will be in touch.

[EDIT]

Rotate on the y axis - as weird as that sounds. Scratch my earlier statement. I got confused.

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Posted

... The params are this:

Angle, X, Y, Z

 

So you would want this:

GL11.glRotatef(tileEntity.direction * (-90), 0.0F, 1.0F, 0.0F);

 

Is that the ONLY rotation call you have? And does it look like that one above?

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Posted

Hi

 

Your up/down is because you were rotating on the z-axis?

 

Have you tried test angles on the y-axis just to see if it rotates in the expected direction eg

 

GL11.glRotatef(45F, 0.0F, 1.0F, 0.0F);

 

-TGG

Posted

Now I have:

 

if(tileEntity.direction == 0 || tileEntity.direction == 2) GL11.glRotatef(tileEntity.direction * (-90), 0.0F, tileEntity.direction * (-90), 1f);

if(tileEntity.direction == 1 || tileEntity.direction == 3) GL11.glRotatef(tileEntity.direction * (90), 0.0F, tileEntity.direction * (-90), 1f);

 

And it perfectly works! It rotates the way it should!

Check out my mod!

Posted

Very nice! That is pretty much a combination of metadata and just storing the rotation... Good job :)

We all stuff up sometimes... But I seem to be at the bottom of that pot.

Posted

By the way, you shouldn't have to use G11 rotation to rotate a ModelRenderer.  ModelRenderer has its own setRotation() method.

 

And yeah, the rotation axis is the one you rotate around, not the direction you want to rotate.  In other words the rotation axis is normally at right angles to the direction you want to rotate.  If you want to rotate left or right you rotate around Y, if you want to rotate up and down you rotate around X, if you want to rotate front face clockwise or counterclockwise you rotate around Z.  It makes sense once you understand it.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.