Java tutorial
package com.savageboy74.savagetech.client.render.item; /* * ItemRenderLootBox.java * Copyright (C) 2015 Savage - github.com/savageboy74 * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ import com.savageboy74.savagetech.util.Textures; import cpw.mods.fml.client.FMLClientHandler; import net.minecraft.client.model.ModelChest; import net.minecraft.item.ItemStack; import net.minecraftforge.client.IItemRenderer; import org.lwjgl.opengl.GL11; public class ItemRenderLootBox implements IItemRenderer { private final ModelChest modelChest; public ItemRenderLootBox() { modelChest = new ModelChest(); } @Override public boolean handleRenderType(ItemStack item, ItemRenderType type) { return true; } @Override public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) { return true; } @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { switch (type) { case ENTITY: { renderLootBox(0.5F, 0.5F, 0.5F, item.getItemDamage()); break; } case EQUIPPED: { renderLootBox(1.0F, 1.0F, 1.0F, item.getItemDamage()); break; } case EQUIPPED_FIRST_PERSON: { renderLootBox(1.0F, 1.0F, 1.0F, item.getItemDamage()); break; } case INVENTORY: { renderLootBox(0.0F, 0.075F, 0.0F, item.getItemDamage()); break; } default: break; } } private void renderLootBox(float x, float y, float z, int metaData) { FMLClientHandler.instance().getClient().renderEngine.bindTexture(Textures.Model.LOOT_BOX); GL11.glPushMatrix(); //start GL11.glTranslatef(x, y, z); //size GL11.glRotatef(180, 1, 0, 0); GL11.glRotatef(-90, 0, 1, 0); modelChest.renderAll(); GL11.glPopMatrix(); //end } }