Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. @SubscribeEvent
  2. public static void renderChatIndicator(RenderPlayerEvent.Post event) {
  3. EntityPlayer player = (EntityPlayer) event.getEntity();
  4. RenderManager renderManager = Minecraft.getMinecraft().getRenderManager();
  5.  
  6. if (player.isInvisible()) return;
  7.  
  8. IChatIndicator chatIndicatorCapability = player.getCapability(CapabilityChatIndicator.CHAT_INDICATOR_CAPABILITY, null);
  9.  
  10. if (chatIndicatorCapability != null) {
  11. int indicatorType = chatIndicatorCapability.get();
  12. double distance = player.getDistanceSq(renderManager.renderViewEntity);
  13.  
  14. if (distance <= INDICATOR_MAX_RANGE && indicatorType != 0) {
  15. ItemStack itemstack = null;
  16.  
  17. switch (indicatorType) {
  18. case 1: // 1 - BASIC CHAT
  19. itemstack = new ItemStack(Items.PAPER);
  20. break;
  21. case 2: // 2 - ROLEPLAY CHAT
  22. itemstack = new ItemStack(Items.FEATHER);
  23. break;
  24. case 3: // 3 - COMMAND CHAT
  25. itemstack = new ItemStack(Items.ENCHANTED_BOOK);
  26. break;
  27. default:
  28. break;
  29. }
  30.  
  31. if (itemstack != null) {
  32. GlStateManager.pushMatrix();
  33. {
  34. double height = event.getY() + player.height + 0.40D - (player.isSneaking() ? 0.15D : 0.0D);
  35. float viewerPitch = (renderManager.options.thirdPersonView == 2 ? -1 : 1) * renderManager.playerViewX;
  36.  
  37. GlStateManager.translate((float) event.getX(), (float) height, (float) event.getZ());
  38. GlStateManager.glNormal3f(0.0F, 1.0F, 0.0F);
  39. GlStateManager.rotate(-renderManager.playerViewY, 0.0F, 1.0F + event.getPartialRenderTick(), 0.0F);
  40. GlStateManager.rotate(viewerPitch, 1.0F + event.getPartialRenderTick(), 0.0F, 0.0F);
  41. GlStateManager.scale(0.5F, 0.5F, 0.5F);
  42. GlStateManager.disableLighting();
  43. Minecraft.getMinecraft().getRenderItem().renderItem(itemstack, ItemCameraTransforms.TransformType.NONE);
  44. GlStateManager.enableLighting();
  45. }
  46. GlStateManager.popMatrix();
  47. }
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement