Maven
<dependency>
<groupId>com.github.cryptomorin</groupId>
<artifactId>XSeries</artifactId>
<version>13.0.0</version>
</dependency>
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("com.github.cryptomorin:XSeries:13.0.0")
}
Important
Don't forget to shade the library.
Happy new year!
Important
XReflection
About
For the past few months I've been working on XReflection extensively. XReflection first started as a small group of classes
that's designed for Minecraft in mind specifically. It makes other classes that require reflection much easier.
However, I've been improving it a lot that simplifies this process, each simplification is in a stage. There are a total of
five stages and currently 4 of them are implemented. All these steps were mostly a proof-of-concept for the 5th and final stage.
This final stage allows developers to seamlessly use NMS/CraftBukkit classes across multiple versions, using real constructors, fields and methods, whether private, protected or public, with compile-time checked types and almost zero overhead.
Future Plans
XSeries packaged JAR is currently 700kb and 200kb belongs to the XReflection classes.
Since XReflection is becoming too big for this project, and frankly, even becoming an offtopic project,
I'm planning to split it into its own project. However, XSeries will
continue to use the stage I and stage II of XReflection as a dependency, but unnecessary classes will be excluded to decrease
the JAR file size. This new project will use Gradle as its build system as it's going to be multimodule with its own custom
IntelliJ plugin to make things easier. For now, XReflection will remain in XSeries until the preparations are done.
Paper's Reflection Remapper
Also, I've just saw this after finishing the stage IV (ASM generated classes), but
it seems like Paper also has a similar project named Reflection Remapper
which uses a similar interface-based system as well. However, there are some features that is missing from that project:
- ReflectionRemapper uses raw Java proxies (similar to Stage III - ReflectiveProxy in our project) but we also have ASM-generated classes as well
which will improve performance significantly with almost zero overhead. - ReflectionRemapper only supports mappings for a single version.
- ReflectionRemapper doesn't support proxy objects for return types or parameters.
- ReflectionRemapper doesn't have isInstance(), instance(), and getTargetClass(). I also plan to add a way to check whether
a method is supported or not, however ReflectionRemapper doesn't have this feature. - ReflectionRemapper doesn't have a proxy class generator utility.
- ReflectionRemapper cannot use real classes with fields, constructors and methods. However, this is going to be added to XRefleciton.
There are some other projects that are also similar to this as well, but none of them have the complete feature set that I have in mind.
Any suggestions or improvements are welcome to the current XReflection systems while it lasts here.
-
Added experimental ReflectiveConstraint API for XReflection to make targets more precise.
-
Added XAccessFlag used mainly for ReflectiveConstraints.
-
Fixed
ENTITY_EXPERIENCE_ORB_TOUCH
v1.9 missing value for XSound. -
Improved ReflectionParser.
-
Improved Unit Tests.
-
Added
@Contract
annotations to most APIs. -
[XBiome] Fixed an issue with world min/max height.
-
[XTag] Fixed
INVENTORY_NOT_DISPLAYABLE
for wheat. -
[XReflection] Using the suffix support for JetBrains
@Language
annotation, we no longer need to add semicolons or{}
at the end of string APIs. Other than the readability improvement, this results in a slight performance
improvement as well, since fewer characters are needed for parsing. -
More compliance with common best code practices.
- Replaced
RuntimeException
s with suitable exceptions. Mostly defaulted toIllegalStateException
when the error is too generic. - Replaced
Cloneable
and itsclone()
methods withcopy()
- Refactored some parts of the code for better readability.
- Not all of these practices make sense, so I skipped some of them.
- Replaced
-
Added experimental ReflectiveProxy API (XReflection Stage III - Proxification) which is has a significant readability advantage but
has a significant
performance disadvantage which makes it unusable in most sitautions, however this prototype will allow us to
develop the next reflection API (Stage IV) which will have significant advantage in terms of both readability and
performance if it's successful. -
Added experimental XReflectASM API (XReflection Stage IV - ASMification) which is the same as ReflectiveProxy which massive performance
advantages that beat raw reflection because of generated code. However, this performance advantage is not as perfect for
inaccessible class members. This is because of Java's Jigsaw project, and we need to use some really hacky workarounds to
make this work for inaccessible methods. ReadXReflectASM#MAGIC_ACCESSOR_IMPL
field for more info.
Once this is done, we can enter XReflection Stage V. It comes with an XProxifier which currently must be used programmatically. -
Added JMH Benchmark which is not 100% reliable due to:
- Running inside IDE testing environment which can be affected by many external factors instead of using a JAR.
- Not running in forked mode. We need to retain the server state.
- Being run using Maven's exec plugin which might be able to affect our benchmarks.