Fluid Physics [Forge]

Fluid Physics [Forge]

233k Downloads

Optifine Mixin Crash 1.16.5 forge

Kaleidio opened this issue ยท 19 comments

commented

Just carrying over this bug for you to remember. I haven't heard from you in a while and it's got me worried. I can't make a new trailer until I have confirmation your mod will launch at all.

Crashing on initialization.

"Reason:
Type 'net/minecraft/block/AbstractBlock$AbstractBlockState' (current frame, stack[2]) is not assignable to 'net/minecraft/fluid/FluidState'"

commented

I found out that it only crashes if Optifine, FluidPhysics and ForgeEndertech is enabled together.

Oh - make sure you have "Fast Render" turned off in Optifine, it rarely works in modded environments. Everything else is fine though, so far and in my experience (even Render Regions).

These two are entirely irrelevant. The crash here is caused by something in the actual fluid class mixins, not the rendering portion of it.

commented

OKAY SO, as if by PURE MAGIC, upgrading from Optifine G7 to G8 fixed LITERALLY EVERYTHING. AND shaders work with fast render and render regions.

Seems like I can close this issue..

@LolHens you will need to notify users Optifine G8 will be most stable with your mod and Optifine G7 can break.

commented

I found out that it only crashes if Optifine, FluidPhysics and ForgeEndertech is enabled together.

I have these in my modpack and everything works OK (Optifine G8, all mods latest as time of writing). Maybe it's been fixed? Or it's a different mod.

Oh - make sure you have "Fast Render" turned off in Optifine, it rarely works in modded environments. Everything else is fine though, so far and in my experience (even Render Regions).

commented

Thank you for testing! I will put up a notice for this.

commented

Sorry, didn't have the time to look at this yet. Might get to this tomorrow.

commented

I had been wondering for a while if a third mod was causing a conflict yes...thankfully you found the issue. Hopefully a fix can be found.

commented

I found out that it only crashes if Optifine, FluidPhysics and ForgeEndertech is enabled together. If I disable one of these three it works...

commented

What I find odd about this is that FluidPhysics doesn't even modify the method that is mentioned in the logs (func_227034_b_) in any way.
I found out that ForgeEndertech applies a transformation to this method in coremods/random_tick_hook.js:

	var targetBlock = {
		'type' : 'METHOD',
		'class' : 'net/minecraft/block/AbstractBlock$AbstractBlockState',
		'methodName' : resolveName('func_227034_b_'), // randomTick
		'methodDesc' : '(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraft/util/math/BlockPos;Ljava/util/Random;)V'
	}

Currently I don't know why this crash only happens in conjunction with FluidPhysics...

commented

Okay so don't ask me what's going on but I've found something on the Optifine side through sheer brute force.
If you delete patch\srg\net\minecraft\crash from the Optifine jar it works and it doesn't seem to impact any features.
Sadly I don't know how to fix you modpack situation with this knowledge.

commented

Aww man, that really sucks! I really loved how this mod behaved.

I'll release an update to my pack without it then. Do let me know if some miracle such as the optifine dev helping you out or a random fix occurs (we both know what sort of diamond in a hay mountain that is), but thank you for trying your best!

commented

From what I can tell both FluidPhysics and ForgeEndertech seem to be doing things correctly. Maybe I can find out what Optifine is doing here. Optifine is particularly weird because it doesn't even have a transformation for that class. Maybe it is doing some global transformations. Also Optifine not being open-source doesn't make it easier.

commented

It might be useful for you to reach out to EnderLanky if you have further trouble. Maybe with the knowledge of your codebases you both can figure out which override both of your mods would be sharing under the hierarchy a global override optifine has.

commented

I just spotted the SurfaceBuilder class in the pathtrace, is that the class optifine is overriding and maybe the order of overrides for generating ocean biomes is messing up there? I did have things like Render Regions active in the options...

commented

image

commented

I think they are all just errors because the method (func_227034_b_ = randomTick) at the bottom of the trace is broken:

[17:41:23] [main/INFO]: [java.lang.Throwable:printEnclosedStackTrace:709]: Caused by: java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    net/minecraft/block/AbstractBlock$AbstractBlockState.func_227034_b_(Lnet/minecraft/world/server/ServerWorld;Lnet/minecraft/util/math/BlockPos;Ljava/util/Random;)V @3: invokestatic
  Reason:
    Type 'net/minecraft/block/AbstractBlock$AbstractBlockState' (current frame, stack[2]) is not assignable to 'net/minecraft/fluid/FluidState'
  Current Frame:
    bci: @3
    flags: { }
    locals: { 'net/minecraft/block/AbstractBlock$AbstractBlockState', 'net/minecraft/world/server/ServerWorld', 'net/minecraft/util/math/BlockPos', 'java/util/Random' }
    stack: { 'net/minecraft/world/server/ServerWorld', 'net/minecraft/util/math/BlockPos', 'net/minecraft/block/AbstractBlock$AbstractBlockState' }
  Bytecode:
    0x0000000: 2b2c 2ab8 02a0 9900 04b1 2ab6 02a6 2b2c
    0x0000010: 2a2d b602 acb1                         
  Stackmap Table:
    same_frame(@10)
commented

This is the mixin in FluidPhysics that modifies that class. It doesn't even modify that method:
https://github.com/LolHens/mc-fluid-physics/blob/master/forge-1.16.4/src/main/scala/de/lolhens/minecraft/fluidphysics/mixin/AbstractBlockStateMixin.java

If you edit the fluidphysics.mixins.json in the FluidPhysics jar file and remove the AbstractBlockStateMixin it works but water will not be pushable by pistons anymore.

commented

Second option is to modify the coremods/random_tick_hook.js and remove these lines:

		'randomTickBlock' : {
			'target' : targetBlock,
			'transformer' : function(method) {
				insertInstructionsBeforeAll(method, instructions.concat(insnInvokeVirtual(getBlockState), insnCallHandler(handlerBlock), instructionsIfTrueReturn()));
				return method;
			}
		},

I don't know which effect this has on the mod but it cannot react to random block ticks anymore.

commented

I am still trying to find the part in Optifine that is responsible but that will probably take a few days.

commented

That's quite alright, I get how strenuous such an optifine bug can be. I can be patient.