Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.plasmablazer.electroniceng.client.renderer.tileentity;
- import com.plasmablazer.electroniceng.block.BlockDeconstructionTable;
- import com.plasmablazer.electroniceng.init.ModItems;
- import com.plasmablazer.electroniceng.tileentity.TileDeconstructionTable;
- import net.minecraft.block.Block;
- import net.minecraft.client.Minecraft;
- import net.minecraft.client.renderer.GlStateManager;
- import net.minecraft.client.renderer.Tessellator;
- import net.minecraft.client.renderer.WorldRenderer;
- import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
- import net.minecraft.entity.item.EntityItem;
- import net.minecraft.item.ItemStack;
- import net.minecraft.tileentity.TileEntity;
- import org.lwjgl.opengl.GL11;
- /**
- * Electronic Engineering (Minecraft Mod)
- * Copyright (C) 2014 Jack Bentley
- * <p/>
- * This program 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.
- * <p/>
- * This program 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.
- * <p/>
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
- public class RendererDeconstructionTable extends TileEntitySpecialRenderer
- {
- TileDeconstructionTable tile;
- ItemStack stackWrench = new ItemStack(ModItems.basicWrench);
- EntityItem entityWrench = new EntityItem(Minecraft.getMinecraft().theWorld, 0D, 0D, 0D);
- EntityItem entityInput = new EntityItem(Minecraft.getMinecraft().theWorld, 0D, 0D, 0D);
- public RendererDeconstructionTable()
- {
- }
- @Override
- public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick, int destroyStage)
- {
- Block block = tileEntity.getBlockType();
- if(!(block instanceof BlockDeconstructionTable))
- return;
- tile = (TileDeconstructionTable) tileEntity;
- int metadata = block.getMetaFromState(tileEntity.getWorld().getBlockState(tileEntity.getPos()));
- renderWrench(x, y, z, metadata);
- renderInput(x, y, z, metadata);
- }
- private void renderWrench(double x, double y, double z, int metadata)
- {
- entityWrench.setEntityItemStack(stackWrench);
- GL11.glPushMatrix();
- this.entityWrench.hoverStart = 0.0F;
- GL11.glDisable(GL11.GL_LIGHTING);
- WorldRenderer renderer = Tessellator.getInstance().getWorldRenderer();
- //renderer.setBrightness(15728880);
- float xOffset = 0.0F;
- float zOffset = 0.0F;
- switch (metadata)
- {
- case 0:
- xOffset += 0.5F;
- zOffset -= 0.1875F;
- break;
- case 1:
- xOffset += 1.1875F;
- zOffset += 0.5F;
- break;
- case 2:
- xOffset += 0.5F;
- zOffset += 1.1875F;
- break;
- case 3:
- xOffset -= 0.175F;
- zOffset += 0.4875;
- break;
- }
- GL11.glTranslatef((float) x + xOffset, (float) y + 1F, (float) z + zOffset);
- GL11.glRotatef(metadata * -90F, 0, 1, 0);
- GL11.glRotatef(180, 0, 1, 1);
- GL11.glScalef(2.0F, 2.0F, 2.0F);
- Minecraft.getMinecraft().getRenderManager().renderEntityWithPosYaw(entityWrench, 0.0D, 0.0D, 0.0D, 2F, 0.0F);
- GL11.glEnable(GL11.GL_LIGHTING);
- GL11.glPopMatrix();
- }
- private void renderInput(double x, double y, double z, int metadata)
- {
- if (tile.getStackInSlot(tile.SLOT_INPUT) != null)
- {
- entityInput.setEntityItemStack(tile.getStackInSlot(tile.SLOT_INPUT));
- GL11.glPushMatrix();
- this.entityInput.hoverStart = 0.0F;
- GL11.glDisable(GL11.GL_LIGHTING);
- WorldRenderer renderer = Tessellator.getInstance().getWorldRenderer();
- //renderer.setBrightness(15728880);
- GL11.glTranslatef((float) x + 0.5F, (float) y + 0.8125F, (float) z + 0.5F);
- GL11.glRotatef(metadata * - 90F, 0, 1, 0);
- Minecraft.getMinecraft().getRenderManager().renderEntityWithPosYaw(entityInput, 0.0D, 0.0D, 0.0D, 2F, 0.0F);
- GL11.glEnable(GL11.GL_LIGHTING);
- GL11.glPopMatrix();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement