Advertisement
Guest User

Tile Entity Renderer

a guest
Jun 3rd, 2016
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.51 KB | None | 0 0
  1. package com.monsterhunter.client.render.blocks;
  2.  
  3. import com.monsterhunter.block.MaterialChestBlock;
  4. import com.monsterhunter.tileentity.MaterialChestTileEntity;
  5.  
  6. import net.minecraft.client.model.ModelChest;
  7. import net.minecraft.client.model.ModelLargeChest;
  8. import net.minecraft.client.renderer.GlStateManager;
  9. import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
  10. import net.minecraft.tileentity.TileEntity;
  11. import net.minecraft.util.EnumFacing;
  12. import net.minecraft.util.ResourceLocation;
  13. /**
  14.  * NOT IN USE YET
  15.  * @author Landon
  16.  *
  17.  */
  18. public class MaterialChestTileEntityRenderer extends TileEntitySpecialRenderer<MaterialChestTileEntity> {
  19.  
  20.     private static final ResourceLocation texture = new ResourceLocation("textures/entity/materialChest.png");
  21.     private ModelChest chestModel = new ModelLargeChest();
  22.  
  23.     public void renderTileEntityAt(MaterialChestTileEntity te, double x, double y, double z, float partialTicks, int destroyStage){
  24.         GlStateManager.enableDepth();
  25.         GlStateManager.depthFunc(515);
  26.         GlStateManager.depthMask(true);
  27.  
  28.         ModelChest model = chestModel;
  29.  
  30.         if(destroyStage >= 0) {
  31.             this.bindTexture(DESTROY_STAGES[destroyStage]);
  32.             GlStateManager.matrixMode(5890);
  33.             GlStateManager.pushMatrix();
  34.             GlStateManager.scale(8.0F, 4.0F, 1.0F);
  35.             GlStateManager.translate(0.0625F, 0.0625F, 0.0625F);
  36.             GlStateManager.matrixMode(5888);
  37.         } else {
  38.             this.bindTexture(texture);
  39.         }
  40.  
  41.        EnumFacing facing = te.getWorld().getBlockState(te.getPos()).getValue(MaterialChestBlock.FACING);
  42.  
  43.        int rotation;
  44.  
  45.        switch(facing) {
  46.        case SOUTH: rotation = 0; break;
  47.        case WEST:  rotation = 90; break;
  48.        case NORTH: rotation = 180; break;
  49.        default:    rotation = 270; break;
  50.        }
  51.  
  52.        GlStateManager.rotate((float)rotation, 0.0F, 1.0F, 0.0F);
  53.        GlStateManager.translate(-0.5F, -0.5F, -0.5F);
  54.        float f = te.prevLidAngle + (te.lidAngle - te.prevLidAngle) * partialTicks;
  55.  
  56.        f = 1.0F - f;
  57.        f = 1.0F - f * f * f;
  58.        model.chestLid.rotateAngleX = -(f * ((float)Math.PI / 2F));
  59.        model.renderAll();
  60.        GlStateManager.disableRescaleNormal();
  61.        GlStateManager.popMatrix();
  62.        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
  63.  
  64.        if (destroyStage >= 0)
  65.        {
  66.            GlStateManager.matrixMode(5890);
  67.            GlStateManager.popMatrix();
  68.            GlStateManager.matrixMode(5888);
  69.        }
  70.  
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement