I've patched bugs in the base game before. For the longest time, if you didn't have a My Games/Terraria folder in your Documents folder, the game would crash when trying to create the settings file. I patched that with the original releases of RomTerraria.
Fortunately, I've got a good place to handle injecting my replacement method. LiquidRenderer.PrepareDraw just calls the internal method.
I'm going to do this patch in two phases.
Phase two will take significantly longer. I'm going to rewrite LiquidRenderer.InternalPrepareDraw. It's a bit over 400 lines of, well, not good code. I mean, it's dereferencing to memory before a pointer. If I was going to be a total dick, I could craft a world file that could potentially turn into a native code exploit. Fortunately, I'm not a total dick. This will take me a lot longer to do and may end up moot if they fix the issue before my rewrite is done.
I've only got this weekend to do this, so here goes nothing.
Update 11/24/2016, 11:57am: Well, it's not going to happen this morning, but I am working on it...
Update 11/24/2016, 12:20pm: I've gotten the replacement class building as a standalone DLL. I've got to do IL-patches to replace 14 instances of the class in six methods in two classes. I'm going to try to get that done before I have to leave for my afternoon social obligation.
Update 11/24/2016, 4:38pm: I'm back from my social obligation and am resuming my coding. I've almost got the replacement working.
Update 11/24/2016, 9:57pm: Stopping for the night. I've got my replacement class patched in and am working on debugging, but I'm exhausted. That said, making PrepareDraw a no-op has other side effects and isn't a good solution, so I'm dropping that part of the plan.
Update 11/25/2016, 12:18pm: Taking a lunch break. Since I'm afraid I'm going to have to do this kind of thing again in the future, I've created a general purpose class replacement system. Will resume testing once I am fed.
Update 11/25/2016, 1:03pm: I'm now able to reproduce the crash inside my custom class inside the debugger. Should help me fix it.
Update 11/25/2016, 1:09pm: Well, it's good that I made the class replacement system generic, because the crash is NOT caused by the code I suspected. It appears that something else is running amok around memory. Give me a bit of time to figure out the appropriate memory layout so I can figure out which object is immediately before this one in the heap.
Update 11/25/2016, 1:30pm: I've got a 1.2GB memory dump that I'm manually going through. I'd be going faster, but the .NET memory tools require a minimum .NET version of 4.5 and Terraria is compiled to 4.0.
Update 11/25/2016, 2:25pm: Good news: managed to stop the game from crashing. Bad news: filled blocks of water aren't rendering. Still going.
Update 11/25/2016, 3:53pm: I've checked my current code into Github. Still trying to figure out why full blocks don't render. Note that this doesn't truly fix the memory overwrite, but it leaves the old 160KB object around as a "safety buffer." I'm going to try for another hour, then call it a day. I've still got work to do around the house.
Update 11/25/2016, 5:51pm: Part of the problem is that the version of Telerik JustDecompile that I'm using doesn't properly decompile unsafe code evidently. Testing a fix now.
Update 11/25/2016 6:00pm: Adding padding around the wave bank let me run with water effects for almost ten seconds before the game crashed in a spectacular fashion. Looks like something is hardcoded with a max resolution and when you go above that resolution, it starts walking over memory it shouldn't. Dinner shortly, then more research
Update 11/25/2016 6:09pm: Here's a test version. This is not guaranteed to work, but appears to be working in my limited testing. Please let me know if it crashes for you.
Update 12/6/2016 1:13pm: v18.104.22.168 was just released. The test version was compiled and tested against v22.214.171.124, and may not work with v126.96.36.199. I'm at work for several more hours. Let me know if I need to address anything after the fix.
Update 12/19/2016 9:35pm: Added LAA support code. Trying to fix an issue with rendering water that surfaced at certain resolutions for v188.8.131.52 before releasing an update.
Update 12/25/2016 3:58pm: Build for v184.108.40.206 here. You'll have to set up your settings again.