Advertisement
Guest User

RenderPlsmf

a guest
Dec 10th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.39 KB | None | 0 0
  1. package Oskiek.FlagmodEurope.tiles.render;
  2.  
  3. import org.lwjgl.opengl.GL11;
  4.  
  5. import Oskiek.FlagmodEurope.model.ModelFlag;
  6. import cpw.mods.fml.relauncher.Side;
  7. import cpw.mods.fml.relauncher.SideOnly;
  8. import net.minecraft.block.Block;
  9. import net.minecraft.client.renderer.OpenGlHelper;
  10. import net.minecraft.client.renderer.Tessellator;
  11. import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
  12. import net.minecraft.entity.EntityLiving;
  13. import net.minecraft.item.ItemStack;
  14. import net.minecraft.tileentity.TileEntity;
  15. import net.minecraft.util.MathHelper;
  16. import net.minecraft.util.ResourceLocation;
  17. import net.minecraft.world.World;
  18.  
  19. @SideOnly(Side.CLIENT)
  20. public class RenderPlsmf extends TileEntitySpecialRenderer {
  21.  
  22.     private ModelFlag model;
  23.     private ResourceLocation texture = new ResourceLocation("flagmodreborn:textures/blocks/Poland.png");
  24.    
  25.    
  26.    
  27.     public RenderPlsmf()
  28.     {
  29.         model = new ModelFlag();
  30.     }
  31.  
  32.  
  33.    
  34.    
  35.     private void adjustRotatePivotViaMeta(World world, int x, int y, int z)
  36.     {
  37.             int meta = world.getBlockMetadata(x, y, z);
  38.             GL11.glPushMatrix();
  39.             GL11.glRotatef(meta * (-90), 0.0F, 0.0F, 1.0F);
  40.             GL11.glPopMatrix();
  41.     }
  42.    
  43.     @Override
  44.     public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale)
  45.     {
  46.     //The PushMatrix tells the renderer to "start" doing something.
  47.             GL11.glPushMatrix();
  48.     //This is setting the initial location.
  49.             GL11.glTranslatef((float) x + 0.5F, (float) y + 0.2F, (float) z + 0.5F);
  50.          
  51.             bindTexture(texture);
  52.      //This rotation part is very important! Without it, your model will render upside-down! And for some reason you DO need PushMatrix again!                      
  53.             GL11.glPushMatrix();
  54.             GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
  55.            
  56.                 int rotation = 0;
  57.                 switch (te.getBlockMetadata() % 4) {
  58.                     case 0:
  59.                         rotation = 270;
  60.                         break;
  61.                     case 1:
  62.                         rotation = 0;
  63.                         break;
  64.                     case 2:
  65.                         rotation = 90;
  66.                         break;
  67.                     case 3:
  68.                         rotation = 180;
  69.                         break;
  70.                 }
  71.               GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
  72.                
  73.                
  74.     //A reference to your Model file. Again, very important.
  75.             this.model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
  76.     //Tell it to stop rendering for both the PushMatrix's
  77.             GL11.glPopMatrix();
  78.             GL11.glPopMatrix();
  79.     }
  80.  
  81.     //Set the lighting stuff, so it changes it's brightness properly.      
  82.     private void adjustLightFixture(World world, int i, int j, int k, Block block)
  83.     {
  84.             Tessellator tess = Tessellator.instance;
  85.             float brightness = block.getLightOpacity(world, i, j, k);
  86.             int skyLight = world.getLightBrightnessForSkyBlocks(i, j, k, 0);
  87.             int modulousModifier = skyLight % 65536;
  88.             int divModifier = skyLight / 65536;
  89.             tess.setColorOpaque_F(brightness, brightness, brightness);
  90.             OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit,  (float) modulousModifier,  divModifier);
  91.     }
  92.    
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement