-
-
Notifications
You must be signed in to change notification settings - Fork 136
Add type check to LevelLightEngineMixin for compatibility with Create #111
Conversation
…er::getLevel returns a Level. Avoids a possible ClassCastException in StarLightInterface's constructor if a custom LightChunkGetter which does not return a Level from its getLevel is passed as an argument to the LevelLightEngine constructor.
// avoid ClassCastException in cases where custom LightChunkGetters do not return a Level from getLevel() | ||
if (chunkProvider.getLevel() instanceof Level) { | ||
this.lightEngine = new StarLightInterface(chunkProvider, hasSkyLight, hasBlockLight, (LevelLightEngine) (Object) this); | ||
} else { | ||
this.lightEngine = new StarLightInterface(null, hasSkyLight, hasBlockLight, (LevelLightEngine) (Object) this); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend moving the instanceof
check into the StarLightInterface
constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My aforementioned PR to Create has been merged (albeit manually). If this PR is also merged, Create and Starlight will at last be compatible. |
Hello! I still have a crash with Starlight and create with the StarLight version that AeiouEnigma shared in the last mentioned issue: (with Not enough crashes: https://crashy.net/WHlr6n9dlVa5sN9qHMf1) |
Could you please share exactly what you tried to do that caused the crash? Anything other than a ClassCastException when Pondering, at this point, would indicate that either I missed an important test case when making changes to Create, or that a necessary Create change was messed up when migrating some of those changes to Flywheel. Most likely this issue means there's something off about the custom world height implementation in Create, but I'll need to know exactly what you were doing, preferably with a screenshot, to produce the crash in order to be sure. |
@Matthysse please try this custom build of Create and confirm it fixes your issue. |
@AeiouEnigma yes! your build resolves indeed the crash! thanks for the quick reaction! |
The fix for that embarrassing error has been merged into Create. Now this current PR to Starlight is really and truly the last piece of the compatibility puzzle. |
Can confirm this fixed my crashes! |
Provided a Create dev can approve this, I will merge it |
As a Create developer, I approve this. ⭐ |
…:getLevel returns a Level. (#111) Avoids a possible ClassCastException in StarLightInterface's constructor if a custom LightChunkGetter which does not return a Level from its getLevel is passed as an argument to the LevelLightEngine constructor. Done for Create compatibility
One last note: Starlight 1.0.1+ won't actually be fully compatible with Create until their next release. |
I will wait to push 1.0.1 until then, as I want to verify locally it works |
I've instead decided to release an alpha build so that users can get updated beforehand, the alpha build will be marked as release once there is a corresponding compatible build of create on CF |
The new Create update just dropped, you can test v0.4c with Starlight 1.0.1 now |
This PR fixes a ClassCastException crash which occurs when using Create's Ponder feature while Starlight is installed.
Create's dependency, Flywheel, has a VirtualEmptyBlockGetter class which serves to ensure that everywhere in Create's fake world has 0 block light and 15 sky light. To accomplish this, the class uses a custom LevelLightEngine, passing to the constructor a LightChunkGetter whose getLevel method returns the VirtualEmptyBlockGetter itself, which does not inherit from Level.
Because Starlight replaces the LevelLightEngine constructor and passes the provided LightChunkGetter to the StarLightInterface constructor, where it is assumed that any provided non-null LightChunkGetter will return a Level from its getLevel method, using the mods together results in a ClassCastException when StarLightInterface's constructor attempts to cast Flywheel's VirtualEmptyBlockGetter to a Level.
Specifically, this PR changes Starlight's LevelLightEngineMixin::construct to check whether the provided LightChunkGetter's getLevel method returns an instance of Level. If it does not, the chunkProvider argument in the call to the StarLightInterface constructor is replaced with a null argument. This change avoids the ClassCastException that would otherwise result from using Create with Starlight.
Closes #45