Jump to content

Strange tile entity model rotation


nike4613

Recommended Posts

I'm trying to rotate a tile entity model and it is causing inconsistant results. Any suggestions? Any help is appreciated!

 

Renderer:

 

package net.mc42.mods.eclipses.tileentities.EssenceInfuser;

import org.lwjgl.opengl.GL11;

import net.mc42.mods.eclipses.mod_Eclipses;
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.entity.Entity;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;

public class TileEntityEssenceInfuserRenderer extends TileEntitySpecialRenderer {
        
        //The model of your block
        private final EssenceInfuserModelBase model;
        
        public TileEntityEssenceInfuserRenderer() {
                this.model = new EssenceInfuserModelBase();
               // this.modelContent = new TileEntityJarContentsModel(0);
        }
        
        private void adjustRotatePivotViaMeta(World world, int x, int y, int z) {
                int meta = world.getBlockMetadata(x, y, z);
                GL11.glPushMatrix();
                GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F);
                GL11.glPopMatrix();
        }
        
        @Override
        public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) {
        	
        	TileEntityEssenceInfuser tej = (TileEntityEssenceInfuser) te;
        //The PushMatrix tells the renderer to "start" doing something.
             //The PushMatrix tells the renderer to "start" doing something.
                GL11.glPushMatrix();
        //This is setting the initial location.
                GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
        //This is the texture of your block. It's pathed to be the same place as your other blocks here.
                //Outdated bindTextureByName("/mods/roads/textures/blocks/TrafficLightPoleRed.png");
       //Use in 1.6.2  this
                ResourceLocation textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Base.png")); 
                //textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Tank.png")); 
                //textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Backboard.png"));
                //textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Top.png"));
        //the ':' is very important
        //binding the textures
                Minecraft.getMinecraft().renderEngine.bindTexture(textures1);

        //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again!                       
                GL11.glPushMatrix();
                
                //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                
                GL11.glRotatef(180F, tej.orient*1F, 0.0F, 1.0F);
        //A reference to your Model file. Again, very important.
                //this.modelCap.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
                this.model.renderBase((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        //Tell it to stop rendering for both the PushMatrix's
                GL11.glPopMatrix();
                textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Tank.png")); 
                //textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Tank.png")); 
                //textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Backboard.png"));
                //textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Top.png"));
        //the ':' is very important
        //binding the textures
                Minecraft.getMinecraft().renderEngine.bindTexture(textures1);

        //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again!                       
                GL11.glPushMatrix();
                GL11.glDisable(GL11.GL_CULL_FACE);
                
                //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                
                GL11.glRotatef(180F, tej.orient*1F, 0.0F, 1.0F);
        //A reference to your Model file. Again, very important.
                //this.modelCap.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
                this.model.renderTank((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        //Tell it to stop rendering for both the PushMatrix's
                GL11.glEnable(GL11.GL_CULL_FACE);
                GL11.glPopMatrix();
                textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Backboard.png")); 
                //textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Tank.png")); 
                //textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Backboard.png"));
                //textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Top.png"));
        //the ':' is very important
        //binding the textures
                Minecraft.getMinecraft().renderEngine.bindTexture(textures1);

        //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again!                       
                GL11.glPushMatrix();
                
                //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                
                GL11.glRotatef(180F, tej.orient*1F, 0.0F, 1.0F);        //A reference to your Model file. Again, very important.
                //this.modelCap.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
                this.model.renderBackboard((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        //Tell it to stop rendering for both the PushMatrix's
                GL11.glPopMatrix();
                textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Top.png")); 
                //textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Tank.png")); 
                //textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Backboard.png"));
                //textures1 = (new ResourceLocation("modeclipses:textures/blocks/EssenceInfuser/Top.png"));
        //the ':' is very important
        //binding the textures
                Minecraft.getMinecraft().renderEngine.bindTexture(textures1);

        //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again!                       
                GL11.glPushMatrix();
                
                //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                
                GL11.glRotatef(180F, tej.orient*1F, 0.0F, 1.0F);
        //A reference to your Model file. Again, very important.
                //this.modelCap.render((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
                this.model.renderTop((Entity)null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        //Tell it to stop rendering for both the PushMatrix's
                GL11.glPopMatrix();
                GL11.glPopMatrix();
        }

        //Set the lighting stuff, so it changes it's brightness properly.       
        private void adjustLightFixture(World world, int i, int j, int k, Block block) {
                Tessellator tess = Tessellator.instance;
                //float brightness = block.getBlockBrightness(world, i, j, k);
                //As of MC 1.7+ block.getBlockBrightness() has become block.getLightValue():
                float brightness = block.getLightValue(world, i, j, k);
                int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
                int modulousModifier = skyLight % 65536;
                int divModifier = skyLight / 65536;
                tess.setColorOpaque_F(brightness, brightness, brightness);
                OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit,  (float) modulousModifier,  divModifier);
        }
}

 

 

Model:

 

// Date: 9/7/2014 8:03:14 PM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX






package net.mc42.mods.eclipses.tileentities.EssenceInfuser;

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

public class EssenceInfuserModelBase extends ModelBase
{
  //fields
    ModelRenderer Base;
    ModelRenderer Tank;
    ModelRenderer Backboard;
    ModelRenderer Top;
  
  public EssenceInfuserModelBase()
  {
    textureWidth = 64;
    textureHeight = 32;
    
      Base = new ModelRenderer(this, 0, 0);
      Base.addBox(0F, 0F, 0F, 14, 14, 14);
      Base.setRotationPoint(-6F, 10F, -7F);
      Base.setTextureSize(64, 32);
      Base.mirror = true;
      setRotation(Base, 0.0174533F, 0F, 0F);
      Tank = new ModelRenderer(this, 0, 0);
      Tank.addBox(0F, 0F, 0F, 8, 14, ;
      Tank.setRotationPoint(-1F, -4F, -4.25F);
      Tank.setTextureSize(64, 32);
      Tank.mirror = true;
      setRotation(Tank, 0.0174533F, 0F, 0F);
      Backboard = new ModelRenderer(this, 0, 0);
      Backboard.addBox(0F, 0F, 0F, 2, 14, 10);
      Backboard.setRotationPoint(6F, -4F, -5.25F);
      Backboard.setTextureSize(64, 32);
      Backboard.mirror = true;
      setRotation(Backboard, 0.0174533F, 0F, 0F);
      Top = new ModelRenderer(this, 0, 0);
      Top.addBox(0F, 0F, 0F, 10, 2, 10);
      Top.setRotationPoint(-2F, -5F, -5.25F);
      Top.setTextureSize(64, 32);
      Top.mirror = true;
      setRotation(Top, 0F, 0F, 0F);
  }
  
  public void renderBase(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);
    //Tank.render(f5);
    //Backboard.render(f5);
    //Top.render(f5);
  }
  public void renderTank(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);
    Tank.render(f5);
    //Backboard.render(f5);
    //Top.render(f5);
  }
  public void renderBackboard(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);
    //Tank.render(f5);
    Backboard.render(f5);
    //Top.render(f5);
  }
  public void renderTop(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);
    //Tank.render(f5);
    //Backboard.render(f5);
    Top.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 e)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5, e);
  }

}

 

 

