Advertisement
Guest User

LightningBoltRendererNew

a guest
Mar 26th, 2020
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.35 KB | None | 0 0
  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by Fernflower decompiler)
  4. //
  5.  
  6. package com.tazering.DarkStorms.entities;
  7.  
  8. import com.mojang.blaze3d.matrix.MatrixStack;
  9. import com.mojang.blaze3d.vertex.IVertexBuilder;
  10. import java.util.Random;
  11. import net.minecraft.client.renderer.IRenderTypeBuffer;
  12. import net.minecraft.client.renderer.Matrix4f;
  13. import net.minecraft.client.renderer.RenderType;
  14. import net.minecraft.client.renderer.entity.EntityRenderer;
  15. import net.minecraft.client.renderer.entity.EntityRendererManager;
  16. import net.minecraft.client.renderer.entity.LightningBoltRenderer;
  17. import net.minecraft.client.renderer.texture.AtlasTexture;
  18. import net.minecraft.entity.effect.LightningBoltEntity;
  19. import net.minecraft.util.ResourceLocation;
  20. import net.minecraftforge.api.distmarker.Dist;
  21. import net.minecraftforge.api.distmarker.OnlyIn;
  22.  
  23. @OnlyIn(Dist.CLIENT)
  24. public class DarkStormsLightningBoltRenderer extends LightningBoltRenderer {
  25.  
  26. public DarkStormsLightningBoltRenderer(EntityRendererManager renderManagerIn) {
  27. super(renderManagerIn);
  28. }
  29.  
  30. public void render(DarkStormsLightningBoltEntity entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn) {
  31. float[] afloat = new float[8];
  32. float[] afloat1 = new float[8];
  33. float f = 0.0F;
  34. float f1 = 0.0F;
  35. Random random = new Random(entityIn.boltVertex);
  36.  
  37. for(int i = 7; i >= 0; --i) {
  38. afloat[i] = f;
  39. afloat1[i] = f1;
  40. f += (float)(random.nextInt(11) - 5);
  41. f1 += (float)(random.nextInt(11) - 5);
  42. }
  43.  
  44. IVertexBuilder ivertexbuilder = bufferIn.getBuffer(RenderType.getLightning());
  45. Matrix4f matrix4f = matrixStackIn.getLast().getMatrix();
  46.  
  47. for(int j = 0; j < 4; ++j) {
  48. Random random1 = new Random(entityIn.boltVertex);
  49.  
  50. for(int k = 0; k < 3; ++k) {
  51. int l = 7;
  52. int i1 = 0;
  53. if (k > 0) {
  54. l = 7 - k;
  55. }
  56.  
  57. if (k > 0) {
  58. i1 = l - 2;
  59. }
  60.  
  61. float f2 = afloat[l] - f;
  62. float f3 = afloat1[l] - f1;
  63.  
  64. for(int j1 = l; j1 >= i1; --j1) {
  65. float f4 = f2;
  66. float f5 = f3;
  67. if (k == 0) {
  68. f2 += (float)(random1.nextInt(11) - 5);
  69. f3 += (float)(random1.nextInt(11) - 5);
  70. } else {
  71. f2 += (float)(random1.nextInt(31) - 15);
  72. f3 += (float)(random1.nextInt(31) - 15);
  73. }
  74.  
  75. float f6 = 0.5F;
  76. float f7 = 0.45F;
  77. float f8 = 0.45F;
  78. float f9 = 0.5F;
  79. float f10 = 0.1F + (float)j * 0.2F;
  80. if (k == 0) {
  81. f10 = (float)((double)f10 * ((double)j1 * 0.1D + 1.0D));
  82. }
  83.  
  84. float f11 = 0.1F + (float)j * 0.2F;
  85. if (k == 0) {
  86. f11 *= (float)(j1 - 1) * 0.1F + 1.0F;
  87. }
  88.  
  89. func_229116_a_(matrix4f, ivertexbuilder, f2, f3, j1, f4, f5, 0.45F, 0.45F, 0.5F, f10, f11, false, false, true, false);
  90. func_229116_a_(matrix4f, ivertexbuilder, f2, f3, j1, f4, f5, 0.45F, 0.45F, 0.5F, f10, f11, true, false, true, true);
  91. func_229116_a_(matrix4f, ivertexbuilder, f2, f3, j1, f4, f5, 0.45F, 0.45F, 0.5F, f10, f11, true, true, false, true);
  92. func_229116_a_(matrix4f, ivertexbuilder, f2, f3, j1, f4, f5, 0.45F, 0.45F, 0.5F, f10, f11, false, true, false, false);
  93. }
  94. }
  95. }
  96.  
  97. }
  98.  
  99. private static void func_229116_a_(Matrix4f p_229116_0_, IVertexBuilder p_229116_1_, float p_229116_2_, float p_229116_3_, int p_229116_4_, float p_229116_5_, float p_229116_6_, float p_229116_7_, float p_229116_8_, float p_229116_9_, float p_229116_10_, float p_229116_11_, boolean p_229116_12_, boolean p_229116_13_, boolean p_229116_14_, boolean p_229116_15_) {
  100. p_229116_1_.pos(p_229116_0_, p_229116_2_ + (p_229116_12_ ? p_229116_11_ : -p_229116_11_), (float)(p_229116_4_ * 16), p_229116_3_ + (p_229116_13_ ? p_229116_11_ : -p_229116_11_)).color(p_229116_7_, p_229116_8_, p_229116_9_, 0.3F).endVertex();
  101. p_229116_1_.pos(p_229116_0_, p_229116_5_ + (p_229116_12_ ? p_229116_10_ : -p_229116_10_), (float)((p_229116_4_ + 1) * 16), p_229116_6_ + (p_229116_13_ ? p_229116_10_ : -p_229116_10_)).color(p_229116_7_, p_229116_8_, p_229116_9_, 0.3F).endVertex();
  102. p_229116_1_.pos(p_229116_0_, p_229116_5_ + (p_229116_14_ ? p_229116_10_ : -p_229116_10_), (float)((p_229116_4_ + 1) * 16), p_229116_6_ + (p_229116_15_ ? p_229116_10_ : -p_229116_10_)).color(p_229116_7_, p_229116_8_, p_229116_9_, 0.3F).endVertex();
  103. p_229116_1_.pos(p_229116_0_, p_229116_2_ + (p_229116_14_ ? p_229116_11_ : -p_229116_11_), (float)(p_229116_4_ * 16), p_229116_3_ + (p_229116_15_ ? p_229116_11_ : -p_229116_11_)).color(p_229116_7_, p_229116_8_, p_229116_9_, 0.3F).endVertex();
  104. }
  105.  
  106. public ResourceLocation getEntityTexture(LightningBoltEntity entity) {
  107. return AtlasTexture.LOCATION_BLOCKS_TEXTURE;
  108. }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement