{"body":"package uk.co.haxyshideout.ashtest.events;\n\nimport com.pixelmonmod.pixelmon.Pixelmon;\nimport cpw.mods.fml.common.eventhandler.SubscribeEvent;\nimport cpw.mods.fml.common.gameevent.TickEvent;\nimport net.minecraft.client.Minecraft;\nimport net.minecraft.client.multiplayer.WorldClient;\nimport net.minecraft.client.renderer.EntityRenderer;\nimport net.minecraft.client.renderer.OpenGlHelper;\nimport net.minecraft.client.renderer.Tessellator;\nimport net.minecraft.entity.EntityLivingBase;\nimport net.minecraft.util.MathHelper;\nimport net.minecraft.util.ResourceLocation;\nimport net.minecraft.world.WorldServer;\nimport net.minecraft.world.biome.BiomeGenBase;\nimport net.minecraftforge.client.IRenderHandler;\nimport net.minecraftforge.client.event.RenderPlayerEvent;\nimport net.minecraftforge.client.event.RenderWorldEvent;\nimport net.minecraftforge.client.event.RenderWorldLastEvent;\nimport org.lwjgl.opengl.GL11;\n\nimport java.util.Random;\n\n/**\n * Created by clienthax on 31/1/2015.\n */\npublic class EventListener {\n\n\n\tfloat[] ashXCoords = null;\n\tfloat[] ashYCoords = null;\n\tint rendererUpdateCount = 0;\n\tRandom random = new Random();\n\tResourceLocation locationSnowPng = new ResourceLocation(Pixelmon.MODID, \"textures/environment/ash.png\");\n\n\n\t@SubscribeEvent\n\tpublic void onRender(RenderWorldLastEvent event) {\n\t\trenderRainSnow(event.partialTicks);\n\t}\n\n\tprotected void renderRainSnow(float p_78474_1_)\n\t{\n\n\t\tMinecraft mc = Minecraft.getMinecraft();\n\t\tEntityRenderer entityRenderer = mc.entityRenderer;\n\n\n\t\tIRenderHandler renderer = null;\n\t\tif ((renderer = mc.theWorld.provider.getWeatherRenderer()) != null)\n\t\t{\n\t\t\trenderer.render(p_78474_1_, mc.theWorld, mc);\n\t\t\treturn;\n\t\t}\n\n\t\tfloat ashStrength = 20;\n\n\t\tif (ashStrength > 0.0F)\n\t\t{\n\t\t\tentityRenderer.enableLightmap((double) p_78474_1_);\n\n\t\t\tif (this.ashXCoords == null)\n\t\t\t{\n\t\t\t\tthis.ashXCoords = new float[1024];\n\t\t\t\tthis.ashYCoords = new float[1024];\n\n\t\t\t\tfor (int i = 0; i < 32; ++i)\n\t\t\t\t{\n\t\t\t\t\tfor (int j = 0; j < 32; ++j)\n\t\t\t\t\t{\n\t\t\t\t\t\tfloat f2 = (float)(j - 16);\n\t\t\t\t\t\tfloat f3 = (float)(i - 16);\n\t\t\t\t\t\tfloat f4 = MathHelper.sqrt_float(f2 * f2 + f3 * f3);\n\t\t\t\t\t\tthis.ashXCoords[i << 5 | j] = -f3 / f4;\n\t\t\t\t\t\tthis.ashYCoords[i << 5 | j] = f2 / f4;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tEntityLivingBase entitylivingbase = mc.renderViewEntity;\n\t\t\tWorldClient worldclient = mc.theWorld;\n\t\t\tint k2 = MathHelper.floor_double(entitylivingbase.posX);\n\t\t\tint l2 = MathHelper.floor_double(entitylivingbase.posY);\n\t\t\tint i3 = MathHelper.floor_double(entitylivingbase.posZ);\n\t\t\tTessellator tessellator = Tessellator.instance;\n\t\t\tGL11.glDisable(GL11.GL_CULL_FACE);\n\t\t\tGL11.glNormal3f(0.0F, 1.0F, 0.0F);\n\t\t\tGL11.glEnable(GL11.GL_BLEND);\n\t\t\tOpenGlHelper.glBlendFunc(770, 771, 1, 0);\n\t\t\tGL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);\n\t\t\tdouble d0 = entitylivingbase.lastTickPosX + (entitylivingbase.posX - entitylivingbase.lastTickPosX) * (double)p_78474_1_;\n\t\t\tdouble d1 = entitylivingbase.lastTickPosY + (entitylivingbase.posY - entitylivingbase.lastTickPosY) * (double)p_78474_1_;\n\t\t\tdouble d2 = entitylivingbase.lastTickPosZ + (entitylivingbase.posZ - entitylivingbase.lastTickPosZ) * (double)p_78474_1_;\n\t\t\tint k = MathHelper.floor_double(d1);\n\t\t\tbyte b0 = 5;\n\n\t\t\tif (mc.gameSettings.fancyGraphics)\n\t\t\t{\n\t\t\t\tb0 = 10;\n\t\t\t}\n\n\t\t\tboolean flag = false;\n\t\t\tbyte b1 = -1;\n\t\t\tfloat f5 = (float)rendererUpdateCount + p_78474_1_;\n\n\t\t\tif (mc.gameSettings.fancyGraphics)\n\t\t\t{\n\t\t\t\tb0 = 10;\n\t\t\t}\n\n\t\t\tGL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);\n\t\t\tflag = false;\n\n\t\t\tfor (int l = i3 - b0; l <= i3 + b0; ++l)\n\t\t\t{\n\t\t\t\tfor (int i1 = k2 - b0; i1 <= k2 + b0; ++i1)\n\t\t\t\t{\n\t\t\t\t\tint j1 = (l - i3 + 16) * 32 + i1 - k2 + 16;\n\t\t\t\t\tfloat f6 = this.ashXCoords[j1] * 0.5F;\n\t\t\t\t\tfloat f7 = this.ashYCoords[j1] * 0.5F;\n\t\t\t\t\tBiomeGenBase biomegenbase = worldclient.getBiomeGenForCoords(i1, l);\n\n\t\t\t\t\tif (biomegenbase.canSpawnLightningBolt() || biomegenbase.getEnableSnow())\n\t\t\t\t\t{\n\t\t\t\t\t\tint k1 = worldclient.getPrecipitationHeight(i1, l);\n\t\t\t\t\t\tint l1 = l2 - b0;\n\t\t\t\t\t\tint i2 = l2 + b0;\n\n\t\t\t\t\t\tif (l1 < k1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tl1 = k1;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (i2 < k1)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ti2 = k1;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tfloat f8 = 1.0F;\n\t\t\t\t\t\tint j2 = k1;\n\n\t\t\t\t\t\tif (k1 < k)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tj2 = k;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tif (l1 != i2)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tthis.random.setSeed((long)(i1 * i1 * 3121 + i1 * 45238971 ^ l * l * 418711 + l * 13761));\n\t\t\t\t\t\t\tfloat f9 = biomegenbase.getFloatTemperature(i1, l1, l);\n\t\t\t\t\t\t\tfloat f10;\n\t\t\t\t\t\t\tdouble d4;\n\n\t\t\t\t\t\t\t//do biome check here\n\t\t\t\t\t\t\tif (1 == 1)\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tif (b1 != 1)\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tif (b1 >= 0)\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\ttessellator.draw();\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\tb1 = 1;\n\t\t\t\t\t\t\t\t\tmc.getTextureManager().bindTexture(locationSnowPng);\n\t\t\t\t\t\t\t\t\ttessellator.startDrawingQuads();\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tf10 = ((float)(this.rendererUpdateCount & 511) + p_78474_1_) / 512.0F;\n\t\t\t\t\t\t\t\tfloat f16 = this.random.nextFloat() + f5 * 0.01F * (float)this.random.nextGaussian();\n\t\t\t\t\t\t\t\tfloat f11 = this.random.nextFloat() + f5 * (float)this.random.nextGaussian() * 0.001F;\n\t\t\t\t\t\t\t\td4 = (double)((float)i1 + 0.5F) - entitylivingbase.posX;\n\t\t\t\t\t\t\t\tdouble d5 = (double)((float)l + 0.5F) - entitylivingbase.posZ;\n\t\t\t\t\t\t\t\tfloat f14 = MathHelper.sqrt_double(d4 * d4 + d5 * d5) / (float)b0;\n\t\t\t\t\t\t\t\tfloat f15 = 1.0F;\n\t\t\t\t\t\t\t\ttessellator.setBrightness((worldclient.getLightBrightnessForSkyBlocks(i1, j2, l, 0) * 3 + 15728880) / 4);\n\t\t\t\t\t\t\t\ttessellator.setColorRGBA_F(f15, f15, f15, ((1.0F - f14 * f14) * 0.3F + 0.5F) * ashStrength);\n\t\t\t\t\t\t\t\ttessellator.setTranslation(-d0 * 1.0D, -d1 * 1.0D, -d2 * 1.0D);\n\t\t\t\t\t\t\t\ttessellator.addVertexWithUV((double)((float)i1 - f6) + 0.5D, (double)l1, (double)((float)l - f7) + 0.5D, (double)(0.0F * f8 + f16), (double)((float)l1 * f8 / 4.0F + f10 * f8 + f11));\n\t\t\t\t\t\t\t\ttessellator.addVertexWithUV((double)((float)i1 + f6) + 0.5D, (double)l1, (double)((float)l + f7) + 0.5D, (double)(1.0F * f8 + f16), (double)((float)l1 * f8 / 4.0F + f10 * f8 + f11));\n\t\t\t\t\t\t\t\ttessellator.addVertexWithUV((double)((float)i1 + f6) + 0.5D, (double)i2, (double)((float)l + f7) + 0.5D, (double)(1.0F * f8 + f16), (double)((float)i2 * f8 / 4.0F + f10 * f8 + f11));\n\t\t\t\t\t\t\t\ttessellator.addVertexWithUV((double)((float)i1 - f6) + 0.5D, (double)i2, (double)((float)l - f7) + 0.5D, (double)(0.0F * f8 + f16), (double)((float)i2 * f8 / 4.0F + f10 * f8 + f11));\n\t\t\t\t\t\t\t\ttessellator.setTranslation(0.0D, 0.0D, 0.0D);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (b1 >= 0)\n\t\t\t{\n\t\t\t\ttessellator.draw();\n\t\t\t}\n\n\t\t\tGL11.glEnable(GL11.GL_CULL_FACE);\n\t\t\tGL11.glDisable(GL11.GL_BLEND);\n\t\t\tGL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);\n\t\t\tentityRenderer.disableLightmap((double) p_78474_1_);\n\t\t}\n\t}\n\n\n}\n","name":"","extension":"","url":"https://www.irccloud.com/pastebin/v5DRCuVu","modified":1422666611,"id":"v5DRCuVu","size":6566,"lines":203,"own_paste":false,"theme":"","date":1422666611}