post3.png

Link to comment
Share on other sites

I actually haven't done much rendering at all, but I think this could be because you're not rotating it back after you're done. I could be completely wrong though.

BEFORE ASKING FOR HELP READ THE EAQ!

 

I'll help if I can. Apologies if I do something obviously stupid. :D

 

If you don't know basic Java yet, go and follow these tutorials.

Link to comment
Share on other sites

GL11.glRotatef(180F, tej.orient*1F, 0.0F, 1.0F);

 

You realize this is rotating about a non-Euclidian axis. The results will not be what you expect. Simple rotation about a world axis sets only one of X, Y or Z to 1.0f the others should be 0.0f.

Link to comment
Share on other sites

  • 2 weeks later...

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

    • https://pastebin.com/VwpAW6PX My game crashes upon launch when trying to implement the Oculus mod to this mod compilation, above is the crash report, I do not know where to begin to attempt to fix this issue and require assistance.
    • https://youtube.com/shorts/gqLTSMymgUg?si=5QOeSvA4TTs-bL46
    • CubeHaven is a SMP server with unique features that can't be found on the majority of other servers! Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132 3 different stores: - CubeHaven Store: Our store to purchase using real money. - Bitcoin Store: Store for Bitcoin. Bitcoin can be earned from playing the server. Giving options for players if they want to spend real money or grind to obtain exclusive packages. - Black Market: A hidden store for trading that operates outside our traditional stores, like custom enchantments, exclusive items and more. Some of our features include: Rank Up: Progress through different ranks to unlock new privileges and perks. 📈 Skills: RPG-style skill system that enhances your gaming experience! 🎮 Leaderboards: Compete and shine! Top players are rewarded weekly! 🏆 Random Teleporter: Travel instantly across different worlds with a click! 🌐 Custom World Generation: Beautifully generated world. 🌍 Dungeons: Explore challenging and rewarding dungeons filled with treasures and monsters. 🏰 Kits: Unlock ranks and gain access to various kits. 🛠️ Fishing Tournament: Compete in a friendly fishing tournament! 🎣 Chat Games: Enjoy games right within the chat! 🎲 Minions: Get some help from your loyal minions. 👥 Piñata Party: Enjoy a festive party with Piñatas! 🎉 Quests: Over 1000 quests that you can complete! 📜 Bounty Hunter: Set a bounty on a player's head. 💰 Tags: Displayed on nametags, in the tab list, and in chat. 🏷️ Coinflip: Bet with other players on coin toss outcomes, victory, or defeat! 🟢 Invisible & Glowing Frames: Hide your frames for a cleaner look or apply a glow to it for a beautiful look. 🔲✨[ Player Warp: Set your own warp points for other players to teleport to. 🌟 Display Shop: Create your own shop and sell to other players! 🛒 Item Skins: Customize your items with unique skins. 🎨 Pets: Your cute loyal companion to follow you wherever you go! 🐾 Cosmetics: Enhance the look of your character with beautiful cosmetics! 💄 XP-Bottle: Store your exp safely in a bottle for later use! 🍶 Chest & Inventory Sorting: Keep your items neatly sorted in your inventory or chest! 📦 Glowing: Stand out from other players with a colorful glow! ✨ Player Particles: Over 100 unique particle effects to show off. 🎇 Portable Inventories: Over virtual inventories with ease. 🧳 And a lot more! Become part of our growing community today! Discord: https://cubehaven.net/discord Java: MC.CUBEHAVEN.NET Bedrock: MC.CUBEHAVEN.NET:19132
    • # Problematic frame: # C [libopenal.so+0x9fb4d] It is always the same issue - this refers to the Linux OS - so your system may prevent Java from working   I am not familiar with Linux - check for similar/related issues  
  • Topics

×
×
  • Create New...

Important Information

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