Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.53 KB | None | 0 0
  1. public class RenderFallout extends Render<EntityFalloutRain> {
  2.  
  3.     private Minecraft mc;
  4.     private Random random = new Random();
  5.     float[] rainXCoords;
  6.     float[] rainYCoords;
  7.     private int rendererUpdateCount;
  8.     long lastTime = System.nanoTime();
  9.     private static final ResourceLocation falloutTexture = new ResourceLocation(RefStrings.MODID, "textures/entity/fallout.png");
  10.    
  11.     public RenderFallout(RenderManager renderManager) {
  12.         super(renderManager);
  13.         this.mc = Minecraft.getMinecraft();
  14.         this.rainXCoords = new float[1024];
  15.         this.rainYCoords = new float[1024];
  16.         for (int i = 0; i < 32; ++i)
  17.         {
  18.             for (int j = 0; j < 32; ++j)
  19.             {
  20.                 float f = (float)(j - 16);
  21.                 float f1 = (float)(i - 16);
  22.                 float f2 = MathHelper.sqrt(f * f + f1 * f1);
  23.                 this.rainXCoords[i << 5 | j] = -f1 / f2;
  24.                 this.rainYCoords[i << 5 | j] = f / f2;
  25.             }
  26.         }
  27.     }
  28.    
  29.     @Override
  30.     public void doRender(EntityFalloutRain entity, double x, double y, double z, float entityYaw, float partialTicks) {
  31.         System.out.println(entity + " " + entity.getScale());
  32.         Entity ent = this.mc.getRenderViewEntity();
  33.         Vec3 vector = Vec3.createVectorHelper(ent.posX - entity.posX,
  34.                 ent.posY - entity.posY, ent.posZ - entity.posZ);
  35.        
  36.         double d = vector.lengthVector();
  37.        
  38.         if (d <= entity.getScale()) {
  39.             rendererUpdateCount++;
  40.             long time = System.nanoTime();
  41.             float t = (time - lastTime) / 50000000;
  42.             if (t <= 1.0F)
  43.                 renderRainSnow(t);
  44.             else
  45.                 renderRainSnow(1.0F);
  46.  
  47.             lastTime = time;
  48.         }
  49.     }
  50.    
  51.     protected void renderRainSnow(float p_78474_1_) {
  52.         MutableBlockPos pos = new BlockPos.MutableBlockPos();
  53.         IRenderHandler renderer = null;
  54.         if ((renderer = this.mc.world.provider.getWeatherRenderer()) != null) {
  55.             renderer.render(p_78474_1_, this.mc.world, mc);
  56.             return;
  57.         }
  58.  
  59.         // float f1 = this.mc.theWorld.getRainStrength(p_78474_1_);
  60.  
  61.         float f1 = 1;
  62.  
  63.         if (f1 > 0.0F) {
  64.             // this.enableLightmap((double)p_78474_1_);
  65.  
  66.             if (this.rainXCoords == null) {
  67.                 this.rainXCoords = new float[1024];
  68.                 this.rainYCoords = new float[1024];
  69.  
  70.                 for (int i = 0; i < 32; ++i) {
  71.                     for (int j = 0; j < 32; ++j) {
  72.                         float f2 = j - 16;
  73.                         float f3 = i - 16;
  74.                         float f4 = MathHelper.sqrt(f2 * f2 + f3 * f3);
  75.                         this.rainXCoords[i << 5 | j] = -f3 / f4;
  76.                         this.rainYCoords[i << 5 | j] = f2 / f4;
  77.                     }
  78.                 }
  79.             }
  80.  
  81.             Entity entitylivingbase = this.mc.getRenderViewEntity();
  82.             WorldClient worldclient = this.mc.world;
  83.             int k2 = MathHelper.floor(entitylivingbase.posX);
  84.             int l2 = MathHelper.floor(entitylivingbase.posY);
  85.             int i3 = MathHelper.floor(entitylivingbase.posZ);
  86.             Tessellator tessellator = Tessellator.getInstance();
  87.             GL11.glDisable(GL11.GL_CULL_FACE);
  88.             GL11.glNormal3f(0.0F, 1.0F, 0.0F);
  89.             GL11.glEnable(GL11.GL_BLEND);
  90.             OpenGlHelper.glBlendFunc(770, 771, 1, 0);
  91.             GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
  92.             double d0 = entitylivingbase.lastTickPosX
  93.                     + (entitylivingbase.posX - entitylivingbase.lastTickPosX) * p_78474_1_;
  94.             double d1 = entitylivingbase.lastTickPosY
  95.                     + (entitylivingbase.posY - entitylivingbase.lastTickPosY) * p_78474_1_;
  96.             double d2 = entitylivingbase.lastTickPosZ
  97.                     + (entitylivingbase.posZ - entitylivingbase.lastTickPosZ) * p_78474_1_;
  98.             int k = MathHelper.floor(d1);
  99.             byte b0 = 5;
  100.  
  101.             if (this.mc.gameSettings.fancyGraphics) {
  102.                 b0 = 10;
  103.             }
  104.  
  105.             boolean flag = false;
  106.             byte b1 = -1;
  107.             float f5 = this.rendererUpdateCount + p_78474_1_;
  108.  
  109.             if (this.mc.gameSettings.fancyGraphics) {
  110.                 b0 = 10;
  111.             }
  112.  
  113.             GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
  114.             flag = false;
  115.  
  116.             for (int l = i3 - b0; l <= i3 + b0; ++l) {
  117.                 for (int i1 = k2 - b0; i1 <= k2 + b0; ++i1) {
  118.                     int j1 = (l - i3 + 16) * 32 + i1 - k2 + 16;
  119.                     float f6 = this.rainXCoords[j1] * 0.5F;
  120.                     float f7 = this.rainYCoords[j1] * 0.5F;
  121.                     pos.setPos(i1, 50, l);
  122.                     Biome biomegenbase = worldclient.getBiomeForCoordsBody(pos);
  123.  
  124.                     if (true) {
  125.                         int k1 = worldclient.getPrecipitationHeight(pos).getY();
  126.                         int l1 = l2 - b0;
  127.                         int i2 = l2 + b0;
  128.  
  129.                         if (l1 < k1) {
  130.                             l1 = k1;
  131.                         }
  132.  
  133.                         if (i2 < k1) {
  134.                             i2 = k1;
  135.                         }
  136.  
  137.                         float f8 = 1.0F;
  138.                         int j2 = k1;
  139.  
  140.                         if (k1 < k) {
  141.                             j2 = k;
  142.                         }
  143.  
  144.                         if (l1 != i2) {
  145.                             pos.setY(l1);
  146.                             this.random.setSeed(i1 * i1 * 3121 + i1 * 45238971 ^ l * l * 418711 + l * 13761);
  147.                             float f9 = biomegenbase.getTemperature(pos);
  148.                             float f10;
  149.                             double d4;
  150.  
  151.                             /*
  152.                              * if (false) { if (b1 != 0) { if (b1 >= 0) {
  153.                              * tessellator.draw(); }
  154.                              *
  155.                              * b1 = 0;
  156.                              * this.mc.getTextureManager().bindTexture(this.
  157.                              * falloutTexture); tessellator.startDrawingQuads();
  158.                              * //System.out.println("Called!"); }
  159.                              *
  160.                              * f10 = ((float)(this.rendererUpdateCount + i1 * i1
  161.                              * * 3121 + i1 * 45238971 + l * l * 418711 + l *
  162.                              * 13761 & 31) + p_78474_1_) / 32.0F * (3.0F +
  163.                              * this.random.nextFloat()); double d3 =
  164.                              * (double)((float)i1 + 0.5F) -
  165.                              * entitylivingbase.posX; d4 = (double)((float)l +
  166.                              * 0.5F) - entitylivingbase.posZ; float f12 =
  167.                              * MathHelper.sqrt_double(d3 * d3 + d4 * d4) /
  168.                              * (float)b0; float f13 = 1.0F;
  169.                              * tessellator.setBrightness(worldclient.
  170.                              * getLightBrightnessForSkyBlocks(i1, j2, l, 0));
  171.                              * tessellator.setColorRGBA_F(f13, f13, f13, ((1.0F
  172.                              * - f12 * f12) * 0.5F + 0.5F) * f1);
  173.                              * tessellator.setTranslation(-d0 * 1.0D, -d1 *
  174.                              * 1.0D, -d2 * 1.0D);
  175.                              * tessellator.addVertexWithUV((double)((float)i1 -
  176.                              * f6) + 0.5D, (double)l1, (double)((float)l - f7) +
  177.                              * 0.5D, (double)(0.0F * f8), (double)((float)l1 *
  178.                              * f8 / 4.0F + f10 * f8));
  179.                              * tessellator.addVertexWithUV((double)((float)i1 +
  180.                              * f6) + 0.5D, (double)l1, (double)((float)l + f7) +
  181.                              * 0.5D, (double)(1.0F * f8), (double)((float)l1 *
  182.                              * f8 / 4.0F + f10 * f8));
  183.                              * tessellator.addVertexWithUV((double)((float)i1 +
  184.                              * f6) + 0.5D, (double)i2, (double)((float)l + f7) +
  185.                              * 0.5D, (double)(1.0F * f8), (double)((float)i2 *
  186.                              * f8 / 4.0F + f10 * f8));
  187.                              * tessellator.addVertexWithUV((double)((float)i1 -
  188.                              * f6) + 0.5D, (double)i2, (double)((float)l - f7) +
  189.                              * 0.5D, (double)(0.0F * f8), (double)((float)i2 *
  190.                              * f8 / 4.0F + f10 * f8));
  191.                              * tessellator.setTranslation(0.0D, 0.0D, 0.0D); }
  192.                              * else
  193.                              */
  194.                             {
  195.                                 if (b1 != 1) {
  196.                                     if (b1 >= 0) {
  197.                                         tessellator.draw();
  198.                                     }
  199.                                     b1 = 1;
  200.                                     this.mc.getTextureManager().bindTexture(RenderFallout.falloutTexture);
  201.                                     tessellator.getBuffer().begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);;
  202.                                 }
  203.  
  204.                                 f10 = ((this.rendererUpdateCount & 511) + p_78474_1_) / 512.0F;
  205.                                 float f16 = this.random.nextFloat() + f5 * 0.01F * (float) this.random.nextGaussian();
  206.                                 float f11 = this.random.nextFloat() + f5 * (float) this.random.nextGaussian() * 0.001F;
  207.                                 d4 = i1 + 0.5F - entitylivingbase.posX;
  208.                                 double d5 = l + 0.5F - entitylivingbase.posZ;
  209.                                 float f14 = MathHelper.sqrt(d4 * d4 + d5 * d5) / b0;
  210.                                 float f15 = 1.0F;
  211.                                 BufferBuilder buf = tessellator.getBuffer();
  212.                                 int bright = (int)(worldclient.getLightBrightness(pos.setPos(i1, j2, l)) * 3 + 15728880 / 4);
  213.                             //  buf.putBrightness4(bright, bright, bright, bright);
  214.                                 buf.color(f15, f15, f15, ((1.0F - f14 * f14) * 0.3F + 0.5F) * f1);
  215.                                 buf.setTranslation(-d0 * 1.0D, -d1 * 1.0D, -d2 * 1.0D);
  216.                                
  217.                                 buf.pos(i1 - f6 + 0.5D, l1, l - f7 + 0.5D).tex(0.0F * f8 + f16, l1 * f8 / 4.0F + f10 * f8 + f11).endVertex();
  218.                                 buf.pos(i1 + f6 + 0.5D, l1, l + f7 + 0.5D).tex(1.0F * f8 + f16, l1 * f8 / 4.0F + f10 * f8 + f11).endVertex();
  219.                                 buf.pos(i1 + f6 + 0.5D, i2, l + f7 + 0.5D).tex(1.0F * f8 + f16, i2 * f8 / 4.0F + f10 * f8 + f11).endVertex();
  220.                                 buf.pos(i1 - f6 + 0.5D, i2, l - f7 + 0.5D).tex(0.0F * f8 + f16, i2 * f8 / 4.0F + f10 * f8 + f11).endVertex();
  221.                                 buf.setTranslation(0.0D, 0.0D, 0.0D);
  222.                             }
  223.                         }
  224.                     }
  225.                 }
  226.             }
  227.  
  228.             if (b1 >= 0) {
  229.                 tessellator.draw();
  230.                 // System.out.println("Fired!");
  231.             }
  232.  
  233.             GL11.glEnable(GL11.GL_CULL_FACE);
  234.             GL11.glDisable(GL11.GL_BLEND);
  235.             GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
  236.             // this.disableLightmap((double)p_78474_1_);
  237.         }
  238.     }
  239.  
  240.     @Override
  241.     protected ResourceLocation getEntityTexture(EntityFalloutRain entity) {
  242.         return null;
  243.     }
  244.  
  245. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement