mal.carbonization.render.FluidTransportItemRenderer.java Source code

Java tutorial

Introduction

Here is the source code for mal.carbonization.render.FluidTransportItemRenderer.java

Source

package mal.carbonization.render;

import mal.carbonization.item.ItemStructureBlock;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.entity.RenderManager;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.IItemRenderer;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import net.minecraftforge.client.IItemRenderer.ItemRendererHelper;

import org.lwjgl.opengl.GL11;

public class FluidTransportItemRenderer implements IItemRenderer {

    private final FluidTransporterModel model;

    public FluidTransportItemRenderer() {
        model = new FluidTransporterModel();
    }

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

    @Override
    public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) {
        switch (type) {
        case ENTITY: {
            return (helper == ItemRendererHelper.ENTITY_BOBBING || helper == ItemRendererHelper.ENTITY_ROTATION
                    || helper == ItemRendererHelper.BLOCK_3D);
        }
        case EQUIPPED: {
            return (helper == ItemRendererHelper.BLOCK_3D || helper == ItemRendererHelper.EQUIPPED_BLOCK);
        }
        case EQUIPPED_FIRST_PERSON: {
            return (helper == ItemRendererHelper.EQUIPPED_BLOCK);
        }
        case INVENTORY: {
            return (helper == ItemRendererHelper.INVENTORY_BLOCK);
        }
        default: {
            return false;
        }
        }
    }

    @Override
    public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
        GL11.glPushMatrix();

        GL11.glScalef(1.6f, 1.6f, 1.6f);
        ResourceLocation texture = new ResourceLocation("carbonization",
                "textures/blocks/fluidTransportTexture.png");
        Minecraft.getMinecraft().renderEngine.bindTexture(texture);

        switch (type) {
        case ENTITY:
            GL11.glTranslatef(-0.4f, 0.0f, -0.4f);
            break;
        case EQUIPPED:
            break;
        case EQUIPPED_FIRST_PERSON:
            break;
        case FIRST_PERSON_MAP:
            break;
        case INVENTORY:
            GL11.glTranslatef(0.0f, -0.06f, 0.0f);
            break;
        default:
            break;

        }

        this.model.render(null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F);
        GL11.glPopMatrix();
    }
}
/*******************************************************************************
* Copyright (c) 2014 Malorolam.
* 
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the included license, which is also
* available at http://carbonization.wikispaces.com/License
* 
*********************************************************************************/