fr.mcnanotech.kevin_68.nanotechmod.main.client.renderer.items.ItemDebugRender.java Source code

Java tutorial

Introduction

Here is the source code for fr.mcnanotech.kevin_68.nanotechmod.main.client.renderer.items.ItemDebugRender.java

Source

/**
 * This work is made available under the terms of the Creative Commons Attribution License:
 * http://creativecommons.org/licenses/by-nc-sa/4.0/deed.en
 * 
 * Cette uvre est mise  disposition selon les termes de la Licence Creative Commons Attribution:
 * http://creativecommons.org/licenses/by-nc-sa/4.0/deed.fr
 */
package fr.mcnanotech.kevin_68.nanotechmod.main.client.renderer.items;

import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;

import org.lwjgl.opengl.GL11;

import fr.mcnanotech.kevin_68.nanotechmod.main.client.model.items.ItemDebugModel;

public class ItemDebugRender implements IItemRenderer {
    protected ItemDebugModel model;
    protected static final ResourceLocation texture = new ResourceLocation("nanotechmod",
            "textures/items/debug.png");

    public ItemDebugRender() {
        model = new ItemDebugModel();
    }

    @Override
    public boolean handleRenderType(ItemStack item, ItemRenderType type) {
        switch (type) {
        case EQUIPPED:
            return true;
        case EQUIPPED_FIRST_PERSON:
            return true;
        case ENTITY:
            return true;
        default:
            return false;
        }
    }

    @Override
    public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
        return false;
    }

    @Override
    public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
        switch (type) {
        case EQUIPPED: {
            GL11.glPushMatrix();
            Minecraft.getMinecraft().renderEngine.bindTexture(texture);
            GL11.glTranslatef(0.4F, -0.6F, 0.0F);
            model.render((Entity) data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
            GL11.glPopMatrix();
            break;
        }
        case EQUIPPED_FIRST_PERSON: {
            GL11.glPushMatrix();
            Minecraft.getMinecraft().renderEngine.bindTexture(texture);
            GL11.glTranslatef(0.4F, -0.6F, 0.0F);
            model.render((Entity) data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
            GL11.glPopMatrix();
            break;
        }
        case ENTITY: {
            GL11.glPushMatrix();
            Minecraft.getMinecraft().renderEngine.bindTexture(texture);
            GL11.glTranslatef(0.4F, -0.6F, 0.0F);
            if (RenderItem.renderInFrame) {
                GL11.glScalef(1.2F, 1.2F, 1.2F);
                GL11.glTranslatef(-0.35F, -0.35F, 0.05F);
            }
            model.render((Entity) data[1], 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
            GL11.glPopMatrix();
            break;
        }
        default:
            break;
        }
    }
}