ModTheSpire
ModTheSpire copied to clipboard
SpirePatch condition argument
Adds condition argument to SpirePatch, which allows a boolean value to determine whether to apply the patch. Adds the possibility to lower file sizes and load times. An example could be using Loader.DEBUG
.
What is the use of this? Your example of Loader.DEBUG
won't work as it's not a compile-time constant.
Oh, that's quite embarrassing. I have not worked personally with java's annotation system, I was not aware that arguments had to be compile-time constant. The thought process was to use this value to avoid a patch if it was not necessary, as a more versatile version of the "optional" argument. By using a condition at run-time, resources would not have to be used to perform a patch, which could improve loading time noticeably depending on the number of patches. For instance, if a modder had to change something for a render that could be avoided using said condition, it could preserve performance, or if multiple mods being run have similar patches, instead of having inefficient and ugly checks for other mods so errors don't occur. For instance, if three mods were installed which all had the same fix, they would each have to check for each other. The next best option would be somehow checking if a specific method was already modified to have the same effective result as a new patch being applied, but I don't think that would be possible.
@GreatThane This could be possible if you use another annotation for each specific case, e.g. @DebugPatch for your Loader.Debug example. This won't be very extensible or dynamic though