LapisSea

Untitled

Aug 21st, 2016
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1.     private boolean flag;
  2.    
  3.     @SubscribeEvent(priority=EventPriority.HIGHEST)
  4.     public void renderEntityPre(RenderPlayerEvent.Pre e){
  5.         EntityPlayer player=e.getEntityPlayer();
  6.        
  7.         Entity en=player.getRidingEntity();
  8.         if(en instanceof EntitySquid){
  9.             EntitySquid squid=(EntitySquid)en;
  10.             flag=true;
  11.            
  12.             OpenGLM.pushMatrix();
  13.            
  14.             OpenGLM.translate(0, 3/16F, 0);//not sure why this is needed for fixing center of rotation (if you are using translate below)
  15.            
  16.             //PartialTicksUtil.calculate(prevPos, pos) is equal to prevPos+(pos-prevPos)*partialTicks to smooth out transformation
  17.             //OpenGLM.rotateX,Y,Z https://github.com/LapisSea/Magiology/blob/1.9/src/main/java/com/magiology/util/statics/OpenGLM.java#L129-L146
  18.             OpenGLM.rotateY(-PartialTicksUtil.calculate(squid.prevRenderYawOffset,squid.renderYawOffset));//-\
  19.             OpenGLM.rotateX(-PartialTicksUtil.calculate(squid.prevSquidPitch,squid.squidPitch)+90);//--------===> match squid rotation
  20.             OpenGLM.rotateZ(-PartialTicksUtil.calculate(squid.prevSquidYaw,squid.squidYaw));//---------------/
  21.            
  22.             //fix gap between riding entity and
  23.             OpenGLM.translate(0, -3/16F, 0);
  24.            
  25.            
  26.            
  27.         }else flag=false;
  28.     }
  29.    
  30.     @SubscribeEvent(priority=EventPriority.HIGHEST)
  31.     public void renderPlayerPost(RenderPlayerEvent.Post e){
  32.         if(flag){
  33.             OpenGLM.popMatrix();
  34.         }
  35.     }
Add Comment
Please, Sign In to add comment