minesweeperMod.client.ModelFlag.java Source code

Java tutorial

Introduction

Here is the source code for minesweeperMod.client.ModelFlag.java

Source

// Date: 19-7-2013 16:19:21
// Template version 1.1
// Java generated by Techne

package minesweeperMod.client;

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

import org.lwjgl.opengl.GL11;

/**
 * Minesweeper Mod
 * @author MineMaarten
 * www.minemaarten.com
 * @license Lesser GNU Public License v3 (http://www.gnu.org/licenses/lgpl.html)
 */

public class ModelFlag extends ModelBase {
    private final ModelRenderer Base;
    private final ModelRenderer Pole;
    private final ModelRenderer Flag;

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

        Base = new ModelRenderer(this, 8, 0);
        Base.addBox(0F, 0F, 0F, 12, 1, 12);
        Base.setRotationPoint(-6F, 23F, -6F);
        Base.setTextureSize(64, 32);
        Base.mirror = true;
        setRotation(Base, 0F, 0F, 0F);
        Pole = new ModelRenderer(this, 0, 0);
        Pole.addBox(0F, 0F, 0F, 2, 30, 2);
        Pole.setRotationPoint(-1F, -7F, -1F);
        Pole.setTextureSize(64, 32);
        Pole.mirror = true;
        setRotation(Pole, 0F, 0F, 0F);
        Flag = new ModelRenderer(this, 8, 13);
        Flag.addBox(0F, 0F, 0F, 8, 8, 1);
        Flag.setRotationPoint(1F, -7F, -0.5F);
        Flag.setTextureSize(64, 32);
        Flag.mirror = true;
        setRotation(Flag, 0F, 0F, 0F);
    }

    @Override
    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);
        Pole.render(f5);
        Flag.render(f5);
    }

    public void renderModel(float size, float rotation) {
        Base.render(size);
        GL11.glRotated(rotation, 0, 1, 0);
        Pole.render(size);
        Flag.render(size);
    }

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