Advertisement
Guest User

Untitled

a guest
Dec 29th, 2015
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.97 KB | None | 0 0
  1. /**
  2.  * This class was created by <Vazkii>. It's distributed as
  3.  * part of the Botania Mod. Get the Source Code in github:
  4.  * https://github.com/Vazkii/Botania
  5.  *
  6.  * Botania is Open Source and distributed under the
  7.  * Botania License: http://botaniamod.net/license.php
  8.  *
  9.  * File Created @ [Jul 8, 2014, 10:58:46 PM (GMT)]
  10.  */
  11. package vazkii.botania.client.render.tile;
  12.  
  13. import java.util.Random;
  14.  
  15. import net.minecraft.block.state.IBlockState;
  16. import net.minecraft.client.Minecraft;
  17. import net.minecraft.client.renderer.BlockRendererDispatcher;
  18. import net.minecraft.client.renderer.GlStateManager;
  19. import net.minecraft.client.renderer.ItemRenderer;
  20. import net.minecraft.client.renderer.Tessellator;
  21. import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
  22. import net.minecraft.client.renderer.texture.TextureMap;
  23. import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
  24. import net.minecraft.client.resources.model.IBakedModel;
  25. import net.minecraft.item.ItemStack;
  26. import net.minecraft.tileentity.TileEntity;
  27.  
  28. import net.minecraft.util.BlockPos;
  29. import net.minecraftforge.client.model.ISmartBlockModel;
  30. import org.lwjgl.opengl.GL11;
  31.  
  32. import vazkii.botania.client.core.handler.ClientTickHandler;
  33. import vazkii.botania.client.model.FloatingFlowerModel;
  34. import vazkii.botania.client.model.ModelMiniIsland;
  35. import vazkii.botania.common.block.decor.IFloatingFlower;
  36.  
  37. public class RenderTileFloatingFlower extends TileEntitySpecialRenderer {
  38.  
  39.     private static final ModelMiniIsland model = new ModelMiniIsland();
  40.  
  41.     @Override
  42.     public void renderTileEntityAt(TileEntity tile, double d0, double d1, double d2, float t, int digProgress) {
  43.         BlockRendererDispatcher brd = Minecraft.getMinecraft().getBlockRendererDispatcher();
  44.         IFloatingFlower flower = (IFloatingFlower) tile;
  45.         GlStateManager.pushMatrix();
  46.         GlStateManager.color(1F, 1F, 1F, 1F);
  47.         GlStateManager.translate(d0, d1, d2);
  48.  
  49.         double worldTime = tile.getWorld() == null ? 0 : (double) (ClientTickHandler.ticksInGame + t);
  50.         if(tile.getWorld() != null)
  51.             worldTime += new Random(tile.getPos().hashCode()).nextInt(1000);
  52.  
  53.         GlStateManager.translate(0.5F, 0F, 0.5F);
  54.         GlStateManager.rotate(-((float) worldTime * 0.5F), 0F, 1F, 0F);
  55.         GlStateManager.translate(-0.5F, 0F, -0.5F);
  56.  
  57.         if(tile.getWorld() != null) {
  58.             GlStateManager.translate(0F, (float) Math.sin(worldTime * 0.05F) * 0.1F, 0F);
  59.             GlStateManager.rotate(4F * (float) Math.sin(worldTime * 0.04F), 1F, 0F, 0F);
  60.         }
  61.  
  62.         Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
  63.         GlStateManager.pushMatrix();
  64.  
  65.         IBlockState state = tile.getWorld().getBlockState(tile.getPos());
  66.         state = state.getBlock().getExtendedState(state, tile.getWorld(), tile.getPos());
  67.         IBakedModel ibakedmodel = FloatingFlowerModel.INSTANCE.handleBlockState(state);
  68.  
  69.         brd.getBlockModelRenderer().renderModelBrightness(ibakedmodel, state, 1.0F, true);
  70.  
  71.         GlStateManager.popMatrix();
  72.         GlStateManager.popMatrix();
  73.  
  74.     }
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement