Jump to content

[SOLVED] [1.12.2] Replacing weather renderer, raining blood!


Recommended Posts

Posted (edited)

I've been fiddling around with seasons and weather stuff, and I'm trying to change when precipitation is rendered as rain vs. snow. I don't want it to be controlled solely by biome temperature. After a bit of research, it seemed like creating my own weather renderer might be the thing to do, so I can sidestep the way vanilla relies on biome temperature to decide whether to render rain or snow. I created a class that extends IRenderHandler and just copied the vanilla code for EntityRenderer#renderRainSnow. However, the vanilla code contains a reference to a private variable called rendererUpdateCount. I don't really understand what the variable does—any insight into that would be appreciated. In vanilla, it gets updated in EntityRenderer#updateRenderer, and I assume I would need to use that value as it gets updated. Or can I, like, create my own variable and update it somehow...?

Edited by Daeruin
Updated title to reflect new problem
Posted

I think that field is being used to help animate the motion of the rain/snow.

 

It is your class so you can just make your own field with the same name. But you'll also need to update it similarly so you'll need something like the updateRenderer() method.

 

Also, note that there is also an addRainParticles() method you probably need to implement as well.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted (edited)

I created a rendererUpdateCount field in my ClientTickEvent and update it once a tick. That seemed to be the right thing to do, since the original gets updated during Minecraft#runTick. (I didn't bother with addRainParticles() since it's already called from EntityRenderer#updateRenderer.) I'm not getting any crashes or errors. However, when it rains and snows the particles are red, like it's raining blood.

 

I'm guessing this is a problem with renderUpdateCount not being the right value. At first I thought it was a problem with the texture, but after fiddling with that for a while I couldn't fix it. I also tried implementing addRainParticles()  in my ClientTickEvent, but it didn't seem to do anything.

 

Here's my IRenderHandler code, if it helps:

 

  Reveal hidden contents

 

snow particles.png

Edited by Daeruin
Posted

By playing around with the color values on the lines that look like this:

 

bufferbuilder.pos((double) l1 - d3 + 0.5D, (double) l2, (double) k1 - d4 + 0.5D).tex(0.0D, (double) k2 * 0.25D + d5).color(1.0F, 1.0F, 1.0F, 

 

I have gotten the color to change to dark red and black. Which makes me reasonably sure these lines are not the issue. I've gone back to the theory that it's some kind of texture error. Like, it can't find the textures or something. I had originally left the texture fields the same as they are in vanilla:

 

private static final ResourceLocation SNOW_TEXTURES = new ResourceLocation("textures/environment/snow.png");

 

I then tried copying the PNG files into my mod's texture folder and adding my own mod id, but that didn't work. I double checked the spelling on the folders and file names.

 

private static final ResourceLocation SNOW_TEXTURES = new ResourceLocation("primalcraft:textures/environment/snow.png");

 

Any other ideas what's going on here? I don't WANT to muck around with particles and renderers. I just want to make snow appear at reasonable times.

Posted

That's pretty cool actually. One thing about red is that it is a primary display color so makes me think that somewhere that it should be white FFFFFF is somehow FF0000 through shifting or something. But I can't see anything there.

 

I don't think it is a problem with finding the texture since the shapes of the snowflakes are correct.

 

As far as I can think, it can be a blending issue (maybe even blending from before the renderer is called if the GLState has something left over, so look at that GL stuff at the top. Secondly, it could be direct color methods but your color() methods seem to be white. Lastly it could maybe be a lighting issue, although I'm not aware of lighting changing color, but you could look at how it get lighting.

 

I'm most suspicious that the GLState is somehow blending red due to something left over in the state. However, the state is explicitly set to white with the GLStateManager.color() method call, so it is very curious as to how you're getting red. I do feel that it has something to do with blending though. Did you try to disable the blending? You can use GLStateManager.disableBlend() early on in your code (probably right after the enable call). Don't just comment out the enable call because it can possibly already be enabled and you need to make sure it is disabled.

 

One other thing for debug, when I copy code with a lot of fields with obfuscated names like j1, f3, and such, I like to go through and figure out what they do and refactor the name to something meaningful. You might find a clue as you do that.

  • Like 1

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted (edited)

Thank you so much for your help! I was starting to despair. I'm totally new to this rendering stuff and have very little idea what most of the code does. I've been trying to figure it out, but it's quite a learning curve for what I thought was going to be something simple.

 

I tried disabling blending, but there was no change.

 

I then commented out the line where the light map is enabled (enableLightmap), and like magic the rain turned blue.

 

Which makes me wonder what I'm getting out of it. Why use that method at all? I did have to replicate the light map code, because I couldn't refer to the vanilla method statically. The only thing I had to change was the reference to the lightMap texture, since the variable was private, which also forced me to create a new DynamicTexture for the light map. I've never heard of dynamic textures before, but it appears to get updated in updateLightMap(), which only seems to be used when updateTorchFlicker() sets lightmapUpdateNeeded to true. So I'm not sure why that would affect what I'm doing. Unless I need to refer to the exact DynamicTexture created in EntityRenderer?

 

I have been slowly working on refactoring the variable names, but some of the code is pretty obscure. For example, I think I have the variable names used in this line of code figured out:

 

double d5 = -((double) (PrimalClientTickEvent.rendererUpdateCount + xDistFromEntity * xDistFromEntity * 3121 + xDistFromEntity * 45238971 + zDistFromEntity * zDistFromEntity * 418711 + zDistFromEntity * 13761 & 31) + (double) partialTicks) / 32.0D * (3.0D + this.random.nextDouble());

 

But I have no idea what the math is really doing. Based on where d5 is used—in a BufferBuilder.tex() call—I think it's something to find the right part of the texture to render? But the math itself is very obscure, and I'm mostly guessing on the purpose of tex() so I don't really know what to change d5 to.

Edited by Daeruin
Posted

Sorry I don't know much about the lighting or texture buffers. I do suspect you ran into trouble when you couldn't reference the static lightmap -- I have a feeling you can't just create your own instance since I expect it contains information from a bunch of previous lighting calculations.

 

In terms of refactoring all the fields, I agree sometimes it is almost "impossible". In particular when they are randomizing in things like world generators it takes a lot of investigation to figure out why they're doing things. So don't worry about refactoring everything, but I just suggest always refactoring what you can as then you will understand more and it becomes more properly "your" code.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Well, I'm going to mark this one solved for now. Hopefully it doesn't cause trouble in the future to go without the light map enabled.

 

Thanks again for your help. I probably wouldn't have stumbled upon the answer to this one without you.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Looking for the best way to save big on your Temu purchases? Look no further than the Temu coupon code $100 off, which brings you massive savings with just a few clicks. One of the most powerful coupon codes right now is acs670886. This Temu coupon code will give maximum benefits for people residing in the USA, Canada, and European nations. With the Temu coupon $100 off and Temu 100 off coupon code, you can unlock exclusive deals and discounts that make shopping on Temu even more rewarding. What Is The Coupon Code For Temu $100 Off? Whether you're a new or returning customer, this exclusive code opens the door to amazing savings on the Temu app and website. Just apply the Temu coupon $100 off or $100 off Temu coupon and enjoy discounts you can't find anywhere else. acs670886 – Flat $100 off instantly on eligible purchases.   acs670886 – Enjoy a $100 coupon pack for multiple uses.   acs670886 – Get $100 flat discount as a welcome gift for new customers.   acs670886 – Extra $100 promo code tailored especially for existing customers.   acs670886 – $100 coupon specially designed for users in the USA and Canada.   Temu Coupon Code $100 Off For New Users In 2025 If you're signing up for the first time, you're in for the best deal Temu has to offer. New users can enjoy huge discounts simply by using our verified coupon. With the Temu coupon $100 off and Temu coupon code $100 off, your first-time shopping experience is guaranteed to be budget-friendly. acs670886 – Unlock a flat $100 discount for new users.   acs670886 – Get a $100 coupon bundle on your first order.   acs670886 – Use up to $100 in coupon benefits across multiple purchases.   acs670886 – Get free shipping to 68 countries including the USA and Canada.   acs670886 – First-time users also get an extra 30% off on any purchase.   How To Redeem The Temu Coupon $100 Off For New Customers? To redeem the Temu $100 coupon or the Temu $100 off coupon code for new users, simply follow these steps: Download the Temu app or visit the official website.   Sign up with a valid email address.   Add your favorite products to the cart.   Go to checkout and apply the coupon code acs670886.   See your total drop instantly as the coupon is applied.   Temu Coupon $100 Off For Existing Customers Already a Temu shopper? Don't worry – there’s still something special for you. By using our exclusive code, loyal users also get access to massive savings. With Temu $100 coupon codes for existing users and Temu coupon $100 off for existing customers free shipping, everyone gets a reason to smile while shopping. acs670886 – Get a $100 extra discount for existing Temu users.   acs670886 – Receive a $100 coupon bundle to use across multiple purchases.   acs670886 – Enjoy a free gift with express shipping throughout the USA and Canada.   acs670886 – Add an extra 30% discount on top of your current promotions.   acs670886 – Free shipping available to 68 countries worldwide.   How To Use The Temu Coupon Code $100 Off For Existing Customers? To redeem the Temu coupon code $100 off or Temu coupon $100 off code as an existing user, follow these easy steps: Open your Temu app or go to the official site.   Log in using your existing account credentials.   Shop as usual and add items to your cart.   Proceed to checkout and input acs670886 in the promo code section.   Enjoy the instant discount and perks that come with it.   Latest Temu Coupon $100 Off First Order If you're planning to place your first order on Temu, you're in luck. Use our code and unlock the biggest deal on your first-time purchase. With Temu coupon code $100 off first order, Temu coupon code first order, and Temu coupon code $100 off first time user, you're starting your shopping journey the right way. acs670886 – Get a flat $100 discount on your first order.   acs670886 – Apply the $100 Temu coupon code at checkout for instant savings.   acs670886 – Receive up to $100 in coupons usable over multiple orders.   acs670886 – Benefit from free shipping to over 68 countries.   acs670886 – Score an extra 30% discount on your entire first order.   How To Find The Temu Coupon Code $100 Off? Wondering how to discover verified deals? It's easier than you think. To find the best and latest Temu coupon $100 off or Temu coupon $100 off Reddit shared deals, follow these tips: Sign up for the Temu newsletter and get access to exclusive promo codes.   Follow Temu on social media platforms like Facebook, Instagram, and Twitter for real-time coupon announcements.   Visit reputable coupon-sharing websites (like ours!) to access the most up-to-date and verified codes like acs670886.   Is Temu $100 Off Coupon Legit? Yes, it absolutely is! If you're wondering whether the Temu $100 Off Coupon Legit or Temu 100 off coupon legit, we're here to clear the air. Our verified code acs670886 has been tested and confirmed to work by thousands of happy shoppers across the USA, Canada, and Europe. So, when you use this code, you're not just saving money—you're also using a 100% legit and verified deal that’s designed to help you shop smarter. Happy shopping and big savings await when you use acs670886!  
    • I have already tried other versions of MCP, from 2841 to 2860.
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • The official documentation says next to nothing and I have had no success finding reference snippets (e.g. minimap mods and other stuff that involves directly drawing to the screen). Google searches and GPT outputs reference deprecated and/or removed content from older versions. Legends speak of a layered rendering system that also has next to no documentation. Any help is appreciated. Even drawing just a single pixel is enough.
    • Записывает в консоль INTELIJ IDEA Failed to resolve all files for the configuration. ':forgeGradleUserDevPackage'. > Failed to find forge.-userdev.jar (net.minecraftforge:forge:1.12.2-14.23.5.2860). The search was conducted in the following locations.: https://maven.minecraftforge.net/net/minecraftforge/forge/1.12.2-14.23.5.2860/forge-1.12.2-14.23.5.2860-userdev.jar Possible solution: - Declare the repository that provides the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html Can anyone send me forge-1.12.2-14.23.5.2860-userdev.jar? I have already tried other versions of MCP, from 2841 to 2860.
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.