com.stormister.rediscovered.ModelChair.java Source code

Java tutorial

Introduction

Here is the source code for com.stormister.rediscovered.ModelChair.java

Source

//     Copyright 2012-2014 Matthew Karcz
//
//     This file is part of The Rediscovered Mod.
//
//    The Rediscovered Mod is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    The Rediscovered Mod is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with The Rediscovered Mod.  If not, see <http://www.gnu.org/licenses/>.

// Date: 12/22/2012 10:59:16 PM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX

package com.stormister.rediscovered;

import org.lwjgl.opengl.GL11;

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

public class ModelChair extends ModelBase {
    //fields
    ModelRenderer leg1;
    ModelRenderer leg3;
    ModelRenderer leg2;
    ModelRenderer leg4;
    ModelRenderer seat;
    ModelRenderer back;

    public ModelChair() {
        textureWidth = 64;
        textureHeight = 32;

        leg1 = new ModelRenderer(this, 0, 0);
        leg1.addBox(0F, 0F, 0F, 2, 6, 2);
        leg1.setRotationPoint(-6F, 18F, -6F);
        leg1.setTextureSize(64, 32);
        leg1.mirror = true;
        setRotation(leg1, 0F, 0F, 0F);
        leg3 = new ModelRenderer(this, 0, 0);
        leg3.addBox(0F, 0F, 0F, 2, 6, 2);
        leg3.setRotationPoint(4F, 18F, 4F);
        leg3.setTextureSize(64, 32);
        leg3.mirror = true;
        setRotation(leg3, 0F, 0F, 0F);
        leg2 = new ModelRenderer(this, 0, 0);
        leg2.addBox(0F, 0F, 0F, 2, 6, 2);
        leg2.setRotationPoint(4F, 18F, -6F);
        leg2.setTextureSize(64, 32);
        leg2.mirror = true;
        setRotation(leg2, 0F, 0F, 0F);
        leg4 = new ModelRenderer(this, 0, 0);
        leg4.addBox(0F, 0F, 0F, 2, 6, 2);
        leg4.setRotationPoint(-6F, 18F, 4F);
        leg4.setTextureSize(64, 32);
        leg4.mirror = true;
        setRotation(leg4, 0F, 0F, 0F);
        seat = new ModelRenderer(this, 0, 14);
        seat.addBox(0F, 0F, 0F, 12, 2, 12);
        seat.setRotationPoint(-6F, 16F, -6F);
        seat.setTextureSize(64, 32);
        seat.mirror = true;
        setRotation(seat, 0F, 0F, 0F);
        back = new ModelRenderer(this, 8, 0);
        back.addBox(0F, 0F, 0F, 12, 8, 2);
        back.setRotationPoint(-6F, 8F, 4F);
        back.setTextureSize(64, 32);
        back.mirror = true;
        setRotation(back, 0F, 0F, 0F);
    }

    public void render(float scale, double x, double y, double z, float ang, float angY, boolean renderLantern,
            boolean lanternOn, boolean renderHeadTorch) {
        GL11.glPushMatrix();
        GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
        GL11.glPushMatrix();
        GL11.glRotatef(ang, 1f, 0f, 0f);
        GL11.glRotatef(angY, 0f, 1f, 0f);
        back.render(scale);
        leg1.render(scale);
        leg2.render(scale);
        leg3.render(scale);
        leg4.render(scale);
        seat.render(scale);

        GL11.glPopMatrix();
        GL11.glPopMatrix();
    }

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

    public void renderAll() {
        back.render(0.0625F);
        leg1.render(0.0625F);
        leg2.render(0.0625F);
        leg3.render(0.0625F);
        leg4.render(0.0625F);
        seat.render(0.0625F);
    }

}